Class: Transrate::ContigMetrics
- Inherits:
-
Object
- Object
- Transrate::ContigMetrics
- Defined in:
- lib/transrate/contig_metrics.rb
Instance Attribute Summary collapse
-
#at_skew ⇒ Object
readonly
Returns the value of attribute at_skew.
-
#bases_n ⇒ Object
readonly
Returns the value of attribute bases_n.
-
#cpg_ratio ⇒ Object
readonly
Returns the value of attribute cpg_ratio.
-
#gc_prop ⇒ Object
readonly
Returns the value of attribute gc_prop.
-
#gc_skew ⇒ Object
readonly
Returns the value of attribute gc_skew.
-
#has_run ⇒ Object
readonly
Returns the value of attribute has_run.
-
#linguistic_complexity ⇒ Object
readonly
Returns the value of attribute linguistic_complexity.
-
#proportion_n ⇒ Object
readonly
Returns the value of attribute proportion_n.
-
#shannon ⇒ Object
readonly
Returns the value of attribute shannon.
-
#wootton_federhen ⇒ Object
readonly
Returns the value of attribute wootton_federhen.
-
#zlib_comp ⇒ Object
readonly
Returns the value of attribute zlib_comp.
Instance Method Summary collapse
- #calculate ⇒ Object
- #initial_values ⇒ Object
-
#initialize(assembly) ⇒ ContigMetrics
constructor
A new instance of ContigMetrics.
- #results ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(assembly) ⇒ ContigMetrics
Returns a new instance of ContigMetrics.
12 13 14 15 16 |
# File 'lib/transrate/contig_metrics.rb', line 12 def initialize assembly @assembly = assembly self.initial_values @has_run = false end |
Instance Attribute Details
#at_skew ⇒ Object (readonly)
Returns the value of attribute at_skew.
7 8 9 |
# File 'lib/transrate/contig_metrics.rb', line 7 def at_skew @at_skew end |
#bases_n ⇒ Object (readonly)
Returns the value of attribute bases_n.
9 10 11 |
# File 'lib/transrate/contig_metrics.rb', line 9 def bases_n @bases_n end |
#cpg_ratio ⇒ Object (readonly)
Returns the value of attribute cpg_ratio.
7 8 9 |
# File 'lib/transrate/contig_metrics.rb', line 7 def cpg_ratio @cpg_ratio end |
#gc_prop ⇒ Object (readonly)
Returns the value of attribute gc_prop.
7 8 9 |
# File 'lib/transrate/contig_metrics.rb', line 7 def gc_prop @gc_prop end |
#gc_skew ⇒ Object (readonly)
Returns the value of attribute gc_skew.
7 8 9 |
# File 'lib/transrate/contig_metrics.rb', line 7 def gc_skew @gc_skew end |
#has_run ⇒ Object (readonly)
Returns the value of attribute has_run.
10 11 12 |
# File 'lib/transrate/contig_metrics.rb', line 10 def has_run @has_run end |
#linguistic_complexity ⇒ Object (readonly)
Returns the value of attribute linguistic_complexity.
8 9 10 |
# File 'lib/transrate/contig_metrics.rb', line 8 def linguistic_complexity @linguistic_complexity end |
#proportion_n ⇒ Object (readonly)
Returns the value of attribute proportion_n.
9 10 11 |
# File 'lib/transrate/contig_metrics.rb', line 9 def proportion_n @proportion_n end |
#shannon ⇒ Object (readonly)
Returns the value of attribute shannon.
8 9 10 |
# File 'lib/transrate/contig_metrics.rb', line 8 def shannon @shannon end |
#wootton_federhen ⇒ Object (readonly)
Returns the value of attribute wootton_federhen.
8 9 10 |
# File 'lib/transrate/contig_metrics.rb', line 8 def wootton_federhen @wootton_federhen end |
#zlib_comp ⇒ Object (readonly)
Returns the value of attribute zlib_comp.
8 9 10 |
# File 'lib/transrate/contig_metrics.rb', line 8 def zlib_comp @zlib_comp end |
Instance Method Details
#calculate ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/transrate/contig_metrics.rb', line 33 def calculate total = 0 a = 0 c = 0 g = 0 t = 0 @bases_n = 0 cpg_count = 0 lc = 0 k = 6 @assembly.assembly.each_value do |contig| total += contig.length a += contig.bases_a c += contig.bases_c g += contig.bases_g t += contig.bases_t @bases_n += contig.bases_n cpg_count += contig.cpg_count lc += contig.linguistic_complexity k end @gc_prop = (g + c) / (a + c + g + t).to_f @gc_skew = (g - c) / (g + c).to_f @at_skew = (a - t) / (a + t).to_f @cpg_ratio = cpg_count.to_f / (c * g) * total @linguistic_complexity = lc / @assembly.assembly.size.to_f @proportion_n = @bases_n / total.to_f end |
#initial_values ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/transrate/contig_metrics.rb', line 18 def initial_values @gc_prop = -1 @gc_skew = -1 @at_skew = -1 @cpg = -1 @bases_n = -1 @proportion_n = -1 @linguistic_complexity = -1 end |
#results ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/transrate/contig_metrics.rb', line 61 def results return if !@has_run return {'gc' => @gc_prop, 'gc_skew' => @gc_skew, 'at_skew' => @at_skew, 'cpg_ratio' => @cpg_ratio, 'bases_n' => @bases_n, 'proportion_n' => @proportion_n, 'linguistic_complexity' => @linguistic_complexity } end |
#run ⇒ Object
28 29 30 31 |
# File 'lib/transrate/contig_metrics.rb', line 28 def run calculate @has_run = true end |