[BioRuby-cvs] bioruby/lib/bio/appl/iprscan report.rb,1.2,1.3
Mitsuteru C. Nakao
nakao at dev.open-bio.org
Thu Feb 22 08:44:36 UTC 2007
Update of /home/repository/bioruby/bioruby/lib/bio/appl/iprscan
In directory dev.open-bio.org:/tmp/cvs-serv13975/lib/bio/appl/iprscan
Modified Files:
report.rb
Log Message:
* Added test codes.
Index: report.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/iprscan/report.rb,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** report.rb 22 Feb 2007 07:53:49 -0000 1.2
--- report.rb 22 Feb 2007 08:44:34 -0000 1.3
***************
*** 127,131 ****
# end
def self.reports_in_txt(io)
! io.each(/\n\/\/\n/m) do |entry|
yield self.parse_in_txt(entry)
end
--- 127,137 ----
# end
def self.reports_in_txt(io)
! io.each("\n\nSequence") do |entry|
! if entry =~ /Sequence$/
! entry = entry.sub(/Sequence$/, '')
! end
! unless entry =~ /^Sequence/
! entry = 'Sequence' + entry
! end
yield self.parse_in_txt(entry)
end
***************
*** 133,140 ****
--- 139,150 ----
+
# Parser method for a txt formated entry. Returns a Bio::Iprscan::Report
# object.
#
def self.parse_in_txt(str)
+ unless str =~ /^Sequence /
+ raise Exception, "Invalid format: \n\n#{str}"
+ end
header, *matches = str.split(/\n\n/)
report = self.new
***************
*** 172,175 ****
--- 182,198 ----
end
+
+ # Splits entry stream.
+ #
+ # == Usage
+ # Bio::Iprscan::Report.reports_in_ptxt(File.open("merged.txt")) do |report|
+ # report
+ # end
+ def self.reports_in_ptxt(io)
+ io.each(/\n\/\/\n/m) do |entry|
+ yield self.parse_in_ptxt(entry)
+ end
+ end
+
# Parser method for a pseudo-txt formated entry. Retruns a Bio::Iprscan::Report
# object.
More information about the bioruby-cvs
mailing list