Class: Bio::ExportPred::Wrapper
- Inherits:
-
Object
- Object
- Bio::ExportPred::Wrapper
- Defined in:
- lib/bio/appl/exportpred.rb
Instance Method Summary collapse
-
#calculate(sequence, options = {}) ⇒ Object
Use ExportPred called locally to predict whether a protein is exported or not.
Instance Method Details
#calculate(sequence, options = {}) ⇒ Object
Use ExportPred called locally to predict whether a protein is exported or not. TODO: better doco here, explain options
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bio/appl/exportpred.rb', line 9 def calculate(sequence, ={}) command = 'exportpred --input=-' #--no-RLE and -r seem to fail when running exportpred on the command line, so here I'll just set the thresholds very high instead command = "#{command} --KLD-threshold=99999" if [:no_KLD] command = "#{command} --RLE-threshold=99999" if [:no_RLE] 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 |