Mercurial > repos > tyty > structurefold
comparison predict/rtts_plot.py @ 64:a1ce42d5258d draft
Uploaded
author | tyty |
---|---|
date | Tue, 18 Nov 2014 15:54:31 -0500 |
parents | afd114ef8857 |
children | 96a827962750 |
comparison
equal
deleted
inserted
replaced
63:c1f1b552c1b8 | 64:a1ce42d5258d |
---|---|
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('Structural 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 upmax = int(math.ceil(float(N)/intervel/tail)*intervel*tail)+1 | |
44 ax.set_xticks(np.arange(0,upmax,intervel*tail)) | |
45 print(np.arange(0,upmax,intervel*tail)) | |
46 ax.set_xticklabels(np.arange(0,upmax,intervel*tail)) | |
47 | |
48 ax.set_title(id_s+" reactivity distribution") | |
49 savefig(path+id_s+'.tif') | |
50 | |
51 | |
52 | |
53 | |
54 | |
55 | |
56 | |
57 |