-
-
Save Pinjontall94/efc4edfc9694b59e6f49f7168ef3ec78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" | |
Description: Will write the barcodes at the beginning of the output file. | |
Usage: | |
python merge_bcs_reads.py X Y Z | |
X: barcodes fastq file | |
Y: reads fastq file | |
Z: merged output file | |
""" | |
from sys import argv | |
from cogent.parse.fastq import MinimalFastqParser | |
bcs = open(argv[1], "U") | |
reads = open(argv[2], "U") | |
combined_out = open(argv[3], "w") | |
header_index = 0 | |
sequence_index = 1 | |
quality_index = 2 | |
for bc_data, read_data in zip(MinimalFastqParser(bcs, strict=False), | |
MinimalFastqParser(reads, strict=False)): | |
curr_label = bc_data[header_index].strip() | |
bc_read = bc_data[sequence_index] | |
bc_qual = bc_data[quality_index] | |
seq_read = read_data[sequence_index] | |
seq_qual = read_data[quality_index] | |
combined_out.write("@%s\n" % curr_label) | |
combined_out.write("%s\n" % (bc_read + seq_read)) | |
combined_out.write("+\n") | |
combined_out.write("%s\n" % (bc_qual + seq_qual)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment