-
Notifications
You must be signed in to change notification settings - Fork 26
/
run_pasta_gui.py
1082 lines (949 loc) · 68.3 KB
/
run_pasta_gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""Main script for PASTA GUI on Windows/Mac/Linux
"""
# This file is part of PASTA which is forked from SATe
# PASTA, like SATe is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Jiaye Yu and Mark Holder, University of Kansas
import os
import platform
import subprocess
import tempfile
import sys
import time
import wx
import string
from pasta import PROGRAM_AUTHOR
from pasta import PROGRAM_INSTITUTE
from pasta import PROGRAM_DESCRIPTION
from pasta import PROGRAM_LICENSE
from pasta import PROGRAM_NAME
from pasta import PROGRAM_VERSION
from pasta import PROGRAM_WEBSITE
from pasta import PROGRAM_YEAR
from pasta import GLOBAL_DEBUG
from pasta import DEFAULT_MAX_MB
try:
from configparser import RawConfigParser
except:
from ConfigParser import RawConfigParser
from pasta import pasta_is_frozen
from pasta import pasta_home_dir
from pasta.configure import get_invoke_run_pasta_command
from pasta.tools import AlignerClasses
from pasta.tools import MergerClasses
from pasta.tools import TreeEstimatorClasses
from pasta.tools import get_aligner_classes, get_merger_classes, get_tree_estimator_classes
from pasta import filemgr
from pasta.usersettingclasses import get_list_of_seq_filepaths_from_dir
from pasta.alignment import summary_stats_from_parse
from pasta.mainpasta import get_auto_defaults_from_summary_stats
WELCOME_MESSAGE = "%s %s, %s\n\n"% (PROGRAM_NAME, PROGRAM_VERSION, PROGRAM_YEAR)
GRID_VGAP = 8
GRID_HGAP = 8
PARSING_FILES_IN_GUI = True
MAX_NUM_CPU = 16
PASTA_GUI_ONLY_PRINTS_CONFIG = os.environ.get('PASTA_GUI_ONLY_PRINTS_CONFIG') == '1'
def is_valid_int_str(s, min_v, max_v):
try:
i = int(s)
except:
return False
si = str(i)
if si != s:
return False
if min_v is not None and i < min_v:
return False
if max_v is not None and i > max_v:
return False
return True
class RangedIntValidator(wx.PyValidator):
def __init__(self, min_v, max_v):
wx.PyValidator.__init__(self)
self.min_v = min_v
self.max_v = max_v
self.Bind(wx.EVT_CHAR, self.OnChar)
def Clone(self):
return RangedIntValidator(self.min_v, self.max_v)
def is_valid_str(self, s):
return is_valid_int_str(s, self.min_v, self.max_v)
def Validate(self, win):
v = win.GetValue()
return self.is_valid_str(v)
def OnChar(self, event):
key = event.GetKeyCode()
textCtrl = self.GetWindow()
if key == wx.WXK_BACK or key == wx.WXK_DELETE:
textCtrl.SetBackgroundColour("white")
event.Skip()
return
if key < wx.WXK_SPACE or key > 255:
textCtrl.SetBackgroundColour("white")
event.Skip()
return
if chr(key) in string.digits:
textCtrl.SetBackgroundColour("white")
event.Skip()
return
if not wx.Validator_IsSilent():
wx.Bell()
# Returning without calling even.Skip eats the event before it
# gets to the text control
return
def TransferToWindow(self):
return True
def TransferFromWindow(self):
return True
class PastaFrame(wx.Frame):
def __init__(self, size):
wx.Frame.__init__(self, None, -1, "PASTA - Practical Alignment using SATe and TraAnsitivity", size=(640,480), style=wx.DEFAULT_FRAME_STYLE)
self.SetBackgroundColour(wx.LIGHT_GREY)
self.statusbar = self.CreateStatusBar()
self.statusbar.SetStatusText("PASTA Ready!")
if wx.Platform == "__WXMSW__" or wx.Platform == "__WXMAC__":
import base64
import io
icon = wx.EmptyIcon()
icon.CopyFromBitmap(wx.BitmapFromImage(wx.ImageFromStream(io.BytesIO(base64.b64decode(ICO_STR)))))
self.SetIcon(icon)
self.ctrls = []
sizer_all = wx.BoxSizer(wx.VERTICAL)
self.sizer_tool_settings = self._create_tools_sizer()
self.sizer_data = self._create_data_sizer()
self.sizer_pasta_settings = self._create_pasta_settings_sizer()
self.sizer_job_settings = self._create_job_settings_sizer()
self.sizer_workflow_settings = self._create_workflow_settings_sizer()
sizer1 = wx.BoxSizer(wx.VERTICAL)
sizer1.Add(self.sizer_tool_settings, 0, wx.EXPAND|wx.BOTTOM|wx.RIGHT, 5)
sizer1.Add(self.sizer_data, 0, wx.EXPAND|wx.TOP|wx.RIGHT, 5)
sizer1.Add(self.sizer_workflow_settings, 0, wx.EXPAND|wx.TOP|wx.RIGHT, 5)
self.sizer_settings = wx.BoxSizer(wx.HORIZONTAL)
self.sizer_settings.Add(sizer1, 0, wx.EXPAND|wx.ALL, 0)
sizer2 = wx.BoxSizer(wx.VERTICAL)
sizer2.Add(self.sizer_job_settings, 0, wx.EXPAND|wx.ALL, 0)
sizer2.Add(self.sizer_pasta_settings, 0, wx.EXPAND|wx.ALL, 0)
self.sizer_settings.Add(sizer2, 0, wx.EXPAND|wx.ALL, 0)
sizer_all.Add(self.sizer_settings, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 10)
self.button = wx.Button(self, label="Start")
self.log = wx.TextCtrl(self, -1, "", size=(200,120),style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH2)
self.log.AppendText(WELCOME_MESSAGE)
self.log.AppendText("Running Log (%s %s)\n\n" % (time.strftime("%Y-%m-%d %H:%M:%S"), time.tzname[0]))
sizer_all.Add(self.button, 0, wx.BOTTOM|wx.ALIGN_CENTER, 10)
sizer_all.Add(self.log, 4, wx.EXPAND)
self.SetAutoLayout(True)
self.Layout()
self.SetSizerAndFit(sizer_all)
self._create_menu()
self.process = None
self.process_cfg_file = None
self.Bind(wx.EVT_IDLE, self.OnIdle)
self.Bind(wx.EVT_END_PROCESS, self.OnProcessEnded)
self.Bind(wx.EVT_BUTTON, self.OnButton, self.button)
self.set_char_model() # this fixes the model based on the current default tree estimator
def _create_job_settings_sizer(self):
staticboxsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Job Settings"), wx.VERTICAL)
sizer = wx.GridBagSizer(GRID_VGAP, GRID_HGAP)
cr = 0
sizer.Add(wx.StaticText(self, -1, "Job Name"),(cr,0), flag=wx.ALIGN_LEFT )
self.txt_jobname = wx.TextCtrl(self,-1,"pastajob")
sizer.Add(self.txt_jobname, (cr,1), flag=wx.EXPAND)
cr += 1
self.outputdir_btn = wx.Button(self, label="Output Dir." )
sizer.Add(self.outputdir_btn,(cr,0), flag=wx.ALIGN_LEFT )
self.txt_outputdir = wx.TextCtrl(self, -1, "", size=(250,9))
sizer.Add(self.txt_outputdir, (cr,1), flag=wx.EXPAND)
cr += 1
sizer.Add(wx.StaticText(self, -1, "CPU(s) Available"), (cr,0), flag=wx.ALIGN_LEFT )
self.cb_ncpu = wx.ComboBox(self, -1, "1", choices=list(map(str, list(range(1, MAX_NUM_CPU + 1)))), style=wx.CB_READONLY)
sizer.Add(self.cb_ncpu, (cr,1), flag=wx.EXPAND)
cr += 1
sizer.Add(wx.StaticText(self, -1, "Max. Memory (MB)"), (cr,0), flag=wx.ALIGN_LEFT )
self.txt_maxmb = wx.TextCtrl(self, -1, str(DEFAULT_MAX_MB))
sizer.Add(self.txt_maxmb, (cr,1), flag=wx.EXPAND)
staticboxsizer.Add(sizer, 0, wx.CENTER, 0)
self.Bind(wx.EVT_BUTTON, self.OnChooseOutputDir, self.outputdir_btn)
return staticboxsizer
def validate_max_mb(self, value):
try:
mb = int(value)
if mb <= 0:
raise ValueError
return True
except ValueError:
wx.MessageBox("Invalid value for Maximum MB: '" + value + "': require positive integer value.",
"Invalid Value for Maximum MB",
wx.OK|wx.ICON_EXCLAMATION)
return False
def OnChooseOutputDir(self, event):
dialog = wx.DirDialog(None, "Choose directory for output", style=wx.FD_OPEN)
dialog.ShowModal()
self.txt_outputdir.SetValue( dialog.GetPath() )
def _set_custom_pasta_settings(self, event):
#self.cb_sate_presets.SetValue("(custom)")
pass
def _create_tools_sizer(self):
from pasta.configure import get_configuration
cfg = get_configuration()
staticboxsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "External Tools"), wx.VERTICAL)
sizer = wx.FlexGridSizer(0, 2, GRID_VGAP, GRID_HGAP)
items = ["Aligner", "Merger", "TreeEstimator"]
tool_list_list = [get_aligner_classes(), get_merger_classes(), get_tree_estimator_classes()]
self.raxml_dna_models = ["GTRCAT", "GTRGAMMA", "GTRGAMMAI"]
self.fasttree_dna_models = ["GTR+G20", "GTR+CAT", "JC+G20", "JC+CAT"]
prot_matrix = ["DAYHOFF", "DCMUT", "JTT", "MTREV", "WAG", "RTREV", "CPREV", "VT", "BLOSUM62", "MTMAM", "LG"]
prot_type = ["PROTCAT", "PROTCATI", "PROTGAMMA", "PROTGAMMAI"]
self.raxml_prot_models = [j+i for i in prot_matrix for j in prot_type]
self.raxml_prot_models.extend([j+i+"F" for i in prot_matrix for j in prot_type])
self.fasttree_prot_models = ["JTT+G20", "JTT+CAT", "WAG+G20", "WAG+CAT"]
if GLOBAL_DEBUG:
defaults = {"Aligner":"PADALIGNER", "Merger":"PADALIGNER", "TreeEstimator":"RANDTREE"}
else:
defaults = {"Aligner":"MAFFT", "Merger":"MUSCLE", "TreeEstimator":"FASTTREE"}
self.cb_tools = {}
for item_idx, item in enumerate(items):
text = wx.StaticText(self, -1, "Tree Estimator") if item == "TreeEstimator" else wx.StaticText(self, -1, item)
sizer.Add(text, 0, wx.LEFT)
tool_list = tool_list_list[item_idx]
active_tool_name_list = []
for tool in tool_list:
try:
tool_attr_name = tool.section_name.split()[0].lower()
tool_path = getattr(cfg, tool_attr_name).path
if os.path.exists(tool_path):
active_tool_name_list.append(tool_attr_name.upper())
else:
print("WARNING: tool %s not found at %s" %(tool,tool_path))
except :
raise
combobox = wx.ComboBox(self, -1, defaults[item], (-1,-1), (-1,-1), active_tool_name_list, wx.CB_READONLY)
self.cb_tools[item.lower()] = combobox
self.ctrls.append(self.cb_tools[item.lower()])
sizer.Add(combobox, 0, wx.EXPAND)
self.Bind(wx.EVT_COMBOBOX, self.OnTreeEstimatorChange, self.cb_tools["treeestimator"])
combobox = wx.ComboBox(self, -1, "GTRCAT", (-1,-1), (-1,-1), self.raxml_dna_models, wx.CB_READONLY)
self.cb_tools["model"] = combobox
self.ctrls.append(self.cb_tools["model"])
sizer.Add(wx.StaticText(self, -1, "Model"), wx.LEFT)
sizer.Add(combobox, 0, wx.EXPAND)
staticboxsizer.Add(sizer, 0, wx.CENTER, 0)
return staticboxsizer
def _create_data_sizer(self):
staticboxsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Sequences and Tree"), wx.VERTICAL)
sizer = wx.FlexGridSizer(0, 2, GRID_VGAP, GRID_HGAP)
self.datatype = wx.ComboBox(self, -1, "DNA", (-1, -1), (-1, -1), ["DNA", "RNA", "Protein"], wx.CB_READONLY)
self.seq_btn = wx.Button(self, label="Sequence file ..." )
self.tree_btn = wx.Button(self, label="Tree file (optional) ..." )
self.txt_seqfn = wx.TextCtrl(self,-1)
self.txt_treefn = wx.TextCtrl(self,-1)
self.cb_multilocus = wx.CheckBox(self, -1, "Multi-Locus Data")
self.cb_multilocus.Disable()
self.checkbox_aligned = wx.CheckBox(self, -1, "Use for inital tree")
self.checkbox_aligned.SetValue(False)
self._could_be_aligned = False
self.checkbox_aligned.Disable()
sizer.AddMany([ (self.seq_btn, 0, wx.LEFT|wx.EXPAND),
(self.txt_seqfn, 0),
(wx.StaticText(self, -1, ""), 0, wx.EXPAND),
(self.cb_multilocus, 1, wx.EXPAND),
(wx.StaticText(self, -1, "Data Type"), 0, wx.ALIGN_RIGHT),
(self.datatype, 0),
(wx.StaticText(self, -1, "Initial Alignment"), 0, wx.ALIGN_RIGHT),
(self.checkbox_aligned, 0),
(self.tree_btn, 0, wx.LEFT|wx.EXPAND),
(self.txt_treefn, 0),
])
self.ctrls.extend([self.seq_btn,
self.txt_seqfn,
self.tree_btn,
self.txt_treefn,
self.datatype])
staticboxsizer.Add(sizer, 0, wx.CENTER, 0)
self.Bind(wx.EVT_BUTTON, self.OnChooseSeq, self.seq_btn)
self.Bind(wx.EVT_BUTTON, self.OnChooseTree, self.tree_btn)
self.Bind(wx.EVT_COMBOBOX, self.OnDataType, self.datatype)
self.Bind(wx.EVT_CHECKBOX, self.OnMultiLocus, self.cb_multilocus)
return staticboxsizer
def _create_workflow_settings_sizer(self):
"""
returns a wx.StaticBoxSizer with the widgets that control pre and post
processing of PASTA output.
"""
staticboxsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Workflow Settings"), wx.VERTICAL)
sizer = wx.GridBagSizer(GRID_VGAP, GRID_HGAP)
self.two_phase = wx.CheckBox(self, -1, "Two-Phase (not PASTA)")
self.two_phase.Value = False
self.raxml_after = wx.CheckBox(self, -1, "Extra RAxML Search")
self.raxml_after.Value = False
#self.trusted_data = wx.CheckBox(self, -1, "Trusted Data")
#self.trusted_data.Value = True
self.ctrls.extend([self.two_phase,
])
cr = 0
sizer.Add(wx.StaticText(self, -1, "Algorithm"), (cr,0), flag=wx.ALIGN_LEFT )
sizer.Add(self.two_phase, (cr,1), flag=wx.EXPAND)
cr += 1
sizer.Add(wx.StaticText(self, -1, "Post-Processing"), (cr,0), flag=wx.ALIGN_LEFT )
sizer.Add(self.raxml_after, (cr,1), flag=wx.EXPAND)
#cr += 1
#sizer.Add(wx.StaticText(self, -1, "Input Validation"), (cr,0), flag=wx.ALIGN_LEFT )
#sizer.Add(self.trusted_data, (cr,1), flag=wx.EXPAND)
self.Bind(wx.EVT_CHECKBOX, self.OnTwoPhase, self.two_phase)
staticboxsizer.Add(sizer, 0, wx.ALL, 0)
return staticboxsizer
def _create_pasta_settings_sizer(self):
staticboxsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "PASTA Settings"), wx.VERTICAL)
sizer = wx.GridBagSizer(GRID_VGAP, GRID_HGAP)
# preset_choices = ["SATe-II-fast", "SATe-II-ML", "SATe-II-simple", "(Custom)",]
# self.cb_sate_presets = wx.ComboBox(self,
# -1,
# "SATe-II-ML",
# choices=preset_choices,
# style=wx.CB_READONLY)
tree_and_alignment_choices = ["Final", "Best"]
self.cb_tree_and_alignment = wx.ComboBox(self,
-1,
tree_and_alignment_choices[0],
choices=tree_and_alignment_choices,
style=wx.CB_READONLY)
timelimit_list = list(map(str, [i/100.0 for i in range(1,10)] + [i/10.0 for i in range(1,10)] + list(range(1,73))))
iterlimit_list = list(map(str, [1, 5, 10, 20, 50, 100, 200, 500, 1000]))
self.rb_maxsub1 = wx.RadioButton(self, -1, "Percentage", name="frac", style=wx.RB_GROUP)
self.rb_maxsub2 = wx.RadioButton(self, -1, "Size", name="size")
self.cb_maxsub1 = wx.ComboBox(self, -1, "50", choices=list(map(str, list(range(1,51)))), style=wx.CB_READONLY)
self.cb_maxsub2 = wx.ComboBox(self, -1, "200", choices=list(map(str, list(range(1,201)))), style=wx.CB_READONLY)
self.ctrls.extend([self.rb_maxsub1,
self.cb_maxsub1,
self.rb_maxsub2,
self.cb_maxsub2
])
self.checkbox_stop_time = wx.CheckBox(self, -1, "Time Limit (hr)")
self.checkbox_stop_iter = wx.CheckBox(self, -1, "Iteration Limit")
self.cb_stop1 = wx.ComboBox(self, -1, "24", choices=timelimit_list, style=wx.CB_READONLY)
self._iter_limits = [1, None]
riv = RangedIntValidator(self._iter_limits[0], self._iter_limits[1])
self.text_stop2 = wx.TextCtrl(self, -1, "8", validator=riv)
# self.text_stop2.Bind(wx.EVT_KILL_FOCUS, lambda event : self.validate_iter_limit_text() and event.Skip())
# self.blindmode = wx.CheckBox(self, -1, "Blind Mode Enabled")
# self.blindmode.Value = True
self.ctrls.extend([self.checkbox_stop_time,
self.cb_stop1,
self.checkbox_stop_iter,
self.text_stop2,
])
strategy_list = ["MinCluster","Centroid", "Longest"]
self.cb_decomp = wx.ComboBox(self, -1, "MinCluster", choices=strategy_list, style=wx.CB_READONLY)
self.ctrls.append(self.cb_decomp)
self.pasta_settings_ctrl_list = []
cr = 0
# sizer.Add(wx.StaticText(self, -1, "Quick Set"), (cr, 0), flag=wx.ALIGN_LEFT )
# sizer.Add(self.cb_sate_presets, (cr, 1), flag=wx.EXPAND)
# self.pasta_settings_ctrl_list.append(self.cb_sate_presets)
cr += 1
sizer.Add(wx.StaticText(self, -1, "Max. Subproblem"), (cr,0), flag=wx.ALIGN_LEFT )
sizer.Add(self.rb_maxsub1, (cr,1), flag=wx.ALIGN_LEFT)
sizer.Add(self.cb_maxsub1, (cr,2), flag=wx.EXPAND)
self.pasta_settings_ctrl_list.extend([self.rb_maxsub1, self.cb_maxsub1])
cr += 1
sizer.Add(self.rb_maxsub2, (cr,1), flag=wx.ALIGN_LEFT)
sizer.Add(self.cb_maxsub2, (cr,2), flag=wx.EXPAND)
self.pasta_settings_ctrl_list.extend([self.rb_maxsub2, self.cb_maxsub2])
cr += 1
sizer.Add(wx.StaticText(self, -1, "Decomposition"), (cr,0), flag=wx.ALIGN_LEFT )
sizer.Add(self.cb_decomp, (cr,1), flag=wx.EXPAND)
self.pasta_settings_ctrl_list.extend([self.cb_decomp])
# cr += 1
# sizer.Add(wx.StaticText(self, -1, "Apply Stop Rule"), (cr,0), flag=wx.ALIGN_LEFT )
# sizer.Add(self.cb_apply_stop_rule, (cr,1), flag=wx.EXPAND)
# self.pasta_settings_ctrl_list.extend([self.cb_apply_stop_rule])
# cr += 1
# sizer.Add(wx.StaticText(self, -1, "Stopping Rule"), (cr,0), flag=wx.ALIGN_LEFT )
# sizer.Add(self.blindmode, (cr,1), flag=wx.EXPAND)
# self.pasta_settings_ctrl_list.extend([self.blindmode])
cr += 1
sizer.Add(self.checkbox_stop_time, (cr,1), flag=wx.ALIGN_LEFT)
sizer.Add(self.cb_stop1, (cr,2), flag=wx.EXPAND)
self.pasta_settings_ctrl_list.extend([self.checkbox_stop_time, self.cb_stop1])
cr += 1
sizer.Add(self.checkbox_stop_iter, (cr,1), flag=wx.ALIGN_LEFT)
sizer.Add(self.text_stop2, (cr,2), flag=wx.EXPAND)
self.pasta_settings_ctrl_list.extend([self.checkbox_stop_iter, self.text_stop2])
cr += 1
sizer.Add(wx.StaticText(self, -1, "Return"), (cr, 0), flag=wx.ALIGN_LEFT )
sizer.Add(self.cb_tree_and_alignment, (cr, 1), flag=wx.EXPAND)
self.pasta_settings_ctrl_list.extend([self.cb_tree_and_alignment])
self.cb_maxsub1.Disable()
self.cb_maxsub2.Disable()
self.rb_maxsub1.Value = True
self.cb_maxsub1.Enable()
self.checkbox_stop_time.Value = False
self.cb_stop1.Disable()
self.text_stop2.Enable()
self.checkbox_stop_iter.Value = True
self.text_stop2.Value = "100"
#self.Bind(wx.EVT_COMBOBOX, self.OnSatePresets, self.cb_sate_presets)
#self.OnSatePresets(self.cb_sate_presets)
#self.Bind(wx.EVT_CHECKBOX, self.OnBlindMode, self.blindmode)
self.Bind(wx.EVT_RADIOBUTTON, self.OnMaxSubproblem, self.rb_maxsub1)
self.Bind(wx.EVT_RADIOBUTTON, self.OnMaxSubproblem, self.rb_maxsub2)
self.Bind(wx.EVT_CHECKBOX, self.OnTimeRuleCheckbox, self.checkbox_stop_time)
self.Bind(wx.EVT_CHECKBOX, self.OnIterRuleCheckbox, self.checkbox_stop_iter)
self.Bind(wx.EVT_COMBOBOX, self._set_custom_pasta_settings, self.cb_decomp)
#self.Bind(wx.EVT_COMBOBOX, self._set_custom_pasta_settings, self.cb_apply_stop_rule)
self.Bind(wx.EVT_COMBOBOX, self._set_custom_pasta_settings, self.cb_stop1)
self.Bind(wx.EVT_COMBOBOX, self._set_custom_pasta_settings, self.text_stop2)
self.Bind(wx.EVT_COMBOBOX, self._set_custom_pasta_settings, self.cb_tree_and_alignment)
#cr += 1
#presets = wx.ComboBox(self, -1, "1", choices=map(str, range(1,9)), style=wx.CB_READONLY)
#sizer.Add(wx.StaticText(self, -1, "Preset Configuration"), (cr,0), flag=wx.ALIGN_LEFT )
#sizer.Add(presets, (cr,1), flag=wx.EXPAND)
staticboxsizer.Add(sizer, 0, wx.ALL, 0)
return staticboxsizer
def validate_iter_limit_text(self):
field=self.text_stop2
t = field.GetValue()
if is_valid_int_str(t, self._iter_limits[0], self._iter_limits[1]):
return True
field.SetBackgroundColour("red")
#wx.MessageBox(message='"Iteration Limit" must contain a positive integer',
# caption='Input Error', style=wx.OK|wx.ICON_ERROR)
field.SetFocus()
field.Refresh()
return False
def _create_menu(self):
self.menuBar = wx.MenuBar()
self.menuFile = wx.Menu()
self.menuHelp = wx.Menu()
self.menuFileSaveLog = self.menuFile.Append(-1, "&Save Log...\tCtrl+S")
self.menuFileExit = self.menuFile.Append(wx.ID_EXIT, "&Quit PASTA\tCtrl+Q")
self.menuHelpHelp = self.menuHelp.Append( -1, "&Help")
self.menuHelpAbout = self.menuHelp.Append(wx.ID_ABOUT, "&About PASTA")
self.menuBar.Append(self.menuFile, "&File")
self.menuBar.Append(self.menuHelp, "&Help")
self.SetMenuBar(self.menuBar)
self.Bind(wx.EVT_MENU, self.OnSaveLog, self.menuFileSaveLog)
self.Bind(wx.EVT_MENU, self.OnExit, self.menuFileExit)
self.Bind(wx.EVT_MENU, self.OnHelp, self.menuHelpHelp)
self.Bind(wx.EVT_MENU, self.OnAbout, self.menuHelpAbout)
self.Bind(wx.EVT_CLOSE, self.OnExit)
def OnTreeEstimatorChange(self, event):
self.set_char_model()
def OnDataType(self, event):
self.set_char_model()
def set_char_model(self):
if self.datatype.Value == "DNA" or self.datatype.Value == "RNA":
self.cb_tools["model"].Clear()
if self.cb_tools["treeestimator"].Value.lower() == "raxml":
self.raxml_after.Value = False
for model in self.raxml_dna_models:
self.cb_tools["model"].Append(model)
self.cb_tools["model"].SetStringSelection("GTRCAT")
elif self.cb_tools["treeestimator"].Value.lower() == "fasttree":
for model in self.fasttree_dna_models:
self.cb_tools["model"].Append(model)
self.cb_tools["model"].SetStringSelection("GTR+G20")
elif self.datatype.Value == "Protein":
self.cb_tools["model"].Clear()
if self.cb_tools["treeestimator"].Value.lower() == "raxml":
self.raxml_after.Value = False
for model in self.raxml_prot_models:
self.cb_tools["model"].Append(model)
self.cb_tools["model"].SetStringSelection("PROTCATWAGF")
elif self.cb_tools["treeestimator"].Value.lower() == "fasttree":
for model in self.fasttree_prot_models:
self.cb_tools["model"].Append(model)
self.cb_tools["model"].SetStringSelection("JTT+G20")
def OnSaveLog(self, event):
dialog = wx.FileDialog(None, "Save Log", defaultFile=self.txt_jobname.Value, wildcard = "Log files (*.log)|*.log", style=wx.FD_OVERWRITE_PROMPT|wx.FD_SAVE)
dialog.ShowModal()
fn = dialog.GetPath()
if len(fn) > 4:
if not fn[-4:] == ".log":
fn += ".log"
else:
fn += ".log"
fc = open(fn, "w")
fc.write(self.log.GetValue())
fc.close()
def OnMaxSubproblem(self, event):
self._set_custom_pasta_settings(event)
radio_selected = event.GetEventObject()
if radio_selected.GetName() == "frac":
self.cb_maxsub1.Enable()
self.cb_maxsub2.Disable()
elif radio_selected.GetName() == "size":
self.cb_maxsub2.Enable()
self.cb_maxsub1.Disable()
def OnTwoPhase(self, event):
"""
Called every time the 'Two-Phase' checkbox is clicked. The main action
that needs to occur is the Disabling/Enabling of the PASTA settings
controls
"""
if self.two_phase.Value:
for c in self.pasta_settings_ctrl_list:
c.Disable()
self.cb_tools["merger"].Disable()
self.tree_btn.Disable()
self.txt_treefn.Disable()
self.raxml_after.Disable()
else:
fragile_list = [self.cb_maxsub1, self.cb_maxsub2, self.cb_stop1, self.text_stop2]
for c in self.pasta_settings_ctrl_list:
if c not in fragile_list:
c.Enable()
if self.rb_maxsub1.Value:
self.cb_maxsub1.Enable()
else:
self.cb_maxsub2.Enable()
if self.checkbox_stop_time.Value:
self.cb_stop1.Enable()
else:
self.text_stop2.Enable()
self.cb_tools["merger"].Enable()
self.tree_btn.Enable()
self.txt_treefn.Enable()
self.raxml_after.Enable()
def OnTimeRuleCheckbox(self, event):
self._set_custom_pasta_settings(event)
if self.checkbox_stop_time.Value:
self.cb_stop1.Enable()
else:
self.cb_stop1.Disable()
def OnIterRuleCheckbox(self, event):
self._set_custom_pasta_settings(event)
if self.checkbox_stop_iter.Value:
self.text_stop2.Enable()
else:
self.text_stop2.Disable()
def OnExit(self, event):
if self.process is not None:
wx.Process.Kill(self.pid, wx.SIGKILL)
self._remove_config_file()
self.Destroy()
def OnHelp(self, event):
import wx.html
wx.FileSystem.AddHandler(wx.ZipFSHandler())
def _addBook(filename):
if not self.help.AddBook(filename, True):
wx.MessageBox("Unable to open: " + filename, "Error", wx.OK|wx.ICON_EXCLAMATION)
self.help = wx.html.HtmlHelpController(style = wx.html.HF_DEFAULT_STYLE^wx.html.HF_BOOKMARKS^wx.html.HF_INDEX)
_addBook("help.zip")
self.help.DisplayContents()
def OnAbout(self, event):
from wx.lib.wordwrap import wordwrap
info = wx.AboutDialogInfo()
info.SetName(PROGRAM_NAME)
info.SetVersion(PROGRAM_VERSION)
info.SetCopyright("Copyright (C) %s" % PROGRAM_YEAR)
info.SetWebSite((PROGRAM_WEBSITE, "%s Homepage" % PROGRAM_NAME))
info.SetLicense(PROGRAM_LICENSE)
info.SetDescription(PROGRAM_DESCRIPTION)
[info.AddDeveloper(i) for i in PROGRAM_AUTHOR]
wx.AboutBox(info)
def _show_error_dialog(self, error_msg, caption):
"""
Puts up a modal dialog with a `error_msg` and `caption`
destroys the dialog after the user clicks `OK`
"""
error_msg_dlg = wx.MessageDialog(parent=self,
message=error_msg,
caption=caption,
style=wx.OK|wx.ICON_ERROR)
error_msg_dlg.ShowModal()
error_msg_dlg.Destroy()
def OnChooseSeq(self, event):
filepath = None
parse_as_multilocus = self.cb_multilocus.Value
if not parse_as_multilocus:
dialog = wx.FileDialog(None, "Choose sequences...", wildcard = "FASTA files (*.fasta)|*.fasta|FASTA files (*.fas)|*.fas|FASTA files (*)|*", style=wx.FD_OPEN)
dialog.ShowModal()
self.txt_seqfn.SetValue( dialog.GetPath() )
filepath = self._encode_arg(self.txt_seqfn.GetValue())
if filepath and not self.txt_outputdir.GetValue():
self.txt_outputdir.SetValue(os.path.dirname(os.path.abspath(filepath)))
else:
dialog = wx.DirDialog(None, "Choose directory for multiple sequence files", style=wx.FD_OPEN)
dialog.ShowModal()
self.txt_seqfn.SetValue( dialog.GetPath() )
filepath = self._encode_arg(self.txt_seqfn.GetValue())
if PARSING_FILES_IN_GUI and filepath:
confirm_parse_dlg = wx.MessageDialog(parent=self,
message="Do you want PASTA to read the data now? (this causes PASTA to customize some of the settings for your data).",
caption="Read input data now?",
style=wx.OK|wx.CANCEL|wx.ICON_QUESTION)
result = confirm_parse_dlg.ShowModal()
confirm_parse_dlg.Destroy()
if result == wx.ID_OK:
progress_dialog = wx.ProgressDialog(title="Reading input data",
message="Parsing data files ",
maximum=100,
parent=self,
style=wx.PD_AUTO_HIDE|wx.PD_APP_MODAL)
progress_dialog.Update(1, "Beginning Parse")
error_msg = None
try:
if parse_as_multilocus:
fn_list = get_list_of_seq_filepaths_from_dir(filepath)
else:
fn_list = [filepath]
# if self.datatype.Value == "Protein":
# datatype_list = ["PROTEIN"]
# else:
datatype_list = ["DNA", "RNA", "PROTEIN"]
careful_parse = False
summary_stats = summary_stats_from_parse(fn_list,
datatype_list,
None,
careful_parse=careful_parse)
progress_dialog.Update(100, "Done")
except Exception as x:
try:
error_msg = "Problem reading the data:\n" + str(x.message)
except:
error_msg = "Unknown error encountered while reading the data."
except:
error_msg = "Unknown error encountered while reading the data."
if error_msg:
self._show_error_dialog(error_msg, caption="Input parsing error")
filepath = None
self._could_be_aligned = False
self.refresh_aligned_checkbox()
else:
read_type = summary_stats[0]
if read_type == "PROTEIN":
self.datatype.SetValue("Protein")
else:
self.datatype.SetValue(read_type)
# Set defaults from "auto_defaults"
auto_opts = get_auto_defaults_from_summary_stats(summary_stats[0], summary_stats[1], summary_stats[2])
self._could_be_aligned = summary_stats[3]
self.refresh_aligned_checkbox()
auto_pasta_opts = auto_opts["sate"]
te_str = auto_pasta_opts["tree_estimator"].upper()
self.cb_tools["treeestimator"].SetStringSelection(te_str)
self.set_char_model()
if te_str == "FASTTREE":
te_opts = auto_opts['fasttree']
self.cb_tools["model"].SetStringSelection(te_opts["GUI_model"])
self.cb_tools["merger"].SetStringSelection(auto_pasta_opts["merger"].upper())
self.cb_tools["aligner"].SetStringSelection(auto_pasta_opts["aligner"].upper())
self.cb_ncpu.SetStringSelection(str(min(MAX_NUM_CPU, auto_pasta_opts["num_cpus"])))
# Set max decomposition based on data set size (always move to actual # here)
self.rb_maxsub1.Value = False
self.cb_maxsub1.Disable()
self.rb_maxsub2.Value = True
self.cb_maxsub2.SetStringSelection(str(max(1, auto_pasta_opts["max_subproblem_size"])))
self.cb_maxsub2.Enable()
bs = auto_pasta_opts["break_strategy"]
bs = {"mincluster":"MinCluster","centroid":"Centroid", "longest":"Longest"}[bs]
#bs = bs[0].upper() + bs[1:].lower()
self.cb_decomp.SetValue(bs)
self.cb_stop1.Disable()
self.checkbox_stop_iter.Value = True
self.cb_maxsub2.SetStringSelection(str(max(1, auto_pasta_opts["max_subproblem_size"])))
self.cb_maxsub2.Enable()
if auto_pasta_opts['move_to_blind_on_worse_score']:
#self.blindmode.Value = True
t_l = auto_pasta_opts['after_blind_time_without_imp_limit']
else:
#self.blindmode.Value = False
t_l = auto_pasta_opts['time_limit']
if t_l <= 0:
self.checkbox_stop_time.Value = False
else:
self.checkbox_stop_time.Value = True
# self.cb_apply_stop_rule.SetValue("After Last Improvement")
after_blind_it_lim = auto_pasta_opts['iter_limit']
self.text_stop2.SetValue(str(after_blind_it_lim))
if self._could_be_aligned:
a_tag = "aligned"
else:
a_tag = "unaligned"
self.log.AppendText("Read %d file(s) with %s %s data. Total of %d taxa found.\n" % (len(fn_list), a_tag, read_type, summary_stats[2]))
by_file = summary_stats[1]
for n, fn in enumerate(fn_list):
t_c_tuple = by_file[n]
if self._could_be_aligned:
self.log.AppendText(' Parsing of the file "%s" returned %d sequences of length = %d\n' % (fn, t_c_tuple[0], t_c_tuple[1]))
else:
self.log.AppendText(' Parsing of the file "%s" returned %d sequences with longest length = %d\n' % (fn, t_c_tuple[0], t_c_tuple[1]))
progress_dialog.Destroy()
else:
self._could_be_aligned = True
self.refresh_aligned_checkbox()
if filepath:
if not parse_as_multilocus:
if filepath and not self.txt_outputdir.GetValue():
self.txt_outputdir.SetValue(os.path.dirname(os.path.abspath(filepath)))
else:
if filepath and not self.txt_outputdir.GetValue():
self.txt_outputdir.SetValue(os.path.abspath(filepath))
else:
self.txt_seqfn.SetValue("")
def refresh_aligned_checkbox(self):
self.checkbox_aligned.SetValue(self._could_be_aligned)
if self._could_be_aligned:
treefilename = self.txt_treefn.GetValue()
if treefilename and os.path.isfile(treefilename):
self.checkbox_aligned.Disable()
else:
self.checkbox_aligned.Enable()
else:
self.checkbox_aligned.Disable()
def OnChooseTree(self, event):
dialog = wx.FileDialog(None, "Choose tree...", wildcard = "Tree files (*.tre)|*.tre|Tree files (*.tree)|*.tree|Tree files (*.phy)|*.phy", style=wx.FD_OPEN)
dialog.ShowModal()
self.txt_treefn.SetValue( dialog.GetPath() )
self.refresh_aligned_checkbox()
def OnIdle(self, evt):
if self.process is not None:
stream = self.process.GetInputStream()
if stream is not None and stream.CanRead():
text = stream.read()
self.log.AppendText(text)
stream = self.process.GetErrorStream()
if stream is not None and stream.CanRead():
text = stream.read()
self.log.AppendText(text)
def OnProcessEnded(self, evt):
stream = self.process.GetInputStream()
if stream.CanRead():
text = stream.read()
self.log.AppendText(text)
stream = self.process.GetErrorStream()
if stream.CanRead():
text = stream.read()
self.log.AppendText(text)
self.process.Destroy()
self.process = None
self.log.AppendText("Job %s is finished.\n" % self.txt_jobname.GetValue())
self._remove_config_file()
self._ReactivateOptions()
self.statusbar.SetStatusText("PASTA Ready!")
self.button.SetLabel("Start")
def OnButton(self, event):
if self.button.GetLabel() == "Start":
self._OnStart()
elif self.button.GetLabel() == "Stop":
self._OnStop()
else:
raise ValueError("Button label %s not recognized.\n" % self.button.GetLabel() )
def OnMultiLocus(self, event):
if self.cb_multilocus.Value:
self.seq_btn.SetLabel("Sequence files ...")
else:
self.seq_btn.SetLabel("Sequence file ...")
self.txt_seqfn.SetValue("")
def _FreezeOptions(self):
self.prev_ctrls_status = []
for ctrl in self.ctrls:
self.prev_ctrls_status.append( ctrl.IsEnabled() )
ctrl.Disable()
def _ReactivateOptions(self):
for i in range(len(self.ctrls)):
self.ctrls[i].Enable(self.prev_ctrls_status[i])
def _OnStart(self):
if self.process is None:
if (not self.checkbox_stop_time.Value) and (not self.checkbox_stop_iter.Value):
self._show_error_dialog("Termination conditions are not set correctly. Either a time limit, an iteration limit, or both must be used.\n", caption="PASTA Settings Error")
return
if self.checkbox_stop_iter.Value and (not self.validate_iter_limit_text()):
self._show_error_dialog("Iteration limit is not set correctly. Enter a positive integer in that field.\n", caption="PASTA Settings Error")
return
input_filename = self._encode_arg(self.txt_seqfn.GetValue())
if not input_filename:
self._show_error_dialog("Input sequence file(s) are required.\n", caption="PASTA Settings Error")
return
if not os.path.exists(input_filename):
self._show_error_dialog('Input sequence file(s) are "%s" does not exist!.\n', caption="PASTA Settings Error")
return
if self.cb_multilocus.Value:
if not os.path.isdir(input_filename):
self._show_error_dialog('Input sequence file specification should be a directory when multilocus model is used.\n', caption="PASTA Settings Error")
return
elif not os.path.isfile(input_filename):
self._show_error_dialog('Input sequence file must be a file when single-locus mode used.\n', caption="PASTA Settings Error")
return
cfg_success = self._create_config_file()
if not cfg_success:
return
#command = [filemgr.quoted_file_path(x) for x in get_invoke_run_pasta_command()]
command = get_invoke_run_pasta_command()
treefilename = self._encode_arg(self.txt_treefn.GetValue())
jobname = self._encode_arg(self.txt_jobname.GetValue())
if not jobname:
wx.MessageBox("Job name cannot be empty, it is REQUIRED by PASTA!", "WARNING", wx.OK|wx.ICON_WARNING)
self._remove_config_file()
return
command.extend(["-i", filemgr.quoted_file_path(input_filename)])
if treefilename and os.path.isfile(treefilename):
command.extend(["-t", filemgr.quoted_file_path(treefilename)])
command.extend(["-j", filemgr.quoted_file_path(jobname) ])
if self.datatype.Value == "DNA":
dt = "dna"
elif self.datatype.Value == "RNA":
dt = "rna"
else:
dt = "protein"
command.extend(["-d", dt])
command.extend(["%s" % filemgr.quoted_file_path(self.process_cfg_file)])
if PASTA_GUI_ONLY_PRINTS_CONFIG:
self.log.AppendText("Command is:\n '%s'\n" % "' '".join(command))
self.log.AppendText("config_file:\n#############################################################\n")
for line in open(self.process_cfg_file, 'r'):
self.log.AppendText(line)
self.log.AppendText("#############################################################\n")
self._remove_config_file()
self.statusbar.SetStatusText("\n\nRun emulated!\n\n")
else:
print("running %s" %" ".join(command))
self.process = wx.Process(self)
self.process.Redirect()
self.pid = wx.Execute( " ".join(command), wx.EXEC_ASYNC, self.process)
self.button.SetLabel("Stop")
self.statusbar.SetStatusText("PASTA Running!")
self._FreezeOptions()
else:
self.log.AppendText("Job %s is still running!\n" % self.txt_jobname.GetValue())
def _OnStop(self):
if self.process is not None:
self.log.AppendText("Job %s is terminated early.\n" % self.txt_jobname.GetValue())
self.process.Kill(self.pid, wx.SIGKILL)
self._remove_config_file()
self._ReactivateOptions()
self.button.SetLabel("Start")
self.statusbar.SetStatusText("PASTA Ready!")
else:
self.log.AppendText("No active PASTA jobs to terminate!\n")
def _encode_arg(self, arg, encoding='utf-8'):
#if isinstance(arg, str):
# return arg.encode(encoding)
return arg
def _create_config_file(self):
from pasta.configure import get_configuration
cfg = get_configuration()
#if self.txt_resultdir.Value:
# basefilename = os.path.basename(self.txt_seqfn.GetValue())
# jobname = self.txt_jobname.GetValue()
# resultdir = self.txt_resultdir.Value
# cfg.commandline.output = os.path.join(resultdir, basefilename+"_%s.aln" % jobname )
# cfg.commandline.result = os.path.join(resultdir, basefilename+"_%s.tre" % jobname )
cfg.sate.aligner = self.cb_tools["aligner"].Value
cfg.sate.tree_estimator = self.cb_tools["treeestimator"].Value
if self.cb_tools["treeestimator"].Value.lower() == "raxml":
cfg.raxml.model = self.cb_tools["model"].Value
else:
model_desc = self.cb_tools["model"].Value
if model_desc == "GTR+G20":
cfg.fasttree.model = "-gtr -gamma"
elif model_desc == "GTR+CAT":
cfg.fasttree.model = "-gtr"
elif model_desc == "JC+G20":
cfg.fasttree.model = "-gamma"
elif model_desc == "JC+CAT":
cfg.fasttree.model = ""
elif model_desc == "JTT+G20":
cfg.fasttree.model = "-gamma"
elif model_desc == "JTT+CAT":
cfg.fasttree.model = ""
elif model_desc == "WAG+G20":
cfg.fasttree.model = "-wag -gamma"
elif model_desc == "WAG+CAT":
cfg.fasttree.model = "-wag"
else:
raise Exception("Unrecognized model: %s" % model_desc)
cfg.commandline.keeptemp = True
cfg.commandline.keepalignmenttemps = True
if self.checkbox_aligned.Value:
cfg.commandline.aligned = True
#cfg.commandline.untrusted = not bool(self.trusted_data.Value)
if self.cb_multilocus.Value:
cfg.commandline.multilocus = True
if self.two_phase.Value:
cfg.commandline.two_phase = True
cfg.commandline.raxml_search_after = False
else:
cfg.commandline.two_phase = False
cfg.commandline.raxml_search_after = bool(self.raxml_after.Value)
cfg.sate.merger = self.cb_tools["merger"].Value
cfg.sate.break_strategy = self.cb_decomp.Value
cfg.sate.start_tree_search_from_current = True