Module: Bio::Sequence::QualityScore::Phred
- Includes:
- Converter
- Defined in:
- lib/bio/sequence/quality_score.rb
Overview
Bio::Sequence::QualityScore::Phred is a module having quality calculation methods for the PHRED quality score.
BioRuby internal use only (mainly from Bio::Fastq).
Class Method Summary collapse
- .convert_scores_to_solexa ⇒ Object
-
.p2q ⇒ Object
Probability to PHRED score conversion.
-
.q2p ⇒ Object
PHRED score to probability conversion.
Instance Method Summary collapse
-
#phred_p2q(probabilities) ⇒ Object
(also: #p2q)
Probability to PHRED score conversion.
-
#phred_q2p(scores) ⇒ Object
(also: #q2p)
PHRED score to probability conversion.
-
#quality_score_type ⇒ Object
Type of quality scores.
Methods included from Converter
#convert_nothing, #convert_scores_from_phred_to_solexa, #convert_scores_from_solexa_to_phred
Class Method Details
.convert_scores_to_solexa ⇒ Object
133 |
# File 'lib/bio/sequence/quality_score.rb', line 133 alias convert_scores_to_solexa convert_scores_from_phred_to_solexa |
.p2q ⇒ Object
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
126 127 128 129 130 131 132 |
# File 'lib/bio/sequence/quality_score.rb', line 126 def phred_p2q(probabilities) probabilities.collect do |p| p = Float::MIN if p < Float::MIN q = -10 * Math.log10(p) q.finite? ? q.round : q end end |
.q2p ⇒ Object
PHRED score to probability conversion.
Arguments:
-
(required) scores: (Array containing Integer) scores
- Returns
-
(Array containing Float) probabilities (0<=p<=1)
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/bio/sequence/quality_score.rb', line 107 def phred_q2p(scores) scores.collect do |q| r = 10 ** (- q / 10.0) if r > 1.0 then r = 1.0 #elsif r < 0.0 then # r = 0.0 end r end end |
Instance Method Details
#phred_p2q(probabilities) ⇒ Object Also known as: p2q
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
119 120 121 122 123 124 125 |
# File 'lib/bio/sequence/quality_score.rb', line 119 def phred_p2q(probabilities) probabilities.collect do |p| p = Float::MIN if p < Float::MIN q = -10 * Math.log10(p) q.finite? ? q.round : q end end |
#phred_q2p(scores) ⇒ Object Also known as: q2p
PHRED score to probability conversion.
Arguments:
-
(required) scores: (Array containing Integer) scores
- Returns
-
(Array containing Float) probabilities (0<=p<=1)
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/bio/sequence/quality_score.rb', line 96 def phred_q2p(scores) scores.collect do |q| r = 10 ** (- q / 10.0) if r > 1.0 then r = 1.0 #elsif r < 0.0 then # r = 0.0 end r end end |
#quality_score_type ⇒ Object
Type of quality scores.
- Returns
-
(Symbol) the type of quality score.
87 88 89 |
# File 'lib/bio/sequence/quality_score.rb', line 87 def quality_score_type :phred end |