Skip to content
Snippets Groups Projects
Commit fb1e5043 authored by Blaise Li's avatar Blaise Li
Browse files

Demultiplex in gzipped format.

parent d7b5fc52
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ import argparse
import fileinput
import os
from itertools import islice
from gzip import open as gzopen
# from qaf_demux.libqafdemux import parse_fastq
OPD = os.path.dirname
......@@ -70,15 +71,16 @@ def main():
bc_len = len(barcode)
else:
assert(len(barcode) == bc_len), f"len({barcode}) != {bc_len}"
outfiles[barcode] = open(OPJ(out_dir, f"{barcode}.fastq"), "w")
outfiles[barcode] = gzopen(OPJ(out_dir, f"{barcode}.fastq.gz"), "wb")
if not outfiles:
print("No barcode given.")
exit(0)
outfiles["undetermined"] = open(OPJ(
out_dir, f"undetermined.fastq"), "w")
outfiles["undetermined"] = gzopen(OPJ(
out_dir, f"undetermined.fastq.gz"), "wb")
bc_start = args.barcode_start - 1
def bc_prob_profile(seq, qual):
# if bytes instead of string
# return [(letter, 10 ** ((33 - quality) / 10))
return [(letter, 10 ** ((33 - ord(quality)) / 10))
for letter, quality
......@@ -125,7 +127,7 @@ def main():
best_prob,
best_diff) = (barcode, this_prob, this_diff)
bc_comments = f"{best_bc}:{best_prob}:{best_diff}"
fq_repr = f"{name} {bc_comments}\n{seq}\n+\n{qual}\n"
fq_repr = f"{name} {bc_comments}\n{seq}\n+\n{qual}\n".encode("utf-8")
if best_diff <= args.max_diff:
outfiles[best_bc].write(fq_repr)
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment