Skip to content

Instantly share code, notes, and snippets.

@wdecoster
Created September 30, 2019 08:31
Show Gist options
  • Save wdecoster/6d96abcc1cf421ad86e4ecb9d05a8b0e to your computer and use it in GitHub Desktop.
Save wdecoster/6d96abcc1cf421ad86e4ecb9d05a8b0e to your computer and use it in GitHub Desktop.
from Bio import SeqIO
import seaborn as sns
from collections import defaultdict
import gzip
import sys
q_per_base = defaultdict(list)
for record in SeqIO.parse(gzip.open(sys.argv[1], 'rt'), "fastq"):
for n, q in zip(record.seq, record.letter_annotations["phred_quality"]):
q_per_base[n].append(q)
ax = sns.violinplot(data=list(q_per_base.values()))
ax.set_xticklabels(list(q_per_base.keys()))
fig = ax.get_figure()
fig.savefig(fname="Per_base_quality.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment