Mercurial > repos > tyty > structurefold
comparison predict/rtts_plot.py @ 74:63c41304b221 draft
Uploaded
author | tyty |
---|---|
date | Tue, 09 Dec 2014 03:03:30 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
73:1c325ff557d9 | 74:63c41304b221 |
---|---|
1 #!/usr/bin/env python | |
2 #Make a plot of reactivity distribution | |
3 | |
4 import sys | |
5 import os | |
6 import numpy as np | |
7 import matplotlib | |
8 from pylab import * | |
9 import math | |
10 | |
11 #Convert the reactivities (Make NA to 0) | |
12 def convert_react(a): | |
13 r = [] | |
14 for i in range(len(a)): | |
15 if a[i]!='NA': | |
16 r.append(float(a[i])) | |
17 else: | |
18 r.append(float(0)) | |
19 return r | |
20 | |
21 | |
22 #Make a plot of the distribution | |
23 def make_plot(ar,id_s,path): | |
24 font = {'family' : 'normal', | |
25 'weight' : 'bold', | |
26 'size' : 16} | |
27 matplotlib.rc('font', **font) | |
28 N = len(ar) | |
29 a = convert_react(ar) | |
30 w = 1 | |
31 ind = np.arange(N) | |
32 | |
33 fig = figure() | |
34 fig, ax = subplots() | |
35 ax.bar(ind+w, a, width = w, color = 'black',edgecolor = 'black') | |
36 ax.set_ylabel('Final Structural Reactivity (FSR)') | |
37 ax.set_xlabel('Nucleotide Number') | |
38 | |
39 | |
40 mag = int(math.log(N,10))-1 | |
41 tail = 10**mag | |
42 | |
43 intervel = int(math.ceil(float(N)/tail/5)) | |
44 print(N) | |
45 print(intervel) | |
46 tl = [] | |
47 k = 0 | |
48 upmax = int(math.ceil(float(N)/intervel/tail)*intervel*tail)+1 | |
49 ax.set_xticks(np.arange(0,upmax,intervel*tail)) | |
50 print(np.arange(0,upmax,intervel*tail)) | |
51 ax.set_xticklabels(np.arange(0,upmax,intervel*tail)) | |
52 savefig(os.path.join(path, id_s+'.tif')) | |
53 | |
54 | |
55 | |
56 | |
57 | |
58 | |
59 | |
60 |