Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit, gathering old scattered code

  • Loading branch information...
commit 50049806c1b6fa8a4084c86644e86e8a432c030c 1 parent 190e569
Ben J Woodcroft authored
View
4 .gitignore
@@ -46,3 +46,7 @@ pkg
# For rubinius:
#*.rbc
+
+# Because this is a Gem, not an app
+Gemfile.lock
+
View
4 README.rdoc
@@ -1,6 +1,8 @@
= bio-exportpred
-Description goes here.
+ExportPred is a computer program for predicting whether particular Plasmodium falciparum proteins are exported into the red blood cell cytosol during the intraerythrocytic stages. This biogem is a wrapper around the program, so that it can be interacted with programmatically.
+
+http://bioinf.wehi.edu.au/exportpred/
== Contributing to bio-exportpred
View
4 Rakefile
@@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
gem.name = "bio-exportpred"
gem.homepage = "http://github.com/wwood/bioruby-exportpred"
gem.license = "MIT"
- gem.summary = %Q{TODO: one-line summary of your gem}
- gem.description = %Q{TODO: longer description of your gem}
+ gem.summary = %Q{Wrapper around the ExportPred algorithm for predicting P. falciparum exported proteins}
+ gem.description = %Q{Wrapper around the ExportPred algorithm for predicting P. falciparum exported proteins. Requires local install of the program, which is available from http://bioinf.wehi.edu.au/exportpred/}
gem.email = "donttrustben near gmail.com"
gem.authors = ["Ben J Woodcroft"]
# dependencies defined in Gemfile
View
2  VERSION
@@ -1 +1 @@
-0.0.0
+0.0.1
View
60 bio-exportpred.gemspec
@@ -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
+
View
12 lib/bio-exportpred.rb
@@ -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'
View
70 lib/bio/appl/exportpred.rb
@@ -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
View
30 test/test_bio-exportpred.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.