Class: Bio::Sequence::Format::Formatter::Fasta_ncbi

Inherits:
Bio::Sequence::Format::FormatterBase show all
Defined in:
lib/bio/db/fasta/format_fasta.rb

Overview

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.

Instance Method Summary collapse

Methods inherited from Bio::Sequence::Format::FormatterBase

#initialize, output

Constructor Details

This class inherits a constructor from Bio::Sequence::Format::FormatterBase

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bio::Sequence::Format::FormatterBase

Instance Method Details

#outputObject

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



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# 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