Class | Bio::Blat::Report
In: | lib/bio/appl/blat/report.rb
Parent: | Object

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.

### Methods

add_header_line add_line each each_hit new num_hits query_def query_id query_len

### Classes and Modules

Class Bio::Blat::Report::Hit
Class Bio::Blat::Report::SegmentPair
Class Bio::Blat::Report::SeqDesc

### Constants

DELIMITER | = | RS = nil |  | Delimiter of each entry. Bio::FlatFile uses it. In Bio::Blat::Report, it it nil (1 entry 1 file).
FLATFILE_SPLITTER | = | Bio::FlatFile::Splitter::LineOriented |  | Splitter for Bio::FlatFile

### Attributes

columns | [R] | Returns descriptions of columns. Returns an Array. This would be a Bio::Blat specific method.
hits | [R] | hits of the result. Returns an Array of Bio::Blat::Report::Hit objects.
psl_version | [R] | version of the psl format (String or nil).

### Public Class methods

new(text = '')

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.

[Source]

        # File lib/bio/appl/blat/report.rb, line 56
    56:       def initialize(text = '')
    57:         flag = false
    58:         head = []
    59:         @hits = []
    60:         text.each_line do |line|
    61:           if flag then
    62:             @hits << Hit.new(line)
    63:           else
    64:             # for headerless data
    65:             if /^\d/ =~ line then
    66:               flag = true
    67:               redo
    68:             end
    69:             line = line.chomp
    70:             if /\A\-+\s*\z/ =~ line
    71:               flag = true
    72:             else
    73:               head << line
    74:             end
    75:           end
    76:         end
    77:         @columns = parse_header(head) unless head.empty?
    78:       end

### Public Instance methods

add_header_line(line)

Adds a header line if the header data is not yet given and the given line is suitable for header. Returns self if adding header line is succeeded. Otherwise, returns false (the line is not added).

[Source]

        # File lib/bio/appl/blat/report.rb, line 84
    84:       def add_header_line(line)
    85:         return false if defined? @columns
    86:         line = line.chomp
    87:         case line
    88:         when /^\d/
    89:           @columns = (defined? @header_lines) ? parse_header(@header_lines) : []
    90:           return false
    91:         when /\A\-+\s*\z/
    92:           @columns = (defined? @header_lines) ? parse_header(@header_lines) : []
    93:           return self
    94:         else
    95:           @header_lines ||= []
    96:           @header_lines.push line
    97:         end
    98:       end

add_line(line)

Adds a line to the entry if the given line is regarded as a part of the current entry. If the current entry (self) is empty, or the line has the same query name, the line is added and returns self. Otherwise, returns false (the line is not added).

[Source]

         # File lib/bio/appl/blat/report.rb, line 105
    105:       def add_line(line)
    106:         if /\A\s*\z/ =~ line then
    107:           return @hits.empty? ? self : false
    108:         end
    109:         hit = Hit.new(line.chomp)
    110:         if @hits.empty? or @hits.first.query.name == hit.query.name then
    111:           @hits.push hit
    112:           return self
    113:         else
    114:           return false
    115:         end
    116:       end

each()

Alias for each_hit

each_hit() {|hit| ...}

Iterates over each Bio::Blat::Report::Hit object. Same as hits.each.

[Source]

         # File lib/bio/appl/blat/report.rb, line 496
    496:       def each_hit(&x) #:yields: hit
    497:         @hits.each(&x)
    498:       end

num_hits()

Returns number of hits. Same as hits.size.

[Source]

         # File lib/bio/appl/blat/report.rb, line 492
    492:       def num_hits;     @hits.size;     end

query_def()

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.

[Source]

         # File lib/bio/appl/blat/report.rb, line 505
    505:       def query_def; (x = @hits.first) ? x.query_def : nil; end

query_id()

Alias for query_def

query_len()

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.

[Source]

         # File lib/bio/appl/blat/report.rb, line 511
    511:       def query_len; (x = @hits.first) ? x.query_len : nil; end

[Validate]