Beispiel #1
0
def massoc_worker(inputs):
    """
    Alternative version of massoc's main pipe.
    Uses publisher to send messages instead of sys.stdout.write.
    """
    get_input(inputs, publish=True)
    run_network(inputs, publish=True)
Beispiel #2
0
 def test_run_network(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
     }
     write_biom_table(testbiom['test'],
                      fmt='hdf5',
                      filepath=(inputs['biom_file'][0]))
     get_input(inputs)
     inputs['settings'] = inputs['fp'] + '/settings.json'
     run_network(inputs)
     test = Path(inputs['fp'] + "/conet_family_test.txt")
     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"))
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"))