Mercurial > repos > tyty > structurefold
view predict/rtts_plot.py @ 66:d2817a631a7b draft
Uploaded
author | tyty |
---|---|
date | Tue, 18 Nov 2014 16:24:04 -0500 |
parents | afd114ef8857 |
children | 96a827962750 |
line wrap: on
line source
#!/usr/bin/env python #Make a plot of reactivity distribution import sys import numpy as np import matplotlib from pylab import * import math #Convert the reactivities (Make NA to 0) def convert_react(a): r = [] for i in range(len(a)): if a[i]!='NA': r.append(float(a[i])) else: r.append(float(0)) return r #Make a plot of the distribution def make_plot(ar,id_s,path): N = len(ar) a = convert_react(ar) w = 1 ind = np.arange(N) fig = figure() fig, ax = subplots() ax.bar(ind+w, a, width = w, color = 'r',edgecolor = 'r') ax.set_ylabel('Structural Reactivity') ax.set_xlabel('Nucleotide Index') mag = int(math.log(N,10))-1 tail = 10**mag intervel = int(math.ceil(float(N)/tail/5)) print(N) print(intervel) tl = [] k = 0 upmax = int(math.ceil(float(N)/intervel/tail)*intervel*tail)+1 ax.set_xticks(np.arange(0,upmax,intervel*tail)) print(np.arange(0,upmax,intervel*tail)) ax.set_xticklabels(np.arange(0,upmax,intervel*tail)) ax.set_title(id_s+" reactivity distribution") savefig(path+id_s+'.tif')