annotate commons/launcher/launchPrank.py @ 18:94ab73e8a190

Uploaded
author m-zytnicki
date Mon, 29 Apr 2013 03:20:15 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
1 #!/usr/bin/env python
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
2
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
3 import os
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
4 import sys
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5 import getopt
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7 from pyRepet.launcher.programLauncher import programLauncher
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
8
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
9
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
10 def help():
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11 print
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12 print "usage: launchPrank.py [ options ]"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 print "options:"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14 print " -h: this help"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15 print " -i: name of the input file (format=fasta)"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16 print " -o: name of the output file (format=aligned fasta, default='inFileName'+fa_aln)"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17 print " -P: Prank's parameters"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 print " -c: clean"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 print " -v: verbose (default=0/1)"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 print
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23 def main():
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24 """
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 Launch PRANK.
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26 """
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 inFileName = ""
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 outFileName = ""
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 parameters = ""
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30 clean = False
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 verbose = 0
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 try:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34 opts, args = getopt.getopt( sys.argv[1:], "hi:o:P:cv:" )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35 except getopt.GetoptError, err:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36 print str(err)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37 help()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38 sys.exit(1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 for o,a in opts:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40 if o == "-h":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41 help()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42 sys.exit(0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43 elif o == "-i":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44 inFileName = a
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
45 elif o == "-o":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46 outFileName = a
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47 elif o == "-P":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48 parameters = a
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49 elif o == "-c":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50 clean = True
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
51 elif o == "-v":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
52 verbose = int(a)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
53
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
54 if inFileName == "":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
55 print "ERROR: missing input file (-i)"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
56 help()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
57 sys.exit(1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
58
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
59 if not os.path.exists( inFileName ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
60 print "ERROR: can't find file '%s'" % ( inFileName )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
61 help()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
62 sys.exit(1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
63
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
64 if verbose > 0:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
65 print "START %s" % ( sys.argv[0].split("/")[-1] )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
66 sys.stdout.flush()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
67
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
68 if outFileName == "":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
69 outFileName = "%s.fa_aln" % ( inFileName )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
70
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
71 pL = programLauncher( inFileName )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
72 returnStatus = pL.launchPrank( outFileName, parameters, "yes", verbose )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
73 if returnStatus != 0:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
74 print "ERROR: launchPrank() returned '%i'" % ( returnStatus )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
75 sys.exit(1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
76
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
77 if verbose > 0:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
78 print "END %s" % ( sys.argv[0].split("/")[-1] )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
79 sys.stdout.flush()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
80
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
81 return 0
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
82
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
83
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
84 if __name__ == "__main__":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
85 main()