root/galaxy-central/tools/fastq/fastq_to_tabular.py

リビジョン 2, 0.8 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1#Dan Blankenberg
2import sys
3from galaxy_utils.sequence.fastq import fastqReader
4
5def 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   
21if __name__ == "__main__": main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。