[BioRuby-cvs] bioruby/lib/bio/appl/iprscan report.rb,1.1,1.2

Mitsuteru C. Nakao nakao at dev.open-bio.org
Thu Feb 22 07:53:51 UTC 2007


Update of /home/repository/bioruby/bioruby/lib/bio/appl/iprscan
In directory dev.open-bio.org:/tmp/cvs-serv13869/lib/bio/appl/iprscan

Modified Files:
	report.rb 
Log Message:
* Added the txt format test file.
* Added Bio::Iprscan::Report.parse_in_txt method. 


Index: report.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/iprscan/report.rb,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** report.rb	14 Dec 2006 16:22:12 -0000	1.1
--- report.rb	22 Feb 2007 07:53:49 -0000	1.2
***************
*** 24,28 ****
      # == USAGE
      #  # Read a marged.txt and split each entry.
!     #  Bio::Iprscan::Report.reports_in_txt(File.read("marged.txt") do |report| 
      #    report.query_id
      #    report.matches.size
--- 24,28 ----
      # == USAGE
      #  # Read a marged.txt and split each entry.
!     #  Bio::Iprscan::Report.reports_in_txt(File.read("marged.txt")) do |report| 
      #    report.query_id
      #    report.matches.size
***************
*** 41,45 ****
      #  end
      #
!     #  Bio::Iprscan::Report.reports_in_raw(File.read("marged.raw") do |report| 
      #    report.class #=> Bio::Iprscan::Report
      #  end
--- 41,45 ----
      #  end
      #
!     #  Bio::Iprscan::Report.reports_in_raw(File.read("marged.raw")) do |report| 
      #    report.class #=> Bio::Iprscan::Report
      #  end
***************
*** 56,59 ****
--- 56,62 ----
        attr_accessor :query_length
  
+       # CRC64 checksum of query sequence.
+       attr_accessor :crc64
+ 
        # Matched InterPro motifs in Hash. Each InterPro motif have :name, 
        # :definition, :accession and :motifs keys. And :motifs key contains
***************
*** 129,133 ****
        end
  
!       # Parser method for a txt formated entry. Retruns a Bio::Iprscan::Report 
        # object.
        # 
--- 132,176 ----
        end
  
! 
!       # Parser method for a txt formated entry. Returns a Bio::Iprscan::Report
!       # object.
!       #
!       def self.parse_in_txt(str)
!         header, *matches = str.split(/\n\n/)
!         report = self.new
!         report.query_id = if header =~ /Sequence \"(.+)\" / then $1 else '' end
!         report.query_length = if header =~ /length: (\d+) aa./ then $1.to_i else nil end
!         report.crc64 = if header =~ /crc64 checksum: (\S+) / then $1 else nil end
!         ipr_line = ''
!         go_annotation = ''
!         matches.each do |m|
!           m = m.split(/\n/).map {|x| x.split(/  +/) }
!           m.each do |match|
!             case match[0]
!             when 'method'
!             when /(Molecular Function|Cellular Component|Biological Process):/
!               go_annotation = match[0].scan(/([MCB]\w+ \w+): (\S.+?\S) \((GO:\d+)\),*/)
!             when 'InterPro'
!               ipr_line = match
!             else
!               pos_scores = match[3].scan(/(\S)\[(\d+)-(\d+)\] (\S+) */)
!               pos_scores.each do |pos_score|
!                 report.matches << Match.new(:ipr_id          => ipr_line[1],
!                                             :ipr_description => ipr_line[2],
!                                             :method      => match[0], 
!                                             :accession   => match[1],
!                                             :description => match[2], 
!                                             :evalue      => pos_score[3],
!                                             :match_start => pos_score[1].to_i,
!                                             :match_end   => pos_score[2].to_i,
!                                             :go_terms => go_annotation)
!               end
!             end
!           end
!         end
!         return report
!       end 
! 
!       # Parser method for a pseudo-txt formated entry. Retruns a Bio::Iprscan::Report 
        # object.
        # 
***************
*** 135,142 ****
        #
        #  File.read("marged.txt").each(Bio::Iprscan::Report::RS) do |e| 
!       #    report = Bio::Iprscan::Report.parse_in_txt(e)
        #  end
        #
!       def self.parse_in_txt(str)
          report = self.new
          ipr_line = ''
--- 178,185 ----
        #
        #  File.read("marged.txt").each(Bio::Iprscan::Report::RS) do |e| 
!       #    report = Bio::Iprscan::Report.parse_in_ptxt(e)
        #  end
        #
!       def self.parse_in_ptxt(str)
          report = self.new
          ipr_line = ''
***************
*** 168,171 ****
--- 211,215 ----
          @query_id = nil
          @query_length = nil
+         @crc64 = nil
          @matches = []
        end




More information about the bioruby-cvs mailing list