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

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

import galaxy-central

行番号 
1#Dan Blankenberg
2import sys
3from galaxy_utils.sequence.fastq import fastqReader, fastqAggregator, fastqWriter
4
5def main():
6    input_filename = sys.argv[1]
7    input_type = sys.argv[2]
8    output_filename = sys.argv[3]
9    output_type = sys.argv[4]
10    force_quality_encoding = sys.argv[5]
11    summarize_input = sys.argv[6] == 'summarize_input'
12    if force_quality_encoding == 'None':
13        force_quality_encoding = None
14   
15    aggregator = fastqAggregator()
16    out = fastqWriter( open( output_filename, 'wb' ), format = output_type, force_quality_encoding = force_quality_encoding )
17    read_count = None
18    for read_count, fastq_read in enumerate( fastqReader( open( input_filename ), format = input_type ) ):
19        if summarize_input:
20            aggregator.consume_read( fastq_read )
21        out.write( fastq_read )
22    out.close()
23   
24    if read_count is not None:
25        print "Groomed %i %s reads into %s reads." % ( read_count + 1, input_type, output_type )
26    else:
27        print "No valid FASTQ reads were provided."
28    if input_type != output_type and 'solexa' in [ input_type, output_type ]:
29        print "Converted between Solexa and PHRED scores."
30    if summarize_input:
31        print "Based upon quality and sequence, the input data is valid for: %s" % ( ", ".join( aggregator.get_valid_formats() )  or "None" )
32        ascii_range = aggregator.get_ascii_range()
33        decimal_range =  aggregator.get_decimal_range()
34        print "Input ASCII range: %s(%i) - %s(%i)" % ( repr( ascii_range[0] ), ord( ascii_range[0] ), repr( ascii_range[1] ), ord( ascii_range[1] ) ) #print using repr, since \x00 (null) causes info truncation in galaxy when printed
35        print "Input decimal range: %i - %i" % ( decimal_range[0], decimal_range[1] )
36
37if __name__ == "__main__": main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。