vienna_rna 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/modules/base.rb CHANGED
@@ -25,13 +25,16 @@ module ViennaRna
25
25
  @exec_name || "rna#{self.class.name.split('::').last.underscore}"
26
26
  end
27
27
 
28
- def initialize(fasta)
29
- @fasta = fasta
28
+ def initialize(data)
29
+ @fasta = case data
30
+ when Bio::FastaFormat then data
31
+ when String then Bio::FastaFormat.new(data.split(/\n/).length > 1 ? data : ">\n%s" % data)
32
+ end
30
33
  end
31
34
 
32
35
  def run_with_hooks(flags = {})
33
36
  pre_run_check
34
- response = run_without_hooks
37
+ response = run_without_hooks(flags)
35
38
  self.class.method_defined?(:post_process) ? post_process(response) : response
36
39
  end
37
40
 
@@ -42,7 +45,7 @@ module ViennaRna
42
45
  end
43
46
 
44
47
  def stringify_flags(flags)
45
- flags.inject("") { |string, flag| (string + (" %s %s" % flag)).strip }
48
+ flags.inject("") { |string, flag| (string + (" -%s %s" % flag)).strip }
46
49
  end
47
50
 
48
51
  def run(flags = {})
data/lib/modules/fold.rb CHANGED
@@ -1,15 +1,24 @@
1
- # Rip this out, infer it through metaprogramming.
2
-
3
1
  module ViennaRna
4
2
  class Fold < Base
3
+ attr_reader :structure, :mfe
4
+
5
5
  def post_process(response)
6
- structure = response.split(/\n/).last.gsub(/ \(\s*-?\d*\.\d*\)$/, "")
6
+ tap do
7
+ structure = response.split(/\n/).last.gsub(/ \(\s*(-?\d*\.\d*)\)$/, "")
7
8
 
8
- unless fasta.seq.length == structure.length
9
- raise "Sequence: '#{fasta.seq}'\nStructure: '#{structure}'"
10
- else
11
- structure
9
+ unless fasta.seq.length == structure.length
10
+ raise "Sequence: '#{fasta.seq}'\nStructure: '#{structure}'"
11
+ else
12
+ @structure, @mfe = structure, $1
13
+ end
12
14
  end
13
15
  end
14
16
  end
17
+
18
+ # Mix this baby into the Batch class after I write it for great cleanness!
19
+ module Batch
20
+ def prune_same_structures
21
+
22
+ end
23
+ end
15
24
  end
@@ -0,0 +1,19 @@
1
+ module ViennaRna
2
+ class Subopt < Base
3
+ attr_reader :structures
4
+
5
+ def post_process(response)
6
+ tap do
7
+ @structures = response.split(/\n/)
8
+ end
9
+ end
10
+
11
+ def bin(count = 1)
12
+ run(p: count).structures.inject(Hash.new { |hash, key| hash[key] = 0 }) do |hash, structure|
13
+ hash.tap do
14
+ hash[structure] += 1
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
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.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bio
16
- requirement: &70224206504420 !ruby/object:Gem::Requirement
16
+ requirement: &70120459237640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70224206504420
24
+ version_requirements: *70120459237640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: active_support
27
- requirement: &70224206503980 !ruby/object:Gem::Requirement
27
+ requirement: &70120459237200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70224206503980
35
+ version_requirements: *70120459237200
36
36
  description: A Ruby API for interacting with the Vienna RNA package.
37
37
  email: evansenter@gmail.com
38
38
  executables: []
@@ -45,6 +45,8 @@ files:
45
45
  Li9saWIvbW9kdWxlcy9iYXRjaC5yYg==
46
46
  - !binary |-
47
47
  Li9saWIvbW9kdWxlcy9mb2xkLnJi
48
+ - !binary |-
49
+ Li9saWIvbW9kdWxlcy9zdWJvcHQucmI=
48
50
  - !binary |-
49
51
  Li9saWIvbW9kdWxlcy91dGlscy5yYg==
50
52
  - !binary |-