-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit, gathering old scattered code
- Loading branch information
Ben J Woodcroft
committed
Jan 14, 2012
1 parent
190e569
commit 5004980
Showing
8 changed files
with
169 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,7 @@ pkg | |
|
||
# For rubinius: | ||
#*.rbc | ||
|
||
# Because this is a Gem, not an app | ||
Gemfile.lock | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.0.0 | ||
0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Generated by jeweler | ||
# DO NOT EDIT THIS FILE DIRECTLY | ||
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' | ||
# -*- encoding: utf-8 -*- | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "bio-exportpred" | ||
s.version = "0.0.0" | ||
|
||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | ||
s.authors = ["Ben J Woodcroft"] | ||
s.date = "2012-01-14" | ||
s.description = "TODO: longer description of your gem" | ||
s.email = "donttrustben near gmail.com" | ||
s.extra_rdoc_files = [ | ||
"LICENSE.txt", | ||
"README.rdoc" | ||
] | ||
s.files = [ | ||
".document", | ||
"Gemfile", | ||
"LICENSE.txt", | ||
"README.rdoc", | ||
"Rakefile", | ||
"VERSION", | ||
"lib/bio-exportpred.rb", | ||
"test/helper.rb", | ||
"test/test_bio-exportpred.rb" | ||
] | ||
s.homepage = "http://github.com/wwood/bioruby-exportpred" | ||
s.licenses = ["MIT"] | ||
s.require_paths = ["lib"] | ||
s.rubygems_version = "1.8.14" | ||
s.summary = "TODO: one-line summary of your gem" | ||
|
||
if s.respond_to? :specification_version then | ||
s.specification_version = 3 | ||
|
||
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then | ||
s.add_development_dependency(%q<shoulda>, [">= 0"]) | ||
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"]) | ||
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"]) | ||
s.add_development_dependency(%q<rcov>, [">= 0"]) | ||
s.add_development_dependency(%q<bio>, [">= 1.4.2"]) | ||
else | ||
s.add_dependency(%q<shoulda>, [">= 0"]) | ||
s.add_dependency(%q<bundler>, ["~> 1.0.0"]) | ||
s.add_dependency(%q<jeweler>, ["~> 1.6.4"]) | ||
s.add_dependency(%q<rcov>, [">= 0"]) | ||
s.add_dependency(%q<bio>, [">= 1.4.2"]) | ||
end | ||
else | ||
s.add_dependency(%q<shoulda>, [">= 0"]) | ||
s.add_dependency(%q<bundler>, ["~> 1.0.0"]) | ||
s.add_dependency(%q<jeweler>, ["~> 1.6.4"]) | ||
s.add_dependency(%q<rcov>, [">= 0"]) | ||
s.add_dependency(%q<bio>, [">= 1.4.2"]) | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1 @@ | ||
# Please require your code below, respecting the bioruby directory tree. | ||
# For instance, perhaps the only uncommented line in this file might | ||
# be something like this: | ||
# | ||
# require 'bio/sequence/awesome_sequence_plugin_thingy' | ||
# | ||
# and then create the ruby file 'lib/bio/sequence/awesome_sequence_thingy.rb' | ||
# and put your plugin's code there. It is bad practice to write other code | ||
# directly into this file, because doing so causes confusion if this biogem | ||
# was ever to get merged into the main bioruby tree. | ||
|
||
require 'bio/appl/exportpred' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
require 'open3' | ||
|
||
module Bio | ||
class ExportPred | ||
class Wrapper | ||
def calculate(sequence) | ||
command = 'exportpred --input=-' | ||
Open3.popen3(command) do |stdin, stdout, stderr, wait_thr| | ||
stdin.puts '>wrapperSeq' | ||
stdin.puts "#{sequence}" | ||
stdin.close | ||
|
||
result = stdout.readlines | ||
error = stderr.readlines | ||
|
||
unless error.length == 1 | ||
raise Exception, "There appears to be a problem while running ExportPred:\n#{error}" | ||
end | ||
parse_error = error[0].strip.match(/^(\d+) sequences read from stdin$/) | ||
unless parse_error[1].to_i == 1 | ||
raise Exception, "There appears to be a problem while running ExportPred, unexpected output form: \n#{error}" | ||
end | ||
|
||
# Error checking | ||
unless [0,1].include?(result.length) | ||
raise Exception, "Unexpected number of lines found in ExportPred output (#{result.length}:\n#{result}" | ||
end | ||
|
||
return Result.create_from_line(result[0]) | ||
end | ||
end | ||
end | ||
|
||
class Result | ||
@@all_result_names = [ | ||
:predicted, | ||
:score | ||
] | ||
@@all_result_names.each do |rn| | ||
attr_accessor rn | ||
end | ||
|
||
# Given the STDOUT from the ExportPred program, create a programmatically manipulatable Bio::ExportPred::Result object | ||
def self.create_from_line(line) | ||
result = Result.new | ||
if !line or line == '' #possible bug that scores below 2.3 don't work? | ||
result.predicted = false | ||
return result | ||
end | ||
|
||
# line is going to be something like | ||
# metoo RLE 6.44141 [a-met:M][a-leader:AVSTYNNTRRNGLRYVLKRR][a-hydrophobic:TILSVFAVICMLSL][a-spacer:NLSIFENNNNNYGFHCNKRH][a-RLE:FKSLAEA][a-tail:SPEEHNNLRSHSTSDPKKNEEKSLSDEINKCDMKKYTAEEINEMINSSNEFINRNDMNIIFSYVHESEREKFKKVEENIFKFIQSIVETYKIPDEYKMRKFKFAHFEMQGYALKQEKFLLEYAFLSLNGKLCERKKFKEVLEYVKREWIEFRKSMFDVWKEKLASEFREHGEMLNQKRKLKQHELDRRAQREKMLEEHSRGIFAKGYLGEVESETIKKKTEHHENVNEDNVEKPKLQQHKVQPPKVQQQKVQPPKSQQQKVQPPKSQQQKVQPPKVQQQKVQPPKVQKPKLQNQKGQKQVSPKAKGNNQAKPTKGNKLKKN] | ||
splits = line.split("\t") | ||
raise Exception, "Badly parsed line: #{line}" if splits.length != 4 | ||
result.predicted = true | ||
result.score = splits[2].to_f | ||
return result | ||
end | ||
|
||
def predicted? | ||
@predicted | ||
end | ||
alias_method :signal?, :predicted? | ||
|
||
def self.all_result_names | ||
@@all_result_names | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,33 @@ | ||
require 'helper' | ||
|
||
class TestBioExportpred < Test::Unit::TestCase | ||
should "probably rename this file and start testing for real" do | ||
flunk "hey buddy, you should probably rename this file and start testing for real" | ||
def setup | ||
@exportpred = Bio::ExportPred::Wrapper.new | ||
end | ||
|
||
def test_create_from_line | ||
# test empty | ||
line = '' | ||
r = Bio::ExportPred::Result.create_from_line(line) | ||
assert r | ||
assert_kind_of Bio::ExportPred::Result, r | ||
assert_equal false, r.predicted? | ||
|
||
line = 'metoo RLE 6.44141 [a-met:M][a-leader:AVSTYNNTRRNGLRYVLKRR][a-hydrophobic:TILSVFAVICMLSL][a-spacer:NLSIFENNNNNYGFHCNKRH][a-RLE:FKSLAEA][a-tail:SPEEHNNLRSHSTSDPKKNEEKSLSDEINKCDMKKYTAEEINEMINSSNEFINRNDMNIIFSYVHESEREKFKKVEENIFKFIQSIVETYKIPDEYKMRKFKFAHFEMQGYALKQEKFLLEYAFLSLNGKLCERKKFKEVLEYVKREWIEFRKSMFDVWKEKLASEFREHGEMLNQKRKLKQHELDRRAQREKMLEEHSRGIFAKGYLGEVESETIKKKTEHHENVNEDNVEKPKLQQHKVQPPKVQQQKVQPPKSQQQKVQPPKSQQQKVQPPKVQQQKVQPPKVQKPKLQNQKGQKQVSPKAKGNNQAKPTKGNKLKKN]' | ||
r = Bio::ExportPred::Result.create_from_line(line) | ||
assert r | ||
assert_kind_of Bio::ExportPred::Result, r | ||
assert r.predicted? | ||
assert_equal 6.44141, r.score | ||
end | ||
|
||
def test_wrapper_positive | ||
positive = 'MAVSTYNNTRRNGLRYVLKRRTILSVFAVICMLSLNLSIFENNNNNYGFHCNKRHFKSLAEASPEEHNNLRSHSTSDPKKNEEKSLSDEINKCDMKKYTAEEINEMINSSNEFINRNDMNIIFSYVHESEREKFKKVEENIFKFIQSIVETY' | ||
assert_equal true, @exportpred.calculate(positive).signal? | ||
end | ||
|
||
def test_wrapper_negative | ||
negative = 'MKILLLCIIFLYYVNAFKNTQKDGVSLQILKKKRSNQVNFLNRKNDYNLIKNKNPSSSLKSTFDDIKKIISKQLSVEEDKIQMNSNFTKDLGADSLDLVELIMALEEKFNVTISDQDALKINTVQDAIDYIEKNNKQ' | ||
assert_equal false, @exportpred.calculate(negative).signal? | ||
end | ||
end |