bio-signalp 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,14 @@
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 "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.0"
12
+ gem "rcov", ">= 0"
13
+ gem "bio", ">= 1.4.1"
14
+ end
@@ -0,0 +1,22 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ bio (1.4.1)
5
+ git (1.2.5)
6
+ jeweler (1.6.4)
7
+ bundler (~> 1.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rake (0.9.2)
11
+ rcov (0.9.9)
12
+ shoulda (2.11.3)
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ bio (>= 1.4.1)
19
+ bundler (~> 1.0.0)
20
+ jeweler (~> 1.6.0)
21
+ rcov
22
+ shoulda
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 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.
@@ -0,0 +1,25 @@
1
+ = bio-signalp
2
+
3
+ A wrapper for the signal peptide prediction algorithm SignalP.
4
+
5
+ Using this bio-gem requires SignalP to be locally installed and configured correctly. http://www.cbs.dtu.dk/services/SignalP/ has instructions on how it may be downloaded. This gem requires that the signalp executable is available from the command line (i.e. running 'signalp' works at the command).
6
+
7
+ Only compatible with Ruby 1.8 at this stage, because of the dependency on the rio gem. This might be replaced in the future with using BioRuby's Bio::Command class.
8
+
9
+ This bio-gem is merely a software library, and does not (currently) include any scripts. An example script is freely available at https://github.com/wwood/bbbin/blob/master/signalp.rb
10
+
11
+ == Contributing to bio-signalp
12
+
13
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
14
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
15
+ * Fork the project
16
+ * Start a feature/bugfix branch
17
+ * Commit and push until you are happy with your contribution
18
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
19
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
20
+
21
+ == Copyright
22
+
23
+ Copyright (c) 2011 Ben J Woodcroft. See LICENSE.txt for
24
+ further details.
25
+
@@ -0,0 +1,53 @@
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-signalp"
18
+ gem.homepage = "http://github.com/wwood/bioruby-signalp"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A wrapper for the signal peptide prediction algorith SignalP}
21
+ gem.description = %Q{A wrapper for the signal peptide prediction algorith SignalP. Not very well supported, but seems to work for the author, at least.}
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 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "bio-signalp #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,63 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{bio-signalp}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ben J Woodcroft"]
12
+ s.date = %q{2011-07-25}
13
+ s.description = %q{A wrapper for the signal peptide prediction algorith SignalP. Not very well supported, but seems to work for the author, at least.}
14
+ s.email = %q{donttrustben near gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "bio-signalp.gemspec",
28
+ "lib/bio-signalp.rb",
29
+ "lib/bio/appl/signalp.rb",
30
+ "test/helper.rb",
31
+ "test/test_bio-signalp.rb"
32
+ ]
33
+ s.homepage = %q{http://github.com/wwood/bioruby-signalp}
34
+ s.licenses = ["MIT"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.6.1}
37
+ s.summary = %q{A wrapper for the signal peptide prediction algorith SignalP}
38
+
39
+ if s.respond_to? :specification_version then
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
44
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
45
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
46
+ s.add_development_dependency(%q<rcov>, [">= 0"])
47
+ s.add_development_dependency(%q<bio>, [">= 1.4.1"])
48
+ else
49
+ s.add_dependency(%q<shoulda>, [">= 0"])
50
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
51
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
52
+ s.add_dependency(%q<rcov>, [">= 0"])
53
+ s.add_dependency(%q<bio>, [">= 1.4.1"])
54
+ end
55
+ else
56
+ s.add_dependency(%q<shoulda>, [">= 0"])
57
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
59
+ s.add_dependency(%q<rcov>, [">= 0"])
60
+ s.add_dependency(%q<bio>, [">= 1.4.1"])
61
+ end
62
+ end
63
+
@@ -0,0 +1,11 @@
1
+ # Please require your code below, respecting the bioruby directory tree.
2
+ # For instance, perhaps the only uncommented line in this file might
3
+ # be something like this:
4
+ #
5
+ # require 'lib/bio/sequence/awesome_sequence_plugin_thingy'
6
+ #
7
+ # and then create the ruby file 'lib/bio/sequence/awesome_sequence_thingy.rb'
8
+ # and put your plugin's code there. It is bad practice to write other code
9
+ # directly into this file, because doing so causes confusion if this biogem
10
+ # was ever to get merged into the main bioruby tree.
11
+ require 'bio/appl/signalp'
@@ -0,0 +1,151 @@
1
+ # Methods to wrap around the signal peptide prediction program SignalP (version 3.0)
2
+ require 'tempfile'
3
+ require 'rubygems'
4
+ require 'rio'
5
+
6
+ # Wrapper around a locally installed SignalP program
7
+ module Bio
8
+ class SignalP
9
+ class Wrapper
10
+ # Given an amino acid sequence, return a SignalPResult
11
+ # representing it taken from the file.
12
+ def calculate(sequence)
13
+ Tempfile.open('signalpin') { |tempfilein|
14
+ # Write a fasta to the tempfile
15
+ tempfilein.puts '>wrapperSeq'
16
+ tempfilein.puts "#{sequence}"
17
+ tempfilein.close #required. Maybe because it doesn't flush otherwise?
18
+
19
+ Tempfile.open('signalpout') {|out|
20
+ result = system("signalp -trunc 70 -format short -t euk #{tempfilein.path} >#{out.path}")
21
+
22
+ if !result
23
+ raise Exception, "Running signalp program failed. $? is #{$!.inspect}"
24
+ end
25
+ line = rio(out.path)[2][0].strip
26
+ return Result.create_from_line(line)
27
+ }
28
+ }
29
+ end
30
+ end
31
+
32
+ # The result of a SignalP program. Create using the output from
33
+ # -format short output and create_from_line()
34
+ class Result
35
+ @@nn_results =
36
+ [:nn_Cmax, :nn_Cmax_position, :nn_Cmax_prediction,
37
+ :nn_Ymax, :nn_Ymax_position, :nn_Ymax_prediction,
38
+ :nn_Smax, :nn_Smax_position, :nn_Smax_prediction,
39
+ :nn_Smean, :nn_Smean_prediction,
40
+ :nn_D, :nn_D_prediction]
41
+ @@hmm_results = [
42
+ :hmm_result, :hmm_Cmax, :hmm_Cmax_position, :hmm_Cmax_prediction, :hmm_Sprob, :hmm_Sprob_prediction]
43
+
44
+ @@nn_results.each do |sym|
45
+ attr_accessor sym
46
+ end
47
+ @@hmm_results.each do |sym|
48
+ attr_accessor sym
49
+ end
50
+
51
+ # Create a new SignalpResult using a line from the signal p 'short' output format,
52
+ # version 3.0
53
+ def self.create_from_line(line)
54
+ # e.g.
55
+ # # name Cmax pos ? Ymax pos ? Smax pos ? Smean ? D ? # name ! Cmax pos ? Sprob ?
56
+ # 526.m04658 0.734 19 Y 0.686 19 Y 0.933 6 Y 0.760 Y 0.723 Y 526.m04658 Q 0.037 19 N 0.004 N
57
+ matches = line.split(/[ \t]+/)
58
+ if matches.length != 21
59
+ raise Exception, "Bad SignalP Short Line Found (#{matches.length}): '#{line}'"
60
+ end
61
+
62
+ i = 1
63
+ result = Result.new
64
+ result.nn_Cmax = matches[i].to_f; i += 1
65
+ result.nn_Cmax_position = matches[i].to_i; i += 1
66
+ result.nn_Cmax_prediction = to_bool matches[i]; i += 1
67
+ result.nn_Ymax = matches[i].to_f; i += 1
68
+ result.nn_Ymax_position = matches[i].to_i; i += 1
69
+ result.nn_Ymax_prediction = to_bool matches[i]; i += 1
70
+ result.nn_Smax = matches[i].to_f; i += 1
71
+ result.nn_Smax_position = matches[i].to_i; i += 1
72
+ result.nn_Smax_prediction = to_bool matches[i]; i += 1
73
+ result.nn_Smean = matches[i].to_f; i += 1
74
+ result.nn_Smean_prediction = to_bool matches[i]; i += 1
75
+ result.nn_D = matches[i].to_f; i += 1
76
+ result.nn_D_prediction = to_bool matches[i]; i += 1
77
+
78
+ i+= 1
79
+ result.hmm_result = matches[i]; i += 1
80
+ result.hmm_Cmax = matches[i].to_f; i += 1
81
+ result.hmm_Cmax_position = matches[i].to_i; i += 1
82
+ result.hmm_Cmax_prediction = to_bool matches[i]; i += 1
83
+ result.hmm_Sprob = matches[i].to_f; i += 1
84
+ result.hmm_Sprob_prediction = to_bool matches[i]; i += 1
85
+
86
+ return result
87
+ end
88
+
89
+ def self.to_bool(string)
90
+ if string === 'Y'
91
+ return true
92
+ elsif string === 'N'
93
+ return false
94
+ else
95
+ return nil
96
+ end
97
+ end
98
+
99
+ # Does it have a signal peptide? It can be this class (default),
100
+ # or another class that responds to :nn_D_prediction and :hmm_Sprob_prediction
101
+ def signal?(clazz=self)
102
+ return (clazz.send(:nn_D_prediction) or clazz.send(:hmm_Sprob_prediction))
103
+ end
104
+
105
+ def classical_signal_sequence?
106
+ return @nn_D_prediction
107
+ end
108
+
109
+ def signal_anchor?
110
+ return @hmm_Sprob_prediction
111
+ end
112
+
113
+ # Return an array of all the results. NN then HMM, as per SignalP short format
114
+ def all_results
115
+ all = []
116
+
117
+ @@nn_results.each do |sym|
118
+ all.push self.send(sym)
119
+ end
120
+
121
+ @@hmm_results.each do |sym|
122
+ all.push self.send(sym)
123
+ end
124
+
125
+ return all
126
+ end
127
+
128
+ # Return an array of symbols representing the names of the columns
129
+ def self.all_result_names
130
+ return [@@nn_results, @@hmm_results].flatten
131
+ end
132
+
133
+ # Return the number of the residue after the cleavage site
134
+ # ie. the first residue of the mature protein
135
+ # Taken from the Y score, as it was decided this is the best prediction
136
+ def cleavage_site
137
+ @nn_Ymax_position
138
+ end
139
+
140
+ # Given an amino acid sequence (as a string),
141
+ # chop it off and return the remnants
142
+ def cleave(sequence)
143
+ if signal?
144
+ return sequence[cleavage_site-1..sequence.length-1]
145
+ else
146
+ return sequence
147
+ end
148
+ end
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'bio-signalp'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestBioSignalp < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bio-signalp
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Ben J Woodcroft
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-07-25 00:00:00 +10:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :development
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ version_requirements: *id001
33
+ name: shoulda
34
+ prerelease: false
35
+ - !ruby/object:Gem::Dependency
36
+ type: :development
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 23
43
+ segments:
44
+ - 1
45
+ - 0
46
+ - 0
47
+ version: 1.0.0
48
+ version_requirements: *id002
49
+ name: bundler
50
+ prerelease: false
51
+ - !ruby/object:Gem::Dependency
52
+ type: :development
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ~>
57
+ - !ruby/object:Gem::Version
58
+ hash: 15
59
+ segments:
60
+ - 1
61
+ - 6
62
+ - 0
63
+ version: 1.6.0
64
+ version_requirements: *id003
65
+ name: jeweler
66
+ prerelease: false
67
+ - !ruby/object:Gem::Dependency
68
+ type: :development
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ version_requirements: *id004
79
+ name: rcov
80
+ prerelease: false
81
+ - !ruby/object:Gem::Dependency
82
+ type: :development
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 5
89
+ segments:
90
+ - 1
91
+ - 4
92
+ - 1
93
+ version: 1.4.1
94
+ version_requirements: *id005
95
+ name: bio
96
+ prerelease: false
97
+ description: A wrapper for the signal peptide prediction algorith SignalP. Not very well supported, but seems to work for the author, at least.
98
+ email: donttrustben near gmail.com
99
+ executables: []
100
+
101
+ extensions: []
102
+
103
+ extra_rdoc_files:
104
+ - LICENSE.txt
105
+ - README.rdoc
106
+ files:
107
+ - .document
108
+ - Gemfile
109
+ - Gemfile.lock
110
+ - LICENSE.txt
111
+ - README.rdoc
112
+ - Rakefile
113
+ - VERSION
114
+ - bio-signalp.gemspec
115
+ - lib/bio-signalp.rb
116
+ - lib/bio/appl/signalp.rb
117
+ - test/helper.rb
118
+ - test/test_bio-signalp.rb
119
+ has_rdoc: true
120
+ homepage: http://github.com/wwood/bioruby-signalp
121
+ licenses:
122
+ - MIT
123
+ post_install_message:
124
+ rdoc_options: []
125
+
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ hash: 3
134
+ segments:
135
+ - 0
136
+ version: "0"
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ hash: 3
143
+ segments:
144
+ - 0
145
+ version: "0"
146
+ requirements: []
147
+
148
+ rubyforge_project:
149
+ rubygems_version: 1.6.1
150
+ signing_key:
151
+ specification_version: 3
152
+ summary: A wrapper for the signal peptide prediction algorith SignalP
153
+ test_files: []
154
+