-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadLenHist.py
More file actions
31 lines (29 loc) · 889 Bytes
/
readLenHist.py
File metadata and controls
31 lines (29 loc) · 889 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
import sys
import argparse
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
def hist():
l = []
with open(args.i, 'r') as f:
for line in f:
l.append(len(f.next().rstrip("\n")))
f.next()
f.next()
p = PdfPages(args.o + "RLHist.pdf")
plot = plt.figure()
plt.title("Read Length")
plt.ylabel("Number of Reads")
plt.xlabel("Read Length")
plt.hist(l, 257, color = 'blue', alpha = .6)
p.savefig(plot)
p.close()
parser = argparse.ArgumentParser(description = "plots a histogram of read lenghts from a fastq file into a pdf")
parser.add_argument("i", help = "input fastq file")
parser.add_argument("o", help = "output pdf destination")
if len(sys.argv) < 2:
parser.print_help()
else:
args = parser.parse_args()
hist()