forked from uvasomrc/quality
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqcheck.py
More file actions
38 lines (30 loc) · 744 Bytes
/
qcheck.py
File metadata and controls
38 lines (30 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
import sys
from Bio import SeqIO
import matplotlib.pyplot as plt
# Accept command line argument
if len(sys.argv) < 3:
print("USAGE: python %s <r1-FASTQ> <r2-FASTQ>" % sys.argv[0])
sys.exit()
# input fastq file
r1Fastq = sys.argv[1]
r2Fastq = sys.argv[2]
# define plot function
def myPlotFunc(fastq):
for i,rec in enumerate(SeqIO.parse(fastq,"fastq")):
if i >= 50:
break
plt.plot(rec.letter_annotations["phred_quality"])
plt.ylim(0,45)
plt.ylabel("PHRED quality score")
plt.xlabel("Position")
# plot quality of forward reads
plt.subplot(1,2,1)
myPlotFunc(r1Fastq)
# plot quality of reverse reads
plt.subplot(1,2,2)
myPlotFunc(r2Fastq)
# save plot
plt.savefig("plots/plot.png")
print("Done")
sys.exit()