Previous changeset 27:8f6b0b0b242c (2016-01-28) Next changeset 29:c75a787fd1b1 (2016-01-28) |
Commit message:
Uploaded |
modified:
saint_wrapper.py |
b |
diff -r 8f6b0b0b242c -r b7e5a9bfa620 saint_wrapper.py --- a/saint_wrapper.py Thu Jan 28 16:31:30 2016 -0500 +++ b/saint_wrapper.py Thu Jan 28 16:32:34 2016 -0500 |
[ |
@@ -1,10 +1,10 @@ ####################################################################################### -# Python-code: SAINT wrapper +# Python-code: Dotplot Runner # Author: Adam L Borne # Contributers: Paul A Stewart, Brent Kuenzi ####################################################################################### -# This program takes a bait, prey and interactions file and uses SaintExpress to -# generate resulting matrices. This allows the software to run within galaxy. +# This runs SAINTexpress found at http://saint-apms.sourceforge.net/Main.html in +# galaxy. ####################################################################################### # Copyright (C) Adam Borne. # Permission is granted to copy, distribute and/or modify this document @@ -16,18 +16,17 @@ ####################################################################################### ## REQUIRED INPUT ## -# 1) inter_file: Interaction file listing experiment bait, assignement, gene name and -# spectrum count. -# 2) prey_file: Prey file listing gene name, sequence legnth, and gene id. -# 3) bait_file: Bait file listing bait experiment, assignment, and T or C. -# 4) vc_bool: Boolean used to determine if virtual controls are being used. -# 5) vc_num: Number of virtual controls to be used. (default = 1) -# 6) go_bool: Boolean used to determine used of external data set. -# 7) go_file: External data file if being used. (default = "None") +# 1) list_file: SaintExpress output file. +# 2) FDR1: Primary false discovery rate. (default = 0.01) +# 3) FDR2: Secondary false discovery rate. (default = 0.025) +# 4) spec_max: Maximum spectral count. (default = 50) ####################################################################################### + + import os import sys + inter_file = sys.argv[1] prey_file = sys.argv[2] bait_file = sys.argv[3] @@ -39,54 +38,70 @@ output_file = sys.argv[9] ins_path = sys.argv[10] -# Verifies the install of SaintExpress and installs if not found. -def first_run_check(): - os.chdir(ins_path) - dirs_list = [] - for (dirpath, dirnames, filename) in os.walk("./"): - dirs_list.extend(dirnames) - break - if r"SAINTexpress_v3.6.1__2015-05-03" in dirs_list: - pass - else: - cmd = r"unzip SAINTexpress_v3.6.1__2015-05-03.zip" - os.system(cmd) - os.chdir("./SAINTexpress_v3.6.1__2015-05-03") - cmd1 = r"make -j" - os.system(cmd1) -def default_run(inter_file1,prey_file1,bait_file1,output_file1,num_of_rep1): - 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) - os.system(cmd) - open('list.txt') - os.rename('list.txt', str(output_file1)) +def first_run_check(): + dirs_list = [] + for (dirpath, dirnames, filename) in os.walk("./"): + dirs_list.extend(dirnames) + break + if r"SAINTexpress_v3.6.1__2015-05-03" in dirs_list: + pass + else: + cmd = r"unzip SAINTexpress_v3.6.1__2015-05-03.zip" + os.system(cmd) + os.chdir("./SAINTexpress_v3.6.1__2015-05-03") + cmd1 = r"make -j" + os.system(cmd1) + + +def default_run(inter_file1, prey_file1, bait_file1, output_file1, num_of_rep1): + # Default is no virtual controls through purification and set replicates number. + 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)) + os.system(cmd) + open('list.txt') + os.rename('list.txt', str(output_file1)) + -def with_L(inter_file1,prey_file1,bait_file1,output_file1,vc_num1,num_of_rep1): - 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) - os.system(cmd) - open('list.txt') - os.rename('list.txt', str(output_file1)) +def with_L(inter_file1, prey_file1, bait_file1, output_file1, vc_num1, num_of_rep1): + # L is the flag for Virtual Controls through Purification. + 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)) + os.system(cmd) + open('list.txt') + os.rename('list.txt', str(output_file1)) + -def external_data_no_L(inter_file1,prey_file1,bait_file1,output_file1,go_file1,num_of_rep1): - 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) - os.system(cmd) - open('list.txt') - os.rename('list.txt', str(output_file1)) +def external_data_no_L(inter_file1, prey_file1, bait_file1, output_file1, go_file1, num_of_rep1): + # Uses external data in the GO file format and no Virtual Controls. + 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)) + os.system(cmd) + open('list.txt') + os.rename('list.txt', str(output_file1)) + -def external_data_with_L(inter_file1,prey_file1,bait_file1,output_file1,go_file1,num_of_rep1,vc_num1): - 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) - os.system(cmd) - open('list.txt') - os.rename('list.txt', str(output_file1)) +def external_data_with_L(inter_file1, prey_file1, bait_file1, output_file1, go_file1, num_of_rep1, vc_num1): + # Uses external data in the GO file format and Virtual Controls. + 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)) + os.system(cmd) + open('list.txt') + os.rename('list.txt', str(output_file1)) + -first_run_check() -if (vc_bool == "true"): - if (go_bool == "false"): - with_L(inter_file, prey_file, bait_file, output_file, vc_num, num_of_rep) - elif (go_bool == "true"): - external_data_with_L(inter_file, prey_file, bait_file, output_file, go_file, num_of_rep, vc_num) -elif (vc_bool == "false"): - if (go_bool == "false"): - default_run(inter_file, prey_file, bait_file, output_file, num_of_rep) - elif (go_bool == "true"): - external_data_no_L(inter_file, prey_file, bait_file, output_file, go_file, num_of_rep) +first_run_check() +if vc_bool == "true": + if go_bool == "false": + with_L(inter_file, prey_file, bait_file, output_file, vc_num, num_of_rep) + elif go_bool == "true": + external_data_with_L(inter_file, prey_file, bait_file, output_file, go_file, num_of_rep, vc_num) +elif vc_bool == "false": + if go_bool == "false": + default_run(inter_file, prey_file, bait_file, output_file, num_of_rep) + elif go_bool == "true": + external_data_no_L(inter_file, prey_file, bait_file, output_file, go_file, num_of_rep) |