comparison predict/rtts_plot.py @ 52:12551ae128be draft

Uploaded
author tyty
date Mon, 27 Oct 2014 01:52:39 -0400
parents a292aaf51735
children
comparison
equal deleted inserted replaced
51:765da0718336 52:12551ae128be
1 #!/usr/bin/env python
2 #Make a plot of reactivity distribution
3
4 import sys
5 import numpy as np
6 import matplotlib
7 from pylab import *
8 import math
9
10 #Convert the reactivities (Make NA to 0)
11 def convert_react(a):
12 r = []
13 for i in range(len(a)):
14 if a[i]!='NA':
15 r.append(float(a[i]))
16 else:
17 r.append(float(0))
18 return r
19
20
21 #Make a plot of the distribution
22 def make_plot(ar,id_s,path):
23 N = len(ar)
24 a = convert_react(ar)
25 w = 1
26 ind = np.arange(N)
27
28 fig = figure()
29 fig, ax = subplots()
30 ax.bar(ind+w, a, width = w, color = 'r',edgecolor = 'r')
31 ax.set_ylabel('DMS Reactivity')
32 ax.set_xlabel('Nucleotide Index')
33
34
35 mag = int(math.log(N,10))-1
36 tail = 10**mag
37
38 intervel = int(math.ceil(float(N)/tail)/5)
39 print(N)
40 print(intervel)
41 tl = []
42 k = 0
43 ax.set_xticks(np.arange(0,N,intervel*tail))
44 print(np.arange(0,N,intervel*tail))
45 ax.set_xticklabels(np.arange(0,N,intervel*tail))
46
47 ax.set_title(id_s+" reactivity distribution")
48 savefig(path+id_s+'.tif')
49
50
51
52
53
54
55
56