-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdist_graph.py
More file actions
executable file
·30 lines (23 loc) · 846 Bytes
/
dist_graph.py
File metadata and controls
executable file
·30 lines (23 loc) · 846 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
#! /usr/bin/env python
import argparse
import sys
import os
from pbcore.io import FastaReader
import matplotlib.pyplot as plt
# Set up argument parser
parser = argparse.ArgumentParser(
description="Create a read length distribution graph.")
parser.add_argument(
"infile", help="FASTA file containing the sequence reads",
type=str)
parser.add_argument(
'outfile', help="Specify a file to output the graph\
. The output format is deduced by the finame extension.",
type=argparse.FileType('w'))
args = parser.parse_args()
f = FastaReader(args.infile)
lenlist = [len(r.sequence) for r in f]
plt.hist(lenlist,50)
plt.ylabel('Number of reads')
plt.xlabel('Read length (bp)')
plt.savefig(args.outfile)