26
|
1 #######################################################################################
|
|
2 # Python-code: SAINT wrapper
|
|
3 # Author: Adam L Borne
|
|
4 # Contributers: Paul A Stewart, Brent Kuenzi
|
|
5 #######################################################################################
|
|
6 # This program takes a bait, prey and interactions file and uses SaintExpress to
|
|
7 # generate resulting matrices. This allows the software to run within galaxy.
|
|
8 #######################################################################################
|
|
9 # Copyright (C) Adam Borne.
|
|
10 # Permission is granted to copy, distribute and/or modify this document
|
|
11 # under the terms of the GNU Free Documentation License, Version 1.3
|
|
12 # or any later version published by the Free Software Foundation;
|
|
13 # with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
|
14 # A copy of the license is included in the section entitled "GNU
|
|
15 # Free Documentation License".
|
|
16 #######################################################################################
|
|
17 ## REQUIRED INPUT ##
|
|
18
|
|
19 # 1) inter_file: Interaction file listing experiment bait, assignement, gene name and
|
|
20 # spectrum count.
|
|
21 # 2) prey_file: Prey file listing gene name, sequence legnth, and gene id.
|
|
22 # 3) bait_file: Bait file listing bait experiment, assignment, and T or C.
|
|
23 # 4) vc_bool: Boolean used to determine if virtual controls are being used.
|
|
24 # 5) vc_num: Number of virtual controls to be used. (default = 1)
|
|
25 # 6) go_bool: Boolean used to determine used of external data set.
|
|
26 # 7) go_file: External data file if being used. (default = "None")
|
|
27 #######################################################################################
|
|
28 import os
|
|
29 import sys
|
|
30
|
|
31 inter_file = sys.argv[1]
|
|
32 prey_file = sys.argv[2]
|
|
33 bait_file = sys.argv[3]
|
|
34 num_of_rep = sys.argv[4]
|
|
35 vc_bool = sys.argv[5]
|
|
36 vc_num = sys.argv[6]
|
|
37 go_bool = sys.argv[7]
|
|
38 go_file = sys.argv[8]
|
|
39 output_file = sys.argv[9]
|
|
40 ins_path = sys.argv[10]
|
|
41
|
|
42 # Verifies the install of SaintExpress and installs if not found.
|
|
43 def first_run_check():
|
|
44 os.chdir(ins_path)
|
|
45 dirs_list = []
|
|
46 for (dirpath, dirnames, filename) in os.walk("./"):
|
|
47 dirs_list.extend(dirnames)
|
|
48 break
|
|
49 if r"SAINTexpress_v3.6.1__2015-05-03" in dirs_list:
|
|
50 pass
|
|
51 else:
|
|
52 cmd = r"unzip SAINTexpress_v3.6.1__2015-05-03.zip"
|
|
53 os.system(cmd)
|
|
54 os.chdir("./SAINTexpress_v3.6.1__2015-05-03")
|
|
55 cmd1 = r"make -j"
|
|
56 os.system(cmd1)
|
|
57
|
|
58 def default_run(inter_file1,prey_file1,bait_file1,output_file1,num_of_rep1):
|
|
59 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)
|
|
60 os.system(cmd)
|
|
61 open('list.txt')
|
|
62 os.rename('list.txt', str(output_file1))
|
|
63
|
|
64 def with_L(inter_file1,prey_file1,bait_file1,output_file1,vc_num1,num_of_rep1):
|
|
65 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)
|
|
66 os.system(cmd)
|
|
67 open('list.txt')
|
|
68 os.rename('list.txt', str(output_file1))
|
|
69
|
|
70 def external_data_no_L(inter_file1,prey_file1,bait_file1,output_file1,go_file1,num_of_rep1):
|
|
71 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)
|
|
72 os.system(cmd)
|
|
73 open('list.txt')
|
|
74 os.rename('list.txt', str(output_file1))
|
|
75
|
|
76 def external_data_with_L(inter_file1,prey_file1,bait_file1,output_file1,go_file1,num_of_rep1,vc_num1):
|
|
77 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)
|
|
78 os.system(cmd)
|
|
79 open('list.txt')
|
|
80 os.rename('list.txt', str(output_file1))
|
|
81
|
|
82 first_run_check()
|
|
83 if (vc_bool == "true"):
|
|
84 if (go_bool == "false"):
|
|
85 with_L(inter_file, prey_file, bait_file, output_file, vc_num, num_of_rep)
|
|
86 elif (go_bool == "true"):
|
|
87 external_data_with_L(inter_file, prey_file, bait_file, output_file, go_file, num_of_rep, vc_num)
|
|
88 elif (vc_bool == "false"):
|
|
89 if (go_bool == "false"):
|
|
90 default_run(inter_file, prey_file, bait_file, output_file, num_of_rep)
|
|
91 elif (go_bool == "true"):
|
|
92 external_data_no_L(inter_file, prey_file, bait_file, output_file, go_file, num_of_rep)
|