Module: Bio::Sequence::QualityScore::Solexa

Includes:
Converter
Included in:
Fastq::FormatData::FASTQ_SOLEXA
Defined in:
lib/bio/sequence/quality_score.rb

Overview

Bio::Sequence::QualityScore::Solexa is a module having quality calculation methods for the Solexa quality score.

BioRuby internal use only (mainly from Bio::Fastq).

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Converter

#convert_nothing, #convert_scores_from_phred_to_solexa, #convert_scores_from_solexa_to_phred

Class Method Details

.convert_scores_to_phredObject



197
# File 'lib/bio/sequence/quality_score.rb', line 197

alias convert_scores_to_phred     convert_scores_from_solexa_to_phred

.p2qObject

Probability to Solexa score conversion.


Arguments:

  • (required) probabilities: (Array containing Float) probabilities

Returns

(Array containing Float) scores



190
191
192
193
194
195
196
197
# File 'lib/bio/sequence/quality_score.rb', line 190

def solexa_p2q(probabilities)
  probabilities.collect do |p|
    t = p / (1.0 - p)
    t = Float::MIN if t < Float::MIN
    q = -10 * Math.log10(t)
    q.finite? ? q.round : q
  end
end

.q2pObject

Solexa score to probability conversion.


Arguments:

  • (required) scores: (Array containing Integer) scores

Returns

(Array containing Float) probabilities



173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/bio/sequence/quality_score.rb', line 173

def solexa_q2p(scores)
  scores.collect do |q|
    t = 10 ** (- q / 10.0)
    t /= (1.0 + t)
    if t > 1.0 then
      t = 1.0
    #elsif t < 0.0 then
    #  t = 0.0
    end
    t
  end
end

Instance Method Details

#quality_score_typeObject

Type of quality scores.


Returns

(Symbol) the type of quality score.



152
153
154
# File 'lib/bio/sequence/quality_score.rb', line 152

def quality_score_type
  :solexa
end

#solexa_p2q(probabilities) ⇒ Object Also known as: p2q

Probability to Solexa score conversion.


Arguments:

  • (required) probabilities: (Array containing Float) probabilities

Returns

(Array containing Float) scores



182
183
184
185
186
187
188
189
# File 'lib/bio/sequence/quality_score.rb', line 182

def solexa_p2q(probabilities)
  probabilities.collect do |p|
    t = p / (1.0 - p)
    t = Float::MIN if t < Float::MIN
    q = -10 * Math.log10(t)
    q.finite? ? q.round : q
  end
end

#solexa_q2p(scores) ⇒ Object Also known as: q2p

Solexa score to probability conversion.


Arguments:

  • (required) scores: (Array containing Integer) scores

Returns

(Array containing Float) probabilities



161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/bio/sequence/quality_score.rb', line 161

def solexa_q2p(scores)
  scores.collect do |q|
    t = 10 ** (- q / 10.0)
    t /= (1.0 + t)
    if t > 1.0 then
      t = 1.0
    #elsif t < 0.0 then
    #  t = 0.0
    end
    t
  end
end