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.
INTERNAL USE ONLY, YOU SHOULD NOT CALL THIS METHOD.
Creates a new Fasta format generater object from the sequence.
Arguments:
# File lib/bio/db/fasta/format_fasta.rb, line 30 30: def initialize; end
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 |
# 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