3.1.1.1. datanator_api.query package¶
3.1.1.1.1. Submodules¶
3.1.1.1.2. datanator_api.query.front_end_query module¶
3.1.1.1.3. datanator_api.query.query_metabolites_meta module¶
-
class
datanator_api.query.query_metabolites_meta.
QueryMetabolitesMeta
(cache_dirname=None, MongoDB=None, replicaSet=None, db=None, collection_str='metabolites_meta', verbose=False, max_entries=inf, username=None, password=None, authSource='admin')[source]¶ Bases:
datanator_api.query.query_nosql.DataQuery
Queries specific to metabolites_meta collection
-
get_ids_from_hash
(hashed_inchi)[source]¶ Given a hashed inchi string, find its corresponding m2m_id and/or ymdb_id :param hashed_inchi: string of hashed inchi
Returns: - dictionary of ids and their keys
- {‘m2m_id’: …, ‘ymdb_id’: …}
Return type: result
-
get_metabolite_hashed_inchi
(compounds)[source]¶ Given a list of compound name(s) Return the corresponding hashed inchi string :param compounds: [‘ATP’, ‘2-Ketobutanoate’]
Returns: [‘3e23df….’, ‘7666ffa….’] Return type: hashed_inchi
-
get_metabolite_inchi
(compounds)[source]¶ Given a list of compound name(s) Return the corrensponding inchi string :param compounds: list of compounds :param [‘ATP’, ‘2-Ketobutanoate’]:
Returns: [‘….’, ‘InChI=1S/C4H6O3/c1-2-3(5)4(6)7/…’]
-
get_metabolite_name_by_hash
(compounds)[source]¶ Given a list of hashed inchi, return a list of name (one of the synonyms) for each compound :param compounds: list of compounds in hashed_inchi format
Returns: - list of names
- [name, name, name]
Return type: result
-
get_metabolite_similar_compounds
(compounds, num=0, threshold=0)[source]¶ Given a list of compound names Return the top num number of similar compounds with tanimoto score above threshold values :param compounds: list of compound names :param num: number of similar compounds to return :param threshold: threshold tanimoto coefficient value :param return_format: return dictionary key format, either
hashed inchi or nameReturns: list of similar compounds and their tanimoto score [ {‘compound1’: score, ‘compound2’: score, … ‘compound_num’: score}, - {‘compound1’: score, ‘compound2’: score, … ‘compound_num’: score}, …]
- compound(1-n) will be in name format
raw: list of similar compounds and their tanimoto score [ {‘compound1’: score, ‘compound2’: score, … ‘compound_num’: score},
- {‘compound1’: score, ‘compound2’: score, … ‘compound_num’: score}, …]
- compound(1-n) will be in hashed_inchi format
Return type: result
-
get_metabolite_synonyms
(compounds)[source]¶ Find synonyms of a compound :param compound: name(s) of the compound e.g. “ATP”, [“ATP”, “Oxygen”, …]
Returns: - dictionary of synonyms of the compounds
- {‘ATP’: [], ‘Oxygen’: [], …}
- rxns: dictionary of rxns in which each compound is found
- {‘ATP’: [12345,45678,…], ‘Oxygen’: […], …}
Return type: synonyms
-
3.1.1.1.4. datanator_api.query.query_nosql module¶
-
class
datanator_api.query.query_nosql.
DataQuery
(cache_dirname=None, MongoDB=None, replicaSet=None, db=None, verbose=False, max_entries=inf, username=None, password=None, authSource='admin')[source]¶ Bases:
datanator_api.util.mongo_util.MongoUtil
Collection agnostic queries
-
doc_feeder
(collection_str=None, sym_link=False, step=1000, s=None, e=None, inbatch=False, query=None, batch_callback=None, projection=None, verbose=False)[source]¶ An iterator for returning docs in a collection, with batch query. additional filter query can be passed via “query”, e.g., doc_feeder(collection_str, query={‘taxid’: {‘$in’: [9606, 10090, 10116]}}) batch_callback is a callback function as fn(cnt, t), called after every batch fields is optional parameter passed to find to restrict fields to return.
-
3.1.1.1.5. datanator_api.query.query_sabiork module¶
-
class
datanator_api.query.query_sabiork.
QuerySabio
(cache_dirname=None, MongoDB=None, replicaSet=None, db=None, collection_str='sabio_rk', verbose=False, max_entries=inf, username=None, password=None, authSource='admin')[source]¶ Bases:
datanator_api.query.query_nosql.DataQuery
Queries specific to sabio_rk collection
-
find_reaction_participants
(kinlaw_id)[source]¶ Find the reaction participants defined in sabio_rk using kinetic law id :param kinlaw_id: list of kinlaw_id to search for
Returns: list of dictionaries containing names of reaction participants [{‘substrates’: [], ‘products’: [] }, … {} ] Return type: rxns
-
get_kinlawid_by_inchi
(inchi)[source]¶ Find the kinlaw_id defined in sabio_rk using rxn participants’ inchi string :param inchi: list of inchi, all in one rxn
Returns: list of kinlaw_ids that satisfy the condition [id0, id1, id2,…, ] Return type: rxns
-
get_kinlawid_by_inchi_slow
(inchi)[source]¶ Find the kinlaw_id defined in sabio_rk using rxn participants’ inchi string :param inchi: list of inchi, all in one rxn
Returns: list of kinlaw_ids that satisfy the condition [id0, id1, id2,…, ] Return type: rxns
-
get_kinlawid_by_rxn
(substrates, products)[source]¶ Find the kinlaw_id defined in sabio_rk using rxn participants’ inchi string :param substrates: list of substrates’ inchi :param products: list of products’ inchi
Returns: list of kinlaw_ids that satisfy the condition [id0, id1, id2,…, ] Return type: rxns
-
3.1.1.1.6. datanator_api.query.query_taxon_tree module¶
-
class
datanator_api.query.query_taxon_tree.
QueryTaxonTree
(cache_dirname=None, MongoDB=None, replicaSet=None, db=None, collection_str='taxon_tree', verbose=False, max_entries=inf, username=None, password=None, authSource='admin')[source]¶ Bases:
datanator_api.query.query_nosql.DataQuery
Queries specific to taxon_tree collection
-
get_anc_by_id
(ids)[source]¶ Get organism’s ancestor ids by using organism’s ids :param ids: list of organism’s ids e.g. Candidatus Diapherotrites
Returns: list of ancestors in order of the farthest to the closest Return type: result
-
get_anc_by_name
(names)[source]¶ Get organism’s ancestor ids by using organism’s names :param names: list of organism’s names e.g. Candidatus Diapherotrites
Returns: list of ancestors ids in order of the farthest to the closest result_name: list of ancestors’ names in order of the farthest to the closest Return type: result_id
-
get_common_ancestor
(org1, org2, org_format='name')[source]¶ Get the closest common ancestor between two organisms and their distances to the said ancestor :param org1: organism 1 :param org2: organism 2 :param org_format: the format of organism eg tax_id or tax_name
Returns: closest common ancestor’s name distance: each organism’s distance to the ancestor Return type: ancestor
-