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

Uploaded
author m-zytnicki
date Mon, 29 Apr 2013 03:20:15 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commons/launcher/launchPrank.py	Mon Apr 29 03:20:15 2013 -0400
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import getopt
+
+from pyRepet.launcher.programLauncher import programLauncher
+
+
+def help():
+    print
+    print "usage: launchPrank.py [ options ]"
+    print "options:"
+    print "     -h: this help"
+    print "     -i: name of the input file (format=fasta)"
+    print "     -o: name of the output file (format=aligned fasta, default='inFileName'+fa_aln)"
+    print "     -P: Prank's parameters"
+    print "     -c: clean"
+    print "     -v: verbose (default=0/1)"
+    print
+
+
+def main():
+    """
+    Launch PRANK.
+    """
+    inFileName = ""
+    outFileName = ""
+    parameters = ""
+    clean = False
+    verbose = 0
+
+    try:
+        opts, args = getopt.getopt( sys.argv[1:], "hi:o:P:cv:" )
+    except getopt.GetoptError, err:
+        print str(err)
+        help()
+        sys.exit(1)
+    for o,a in opts:
+        if o == "-h":
+            help()
+            sys.exit(0)
+        elif o == "-i":
+            inFileName = a
+        elif o == "-o":
+            outFileName = a
+        elif o == "-P":
+            parameters = a
+        elif o == "-c":
+            clean = True
+        elif o == "-v":
+            verbose = int(a)
+
+    if inFileName == "":
+        print "ERROR: missing input file (-i)"
+        help()
+        sys.exit(1)
+
+    if not os.path.exists( inFileName ):
+        print "ERROR: can't find file '%s'" % ( inFileName )
+        help()
+        sys.exit(1)
+
+    if verbose > 0:
+        print "START %s" % ( sys.argv[0].split("/")[-1] )
+        sys.stdout.flush()
+
+    if outFileName == "":
+        outFileName = "%s.fa_aln" % ( inFileName )
+
+    pL = programLauncher( inFileName )
+    returnStatus = pL.launchPrank( outFileName, parameters, "yes", verbose )
+    if returnStatus != 0:
+        print "ERROR: launchPrank() returned '%i'" % ( returnStatus )
+        sys.exit(1)
+
+    if verbose > 0:
+        print "END %s" % ( sys.argv[0].split("/")[-1] )
+        sys.stdout.flush()
+
+    return 0
+
+
+if __name__ == "__main__":
+    main()