annotate saint_wrapper.py @ 8:67631a640534 draft default tip

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