Skip to content

Commit

Permalink
added kegg_meta in get_meta_by_id
Browse files Browse the repository at this point in the history
  • Loading branch information
lzy7071 committed Mar 6, 2020
1 parent 1c951cf commit ea87b17
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
11 changes: 5 additions & 6 deletions datanator_query_python/query/query_kegg_orthology.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
from pymongo.collation import Collation, CollationStrength


class QueryKO:
class QueryKO(mongo_util.MongoUtil):

def __init__(self, username=None, password=None, server=None, authSource='admin',
database='datanator', max_entries=float('inf'), verbose=True,
readPreference='nearest'):

mongo_manager = mongo_util.MongoUtil(MongoDB=server, username=username,
password=password, authSource=authSource, db=database,
readPreference=readPreference)
super().__init__(MongoDB=server, username=username,
password=password, authSource=authSource, db=database,
readPreference=readPreference)
self.max_entries = max_entries
self.verbose = verbose
self.client, self.db, self.collection = mongo_manager.con_db(
'kegg_orthology')
self.client, self.db, self.collection = self.con_db('kegg_orthology')
self.collation = Collation(locale='en', strength=CollationStrength.SECONDARY)

def get_ko_by_name(self, name):
Expand Down
18 changes: 12 additions & 6 deletions datanator_query_python/query/query_protein.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
from datanator_query_python.util import mongo_util, file_util
from datanator_query_python.query import query_taxon_tree
from datanator_query_python.query import query_taxon_tree, query_kegg_orthology
from pymongo.collation import Collation, CollationStrength
import json


class QueryProtein:
class QueryProtein(mongo_util.MongoUtil):

def __init__(self, username=None, password=None, server=None, authSource='admin',
database='datanator', max_entries=float('inf'), verbose=True, collection_str='uniprot',
readPreference='nearest'):

self.mongo_manager = mongo_util.MongoUtil(MongoDB=server, username=username,
password=password, authSource=authSource, db=database,
readPreference=readPreference)
super().__init__(MongoDB=server, username=username,
password=password, authSource=authSource, db=database,
readPreference=readPreference)
self.taxon_manager = query_taxon_tree.QueryTaxonTree(MongoDB=server, username=username, password=password,
authSource=authSource, db=database)
self.kegg_manager = query_kegg_orthology.QueryKO(username=username, password=password, server=server, authSource=authSource)
self.file_manager = file_util.FileUtil()
self.max_entries = max_entries
self.verbose = verbose
self.client, self.db, self.collection = self.mongo_manager.con_db(collection_str)
self.client, self.db, self.collection = self.con_db(collection_str)
self.collation = Collation(locale='en', strength=CollationStrength.SECONDARY)
self.collection_str = collection_str

Expand Down Expand Up @@ -52,6 +53,11 @@ def get_meta_by_id(self, _id):
'species_name': '99999999'}

for doc in docs:
ko_number = doc.get('ko_number')
if ko_number is not None:
D, c = self.kegg_manager.get_meta_by_kegg_id([ko_number])
if c != 0:
doc['kegg_meta'] = [d for d in D]
result.append(doc)
return result

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ python_dotenv
pytz >= 2019.1
requirements_parser
karr_lab_aws_manager==0.0.21
pandas
pandas >= 1.0.1
requests
pytest

0 comments on commit ea87b17

Please sign in to comment.