Class: Bio::Sequence::Format::Formatter::Fastq
- Inherits:
-
Bio::Sequence::Format::FormatterBase
- Object
- Bio::Sequence::Format::FormatterBase
- Bio::Sequence::Format::Formatter::Fastq
- Defined in:
- lib/bio/db/fastq/format_fastq.rb
Overview
INTERNAL USE ONLY, YOU SHOULD NOT USE THIS CLASS.
FASTQ format output class for Bio::Sequence.
The default FASTQ format is fastq-sanger.
Instance Method Summary (collapse)
-
- (Fastq) initialize
constructor
A new instance of Fastq.
-
- (Object) output
INTERNAL USE ONLY, YOU SHOULD NOT CALL THIS METHOD.
Methods inherited from Bio::Sequence::Format::FormatterBase
Constructor Details
- (Fastq) initialize
A new instance of Fastq
32 |
# File 'lib/bio/db/fastq/format_fastq.rb', line 32 def initialize; end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Bio::Sequence::Format::FormatterBase
Instance Method Details
- (Object) output
INTERNAL USE ONLY, YOU SHOULD NOT CALL THIS METHOD.
Output the FASTQ format string of the sequence.
Currently, this method is used in Bio::Sequence#output like so,
s = Bio::Sequence.new('atgc')
puts s.output(:fastq_sanger)
Returns |
String object |
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/bio/db/fastq/format_fastq.rb', line 44 def output title = @options[:title] width = @options.has_key?(:width) ? @options[:width] : 70 seq = @sequence.seq.to_s entry_id = @sequence.entry_id || "#{@sequence.primary_accession}.#{@sequence.sequence_version}" definition = @sequence.definition unless title then title = definition.to_s unless title[0, entry_id.length] == entry_id and /\s/ =~ title[entry_id.length, 1].to_s then title = "#{entry_id} #{title}" end end title2 = @options[:repeat_title] ? title : '' qstr = fastq_quality_string(seq, @options[:default_score]) "@#{title}\n" + if width then seq.gsub(Regexp.new(".{1,#{width}}"), "\\0\n") else seq + "\n" end + "+#{title2}\n" + if width then qstr.gsub(Regexp.new(".{1,#{width}}"), "\\0\n") else qstr + "\n" end end |