changeset 67:96a827962750 draft

Uploaded updated scripts, removed *.pyc and .DS_Store
author devteam
date Fri, 21 Nov 2014 11:28:59 -0500
parents d2817a631a7b
children fb80870002a3
files Iterative_mapping/._.DS_Store Iterative_mapping/._iterative_map.xml Iterative_mapping/read_file.pyc Iterative_mapping/read_s_file.pyc get_reads/._.DS_Store get_reads/read_file.pyc predict/._.DS_Store predict/._predict_RNAs.py predict/parse_dis_pac.pyc predict/predict_RNAs.py predict/read_file.pyc predict/rtts_plot.py predict/rtts_plot.pyc reactivity_cal/parse_dis_react.pyc reactivity_cal/react_norm_function.pyc
diffstat 15 files changed, 41 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
Binary file Iterative_mapping/._.DS_Store has changed
Binary file Iterative_mapping/._iterative_map.xml has changed
Binary file Iterative_mapping/read_file.pyc has changed
Binary file Iterative_mapping/read_s_file.pyc has changed
Binary file get_reads/._.DS_Store has changed
Binary file get_reads/read_file.pyc has changed
Binary file predict/._.DS_Store has changed
Binary file predict/._predict_RNAs.py has changed
Binary file predict/parse_dis_pac.pyc has changed
--- a/predict/predict_RNAs.py	Tue Nov 18 16:24:04 2014 -0500
+++ b/predict/predict_RNAs.py	Fri Nov 21 11:28:59 2014 -0500
@@ -1,6 +1,9 @@
 #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
@@ -15,12 +18,12 @@
 output_file = sys.argv[4]
 
 
-flag = 0
+flag = False
 if sys.argv[3]!='None': #input reactivity file if provided
     react_file = sys.argv[3]
     react = parse_dist(react_file)
     react = react[1]
-    flag = 1
+    flag = True
 
 syspath = os.getcwd()
 
@@ -38,54 +41,55 @@
     
 
 #predict RNA structures
-output_directory = os.path.join(syspath, "output_files/")
-os.makedirs(output_directory)
+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)):
     id_s = ids[i][0]
     print(id_s)
     #Put RNA sequence and reactivities into files
     if id_s in seqs:
-        f = file(syspath+"temp.txt", 'w')        
-        f.write('>'+id_s)
-        f.write('\n')
-        f.write(seqs[id_s])
-        f.close()
-        if flag == 0:
-            os.system("Fold "+syspath+"temp.txt"+" "+output_directory+id_s+".ct")
-        if flag == 1:
+        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 %s' % (os.path.join(syspath, temp.txt), os.path.join(output_directory, '%s.ct' % id_s)))
+            subprocess.call(command)
+        else:
             if id_s in react:
-                f = file(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
-                #h = file(syspath+"output_f/transcript_reactivities.txt", 'w')
-                #h.write(id_s)
-                #h.write('\n')
+                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':
-                        f.write(str(j+1))
-                        f.write('\t')
-                        f.write(str(react[id_s][j]))
-                        f.write('\n')
+                        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')
-                f.close()
+                fh.close()
                 #h.write('\n')
                 #h.write('\n')
-                os.system("Fold "+syspath+"temp.txt"+" -sh"+" "+syspath+"constraint.txt"+" "+output_directory+id_s+".ct")
+                command = shlex.split("Fold %s -sh %s %s" % (os.path.join(syspath, "temp.txt"), 
+                                                             os.path.join(syspath, "constraint.txt"),
+                                                             os.path.join(output_directory, "%s.ct" % id_s)))
+                subprocess.call(command)
             else:
                 print(id_s+" not in the data of react!")
-        os.system("draw "+output_directory+id_s+".ct "+output_directory+"/"+id_s+".ps")
+        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
-os.system("tar -zcvPf "+output_file+" "+output_directory+"/"+"*.* 2>"+output_directory+"log.txt")
-os.system("rm -f "+syspath+"temp.txt")
-os.system("rm -r "+output_directory)
-if flag == 1:
-    os.system("rm -f "+syspath+"constraint.txt")
- #   h.close()
-    
-    
-
-
-
+tarball = tarfile.open(output_file, 'w:gz')
+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()
\ No newline at end of file
Binary file predict/read_file.pyc has changed
--- a/predict/rtts_plot.py	Tue Nov 18 16:24:04 2014 -0500
+++ b/predict/rtts_plot.py	Fri Nov 21 11:28:59 2014 -0500
@@ -2,6 +2,7 @@
 #Make a plot of reactivity distribution
 
 import sys
+import os
 import numpy as np
 import matplotlib
 from pylab import *
@@ -46,7 +47,7 @@
     ax.set_xticklabels(np.arange(0,upmax,intervel*tail))
 
     ax.set_title(id_s+" reactivity distribution")
-    savefig(path+id_s+'.tif')
+    savefig(os.path.join(path, id_s+'.tif'))
 
 
 
Binary file predict/rtts_plot.pyc has changed
Binary file reactivity_cal/parse_dis_react.pyc has changed
Binary file reactivity_cal/react_norm_function.pyc has changed