module Bio::Sequence::QualityScore::Phred

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

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

Public Class Methods

p2q(probabilities)
Alias for: phred_p2q
q2p(scores)
Alias for: phred_q2p

Public Instance Methods

p2q(probabilities)
Alias for: phred_p2q
phred_p2q(probabilities) click to toggle source

Probability to PHRED score conversion.

The values may be truncated or incorrect if overflows/underflows occurred during the calculation.


Arguments:

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

Returns

(Array containing Float) scores

    # File lib/bio/sequence/quality_score.rb
121 def phred_p2q(probabilities)
122   probabilities.collect do |p|
123     p = Float::MIN if p < Float::MIN
124     q = -10 * Math.log10(p)
125     q.finite? ? q.round : q
126   end
127 end
Also aliased as: p2q
phred_q2p(scores) click to toggle source

PHRED score to probability conversion.


Arguments:

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

Returns

(Array containing Float) probabilities (0<=p<=1)

    # File lib/bio/sequence/quality_score.rb
 98 def phred_q2p(scores)
 99   scores.collect do |q|
100     r = 10 ** (- q / 10.0)
101     if r > 1.0 then
102       r = 1.0
103     #elsif r < 0.0 then
104     #  r = 0.0
105     end
106     r
107   end
108 end
Also aliased as: q2p
q2p(scores)
Alias for: phred_q2p
quality_score_type() click to toggle source

Type of quality scores.


Returns

(Symbol) the type of quality score.

   # File lib/bio/sequence/quality_score.rb
89 def quality_score_type
90   :phred
91 end