annotate fastq_to_fasta.py @ 0:daf96c3e3b60 draft

Imported from capsule None
author devteam
date Thu, 23 Jan 2014 12:31:31 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
1 #Dan Blankenberg
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
2 import sys
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
3 from galaxy_utils.sequence.fastq import fastqReader
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
4 from galaxy_utils.sequence.fasta import fastaWriter
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
5
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
6 def main():
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
7 input_filename = sys.argv[1]
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
8 output_filename = sys.argv[2]
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
9 input_type = sys.argv[3] or 'sanger' #input type should ordinarily be unnecessary
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
10
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
11 num_reads = None
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
12 fastq_read = None
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
13 out = fastaWriter( open( output_filename, 'wb' ) )
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
14 for num_reads, fastq_read in enumerate( fastqReader( open( input_filename ), format = input_type ) ):
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
15 out.write( fastq_read )
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
16 out.close()
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
17 if num_reads is None:
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
18 print "No valid FASTQ reads could be processed."
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
19 else:
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
20 print "%i FASTQ reads were converted to FASTA." % ( num_reads + 1 )
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
21
daf96c3e3b60 Imported from capsule None
devteam
parents:
diff changeset
22 if __name__ == "__main__": main()