Commits

Aleš Erjavec committed ddd6bfa

Added EnzymeEntry class.

Comments (0)

Files changed (2)

obiKEGG2/databases.py

               ("TAXONOMY", fields.DBTaxonomyField),
               ("DATA_SOURCE", fields.DBSimpleField),
               ("ORIGINAL_DB", fields.DBSimpleField),
+              ("KEYWORDS", fields.DBSimpleField),
+              ("DISEASE", fields.DBSimpleField),
+              ("COMMENT", fields.DBSimpleField),
               ("CHROMOSOME", fields.DBFieldWithSubsections),
               ("STATISTICS", fields.DBSimpleField),
               ("REFERENCE", fields.DBReference)]
         return ['ddi', 'dme', 'hsa', 'mmu', 'sce']
     
     def search(self, string, relevance=False):
+        """ Search the genome database for string using ``bfind``.
+        """
         if relevance:
             raise NotImplementedError("relevance is no longer supported")
         if string in self.TAXID_MAP:
         res = [r.split(" ", 1)[1] for r in res]
         return res
     
+    
 @entry.entry_decorate
 class GeneEntry(entry.DBEntry):
     FIELDS = [("ENTRY", fields.DBEntryField),
         DBDataBase.__init__(self)
         self._keys = [] # All keys are not available
 
-KEGGCompounds = Compounds
 
 @entry.entry_decorate    
 class ReactionEntry(entry.DBEntry):
 class Drug(DBDataBase):
     DB = "dr"
     
+@entry.entry_decorate
+class EnzymeEntry(entry.DBEntry):
+    FIELDS = [("ENTRY", fields.DBEntryField),
+              ("NAME", fields.DBNameField),
+              ("CLASS", fields.DBSimpleField),
+              ("SYSNAME", fields.DBSimpleField),
+              ("REACTION", fields.DBSimpleField),
+              ("ALL_REAC", fields.DBSimpleField),
+              ("SUBSTRATE", fields.DBSimpleField),
+              ("PRODUCT", fields.DBSimpleField),
+              ("COMMENT", fields.DBSimpleField),
+              ("REFERENCE", fields.DBReference),
+              ("PATHWAY", fields.DBPathway),
+              ("ORTHOLOGY", fields.DBSimpleField),
+              ("GENES", fields.DBSimpleField),
+              ("DBLINKS", fields.DBDBLinks)
+              ]
+    
+    MULTIPLE_FIELDS = ["REFERENCE"]
+    
 class Enzymes(DBDataBase):
     DB = "ec"
+    ENTRY_TYPE = EnzymeEntry
+    
     
 @entry.entry_decorate
 class OrthologyEntry(entry.DBEntry):
     DB = "ko"
     ENTRY_TYPE = OrthologyEntry
     
+    
 @entry.entry_decorate
 class PathwayEntry(entry.DBEntry):
     FIELDS = [("ENTRY", fields.DBEntryField),
               ("DBLINKS", fields.DBDBLinks),
               ("ORGANISM", fields.DBSimpleField),
               ("GENE", fields.DBGeneField),
-              ("ENZYME", fields.DBSimpleField),
-              ("COMPOUND", fields.DBSimpleField),
+              ("ENZYME", fields.DBEnzymeField),
+              ("COMPOUND", fields.DBCompoundField),
               ("REFERENCE", fields.DBReference),
               ("REL_PATHWAY", fields.DBSimpleField),
               ("KO_PATHWAY", fields.DBSimpleField),

obiKEGG2/entry/fields.py

     
     @property
     def pathways(self):
-        return [s.split(" ", 1)[0] for s in self.text.splitlines()]
+        return self._convert()
+    
+    def _convert(self):
+        text = DBSimpleField._convert(self)
+        return [line.split(" ", 1)[0] for line in text.splitlines()]
     
     
 class DBAASeq(DBSimpleField):
     def sequence_lenght(self):
         return int(self.text.split("\n", 1)[0])
     
+    def _convert(self):
+        text = DBSimpleField._convert(self)
+        count, seq = text.split("\n", 1)
+        return seq.replace("\n", "")
+    
     
 class DBNTSeq(DBSimpleField):
     __SLOTS__ = ["text"]
     def sequence_lenght(self):
         return int(self.text.split("\n", 1)[0])
     
+    def _convert(self):
+        text = DBSimpleField._convert(self)
+        count, seq = text.split("\n", 1)
+        return seq.replace("\n", "")
+    
     
 class DBPathwayMapField(DBSimpleField):
     __SLOTS__ = ["text"]
         lines = text.splitlines()
         return [line.split(" ", 1)[0] for line in lines]
     
+class DBEnzymeField(DBSimpleField):
+    __SLOTS__ = ["text"]
+    TITLE = "ENZYME"
     
+    def _convert(self):
+        text = DBSimpleField._convert(self)
+        lines = text.splitlines()
+        return lines
+    
+class DBCompoundField(DBSimpleField):
+    __SLOTS__ = ["text"]
+    TITLE = "COMPOUND"
+    
+    def _convert(self):
+        text = DBSimpleField._convert(self)
+        lines = text.splitlines()
+        return [line.split(" ", 1)[0] for line in lines]
+    
+