Class: GenomerPluginSummary::Genome

Inherits:
Genomer::Plugin
  • Object
show all
Includes:
Format, Metrics
Defined in:
lib/genomer-plugin-summary/genome.rb

Constant Summary collapse

LAYOUT =
[
  {:name => 'Sequences (#)', :entry_type => :sequence,  :method => :count},
  {:name => 'Contigs (#)',   :entry_type => :contig,    :method => :count},
  {:name => 'Gaps (#)',      :entry_type => :gap,       :method => :count},
  :separator,
  {:name => 'Size (bp)',      :entry_type => :all,      :method => :length},
  {:name => 'Sequences (bp)', :entry_type => :sequence, :method => :length},
  {:name => 'Contigs (bp)',   :entry_type => :contig,   :method => :length},
  {:name => 'Gaps (bp)',      :entry_type => :gap,      :method => :length},
  :separator,
  {:name => 'G+C (%)',        :entry_type => :all,      :method => :gc_content},
  {:name => 'Sequences (%)',  :entry_type => :sequence, :method => :percent},
  {:name => 'Contigs (%)',    :entry_type => :contig,   :method => :percent},
  {:name => 'Gaps (%)',       :entry_type => :gap,      :method => :percent}
]
FORMATTING =
{
  :title         => 'Scaffold',
  :width         => {0 => 12, 1 => 9},
  :justification => {1 => :right},
  :format        => {1 => lambda{|i| i.class == Float ? sprintf('%#.2f',i) : i }}
}

Constants included from Format

Format::DEFAULTS

Constants included from Metrics

Metrics::ALL

Instance Method Summary collapse

Methods included from Format

#create_cells, #csv, #format_cell, #pretty, #table

Methods included from Metrics

#atgc, #count, #gc, #gc_content, #length, #percent, #sequence_total

Methods included from Enumerators

#enumerator_for, #enumerator_for_all, #enumerator_for_contig, #enumerator_for_gap, #enumerator_for_sequence, #enumerator_for_unresolved

Instance Method Details

#calculate_metrics(specs, scaffold) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/genomer-plugin-summary/genome.rb', line 41

def calculate_metrics(specs,scaffold)
  specs.map do |spec|
    if spec == :separator
      spec
    else
      [spec[:name], send(spec[:method],spec[:entry_type],scaffold)]
    end
  end
end

#runObject



32
33
34
# File 'lib/genomer-plugin-summary/genome.rb', line 32

def run
  tabulate(calculate_metrics(LAYOUT, scaffold),flags)
end

#tabulate(data, flags) ⇒ Object



36
37
38
39
# File 'lib/genomer-plugin-summary/genome.rb', line 36

def tabulate(data,flags)
  FORMATTING.store(:output,flags[:output]) if flags[:output]
  table(data,FORMATTING)
end