bio-stockholm 0.0.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.
- data/.document +5 -0
- data/.rspec +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +15 -0
- data/LICENSE.txt +20 -0
- data/README.md +85 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/lib/bio-stockholm.rb +12 -0
- data/lib/bio-stockholm/stockholm.rb +122 -0
- data/spec/bio-stockholm_spec.rb +77 -0
- data/spec/data/2wikipedias.sto +51 -0
- data/spec/data/test1.sto +14 -0
- data/spec/data/wikipedia_test.sto +26 -0
- data/spec/spec_helper.rb +14 -0
- metadata +161 -0
data/.document
ADDED
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
language: ruby
|
|
2
|
+
rvm:
|
|
3
|
+
- 1.9.2
|
|
4
|
+
- 1.9.3
|
|
5
|
+
- jruby-19mode # JRuby in 1.9 mode
|
|
6
|
+
- rbx-19mode
|
|
7
|
+
# - 1.8.7
|
|
8
|
+
# - jruby-18mode # JRuby in 1.8 mode
|
|
9
|
+
# - rbx-18mode
|
|
10
|
+
|
|
11
|
+
# uncomment this line if your project needs to run something other than `rake`:
|
|
12
|
+
# script: bundle exec rspec spec
|
data/Gemfile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
source "http://rubygems.org"
|
|
2
|
+
# Add dependencies required to use your gem here.
|
|
3
|
+
# Example:
|
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
|
5
|
+
|
|
6
|
+
# Add dependencies to develop your gem here.
|
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
|
8
|
+
group :development do
|
|
9
|
+
gem "rspec", "~> 2.8.0"
|
|
10
|
+
gem "rdoc", "~> 3.12"
|
|
11
|
+
gem "jeweler", "~> 1.8.4"
|
|
12
|
+
gem "bundler", ">= 1.0.21"
|
|
13
|
+
gem "bio", ">= 1.4.2"
|
|
14
|
+
gem "rdoc", "~> 3.12"
|
|
15
|
+
end
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2013 Ben J. Woodcroft
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# bio-stockholm
|
|
2
|
+
|
|
3
|
+
[](http://travis-ci.org/wwood/bioruby-stockholm)
|
|
4
|
+
|
|
5
|
+
Stockholm format file parser for ruby.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
gem install bio-stockholm
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
An example stockholm format file, from https://en.wikipedia.org/wiki/Stockholm_format
|
|
16
|
+
```
|
|
17
|
+
# STOCKHOLM 1.0
|
|
18
|
+
#=GF ID CBS1
|
|
19
|
+
#=GF AC PF00571
|
|
20
|
+
#=GF DE CBS domain
|
|
21
|
+
#=GF AU Bateman A
|
|
22
|
+
#=GF CC CBS domains are small intracellular modules mostly found
|
|
23
|
+
#=GF CC in 2 or four copies within a protein.
|
|
24
|
+
#=GF SQ 5
|
|
25
|
+
#=GS O31698/18-71 AC O31698
|
|
26
|
+
#=GS O83071/192-246 AC O83071
|
|
27
|
+
#=GS O83071/259-312 AC O83071
|
|
28
|
+
#=GS O31698/88-139 AC O31698
|
|
29
|
+
#=GS O31698/88-139 OS Bacillus subtilis
|
|
30
|
+
O83071/192-246 MTCRAQLIAVPRASSLAEAIACAQKMRVSRVPVYERS
|
|
31
|
+
#=GR O83071/192-246 SA 9998877564535242525515252536463774777
|
|
32
|
+
O83071/259-312 MQHVSAPVFVFECTRLAYVQHKLRAHSRAVAIVLDEY
|
|
33
|
+
#=GR O83071/259-312 SS CCCCCHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEE
|
|
34
|
+
O31698/18-71 MIEADKVAHVQVGNNLEHALLVLTKTGYTAIPVLDPS
|
|
35
|
+
#=GR O31698/18-71 SS CCCHHHHHHHHHHHHHHHEEEEEEEEEEEEEEEEHHH
|
|
36
|
+
O31698/88-139 EVMLTDIPRLHINDPIMKGFGMVINN..GFVCVENDE
|
|
37
|
+
#=GR O31698/88-139 SS CCCCCCCHHHHHHHHHHHHEEEEEEEEEEEEEEEEEH
|
|
38
|
+
#=GC SS_cons CCCCCHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEH
|
|
39
|
+
O31699/88-139 EVMLTDIPRLHINDPIMKGFGMVINN..GFVCVENDE
|
|
40
|
+
#=GR O31699/88-139 AS ________________*____________________
|
|
41
|
+
#=GR O31699/88-139 IN ____________1____________2______0____
|
|
42
|
+
//
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
require 'bio-stockholm'
|
|
47
|
+
|
|
48
|
+
entries = Bio::Stockholm::Reader.parse_from_file('spec/data/wikipedia.sto') #=> Array of 1
|
|
49
|
+
|
|
50
|
+
cbs = entries[0] #=> Bio::Stockholm::Store object
|
|
51
|
+
|
|
52
|
+
cbs.gf_features['ID'] #=> 'CBS'
|
|
53
|
+
cbs.gf_features['AC'] #=> 'PF00571'
|
|
54
|
+
|
|
55
|
+
# #=GS O31698/88-139 OS Bacillus subtilis
|
|
56
|
+
cbs.records['O31698/88-139'].gs_features['OS'] #=> 'Bacillus subtilis'
|
|
57
|
+
|
|
58
|
+
# O83071/192-246 MTCRAQLIAVPRASSLAEAIACAQKMRVSRVPVYERS
|
|
59
|
+
cbs.records['O83071/192-246'].sequence #=> 'MTCRAQLIAVPRASSLAEAIACAQKMRVSRVPVYERS'
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The API doc is online. For more code examples see the test files in
|
|
63
|
+
the source tree.
|
|
64
|
+
|
|
65
|
+
## Project home page
|
|
66
|
+
|
|
67
|
+
Information on the source tree, documentation, examples, issues and
|
|
68
|
+
how to contribute, see
|
|
69
|
+
|
|
70
|
+
http://github.com/wwood/bioruby-stockholm
|
|
71
|
+
|
|
72
|
+
The BioRuby community is on IRC server: irc.freenode.org, channel: #bioruby.
|
|
73
|
+
|
|
74
|
+
## Cite
|
|
75
|
+
|
|
76
|
+
This software is currently unpublished.
|
|
77
|
+
|
|
78
|
+
## Biogems.info
|
|
79
|
+
|
|
80
|
+
This Biogem is published at (http://biogems.info/index.html#bio-stockholm)
|
|
81
|
+
|
|
82
|
+
## Copyright
|
|
83
|
+
|
|
84
|
+
Copyright (c) 2013 Ben J. Woodcroft. See LICENSE.txt for further details.
|
|
85
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'bundler'
|
|
5
|
+
begin
|
|
6
|
+
Bundler.setup(:default, :development)
|
|
7
|
+
rescue Bundler::BundlerError => e
|
|
8
|
+
$stderr.puts e.message
|
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
10
|
+
exit e.status_code
|
|
11
|
+
end
|
|
12
|
+
require 'rake'
|
|
13
|
+
|
|
14
|
+
require 'jeweler'
|
|
15
|
+
Jeweler::Tasks.new do |gem|
|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
|
17
|
+
gem.name = "bio-stockholm"
|
|
18
|
+
gem.homepage = "http://github.com/wwood/bioruby-stockholm"
|
|
19
|
+
gem.license = "MIT"
|
|
20
|
+
gem.summary = %Q{Parse stockholm sequence alignment format}
|
|
21
|
+
gem.description = %Q{Parses stockholm sequence alignment format}
|
|
22
|
+
gem.email = "donttrustben near gmail.com"
|
|
23
|
+
gem.authors = ["Ben J. Woodcroft"]
|
|
24
|
+
# dependencies defined in Gemfile
|
|
25
|
+
end
|
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
|
27
|
+
|
|
28
|
+
require 'rspec/core'
|
|
29
|
+
require 'rspec/core/rake_task'
|
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
|
36
|
+
spec.rcov = true
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
task :default => :spec
|
|
40
|
+
|
|
41
|
+
require 'rdoc/task'
|
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
44
|
+
|
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
46
|
+
rdoc.title = "bio-stockholm #{version}"
|
|
47
|
+
rdoc.rdoc_files.include('README*')
|
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
49
|
+
end
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.0.1
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Please require your code below, respecting the naming conventions in the
|
|
2
|
+
# bioruby directory tree.
|
|
3
|
+
#
|
|
4
|
+
# For example, say you have a plugin named bio-plugin, the only uncommented
|
|
5
|
+
# line in this file would be
|
|
6
|
+
#
|
|
7
|
+
# require 'bio/bio-plugin/plugin'
|
|
8
|
+
#
|
|
9
|
+
# In this file only require other files. Avoid other source code.
|
|
10
|
+
|
|
11
|
+
require 'bio-stockholm/stockholm.rb'
|
|
12
|
+
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
|
|
2
|
+
module Bio
|
|
3
|
+
module Stockholm
|
|
4
|
+
class Reader
|
|
5
|
+
def self.parse_from_file(filename)
|
|
6
|
+
# # STOCKHOLM 1.0
|
|
7
|
+
#
|
|
8
|
+
# #=GS ABK77038.1 DE ammonia monooxygenase subunit A [Cenarchaeum symbiosum A]
|
|
9
|
+
#
|
|
10
|
+
# ABK77038.1 --------------------------------------LTMVWLRRCTHY
|
|
11
|
+
# #=GR ABK77038.1 PP ......................................67889999****
|
|
12
|
+
# #=GC PP_cons ......................................67889999****
|
|
13
|
+
# #=GC RF xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
14
|
+
#
|
|
15
|
+
# ABK77038.1 LFIAVVAVNSTLLTINAGDYIFYTDWAWTS--F..TVFSISQTLML....
|
|
16
|
+
# #=GR ABK77038.1 PP **************************9886..4..699********....
|
|
17
|
+
# #=GC PP_cons **************************9886..4..699********....
|
|
18
|
+
# #=GC RF xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx..xxxxxxxxxxx....
|
|
19
|
+
# //
|
|
20
|
+
state = :first
|
|
21
|
+
returns = []
|
|
22
|
+
to_return = Bio::Stockholm::Store.new
|
|
23
|
+
|
|
24
|
+
File.open(filename).each_line do |line|
|
|
25
|
+
next if line.strip.empty? and state == :first_block
|
|
26
|
+
|
|
27
|
+
if state == :first
|
|
28
|
+
unless line == "\# STOCKHOLM 1.0\n"
|
|
29
|
+
raise FormatException, "Currently unable to parse stockholm format files unless they are version 1.0"
|
|
30
|
+
end
|
|
31
|
+
to_return.header = line.strip
|
|
32
|
+
state = :first_block
|
|
33
|
+
|
|
34
|
+
elsif state == :first_block
|
|
35
|
+
# Match a GR, GS, etc. "markup" line
|
|
36
|
+
if matches = line.match(/^\#=(..) (\S+)\s+(.*)/)
|
|
37
|
+
if matches[1] == 'GF'
|
|
38
|
+
to_return.gf_features ||= {}
|
|
39
|
+
if to_return.gf_features.key?(matches[2])
|
|
40
|
+
to_return.gf_features[matches[2]] = to_return.gf_features[matches[2]]+' '+matches[3]
|
|
41
|
+
else
|
|
42
|
+
to_return.gf_features[matches[2]] = matches[3]
|
|
43
|
+
end
|
|
44
|
+
elsif matches[1] == 'GC'
|
|
45
|
+
to_return.gc_features ||= {}
|
|
46
|
+
if to_return.gc_features.key?(matches[2])
|
|
47
|
+
to_return.gc_features[matches[2]] = to_return.gc_features[matches[2]]+matches[3]
|
|
48
|
+
else
|
|
49
|
+
to_return.gc_features[matches[2]] = matches[3]
|
|
50
|
+
end
|
|
51
|
+
else
|
|
52
|
+
# GS, GR, or bad parsing
|
|
53
|
+
unless matches2 = matches[3].match(/(.*?)\s+(.*)/)
|
|
54
|
+
raise FormatException, "Unable to parse stockholm GS or GR format line: #{line}"
|
|
55
|
+
end
|
|
56
|
+
sequence_identifier = matches[2]
|
|
57
|
+
to_return.records[sequence_identifier] ||= Record.new
|
|
58
|
+
|
|
59
|
+
if matches[1] == 'GS'
|
|
60
|
+
to_return.records[sequence_identifier].gs_features ||= {}
|
|
61
|
+
|
|
62
|
+
if to_return.records[sequence_identifier].gs_features[matches2[1]]
|
|
63
|
+
to_return.records[sequence_identifier].gs_features[matches2[1]] += matches2[2]
|
|
64
|
+
else
|
|
65
|
+
to_return.records[sequence_identifier].gs_features[matches2[1]] = matches2[2]
|
|
66
|
+
end
|
|
67
|
+
elsif matches[1] == 'GR'
|
|
68
|
+
to_return.records[sequence_identifier].gr_features ||= {}
|
|
69
|
+
|
|
70
|
+
if to_return.records[sequence_identifier].gr_features[matches2[1]]
|
|
71
|
+
to_return.records[sequence_identifier].gr_features[matches2[1]] += matches2[2]
|
|
72
|
+
else
|
|
73
|
+
to_return.records[sequence_identifier].gr_features[matches2[1]] = matches2[2]
|
|
74
|
+
end
|
|
75
|
+
else
|
|
76
|
+
raise FormatException, "Unable to parse stockholm format line: #{line}"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
elsif line.match(/^\/\//)
|
|
80
|
+
returns.push to_return
|
|
81
|
+
to_return = Bio::Stockholm::Store.new
|
|
82
|
+
else
|
|
83
|
+
# Else this is just plain old sequence, aligned
|
|
84
|
+
unless matches = line.match(/^(\S+)\s+(.+)$/)
|
|
85
|
+
raise FormatException, "Unable to parse stockholm format line: #{line}"
|
|
86
|
+
end
|
|
87
|
+
to_return.records[matches[1]] ||= Record.new
|
|
88
|
+
to_return.records[matches[1]].sequence ||= ''
|
|
89
|
+
to_return.records[matches[1]].sequence += matches[2].rstrip
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
return returns
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
class Store
|
|
99
|
+
# '# STOCKHOLM 1.0'
|
|
100
|
+
attr_accessor :header
|
|
101
|
+
|
|
102
|
+
# Array of Record objects, which in turn store sequence, GR and GS features
|
|
103
|
+
attr_accessor :records
|
|
104
|
+
|
|
105
|
+
# GF and GC type features
|
|
106
|
+
attr_accessor :gc_features, :gf_features
|
|
107
|
+
|
|
108
|
+
def initialize
|
|
109
|
+
@records = {}
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
class Record
|
|
114
|
+
# Hash of feature field names to values
|
|
115
|
+
attr_accessor :gr_features, :gs_features
|
|
116
|
+
|
|
117
|
+
attr_accessor :sequence
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
class FormatException < Exception; end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "BioStockholm" do
|
|
4
|
+
it "should parse a stockholm file 1" do
|
|
5
|
+
stocks = Bio::Stockholm::Reader.parse_from_file(File.expand_path "#{TEST_DATA_DIR}/test1.sto")
|
|
6
|
+
stocks.should be_kind_of(Array)
|
|
7
|
+
stocks.length.should == 1
|
|
8
|
+
stock = stocks[0]
|
|
9
|
+
stock.records.length.should == 1
|
|
10
|
+
stock.records.values[0].sequence.should == '--------------------------------------LTMVWLRRCTHYLFIAVVAVNSTLLTINAGDYIFYTDWAWTS--F..TVFSISQTLML....'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'should parse a version correctly' do
|
|
14
|
+
stocks = Bio::Stockholm::Reader.parse_from_file(File.expand_path "#{TEST_DATA_DIR}/test1.sto")
|
|
15
|
+
stock = stocks[0]
|
|
16
|
+
stock.header.should == '# STOCKHOLM 1.0'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should parse the wikipedia stockholm format entry' do
|
|
20
|
+
# # STOCKHOLM 1.0
|
|
21
|
+
# #=GF ID CBS
|
|
22
|
+
# #=GF AC PF00571
|
|
23
|
+
# #=GF DE CBS domain
|
|
24
|
+
# #=GF AU Bateman A
|
|
25
|
+
# #=GF CC CBS domains are small intracellular modules mostly found
|
|
26
|
+
# #=GF CC in 2 or four copies within a protein.
|
|
27
|
+
# #=GF SQ 5
|
|
28
|
+
# #=GS O31698/18-71 AC O31698
|
|
29
|
+
# #=GS O83071/192-246 AC O83071
|
|
30
|
+
# #=GS O83071/259-312 AC O83071
|
|
31
|
+
# #=GS O31698/88-139 AC O31698
|
|
32
|
+
# #=GS O31698/88-139 OS Bacillus subtilis
|
|
33
|
+
# O83071/192-246 MTCRAQLIAVPRASSLAEAIACAQKMRVSRVPVYERS
|
|
34
|
+
# #=GR O83071/192-246 SA 9998877564535242525515252536463774777
|
|
35
|
+
# O83071/259-312 MQHVSAPVFVFECTRLAYVQHKLRAHSRAVAIVLDEY
|
|
36
|
+
# #=GR O83071/259-312 SS CCCCCHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEE
|
|
37
|
+
# O31698/18-71 MIEADKVAHVQVGNNLEHALLVLTKTGYTAIPVLDPS
|
|
38
|
+
# #=GR O31698/18-71 SS CCCHHHHHHHHHHHHHHHEEEEEEEEEEEEEEEEHHH
|
|
39
|
+
# O31698/88-139 EVMLTDIPRLHINDPIMKGFGMVINN..GFVCVENDE
|
|
40
|
+
# #=GR O31698/88-139 SS CCCCCCCHHHHHHHHHHHHEEEEEEEEEEEEEEEEEH
|
|
41
|
+
# #=GC SS_cons CCCCCHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEH
|
|
42
|
+
# O31699/88-139 EVMLTDIPRLHINDPIMKGFGMVINN..GFVCVENDE
|
|
43
|
+
# #=GR O31699/88-139 AS ________________*____________________
|
|
44
|
+
# #=GR O31699/88-139 IN ____________1____________2______0____
|
|
45
|
+
# //
|
|
46
|
+
stocks = Bio::Stockholm::Reader.parse_from_file(File.expand_path "#{TEST_DATA_DIR}/wikipedia_test.sto")
|
|
47
|
+
stocks.should be_kind_of(Array)
|
|
48
|
+
stocks.length.should == 1
|
|
49
|
+
stock = stocks[0]
|
|
50
|
+
|
|
51
|
+
stock.gf_features['ID'].should == 'CBS'
|
|
52
|
+
stock.gf_features['DE'].should == 'CBS domain'
|
|
53
|
+
stock.gf_features['SQ'].should == '5'
|
|
54
|
+
stock.gf_features.length.should == 6
|
|
55
|
+
stock.gf_features['CC'].should == 'CBS domains are small intracellular modules mostly found in 2 or four copies within a protein.'
|
|
56
|
+
|
|
57
|
+
stock.records['O31698/18-71'].should be_kind_of(Bio::Stockholm::Record)
|
|
58
|
+
stock.records['O31698/18-71'].gs_features.should be_kind_of(Hash)
|
|
59
|
+
stock.records['O31698/18-71'].gs_features['AC'].should == 'O31698'
|
|
60
|
+
stock.records['O31698/88-139'].gs_features['AC'].should == 'O31698'
|
|
61
|
+
stock.records['O31698/88-139'].gs_features['OS'].should == 'Bacillus subtilis'
|
|
62
|
+
stock.records['O31698/88-139'].gs_features.length.should == 2
|
|
63
|
+
|
|
64
|
+
stock.records.length.should == 5
|
|
65
|
+
stock.records['O83071/259-312'].sequence.should == 'MQHVSAPVFVFECTRLAYVQHKLRAHSRAVAIVLDEY'
|
|
66
|
+
stock.records['O83071/259-312'].gr_features['SS'].should == 'CCCCCHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEE'
|
|
67
|
+
stock.gc_features.should == {'SS_cons' => 'CCCCCHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEH'}
|
|
68
|
+
stock.gc_features.should be_kind_of(Hash)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'should parse multiple ones' do
|
|
72
|
+
stocks = Bio::Stockholm::Reader.parse_from_file(File.expand_path "#{TEST_DATA_DIR}/2wikipedias.sto")
|
|
73
|
+
stocks.length.should == 2
|
|
74
|
+
stocks[0].gf_features['ID'].should == 'CBS1'
|
|
75
|
+
stocks[1].gf_features['ID'].should == 'CBS2'
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# STOCKHOLM 1.0
|
|
2
|
+
#=GF ID CBS1
|
|
3
|
+
#=GF AC PF00571
|
|
4
|
+
#=GF DE CBS domain
|
|
5
|
+
#=GF AU Bateman A
|
|
6
|
+
#=GF CC CBS domains are small intracellular modules mostly found
|
|
7
|
+
#=GF CC in 2 or four copies within a protein.
|
|
8
|
+
#=GF SQ 5
|
|
9
|
+
#=GS O31698/18-71 AC O31698
|
|
10
|
+
#=GS O83071/192-246 AC O83071
|
|
11
|
+
#=GS O83071/259-312 AC O83071
|
|
12
|
+
#=GS O31698/88-139 AC O31698
|
|
13
|
+
#=GS O31698/88-139 OS Bacillus subtilis
|
|
14
|
+
O83071/192-246 MTCRAQLIAVPRASSLAEAIACAQKMRVSRVPVYERS
|
|
15
|
+
#=GR O83071/192-246 SA 9998877564535242525515252536463774777
|
|
16
|
+
O83071/259-312 MQHVSAPVFVFECTRLAYVQHKLRAHSRAVAIVLDEY
|
|
17
|
+
#=GR O83071/259-312 SS CCCCCHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEE
|
|
18
|
+
O31698/18-71 MIEADKVAHVQVGNNLEHALLVLTKTGYTAIPVLDPS
|
|
19
|
+
#=GR O31698/18-71 SS CCCHHHHHHHHHHHHHHHEEEEEEEEEEEEEEEEHHH
|
|
20
|
+
O31698/88-139 EVMLTDIPRLHINDPIMKGFGMVINN..GFVCVENDE
|
|
21
|
+
#=GR O31698/88-139 SS CCCCCCCHHHHHHHHHHHHEEEEEEEEEEEEEEEEEH
|
|
22
|
+
#=GC SS_cons CCCCCHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEH
|
|
23
|
+
O31699/88-139 EVMLTDIPRLHINDPIMKGFGMVINN..GFVCVENDE
|
|
24
|
+
#=GR O31699/88-139 AS ________________*____________________
|
|
25
|
+
#=GR O31699/88-139 IN ____________1____________2______0____
|
|
26
|
+
//
|
|
27
|
+
#=GF ID CBS2
|
|
28
|
+
#=GF AC PF00571
|
|
29
|
+
#=GF DE CBS domain
|
|
30
|
+
#=GF AU Bateman A
|
|
31
|
+
#=GF CC CBS domains are small intracellular modules mostly found
|
|
32
|
+
#=GF CC in 2 or four copies within a protein.
|
|
33
|
+
#=GF SQ 5
|
|
34
|
+
#=GS O31698/18-71 AC O31698
|
|
35
|
+
#=GS O83071/192-246 AC O83071
|
|
36
|
+
#=GS O83071/259-312 AC O83071
|
|
37
|
+
#=GS O31698/88-139 AC O31698
|
|
38
|
+
#=GS O31698/88-139 OS Bacillus subtilis
|
|
39
|
+
O83071/192-246 MTCRAQLIAVPRASSLAEAIACAQKMRVSRVPVYERS
|
|
40
|
+
#=GR O83071/192-246 SA 9998877564535242525515252536463774777
|
|
41
|
+
O83071/259-312 MQHVSAPVFVFECTRLAYVQHKLRAHSRAVAIVLDEY
|
|
42
|
+
#=GR O83071/259-312 SS CCCCCHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEE
|
|
43
|
+
O31698/18-71 MIEADKVAHVQVGNNLEHALLVLTKTGYTAIPVLDPS
|
|
44
|
+
#=GR O31698/18-71 SS CCCHHHHHHHHHHHHHHHEEEEEEEEEEEEEEEEHHH
|
|
45
|
+
O31698/88-139 EVMLTDIPRLHINDPIMKGFGMVINN..GFVCVENDE
|
|
46
|
+
#=GR O31698/88-139 SS CCCCCCCHHHHHHHHHHHHEEEEEEEEEEEEEEEEEH
|
|
47
|
+
#=GC SS_cons CCCCCHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEH
|
|
48
|
+
O31699/88-139 EVMLTDIPRLHINDPIMKGFGMVINN..GFVCVENDE
|
|
49
|
+
#=GR O31699/88-139 AS ________________*____________________
|
|
50
|
+
#=GR O31699/88-139 IN ____________1____________2______0____
|
|
51
|
+
//
|
data/spec/data/test1.sto
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# STOCKHOLM 1.0
|
|
2
|
+
|
|
3
|
+
#=GS ABK77038.1 DE ammonia monooxygenase subunit A [Cenarchaeum symbiosum A]
|
|
4
|
+
|
|
5
|
+
ABK77038.1 --------------------------------------LTMVWLRRCTHY
|
|
6
|
+
#=GR ABK77038.1 PP ......................................67889999****
|
|
7
|
+
#=GC PP_cons ......................................67889999****
|
|
8
|
+
#=GC RF xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
9
|
+
|
|
10
|
+
ABK77038.1 LFIAVVAVNSTLLTINAGDYIFYTDWAWTS--F..TVFSISQTLML....
|
|
11
|
+
#=GR ABK77038.1 PP **************************9886..4..699********....
|
|
12
|
+
#=GC PP_cons **************************9886..4..699********....
|
|
13
|
+
#=GC RF xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx..xxxxxxxxxxx....
|
|
14
|
+
//
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# STOCKHOLM 1.0
|
|
2
|
+
#=GF ID CBS
|
|
3
|
+
#=GF AC PF00571
|
|
4
|
+
#=GF DE CBS domain
|
|
5
|
+
#=GF AU Bateman A
|
|
6
|
+
#=GF CC CBS domains are small intracellular modules mostly found
|
|
7
|
+
#=GF CC in 2 or four copies within a protein.
|
|
8
|
+
#=GF SQ 5
|
|
9
|
+
#=GS O31698/18-71 AC O31698
|
|
10
|
+
#=GS O83071/192-246 AC O83071
|
|
11
|
+
#=GS O83071/259-312 AC O83071
|
|
12
|
+
#=GS O31698/88-139 AC O31698
|
|
13
|
+
#=GS O31698/88-139 OS Bacillus subtilis
|
|
14
|
+
O83071/192-246 MTCRAQLIAVPRASSLAEAIACAQKMRVSRVPVYERS
|
|
15
|
+
#=GR O83071/192-246 SA 9998877564535242525515252536463774777
|
|
16
|
+
O83071/259-312 MQHVSAPVFVFECTRLAYVQHKLRAHSRAVAIVLDEY
|
|
17
|
+
#=GR O83071/259-312 SS CCCCCHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEE
|
|
18
|
+
O31698/18-71 MIEADKVAHVQVGNNLEHALLVLTKTGYTAIPVLDPS
|
|
19
|
+
#=GR O31698/18-71 SS CCCHHHHHHHHHHHHHHHEEEEEEEEEEEEEEEEHHH
|
|
20
|
+
O31698/88-139 EVMLTDIPRLHINDPIMKGFGMVINN..GFVCVENDE
|
|
21
|
+
#=GR O31698/88-139 SS CCCCCCCHHHHHHHHHHHHEEEEEEEEEEEEEEEEEH
|
|
22
|
+
#=GC SS_cons CCCCCHHHHHHHHHHHHHEEEEEEEEEEEEEEEEEEH
|
|
23
|
+
O31699/88-139 EVMLTDIPRLHINDPIMKGFGMVINN..GFVCVENDE
|
|
24
|
+
#=GR O31699/88-139 AS ________________*____________________
|
|
25
|
+
#=GR O31699/88-139 IN ____________1____________2______0____
|
|
26
|
+
//
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
3
|
+
require 'rspec'
|
|
4
|
+
require 'bio-stockholm'
|
|
5
|
+
|
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
|
7
|
+
# in ./support/ and its subdirectories.
|
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
|
9
|
+
|
|
10
|
+
RSpec.configure do |config|
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
TEST_DATA_DIR = File.join(File.dirname(__FILE__),'data')
|
metadata
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: bio-stockholm
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Ben J. Woodcroft
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2013-06-19 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: rspec
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ~>
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: 2.8.0
|
|
22
|
+
type: :development
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ~>
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: 2.8.0
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: rdoc
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ~>
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '3.12'
|
|
38
|
+
type: :development
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ~>
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '3.12'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: jeweler
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ~>
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 1.8.4
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ~>
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 1.8.4
|
|
62
|
+
- !ruby/object:Gem::Dependency
|
|
63
|
+
name: bundler
|
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
|
65
|
+
none: false
|
|
66
|
+
requirements:
|
|
67
|
+
- - ! '>='
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: 1.0.21
|
|
70
|
+
type: :development
|
|
71
|
+
prerelease: false
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ! '>='
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: 1.0.21
|
|
78
|
+
- !ruby/object:Gem::Dependency
|
|
79
|
+
name: bio
|
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
|
81
|
+
none: false
|
|
82
|
+
requirements:
|
|
83
|
+
- - ! '>='
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: 1.4.2
|
|
86
|
+
type: :development
|
|
87
|
+
prerelease: false
|
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
89
|
+
none: false
|
|
90
|
+
requirements:
|
|
91
|
+
- - ! '>='
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: 1.4.2
|
|
94
|
+
- !ruby/object:Gem::Dependency
|
|
95
|
+
name: rdoc
|
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
|
97
|
+
none: false
|
|
98
|
+
requirements:
|
|
99
|
+
- - ~>
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '3.12'
|
|
102
|
+
type: :development
|
|
103
|
+
prerelease: false
|
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
+
none: false
|
|
106
|
+
requirements:
|
|
107
|
+
- - ~>
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '3.12'
|
|
110
|
+
description: Parses stockholm sequence alignment format
|
|
111
|
+
email: donttrustben near gmail.com
|
|
112
|
+
executables: []
|
|
113
|
+
extensions: []
|
|
114
|
+
extra_rdoc_files:
|
|
115
|
+
- LICENSE.txt
|
|
116
|
+
- README.md
|
|
117
|
+
files:
|
|
118
|
+
- .document
|
|
119
|
+
- .rspec
|
|
120
|
+
- .travis.yml
|
|
121
|
+
- Gemfile
|
|
122
|
+
- LICENSE.txt
|
|
123
|
+
- README.md
|
|
124
|
+
- Rakefile
|
|
125
|
+
- VERSION
|
|
126
|
+
- lib/bio-stockholm.rb
|
|
127
|
+
- lib/bio-stockholm/stockholm.rb
|
|
128
|
+
- spec/bio-stockholm_spec.rb
|
|
129
|
+
- spec/data/2wikipedias.sto
|
|
130
|
+
- spec/data/test1.sto
|
|
131
|
+
- spec/data/wikipedia_test.sto
|
|
132
|
+
- spec/spec_helper.rb
|
|
133
|
+
homepage: http://github.com/wwood/bioruby-stockholm
|
|
134
|
+
licenses:
|
|
135
|
+
- MIT
|
|
136
|
+
post_install_message:
|
|
137
|
+
rdoc_options: []
|
|
138
|
+
require_paths:
|
|
139
|
+
- lib
|
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
|
+
none: false
|
|
142
|
+
requirements:
|
|
143
|
+
- - ! '>='
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
segments:
|
|
147
|
+
- 0
|
|
148
|
+
hash: 602560815
|
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
|
+
none: false
|
|
151
|
+
requirements:
|
|
152
|
+
- - ! '>='
|
|
153
|
+
- !ruby/object:Gem::Version
|
|
154
|
+
version: '0'
|
|
155
|
+
requirements: []
|
|
156
|
+
rubyforge_project:
|
|
157
|
+
rubygems_version: 1.8.25
|
|
158
|
+
signing_key:
|
|
159
|
+
specification_version: 3
|
|
160
|
+
summary: Parse stockholm sequence alignment format
|
|
161
|
+
test_files: []
|