Skip to content

Commit

Permalink
changes to sabiork
Browse files Browse the repository at this point in the history
  • Loading branch information
lzy7071 committed Oct 15, 2019
1 parent de5d455 commit 25108ff
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions datanator/data_source/sabio_rk.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, cache_dirname=None, MongoDB=None, replicaSet=None, db=None,
authSource=authSource).con_db('sabio_rk_new')
self.client, self.db_obj, self.collection_compound = mongo_util.MongoUtil(
MongoDB=MongoDB, db=db, username=username, password=password,
authSource=authSource).con_db('sabio_compound_new')
authSource=authSource).con_db('sabio_compound')
self.excel_batch_size = excel_batch_size
self.ENDPOINT_DOMAINS = {
'sabio_rk': 'http://sabiork.h-its.org',
Expand Down Expand Up @@ -65,7 +65,7 @@ def load_content(self):

##################################
##################################
# determine ids of kinetic laws
# # determine ids of kinetic laws
# if self.verbose:
# print('Downloading the IDs of the kinetic laws ...')

Expand Down Expand Up @@ -109,19 +109,18 @@ def load_content(self):
# if self.verbose:
# print('Updating {} kinetic laws ...'.format(len(loaded_new_ids)))

# self.load_missing_kinetic_law_information_from_tsv(exisitng_ids)
self.load_missing_kinetic_law_information_from_tsv(exisitng_ids[43601:])

# if self.verbose:
# print(' done')

# ##################################
# ##################################
##################################
##################################
# # fill in missing information from HTML pages
# if self.verbose:
# print('Updating {} kinetic laws ...'.format(len(loaded_new_ids)))

self.load_missing_enzyme_information_from_html(exisitng_ids, start=14603)

# self.load_missing_enzyme_information_from_html(not_loaded_ids)
# if self.verbose:
# print(' done')

Expand Down Expand Up @@ -801,6 +800,7 @@ def load_missing_kinetic_law_information_from_tsv(self, ids):
Args:
ids (:obj:`list` of :obj:`int`): list of IDs of kinetic laws to download
start (:obj:`int`): starting row
"""
batch_size = self.excel_batch_size

Expand Down Expand Up @@ -836,7 +836,7 @@ def load_missing_kinetic_law_information_from_tsv(self, ids):
self.load_missing_kinetic_law_information_from_tsv_helper(
response.text)

def load_missing_kinetic_law_information_from_tsv_helper(self, tsv):
def load_missing_kinetic_law_information_from_tsv_helper(self, tsv, start=0):
""" Update the properties of kinetic laws in the mongodb based on content downloaded
from SABIO in TSV format.
Expand All @@ -845,6 +845,7 @@ def load_missing_kinetic_law_information_from_tsv_helper(self, tsv):
Args:
tsv (:obj:`str`): TSV-formatted table
start (:obj:`int`): starting row
Raises:
:obj:`ValueError`: if a kinetic law or compartment is not contained in the local sqlite database
Expand Down Expand Up @@ -972,6 +973,8 @@ def get_parameter_by_properties(self, kinetic_law, parameter_properties):

# match observed name and compound
def func(parameter):
if parameter.get('observed_type') is None:
return []
return parameter['observed_type'] == parameter_properties['type_code'] and \
((parameter['compound'] is None and parameter_properties['associatedSpecies'] is None) or
(parameter['compound'] is not None and parameter['compound']['name'] == parameter_properties['associatedSpecies']))
Expand All @@ -981,13 +984,17 @@ def func(parameter):

# match observed name
def func(parameter):
if parameter.get('observed_type') is None:
return []
return parameter['observed_type'] == parameter_properties['type_code']
parameters = list(filter(func, kinetic_law['parameters']))
if len(parameters) == 1:
return parameters[0]

# match compound
def func(parameter):
if parameter.get('compound') is None:
return []
return (parameter['compound'] is None and parameter_properties['associatedSpecies'] is None) or \
(parameter['compound'] is not None and parameter['compound']
['name'] == parameter_properties['associatedSpecies'])
Expand All @@ -997,6 +1004,8 @@ def func(parameter):

# match value
def func(parameter):
if parameter.get('observed_value') is None:
return []
return parameter['observed_value'] == parameter_properties['startValue']
parameters = list(filter(func, kinetic_law['parameters']))
if len(parameters) == 1:
Expand Down

0 comments on commit 25108ff

Please sign in to comment.