in progress...
[jalview.git] / forester / ruby / evoruby / lib / evo / io / parser / uniprot_parser.rb
index 28a5730..607804c 100644 (file)
@@ -23,47 +23,36 @@ module Evoruby
     DR = "DR"
     LAST = '//'
 
-    def initialize file
-      Util.check_file_for_readability file
-      @file = file
+    def initialize
+
     end
 
-   
 
-    def parse( ids )
-      #ic = Iconv.new( 'UTF-8//IGNORE', 'UTF-8' )
-      entries = []
+    def parse( lines )
       de = []
       dr = []
-      read = false
-      File.open( @file ).each do | line |
-        if line.index ID == 0
-          ids.each do | id |
-            if line.index id == 0
-              read = true
-              break
-            end
-          end
-        end
-        if read
-          if line.index LAST == 0
-            read = false
+      id = nil
+      lines.each do | line |
+
+        if line.include?( ID ) && line.index( ID ) == 0
+          id = line.split[ 1 ]
+        elsif id != nil
+          if line.include?( LAST ) && line.index( LAST ) == 0
             e = UniprotEntry.new
+            e.id = id
             e.de = de
             e.dr = dr
-            entries << e
-            de = []
-            dr = []
+            return e
           else
-            if line.index DE == 0
+            if line.include?( DE ) && line.index( DE ) == 0
               add( line, de )
-            elsif line.index DR == 0
+            elsif line.include?( DR ) && line.index( DR ) == 0
               add( line, dr )
             end
           end
         end
       end
-      entries
+      return nil
     end
 
     private
@@ -88,7 +77,61 @@ module Evoruby
     attr_accessor :pe
     attr_accessor :kw
 
+    def get_pdb_ids
+      ids = []
+      if dr != nil
+        dr.each do | dr |
+          if dr != nil
+            if dr =~ /PDB;\s+([A-Z0-9]{4});/
+              ids << $1
+            end
+          end
+        end
+      end
+      ids
+    end
+
+    def get_go_descriptions
+      gos = []
+      if dr != nil
+        dr.each do | dr |
+          if dr != nil
+            if dr =~ /GO;\s+GO:\d+(.+);\s+([^;]+)/
+              gos << $1
+            end
+          end
+        end
+      end
+      gos
+    end
+
+    def get_full_name
+     # DE   RecName: Full=Apoptosis regulator Bcl-2;
+    end
+
+
+     def get_reactome_descriptions
+      s = []
+      if dr != nil
+        dr.each do | dr |
+          if dr != nil
+            if dr =~ /Reactome;\s+REACT_\d+;\s+([^.]+)/
+              s << $1
+            end
+          end
+        end
+      end
+      s
+    end
+
+
   end
 
 
+
+
+
+
+
+
 end # module Evoruby