Class | Bio::Sequence::Format::Formatter::Fasta_numeric
In: | lib/bio/db/fasta/format_qual.rb
Parent: | Bio::Sequence::Format::FormatterBase

INTERNAL USE ONLY, YOU SHOULD NOT USE THIS CLASS. Simple FastaNumeric format output class for Bio::Sequence.

### Methods

new output

### Public Class methods

new()

INTERNAL USE ONLY, YOU SHOULD NOT CALL THIS METHOD.

Creates a new FastaNumericFormat generater object from the sequence.

It does not care whether the content of the quality score is consistent with the sequence or not, e.g. it does not check length of the quality score.

Arguments:

- sequence: Bio::Sequence object
- (optional) :header => header: (String) (default nil)
- (optional) :width => width: (Fixnum) (default 70)

[Source]

        # File lib/bio/db/fasta/format_qual.rb, line 33
    33:     def initialize; end

### Public Instance methods

output()

INTERNAL USE ONLY, YOU SHOULD NOT CALL THIS METHOD.

Output the FASTA format string of the sequence.

Currently, this method is used in Bio::Sequence#output like so,

      s = Bio::Sequence.new('atgc')
      s.quality_scores = [ 70, 80, 90, 100 ]
      puts s.output(:fasta_numeric)

Returns: | String object

[Source]

        # File lib/bio/db/fasta/format_qual.rb, line 46
    46:     def output
    47:       header = @options[:header]
    48:       width = @options.has_key?(:width) ? @options[:width] : 70
    49:       seq = @sequence.seq.to_s
    50:       entry_id = @sequence.entry_id ||
    51:         "#{@sequence.primary_accession}.#{@sequence.sequence_version}"
    52:       definition = @sequence.definition
    53:       header ||= "#{entry_id} #{definition}"
    54:
    55:       sc = fastanumeric_quality_scores(seq)
    56:       if width then
    57:         if width <= 0 then
    58:           main = sc.join("\n")
    59:         else
    60:           len = 0
    61:           main = sc.collect do |x|
    62:             str = (len == 0) ? "#{x}" : " #{x}"
    63:             len += str.size
    64:             if len > width then
    65:               len = "#{x}".size
    66:               str = "\n#{x}"
    67:             end
    68:             str
    69:           end.join('')
    70:         end
    71:       else
    72:         main = sc.join(' ')
    73:       end
    74:
    75:       ">#{header}\n#{main}\n"
    76:     end

[Validate]