# HG changeset patch # User tyty # Date 1426801050 14400 # Node ID 833961d63f1c31948889ff44d812151e13affbb3 # Parent 5658f528abebdedb9a775341837873dade822a27 Deleted selected files diff -r 5658f528abeb -r 833961d63f1c predict/parse_dis_pac.py --- a/predict/parse_dis_pac.py Thu Mar 19 17:36:58 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -#parse reactivity file into a dictionary - -import sys - -def parse_dist(in_file): - result = [] - distribution = {} - name = [] - f = open(in_file) - for aline in f.readlines(): - line = aline.strip() - dis = line.strip() - dist = dis.split('\t') #split the line and the reactivites or reads are in a list - if len(dist) > 0: - if len(dist) == 1: - if dist[0].strip().find('coverage')==-1: - name.append(line) #add the name in the name list - flag = 1 - t_name = line - else: - distri = [] - for i in range(0, len(dist)): - distri.append(dist[i].strip()) - distribution[t_name] = distri #add the list of reactivities into a dictionary - result.append(name) - result.append(distribution) #Output the dictionary - f.close() - return result - - - - - - - - - - - - - - - diff -r 5658f528abeb -r 833961d63f1c predict/parse_dis_pac.pyc Binary file predict/parse_dis_pac.pyc has changed diff -r 5658f528abeb -r 833961d63f1c predict/predict_RNAs.py --- a/predict/predict_RNAs.py Thu Mar 19 17:36:58 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -#RNA structure prediction & Output and illustrate reactivities - -import sys -import shlex -import subprocess -import tarfile -from parse_dis_pac import * -from read_file import * -from Bio import SeqIO -import os -from rtts_plot import * -import random -import string - - -id_file = sys.argv[1] -seq_file = sys.argv[2] -predict_type = sys.argv[3] -temperature = sys.argv[4] -output_file = sys.argv[5] - - -flag = False -if predict_type!='silico': #input reactivity file if provided - react_file = sys.argv[6] - slope = sys.argv[7] - intercept = sys.argv[8] - react = parse_dist(react_file) - react = react[1] - flag = True - -syspath = os.getcwd() - -ids = read_t_file(id_file) -sequences = SeqIO.parse(seq_file, 'fasta') - - -seqs = {} -for seq in sequences: - seqs[seq.id] = seq.seq.tostring() - -if len(ids)>100: #setup a limit of the number of sequence to be predicted - print("Number of sequences exceeds limitation!") - sys.exit(0) - - -#predict RNA structures -output_directory = os.path.join(syspath, "output_files") -if not os.path.exists(output_directory): - os.makedirs(output_directory) -for i in range(len(ids)): - flag2 = 0 - id_s = ids[i][0] - #print(id_s) - #Put RNA sequence and reactivities into files - if id_s in seqs: - fh = file(os.path.join(syspath,"temp.txt"), 'w') - fh.write('>'+id_s) - fh.write('\n') - fh.write(seqs[id_s]) - fh.close() - if not flag: - command = shlex.split('Fold %s -T %s %s' % (os.path.join(syspath, 'temp.txt'), temperature, os.path.join(output_directory, '%s.ct' % id_s))) - subprocess.call(command) - else: - if id_s in react: - fh = file(os.path.join(syspath, "constraint.txt"), 'w') - make_plot(react[id_s], id_s, output_directory) #make a plot of the distribution of the reactivites of the input RNA - for j in range(0, (len(react[id_s]))): - if react[id_s][j]!='NA': - fh.write(str(j+1)) - fh.write('\t') - fh.write(str(react[id_s][j])) - fh.write('\n') - #h.write(str(react[id_s][j])) #Output the reactivities - #h.write('\t') - fh.close() - #h.write('\n') - #h.write('\n') - command = shlex.split("Fold %s -sh %s -si %s -sm %s -T %s %s" % (os.path.join(syspath, "temp.txt"), - os.path.join(syspath, "constraint.txt"), intercept, slope, temperature, - os.path.join(output_directory, "%s.ct" % id_s))) - subprocess.call(command) - else: - print(id_s+" not in the data of react!") - flag2 = 1 - if flag2 == 0: - command = shlex.split('draw %s.ct %s.ps' % (os.path.join(output_directory, id_s), os.path.join(output_directory, id_s))) - subprocess.call(command) - else: - print(id_s+" not in the data of sequences!") - -#Remove the unnecessary files -tarball = tarfile.open(output_file, 'w:') -for filename in os.listdir(output_directory): - filepath = os.path.join(output_directory, filename) - print filepath - tarball.add(filepath, arcname=filename) -#print os.listdir(syspath) -#print os.listdir(output_directory) -# tarball.add('%s.tif' % os.path.join(syspath, id_s), arcname='%s.tif' % id_s) -tarball.close() diff -r 5658f528abeb -r 833961d63f1c predict/predict_RNAs.xml --- a/predict/predict_RNAs.xml Thu Mar 19 17:36:58 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ - - predict RNA structures with or without experimental constraints from the Reactivity Calculation module - - #if $reactivity.type == "restraint" - predict_RNAs.py $rna_list $reference_file $reactivity.type $temperature $output $reactivity.reactivity_file $reactivity.slope $reactivity.intercept - #else - predict_RNAs.py $rna_list $reference_file $reactivity.type $temperature $output - #end if - - - - - - - - - biopython - numpy - matplotlib - - - - - - - - - - - - - - - - - - - - - - - - - - -**Function** - -RNA Structure Prediction uses the RNAstructure algorithm (Version 5.6, http://rna.urmc.rochester.edu/RNAstructure.html) to predict RNA structures without restraints (in silico) or with restraints from structural reactivities, typically provided by the Reactivity Calculation module. Users can designate the temperature under which to predict the RNA structures. - ------ - -**Input**: - -* 1. A file with transcript Ids (Max num. 100), (each ID one line) -* 2. Reference file (fasta) used to map the reads to -* 3. Temperature for RNA structure prediction -* [Optional]: -* 1. A reactivity file with structural reactivity for each nucleotide on the sequence provided -* 2. Slope used with structural restraints (default 1.8) -* 3. Intercept used with structural restraints (default -0.6) - ------ - -**Output**: - -* 1. .ct files with predicted RNA structures [transciptID.ct] -* 2. .ps files which depict the predicted RNA structures [[transciptID.ps] -* [Optional] -* 3. .png files that shows the distribution of the reactivity of each nucleotide on the transcripts of interest. [transciptID.png] - ------ - -**Attention** - -Make sure that none of the transcript Ids contains a "|" or a space! - ------ - -**Backend program**: - -* 1. This module uses RNAstructure (http://rna.urmc.rochester.edu/RNAstructure.html) as the backend program to predict RNA structures. -* 2. Default parameters are used for RNAstructure except -T (Temperature), -sm (slope used with SHAPE restraints) and -si (intercept used with SHAPE restraints), for which users can specify the value - - - - - diff -r 5658f528abeb -r 833961d63f1c predict/read_file.py --- a/predict/read_file.py Thu Mar 19 17:36:58 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import sys - - - -def read_t_file(in_file): - f = open(in_file); - result = []; - for aline in f.readlines(): - temp = []; - tline = aline.strip(); - tl = tline.split('\t'); - for i in range(0, len(tl)): - temp.append(tl[i].strip()); - result.append(temp); - f.close(); - return result; - - diff -r 5658f528abeb -r 833961d63f1c predict/read_file.pyc Binary file predict/read_file.pyc has changed diff -r 5658f528abeb -r 833961d63f1c predict/rtts_plot.py --- a/predict/rtts_plot.py Thu Mar 19 17:36:58 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -#!/usr/bin/env python -#Make a plot of reactivity distribution - -import sys -import os -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): - font = {'family' : 'normal', - 'weight' : 'bold', - 'size' : 16} - matplotlib.rc('font', **font) - 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 = 'black',edgecolor = 'black') - ax.set_ylabel('Final Structural Reactivity (FSR)') - ax.set_xlabel('Nucleotide Number') - - - 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)) - savefig(os.path.join(path, id_s+'.tif')) - - - - - - - - diff -r 5658f528abeb -r 833961d63f1c predict/rtts_plot.pyc Binary file predict/rtts_plot.pyc has changed