Class: Quality
- Inherits:
-
String
- Object
- String
- Quality
- Defined in:
- lib/parse_fasta/quality.rb
Overview
Provide some methods for dealing with common tasks regarding quality strings.
Instance Method Summary collapse
-
#initialize(str) ⇒ Quality
constructor
Strips whitespace from the str argument before calling super.
-
#mean_qual ⇒ Float
Returns the mean quality for the record.
-
#qual_scores ⇒ Array<Fixnum>
Returns an array of illumina style quality scores.
Constructor Details
#initialize(str) ⇒ Quality
Strips whitespace from the str argument before calling super
29 30 31 |
# File 'lib/parse_fasta/quality.rb', line 29 def initialize(str) super(str.gsub(/ +/, "")) end |
Instance Method Details
#mean_qual ⇒ Float
Returns the mean quality for the record. This will be a good deal faster than getting the average with ‘qual_scores` and reduce.
40 41 42 |
# File 'lib/parse_fasta/quality.rb', line 40 def mean_qual (self.sum - (self.length * 33)) / self.length.to_f end |
#qual_scores ⇒ Array<Fixnum>
Returns an array of illumina style quality scores. The quality scores generated will be Phred+33 (i.e., new Illumina).
51 52 53 |
# File 'lib/parse_fasta/quality.rb', line 51 def qual_scores self.each_byte.map { |b| b - 33 } end |