[BioRuby-cvs] bioruby/lib/bio/appl/iprscan report.rb,1.3,1.4
Mitsuteru C. Nakao
nakao at dev.open-bio.org
Thu Feb 22 10:15:03 UTC 2007
Update of /home/repository/bioruby/bioruby/lib/bio/appl/iprscan
In directory dev.open-bio.org:/tmp/cvs-serv15976/lib/bio/appl/iprscan
Modified Files:
report.rb
Log Message:
* Added list_of_interpro method.
Index: report.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/appl/iprscan/report.rb,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** report.rb 22 Feb 2007 08:44:34 -0000 1.3
--- report.rb 22 Feb 2007 10:15:01 -0000 1.4
***************
*** 120,129 ****
end
! # Splits entry stream.
#
# == Usage
# Bio::Iprscan::Report.reports_in_txt(File.open("merged.txt")) do |report|
! # report
# end
def self.reports_in_txt(io)
io.each("\n\nSequence") do |entry|
--- 120,131 ----
end
! # Splits the entry stream.
#
# == Usage
+ #
# Bio::Iprscan::Report.reports_in_txt(File.open("merged.txt")) do |report|
! # report.class #=> Bio::Iprscan::Report
# end
+ #
def self.reports_in_txt(io)
io.each("\n\nSequence") do |entry|
***************
*** 145,149 ****
def self.parse_in_txt(str)
unless str =~ /^Sequence /
! raise Exception, "Invalid format: \n\n#{str}"
end
header, *matches = str.split(/\n\n/)
--- 147,151 ----
def self.parse_in_txt(str)
unless str =~ /^Sequence /
! raise ArgumentError, "Invalid format: \n\n#{str}"
end
header, *matches = str.split(/\n\n/)
***************
*** 172,175 ****
--- 174,178 ----
:description => match[2],
:evalue => pos_score[3],
+ :status => pos_score[0],
:match_start => pos_score[1].to_i,
:match_end => pos_score[2].to_i,
***************
*** 246,250 ****
end
! def to_ebihtml
NotImplementedError
end
--- 249,253 ----
end
! def to_ebixml
NotImplementedError
end
***************
*** 255,259 ****
def to_raw
! NotImplementedError
end
--- 258,278 ----
def to_raw
! @matches.map { |match|
! [self.query_id,
! self.crc64,
! self.query_length,
! match.method,
! match.accession,
! match.description,
! match.match_start,
! match.match_end,
! match.evalue,
! match.status,
! match.date,
! match.ipr_id,
! match.ipr_description,
! match.go_terms.map {|x| x[0] + ': ' + x[1] + ' (' + x[2] + ')' }.join(', ')
! ].join("\t")
! }.join("\n")
end
***************
*** 262,273 ****
end
! # == DESCRIPTION
# Container class for InterProScan matches.
#
! # == USAGE
# match = Match.new(:query_id => ...)
#
# match.ipr_id = 'IPR001234'
! # match.ipr_id #=> 'IPR1234'
#
class Match
--- 281,313 ----
end
!
! # Returns a Hash (key as an interpro id and value as index key for
! # matches (Array).
! #
! # report.list_of_interpro.each do |ipr_id, indexes|
! # indexes.each do |index|
! # report.matches[index].ipr_id == ipr_id #=> true
! # end
! # end
! #
! def list_of_interpro
! @ipr_ids = {} unless @ipr_ids
! @matches.each_with_index do |match, i|
! @ipr_ids[match.ipr_id] = [] unless @ipr_ids[match.ipr_id]
! @ipr_ids[match.ipr_id] << i
! end
! @ipr_ids
! end
!
!
!
! # == Description
# Container class for InterProScan matches.
#
! # == Usage
# match = Match.new(:query_id => ...)
#
# match.ipr_id = 'IPR001234'
! # match.ipr_id #=> 'IPR001234'
#
class Match
***************
*** 306,310 ****
def match_start; @data[:match_start]; end
# the descriotion of the InterPro entry.
! def ipr_description; @data[:ipr_description]; end
def method_missing(name, arg = nil)
--- 346,350 ----
def match_start; @data[:match_start]; end
# the descriotion of the InterPro entry.
! def ipr_odescription; @data[:ipr_description]; end
def method_missing(name, arg = nil)
More information about the bioruby-cvs
mailing list