Class | Bio::Fastq::FormatData
In: | lib/bio/db/fastq.rb
Parent: | Object

Bio::Fastq::FormatData is a data class to store Fastq format parameters and quality calculation methods. Bio::Fastq internal use only.

### Methods

new scores2str str2scores

### Classes and Modules

Class Bio::Fastq::FormatData::FASTQ_ILLUMINA
Class Bio::Fastq::FormatData::FASTQ_SANGER
Class Bio::Fastq::FormatData::FASTQ_SOLEXA

### Constants

NAME | = | nil |  | Format name. Should be redefined in subclass.
OFFSET | = | nil |  | Offset. Should be redefined in subclass.
SCORE_RANGE | = | nil |  | Range of score. Should be redefined in subclass. The range must not exclude end value, i.e. it must be X..Y, and must not be X...Y.

### Attributes

name | [R] | Format name
offset | [R] | Offset when converting a score to a character
quality_score_type | [R] | Type of quality scores. Maybe one of :phred or :solexa.
score_range | [R] | Allowed range of a score value
symbol | [R] | Format name symbol. Note that "-" in the format name is substituted to "_" because "-" in a symbol is relatively difficult to handle.

### Public Class methods

new()

[Source]

        # File lib/bio/db/fastq.rb, line 52
    52:     def initialize
    53:       @name = self.class::NAME
    54:       @symbol = @name.gsub(/\-/, '_').to_sym
    55:       @offset = self.class::OFFSET
    56:       @score_range = self.class::SCORE_RANGE
    57:     end

### Public Instance methods

scores2str(a) {|i| ...}

Converts scores to a string. Overflow/underflow checks will be performed. If a block is given, when overflow/underflow detected, the score value is passed to the block, and uses returned value as the score. If no blocks, silently truncated.

Arguments:

- (required) a: (Array containing Integer) score values

Returns: | (String) quality string

[Source]

         # File lib/bio/db/fastq.rb, line 98
     98:     def scores2str(a)
     99:       if block_given? then
    100:         tmp = a.collect do |i|
    101:           i = yield(i) unless @score_range.include?(i)
    102:           i + @offset
    103:         end
    104:       else
    105:         min = @score_range.begin
    106:         max = @score_range.end
    107:         tmp = a.collect do |i|
    108:           if i < min then
    109:             i = min
    110:           elsif i > max then
    111:             i = max
    112:           end
    113:           i + @offset
    114:         end
    115:       end
    116:       tmp.pack('C*')
    117:     end

str2scores(str)

Converts quality string to scores. No overflow/underflow checks will be performed.

Arguments:

- (required) c: (String) quality string

Returns: | (Array containing Integer) score values

[Source]

        # File lib/bio/db/fastq.rb, line 82
    82:     def str2scores(str)
    83:       a = str.unpack('C*')
    84:       a.collect! { |i| i - @offset }
    85:       a
    86:     end

[Validate]