Mercurial > repos > devteam > tabular_to_fastq
diff tabular_to_fastq.py @ 3:643018aa1435 draft
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/galaxy_sequence_utils/tabular_to_fastq commit f2582539542b33240234e8ea6093e25d0aee9b6a
author | devteam |
---|---|
date | Sat, 30 Sep 2017 13:54:43 -0400 |
parents | 9ae652b76979 |
children | e8ca9af08774 |
line wrap: on
line diff
--- a/tabular_to_fastq.py Fri Dec 18 19:31:46 2015 -0500 +++ b/tabular_to_fastq.py Sat Sep 30 13:54:43 2017 -0400 @@ -1,29 +1,33 @@ -#Dan Blankenberg +# Dan Blankenberg +from __future__ import print_function + import sys + def main(): input_filename = sys.argv[1] output_filename = sys.argv[2] - identifier_col = int( sys.argv[3] ) - 1 - sequence_col = int( sys.argv[4] ) - 1 - quality_col = int( sys.argv[5] ) - 1 - - max_col = max( identifier_col, sequence_col, quality_col ) + identifier_col = int(sys.argv[3]) - 1 + sequence_col = int(sys.argv[4]) - 1 + quality_col = int(sys.argv[5]) - 1 + + max_col = max(identifier_col, sequence_col, quality_col) num_reads = None - fastq_read = None skipped_lines = 0 - out = open( output_filename, 'wb' ) - for num_reads, line in enumerate( open( input_filename ) ): - fields = line.rstrip( '\n\r' ).split( '\t' ) - if len( fields ) > max_col: - out.write( "@%s\n%s\n+\n%s\n" % ( fields[identifier_col], fields[sequence_col], fields[quality_col] ) ) + out = open(output_filename, 'w') + for num_reads, line in enumerate(open(input_filename)): + fields = line.rstrip('\n\r').split('\t') + if len(fields) > max_col: + out.write("@%s\n%s\n+\n%s\n" % (fields[identifier_col], fields[sequence_col], fields[quality_col])) else: skipped_lines += 1 - + out.close() if num_reads is None: - print "Input was empty." + print("Input was empty.") else: - 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 ) - -if __name__ == "__main__": main() + 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)) + + +if __name__ == "__main__": + main()