diff saint_wrapper.py @ 26:bb1601260366 draft

Uploaded
author bornea
date Thu, 28 Jan 2016 16:31:19 -0500
parents
children b7e5a9bfa620
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/saint_wrapper.py	Thu Jan 28 16:31:19 2016 -0500
@@ -0,0 +1,92 @@
+#######################################################################################
+# Python-code: SAINT wrapper 
+# Author: Adam L Borne
+# Contributers: Paul A Stewart, Brent Kuenzi
+#######################################################################################
+# This program takes a bait, prey and interactions file and uses SaintExpress to 
+# generate resulting matrices. This allows the software to run within galaxy. 
+#######################################################################################
+# Copyright (C)  Adam Borne.
+# Permission is granted to copy, distribute and/or modify this document
+# under the terms of the GNU Free Documentation License, Version 1.3
+# or any later version published by the Free Software Foundation;
+# with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+# A copy of the license is included in the section entitled "GNU
+# Free Documentation License".
+#######################################################################################
+## REQUIRED INPUT ##
+
+# 1) inter_file: Interaction file listing experiment bait, assignement, gene name and 
+# spectrum count.
+# 2) prey_file: Prey file listing gene name, sequence legnth, and gene id.
+# 3) bait_file: Bait file listing bait experiment, assignment, and T or C. 
+# 4) vc_bool: Boolean used to determine if virtual controls are being used.
+# 5) vc_num: Number of virtual controls to be used. (default = 1)
+# 6) go_bool: Boolean used to determine used of external data set. 
+# 7) go_file: External data file if being used. (default = "None")
+#######################################################################################
+import os
+import sys
+
+inter_file = sys.argv[1]
+prey_file = sys.argv[2]
+bait_file = sys.argv[3]
+num_of_rep = sys.argv[4]
+vc_bool = sys.argv[5]
+vc_num = sys.argv[6]
+go_bool = sys.argv[7]
+go_file = sys.argv[8]
+output_file = sys.argv[9]
+ins_path = sys.argv[10]
+
+# Verifies the install of SaintExpress and installs if not found.
+def first_run_check(): 
+	os.chdir(ins_path)
+	dirs_list = []
+	for (dirpath, dirnames, filename) in os.walk("./"):
+		dirs_list.extend(dirnames)
+		break
+	if r"SAINTexpress_v3.6.1__2015-05-03" in dirs_list:
+		pass
+	else: 
+		cmd = r"unzip SAINTexpress_v3.6.1__2015-05-03.zip" 
+		os.system(cmd)
+		os.chdir("./SAINTexpress_v3.6.1__2015-05-03")
+		cmd1 = r"make -j"
+		os.system(cmd1)
+
+def default_run(inter_file1,prey_file1,bait_file1,output_file1,num_of_rep1):
+	cmd = str(ins_path) + r"/SAINTexpress_v3.6.1__2015-05-03/bin/SAINTexpress-spc " + r"-R" + str(num_of_rep1) + " " + str(inter_file1) + " " + str(prey_file1) + " " + str(bait_file1) 
+	os.system(cmd) 
+	open('list.txt')
+	os.rename('list.txt', str(output_file1)) 
+
+def with_L(inter_file1,prey_file1,bait_file1,output_file1,vc_num1,num_of_rep1):
+	cmd = str(ins_path) + r"/SAINTexpress_v3.6.1__2015-05-03/bin/SAINTexpress-spc "+ r"-R" + str(num_of_rep1) + " " + r"-L" + str(vc_num1) + " " + str(inter_file1) + " " + str(prey_file1) + " " + str(bait_file1) 
+	os.system(cmd) 
+	open('list.txt')
+	os.rename('list.txt', str(output_file1)) 
+
+def external_data_no_L(inter_file1,prey_file1,bait_file1,output_file1,go_file1,num_of_rep1):
+	cmd = str(ins_path) + r"/SAINTexpress_v3.6.1__2015-05-03/bin/SAINTexpress-spc "+ r"-R" + str(num_of_rep1) + " " + str(inter_file1) + " " + str(prey_file1) + " " + str(bait_file1) + " " + str(go_file1)
+	os.system(cmd) 
+	open('list.txt')
+	os.rename('list.txt', str(output_file1)) 
+
+def external_data_with_L(inter_file1,prey_file1,bait_file1,output_file1,go_file1,num_of_rep1,vc_num1):
+	cmd = str(ins_path) + r"/SAINTexpress_v3.6.1__2015-05-03/bin/SAINTexpress-spc "+ r"-R" + str(num_of_rep1) + " " + r"-L" + str(vc_num1) + " " + str(inter_file1) + " " + str(prey_file1) + " " + str(bait_file1) + " " + str(go_file1)
+	os.system(cmd) 
+	open('list.txt')
+	os.rename('list.txt', str(output_file1)) 
+
+first_run_check() 
+if (vc_bool == "true"):
+	if (go_bool == "false"):
+		with_L(inter_file, prey_file, bait_file, output_file, vc_num, num_of_rep)
+	elif (go_bool == "true"):
+		external_data_with_L(inter_file, prey_file, bait_file, output_file, go_file, num_of_rep, vc_num)
+elif (vc_bool == "false"):
+	if (go_bool == "false"):
+		default_run(inter_file, prey_file, bait_file, output_file, num_of_rep)
+	elif (go_bool == "true"):
+		external_data_no_L(inter_file, prey_file, bait_file, output_file, go_file, num_of_rep)