Class: GenomerPluginView::Fasta
- Inherits:
-
Genomer::Plugin
- Object
- Genomer::Plugin
- GenomerPluginView::Fasta
- Defined in:
- lib/genomer-plugin-view/fasta.rb
Instance Method Summary collapse
- #header(identifier) ⇒ Object
- #header_flags ⇒ Object
- #identifier ⇒ Object
- #run ⇒ Object
- #sequence ⇒ Object
Instance Method Details
#header(identifier) ⇒ Object
20 21 22 |
# File 'lib/genomer-plugin-view/fasta.rb', line 20 def header(identifier) (identifier + ' ' + header_flags).strip end |
#header_flags ⇒ Object
28 29 30 |
# File 'lib/genomer-plugin-view/fasta.rb', line 28 def header_flags flags.map{|k,v| "[#{k}=#{v}]" }.join(' ') end |
#identifier ⇒ Object
24 25 26 |
# File 'lib/genomer-plugin-view/fasta.rb', line 24 def identifier flags[:identifier] ? flags.delete(:identifier) : '.' end |
#run ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/genomer-plugin-view/fasta.rb', line 5 def run if flags[:contigs] flags.delete(:contigs) sequence. split(/[Nn]+/). map{|s| Bio::Sequence.new(s) }. each_with_index. map{|s,i| s.output(:fasta,:header => header(sprintf("contig%05d",i+1))) }. join else Bio::Sequence.new(sequence).output(:fasta,:header => header(identifier)) end end |
#sequence ⇒ Object
32 33 34 |
# File 'lib/genomer-plugin-view/fasta.rb', line 32 def sequence scaffold.map{|entry| entry.sequence}.join end |