Class: Bio::Blat::Report
Overview
Bio::Blat::Report is a BLAT report parser class. Its object may contain some Bio::Blat::Report::Hits objects.
In BLAT results, the start position of a sequnece is numbered as 0. On the other hand, in many other homology search programs, the start position of a sequence is numbered as 1. To keep compatibility, the BLAT parser adds 1 to every position number except Bio::Blat::Report::Seqdesc and some Bio::Blat specific methods.
Note that Bio::Blat::Report#query_def, #query_id, #query_len methods simply return first hit’s query_*. If multiple query sequences are given, these values will be incorrect.
Defined Under Namespace
Classes: Hit, SegmentPair, SeqDesc
Constant Summary collapse
- DELIMITER =
Delimiter of each entry. Bio::FlatFile uses it. In Bio::Blat::Report, it it nil (1 entry 1 file).
RS = nil
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns descriptions of columns.
-
#hits ⇒ Object
readonly
hits of the result.
-
#psl_version ⇒ Object
readonly
version of the psl format (String or nil).
Instance Method Summary collapse
-
#each_hit(&x) ⇒ Object
(also: #each)
Iterates over each Bio::Blat::Report::Hit object.
-
#initialize(text) ⇒ Report
constructor
Creates a new Bio::Blat::Report object from BLAT result text (String).
-
#num_hits ⇒ Object
Returns number of hits.
-
#query_def ⇒ Object
(also: #query_id)
Returns the name of query sequence.
-
#query_len ⇒ Object
Returns the length of query sequence.
Constructor Details
#initialize(text) ⇒ Report
Creates a new Bio::Blat::Report object from BLAT result text (String). You can use Bio::FlatFile to read a file. Currently, results created with options -out=psl (default) or -out=pslx are supported.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/bio/appl/blat/report.rb', line 53 def initialize(text) flag = false head = [] @hits = [] text.each do |line| if flag then @hits << Hit.new(line) else # for headerless data if /^\d/ =~ line then flag = true redo end line = line.chomp if /\A\-+\s*\z/ =~ line flag = true else head << line end end end @columns = parse_header(head) end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns descriptions of columns. Returns an Array. This would be a Bio::Blat specific method.
84 85 86 |
# File 'lib/bio/appl/blat/report.rb', line 84 def columns @columns end |
#hits ⇒ Object (readonly)
hits of the result. Returns an Array of Bio::Blat::Report::Hit objects.
79 80 81 |
# File 'lib/bio/appl/blat/report.rb', line 79 def hits @hits end |
#psl_version ⇒ Object (readonly)
version of the psl format (String or nil).
111 112 113 |
# File 'lib/bio/appl/blat/report.rb', line 111 def psl_version @psl_version end |
Instance Method Details
#each_hit(&x) ⇒ Object Also known as: each
Iterates over each Bio::Blat::Report::Hit object. Same as hits.each.
455 456 457 |
# File 'lib/bio/appl/blat/report.rb', line 455 def each_hit(&x) #:yields: hit @hits.each(&x) end |
#num_hits ⇒ Object
Returns number of hits. Same as hits.size.
451 |
# File 'lib/bio/appl/blat/report.rb', line 451 def num_hits; @hits.size; end |
#query_def ⇒ Object Also known as: query_id
Returns the name of query sequence. CAUTION: query_* methods simply return first hit’s query_*. If multiple query sequences are given, these values will be incorrect.
464 |
# File 'lib/bio/appl/blat/report.rb', line 464 def query_def; (x = @hits.first) ? x.query_def : nil; end |
#query_len ⇒ Object
Returns the length of query sequence. CAUTION: query_* methods simply return first hit’s query_*. If multiple query sequences are given, these values will be incorrect.
470 |
# File 'lib/bio/appl/blat/report.rb', line 470 def query_len; (x = @hits.first) ? x.query_len : nil; end |