Module: Bio::Sequence::QualityScore::Converter

Included in:
Phred, Solexa
Defined in:
lib/bio/sequence/quality_score.rb

Overview

Converter methods between PHRED and Solexa quality scores.

Instance Method Summary (collapse)

Instance Method Details

- (Object) convert_nothing(scores)

Does nothing and simply returns the given argument.


Arguments:

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

Returns

(Array containing Integer) quality scores



70
71
72
# File 'lib/bio/sequence/quality_score.rb', line 70

def convert_nothing(scores)
  scores
end

- (Object) convert_scores_from_phred_to_solexa(scores)

Converts PHRED scores to Solexa scores.

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


Arguments:

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

Returns

(Array containing Integer) quality scores



38
39
40
41
42
43
44
45
46
# File 'lib/bio/sequence/quality_score.rb', line 38

def convert_scores_from_phred_to_solexa(scores)
  sc = scores.collect do |q|
    t = 10 ** (q / 10.0) - 1
    t = Float::MIN if t < Float::MIN
    r = 10 * Math.log10(t)
    r.finite? ? r.round : r
  end
  sc
end

- (Object) convert_scores_from_solexa_to_phred(scores)

Converts Solexa scores to PHRED scores.

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


Arguments:

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

Returns

(Array containing Integer) quality scores



56
57
58
59
60
61
62
# File 'lib/bio/sequence/quality_score.rb', line 56

def convert_scores_from_solexa_to_phred(scores)
  sc = scores.collect do |q|
    r = 10 * Math.log10(10 ** (q / 10.0) + 1)
    r.finite? ? r.round : r
  end
  sc
end