def __init__(self, username=None, password=None, server=None, authSource='admin', src_database='datanator', dest_database=None, max_entries=float('inf'), verbose=True, src_collection='sabio_compound', dest_collection=None, cache_dir=None): ''' Args: src_database (:obj: `str`): name of database in which source collections reside ''' self.mongo_manager = mongo_util.MongoUtil(MongoDB=server, username=username, password=password, authSource=authSource, db=src_database) self.file_manager = file_util.FileUtil() self.chem_manager = chem_util.ChemUtil() self.collation = Collation(locale='en', strength=CollationStrength.SECONDARY) self.verbose = verbose self.max_entries = max_entries self.src_collection = src_collection
def __init__(self, cache_dirname=None, MongoDB=None, replicaSet=None, db=None, verbose=False, max_entries=float('inf'), username=None, password=None, authSource='admin', meta_loc=None): self.cache_dirname = cache_dirname self.verbose = verbose self.MongoDB = MongoDB self.replicaSet = replicaSet self.max_entries = max_entries self.username = username self.password = password self.authSource = authSource self.meta_loc = meta_loc super(MetabolitesMeta, self).__init__(cache_dirname=cache_dirname, MongoDB=MongoDB, replicaSet=replicaSet, db=db, verbose=verbose, max_entries=max_entries, username=username, password=password, authSource=authSource) self.frequency = 50 self.chem_manager = chem_util.ChemUtil() self.file_manager = file_util.FileUtil() self.ymdb_query = query_xmdb.QueryXmdb(username=username, password=password, server=MongoDB, authSource=authSource, database=db, collection_str='ymdb', readPreference='nearest') self.ecmdb_query = query_xmdb.QueryXmdb(username=username, password=password, server=MongoDB, authSource=authSource, database=db, collection_str='ecmdb', readPreference='nearest') self.collation = Collation('en', strength=CollationStrength.SECONDARY) self.client, self.db, self.collection = self.con_db('metabolites_meta')
def main(): db = 'datanator' username = datanator.config.core.get_config()['datanator']['mongodb']['user'] password = datanator.config.core.get_config()['datanator']['mongodb']['password'] server = datanator.config.core.get_config()['datanator']['mongodb']['server'] port = datanator.config.core.get_config()['datanator']['mongodb']['port'] replSet = datanator.config.core.get_config()['datanator']['mongodb']['replSet'] manager = CalcTanimoto( MongoDB=server, replicaSet=replSet, db=db, verbose=True, password=password, username=username) chem_manager = chem_util.ChemUtil() # manager.many_to_many(field1 = 'inchi', field2 = 'inchi') # one-time update for adp inchi = 'InChI=1S/C10H15N5O10P2/c11-8-5-9(13-2-12-8)15(3-14-5)10-7(17)6(16)4(24-10)1-23-27(21,22)25-26(18,19)20/h2-4,6-7,10,16-17H,1H2,(H,21,22)(H2,11,12,13)(H2,18,19,20)/t4-,6-,7-,10-/m1/s1' sorted_coeff, sorted_inchi = manager.one_to_many(inchi) _, _, collection = manager.con_db('metabolites_meta') for key, val in zip(sorted_inchi, sorted_coeff): dic = {key: val} collection.update_one({'inchi': inchi}, {'$push': {'similar_compounds': dic} })
def __init__(self, db=None, MongoDB=None, cache_directory=None, verbose=False, max_entries=float('inf'), replicaSet=None, username=None, password=None, authSource='admin'): ''' Attributes: cache_directory: JSON file (converted from sqlite) directory db: mongodb database name MongoDB: MongoDB server address and login e.g. 'mongodb://mongo:27017/' ''' self.db = db self.MongoDB = MongoDB self.cache_directory = cache_directory self.verbose = verbose self.max_entries = max_entries self.collection_str = 'sabio_rk_old' super(SabioRkNoSQL, self).__init__(cache_dirname=cache_directory, MongoDB=MongoDB, replicaSet=replicaSet, db=db, verbose=verbose, max_entries=max_entries, username=username, password=password, authSource=authSource) self.client, self.db_obj, self.collection = self.con_db( self.collection_str) self.sabio_reaction_entries = self.db_obj['sabio_reaction_entries'] self.kegg_collection = self.db_obj['kegg_orthology'] self.sabiork_manager = query_sabiork.QuerySabio( MongoDB=MongoDB, db=db, collection_str='sabio_rk', verbose=verbose, max_entries=max_entries, username=username, password=password, authSource=authSource) self.protein_manager = query_protein.QueryProtein( username=username, password=password, server=MongoDB, authSource=authSource, database=db, max_entries=max_entries, verbose=verbose, collection_str='uniprot', readPreference='nearest') self.ec = self.db_obj['ec'] self.chem_manager = chem_util.ChemUtil() self.tax_manager = query_taxon_tree.QueryTaxonTree(username=username, MongoDB=MongoDB, password=password) self.file_manager = file_util.FileUtil()
def setUpClass(cls): cls.cache_dirname = tempfile.mkdtemp() cls.src = chem_util.ChemUtil()