Created
May 13, 2010 15:30
-
-
Save sjcockell/399952 to your computer and use it in GitHub Desktop.
A short script for running SignalP over a directory of sequence files.
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
import os | |
from optparse import OptionParser | |
def main(file, path): | |
"""runs SignalP for every sequence file in a directory""" | |
for filename in os.listdir(file): | |
#other checks other than filer suffix would be more sophisticated | |
if filename.endswith('.fa') or filename.endswith('.fasta'): | |
sig = signalp(path, 'gram+', os.path.join(file, filename)) | |
length = len(sig) | |
#this prints the prediction, and the signal peptide probability | |
print sig[length-4], sig[length-3] | |
def signalp(path, organism_type, sequence_file): | |
"""method to run signalp and capture the output, which it returns""" | |
p = os.popen(os.path.join(path, 'signalp')+' -t '+organism_type+' '+sequence_file) | |
output = p.readlines() | |
return output | |
if __name__ == '__main__': | |
parser = OptionParser(usage="Usage: %prog [options] sequence_directory", | |
version="%prog 0.1") | |
parser.add_option("-s", "--signalp", dest="signalp_path", | |
help="Path to signalp binary, defaults to /usr/local/bin", metavar="INT") | |
(options, args) = parser.parse_args() | |
if options.signalp_path: | |
sigp = options.signalp_path | |
else: | |
sigp = '/usr/local/bin' | |
if len(args) != 1: | |
print 'Usage error, no infile defined' | |
parser.print_help() | |
else: | |
main(args[0], sigp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A short script for running SignalP over a directory of sequence files.