annotate fastq_to_fasta.py @ 0:3571553aeb20 draft

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