Module | Bio::Sequence::Format
In: | lib/bio/sequence/format.rb

# DESCRIPTION

A Mixin of methods used by Bio::Sequence#output to output sequences in common bioinformatic formats. These are not called in isolation.

# USAGE

      # Given a Bio::Sequence object,
      puts s.output(:fasta)
      puts s.output(:genbank)
      puts s.output(:embl)

### Methods

list_output_formats output output_fasta

### Classes and Modules

Module Bio::Sequence::Format::AminoFormatter
Module Bio::Sequence::Format::Formatter
Module Bio::Sequence::Format::INSDFeatureHelper
Module Bio::Sequence::Format::NucFormatter
Class Bio::Sequence::Format::FormatterBase

### Public Instance methods

list_output_formats()

Returns a list of available output formats for the sequence

Arguments:

Returns: | Array of Symbols

[Source]

         # File lib/bio/sequence/format.rb, line 179
    179:   def list_output_formats
    180:     a = get_formatter_repositories.collect { |mod| mod.constants }
    181:     a.flatten!
    182:     a.collect! { |x| x.to_s.downcase.intern }
    183:     a
    184:   end

output(format = :fasta, options = {})

Using Bio::Sequence::Format, return a String with the Bio::Sequence object formatted in the given style.

Formats currently implemented are: ‘fasta’, ‘genbank’, and ‘embl‘

      s = Bio::Sequence.new('atgc')
      puts s.output(:fasta)                   #=> "> \natgc\n"

The style argument is given as a Ruby Symbol(www.ruby-doc.org/core/classes/Symbol.html)

Arguments:

- (required) format: :fasta, :genbank, or :embl

Returns: | String object

[Source]

         # File lib/bio/sequence/format.rb, line 157
    157:   def output(format = :fasta, options = {})
    158:     formatter_const = format.to_s.capitalize.intern
    159:
    160:     formatter_class = nil
    161:     get_formatter_repositories.each do |mod|
    162:       begin
    163:         formatter_class = mod.const_get(formatter_const)
    164:       rescue NameError
    165:       end
    166:       break if formatter_class
    167:     end
    168:     unless formatter_class then
    169:       raise "unknown format name #{format.inspect}"
    170:     end
    171:
    172:     formatter_class.output(self, options)
    173:   end

output_fasta(definition = nil, width = 70)

The same as output(:fasta, :header=>definition, :width=>width) This method is intended to replace Bio::Sequence#to_fasta.

      s = Bio::Sequence.new('atgc')
      puts s.output_fasta                   #=> "> \natgc\n"

Arguments:

- (optional) definition: (String) definition line
- (optional) width: (Integer) width (default 70)

Returns: | String object

[Source]

         # File lib/bio/sequence/format.rb, line 196
    196:   def output_fasta(definition = nil, width = 70)
    197:     output(:fasta, :header=> definition, :width => width)
    198:   end

[Validate]