rbfam 0.0.2 → 0.0.5

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.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ rbfam
2
+ =====
3
+
4
+ Light wrapper for RFam data in Ruby.
data/lib/rbfam.rb CHANGED
@@ -1,14 +1,13 @@
1
1
  require "bio"
2
2
  require "vienna_rna"
3
+ require "entrez"
3
4
  require "httparty"
4
5
  require "active_support/inflector"
5
6
 
7
+ Dir[File.join(File.dirname(__FILE__), "rbfam", "modules", "*.rb")].each { |name| require "rbfam/modules/#{File.basename(name, '.rb')}" }
8
+
6
9
  module Rbfam
7
- Dir[File.join(File.dirname(__FILE__), "/modules/*")].each do |file|
8
- autoload File.basename(file, ".rb").camelize.to_sym, file
9
- end
10
-
11
10
  def self.script(name)
12
- require File.dirname(__FILE__) + "/scripts/#{File.basename(name, '.rb')}.rb"
11
+ require "rbfam/scripts/#{File.basename(name, '.rb')}"
13
12
  end
14
13
  end
@@ -54,7 +54,7 @@ module Rbfam
54
54
  def parse_line(line)
55
55
  line_match = line.match(LINE_REGEXP)
56
56
 
57
- Rbfam::Sequence.new(family, line_match[1], line_match[2].to_i, line_match[3].to_i, autoload: { length: 300, extend: 3 })
57
+ Rbfam::Sequence.new(family, line_match[1], line_match[2].to_i, line_match[3].to_i, autoload: true)
58
58
  end
59
59
  end
60
60
  end
@@ -54,7 +54,7 @@ module Rbfam
54
54
  def parse_line(line)
55
55
  split_line = line.split(/\t/)
56
56
 
57
- Rbfam::Sequence.new(self, split_line[0], split_line[2].to_i, split_line[3].to_i, autoload: { length: 300, extend: 3 })
57
+ Rbfam::Sequence.new(self, split_line[0], split_line[2].to_i, split_line[3].to_i, autoload: true)
58
58
  end
59
59
  end
60
60
  end
@@ -6,7 +6,7 @@ module Rbfam
6
6
  @family, @accession, @from, @to = family, accession, from, to
7
7
 
8
8
  if options[:sequence]
9
- @raw_sequence = options[:sequence]
9
+ @raw_sequence = (options[:sequence].is_a?(String) ? Bio::Sequence::NA.new(options[:sequence]) : options[:sequence])
10
10
  end
11
11
 
12
12
  if options[:autoload]
@@ -24,8 +24,8 @@ module Rbfam
24
24
  sequence_length: sequence.length,
25
25
  from: from,
26
26
  to: to,
27
- seq_from: up_coord + coord_window({ length: 300, extend: 3 }).min,
28
- seq_to: up_coord + coord_window({ length: 300, extend: 3 }).max,
27
+ seq_from: up_coord + coord_window(options[:coord_window] || {}).min,
28
+ seq_to: up_coord + coord_window(options[:coord_window] || {}).max,
29
29
  seed: options[:seed]
30
30
  })
31
31
  end
@@ -66,6 +66,8 @@ module Rbfam
66
66
  end
67
67
 
68
68
  def coord_window(options = {})
69
+ # Ex: { length: 300, extend: 3 }
70
+
69
71
  range = 0..(down_coord - up_coord)
70
72
 
71
73
  if options[:length] && options[:extend]
@@ -1,8 +1,12 @@
1
- require "entrez"
2
-
3
1
  module Rbfam
4
2
  module Utils
5
3
  class << self
4
+ def simple_rna_sequence(id, from, to)
5
+ sequence = rna_sequence_from_entrez(id, [from, to].min, 0..((to - from).abs))
6
+
7
+ to < from ? sequence.complement : sequence
8
+ end
9
+
6
10
  def rna_sequence_from_entrez(id, position, window, buffer_size = 0)
7
11
  na_sequence_from_entrez(id, position, window, buffer_size).rna
8
12
  end
@@ -6,7 +6,7 @@ class Object; def this; self; end; end
6
6
  class SequenceTable < ActiveRecord::Base
7
7
  self.table_name = "sequences"
8
8
 
9
- validates_uniqueness_of :accession, scope: [:seq_from, :seq_to]
9
+ validates_uniqueness_of :accession, scope: [:sequence, :structure]
10
10
 
11
11
  def self.connect
12
12
  ActiveRecord::Base.establish_connection(config = { adapter: "mysql2", username: "root", reconnect: true })
@@ -20,8 +20,12 @@ class SequenceTable < ActiveRecord::Base
20
20
  inline_rails if defined?(inline_rails)
21
21
  end
22
22
 
23
- def to_rbfam_sequence(family)
24
- Rbfam::Sequence.new(family, accession, from, to, sequence: sequence)
23
+ def clean_description
24
+ ("%s %s %s" % [accession, seq_from, seq_to]).gsub(/[^A-Za-z0-9]/, "_")
25
+ end
26
+
27
+ def to_rbfam_sequence(family = nil)
28
+ Rbfam::Sequence.new(family || Rbfam::Family.new(family), accession, from, to, sequence: sequence)
25
29
  end
26
30
  end
27
31
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbfam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-06 00:00:00.000000000 Z
12
+ date: 2012-07-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bio
@@ -81,12 +81,13 @@ executables: []
81
81
  extensions: []
82
82
  extra_rdoc_files: []
83
83
  files:
84
- - ./lib/modules/alignment.rb
85
- - ./lib/modules/family.rb
86
- - ./lib/modules/sequence.rb
87
- - ./lib/modules/utils.rb
88
- - ./lib/rbfam.rb
89
- - ./lib/scripts/sequences_in_mysql.rb
84
+ - lib/rbfam/modules/alignment.rb
85
+ - lib/rbfam/modules/family.rb
86
+ - lib/rbfam/modules/sequence.rb
87
+ - lib/rbfam/modules/utils.rb
88
+ - lib/rbfam/scripts/sequences_in_mysql.rb
89
+ - lib/rbfam.rb
90
+ - README.md
90
91
  homepage: http://rubygems.org/gems/rbfam
91
92
  licenses: []
92
93
  post_install_message: