Class: GenomerPluginSummary::Sequences
- Inherits:
-
Genomer::Plugin
- Object
- Genomer::Plugin
- GenomerPluginSummary::Sequences
- Includes:
- Enumerators, Format, Metrics
- Defined in:
- lib/genomer-plugin-summary/sequences.rb
Constant Summary collapse
- COLUMNS =
[:id, :start, :stop, :size, :percent, :gc]
- FORMATTING =
{ :title => 'Scaffold Sequences', :headers => ['Sequence', 'Start (bp)', 'End (bp)', 'Size (bp)', 'Size (%)', 'GC (%)'], :width => { 0 => 16, 1 => 10, 2 => 10, 3 => 10, 4 => 8, 5 => 6 }, :justification => { 0 => :left, 1 => :right, 2 => :right, 3 => :right, 4 => :right, 5 => :right }, :format => { 4 => '%#.2f', 5 => '%#.2f' } }
Constants included from Format
Constants included from Metrics
Instance Method Summary collapse
Methods included from Enumerators
#enumerator_for, #enumerator_for_all, #enumerator_for_contig, #enumerator_for_gap, #enumerator_for_sequence, #enumerator_for_unresolved
Methods included from Format
#create_cells, #csv, #format_cell, #pretty, #table
Methods included from Metrics
#atgc, #count, #gc, #gc_content, #length, #percent, #sequence_total
Instance Method Details
#calculate(scaffold) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/genomer-plugin-summary/sequences.rb', line 53 def calculate(scaffold) total_length = scaffold.mapping(&:sequence).mapping(&:length).inject(&:+).to_f enumerator_for(:sequence,scaffold).mapping do |entry| sequence = entry.delete(:sequence) entry[:size] = sequence.length entry[:gc] = gc(sequence) / atgc(sequence) * 100 entry[:percent] = sequence.length / total_length * 100 entry end.to_a end |
#run ⇒ Object
10 11 12 13 14 15 |
# File 'lib/genomer-plugin-summary/sequences.rb', line 10 def run sequences = calculate(scaffold) total = sequence_total(sequences) tabulate(sequences,total,flags) end |
#tabulate(sequences, total, flags) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/genomer-plugin-summary/sequences.rb', line 44 def tabulate(sequences,total,flags) rows = sequences.map{|sequence| COLUMNS.map{|col| sequence[col]}}. <<(:separator). <<(COLUMNS.map{|col| total[col] || 'All'}) FORMATTING[:output] = flags[:output] table(rows,FORMATTING) end |