Changeset 1769:c0c6b64879cf in orange-bioinformatics


Ignore:
Timestamp:
04/30/13 14:29:43 (12 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Filter out terms from the annotations that are not present in the ontology.

If the annotations are newer then the ontology they can contain terms not yet
present in the ontology. This leads to an error when extracting the term's
parents.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • _bioinformatics/obiGO.py

    r1768 r1769  
    872872            self.ontology.SetSlimsSubset("goslim_generic") 
    873873 
    874         terms = self.ontology.ExtractSuperGraph(annotationsDict.keys()) 
     874        terms = annotationsDict.keys() 
     875        filteredTerms = [term for term in terms if term in self.ontology] 
     876 
     877        if len(terms) != len(filteredTerms): 
     878            termDiff = set(terms) - set(filteredTerms) 
     879            warnings.warn("%s terms in the annotations were not found in the " 
     880                          "ontology." % ",".join(map(repr, termDiff)), 
     881                          UserWarning) 
     882 
     883        terms = self.ontology.ExtractSuperGraph(filteredTerms) 
    875884        res = {} 
    876885 
     
    918927            dd[ann.GO_ID].add(revGenesDict.get(ann.geneName, ann.geneName)) 
    919928        if not directAnnotationOnly: 
    920             terms = self.ontology.ExtractSuperGraph(dd.keys()) 
     929            terms = dd.keys() 
     930            filteredTerms = [term for term in terms if term in self.ontology] 
     931            if len(terms) != len(filteredTerms): 
     932                termDiff = set(terms) - set(filteredTerms) 
     933                warnings.warn( 
     934                    "%s terms in the annotations were not found in the " 
     935                    "ontology." % ",".join(map(repr, termDiff)), 
     936                    UserWarning) 
     937 
     938            terms = self.ontology.ExtractSuperGraph(filteredTerms) 
    921939            for i, term in enumerate(terms): 
    922940                termAnnots = self.GetAllAnnotations(term).intersection(annotations) 
Note: See TracChangeset for help on using the changeset viewer.