annotate tools/fastq/fastq_to_fasta.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 #Dan Blankenberg
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
2 import sys
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
3 from galaxy_utils.sequence.fastq import fastqReader
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
4 from galaxy_utils.sequence.fasta import fastaWriter
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
5
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
6 def main():
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
7 input_filename = sys.argv[1]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
8 output_filename = sys.argv[2]
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
9 input_type = sys.argv[3] or 'sanger' #input type should ordinarily be unnecessary
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
10
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
11 num_reads = None
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
12 fastq_read = None
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
13 out = fastaWriter( open( output_filename, 'wb' ) )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
14 for num_reads, fastq_read in enumerate( fastqReader( open( input_filename ), format = input_type ) ):
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
15 out.write( fastq_read )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
16 out.close()
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
17 if num_reads is None:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
18 print "No valid FASTQ reads could be processed."
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
19 else:
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
20 print "%i FASTQ reads were converted to FASTA." % ( num_reads + 1 )
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
21
9071e359b9a3 Uploaded
xuebing
parents:
diff changeset
22 if __name__ == "__main__": main()