class Bio::Sequence::Format::Formatter::Fasta_ncbi

INTERNAL USE ONLY, YOU SHOULD NOT USE THIS CLASS. NCBI-Style Fasta format output class for Bio::Sequence. (like “ncbi” format in EMBOSS)

Note that this class is under construction.

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(:ncbi)                   #=> "> \natgc\n"

Returns

String object

# File lib/bio/db/fasta/format_fasta.rb, line 73
def output
  width = 70
  seq = @sequence.seq
  #gi = @sequence.gi_number
  dbname = 'lcl'
  if @sequence.primary_accession.to_s.empty? then
    idstr = @sequence.entry_id
  else
    idstr = "#{@sequence.primary_accession}.#{@sequence.sequence_version}"
  end

  definition = @sequence.definition
  header = "#{dbname}|#{idstr} #{definition}"

  ">#{header}\n" + seq.to_s.gsub(Regexp.new(".{1,#{width}}"), "\\0\n")
end