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

Uploaded
author xuebing
date Fri, 09 Mar 2012 19:37:19 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
1 #!/usr/bin/env python
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3 """
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4 Performs various conversions around Sanger FASTQ data
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
5
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6 usage: %prog [options]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
7 -c, --command=c: Command to run
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8 -i, --input=i: Input file to be converted
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
9 -o, --outputFastqsanger=o: FASTQ Sanger converted output file for sol2std
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10 -s, --outputFastqsolexa=s: FASTQ Solexa converted output file
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11 -f, --outputFasta=f: FASTA converted output file
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13 usage: %prog command input_file output_file
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14 """
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16 import os, sys, tempfile
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17 from galaxy import eggs
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18 import pkg_resources; pkg_resources.require( "bx-python" )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19 from bx.cookbook import doc_optparse
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
20
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
21 def stop_err( msg ):
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
22 sys.stderr.write( "%s\n" % msg )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
23 sys.exit()
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
24
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
25 def __main__():
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
26 #Parse Command Line
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
27 options, args = doc_optparse.parse( __doc__ )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
28
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
29 cmd = "fq_all2std.pl %s %s > %s"
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
30 if options.command == 'sol2std':
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
31 cmd = cmd % (options.command, options.input, options.outputFastqsanger)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
32 elif options.command == 'std2sol':
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
33 cmd = cmd % (options.command, options.input, options.outputFastqsolexa)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
34 elif options.command == 'fq2fa':
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
35 cmd = cmd % (options.command, options.input, options.outputFasta)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
36 try:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
37 os.system(cmd)
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
38 except Exception, eq:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
39 stop_err("Error converting data format.\n" + str(eq))
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
40
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
41 if __name__=="__main__": __main__()