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


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

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


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

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


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

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.


150
151
152
# File 'lib/bio/sequence/quality_score.rb', line 150

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


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

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


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

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