diff tools/next_gen_conversion/fastq_conversions.py @ 0:9071e359b9a3

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:37:19 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/next_gen_conversion/fastq_conversions.py	Fri Mar 09 19:37:19 2012 -0500
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+
+"""
+Performs various conversions around Sanger FASTQ data
+
+usage: %prog [options]
+   -c, --command=c: Command to run
+   -i, --input=i: Input file to be converted
+   -o, --outputFastqsanger=o: FASTQ Sanger converted output file for sol2std
+   -s, --outputFastqsolexa=s: FASTQ Solexa converted output file 
+   -f, --outputFasta=f: FASTA converted output file
+
+usage: %prog command input_file output_file
+"""
+
+import os, sys, tempfile
+from galaxy import eggs
+import pkg_resources; pkg_resources.require( "bx-python" )
+from bx.cookbook import doc_optparse
+
+def stop_err( msg ):
+    sys.stderr.write( "%s\n" % msg )
+    sys.exit()
+ 
+def __main__():
+    #Parse Command Line
+    options, args = doc_optparse.parse( __doc__ )
+
+    cmd = "fq_all2std.pl %s %s > %s"
+    if options.command == 'sol2std':
+        cmd = cmd % (options.command, options.input, options.outputFastqsanger)
+    elif options.command == 'std2sol':
+        cmd = cmd % (options.command, options.input, options.outputFastqsolexa)
+    elif options.command == 'fq2fa':
+        cmd = cmd % (options.command, options.input, options.outputFasta)
+    try:
+        os.system(cmd)
+    except Exception, eq:
+        stop_err("Error converting data format.\n" + str(eq))        
+
+if __name__=="__main__": __main__()