Mercurial > repos > tyty > structurefold
comparison predict/rtts_plot.py @ 117:75e3711e23c4 draft
Uploaded
| author | tyty |
|---|---|
| date | Tue, 14 Apr 2015 14:17:27 -0400 |
| parents | f1eb39775b93 |
| children |
comparison
equal
deleted
inserted
replaced
| 116:62e8f7adf1ab | 117:75e3711e23c4 |
|---|---|
| 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 tl = [] | |
| 45 k = 0 | |
| 46 upmax = int(math.ceil(float(N)/intervel/tail)*intervel*tail)+1 | |
| 47 ax.set_xticks(np.arange(0,upmax,intervel*tail)) | |
| 48 ax.set_xticklabels(np.arange(0,upmax,intervel*tail)) | |
| 49 savefig(os.path.join(path, id_s+'.tif')) | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 |
