vienna_rna 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vienna_rna/modules/rna.rb +5 -0
- data/lib/vienna_rna/modules/rna_extensions.rb +7 -0
- data/lib/vienna_rna/modules/utils.rb +7 -12
- data/lib/vienna_rna.rb +10 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 125876026dfe4b5bf2af8e12fe1425c79ce2c41f
|
4
|
+
data.tar.gz: 28cff69aaabc513509da57f049928b7d1f62dc82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce4c556d37c020f386d076a96372602eb68ff3bbc6248ce801f2e8048e550bb5aac94daae9e200cf3c2db2deb9704123141c3d07ef1ff6f63a5b44d0cd940961
|
7
|
+
data.tar.gz: dce9820a4cd5a0ae1b86b6aa329cff3b6373d5ea9892a156940097e58955f793be3e7ecbd902ab7340cc6db112169151302998805e1278842780ce3e6a3fb6d7
|
@@ -40,6 +40,7 @@ module ViennaRna
|
|
40
40
|
alias :seq :sequence
|
41
41
|
alias :str :structure
|
42
42
|
|
43
|
+
|
43
44
|
def inspect
|
44
45
|
case [sequence.present?, structure.present?]
|
45
46
|
when [true, true] then
|
@@ -60,6 +61,10 @@ module ViennaRna
|
|
60
61
|
end
|
61
62
|
end
|
62
63
|
end
|
64
|
+
|
65
|
+
def run(module_name, options = {})
|
66
|
+
ViennaRna.const_missing("#{module_name}".camelize).run(self, options)
|
67
|
+
end
|
63
68
|
|
64
69
|
private
|
65
70
|
|
@@ -2,6 +2,7 @@ module ViennaRna
|
|
2
2
|
module RnaExtensions
|
3
3
|
def self.included(base)
|
4
4
|
base.extend(ClassMethods)
|
5
|
+
base.send(:include, InstanceMethods)
|
5
6
|
base.extend(StructureBasedClassAndInstanceMethods)
|
6
7
|
|
7
8
|
base.class_eval do
|
@@ -25,6 +26,12 @@ module ViennaRna
|
|
25
26
|
Shuffle.new(sequence).shuffle(token_length)
|
26
27
|
end
|
27
28
|
end
|
29
|
+
|
30
|
+
module InstanceMethods
|
31
|
+
def gc_content
|
32
|
+
seq.split(//).select { |i| i =~ /[GC]/i }.size.to_f / seq.size
|
33
|
+
end
|
34
|
+
end
|
28
35
|
|
29
36
|
module StructureBasedClassAndInstanceMethods
|
30
37
|
# All the methods in here are also copied in as instance methods, where the first argument is the ViennaRna::Rna#structure
|
@@ -91,23 +91,18 @@ module ViennaRna
|
|
91
91
|
groups = (range.min + half).step(range.max, bin_size).map { |x| [x, data.count { |i| i >= x - half && i < x + half }] }
|
92
92
|
|
93
93
|
options.merge!(output: "file") if options[:filename]
|
94
|
-
options.merge
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
style: "fill solid 0.5 border"
|
100
|
-
}
|
94
|
+
options[:plot] = (options[:plot] || {}).merge({
|
95
|
+
title: title,
|
96
|
+
yrange: "[0:#{groups.map(&:last).max * 1.1}]",
|
97
|
+
xtics: "#{[bin_size, 5].max}",
|
98
|
+
style: "fill solid 0.5 border"
|
101
99
|
})
|
102
100
|
|
103
101
|
plot([{ x: groups.map(&:first), y: groups.map(&:last), style: "boxes" }], options)
|
104
102
|
end
|
105
103
|
|
106
104
|
def roc(data, title = "", options = {})
|
107
|
-
# data = [[true_score_1, true_score_2, ...], [false_score_1, false_score_2, ...]]
|
108
|
-
# This 'twiddle' removes duplicates by adding a very small random number to any repeated value
|
109
|
-
data = data.map { |scores| scores.group_by(&:_ident).values.inject([]) { |array, values| array + (values.size > 1 ? values.map { |i| i + 1e-8 * (rand - 0.5) } : values) } }
|
110
|
-
|
105
|
+
# data = [[true_score_1, true_score_2, ...], [false_score_1, false_score_2, ...]]~
|
111
106
|
roc_curve = ROC.curve_points({ 1 => data[0], -1 => data[1] }.inject([]) { |data, (truth, values)| data.concat(values.map { |i| [i, truth] })})
|
112
107
|
area = roc_curve.each_cons(2).inject(0) do |sum, (a, b)|
|
113
108
|
delta_x, delta_y = b[0] - a[0], b[1] - a[1]
|
@@ -129,7 +124,7 @@ module ViennaRna
|
|
129
124
|
options[:plot] = ((options[:plot] || {}).merge(title: title))
|
130
125
|
options.merge!(output: "file") if options[:filename]
|
131
126
|
|
132
|
-
plot(data.map { |hash| { title: hash[:label], x: hash[:data].map(&:first), y: hash[:data].map(&:last), style: "linespoints" } }, options)
|
127
|
+
plot(data.map { |hash| { title: hash[:label], x: hash[:data].map(&:first), y: hash[:data].map(&:last), style: "linespoints" }.merge(hash[:options] || {}) }, options)
|
133
128
|
end
|
134
129
|
end
|
135
130
|
end
|
data/lib/vienna_rna.rb
CHANGED
@@ -17,7 +17,9 @@ module ViennaRna
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.const_missing(name)
|
20
|
-
if
|
20
|
+
if const_defined?(name)
|
21
|
+
const_get(name)
|
22
|
+
elsif Base.exec_exists?(name)
|
21
23
|
module_eval do
|
22
24
|
const_set(name, Class.new(Base))
|
23
25
|
end
|
@@ -31,4 +33,11 @@ module ViennaRna
|
|
31
33
|
def self.debug=(value)
|
32
34
|
@debug = value
|
33
35
|
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# This dirties up the public namespace, but I use it so many times that I want a shorthand to it
|
39
|
+
unless defined? RNA
|
40
|
+
def RNA(sequence, structure = nil)
|
41
|
+
ViennaRna::Rna.init_from_string(sequence, structure)
|
42
|
+
end
|
34
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vienna_rna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Senter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bio
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.0.
|
126
|
+
rubygems_version: 2.0.3
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Bindings to the Vienna RNA package.
|