Guest User

Untitled

a guest
May 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. import os
  2. from optparse import OptionParser
  3.  
  4. def main(file, path):
  5. """runs SignalP for every sequence file in a directory"""
  6. for filename in os.listdir(file):
  7. #other checks other than filer suffix would be more sophisticated
  8. if filename.endswith('.fa') or filename.endswith('.fasta'):
  9. sig = signalp(path, 'gram+', os.path.join(file, filename))
  10. length = len(sig)
  11. #this prints the prediction, and the signal peptide probability
  12. print sig[length-4], sig[length-3]
  13.  
  14.  
  15.  
  16. def signalp(path, organism_type, sequence_file):
  17. """method to run signalp and capture the output, which it returns"""
  18. p = os.popen(os.path.join(path, 'signalp')+' -t '+organism_type+' '+sequence_file)
  19. output = p.readlines()
  20. return output
  21.  
  22. if __name__ == '__main__':
  23. parser = OptionParser(usage="Usage: %prog [options] sequence_directory",
  24. version="%prog 0.1")
  25. parser.add_option("-s", "--signalp", dest="signalp_path",
  26. help="Path to signalp binary, defaults to /usr/local/bin", metavar="INT")
  27. (options, args) = parser.parse_args()
  28. if options.signalp_path:
  29. sigp = options.signalp_path
  30. else:
  31. sigp = '/usr/local/bin'
  32. if len(args) != 1:
  33. print 'Usage error, no infile defined'
  34. parser.print_help()
  35. else:
  36. main(args[0], sigp)
Add Comment
Please, Sign In to add comment