|
22 | 22 | def checkInput(axt, kaks, phylip, codeml, outdir): |
23 | 23 | '''Makes sure necessary programs are installed and proper file conversion |
24 | 24 | is run for optional analysis program.''' |
| 25 | + proceed = True |
25 | 26 | if kaks == True: |
26 | 27 | if codeml == True: |
27 | 28 | print("\n\tError: Please specify only one analysis program.\n") |
| 29 | + proceed = False |
28 | 30 | indir = os.path.isfile("bin/KaKs_Calculator") |
29 | 31 | if indir == False: |
30 | | - print("\n\tError: Please install KaKs_Clculator in the\ |
| 32 | + print("\n\tError: Please install KaKs_Calculator in the\ |
31 | 33 | AlignmentProcessor bin.\n") |
32 | | - quit() |
| 34 | + proceed = False |
33 | 35 | if axt == False: |
34 | 36 | print("\n\tError: Files must be converted into axt format for use\ |
35 | 37 | with KaKs_Clculator.\n") |
36 | | - quit() |
| 38 | + proceed = False |
37 | 39 | if codeml == True: |
| 40 | + control = glob(outdir + "*.ctl") |
| 41 | + if len(control) == 0: |
| 42 | + print("\n\tPlease supply a control file for CodeML.\n") |
| 43 | + proceed = False |
| 44 | + elif len(control) > 1: |
| 45 | + print("\n\tPlease supply only one CodeML control file.\n") |
| 46 | + proceed = False |
38 | 47 | indir = os.path.isfile("paml/bin/codeml") |
39 | 48 | phyml = os.path.isfile("PhyML/PhyML") |
40 | 49 | if indir == False: |
41 | 50 | print("\n\tError: Please install PAML in the\ |
42 | 51 | AlignmentProcessor folder.\n") |
43 | | - quit() |
| 52 | + proceed = False |
44 | 53 | if phyml == False: |
45 | 54 | print("\n\tError: Please install and rename PhyML for use\ |
46 | 55 | with CodeML.\n") |
47 | | - quit() |
| 56 | + proceed = False |
48 | 57 | if phylip == False: |
49 | 58 | print("\n\tError: Files must be converted into phylip format for use\ |
50 | 59 | with CodeML.\n") |
51 | | - control = glob(outdir + "*.ctl") |
52 | | - if len(control) == 0: |
53 | | - print("\n\tPlease supply a control file for CodeML.\n") |
54 | | - elif len(control) > 1: |
55 | | - print("\n\tPlease supply only one CodeML control file.\n") |
56 | | - quit() |
| 60 | + proceed = False |
| 61 | + return proceed |
57 | 62 |
|
58 | 63 |
|
59 | 64 | def makeDir(path, outdir, axt, phylip, kaks, codeml): |
@@ -202,34 +207,35 @@ def main(): |
202 | 207 | if axt == True and phylip == True: |
203 | 208 | print("\n\tError: Please specify only one file type.\n") |
204 | 209 | quit() |
205 | | - checkInput(axt, kaks, phylip, codeml, outdir) |
206 | | - # Set checkpoint variables to False: |
207 | | - sf = False |
208 | | - ff = False |
209 | | - cf = False |
210 | | - done = False |
211 | | - # Save working directory to variable and call other scripts: |
212 | | - path = os.getcwd() |
213 | | - path = path + "/" |
214 | | - makeDir(path, outdir, axt, phylip, kaks, codeml) |
215 | | - sf = splitFasta(infile, outdir) |
216 | | - if sf == True: |
217 | | - ff = filterFasta(outdir, ref, percent, retainstops) |
218 | | - if ff == True: |
219 | | - cf = convert(outdir, axt, phylip) |
220 | | - if cf == True: |
221 | | - # Run KaKs_Calculator: |
222 | | - if kaks == True: |
223 | | - done = calculateKaKs(outdir, method) |
224 | | - # Run codeml |
225 | | - elif codeml == True: |
226 | | - done = runcodeml(cpu, outdir, forward, cleanup) |
227 | | - else: |
228 | | - # Exit if neither program was called |
229 | | - done = True |
230 | | - # Print run time |
231 | | - if done == True: |
232 | | - print("\n\tTotal runtime: ", datetime.now() - starttime, "\n") |
| 210 | + proceed = checkInput(axt, kaks, phylip, codeml, outdir) |
| 211 | + if proceed == True: |
| 212 | + # Set checkpoint variables to False: |
| 213 | + sf = False |
| 214 | + ff = False |
| 215 | + cf = False |
| 216 | + done = False |
| 217 | + # Save working directory to variable and call other scripts: |
| 218 | + path = os.getcwd() |
| 219 | + path = path + "/" |
| 220 | + makeDir(path, outdir, axt, phylip, kaks, codeml) |
| 221 | + sf = splitFasta(infile, outdir) |
| 222 | + if sf == True: |
| 223 | + ff = filterFasta(outdir, ref, percent, retainstops) |
| 224 | + if ff == True: |
| 225 | + cf = convert(outdir, axt, phylip) |
| 226 | + if cf == True: |
| 227 | + # Run KaKs_Calculator: |
| 228 | + if kaks == True: |
| 229 | + done = calculateKaKs(outdir, method) |
| 230 | + # Run codeml |
| 231 | + elif codeml == True: |
| 232 | + done = runcodeml(cpu, outdir, forward, cleanup) |
| 233 | + else: |
| 234 | + # Exit if neither program was called |
| 235 | + done = True |
| 236 | + # Print run time |
| 237 | + if done == True: |
| 238 | + print("\n\tTotal runtime: ", datetime.now() - starttime, "\n") |
233 | 239 |
|
234 | 240 | if __name__ == "__main__": |
235 | 241 | main() |
0 commit comments