| Module | Bio::Sequence::Format |
| In: |
lib/bio/sequence/format.rb
|
Returns a list of available output formats for the sequence
Arguments:
| Returns: | Array of Symbols |
# File lib/bio/sequence/format.rb, line 163
163: def list_output_formats
164: a = get_formatter_repositories.collect { |mod| mod.constants }
165: a.flatten!
166: a.collect! { |x| x.to_s.downcase.intern }
167: a
168: 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:
| Returns: | String object |
# File lib/bio/sequence/format.rb, line 141
141: def output(format = :fasta, options = {})
142: formatter_const = format.to_s.capitalize.intern
143:
144: formatter_class = nil
145: get_formatter_repositories.each do |mod|
146: begin
147: formatter_class = mod.const_get(formatter_const)
148: rescue NameError
149: end
150: break if formatter_class
151: end
152: unless formatter_class then
153: raise "unknown format name #{format.inspect}"
154: end
155:
156: formatter_class.output(self, options)
157: end