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

INTERNAL USE ONLY, YOU SHOULD NOT USE THIS CLASS. Simple Fasta 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 Fasta format generater object from the sequence.

Arguments:

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

[Source]

        # File lib/bio/db/fasta/format_fasta.rb, line 30
    30:     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')
      puts s.output(:fasta)                   #=> "> \natgc\n"

Returns: | String object

[Source]

        # File lib/bio/db/fasta/format_fasta.rb, line 42
    42:     def output
    43:       header = @options[:header]
    44:       width = @options.has_key?(:width) ? @options[:width] : 70
    45:       seq = @sequence.seq
    46:       entry_id = @sequence.entry_id ||
    47:         "#{@sequence.primary_accession}.#{@sequence.sequence_version}"
    48:       definition = @sequence.definition
    49:       header ||= "#{entry_id} #{definition}"
    50:
    51:       ">#{header}\n" +
    52:         if width
    53:           seq.to_s.gsub(Regexp.new(".{1,#{width}}"), "\\0\n")
    54:         else
    55:           seq.to_s + "\n"
    56:         end
    57:     end

[Validate]