class Bio::Fastq::FormatData
Bio::Fastq::FormatData
is a data class to store Fastq
format parameters and quality calculation methods. Bio::Fastq
internal use only.
Constants
- NAME
-
Format name. Should be redefined in subclass.
- OFFSET
-
Offset. Should be redefined in subclass.
- SCORE_RANGE
-
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
Format name
Offset when converting a score to a character
Type of quality scores. Maybe one of :phred or :solexa.
Allowed range of a score value
Format name symbol. Note that “-” in the format name is substituted to “_” because “-” in a symbol is relatively difficult to handle.
Public Class Methods
Source
# File lib/bio/db/fastq.rb 53 def initialize 54 @name = self.class::NAME 55 @symbol = @name.gsub(/\-/, '_').to_sym 56 @offset = self.class::OFFSET 57 @score_range = self.class::SCORE_RANGE 58 end
Public Instance Methods
Source
# File lib/bio/db/fastq.rb 99 def scores2str(a) 100 if block_given? then 101 tmp = a.collect do |i| 102 i = yield(i) unless @score_range.include?(i) 103 i + @offset 104 end 105 else 106 min = @score_range.begin 107 max = @score_range.end 108 tmp = a.collect do |i| 109 if i < min then 110 i = min 111 elsif i > max then 112 i = max 113 end 114 i + @offset 115 end 116 end 117 tmp.pack('C*') 118 end
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 83 def str2scores(str) 84 a = str.unpack('C*') 85 a.collect! { |i| i - @offset } 86 a 87 end
Converts quality string to scores. No overflow/underflow checks will be performed.
Arguments:
-
(required) c: (String) quality string
- Returns
-
(Array containing Integer) score values