Class | Bio::Sequence::Format::Formatter::Fastq |
In: |
lib/bio/db/fastq/format_fastq.rb
|
Parent: | Bio::Sequence::Format::FormatterBase |
INTERNAL USE ONLY, YOU SHOULD NOT USE THIS CLASS.
FASTQ format output class for Bio::Sequence.
The default FASTQ format is fastq-sanger.
INTERNAL USE ONLY, YOU SHOULD NOT CALL THIS METHOD.
Creates a new Fasta format generater object from the sequence.
Arguments:
# File lib/bio/db/fastq/format_fastq.rb, line 31 31: def initialize; end
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 |
# File lib/bio/db/fastq/format_fastq.rb, line 43 43: def output 44: title = @options[:title] 45: width = @options.has_key?(:width) ? @options[:width] : nil 46: seq = @sequence.seq.to_s 47: entry_id = @sequence.entry_id || 48: "#{@sequence.primary_accession}.#{@sequence.sequence_version}" 49: definition = @sequence.definition 50: unless title then 51: title = definition.to_s 52: unless title[0, entry_id.length] == entry_id and 53: /\s/ =~ title[entry_id.length, 1].to_s then 54: title = "#{entry_id} #{title}" 55: end 56: end 57: title2 = @options[:repeat_title] ? title : '' 58: qstr = fastq_quality_string(seq, @options[:default_score]) 59: 60: "@#{title}\n" + 61: if width then 62: seq.gsub(Regexp.new(".{1,#{width}}"), "\\0\n") 63: else 64: seq + "\n" 65: end + 66: "+#{title2}\n" + 67: if width then 68: qstr.gsub(Regexp.new(".{1,#{width}}"), "\\0\n") 69: else 70: qstr + "\n" 71: end 72: end