vienna_rna 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vienna_rna/modules/base.rb +4 -4
- data/lib/vienna_rna/modules/fftbor.rb +0 -5
- data/lib/vienna_rna/modules/fftbor2d.rb +24 -1
- data/lib/vienna_rna/modules/rna.rb +57 -30
- data/lib/vienna_rna.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80d4f6159bca186181c792f0a09d696db387a4e3
|
4
|
+
data.tar.gz: 50bc4db672365259c1c25f78659b268e5d3c60c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e534a3181b7c41f6536a7e49ea2458d015944f1c7d6f0c66020839004a28c33d0004d649f237c1bb82d8bf8ec17bce7fd8d58f516307a58d0dc48aba2ee98d3c
|
7
|
+
data.tar.gz: c16e11c3a1e79b2b909692b173b90bf2a20568823376d270859fcbd5133ba09d751d409531ae5c8b1d9c4f44d1f6aced99148791ab98b9690cef5dbf511e73ee
|
@@ -65,10 +65,10 @@ module ViennaRna
|
|
65
65
|
data = [data] unless data.is_a?(Array)
|
66
66
|
|
67
67
|
@data = case data.map(&:class)
|
68
|
-
when [Rna]
|
69
|
-
when [String]
|
70
|
-
when [Hash]
|
71
|
-
when [Array]
|
68
|
+
when [Rna] then data.first
|
69
|
+
when *(1..3).map { |i| [String] * i } then Rna.init_from_string(*data)
|
70
|
+
when [Hash] then Rna.init_from_hash(*data)
|
71
|
+
when [Array] then Rna.init_from_array(*data)
|
72
72
|
else raise TypeError.new("Unsupported ViennaRna::Rna#initialize format: #{data}")
|
73
73
|
end
|
74
74
|
end
|
@@ -1,5 +1,28 @@
|
|
1
1
|
module ViennaRna
|
2
|
-
class Fftbor2d <
|
2
|
+
class Fftbor2d < Base
|
3
|
+
BASE_FLAGS = {
|
4
|
+
E: "/usr/local/bin/rna_turner1999.par",
|
5
|
+
P: 8,
|
6
|
+
S: :empty
|
7
|
+
}
|
8
|
+
|
9
|
+
self.executable_name = "FFTbor2D"
|
10
|
+
|
11
|
+
def run_command(flags = {})
|
12
|
+
ViennaRna.debugger { "Running FFTbor2D on #{data.inspect}" }
|
13
|
+
|
14
|
+
"%s %s %s" % [
|
15
|
+
exec_name,
|
16
|
+
stringify_flags(BASE_FLAGS.merge(self.class.const_defined?(:FLAGS) ? self.class.const_get(:FLAGS) : {}).merge(flags)),
|
17
|
+
data.temp_fa_file!
|
18
|
+
]
|
19
|
+
end
|
3
20
|
|
21
|
+
def distribution
|
22
|
+
response.split(/\n/).map do |line|
|
23
|
+
i, j, p, ensemble = line.split(/\t/)
|
24
|
+
[i, j].map(&:to_i) + [p, ensemble].map(&:to_f)
|
25
|
+
end
|
26
|
+
end
|
4
27
|
end
|
5
28
|
end
|
@@ -2,70 +2,97 @@ module ViennaRna
|
|
2
2
|
class Rna
|
3
3
|
include ViennaRna::RnaExtensions
|
4
4
|
|
5
|
-
attr_reader :sequence, :structure, :raw_data
|
5
|
+
attr_reader :sequence, :structure, :second_structure, :raw_data
|
6
6
|
|
7
7
|
class << self
|
8
|
-
def init_from_string(sequence, structure = nil)
|
9
|
-
new(
|
8
|
+
def init_from_string(sequence, structure = nil, second_structure = nil)
|
9
|
+
new(
|
10
|
+
sequence: sequence,
|
11
|
+
structure: structure,
|
12
|
+
second_structure: second_structure
|
13
|
+
)
|
10
14
|
end
|
11
15
|
|
12
16
|
def init_from_hash(hash)
|
13
|
-
new(
|
17
|
+
new(
|
18
|
+
sequence: hash[:sequence] || hash[:seq],
|
19
|
+
structure: hash[:structure] || hash[:str_1] || hash[:str],
|
20
|
+
second_structure: hash[:second_structure] || hash[:str_2],
|
21
|
+
raw_data: hash
|
22
|
+
)
|
14
23
|
end
|
15
24
|
|
16
25
|
def init_from_array(array)
|
17
|
-
|
26
|
+
init_from_string(*array)
|
18
27
|
end
|
19
28
|
|
20
29
|
def init_from_fasta(string)
|
21
30
|
string = File.read(string).chomp if File.exist?(string)
|
22
|
-
init_from_string(*string.split(/\n/).reject { |line| line.start_with?(">") }[0,
|
31
|
+
init_from_string(*string.split(/\n/).reject { |line| line.start_with?(">") }[0, 3])
|
23
32
|
end
|
24
33
|
|
25
34
|
def init_from_self(rna)
|
26
35
|
# This happens when you call a ViennaRna library function with the output of something like ViennaRna::Fold.run(...).mfe
|
27
|
-
new(
|
36
|
+
new(
|
37
|
+
sequence: rna.sequence,
|
38
|
+
strucutre: rna.structure,
|
39
|
+
second_strucutre: rna.second_structure,
|
40
|
+
raw_data: rna.raw_data
|
41
|
+
)
|
28
42
|
end
|
29
43
|
end
|
30
44
|
|
31
|
-
def initialize(sequence, structure, raw_data
|
45
|
+
def initialize(sequence: "", structure: "", second_structure: "", raw_data: {})
|
32
46
|
@sequence, @raw_data = sequence, raw_data
|
33
47
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
48
|
+
[:structure, :second_structure].each do |structure_symbol|
|
49
|
+
instance_variable_set(
|
50
|
+
:"@#{structure_symbol}",
|
51
|
+
case structure_value = eval("#{structure_symbol}")
|
52
|
+
when :empty then empty_structure
|
53
|
+
when :mfe then RNA(sequence).run(:fold).mfe_rna.structure
|
54
|
+
when String then structure_value
|
55
|
+
end
|
56
|
+
)
|
38
57
|
end
|
39
58
|
|
40
59
|
if str && seq.length != str.length
|
41
|
-
ViennaRna.debugger { "The sequence length (%d) doesn't match the structure length (%d)" % [seq
|
60
|
+
ViennaRna.debugger { "The sequence length (%d) doesn't match the structure length (%d)" % [seq, str].map(&:length) }
|
61
|
+
end
|
62
|
+
|
63
|
+
if str_2 && str_1.length != str_2.length
|
64
|
+
ViennaRna.debugger { "The first structure length (%d) doesn't match the second structure length (%d)" % [str_1, str_2].map(&:length) }
|
42
65
|
end
|
43
66
|
end
|
44
67
|
|
45
|
-
alias :seq
|
46
|
-
alias :str
|
47
|
-
|
68
|
+
alias :seq :sequence
|
69
|
+
alias :str :structure
|
70
|
+
alias :str_1 :structure
|
71
|
+
alias :str_2 :second_structure
|
48
72
|
|
49
73
|
def inspect
|
50
|
-
|
51
|
-
|
52
|
-
"
|
53
|
-
|
54
|
-
"
|
55
|
-
|
56
|
-
"#<#{self.class.name}>"
|
57
|
-
end
|
74
|
+
"#<%s>" % [
|
75
|
+
"#{self.class.name}",
|
76
|
+
("#{seq[0, 20] + (seq.length > 20 ? '...' : '')}" if seq),
|
77
|
+
("#{str_1[0, 20] + (str_1.length > 20 ? ' [truncated]' : '')}" if str_1),
|
78
|
+
("#{str_2[0, 20] + (str_2.length > 20 ? ' [truncated]' : '')}" if str_2),
|
79
|
+
].compact.join(" ")
|
58
80
|
end
|
59
81
|
|
60
82
|
def write_fa!(filename, comment = "")
|
61
|
-
|
62
|
-
File.open(filename,
|
83
|
+
filename.tap do |filename|
|
84
|
+
File.open(filename, ?w) do |file|
|
63
85
|
file.write("> %s\n" % comment) if comment
|
64
86
|
file.write("%s\n" % seq) if seq
|
65
|
-
file.write("%s\n" %
|
87
|
+
file.write("%s\n" % str_1) if str_1
|
88
|
+
file.write("%s\n" % str_2) if str_2
|
66
89
|
end
|
67
90
|
end
|
68
91
|
end
|
92
|
+
|
93
|
+
def temp_fa_file!
|
94
|
+
write_fa!(Tempfile.new("")).path
|
95
|
+
end
|
69
96
|
|
70
97
|
def run(module_name, options = {})
|
71
98
|
if rna_module = ViennaRna.const_missing("#{module_name}".camelize)
|
@@ -74,11 +101,11 @@ module ViennaRna
|
|
74
101
|
raise ArgumentError.new("#{module_name} can't be resolved as an executable")
|
75
102
|
end
|
76
103
|
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
104
|
+
|
80
105
|
def empty_structure
|
81
106
|
"." * seq.length
|
82
107
|
end
|
108
|
+
|
109
|
+
alias :empty_str :empty_structure
|
83
110
|
end
|
84
111
|
end
|
data/lib/vienna_rna.rb
CHANGED
@@ -44,8 +44,8 @@ end
|
|
44
44
|
|
45
45
|
# This dirties up the public namespace, but I use it so many times that I want a shorthand to it
|
46
46
|
unless defined? RNA
|
47
|
-
def RNA(
|
48
|
-
RNA.
|
47
|
+
def RNA(*args)
|
48
|
+
RNA.from_array(args)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
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.7.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-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bio
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.1.1
|
97
|
-
description: A Ruby API for interacting with the Vienna RNA package.
|
97
|
+
description: A Ruby 2.0 API for interacting with the Vienna RNA package.
|
98
98
|
email: evansenter@gmail.com
|
99
99
|
executables: []
|
100
100
|
extensions: []
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.0.
|
141
|
+
rubygems_version: 2.0.6
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Bindings to the Vienna RNA package.
|