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#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
73 def output
74   width = 70
75   seq = @sequence.seq
76   #gi = @sequence.gi_number
77   dbname = 'lcl'
78   if @sequence.primary_accession.to_s.empty? then
79     idstr = @sequence.entry_id
80   else
81     idstr = "#{@sequence.primary_accession}.#{@sequence.sequence_version}"
82   end
83 
84   definition = @sequence.definition
85   header = "#{dbname}|#{idstr} #{definition}"
86 
87   ">#{header}\n" + seq.to_s.gsub(Regexp.new(".{1,#{width}}"), "\\0\n")
88 end