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

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

import galaxy-central

行番号 
1#Dan Blankenberg
2import sys
3
4def main():
5    input_filename = sys.argv[1]
6    output_filename = sys.argv[2]
7    identifier_col = int( sys.argv[3] ) - 1
8    sequence_col = int( sys.argv[4] ) - 1
9    quality_col = int( sys.argv[5] ) - 1
10   
11    max_col = max( identifier_col, sequence_col, quality_col )
12    num_reads = None
13    fastq_read = None
14    skipped_lines = 0
15    out = open( output_filename, 'wb' )
16    for num_reads, line in enumerate( open( input_filename ) ):
17        fields = line.rstrip( '\n\r' ).split( '\t' )
18        if len( fields ) > max_col:
19            out.write( "@%s\n%s\n+\n%s\n" % ( fields[identifier_col], fields[sequence_col], fields[quality_col] ) )
20        else:
21            skipped_lines += 1
22   
23    out.close()
24    if num_reads is None:
25        print "Input was empty."
26    else:
27        print "%i tabular lines were written as FASTQ reads. Be sure to use the FASTQ Groomer tool on this output before further analysis." % ( num_reads + 1 - skipped_lines )
28   
29if __name__ == "__main__": main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。