Commits

Flashpoint committed 91f8402

Changed the exception value from KEGG.OrganismNotFound to obiTaxonomy.UnknownSpeciesIdentifier

Comments (0)

Files changed (6)

_bioinformatics/obiGO.py

 from Orange.orng import orngServerFiles
 from Orange.orng import orngMisc
 
-from . import obiProb, obiGene
+from . import obiProb, obiGene, obiTaxonomy
 
 default_database_path = os.path.join(orngServerFiles.localpath(), "GO")
 
         """
         code = organism_name_search(org)
 
+        print "CODE: %s" % code
+        print "ORG: %s" % org
+
         file = "gene_association.%s.tar.gz" % code
 
         path = os.path.join(orngServerFiles.localpath("GO"), file)
             available = sf.listfiles("GO")
             if file not in available:
                 from . import obiKEGG
-                raise obiKEGG.OrganismNotFoundError(org + str(code))
+                raise obiTaxonomy.UnknownSpeciesIdentifier(org + str(code))
             orngServerFiles.download("GO", file)
 
         return cls(path, ontology=ontology, genematcher=genematcher,

_bioinformatics/obiGeneSets.py

 
     genesetsfn = [ keggGeneSets, goGeneSets, miRNAGeneSets]
     organisms = obiTaxonomy.common_taxids()
+    organisms = [ "3055" ]
     for fn in genesetsfn:
         for org in organisms:
             try:
                     register(gs, rsf) #server files
                     #register(gs)
                     print "successful", gs.common_hierarchy()
-            except (obiKEGG.OrganismNotFoundError, GenesetRegException):
+            except obiTaxonomy.UnknownSpeciesIdentifier, GenesetRegException:
                 print "organism not found", org
 
 if __name__ == "__main__":

_bioinformatics/obiKEGG/__init__.py

     deprecated_keywords, deprecated_attribute, deprecated_function_name
 )
 
-from .. import obiProb
+from .. import obiProb, obiTaxonomy
 
 from . import databases
 from . import entry
 DEFAULT_CACHE_DIR = conf.params["cache.path"]
 
 
-class OrganismNotFoundError(Exception):
-    pass
-
-
 class Organism(object):
     """
     A convenience class for retrieving information regarding an
             if ids:
                 name = ids.pop(0) if ids else name
             else:
-                raise OrganismNotFoundError(name)
+                raise obiTaxonomy.UnknownSpeciesIdentifier(name)
 
         try:
             return genome[name].organism_code
         except KeyError:
-            raise OrganismNotFoundError(name)
+            raise obiTaxonomy.UnknownSpeciesIdentifier(name)
 
 
 def pathways(org):

_bioinformatics/obiTaxonomy.py

             "4577",  # Zea mays
              ] 
 
+def taxname_to_taxid(name):
+    """Return taxonomy ID for a taxonomy name"""
+    ids = {
+    "Arabidopsis thaliana": "3702",
+    "Bos taurus": "9913",
+    "Caenorhabditis elegans": "6239",  
+    "Chlamydomonas reinhardtii": "3055",
+    "Danio rerio": "7955",
+    "Dictyostelium discoideum": "352472", 
+    "Drosophila melanogaster": "7227",
+    "Escherichia coli": "562",
+    "Hepatitis C virus": "11103",
+    "Homo sapiens": "9606",
+    "Mus musculus": "10090", 
+    "Mycoplasma pneumoniae": "2104",
+    "Oryza sativa": "4530",  
+    "Plasmodium falciparum": "5833", 
+    "Pneumocystis carinii": "4754",
+    "Rattus norvegicus": "10116", 
+    "Saccharomyces cerevisiae": "4932",  
+    "Schizosaccharomyces pombe": "4896",  
+    "Takifugu rubripes": "31033",
+    "Xenopus laevis": "8355",
+    "Zea mays": "4577" }
+    if name in ids.keys():
+        return ids[name]
+    return []
+
 def essential_taxids():
     """Return taxonomy IDs for organisms that are included in (default) Orange Bioinformatics installation."""
     return ["352472", # Dictyostelium discoideum

_bioinformatics/obimiRNA.py

                 
         else:
             from . import obiKEGG
-            raise obiKEGG.OrganismNotFoundError(taxid)
+            raise obiTaxonomy.UnknownSpeciesIdentifier(taxid)
         
 class mat_miRNA:
     pass

server_update/updateGO.py

         continue
 
     if u.IsUpdatable(obiGO.Update.UpdateAnnotation, (org,)):
-        print "JA"
         u.UpdateAnnotation(org)
         filename = os.path.join(tmpDir, "gene_association." + org + ".tar.gz")
         
 #        else:
 #            orgName = org
         orgName = obiTaxonomy.name(commonOrgs[org])
+        taxid = obiTaxonomy.taxname_to_taxid(orgName)
 #            print "unknown organism name translation for:", org
         print "Uploading", "gene_association." + org + ".tar.gz"
         sf_server.upload("GO", "gene_association." + org + ".tar.gz", filename, title = "GO Annotations for " + orgName,
                            tags=["gene", "annotation", "ontology", "GO", orgName, "#uncompressed:%i" % uncompressedSize(filename),
-                                 "#organism:"+orgName, "#version:%i" % obiGO.Annotations.version] + (["essential"] if org in essentialOrgs else [])+ obiTaxonomy.shortname(org))
+                                 "#organism:"+orgName, "#version:%i" % obiGO.Annotations.version] + (["essential"] if org in essentialOrgs else []) + obiTaxonomy.shortname(taxid))
         sf_server.unprotect("GO", "gene_association." + org + ".tar.gz")
         
 try:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.