Beispiel #1
0
def data_clear(inputs):
    """Clears the database."""
    inputs['job'] = 'clear'
    run_neo4j(inputs, publish=True)
    # get PID setting
    settings = read_settings(inputs['fp'] + '/settings.json')
    new_pid = settings['pid']
    pub.sendMessage('pid', msg=new_pid)
    pub.sendMessage('update', msg='Completed database operations!')
Beispiel #2
0
def data_starter(inputs):
    """Starts up database and uploads specified files. """
    # first check if process already exists
    inputs['job'] = 'upload'
    run_neo4j(inputs, publish=True)
    # get PID setting
    settings = read_settings(inputs['fp'] + '/settings.json')
    new_pid = settings['pid']
    pub.sendMessage('pid', msg=new_pid)
    pub.sendMessage('update', msg='Completed database operations!')
Beispiel #3
0
def massoc(massoc_args):
    """
    Main function for running massoc. 
    :param massoc_args: Parameters generated through massoc_parser.
    :return: 
    """
    if 'input' in massoc_args:
        logger.info('Running input module. ')
        get_input(massoc_args)
    if 'network' in massoc_args:
        logger.info('Running network inference module. ')
        run_network(massoc_args)
    if 'database' in massoc_args:
        logger.info('Working on Neo4j database. ')
        run_neo4j(massoc_args)
    if 'netstats' in massoc_args:
        logger.info('Performing network analysis on Neo4j database. ')
        run_netstats(massoc_args)
    if 'metastats' in massoc_args:
        logger.info('Performing metadata analysis on Neo4j database. ')
        run_metastats(massoc_args)
    logger.info('Completed tasks! ')
Beispiel #4
0
 def test_run_netstats(self):
     """
     Checks whether combine_data returns
     a batch object if inputs are supplied.
     """
     inputs = {
         'biom_file': [(testloc[0] + '/data/test.biom')],
         'cluster': None,
         'otu_meta': None,
         'prefix': None,
         'sample_data': None,
         'split': None,
         'tax_table': None,
         'fp': testloc[0],
         'otu_table': None,
         'tools': ['spiec-easi', 'conet'],
         'spiec': None,
         'spar': None,
         'conet': (os.path.dirname(massoc.__file__)[:-6] + 'tests\\CoNet3'),
         'conet_bash': None,
         'spar_pval': None,
         'spar_boot': None,
         'levels': ['family'],
         'prev': 20,
         'min': None,
         'rar': None,
         'name': ['test'],
         'cores': None,
         'address': 'bolt://localhost:7687',
         'username': '******',
         'password': '******',
         'quit': False,
         'clear': False,
         'write': False,
         'add': False,
         'output': 'network',
         'logic': ['union', 'difference', 'intersection'],
         'neo4j': (os.path.dirname(massoc.__file__)[:-6] + 'tests\\neo4j')
     }
     write_biom_table(testbiom['test'],
                      fmt='hdf5',
                      filepath=(inputs['biom_file'][0]))
     get_input(inputs)
     inputs['settings'] = inputs['fp'] + '/settings.json'
     run_network(inputs)
     inputs['job'] = 'start'
     run_neo4j(inputs)
     inputs['job'] = 'upload'
     run_neo4j(inputs)
     run_netstats(inputs)
     inputs['job'] = 'clear'
     run_neo4j(inputs)
     inputs['job'] = 'quit'
     run_neo4j(inputs)
     test = Path(inputs['fp'] + "/difference_network.graphml")
     self.assertTrue(test.is_file())
     call(("rm " + inputs['biom_file'][0]))
     call(("rm " + inputs['fp'] + "/settings.json"))
     call(("rm " + inputs['fp'] + "/test_family.hdf5"))
     call(("rm " + inputs['fp'] + "/test_otu.hdf5"))
     call(("rm " + inputs['fp'] + "/conet_test_family.txt"))
     call(("rm " + inputs['fp'] + "/spiec-easi_test_family.txt"))
     call(("rm " + inputs['fp'] + "/network.graphml"))
     call(("rm " + inputs['fp'] + "/difference_network.graphml"))
     call(("rm " + inputs['fp'] + "/union_network.graphml"))
     call(("rm " + inputs['fp'] + "/intersection_network.graphml"))
Beispiel #5
0
def data_closer(inputs):
    """Adds edge list of node properties to Neo4j database."""
    inputs['job'] = 'quit'
    run_neo4j(inputs, publish=True)
    sleep(3)
    pub.sendMessage('update', msg='Completed database operations!')
Beispiel #6
0
def data_adder(inputs):
    """Adds edge list of node properties to Neo4j database."""
    run_neo4j(inputs, publish=True)
    pub.sendMessage('update', msg='Completed database operations!')
Beispiel #7
0
def data_writer(inputs):
    """Exports GraphML file."""
    inputs['job'] = 'write'
    run_neo4j(inputs, publish=True)
    pub.sendMessage('update', msg='Completed database operations!')