module Bio::Sequence::Format
DESCRIPTION¶ ↑
A Mixin of methods used by Bio::Sequence#output
to output sequences in common bioinformatic formats. These are not called in isolation.
USAGE¶ ↑
# Given a Bio::Sequence object, puts s.output(:fasta) puts s.output(:genbank) puts s.output(:embl)
Public Instance Methods
Returns a list of available output formats for the sequence
Arguments:
- Returns
-
Array of Symbols
# File lib/bio/sequence/format.rb 174 def list_output_formats 175 a = get_formatter_repositories.collect { |mod| mod.constants } 176 a.flatten! 177 a.collect! { |x| x.to_s.downcase.intern } 178 a 179 end
Using Bio::Sequence::Format
, return a String with the Bio::Sequence
object formatted in the given style.
Formats currently implemented are: ‘fasta’, ‘genbank’, and ‘embl’
s = Bio::Sequence.new('atgc') puts s.output(:fasta) #=> "> \natgc\n"
The style argument is given as a Ruby Symbol(www.ruby-doc.org/core/classes/Symbol.html)
Arguments:
-
(required) format: :fasta, :genbank, or :embl
- Returns
-
String object
# File lib/bio/sequence/format.rb 152 def output(format = :fasta, options = {}) 153 formatter_const = format.to_s.capitalize.intern 154 155 formatter_class = nil 156 get_formatter_repositories.each do |mod| 157 begin 158 formatter_class = mod.const_get(formatter_const) 159 rescue NameError 160 end 161 break if formatter_class 162 end 163 unless formatter_class then 164 raise "unknown format name #{format.inspect}" 165 end 166 167 formatter_class.output(self, options) 168 end
The same as output(:fasta, :header=>definition, :width=>width) This method is intended to replace Bio::Sequence#to_fasta.
s = Bio::Sequence.new('atgc') puts s.output_fasta #=> "> \natgc\n"
Arguments:
-
(optional) definition: (String) definition line
-
(optional) width: (Integer) width (default 70)
- Returns
-
String object
# File lib/bio/sequence/format.rb 191 def output_fasta(definition = nil, width = 70) 192 output(:fasta, :header=> definition, :width => width) 193 end