Mercurial > repos > bornea > saintexpress
comparison toolshed_version/saint_wrapper.py @ 0:11fe2e7c8fe3 draft
Uploaded
author | bornea |
---|---|
date | Tue, 15 Mar 2016 16:06:51 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:11fe2e7c8fe3 |
---|---|
1 ####################################################################################### | |
2 # Python-code: Dotplot Runner | |
3 # Author: Adam L Borne | |
4 # Contributers: Paul A Stewart, Brent Kuenzi | |
5 ####################################################################################### | |
6 # This runs SAINTexpress found at http://saint-apms.sourceforge.net/Main.html in | |
7 # 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) list_file: SaintExpress output file. | |
20 # 2) FDR1: Primary false discovery rate. (default = 0.01) | |
21 # 3) FDR2: Secondary false discovery rate. (default = 0.025) | |
22 # 4) spec_max: Maximum spectral count. (default = 50) | |
23 ####################################################################################### | |
24 | |
25 | |
26 import os | |
27 import sys | |
28 | |
29 | |
30 inter_file = sys.argv[1] | |
31 prey_file = sys.argv[2] | |
32 bait_file = sys.argv[3] | |
33 num_of_rep = sys.argv[4] | |
34 vc_bool = sys.argv[5] | |
35 vc_num = sys.argv[6] | |
36 go_bool = sys.argv[7] | |
37 go_file = sys.argv[8] | |
38 output_file = sys.argv[9] | |
39 ins_path = sys.argv[10] | |
40 | |
41 | |
42 def first_run_check(): | |
43 dirs_list = [] | |
44 for (dirpath, dirnames, filename) in os.walk(str(ins_path)): | |
45 dirs_list.extend(dirnames) | |
46 break | |
47 if r"SAINTexpress_v3.6.1__2015-05-03" in dirs_list: | |
48 pass | |
49 else: | |
50 cmd = r"unzip " + str(ins_path) + "/SAINTexpress_v3.6.1__2015-05-03.zip -d " + str(ins_path) | |
51 os.system(cmd) | |
52 os.chdir(str(ins_path) + "/SAINTexpress_v3.6.1__2015-05-03") | |
53 cmd1 = r"make -j" | |
54 os.system(cmd1) | |
55 | |
56 | |
57 def default_run(inter_file1, prey_file1, bait_file1, output_file1, num_of_rep1): | |
58 # Default is no virtual controls through purification and set replicates number. | |
59 cmd = (str(ins_path) + r"/SAINTexpress_v3.6.1__2015-05-03/bin/SAINTexpress-spc " + r"-R" | |
60 + str(num_of_rep1) + " " + str(inter_file1) + " " + str(prey_file1) + | |
61 " " + str(bait_file1)) | |
62 os.system(cmd) | |
63 open('list.txt') | |
64 os.rename('list.txt', str(output_file1)) | |
65 | |
66 | |
67 def with_L(inter_file1, prey_file1, bait_file1, output_file1, vc_num1, num_of_rep1): | |
68 # L is the flag for Virtual Controls through Purification. | |
69 cmd = (str(ins_path) + r"/SAINTexpress_v3.6.1__2015-05-03/bin/SAINTexpress-spc "+ r"-R" | |
70 + str(num_of_rep1) + " " + r"-L" + str(vc_num1) + " " + str(inter_file1) + " " + | |
71 str(prey_file1) + " " + str(bait_file1)) | |
72 os.system(cmd) | |
73 open('list.txt') | |
74 os.rename('list.txt', str(output_file1)) | |
75 | |
76 | |
77 def external_data_no_L(inter_file1, prey_file1, bait_file1, output_file1, go_file1, num_of_rep1): | |
78 # Uses external data in the GO file format and no Virtual Controls. | |
79 cmd = (str(ins_path) + r"/SAINTexpress_v3.6.1__2015-05-03/bin/SAINTexpress-spc "+ r"-R" | |
80 + str(num_of_rep1) + " " + str(inter_file1) + " " + str(prey_file1) + " " + | |
81 str(bait_file1) + " " + str(go_file1)) | |
82 os.system(cmd) | |
83 open('list.txt') | |
84 os.rename('list.txt', str(output_file1)) | |
85 | |
86 | |
87 def external_data_with_L(inter_file1, prey_file1, bait_file1, output_file1, go_file1, num_of_rep1, vc_num1): | |
88 # Uses external data in the GO file format and Virtual Controls. | |
89 cmd = (str(ins_path) + r"/SAINTexpress_v3.6.1__2015-05-03/bin/SAINTexpress-spc "+ r"-R" | |
90 + str(num_of_rep1) + " " + r"-L" + str(vc_num1) + " " + str(inter_file1) + " " + | |
91 str(prey_file1) + " " + str(bait_file1) + " " + str(go_file1)) | |
92 os.system(cmd) | |
93 open('list.txt') | |
94 os.rename('list.txt', str(output_file1)) | |
95 | |
96 | |
97 first_run_check() | |
98 if vc_bool == "true": | |
99 if go_bool == "false": | |
100 with_L(inter_file, prey_file, bait_file, output_file, vc_num, num_of_rep) | |
101 elif go_bool == "true": | |
102 external_data_with_L(inter_file, prey_file, bait_file, output_file, go_file, num_of_rep, vc_num) | |
103 elif vc_bool == "false": | |
104 if go_bool == "false": | |
105 default_run(inter_file, prey_file, bait_file, output_file, num_of_rep) | |
106 elif go_bool == "true": | |
107 external_data_no_L(inter_file, prey_file, bait_file, output_file, go_file, num_of_rep) |