From 25108fff5c6761eef7672234127dbbc9fcd6b520 Mon Sep 17 00:00:00 2001 From: "zhouyang.lian" Date: Tue, 15 Oct 2019 11:28:44 -0400 Subject: [PATCH] changes to sabiork --- datanator/data_source/sabio_rk.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/datanator/data_source/sabio_rk.py b/datanator/data_source/sabio_rk.py index 1694df8..b27a76b 100644 --- a/datanator/data_source/sabio_rk.py +++ b/datanator/data_source/sabio_rk.py @@ -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', @@ -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 ...') @@ -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') @@ -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 @@ -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. @@ -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 @@ -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'])) @@ -981,6 +984,8 @@ 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: @@ -988,6 +993,8 @@ def func(parameter): # 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']) @@ -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: