@@ -275,6 +275,7 @@ def interpro(self, analysis_id, organism_id, input, parse_go=False, re_name=None
275275 # Cache analysisfeature content for given analysis_id
276276 self ._init_analysisfeature_cache (analysis_id )
277277 self ._init_featcvterm_cache ()
278+ self ._init_interpro_cache ()
278279
279280 # Cache all existing cvterms from GO cv
280281 db = 'GO'
@@ -501,13 +502,19 @@ def _load_ipr_terms(self, ipr_terms, feature_id, analysis_id, skip_missing):
501502 # load the IPR terms that way, we need to just add them
502503 # as we encounter them. If the term already exists
503504 # we do not want to update it.
504- cvterm_id = self .ci .create_cvterm (ipr_term ['ipr_name' ], 'INTERPRO' , 'INTERPRO' , term_definition = ipr_term ['ipr_desc' ], accession = ipr_id )
505- if not cvterm_id :
506- if skip_missing :
507- warn ('Could not find cvterm %s %s, skipping it' , ipr_id , ipr_term ['ipr_name' ])
508- continue
509- else :
510- raise Exception ('Could not find cvterm %s %s' % ipr_id , ipr_term ['ipr_name' ])
505+
506+ # Check using IPRnumber (in case ipr_name changed at some point in time)
507+ if ipr_id in self ._interpro_cache :
508+ cvterm_id = self ._interpro_cache [ipr_id ]
509+ else :
510+ cvterm_id = self .ci .create_cvterm (ipr_term ['ipr_name' ], 'INTERPRO' , 'INTERPRO' , term_definition = ipr_term ['ipr_desc' ], accession = ipr_id )
511+ if not cvterm_id :
512+ if skip_missing :
513+ warn ('Could not find cvterm %s %s, skipping it' , ipr_id , ipr_term ['ipr_name' ])
514+ continue
515+ else :
516+ raise Exception ('Could not find cvterm %s %s' % ipr_id , ipr_term ['ipr_name' ])
517+ self ._interpro_cache [ipr_id ] = cvterm_id
511518
512519 # Insert IPR terms into the feature_cvterm table
513520 # the default pub_id of 1 (NULL) is used. if the cvterm already exists then just skip adding it
0 commit comments