vienna_rna 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 099ebe746d12378a62249b9a704ad6774f81e517
4
- data.tar.gz: bb38709cf960d5502eaecc608dc848acfdd10abf
3
+ metadata.gz: 7052b517f156ae06e8dee54850909dc0555c2453
4
+ data.tar.gz: 7e0f124fa04b9077cb18475d80180723d9e4de24
5
5
  SHA512:
6
- metadata.gz: ae8e3aa5cc99791d32f736a3bc20ef38a0e8a71aa79c96748bd1ceab68a8921e0d3df2519c65c3fd8028e4a3f4866aa001ee7f3a24de3046ac77440e8e8d4945
7
- data.tar.gz: 5c35acf8d8ab2d1563c61c7ded6b1dfc155dce50d3e63818a01cebd4abe05eb8b7d3d10432f0ae3edf13d2bce04ebbe097ef2e57f862b2b2970b8ea4780628cd
6
+ metadata.gz: f3faaa79b78b25fbb1f73ddf3f58a38335c9b808745fe427f0b6c7ff4ee3f4c445dabb55a9bccb46f782faec2fcaf9670fae638e26aed1ba9758d7b7e805f435
7
+ data.tar.gz: 197f8084f6591c0c99efe740bfde4741fa9dbbab54a18fa30a6932f6305049f514b998a78c3711222b08fa5a11bf64fd018fd60b479e98d11db01ca3fd00685b
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  ViennaRna
2
2
  ------------------------
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/vienna_rna.png)](http://badge.fury.io/rb/vienna_rna)
5
+
4
6
  A simple gem for facilitating bindings to the ViennaRNA package (http://www.tbi.univie.ac.at/~ivo/RNA/), amongst other RNA packages. Note that this gem makes no effort to build and install the ViennaRNA suite locally at this time, and instead relies on its presence on the host machine. Also includes a lot of utilities surrounding RNA sequence / structure parsing, graphing using R (via RinRuby) and other analysis tools. Used privately as the foundation for much of the research I do at http://bioinformatics.bc.edu/clotelab/
5
7
 
6
8
  Simple use case:
@@ -63,8 +63,8 @@ unless defined? RNA
63
63
  end
64
64
 
65
65
  module RNA
66
- def self.load_all(pattern: "*.fa")
67
- Dir[pattern].map { |file| RNA.from_fasta(file) }
66
+ def self.load_all(pattern = "*.fa")
67
+ Dir[File.directory?(pattern) ? pattern + "/*.fa" : pattern].map { |file| RNA.from_fasta(file) }
68
68
  end
69
69
 
70
70
  def self.random(size, *args)
@@ -140,7 +140,7 @@ module ViennaRna
140
140
  ("#{seq[0, 20] + (seq.length > 20 ? '... [%d]' % seq.length : '')}" if seq && !seq.empty?),
141
141
  ("#{str_1[0, 20] + (str_1.length > 20 ? ' [%d]' % seq.length : '')}" if str_1 && !str_1.empty?),
142
142
  ("#{str_2[0, 20] + (str_2.length > 20 ? ' [%d]' % seq.length : '')}" if str_2 && !str_1.empty?),
143
- (!name.empty? ? name : "#{self.class.name}")
143
+ (name ? name : "#{self.class.name}")
144
144
  ].compact.join(", ")
145
145
  end
146
146
  end
@@ -2,43 +2,18 @@ module ViennaRna
2
2
  module Package
3
3
  class Fftbor2d < EnergyGrid2d
4
4
  self.executable_name = "FFTbor2D"
5
- self.default_flags = ->(_, flags) { (flags.keys & %i|X Y M S|).empty? ? { S: :empty } : {} }
6
-
7
- attr_reader :population_proportion_str_2_from_str_1, :population_proportion_for_str_1
8
-
9
- class Population
10
- attr_reader :proportion_over_time
11
-
12
- def initialize(time, proportion)
13
- @proportion_over_time = time.zip(proportion)
14
- end
15
-
16
- def time_range(from, to)
17
- proportion_over_time.select { |time, _| ((from.to_f)..(to.to_f)) === time }
18
- end
19
-
20
- def time_points; proportion_over_time.map(&:first); end
21
- def proportion_points; proportion_over_time.map(&:last); end
22
- end
5
+ self.default_flags = ->(_, flags) { (flags.keys & %i|M S|).empty? ? { S: :empty } : {} }
23
6
 
24
7
  def run_command(flags)
25
8
  ViennaRna.debugger { "Running #{exec_name} on #{data.inspect}" }
26
-
9
+
27
10
  "%s %s %s" % [
28
- exec_name,
11
+ exec_name,
29
12
  stringify_flags(flags),
30
13
  data.temp_fa_file!
31
14
  ]
32
15
  end
33
-
34
- def post_process
35
- if flags.keys.include?(:Y)
36
- time_points, proportion_str_2_from_str_1, proportion_for_str_1 = response.split(/\n/).map { |line| line.split(/\t/).map(&:to_f) }.transpose
37
- @population_proportion_str_2_from_str_1 = Population.new(time_points, proportion_str_2_from_str_1)
38
- @population_proportion_for_str_1 = Population.new(time_points, proportion_for_str_1)
39
- end
40
- end
41
-
16
+
42
17
  def distribution
43
18
  response.split(/\n/).map { |line| line.split(/\t/) }
44
19
  end
@@ -0,0 +1,19 @@
1
+ module ViennaRna
2
+ module Package
3
+ class Plot < Base
4
+ self.call_with = [ :comment, :seq, :str]
5
+ self.default_flags = {
6
+ t: 0,
7
+ o: "svg"
8
+ }
9
+
10
+ def run_command(flags)
11
+ "cat %s | %s %s" % [
12
+ data.temp_fa_file!,
13
+ exec_name,
14
+ stringify_flags(flags)
15
+ ]
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,38 @@
1
+ module ViennaRna
2
+ module Package
3
+ class Population < Base
4
+ attr_reader :population_proportion_str_2_from_str_1, :population_proportion_for_str_1
5
+
6
+ class Population
7
+ attr_reader :proportion_over_time
8
+
9
+ def initialize(time, proportion)
10
+ @proportion_over_time = time.zip(proportion)
11
+ end
12
+
13
+ def time_range(from, to)
14
+ proportion_over_time.select { |time, _| ((from.to_f)..(to.to_f)) === time }
15
+ end
16
+
17
+ def time_points; proportion_over_time.map(&:first); end
18
+ def proportion_points; proportion_over_time.map(&:last); end
19
+ end
20
+
21
+ def run_command(flags)
22
+ ViennaRna.debugger { "Running #{exec_name} on #{data.inspect}" }
23
+
24
+ "%s %s %s" % [
25
+ exec_name,
26
+ stringify_flags(flags),
27
+ data.temp_fa_file!
28
+ ]
29
+ end
30
+
31
+ def post_process
32
+ time_points, proportion_str_2_from_str_1, proportion_for_str_1 = response.split(/\n/).map { |line| line.split(/\t/).map(&:to_f) }.transpose
33
+ @population_proportion_str_2_from_str_1 = Population.new(time_points, proportion_str_2_from_str_1)
34
+ @population_proportion_for_str_1 = Population.new(time_points, proportion_for_str_1)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -2,11 +2,18 @@ module ViennaRna
2
2
  module Package
3
3
  class Subopt < Base
4
4
  attr_reader :structures
5
-
5
+
6
6
  def post_process
7
- @structures = response.split(/\n/)[1..-1].map { |output| RNA.from_string(data.seq, output.split(/\s+/).first) }
7
+ @structures = response.split(/\n/)[1..-1].map do |output|
8
+ structure, mfe = output.split(/\s+/)
9
+
10
+ RNA.from_string(data.seq, structure).tap do |rna|
11
+ rna.instance_variable_set(:@mfe, mfe.to_f)
12
+ rna.class_eval { attr_reader :mfe }
13
+ end
14
+ end
8
15
  end
9
-
16
+
10
17
  def bin(count = 1)
11
18
  run(p: count).structures.inject(Hash.new { |hash, key| hash[key] = 0 }) do |hash, structure|
12
19
  hash.tap do
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.13.0
4
+ version: 0.14.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: 2014-02-06 00:00:00.000000000 Z
11
+ date: 2014-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: shuffle
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -111,6 +111,8 @@ files:
111
111
  - lib/vienna_rna/package/heat.rb
112
112
  - lib/vienna_rna/package/kinwalker.rb
113
113
  - lib/vienna_rna/package/mfpt.rb
114
+ - lib/vienna_rna/package/plot.rb
115
+ - lib/vienna_rna/package/population.rb
114
116
  - lib/vienna_rna/package/rna2dfold.rb
115
117
  - lib/vienna_rna/package/rnabor.rb
116
118
  - lib/vienna_rna/package/spectral.rb
@@ -118,7 +120,8 @@ files:
118
120
  - lib/vienna_rna/package/tabu_path.rb
119
121
  - lib/vienna_rna/package/xbor.rb
120
122
  homepage: http://rubygems.org/gems/vienna_rna
121
- licenses: []
123
+ licenses:
124
+ - MIT
122
125
  metadata: {}
123
126
  post_install_message:
124
127
  rdoc_options: []
@@ -136,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
139
  version: '0'
137
140
  requirements: []
138
141
  rubyforge_project:
139
- rubygems_version: 2.2.1
142
+ rubygems_version: 2.2.2
140
143
  signing_key:
141
144
  specification_version: 4
142
145
  summary: Bindings to the Vienna RNA package, and other major command line utilities