|
16 | 16 | exit_on_error = False
|
17 | 17 | )
|
18 | 18 | parser.add_argument("-p", "--prefix", required = True, type = str, help = "Prefix for outfile files (e.g. <prefix>.R1.fq.gz)")
|
| 19 | +parser.add_argument("-k", "--keep-tags", action='store_true', help = "Keep the existing tags/comments in the FASTQ header") |
19 | 20 | parser.add_argument("-b", "--barcodes", required = True, type=str, help="Barcode conversion key file with format: ATCG<tab>ACBD")
|
20 | 21 | parser.add_argument("forward", type = str, help = "Forward reads of paired-end FASTQ file pair")
|
21 | 22 | parser.add_argument("reverse", type = str, help = "Reverse reads of paired-end FASTQ file pair")
|
@@ -58,20 +59,29 @@ def process_record(fw_rec, rv_rec, barcode_database, bc_len):
|
58 | 59 | if fw_rec and len(fw_rec.sequence) > bc_len:
|
59 | 60 | bc_inline = fw_rec.sequence[:bc_len]
|
60 | 61 | bc_hap = get_value_by_key(barcode_database, bc_inline)
|
61 |
| - fw_rec.comment = fw_rec.comment.split()[0] + f"\tOX:Z:{bc_inline}\tBX:Z:{bc_hap}" |
| 62 | + if args.keep_tags: |
| 63 | + fw_rec.comment += f"\tOX:Z:{bc_inline}\tBX:Z:{bc_hap}" |
| 64 | + else: |
| 65 | + fw_rec.comment = f"OX:Z:{bc_inline}\tBX:Z:{bc_hap}" |
62 | 66 | fw_rec.sequence = fw_rec.sequence[bc_len:]
|
63 | 67 | fw_rec.quality = fw_rec.quality[bc_len:]
|
64 | 68 | _new_fw = str(fw_rec) + "\n"
|
65 | 69 | if rv_rec:
|
66 |
| - rv_rec.comment = rv_rec.comment.split()[0] + f"\tOX:Z:{bc_inline}\tBX:Z:{bc_hap}" |
| 70 | + if args.keep_tags: |
| 71 | + rv_rec.comment += f"\tOX:Z:{bc_inline}\tBX:Z:{bc_hap}" |
| 72 | + else: |
| 73 | + rv_rec.comment = f"OX:Z:{bc_inline}\tBX:Z:{bc_hap}" |
67 | 74 | _new_rv = str(rv_rec) + "\n"
|
68 | 75 | else:
|
69 | 76 | _new_rv = None
|
70 | 77 | else:
|
71 | 78 | _new_fw = None
|
72 | 79 | # no forward read, therefore no barcode to search for
|
73 | 80 | if rv_rec:
|
74 |
| - rv_rec.comment = rv_rec.comment.split()[0] + "\tBX:Z:A00C00B00D00" |
| 81 | + if args.keep_tags: |
| 82 | + rv_rec.comment += "\tBX:Z:A00C00B00D00" |
| 83 | + else: |
| 84 | + rv_rec.comment = "BX:Z:A00C00B00D00" |
75 | 85 | _new_rv = str(rv_rec) + "\n"
|
76 | 86 | else:
|
77 | 87 | _new_rv = None
|
|
0 commit comments