Changeset 1334:3c8eb7c872d1 in orange-bioinformatics for obiGO.py


Ignore:
Timestamp:
02/25/11 11:33:53 (3 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
71a530b80a01d9a15f3e73bdfc7249098f2661a9
Message:
  • changed special handling of genematcher for dicty
  • some code/doctring formating
File:
1 edited

Legend:

Unmodified
Added
Removed
  • obiGO.py

    r1256 r1334  
    7878] 
    7979 
    80 multiplicitySet=set(["alt_id","is_a","subset","synonym","related_synonym","exact_synonym","broad_synonym","narrow_synonym", 
     80multiplicitySet=set(["alt_id","is_a","subset","synonym","related_synonym", 
     81                     "exact_synonym","broad_synonym","narrow_synonym", 
    8182                     "xref_analog","xref_unknown","relationship"]) 
    8283 
    8384multipleTagSet = multiplicitySet 
    8485 
    85 annotationFields=["DB","DB_Object_ID","DB_Object_Symbol","Qualifier","GO_ID", "DB_Reference","Evidence_Code","With_From","Aspect", 
    86                   "DB_Object_Name","DB_Object_Synonym","DB_Object_Type","Taxon","Date","Assigned_by"] 
     86annotationFields=["DB","DB_Object_ID","DB_Object_Symbol","Qualifier","GO_ID", 
     87                  "DB_Reference","Evidence_Code","With_From","Aspect", 
     88                  "DB_Object_Name","DB_Object_Synonym","DB_Object_Type", 
     89                  "Taxon","Date","Assigned_by"] 
    8790 
    8891annotationFieldsDict={"DB":0, 
     
    181184            self._lines.append((tag, value, modifiers, comment)) 
    182185            if tag in multipleTagSet: 
    183                 self.values.setdefault(tag, []).append(value) #[tag] = self.values.get(tag, []) + [value] 
     186                self.values.setdefault(tag, []).append(value) 
    184187            else: 
    185188                self.values[tag] = value 
     
    194197        typeId and the second id of object to whom the relationship applys to. 
    195198        """ 
    196         result = [(typeId, id) for typeId in ["is_a"] for id in self.values.get(typeId, [])] ##TODO add other defined Typedef ids 
     199        ##TODO: add other defined Typedef ids 
     200        result = [(typeId, id) for typeId in ["is_a"] for id in self.values.get(typeId, [])]  
    197201        result = result + [tuple(r.split(None, 1)) for r in self.values.get("relationship", [])] 
    198202        return result 
     
    216220        return "%s: %s" % (self.id, self.name) 
    217221 
    218 #    def __getattr__(self, tag): 
    219 #        """ Return value for the tag 
    220 #        """ 
    221 #        try: 
    222 #            if hasattr(self, "values"): 
    223 #                return self.values["def" if tag == "def_" else tag] 
    224 #            else: 
    225 #                raise KeyError 
    226 #        except KeyError: 
    227 #            raise AttributeError(tag) 
    228  
    229222    def __iter__(self): 
    230223        """ Iterates over sub terms 
     
    243236         
    244237class Ontology(object): 
    245     """Ontology is the main class representing a gene ontology.""" 
     238    """ Ontology is the main class representing a gene ontology. 
     239     
     240    Example:: 
     241        >>> ontology = Ontology("my_gene_ontology.obo") 
     242         
     243    """ 
    246244    version = 1 
    247245    def __init__(self, file=None, progressCallback=None): 
    248         """ Initialize the ontology from file. The optional progressCallback will be called with a single argument to report on the progress. 
     246        """ Initialize the ontology from file (if `None` the default gene 
     247        ontology will be loaded). The optional `progressCallback` will be 
     248        called with a single argument to report on the progress. 
     249         
    249250        """ 
    250251        self.terms = {} 
     
    260261    @classmethod 
    261262    def Load(cls, progressCallback=None): 
    262         """ A class method that tries to load the ontology file from default_database_path. It looks for a filename starting with 'gene_ontology'. 
     263        """ A class method that tries to load the ontology file from 
     264        default_database_path. It looks for a filename starting with 
     265        'gene_ontology'. If not found it will download it. 
    263266        """ 
    264267        filename = os.path.join(default_database_path, "gene_ontology_edit.obo.tar.gz") 
    265268        if not os.path.isfile(filename) and not os.path.isdir(filename): 
    266 ##            print "Ontology file not found on local disk" 
    267 ##            print "Downloading ontology ..." 
    268269            import orngServerFiles 
    269270            orngServerFiles.download("GO", "gene_ontology_edit.obo.tar.gz") 
     
    275276         
    276277    def ParseFile(self, file, progressCallback=None): 
    277         """ Parse the file. file can be a filename string or an open filelike object. The optional progressCallback will be called with a single argument to report on the progress. 
     278        """ Parse the file. file can be a filename string or an open filelike 
     279        object. The optional progressCallback will be called with a single 
     280        argument to report on the progress. 
    278281        """ 
    279282        if type(file) == str: 
     
    317320                self.aliasMapper.update([(alt_id, id) for alt_id in term.alt_id]) 
    318321                self.reverseAliasMapper[id].union_update(term.alt_id) 
    319 #                for alt_id in term.alt_id: 
    320 #                    self.aliasMapper[alt_id] = id 
    321322            except AttributeError: 
    322323                pass 
     
    324325                progressCallback(90.0 + 10.0*i/len(self.terms)) 
    325326 
    326 #        self.reverseAliasMapper = defaultdict(set) 
    327 #        for id in self.aliasMapper: 
    328 #            self.reverseAliasMapper[self.aliasMapper[id]].add(id) 
    329  
    330327    def GetDefinedSlimsSubsets(self): 
    331         """ Return a list of defined subsets 
     328        """ Return a list of defined subsets. 
    332329        """ 
    333330        return [line.split()[1] for line in self.header.split("\n") if line.startswith("subsetdef:")] 
    334331 
    335332    def SetSlimsSubset(self, subset): 
    336         """ Set the slims term subset to subset. If subset is a string it must equal one of the defined subsetdef. 
     333        """ Set the slims term subset to subset. If subset is a string it 
     334        must equal one of the defined subsetdef. 
    337335        """ 
    338336        if type(subset) == str: 
     
    340338        else: 
    341339            self.slimsSubset = set(subset) 
    342 #        print self.slimsSubset 
    343340 
    344341    def GetSlimsSubset(self, subset): 
     
    385382 
    386383    def GetTermDepth(self, term, cache_={}): 
    387         """ Return the minimum depth of a term (length of the shortest path to this term from the top level term). 
     384        """ Return the minimum depth of a term (length of the shortest 
     385        path to this term from the top level term). 
    388386        """ 
    389387        if term not in cache_: 
     
    417415        except Exception: 
    418416            pass 
    419         urlretrieve("http://www.geneontology.org/ontology/gene_ontology_edit.obo", os.path.join(tmpDir, "gene_ontology_edit.obo"), progressCallback and __progressCallbackWrapper(progressCallback)) 
    420         tFile.add(os.path.join(tmpDir, "gene_ontology_edit.obo"), "gene_ontology_edit.obo") 
     417        urlretrieve("http://www.geneontology.org/ontology/gene_ontology_edit.obo",  
     418                    os.path.join(tmpDir, "gene_ontology_edit.obo"), 
     419                    progressCallback and __progressCallbackWrapper(progressCallback)) 
     420        tFile.add(os.path.join(tmpDir, "gene_ontology_edit.obo"), 
     421                  "gene_ontology_edit.obo") 
    421422        tFile.close() 
    422423        os.remove(os.path.join(tmpDir, "gene_ontology_edit.obo")) 
     
    425426 
    426427class AnnotationRecord(object): 
    427     """Holds the data for an annotation record read from the annotation file. Fields can be 
    428     accessed with the names: DB, DB_Object_ID, DB_Object_Symbol, Qualifier, GO_ID, DB_Reference, 
    429     Evidence_code, With_or_From, Aspect, DB_Object_Name, DB_Object_Synonym, DB_Object_Type, taxon, 
    430     Date, Assigned_by (e.g. rec.GO_ID) 
    431     or by supplying the original name of the field (see http://geneontology.org/GO.annotation.shtml#file) 
    432     to the get method (e.g. rec.get("GO ID")) 
    433     The object also provides the folowing data members for quicker access: geneName, GOId, evidence, 
    434     aspect and alias(a list of aliases) 
     428    """Holds the data for an annotation record read from the annotation file. 
     429    Fields can be accessed with the names: DB, DB_Object_ID, DB_Object_Symbol, 
     430    Qualifier, GO_ID, DB_Reference, Evidence_code, With_or_From, Aspect, 
     431    DB_Object_Name, DB_Object_Synonym, DB_Object_Type, taxon, Date, 
     432    Assigned_by (e.g. rec.GO_ID) or by supplying the original name of the 
     433    field (see http://geneontology.org/GO.annotation.shtml#file) to the get 
     434    method (e.g. rec.get("GO ID")) The object also provides the following 
     435    data members for quicker access: geneName, GOId, evidence, aspect and 
     436    alias(a list of aliases) 
    435437    """ 
    436     __slots__ = annotationFields + ["geneName", "GOId", "evidence", "aspect", "alias", "additionalAliases"] 
     438    __slots__ = annotationFields + ["geneName", "GOId", "evidence", 
     439                                    "aspect", "alias", "additionalAliases"] 
    437440    def __init__(self, fullText): 
    438441        for slot, val in zip(annotationFields, fullText.split("\t")): 
    439442            setattr(self, slot, val) 
    440 #        self.original = tuple([t.strip() for t in fullText.split("\t")]) 
    441         self.geneName = self.DB_Object_Symbol #self.original[2] 
    442         self.GOId = self.GO_ID #self.original[4] 
    443         self.evidence = self.Evidence_Code #self.original[6] 
    444         self.aspect = self.Aspect #self.original[8] 
    445         self.alias = self.DB_Object_Synonym.split("|") #self.self.original[10].split("|") 
    446 ##        for key, val in zip(annotationFields, self.original): 
    447 ##            self.__dict__[key] = val 
     443        self.geneName = self.DB_Object_Symbol 
     444        self.GOId = self.GO_ID 
     445        self.evidence = self.Evidence_Code 
     446        self.aspect = self.Aspect 
     447        self.alias = self.DB_Object_Synonym.split("|") 
    448448 
    449449        self.additionalAliases = [] 
     
    454454        if name in annotationFieldsDict: 
    455455            return getattr(self, self.__slots__[annotationFieldsDict[name]]) 
    456 #            return self.original[annotationFieldsDict[name]] 
    457456        else: 
    458457            raise AttributeError(name) 
     
    464463    version = 2 
    465464    def __init__(self, file=None, ontology=None, genematcher=None, progressCallback=None): 
    466         """Initialize the annotations from file by calling ParseFile on it. The ontology must be an instance of Ontology class. The optional progressCallback will be called with a single argument to report on the progress. 
     465        """Initialize the annotations from file by calling ParseFile on it. 
     466        The ontology must be an instance of Ontology class. 
     467        The optional progressCallback will be called with a single argument 
     468        to report on the progress. 
     469         
    467470        """ 
    468471        self.file = file 
     
    496499        if not self.genematcher and self.taxid: 
    497500            import obiGene 
    498             self.genematcher = obiGene.matcher([[obiGene.GMGO(self.taxid)] + ([obiGene.GMDicty()] if self.taxid == "352472"  else [])]) 
     501            self.genematcher = obiGene.matcher([obiGene.GMGO(self.taxid)] + \ 
     502                                               ([obiGene.GMDicty(), [obiGene.GMGO(self.taxid), 
     503                                                                     obiGene.GMDicty()]] \ 
     504                                                if self.taxid == "352472"  else [])) 
    499505        if self.genematcher: 
    500506            self.genematcher.set_targets(self.geneNames) 
     
    516522        codes = set([from_taxid(id) for id in ids]) 
    517523        if len(codes) > 1: 
    518             raise tax.MultipleSpeciesException, ", ".join(["%s: %s" % (str(from_taxid(id)), tax.name(id)) for id in ids]) 
     524            raise tax.MultipleSpeciesException, ", ".join(["%s: %s" % \ 
     525                            (str(from_taxid(id)), tax.name(id)) for id in ids]) 
    519526        elif len(codes) == 0: 
    520527            raise tax.UnknownSpeciesIdentifier, org 
     
    525532        name = organism_name_search(name) 
    526533        orngServerFiles.localpath_download("GO", "gene_association.%s.tar.gz" % name) 
    527         return ("v%i." % cls.version) + orngServerFiles.info("GO", "gene_association.%s.tar.gz" % name)["datetime"] 
     534        return ("v%i." % cls.version) + orngServerFiles.info("GO", 
     535                        "gene_association.%s.tar.gz" % name)["datetime"] 
    528536 
    529537    def SetOntology(self, ontology): 
     538        """ Set the ontology to use in the annotations mapping. 
     539        """ 
    530540        self.allAnnotations = defaultdict(list) 
    531541        self._ontology = ontology 
     
    534544        return self._ontology 
    535545 
    536     ontology = property(GetOntology, SetOntology, doc="Ontology object for annotations") 
     546    ontology = property(GetOntology, SetOntology, 
     547                        doc="Ontology object for annotations") 
    537548     
    538549    @classmethod 
    539550    def Load(cls, org, ontology=None, genematcher=None, progressCallback=None): 
    540         """A class method that tries to load the association file for the given organism from default_database_path. 
     551        """A class method that tries to load the association file for the 
     552        given organism from default_database_path. 
    541553        """ 
    542554        import orngServerFiles 
     
    551563     
    552564    def ParseFile(self, file, progressCallback=None): 
    553         """ Parse and load the annotations from file. Report progress with progressCallback. 
     565        """ Parse and load the annotations from file. Report progress 
     566        with progressCallback. 
    554567        File can be: 
    555568            - a tarball containing the association file named gene_association 
     
    582595 
    583596    def AddAnnotation(self, a): 
     597        """ Add a single `AnotationRecord` instance to this `Annotations` 
     598        object. 
     599        """ 
    584600        if not isinstance(a, AnnotationRecord): 
    585601            a = AnnotationRecord(a) 
     
    598614    @property 
    599615    def geneNamesDict(self): 
    600         if getattr(self, "_geneNamesDict", None) == None: 
    601             self._geneNamesDict = reduce(lambda dict, (alias, name) : dict[name].add(alias) or dict, 
    602                                          self.aliasMapper.items(), defaultdict(set)) 
     616        if getattr(self, "_geneNamesDict", None) is None: 
     617            self._geneNamesDict = defaultdict(set) 
     618            for alias, name in self.aliasMapper.iteritems(): 
     619                self._geneNamesDict[name].add(alias) 
    603620        return self._geneNamesDict 
    604621 
    605622    @property 
    606623    def geneNames(self): 
    607         if getattr(self, "_geneNames", None) == None: 
     624        if getattr(self, "_geneNames", None) is None: 
    608625            self._geneNames = set([ann.geneName for ann in self.annotations]) 
    609626        return self._geneNames 
     
    611628    @property 
    612629    def aliasMapper(self): 
    613         if getattr(self, "_aliasMapper", None) == None: 
    614             self._aliasMapper = reduce(lambda dict, ann: dict.update([(alias, ann.geneName) for alias in ann.alias +\ 
    615                                                                       [ann.geneName, ann.DB_Object_ID]]) or dict, 
    616                                                                       self.annotations, {}) 
     630        if getattr(self, "_aliasMapper", None) is None: 
     631            self._aliasMapper = {} 
     632            for ann in self.annotations: 
     633                self._aliasMapper.update([(alias, ann.geneName) for alias in ann.alias + \ 
     634                                          [ann.geneName, ann.DB_Object_ID]]) 
    617635        return self._aliasMapper 
    618636 
    619637    def GetGeneNamesTranslator(self, genes): 
     638        """ Return a dictionary mapping canonical names (DB_Object_Symbol) 
     639        to `genes`. 
     640          
     641        """ 
    620642        def alias(gene): 
    621643            if self.genematcher: 
    622644                return self.genematcher.umatch(gene) 
    623645            else: 
    624                 return gene if gene in self.geneNames else self.aliasMapper.get(gene, self.additionalAliases.get(gene, None)) 
     646                return gene if gene in self.geneNames else \ 
     647                        self.aliasMapper.get(gene, 
     648                             self.additionalAliases.get(gene, None)) 
     649                         
    625650        return dict([(alias(gene), gene) for gene in genes if alias(gene)]) 
    626651 
     
    630655        if id not in self.allAnnotations and id not in visited: 
    631656            if id in self.ontology.reverseAliasMapper: 
    632                 annotations = [self.termAnnotations.get(alt_id, []) for alt_id in self.ontology.reverseAliasMapper[id]] + [self.termAnnotations[id]] 
     657                annotations = [self.termAnnotations.get(alt_id, []) \ 
     658                               for alt_id in self.ontology.reverseAliasMapper[id]] + \ 
     659                                             [self.termAnnotations[id]] 
    633660            else: 
    634                 annotations = [self.termAnnotations[id]] ## annotations for this term alone 
     661                ## annotations for this term alone 
     662                annotations = [self.termAnnotations[id]]  
    635663            visited.add(id) 
    636664            for typeId, child in self.ontology[id].relatedTo: 
    637665                aa = self._CollectAnnotations(child, visited) 
    638                 if type(aa) == set: ## if it was allready reduced in GetAllAnnotations 
     666                if type(aa) == set: 
     667                    ## if it was already reduced in GetAllAnnotations 
    639668                    annotations.append(aa) 
    640669                else: 
     
    644673 
    645674    def GetAllAnnotations(self, id): 
    646         """ Return a set of all annotations for this and all subterms. 
     675        """ Return a set of all annotations (instances if `AnnotationRectord`) 
     676        for GO term `id` and all it's subterms. 
     677         
     678        :param id: GO term id 
     679        :type id: str 
     680         
    647681        """ 
    648682        visited = set() 
     
    656690 
    657691    def GetAllGenes(self, id, evidenceCodes = None): 
    658         """ Return a list of genes annotated by specified evidence codes to this and all subterms." 
     692        """ Return a list of genes annotated by specified `evidenceCodes` 
     693        to GO term 'id' and all it's subterms." 
     694         
     695        :param id: GO term id 
     696        :type id: str 
     697         
     698        :param evidneceCodes: List of evidence codes to consider when 
     699                              matching annotations to terms. 
     700        :type evidenceCodes: list-of-strings 
    659701        """ 
    660702        evidenceCodes = set(evidenceCodes or evidenceDict.keys()) 
     
    662704        return list(set([ann.geneName for ann in annotations if ann.Evidence_Code in evidenceCodes])) 
    663705 
    664     def GetEnrichedTerms(self, genes, reference=None, evidenceCodes=None, slimsOnly=False, aspect="P", prob=obiProb.Binomial(), useFDR=True, progressCallback=None): 
    665         """ Return a dictionary of enriched terms, with tuples of (list_of_genes, p_value, reference_count) for items and term ids as keys. P-Values are FDR adjusted if useFDR is True (default). 
     706    def GetEnrichedTerms(self, genes, reference=None, evidenceCodes=None,  
     707                         slimsOnly=False, aspect="P", prob=obiProb.Binomial(), 
     708                         useFDR=True, progressCallback=None): 
     709        """ Return a dictionary of enriched terms, with tuples of 
     710        (list_of_genes, p_value, reference_count) for items and term 
     711        ids as keys. P-Values are FDR adjusted if useFDR is True (default). 
     712         
     713        :param genes: List of genes 
     714        :param reference: list of genes (if None all genes included in the 
     715                          annotations will be used). 
     716        :param evidenceCodes: List of evidence codes to consider. 
     717        :param slimsOnly: If `True` return only slim terms 
     718        :param aspect:  
    666719        """ 
    667720        revGenesDict = self.GetGeneNamesTranslator(genes) 
     
    674727        aspects_set = set([aspect]) if type(aspect) == str else aspect 
    675728        evidenceCodes = set(evidenceCodes or evidenceDict.keys()) 
    676         annotations = [ann for gene in genes for ann in self.geneAnnotations[gene] if ann.Evidence_Code in evidenceCodes and ann.Aspect in aspects_set] 
    677         refAnnotations = set([ann for gene in reference for ann in self.geneAnnotations[gene] if ann.Evidence_Code in evidenceCodes and ann.Aspect in aspects_set]) 
     729        annotations = [ann for gene in genes for ann in self.geneAnnotations[gene] \ 
     730                       if ann.Evidence_Code in evidenceCodes and ann.Aspect in aspects_set] 
     731        refAnnotations = set([ann for gene in reference for ann in self.geneAnnotations[gene] \ 
     732                              if ann.Evidence_Code in evidenceCodes and ann.Aspect in aspects_set]) 
    678733        annotationsDict = defaultdict(set) 
    679734        for ann in annotations: 
     
    704759            else: 
    705760                mappedReferenceGenes = allAnnotatedGenes.intersection(reference) 
    706             res[term] = ([revGenesDict[g] for g in mappedGenes], prob.p_value(len(mappedGenes), len(reference), len(mappedReferenceGenes), len(genes)), len(mappedReferenceGenes)) 
     761            res[term] = ([revGenesDict[g] for g in mappedGenes], 
     762                         prob.p_value(len(mappedGenes), len(reference), 
     763                                      len(mappedReferenceGenes), len(genes)), 
     764                         len(mappedReferenceGenes)) 
    707765            if progressCallback and i in milestones: 
    708766                progressCallback(100.0 * i / len(terms)) 
    709767        if useFDR: 
    710768            res = sorted(res.items(), key = lambda (_1, (_2, p, _3)): p) 
    711             res = dict([(id, (genes, p, ref)) for (id, (genes, _, ref)), p in zip(res, obiProb.FDR([p for _, (_, p, _) in res]))]) 
     769            res = dict([(id, (genes, p, ref)) \ 
     770                        for (id, (genes, _, ref)), p in zip(res, obiProb.FDR([p for _, (_, p, _) in res]))]) 
    712771        return res 
    713772 
     
    719778        genes = set(revGenesDict.keys()) 
    720779        evidenceCodes = set(evidenceCodes or evidenceDict.keys()) 
    721         annotations = [ann for gene in genes for ann in self.geneAnnotations[gene] if ann.Evidence_Code in evidenceCodes] 
     780        annotations = [ann for gene in genes for ann in self.geneAnnotations[gene] \ 
     781                       if ann.Evidence_Code in evidenceCodes] 
    722782        dd = defaultdict(set) 
    723783        for ann in annotations: 
     
    736796        fdr = dict(zip([t[0] for t in sortedterms], obiProb.FDR([t[1][1] for t in sortedterms]))) 
    737797        termsList = [(term, (float(len(terms[term][0]))/clusterSize) / (float(terms[term][2])/refSize), 
    738                           len(terms[term][0]), terms[term][2], terms[term][1], fdr[term], terms[term][0]) for term in terms] 
     798                      len(terms[term][0]), terms[term][2], terms[term][1], 
     799                      fdr[term], terms[term][0]) for term in terms] 
    739800                           
    740801        drawEnrichmentGraph(termsList, file, width, height, ontology=self.ontology, precison=precison) 
     
    815876            pass 
    816877        fileName = "gene_association." + org + ".gz" 
    817         urlretrieve("http://www.geneontology.org/gene-associations/" + fileName, os.path.join(tmpDir, fileName), progressCallback and __progressCallbackWraper(progressCallback)) 
     878        urlretrieve("http://www.geneontology.org/gene-associations/" + fileName, 
     879                    os.path.join(tmpDir, fileName), 
     880                    progressCallback and __progressCallbackWraper(progressCallback)) 
    818881        gzFile = GzipFile(os.path.join(tmpDir, fileName), "r") 
    819882        file = open(os.path.join(tmpDir, "gene_association." + org), "w") 
     
    823886##        tFile = tarfile.open(os.path.join(tmpDir, "gene_association." + org + ".tar.gz"), "w:gz") 
    824887        tFile.add(os.path.join(tmpDir, "gene_association." + org), "gene_association") 
    825         annotation = Annotations(os.path.join(tmpDir, "gene_association." + org), genematcher=obiGene.GMDirect(), progressCallback=progressCallback) 
     888        annotation = Annotations(os.path.join(tmpDir, "gene_association." + org), 
     889                    genematcher=obiGene.GMDirect(), progressCallback=progressCallback) 
    826890        cPickle.dump(annotation.geneNames, open(os.path.join(tmpDir, "gene_names.pickle"), "wb")) 
    827891        tFile.add(os.path.join(tmpDir, "gene_names.pickle"), "gene_names.pickle") 
     
    837901 
    838902def filterByPValue(terms, maxPValue=0.1): 
    839     """Filters the terms by the p-value. Asumes terms is is a dict with the same structure as returned from GOTermFinderFunc 
     903    """ Filters the terms by the p-value. Asumes terms is a dict with 
     904    the same structure as returned from GetEnrichedTerms. 
     905     
    840906    """ 
    841907    return dict(filter(lambda (k,e): e[1]<=maxPValue, terms.items())) 
    842908 
    843909def filterByFrequency(terms, minF=2): 
    844     """Filters the terms by the cluster frequency. Asumes terms is is a dict with the same structure as returned from GOTermFinderFunc 
     910    """ Filters the terms by the cluster frequency. Asumes terms is 
     911    a dict with the same structure as returned from GetEnrichedTerms. 
     912     
    845913    """ 
    846914    return dict(filter(lambda (k,e): len(e[0])>=minF, terms.items())) 
    847915 
    848916def filterByRefFrequency(terms, minF=4): 
    849     """Filters the terms by the reference frequency. Asumes terms is is a dict with the same structure as returned from GOTermFinderFunc 
     917    """ Filters the terms by the reference frequency. Asumes terms is 
     918    a dict with the same structure as returned from GetEnrichedTerms. 
     919     
    850920    """ 
    851921    return dict(filter(lambda (k,e): e[2]>=minF, terms.items())) 
Note: See TracChangeset for help on using the changeset viewer.