-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnuc_stats.py
More file actions
22 lines (17 loc) · 791 Bytes
/
nuc_stats.py
File metadata and controls
22 lines (17 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import matplotlib.pyplot as plt
import argparse
import numpy as np
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--infile', type=str, action='store', dest='infile', help='FASTA-formatted samples')
parser.add_argument('-o', '--outfile', type=str, action='store', dest='outfile', help='name of encoded text file')
args = parser.parse_args()
data = np.genfromtxt(args.infile)
data = data.reshape(data.shape[0],40,3)
profile = np.mean(data,axis=0)
plt.bar(range(1,41),profile[:,0])
plt.bar(range(1,41),profile[:,1],bottom=profile[:,0])
plt.bar(range(1,41),profile[:,2],bottom=profile[:,0]+profile[:,1])
plt.bar(range(1,41),profile[:,3],bottom=profile[:,0]+profile[:,1]+profile[:,2])
plt.legend(('A','C','G','T')
plt.title('Nucleotide distribution')
plt.savefig(args.outfile)