annotate toolshed_version/saint_wrapper.py @ 1:ff55700f9d9c draft

Uploaded
author bornea
date Tue, 15 Mar 2016 16:09:35 -0400
parents 11fe2e7c8fe3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
1 #######################################################################################
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
2 # Python-code: Dotplot Runner
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
3 # Author: Adam L Borne
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
4 # Contributers: Paul A Stewart, Brent Kuenzi
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
5 #######################################################################################
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
6 # This runs SAINTexpress found at http://saint-apms.sourceforge.net/Main.html in
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
7 # galaxy.
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
8 #######################################################################################
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
9 # Copyright (C) Adam Borne.
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
10 # Permission is granted to copy, distribute and/or modify this document
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
11 # under the terms of the GNU Free Documentation License, Version 1.3
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
12 # or any later version published by the Free Software Foundation;
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
13 # with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
14 # A copy of the license is included in the section entitled "GNU
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
15 # Free Documentation License".
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
16 #######################################################################################
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
17 ## REQUIRED INPUT ##
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
18
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
19 # 1) list_file: SaintExpress output file.
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
20 # 2) FDR1: Primary false discovery rate. (default = 0.01)
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
21 # 3) FDR2: Secondary false discovery rate. (default = 0.025)
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
22 # 4) spec_max: Maximum spectral count. (default = 50)
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
23 #######################################################################################
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
24
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
25
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
26 import os
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
27 import sys
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
28
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
29
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
30 inter_file = sys.argv[1]
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
31 prey_file = sys.argv[2]
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
32 bait_file = sys.argv[3]
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
33 num_of_rep = sys.argv[4]
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
34 vc_bool = sys.argv[5]
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
35 vc_num = sys.argv[6]
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
36 go_bool = sys.argv[7]
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
37 go_file = sys.argv[8]
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
38 output_file = sys.argv[9]
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
39 ins_path = sys.argv[10]
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
40
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
41
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
42 def first_run_check():
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
43 dirs_list = []
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
44 for (dirpath, dirnames, filename) in os.walk(str(ins_path)):
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
45 dirs_list.extend(dirnames)
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
46 break
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
47 if r"SAINTexpress_v3.6.1__2015-05-03" in dirs_list:
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
48 pass
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
49 else:
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
50 cmd = r"unzip " + str(ins_path) + "/SAINTexpress_v3.6.1__2015-05-03.zip -d " + str(ins_path)
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
51 os.system(cmd)
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
52 os.chdir(str(ins_path) + "/SAINTexpress_v3.6.1__2015-05-03")
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
53 cmd1 = r"make -j"
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
54 os.system(cmd1)
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
55
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
56
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
57 def default_run(inter_file1, prey_file1, bait_file1, output_file1, num_of_rep1):
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
58 # Default is no virtual controls through purification and set replicates number.
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
59 cmd = (str(ins_path) + r"/SAINTexpress_v3.6.1__2015-05-03/bin/SAINTexpress-spc " + r"-R"
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
60 + str(num_of_rep1) + " " + str(inter_file1) + " " + str(prey_file1) +
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
61 " " + str(bait_file1))
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
62 os.system(cmd)
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
63 open('list.txt')
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
64 os.rename('list.txt', str(output_file1))
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
65
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
66
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
67 def with_L(inter_file1, prey_file1, bait_file1, output_file1, vc_num1, num_of_rep1):
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
68 # L is the flag for Virtual Controls through Purification.
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
69 cmd = (str(ins_path) + r"/SAINTexpress_v3.6.1__2015-05-03/bin/SAINTexpress-spc "+ r"-R"
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
70 + str(num_of_rep1) + " " + r"-L" + str(vc_num1) + " " + str(inter_file1) + " " +
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
71 str(prey_file1) + " " + str(bait_file1))
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
72 os.system(cmd)
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
73 open('list.txt')
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
74 os.rename('list.txt', str(output_file1))
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
75
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
76
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
77 def external_data_no_L(inter_file1, prey_file1, bait_file1, output_file1, go_file1, num_of_rep1):
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
78 # Uses external data in the GO file format and no Virtual Controls.
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
79 cmd = (str(ins_path) + r"/SAINTexpress_v3.6.1__2015-05-03/bin/SAINTexpress-spc "+ r"-R"
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
80 + str(num_of_rep1) + " " + str(inter_file1) + " " + str(prey_file1) + " " +
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
81 str(bait_file1) + " " + str(go_file1))
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
82 os.system(cmd)
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
83 open('list.txt')
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
84 os.rename('list.txt', str(output_file1))
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
85
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
86
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
87 def external_data_with_L(inter_file1, prey_file1, bait_file1, output_file1, go_file1, num_of_rep1, vc_num1):
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
88 # Uses external data in the GO file format and Virtual Controls.
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
89 cmd = (str(ins_path) + r"/SAINTexpress_v3.6.1__2015-05-03/bin/SAINTexpress-spc "+ r"-R"
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
90 + str(num_of_rep1) + " " + r"-L" + str(vc_num1) + " " + str(inter_file1) + " " +
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
91 str(prey_file1) + " " + str(bait_file1) + " " + str(go_file1))
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
92 os.system(cmd)
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
93 open('list.txt')
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
94 os.rename('list.txt', str(output_file1))
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
95
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
96
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
97 first_run_check()
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
98 if vc_bool == "true":
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
99 if go_bool == "false":
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
100 with_L(inter_file, prey_file, bait_file, output_file, vc_num, num_of_rep)
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
101 elif go_bool == "true":
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
102 external_data_with_L(inter_file, prey_file, bait_file, output_file, go_file, num_of_rep, vc_num)
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
103 elif vc_bool == "false":
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
104 if go_bool == "false":
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
105 default_run(inter_file, prey_file, bait_file, output_file, num_of_rep)
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
106 elif go_bool == "true":
11fe2e7c8fe3 Uploaded
bornea
parents:
diff changeset
107 external_data_no_L(inter_file, prey_file, bait_file, output_file, go_file, num_of_rep)