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 26
    26:     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 38
    38:     def output
    39:       header = @options[:header]
    40:       width = @options.has_key?(:width) ? @options[:width] : 70
    41:       seq = @sequence.seq
    42:       entry_id = @sequence.entry_id ||
    43:         "#{@sequence.primary_accession}.#{@sequence.sequence_version}"
    44:       definition = @sequence.definition
    45:       header ||= "#{entry_id} #{definition}"
    46:
    47:       ">#{header}\n" +
    48:         if width
    49:           seq.to_s.gsub(Regexp.new(".{1,#{width}}"), "\\0\n")
    50:         else
    51:           seq.to_s + "\n"
    52:         end
    53:     end

[Validate]