1 | #Dan Blankenberg |
---|
2 | import sys |
---|
3 | from galaxy_utils.sequence.fastq import fastqReader |
---|
4 | |
---|
5 | def main(): |
---|
6 | input_filename = sys.argv[1] |
---|
7 | output_filename = sys.argv[2] |
---|
8 | input_type = sys.argv[3] or 'sanger' #input type should ordinarily be unnecessary |
---|
9 | |
---|
10 | num_reads = None |
---|
11 | fastq_read = None |
---|
12 | out = open( output_filename, 'wb' ) |
---|
13 | for num_reads, fastq_read in enumerate( fastqReader( open( input_filename ), format = input_type ) ): |
---|
14 | out.write( "%s\t%s\t%s\n" % ( fastq_read.identifier[1:].replace( '\t', ' ' ), fastq_read.sequence.replace( '\t', ' ' ), fastq_read.quality.replace( '\t', ' ' ) ) ) |
---|
15 | out.close() |
---|
16 | if num_reads is None: |
---|
17 | print "No valid FASTQ reads could be processed." |
---|
18 | else: |
---|
19 | print "%i FASTQ reads were converted to Tabular." % ( num_reads + 1 ) |
---|
20 | |
---|
21 | if __name__ == "__main__": main() |
---|