vienna_rna 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,51 @@
1
+ module ViennaRna
2
+ class Base
3
+ class_inheritable_accessor :exec_name
4
+
5
+ class << self
6
+ def method_added(name)
7
+ if name == :run
8
+ unless @chaining
9
+ @chaining = true
10
+ alias_method_chain :run, :hooks
11
+ else
12
+ remove_instance_variable(:@chaining)
13
+ end
14
+ end
15
+ end
16
+
17
+ def exec_exists?(name)
18
+ !%x[which rna#{name.to_s.downcase}].empty?
19
+ end
20
+ end
21
+
22
+ attr_reader :fasta
23
+
24
+ def exec_name
25
+ @exec_name || "rna#{self.class.name.split('::').last.underscore}"
26
+ end
27
+
28
+ def initialize(fasta)
29
+ @fasta = fasta
30
+ end
31
+
32
+ def run_with_hooks(flags = {})
33
+ pre_run_check
34
+ run_without_hooks
35
+ end
36
+
37
+ def pre_run_check
38
+ if self.class.exec_exists?(exec_name)
39
+ raise RuntimeError.new("#{exec_name} is not defined on this machine")
40
+ end
41
+ end
42
+
43
+ def stringify_flags(flags)
44
+ flags.inject("") { |string, flag| (string + (" %s %s" % flag)).strip }
45
+ end
46
+
47
+ def run(flags = {})
48
+ %x[echo #{fasta.seq} | #{exec_name} #{stringify_flags(flags)}]
49
+ end
50
+ end
51
+ end
@@ -0,0 +1 @@
1
+ # This should be a meta-overlord class that runs the same command on a collection of subclasses of base.rb
@@ -0,0 +1,7 @@
1
+ # Rip this out, infer it through metaprogramming.
2
+
3
+ module ViennaRna
4
+ class Fold < Base
5
+
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ # "/Users/evansenter/Source/mirna_5.1/hairpin.fa"
2
+
3
+ module ViennaRna
4
+ module Utils
5
+ class << self
6
+ def fastas_from_file(path)
7
+ # Force it to not be lazy.
8
+ Bio::FlatFile.auto(path).to_enum.map { |fasta| fasta }
9
+ end
10
+ end
11
+ end
12
+ end
data/lib/vienna_rna.rb ADDED
@@ -0,0 +1,19 @@
1
+ require "bio"
2
+ require "active_support/inflector"
3
+ require "active_support/core_ext/class"
4
+ require "active_support/core_ext/module"
5
+
6
+ # Clean up this include order.
7
+ Dir[File.join(File.dirname(__FILE__), "/modules/*")].each do |file|
8
+ require file
9
+ end
10
+
11
+ module ViennaRna
12
+ def self.const_missing(name)
13
+ if Base.exec_exists?(name)
14
+ module_eval do
15
+ const_set(name, Class.new(Base))
16
+ end
17
+ end
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vienna_rna
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Evan Senter
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bio
16
+ requirement: &70112760171500 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70112760171500
25
+ - !ruby/object:Gem::Dependency
26
+ name: active_support
27
+ requirement: &70112760171060 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70112760171060
36
+ description: A Ruby API for interacting with the Vienna RNA package.
37
+ email: evansenter@gmail.com
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - !binary |-
43
+ Li9saWIvbW9kdWxlcy9iYXNlLnJi
44
+ - !binary |-
45
+ Li9saWIvbW9kdWxlcy9iYXRjaC5yYg==
46
+ - !binary |-
47
+ Li9saWIvbW9kdWxlcy9mb2xkLnJi
48
+ - !binary |-
49
+ Li9saWIvbW9kdWxlcy91dGlscy5yYg==
50
+ - !binary |-
51
+ Li9saWIvdmllbm5hX3JuYS5yYg==
52
+ homepage: http://rubygems.org/gems/vienna_rna
53
+ licenses: []
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 1.8.11
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: Bindings to the Vienna RNA package.
76
+ test_files: []