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