wrnap 1.2.0 → 1.2.1
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/wrnap/package/fft_eq.rb +3 -2
- data/lib/wrnap/package/fft_mfpt.rb +1 -1
- data/lib/wrnap/package/fftbor2d.rb +3 -3
- data/lib/wrnap/rna/box.rb +7 -5
- data/lib/wrnap/rna/constraints.rb +15 -13
- data/lib/wrnap/rna/context.rb +4 -7
- data/lib/wrnap/rna/extensions.rb +9 -0
- data/lib/wrnap/rna/metadata.rb +1 -3
- data/lib/wrnap/rna/tree.rb +27 -25
- data/lib/wrnap/rna.rb +85 -81
- data/lib/wrnap/version.rb +1 -1
- data/lib/wrnap.rb +5 -1
- data/wrnap.gemspec +7 -3
- metadata +71 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2efcb65abde80f14ce6f0e5eba3d5438b23ba33
|
4
|
+
data.tar.gz: 6c7873c5b0936b137a7f0f957f4853bcdc48d345
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa223b71c6b69f3207ebf76b4b34b90a73d4686293adc10579936d3ac609247648ff62dd1f4cf529ac6be9b8fa28010151c673c39c6d0ef4040ecacc07a3875f
|
7
|
+
data.tar.gz: 3808f6f38a0c3a9a5877e3d829afab5fe11766d31dd55a1091207a774dfa31b87d3b4376a1baaf1adc15c396d6cc85f403e4af30eb031a5f5f83964ee5bf4b88
|
data/lib/wrnap/package/fft_eq.rb
CHANGED
@@ -8,12 +8,13 @@ module Wrnap
|
|
8
8
|
"-fftbor2d-i" => context.data.seq,
|
9
9
|
"-fftbor2d-j" => context.data.str_1,
|
10
10
|
"-fftbor2d-k" => context.data.str_2,
|
11
|
-
"-population-
|
11
|
+
"-population-q" => true
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
15
|
def post_process
|
16
|
-
|
16
|
+
raw_eq_time = (response.match(/index\tlogtime\n\d+\t(.*)\n/) || [])[1] || ""
|
17
|
+
@equilibrium = (raw_eq_time =~ /^(|-?Infinity)$/ ? -1 : 10 ** raw_eq_time.to_f)
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -2,12 +2,12 @@ module Wrnap
|
|
2
2
|
module Package
|
3
3
|
class Fftbor2d < EnergyGrid2d
|
4
4
|
self.executable_name = "FFTbor2D"
|
5
|
-
self.default_flags = ->(_, flags) { (flags.keys & %i|
|
5
|
+
self.default_flags = ->(_, flags) { (flags.keys & %i|m s|).empty? ? { s: :empty } : {} }
|
6
6
|
|
7
7
|
def run_command(flags)
|
8
8
|
Wrnap.debugger { "Running #{exec_name} on #{data.inspect}" }
|
9
9
|
|
10
|
-
"%s %s %s" % [
|
10
|
+
"%s %s -f %s" % [
|
11
11
|
exec_name,
|
12
12
|
stringify_flags(flags),
|
13
13
|
data.temp_fa_file!
|
@@ -15,7 +15,7 @@ module Wrnap
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def distribution
|
18
|
-
response.split(/\n/).map { |line| line.
|
18
|
+
response.split(/\n/).map { |line| line.scanf("%d\t%d\t%f\t%f") }
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/lib/wrnap/rna/box.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Wrnap
|
2
2
|
class Rna
|
3
3
|
class Box
|
4
|
+
prepend MetaMissing
|
4
5
|
extend Forwardable
|
5
6
|
include Enumerable
|
6
7
|
include Wrnap::Global::Yaml
|
@@ -9,7 +10,10 @@ module Wrnap
|
|
9
10
|
|
10
11
|
class << self
|
11
12
|
def load_all(pattern = "*.fa", &block)
|
12
|
-
new(Dir[File.directory?(pattern) ? pattern
|
13
|
+
new(Dir[File.directory?(pattern) ? File.join(pattern, "*.fa") : pattern].inject([]) do |array, file|
|
14
|
+
loaded_rnas = RNA.from_fasta(file, &block)
|
15
|
+
array + (loaded_rnas.is_a?(Box) ? loaded_rnas.rnas : [loaded_rnas])
|
16
|
+
end)
|
13
17
|
end
|
14
18
|
end
|
15
19
|
|
@@ -47,10 +51,8 @@ module Wrnap
|
|
47
51
|
klass == Array ? true : super
|
48
52
|
end
|
49
53
|
|
50
|
-
|
51
|
-
|
52
|
-
run_in_parallel(name_str, *args)
|
53
|
-
else super end
|
54
|
+
handle_methods_like(/^run_\w+$/) do |match, name, *args, &block|
|
55
|
+
run_in_parallel(name, *args)
|
54
56
|
end
|
55
57
|
|
56
58
|
def inspect
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "tree.rb")
|
2
|
+
|
1
3
|
module Wrnap
|
2
4
|
class Rna
|
3
5
|
module Constraints
|
@@ -22,6 +24,8 @@ module Wrnap
|
|
22
24
|
end
|
23
25
|
|
24
26
|
class ConstraintBox
|
27
|
+
prepend MetaMissing
|
28
|
+
|
25
29
|
attr_reader :rna, :constraints
|
26
30
|
|
27
31
|
def initialize(rna)
|
@@ -100,21 +104,19 @@ module Wrnap
|
|
100
104
|
end
|
101
105
|
end
|
102
106
|
|
103
|
-
|
107
|
+
alias_method :mask, :to_s
|
104
108
|
|
105
|
-
|
106
|
-
|
109
|
+
handle_methods_like(TreeStem::STEM_NOTATION_REGEX) do |match, name, *args, &block|
|
110
|
+
rna.trunk.send(name.to_s)
|
111
|
+
end
|
112
|
+
|
113
|
+
handle_methods_like(/^(prohibit|force)(_(left|right)_stem)?$/) do |match, name, *args, &block|
|
114
|
+
side_symbol = match[3] ? match[3].to_sym : :both
|
107
115
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
case mask_type[1]
|
114
|
-
when "prohibit" then mask!(args[0], side: side_symbol, symbol: args[1] || ?x)
|
115
|
-
when "force" then mask!(args[0], side: side_symbol, symbol: args[1] || "()")
|
116
|
-
end
|
117
|
-
else super end
|
116
|
+
case match[1]
|
117
|
+
when "prohibit" then mask!(args[0], side: side_symbol, symbol: args[1] || ?x)
|
118
|
+
when "force" then mask!(args[0], side: side_symbol, symbol: args[1] || "()")
|
119
|
+
end
|
118
120
|
end
|
119
121
|
end
|
120
122
|
|
data/lib/wrnap/rna/context.rb
CHANGED
@@ -40,10 +40,9 @@ module Wrnap
|
|
40
40
|
end
|
41
41
|
|
42
42
|
super(
|
43
|
-
sequence:
|
44
|
-
|
45
|
-
|
46
|
-
comment: options[:rna][:comment] || options[:rna][:name] || identifier,
|
43
|
+
sequence: self.sequence,
|
44
|
+
structures: options[:rna][:structures] || options[:rna][:structure] || options[:rna][:strs] || options[:rna][:str],
|
45
|
+
comment: options[:rna][:comment] || options[:rna][:name] || identifier,
|
47
46
|
&block
|
48
47
|
)
|
49
48
|
|
@@ -94,7 +93,7 @@ module Wrnap
|
|
94
93
|
!plus_strand?
|
95
94
|
end
|
96
95
|
|
97
|
-
def sequence
|
96
|
+
alias_method :seq, def sequence
|
98
97
|
if @raw_sequence
|
99
98
|
@raw_sequence
|
100
99
|
else
|
@@ -102,8 +101,6 @@ module Wrnap
|
|
102
101
|
@raw_sequence = (minus_strand? ? entrez_sequence.complement : entrez_sequence).upcase
|
103
102
|
end
|
104
103
|
end
|
105
|
-
|
106
|
-
alias :seq :sequence
|
107
104
|
|
108
105
|
def_delegator :@raw_sequence, :length, :len
|
109
106
|
|
data/lib/wrnap/rna/extensions.rb
CHANGED
@@ -46,6 +46,11 @@ module Wrnap
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def local_structural_shuffle(dishuffle: false)
|
49
|
+
# Permutes the base pairs of the structure provided for the template sequence independently of the unpaired regions, as in
|
50
|
+
# global_structural_shuffle. This adds the additional constraint that loops and helices are permuted as individual sets,
|
51
|
+
# rather than using two global loop / helix bags.
|
52
|
+
raise "the structural_shuffle functions require the initial RNA to have a structure" unless str
|
53
|
+
|
49
54
|
sequence = " " * len
|
50
55
|
loops, helices = loops_and_helices
|
51
56
|
|
@@ -69,6 +74,10 @@ module Wrnap
|
|
69
74
|
end
|
70
75
|
|
71
76
|
def global_structural_shuffle
|
77
|
+
# Permutes the nucleotides of the sequence such that the basepairs in the initial structure are shuffled independently of the
|
78
|
+
# unpaired bases. This ensures that the resulting sequence is compatible with the original structure.
|
79
|
+
raise "the structural_shuffle functions require the initial RNA to have a structure" unless str
|
80
|
+
|
72
81
|
sequence = " " * len
|
73
82
|
loops, helices = loops_and_helices
|
74
83
|
shuffled_loops = Shuffle.new(loops.map { |loop| loop.in(seq) }.join.split(//)).shuffle
|
data/lib/wrnap/rna/metadata.rb
CHANGED
@@ -28,12 +28,10 @@ module Wrnap
|
|
28
28
|
@__rna__, @__data__ = rna, {}
|
29
29
|
end
|
30
30
|
|
31
|
-
def inspect
|
31
|
+
alias_method :to_s, def inspect
|
32
32
|
"#<Metadata: %s>" % __data__.inspect
|
33
33
|
end
|
34
34
|
|
35
|
-
alias :to_s :inspect
|
36
|
-
|
37
35
|
def method_missing(name, *args, &block)
|
38
36
|
case args.size
|
39
37
|
when 0 then __data__[name]
|
data/lib/wrnap/rna/tree.rb
CHANGED
@@ -11,6 +11,7 @@ module Wrnap
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class TreeStem < Tree::TreeNode
|
14
|
+
prepend MetaMissing
|
14
15
|
extend Forwardable
|
15
16
|
include Enumerable
|
16
17
|
|
@@ -19,6 +20,10 @@ module Wrnap
|
|
19
20
|
def_delegators :@content, :i, :j, :k, :l
|
20
21
|
def_delegator :@content, :length, :stem_length
|
21
22
|
|
23
|
+
def in(sequence)
|
24
|
+
sequence[i..j]
|
25
|
+
end
|
26
|
+
|
22
27
|
def unpaired_regions
|
23
28
|
Wrnap.debugger { "Collecting unpaired regions for %s" % [root.content.name] }
|
24
29
|
|
@@ -78,26 +83,27 @@ module Wrnap
|
|
78
83
|
children.each { |child| child.postorder_traversal(&block) }
|
79
84
|
yield self
|
80
85
|
end
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
end
|
86
|
+
|
87
|
+
handle_methods_like(STEM_NOTATION_REGEX) do |match, name, *args, &block|
|
88
|
+
method_name = name.to_s
|
89
|
+
call_type = method_name[0]
|
90
|
+
indices = method_name.gsub(/\D+/, ?_).split(?_).reject(&:empty?).map(&:to_i)
|
91
|
+
helix_index = method_name.match(/([ijkl])$/) ? $1 : ""
|
92
|
+
|
93
|
+
if indices.size > 1 && child = children[indices[0] - 1]
|
94
|
+
child.send(call_type + indices[1..-1].join(?_) + helix_index)
|
95
|
+
elsif child = children[indices[0] - 1]
|
96
|
+
case call_type
|
97
|
+
when ?p then helix_index.empty? ? child.content : child.send(helix_index)
|
98
|
+
when ?t then child
|
95
99
|
end
|
96
|
-
|
100
|
+
end
|
97
101
|
end
|
98
102
|
end
|
99
103
|
|
100
104
|
class TreePlanter
|
105
|
+
prepend MetaMissing
|
106
|
+
|
101
107
|
attr_reader :rna, :root
|
102
108
|
|
103
109
|
def initialize(rna, tree = false)
|
@@ -144,7 +150,7 @@ module Wrnap
|
|
144
150
|
end
|
145
151
|
|
146
152
|
def coalesce
|
147
|
-
self.class.new(rna, root.
|
153
|
+
self.class.new(rna, root.clone).tap { |tree| tree.merge_interior_loops! }
|
148
154
|
end
|
149
155
|
|
150
156
|
def coalesce!
|
@@ -152,7 +158,7 @@ module Wrnap
|
|
152
158
|
end
|
153
159
|
|
154
160
|
def fuse
|
155
|
-
self.class.new(rna, root.
|
161
|
+
self.class.new(rna, root.clone).tap { |tree| tree.extend_interior_loops! }
|
156
162
|
end
|
157
163
|
|
158
164
|
def fuse!
|
@@ -194,16 +200,12 @@ module Wrnap
|
|
194
200
|
root.print_tree and nil
|
195
201
|
end
|
196
202
|
|
197
|
-
def inspect
|
203
|
+
alias_method :to_s, def inspect
|
198
204
|
"#<TreePlanter: %s>" % depth_signature.inspect
|
199
205
|
end
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
def method_missing(name, *args, &block)
|
204
|
-
if name.to_s =~ TreeStem::STEM_NOTATION_REGEX
|
205
|
-
root.send(name, *args, &block)
|
206
|
-
else super end
|
206
|
+
|
207
|
+
handle_methods_like(TreeStem::STEM_NOTATION_REGEX) do |match, name, *args, &block|
|
208
|
+
root.send(name, *args, &block)
|
207
209
|
end
|
208
210
|
end
|
209
211
|
end
|
data/lib/wrnap/rna.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Wrnap
|
2
2
|
class Rna
|
3
|
+
prepend MetaMissing
|
3
4
|
extend Forwardable
|
4
5
|
include Wrnap::Global::Yaml
|
5
6
|
include Wrnap::Rna::Extensions
|
@@ -11,25 +12,28 @@ module Wrnap
|
|
11
12
|
CANONICAL_BASES = Set.new << Set.new([?G, ?C]) << Set.new([?A, ?U]) << Set.new([?G, ?U])
|
12
13
|
|
13
14
|
attr_accessor :comment
|
14
|
-
attr_reader
|
15
|
+
attr_reader :sequence, :structures, :metadata
|
15
16
|
|
16
17
|
class << self
|
17
|
-
def init_from_string(sequence,
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
)
|
18
|
+
def init_from_string(sequence, *remaining_args, &block)
|
19
|
+
init_from_hash(parse_rna_attributes(sequence, remaining_args), &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
def parse_rna_attributes(sequence, attributes = [])
|
23
|
+
last_arg = (attributes = attributes.flatten).last
|
24
|
+
|
25
|
+
if last_arg.is_a?(Symbol) || Regexp.compile("^[\\.\\(\\)]{%d}$" % sequence.length) =~ last_arg
|
26
|
+
{ seq: sequence, strs: attributes }
|
27
|
+
else
|
28
|
+
{ seq: sequence, strs: attributes[0..-2], comment: last_arg }
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
32
|
def init_from_hash(hash, &block)
|
28
33
|
new(
|
29
|
-
sequence:
|
30
|
-
|
31
|
-
|
32
|
-
comment: hash[:comment] || hash[:name],
|
34
|
+
sequence: hash[:sequence] || hash[:seq],
|
35
|
+
structures: hash[:structures] || hash[:structure] || hash[:strs] || hash[:str],
|
36
|
+
comment: hash[:comment] || hash[:name],
|
33
37
|
&block
|
34
38
|
)
|
35
39
|
end
|
@@ -38,7 +42,7 @@ module Wrnap
|
|
38
42
|
init_from_string(*array, &block)
|
39
43
|
end
|
40
44
|
|
41
|
-
def init_from_fasta(string, &block)
|
45
|
+
alias_method :init_from_fa, def init_from_fasta(string, &block)
|
42
46
|
if File.exist?(string)
|
43
47
|
comment = File.basename(string, string.include?(?.) ? ".%s" % string.split(?.)[-1] : "")
|
44
48
|
string = File.read(string).chomp
|
@@ -46,12 +50,12 @@ module Wrnap
|
|
46
50
|
|
47
51
|
if string.count(?>) > 1
|
48
52
|
string.split(/>/).reject(&:empty?).map do |rna_string|
|
49
|
-
rna_data = rna_string.split(?\n)
|
53
|
+
rna_data = rna_string.split(?\n).reject(&:empty?)
|
50
54
|
init_from_string(*rna_data[1..-1]).copy_name_from(rna_data[0])
|
51
55
|
end.wrnap
|
52
56
|
else
|
53
|
-
init_from_string(*string.split(
|
54
|
-
if (line = string.split(
|
57
|
+
init_from_string(*string.split(?\n).reject { |line| line.start_with?(?>) || line.empty? }, &block).tap do |rna|
|
58
|
+
if (line = string.split(?\n).first).start_with?(?>) && !(file_comment = line.gsub(/^>\s*/, "")).empty?
|
55
59
|
rna.comment = file_comment
|
56
60
|
elsif comment
|
57
61
|
rna.comment = comment
|
@@ -67,100 +71,99 @@ module Wrnap
|
|
67
71
|
def init_from_self(rna, &block)
|
68
72
|
# This happens when you call a Wrnap library function with the output of something like Wrnap::Fold.run(...).mfe
|
69
73
|
new(
|
70
|
-
sequence:
|
71
|
-
|
72
|
-
|
73
|
-
comment: rna.comment,
|
74
|
+
sequence: rna.sequence,
|
75
|
+
structures: rna.structures,
|
76
|
+
comment: rna.comment,
|
74
77
|
&block
|
75
|
-
)
|
78
|
+
).tap do |new_rna|
|
79
|
+
new_rna.instance_variable_set(:@metadata, rna.metadata.clone)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def init_from_old_rna_object(rna)
|
84
|
+
init_from_self(rna).tap do |new_rna|
|
85
|
+
new_rna.instance_variable_set(:@structures, [
|
86
|
+
rna.instance_variable_get(:@structure),
|
87
|
+
rna.instance_variable_get(:@second_structure)
|
88
|
+
].compact)
|
89
|
+
end
|
76
90
|
end
|
77
91
|
|
78
92
|
alias_method :placeholder, :new
|
79
93
|
end
|
80
94
|
|
81
|
-
def initialize(sequence: "",
|
82
|
-
@sequence
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
end
|
95
|
+
def initialize(sequence: "", structures: [], comment: "", &block)
|
96
|
+
@sequence = (sequence.kind_of?(Rna) ? sequence.seq : sequence).upcase
|
97
|
+
@comment = comment
|
98
|
+
@metadata = Metadata::Container.new(self)
|
99
|
+
@structures = (structures ? [structures].flatten : []).each_with_index.map do |structure, i|
|
100
|
+
case structure
|
101
|
+
when :empty, :empty_str then empty_structure
|
102
|
+
when :mfe then RNA(@sequence).run(:fold).mfe_rna.structure
|
103
|
+
when String then structure
|
104
|
+
when Hash then
|
105
|
+
if structure.keys.count > 1
|
106
|
+
Wrnap.debugger { "The following options hash has more than one key. This will probably produce unpredictable results: %s" % structure.inspect }
|
107
|
+
end
|
95
108
|
|
96
|
-
|
109
|
+
RNA(@sequence).run(*structure.keys, *structure.values).mfe_rna.structure
|
110
|
+
end.tap do |parsed_structure|
|
111
|
+
if parsed_structure.length != len
|
112
|
+
Wrnap.debugger { "The sequence length (%d) doesn't match the structure length at index %d (%d)" % [len, i, parsed_structure.length] }
|
97
113
|
end
|
98
|
-
|
114
|
+
end
|
99
115
|
end
|
100
116
|
|
101
117
|
metadata.instance_eval(&block) if block_given?
|
102
|
-
|
103
|
-
if str && len != str.length
|
104
|
-
Wrnap.debugger { "The sequence length (%d) doesn't match the structure length (%d)" % [seq, str].map(&:length) }
|
105
|
-
end
|
106
|
-
|
107
|
-
if str_2 && str_1.length != str_2.length
|
108
|
-
Wrnap.debugger { "The first structure length (%d) doesn't match the second structure length (%d)" % [str_1, str_2].map(&:length) }
|
109
|
-
end
|
110
118
|
end
|
111
119
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
alias :str_2 :second_structure
|
116
|
-
alias :name :comment
|
120
|
+
alias_method :seq, :sequence
|
121
|
+
alias_method :strs, :structures
|
122
|
+
alias_method :name, :comment
|
117
123
|
|
118
|
-
def_delegator :@sequence,
|
124
|
+
def_delegator :@sequence, :length, :len
|
125
|
+
def_delegator :@structures, :first, :structure
|
126
|
+
def_delegator :@structures, :first, :str
|
119
127
|
|
120
128
|
def copy_name_from(nameish)
|
121
129
|
tap { @comment = nameish.is_a?(String) ? nameish : nameish.name }
|
122
130
|
end
|
131
|
+
|
132
|
+
alias_method :num_strs, def number_of_structures
|
133
|
+
structures.length
|
134
|
+
end
|
123
135
|
|
124
|
-
def empty_structure
|
136
|
+
alias_method :empty_str, def empty_structure
|
125
137
|
"." * len
|
126
138
|
end
|
127
139
|
|
128
|
-
|
129
|
-
|
130
|
-
def no_structure
|
131
|
-
self.class.init_from_string(seq, nil, nil, name)
|
140
|
+
alias_method :no_str, def no_structure
|
141
|
+
self.class.init_from_string(seq, name)
|
132
142
|
end
|
133
143
|
|
134
|
-
|
135
|
-
|
136
|
-
def one_structure(structure_1)
|
137
|
-
self.class.init_from_string(seq, structure_1.is_a?(Symbol) ? send(structure_1) : structure_1, nil, name)
|
144
|
+
alias_method :one_str, def one_structure(structure_1)
|
145
|
+
self.class.init_from_string(seq, structure_1.is_a?(Symbol) ? send(structure_1) : structure_1, name)
|
138
146
|
end
|
139
147
|
|
140
|
-
|
141
|
-
|
142
|
-
def two_structures(structure_1, structure_2)
|
148
|
+
alias_method :two_str, def two_structures(structure_1, structure_2)
|
143
149
|
self.class.init_from_string(
|
144
150
|
seq,
|
145
|
-
|
151
|
+
[structure_1, structure_2].map { |argument| argument.is_a?(Symbol) ? send(argument) : argument },
|
146
152
|
name
|
147
153
|
)
|
148
154
|
end
|
149
|
-
|
150
|
-
alias :two_str :two_structures
|
151
155
|
|
152
156
|
def formatted_string
|
153
157
|
[
|
154
|
-
(">%s" % name
|
155
|
-
("%s" % seq
|
156
|
-
|
157
|
-
("%s" % str_2 if str_2)
|
158
|
+
(">%s" % name if name),
|
159
|
+
("%s" % seq if seq),
|
160
|
+
*structures
|
158
161
|
].compact.join(?\n)
|
159
162
|
end
|
160
163
|
|
161
164
|
def write_fa!(filename)
|
162
165
|
filename.tap do |filename|
|
163
|
-
File.open(filename, ?w) { |file| file.write(formatted_string) }
|
166
|
+
File.open(filename, ?w) { |file| file.write(formatted_string + ?\n) }
|
164
167
|
end
|
165
168
|
end
|
166
169
|
|
@@ -180,24 +183,25 @@ module Wrnap
|
|
180
183
|
other_rna.kind_of?(Wrnap::Rna) ? [seq, str_1, str_2] == [other_rna.seq, other_rna.str_1, other_rna.str_2] : super
|
181
184
|
end
|
182
185
|
|
183
|
-
def method_missing(name, *args, &block)
|
184
|
-
if (name_str = "#{name}") =~ /^run_\w+$/
|
185
|
-
run(name_str.gsub(/^run_/, ""), *args)
|
186
|
-
else super end
|
187
|
-
end
|
188
|
-
|
189
186
|
def pp
|
190
187
|
puts(formatted_string)
|
191
188
|
end
|
192
189
|
|
193
190
|
def inspect
|
194
191
|
"#<RNA: %s>" % [
|
195
|
-
("#{seq[0, 20]
|
196
|
-
("#{
|
197
|
-
("#{str_2[0, 20] + (str_2.length > 20 ? ' [%d]' % str_2.length : '')}" if str_2 && !str_1.empty?),
|
192
|
+
("#{seq[0, 20] + (len > 20 ? '... [%d]' % len : '')}" if seq && !seq.empty?),
|
193
|
+
*strs.map { |str| ("#{str[0, 20] + (str.length > 20 ? ' [%d]' % str.length : '')}" if str && !str.empty?) },
|
198
194
|
(md.inspect unless md.nil? || md.empty?),
|
199
195
|
(name ? name : "#{self.class.name}")
|
200
196
|
].compact.join(", ")
|
201
197
|
end
|
198
|
+
|
199
|
+
handle_methods_like(/^str(ucture)?_(\d+)$/) do |match, name, *args, &block|
|
200
|
+
structures[match[2].to_i - 1]
|
201
|
+
end
|
202
|
+
|
203
|
+
handle_methods_like(/^run_(\w+)$/) do |match, name, *args, &block|
|
204
|
+
run(match[1], *args)
|
205
|
+
end
|
202
206
|
end
|
203
207
|
end
|
data/lib/wrnap/version.rb
CHANGED
data/lib/wrnap.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
|
-
require "active_support/core_ext
|
1
|
+
require "active_support/core_ext"
|
2
2
|
require "active_support/inflector"
|
3
3
|
require "benchmark"
|
4
4
|
require "bigdecimal"
|
5
5
|
require "bio"
|
6
6
|
require "bio-stockholm"
|
7
7
|
require "entrez"
|
8
|
+
require "meta_missing"
|
9
|
+
require "numbers_in_words"
|
10
|
+
require "numbers_in_words/duck_punch"
|
8
11
|
require "parallel"
|
9
12
|
require "rroc"
|
13
|
+
require "scanf"
|
10
14
|
require "set"
|
11
15
|
require "shuffle"
|
12
16
|
require "tempfile"
|
data/wrnap.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Wrnap::VERSION
|
9
9
|
spec.authors = ["Evan Senter"]
|
10
10
|
spec.email = ["evansenter@gmail.com"]
|
11
|
-
spec.summary = %q{A comprehensive wrapper (
|
11
|
+
spec.summary = %q{A comprehensive wrapper w(RNA)pper for various RNA CLI programs.}
|
12
12
|
spec.description = %q{}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
@@ -20,13 +20,17 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.required_ruby_version = ">= 2.0"
|
22
22
|
|
23
|
-
spec.add_development_dependency "
|
24
|
-
spec.add_development_dependency "
|
23
|
+
spec.add_development_dependency "awesome_print", "~> 1.2.0"
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "gem-release", "~> 0.7", ">= 0.7.3"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
27
|
|
26
28
|
spec.add_runtime_dependency "activesupport", "~> 4.0"
|
27
29
|
spec.add_runtime_dependency "bio", "~> 1.4"
|
28
30
|
spec.add_runtime_dependency "bio-stockholm", "~> 0.0.1"
|
29
31
|
spec.add_runtime_dependency "entrez", "~> 0.5"
|
32
|
+
spec.add_runtime_dependency "meta_missing", "~> 0.3.0"
|
33
|
+
spec.add_runtime_dependency "numbers_in_words", "~> 0.2.0"
|
30
34
|
spec.add_runtime_dependency "parallel", "~> 1.3", ">= 1.3.2"
|
31
35
|
spec.add_runtime_dependency "rinruby", "~> 2.0"
|
32
36
|
spec.add_runtime_dependency "rroc", "~> 0.1"
|
metadata
CHANGED
@@ -1,43 +1,77 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wrnap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Senter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: awesome_print
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.2.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.2.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
33
|
+
version: '1.7'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
40
|
+
version: '1.7'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
42
|
+
name: gem-release
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.7'
|
31
48
|
- - ">="
|
32
49
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
50
|
+
version: 0.7.3
|
34
51
|
type: :development
|
35
52
|
prerelease: false
|
36
53
|
version_requirements: !ruby/object:Gem::Requirement
|
37
54
|
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0.7'
|
38
58
|
- - ">="
|
39
59
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
60
|
+
version: 0.7.3
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '10.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '10.0'
|
41
75
|
- !ruby/object:Gem::Dependency
|
42
76
|
name: activesupport
|
43
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +128,34 @@ dependencies:
|
|
94
128
|
- - "~>"
|
95
129
|
- !ruby/object:Gem::Version
|
96
130
|
version: '0.5'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: meta_missing
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 0.3.0
|
138
|
+
type: :runtime
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 0.3.0
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: numbers_in_words
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: 0.2.0
|
152
|
+
type: :runtime
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: 0.2.0
|
97
159
|
- !ruby/object:Gem::Dependency
|
98
160
|
name: parallel
|
99
161
|
requirement: !ruby/object:Gem::Requirement
|
@@ -272,9 +334,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
334
|
version: '0'
|
273
335
|
requirements: []
|
274
336
|
rubyforge_project:
|
275
|
-
rubygems_version: 2.4.
|
337
|
+
rubygems_version: 2.4.5
|
276
338
|
signing_key:
|
277
339
|
specification_version: 4
|
278
|
-
summary: A comprehensive wrapper (
|
340
|
+
summary: A comprehensive wrapper w(RNA)pper for various RNA CLI programs.
|
279
341
|
test_files: []
|
280
|
-
has_rdoc:
|