Mercurial > repos > tyty > structurefold
diff predict/rtts_plot.py @ 4:a292aaf51735 draft
Uploaded
author | tyty |
---|---|
date | Mon, 15 Sep 2014 14:52:43 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/predict/rtts_plot.py Mon Sep 15 14:52:43 2014 -0400 @@ -0,0 +1,56 @@ +#!/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('DMS 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 + ax.set_xticks(np.arange(0,N,intervel*tail)) + print(np.arange(0,N,intervel*tail)) + ax.set_xticklabels(np.arange(0,N,intervel*tail)) + + ax.set_title(id_s+" reactivity distribution") + savefig(path+id_s+'.tif') + + + + + + + +