Module: Bio::Sequence::Format
- Included in:
- Bio::Sequence
- Defined in:
- lib/bio/sequence/format.rb
Overview
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)
Defined Under Namespace
Modules: AminoFormatter, Formatter, INSDFeatureHelper, NucFormatter Classes: FormatterBase
Instance Method Summary collapse
-
#list_output_formats ⇒ Object
- Returns a list of available output formats for the sequence — Arguments: Returns
-
Array of Symbols.
-
#output(format = :fasta, options = {}) ⇒ Object
Using Bio::Sequence::Format, return a String with the Bio::Sequence object formatted in the given style.
-
#output_fasta(definition = nil, width = 70) ⇒ Object
The same as output(:fasta, :header=>definition, :width=>width) This method is intended to replace Bio::Sequence#to_fasta.
Instance Method Details
#list_output_formats ⇒ Object
Returns a list of available output formats for the sequence
Arguments:
- Returns
-
Array of Symbols
173 174 175 176 177 178 |
# File 'lib/bio/sequence/format.rb', line 173 def list_output_formats a = get_formatter_repositories.collect { |mod| mod.constants } a.flatten! a.collect! { |x| x.to_s.downcase.intern } a end |
#output(format = :fasta, options = {}) ⇒ Object
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
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/bio/sequence/format.rb', line 151 def output(format = :fasta, = {}) formatter_const = format.to_s.capitalize.intern formatter_class = nil get_formatter_repositories.each do |mod| begin formatter_class = mod.const_get(formatter_const) rescue NameError end break if formatter_class end unless formatter_class then raise "unknown format name #{format.inspect}" end formatter_class.output(self, ) end |
#output_fasta(definition = nil, width = 70) ⇒ Object
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
190 191 192 |
# File 'lib/bio/sequence/format.rb', line 190 def output_fasta(definition = nil, width = 70) output(:fasta, :header=> definition, :width => width) end |