annotate saint_wrapper.py @ 28:b7e5a9bfa620 draft

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