Class: Bio::Sequence::Format::Formatter::Fasta
- Inherits:
-
Bio::Sequence::Format::FormatterBase
- Object
- Bio::Sequence::Format::FormatterBase
- Bio::Sequence::Format::Formatter::Fasta
- Defined in:
- lib/bio/db/fasta/format_fasta.rb
Overview
INTERNAL USE ONLY, YOU SHOULD NOT USE THIS CLASS. Simple Fasta format output class for Bio::Sequence.
Instance Method Summary collapse
-
#initialize ⇒ Fasta
constructor
INTERNAL USE ONLY, YOU SHOULD NOT CALL THIS METHOD.
-
#output ⇒ Object
INTERNAL USE ONLY, YOU SHOULD NOT CALL THIS METHOD.
Methods inherited from Bio::Sequence::Format::FormatterBase
Constructor Details
#initialize ⇒ Fasta
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)
30 |
# File 'lib/bio/db/fasta/format_fasta.rb', line 30 def initialize; end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Bio::Sequence::Format::FormatterBase
Instance Method Details
#output ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bio/db/fasta/format_fasta.rb', line 42 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 |