from bioflow.neo4j_db.GraphDeclarator import DatabaseGraph from bioflow.utils.log_behavior import get_logger from bioflow.neo4j_db.db_io_routines import stable_get_all log = get_logger(__name__) def print_node_look_up_by_id(domain, search_legacy_id): """ Looks up a node by legacy ID and prints it's access url. The lookup is a case-sensitive strict match. :param domain: Node type of the form of DatabaseGraph.Object :param search_legacy_id: requested legacy ID :return: list of the items found """ accumulator = [] lookup_generator = domain.index.lookup(ID=search_legacy_id) if not lookup_generator: print "nothing found" if lookup_generator: for item in lookup_generator: print item accumulator.append(item) return accumulator def count_nodes(domain): """ Stupid counter that gets the number of items in a given domain
import numpy as np from scipy.stats import gaussian_kde from matplotlib import pyplot as plt from scipy import histogram2d from csv import reader as csv_reader from bioflow.main_configs import interactome_rand_samp_db from bioflow.utils.log_behavior import get_logger from bioflow.molecular_network.InteractomeInterface import InteractomeInterface from bioflow.algorithms_bank.conduction_routines import perform_clustering from bioflow.main_configs import Dumps # from bioflow.algorithms_bank.conduction_routines import get_current_through_nodes from matplotlib.cm import get_cmap log = get_logger(__name__) interactome_interface_instance = InteractomeInterface(True, True) interactome_interface_instance.fast_load() md5_hash = interactome_interface_instance.md5_hash() print "samples found to test against:\t %s" % interactome_rand_samp_db.find({'size': 2, 'sys_hash': md5_hash, 'sparse_rounds': False}).count() essential_genes_bulbs_ids = [] with open(Dumps.analysis_set_bulbs_ids, 'r') as source: reader = csv_reader(source)
from mock import Mock as MagicMock from bioflow.utils.log_behavior import get_logger log = get_logger('DB_IO_Mocks @ unittests') log.debug('Mocking DB_IO module') def look_up_annotation_set(supplied_list): return supplied_list, [(elt, '') for elt in supplied_list], ['' for _ in supplied_list]
""" Tests the logger behavior """ import unittest import os from bioflow.main_configs import log_location from bioflow.utils.general_utils.high_level_os_io import wipe_dir from bioflow.utils.log_behavior import get_logger log = get_logger('LoggerTester @ unittests') class TestLogs(unittest.TestCase): @classmethod def setUpClass(cls): log.debug('This is a debug test') log.info('This is an info logging test') log.warning('This is a warning test') log.error('This is an error test') log.critical('This is a critical test') @classmethod def tearDownClass(cls): wipe_dir(log_location) def test_file_creation(self): self.assertTrue(os.path.isdir(log_location)) def test_low_level_logs(self): with open(os.path.join(log_location, 'debug.log'), 'r') as source_file: contents = ''.join(source_file.read())
from mock import Mock as MagicMock from bioflow.utils.log_behavior import get_logger log = get_logger('DB_IO_Mocks @ unittests') log.debug('Mocking DB_IO module') def look_up_annotation_set(supplied_list): return supplied_list, [(elt, '') for elt in supplied_list ], ['' for _ in supplied_list]