annotate maaslin-4450aa4ecc84/maaslin_wrapper.py @ 1:a87d5a5f2776

Uploaded the version running on the prod server
author george-weingart
date Sun, 08 Feb 2015 23:08:38 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
1 #!/usr/bin/env python
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
2
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
3 """
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
4 Author: George Weingart
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
5 Description: Wrapper program for maaslin
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
6 """
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
7
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
8 #####################################################################################
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
9 #Copyright (C) <2012>
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
10 #
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
11 #Permission is hereby granted, free of charge, to any person obtaining a copy of
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
12 #this software and associated documentation files (the "Software"), to deal in the
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
13 #Software without restriction, including without limitation the rights to use, copy,
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
14 #modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
15 #and to permit persons to whom the Software is furnished to do so, subject to
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
16 #the following conditions:
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
17 #
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
18 #The above copyright notice and this permission notice shall be included in all copies
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
19 #or substantial portions of the Software.
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
20 #
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
21 #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
22 #INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
23 #PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
24 #HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
25 #OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
26 #SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
27 #####################################################################################
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
28
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
29 __author__ = "George Weingart"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
30 __copyright__ = "Copyright 2012"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
31 __credits__ = ["George Weingart"]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
32 __license__ = "MIT"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
33 __maintainer__ = "George Weingart"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
34 __email__ = "george.weingart@gmail.com"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
35 __status__ = "Development"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
36
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
37 from cStringIO import StringIO
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
38 import sys,string
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
39 import os
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
40 import tempfile
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
41 from pprint import pprint
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
42 import argparse
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
43
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
44 ######################################################################################
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
45 # Parse input parms #
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
46 ######################################################################################
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
47 def read_params(x):
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
48 parser = argparse.ArgumentParser(description='MaAsLin Argparser')
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
49 parser.add_argument('--lastmeta', action="store", dest='lastmeta',nargs='?')
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
50 parser.add_argument('--input', action="store", dest='input',nargs='?')
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
51 parser.add_argument('--output', action="store", dest='output',nargs='?')
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
52 parser.add_argument('--zip_file', action="store", dest='zip_file',nargs='?')
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
53 parser.add_argument('--alpha', action="store", type=float,default=0.05,dest='alpha',nargs='?')
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
54 parser.add_argument('--min_abd', action="store", type=float,default=0.0001,dest='min_abd',nargs='?')
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
55 parser.add_argument('--min_samp', action="store", type=float,default=0.01,dest='min_samp',nargs='?')
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
56 parser.add_argument('--tool_option1', action="store", dest='tool_option1',nargs='?')
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
57 return parser
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
58
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
59
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
60
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
61 ######################################################################################
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
62 # Build read config file #
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
63 ######################################################################################
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
64 def build_read_config_file(strTempDir,results, DSrc, DMaaslin, root_dir):
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
65 fname = results.input
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
66 input_file = open(fname)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
67 input_lines = input_file.readlines()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
68 LenInput = len(input_lines)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
69 input_file.close()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
70 TopLimit = int(results.lastmeta)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
71 ReadConfigFileName = os.path.join(strTempDir,"Test.read.config")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
72 Q = "'"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
73
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
74 #WorkingDir = os.getcwd()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
75 WorkingDir = root_dir
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
76 os.chdir(DMaaslin)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
77
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
78 Limit1 = Q + "2-" + str(TopLimit ) + Q
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
79 ReadConfigTb1 = [
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
80 os.path.join(DSrc,"CreateReadConfigFile.R"),
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
81 "-c",
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
82 Limit1,
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
83 ReadConfigFileName,
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
84 "Metadata"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
85 ">/dev/null",\
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
86 "2>&1"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
87 ]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
88
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
89 cmd_config1 = " ".join(ReadConfigTb1)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
90
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
91 os.system(cmd_config1)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
92
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
93 Limit2 = Q + str(TopLimit +1 ) + '-' + Q
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
94 ReadConfigTb2 = [
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
95 os.path.join(DSrc,"CreateReadConfigFile.R"),
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
96 "-a",
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
97 "-c",
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
98 Limit2,
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
99 ReadConfigFileName,
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
100 "Abundance"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
101 ">/dev/null",\
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
102 "2>&1"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
103 ]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
104
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
105 cmd_config2 = " ".join(ReadConfigTb2)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
106 os.system(cmd_config2)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
107 os.chdir(WorkingDir)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
108 return ReadConfigFileName
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
109
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
110
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
111 ######################################################################################
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
112 # Main Program #
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
113 ######################################################################################
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
114
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
115 # Parse commandline in
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
116 parser = read_params( sys.argv )
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
117 results = parser.parse_args()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
118 root_dir = os.environ.get('maaslin_SCRIPT_PATH')
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
119
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
120
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
121
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
122
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
123
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
124
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
125 ### If option 2 is selected inform user on 2 outputs
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
126 if results.tool_option1 == "2":
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
127 print "***Please note: 2 output files are generated: Complete zipped results + Summary ***"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
128
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
129 ### Project name
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
130 strProjectName = os.path.splitext(os.path.basename(results.input))[0]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
131
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
132 ### Define directory locations
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
133 D = os.path.join(root_dir)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
134 DSrc = os.path.join(root_dir,"src")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
135 DInput = os.path.join(root_dir,"maaslin","input")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
136 DMaaslin = os.path.join(root_dir)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
137
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
138 DMaaslinGalaxy = os.path.join(root_dir)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
139
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
140
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
141
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
142 ### Make temporary folder to work in
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
143 ### Change permissions to make useable
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
144 strTempDir = tempfile.mkdtemp()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
145 cmd_chmod = "chmod 755 /" + strTempDir
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
146 os.system(cmd_chmod)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
147 cmd_mkdir1 = "mkdir -m 755 " + os.path.join(strTempDir,strProjectName)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
148 os.system(cmd_mkdir1)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
149
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
150 ### Transpose the pcl file to a tsv file
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
151 TbCmdTranspose = [\
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
152 "python",
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
153 DMaaslinGalaxy + "/transpose.py<" + str(results.input) + ">" + os.path.join(strTempDir,"output.tsv")\
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
154 ]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
155 cmd_transpose = " ".join(TbCmdTranspose)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
156 os.system(cmd_transpose)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
157
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
158 ### Make path for target output file
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
159 OutputFile = os.path.join(strTempDir,strProjectName,strProjectName+".txt")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
160
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
161 ### Make read config file
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
162 ReadConfigFileName = build_read_config_file(strTempDir,results, DSrc, DMaaslin, root_dir)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
163
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
164 ### Build MaAsLin comamnd
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
165 CmdsArray = [\
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
166 os.path.join(DSrc,"Maaslin.R"), \
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
167 "-d", str(results.alpha),\
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
168 "-r", str(results.min_abd),\
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
169 "-p", str(results.min_samp), \
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
170 "-i", \
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
171 ReadConfigFileName, \
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
172 OutputFile, \
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
173 os.path.join(strTempDir,"output.tsv"), \
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
174 "-v",\
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
175 "ERROR",\
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
176 ">/dev/null",\
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
177 "2>&1"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
178 ]
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
179
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
180 invoke_maaslin_cmd = " ".join(CmdsArray)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
181
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
182
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
183
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
184
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
185
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
186 ### Write to directory cmd line used for troubleshooting
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
187 #CmdFileName = os.path.join(strTempDir,"cmdfile.txt")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
188 #OutFile = open(CmdFileName,"w")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
189 #OutputString = invoke_maaslin_cmd + "\n"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
190 #OutFile.write(OutputString)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
191 #OutFile.close()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
192
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
193 ### Call MaAsLin
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
194 os.system(invoke_maaslin_cmd)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
195
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
196
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
197 ### Copy output file to make available to galaxy
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
198 cmd_copy = "cp " + os.path.join(strTempDir,strProjectName+"/output.txt") + " " + results.output
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
199 MsgFileName = os.path.join(strTempDir,strProjectName+"/output.txt")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
200
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
201 if not os.path.isfile(MsgFileName):
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
202 cmd_copy = "cp " + os.path.join(strTempDir,strProjectName+"/output.txt") + " " + results.output
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
203 OutFile = open(MsgFileName,"w")
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
204 OutputString = "A MaAsLin error has occurred\n"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
205 OutputString = OutputString + "It typically happens when incorrect 'Last metadata row' was selected\n"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
206 OutputString = OutputString + "For demo data please choose 'Weight'\n"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
207 OutFile.write(OutputString)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
208 OutFile.close()
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
209
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
210 os.system(cmd_copy)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
211
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
212 ### Zip up output folder
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
213 cmd_zip = "zip -jr " + os.path.join(strTempDir,strProjectName+".zip") + " " + os.path.join(strTempDir,strProjectName) + ">/dev/null 2>&1"
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
214
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
215 os.system(cmd_zip)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
216
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
217 ### Copy output folder to make available to galaxy
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
218 cmd_copy_zip = "cp " + os.path.join(strTempDir,strProjectName+".zip") + " " + results.zip_file
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
219 os.system(cmd_copy_zip)
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
220
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
221 ### Delete temp directory
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
222 cmd_del_tempdir = "rm -r " + strTempDir
a87d5a5f2776 Uploaded the version running on the prod server
george-weingart
parents:
diff changeset
223 ######os.system(cmd_del_tempdir)