Mercurial > repos > devteam > tabular_to_fastq
view tabular_to_fastq.py @ 6:82c4bc769ba8 draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tool_collections/galaxy_sequence_utils/tabular_to_fastq commit bb5df9e62585e12f08dfc0a9f86eec8e205b4845
author | iuc |
---|---|
date | Fri, 04 Oct 2024 10:34:12 +0000 |
parents | e8ca9af08774 |
children |
line wrap: on
line source
# 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) num_reads = None skipped_lines = 0 with open(output_filename, 'w') as out: 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 if num_reads is None: 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()