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.

### Methods

new output

### Public Class methods

new()

INTERNAL USE ONLY, YOU SHOULD NOT CALL THIS METHOD.

Creates a new Fasta format generater object from the sequence.

Arguments:

- sequence: Bio::Sequence object
- (optional) :repeat_title => (true or false) if true, repeating title in the "+" line; if not true, "+" only (default false)
- (optional) :width => width: (Fixnum) width to wrap sequence and quality lines; nil to prevent wrapping (default 70)
- (optional) :title => title: (String) completely replaces title line with the title (default nil)
- (optional) :default_score => score: (Integer) default score for bases that have no valid quality scores or error probabilities; false or nil means the lowest score, true means the highest score (default nil)

[Source]

        # File lib/bio/db/fastq/format_fastq.rb, line 32
    32:     def initialize; end

### Public Instance methods

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

[Source]

        # File lib/bio/db/fastq/format_fastq.rb, line 44
    44:     def output
    45:       title = @options[:title]
    46:       width = @options.has_key?(:width) ? @options[:width] : 70
    47:       seq = @sequence.seq.to_s
    48:       entry_id = @sequence.entry_id ||
    49:         "#{@sequence.primary_accession}.#{@sequence.sequence_version}"
    50:       definition = @sequence.definition
    51:       unless title then
    52:         title = definition.to_s
    53:         unless title[0, entry_id.length] == entry_id and
    54:             /\s/ =~ title[entry_id.length, 1].to_s then
    55:           title = "#{entry_id} #{title}"
    56:         end
    57:       end
    58:       title2 = @options[:repeat_title] ? title : ''
    59:       qstr = fastq_quality_string(seq, @options[:default_score])
    60:
    61:       "@#{title}\n" +
    62:         if width then
    63:           seq.gsub(Regexp.new(".{1,#{width}}"), "\\0\n")
    64:         else
    65:           seq + "\n"
    66:         end +
    67:         "+#{title2}\n" +
    68:         if width then
    69:           qstr.gsub(Regexp.new(".{1,#{width}}"), "\\0\n")
    70:         else
    71:           qstr + "\n"
    72:         end
    73:     end

[Validate]