Skip to content

Instantly share code, notes, and snippets.

Created November 5, 2013 21:21
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
#!/usr/bin/env python
from sys import argv
from itertools import izip
from cogent.parse.fastq import MinimalFastqParser
""" Usage
python X Y Z
X: barcodes fastq file
Y: reads fastq file
Z: merged output file
Will write the barcodes at the beginning of the output file
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 izip(MinimalFastqParser(bcs,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("%s\n" % (bc_qual + seq_qual))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment