vienna_rna 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/modules/base.rb +3 -2
- data/lib/modules/fftbor.rb +14 -6
- data/lib/modules/utils.rb +31 -0
- data/lib/modules/xbor.rb +1 -1
- metadata +2 -2
data/lib/modules/base.rb
CHANGED
@@ -7,7 +7,7 @@ module ViennaRna
|
|
7
7
|
|
8
8
|
def initialize(sequence, structure = nil)
|
9
9
|
@sequence = sequence
|
10
|
-
@structure = structure
|
10
|
+
@structure = (structure == :mfe ? ViennaRna::Fold.run(seq).structure : structure)
|
11
11
|
end
|
12
12
|
|
13
13
|
alias :seq :sequence
|
@@ -75,6 +75,7 @@ module ViennaRna
|
|
75
75
|
def initialize(data)
|
76
76
|
@data = case data
|
77
77
|
when Bio::FastaFormat then data
|
78
|
+
when Rna then data
|
78
79
|
when String then Rna.new(data)
|
79
80
|
when Hash then Rna.new(data[:sequence] || data[:seq], data[:structure] || data[:str])
|
80
81
|
end
|
@@ -106,7 +107,7 @@ module ViennaRna
|
|
106
107
|
command = if respond_to?(:run_command)
|
107
108
|
method(:run_command).arity.zero? ? run_command : run_command(flags)
|
108
109
|
else
|
109
|
-
"echo #{exec_sequence_format} | #{exec_name} #{stringify_flags(flags)}"
|
110
|
+
"echo #{exec_sequence_format} | #{exec_name} -noPS #{stringify_flags(flags)}"
|
110
111
|
end
|
111
112
|
|
112
113
|
debugger { command }
|
data/lib/modules/fftbor.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
require "tempfile"
|
2
2
|
require "bigdecimal"
|
3
|
+
require "diverge"
|
3
4
|
|
4
5
|
module ViennaRna
|
5
6
|
class Fftbor < Xbor
|
6
7
|
MODES = {
|
7
|
-
dispatch: "
|
8
|
-
standalone: "
|
8
|
+
dispatch: "RNAcentral",
|
9
|
+
standalone: "FFTbor"
|
9
10
|
}
|
10
11
|
|
11
12
|
def run_command(flags = {})
|
12
|
-
flags = { mode: :
|
13
|
-
|
14
|
-
ap flags
|
13
|
+
flags = { mode: :standalone }.merge(flags)
|
15
14
|
|
16
15
|
unless MODES[flags[:mode]]
|
17
16
|
STDERR.puts "ERROR: The mode requested (%s) is not available" % flags[:mode]
|
@@ -21,7 +20,7 @@ module ViennaRna
|
|
21
20
|
when :standalone then
|
22
21
|
super(flags)
|
23
22
|
when :dispatch then
|
24
|
-
"
|
23
|
+
"%s -m 6 -tr 0 -s %s -ss '%s'" % [MODES[flags[:mode]], data.seq, data.safe_structure]
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
@@ -38,5 +37,14 @@ module ViennaRna
|
|
38
37
|
def distribution
|
39
38
|
self.class.parse(response).map { |row| BigDecimal.new(row[1]) }
|
40
39
|
end
|
40
|
+
|
41
|
+
def compare
|
42
|
+
{
|
43
|
+
dispatch: self.class.new(data).run(mode: :dispatch).distribution,
|
44
|
+
standalone: self.class.new(data).run(mode: :standalone).distribution
|
45
|
+
}.tap do |hash|
|
46
|
+
hash[:tvd] = Diverge.new(hash[:dispatch], hash[:standalone]).tvd
|
47
|
+
end
|
48
|
+
end
|
41
49
|
end
|
42
50
|
end
|
data/lib/modules/utils.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require "matrix"
|
2
|
+
require "gnuplot"
|
3
|
+
|
1
4
|
module ViennaRna
|
2
5
|
module Utils
|
3
6
|
class << self
|
@@ -21,6 +24,34 @@ module ViennaRna
|
|
21
24
|
end
|
22
25
|
end
|
23
26
|
end
|
27
|
+
|
28
|
+
def regress(x, y, degree)
|
29
|
+
x_data = x.map { |i| (0..degree).map { |power| i ** power.to_f } }
|
30
|
+
x_matrix = Matrix[*x_data]
|
31
|
+
y_matrix = Matrix.column_vector(y)
|
32
|
+
|
33
|
+
((x_matrix.transpose * x_matrix).inverse * x_matrix.transpose * y_matrix).transpose.to_a[0]
|
34
|
+
end
|
35
|
+
|
36
|
+
def plot(data, options = {})
|
37
|
+
options = { title: "Title", x_label: "X Axis", y_label: "Y Axis" }.merge(options)
|
38
|
+
|
39
|
+
Gnuplot.open do |gnuplot|
|
40
|
+
Gnuplot::Plot.new(gnuplot) do |plot|
|
41
|
+
|
42
|
+
plot.title(options[:title])
|
43
|
+
plot.xlabel(options[:x_label])
|
44
|
+
plot.ylabel(options[:y_label])
|
45
|
+
|
46
|
+
plot.data = data.map do |data_hash|
|
47
|
+
Gnuplot::DataSet.new([data_hash[:x], data_hash[:y]]) do |dataset|
|
48
|
+
dataset.with = "points"
|
49
|
+
data_hash[:title] ? dataset.title = data_hash[:title] : dataset.notitle
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
24
55
|
end
|
25
56
|
end
|
26
57
|
end
|
data/lib/modules/xbor.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vienna_rna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bio
|