Created
July 2, 2020 18:16
-
-
Save audy/67e64cb64310d08fffbb0297a107ca7f to your computer and use it in GitHub Desktop.
check the frequency of the first N bases to try to identify barcode sequences in a non-demultiplexed fastq file
This file contains hidden or 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/env python3 | |
# usage: cat reads.fastq | ./get-barcodes.py | |
from Bio import SeqIO | |
from collections import defaultdict | |
BARCODE_SIZE = 14 | |
counts = defaultdict(lambda: 0) | |
with open("/dev/stdin") as handle: | |
for n, record in enumerate(SeqIO.parse(handle, "fastq")): | |
counts[str(record.seq)[0:BARCODE_SIZE]] += 1 | |
if n > 100_000: | |
break | |
for seq, count in counts.items(): | |
if count > 1000: | |
print(seq, count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment