class Bio::Sequence::Format::Formatter::Fasta
INTERNAL USE ONLY, YOU SHOULD NOT USE THIS CLASS. Simple Fasta format output class for Bio::Sequence.
Public Class Methods
new()
click to toggle source
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)
# File lib/bio/db/fasta/format_fasta.rb, line 26 def initialize; end
Public Instance Methods
output()
click to toggle source
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::Format#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 38 def output header = @options[:header] width = @options.has_key?(:width) ? @options[:width] : 70 seq = @sequence.seq entry_id = @sequence.entry_id || "#{@sequence.primary_accession}.#{@sequence.sequence_version}" definition = @sequence.definition header ||= "#{entry_id} #{definition}" ">#{header}\n" + if width seq.to_s.gsub(Regexp.new(".{1,#{width}}"), "\\0\n") else seq.to_s + "\n" end end