-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdialogues.py
2031 lines (1333 loc) · 62.5 KB
/
dialogues.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
"""
Collection of dialogue windows
"""
import pynet,os,netio,netext,visuals,eden,transforms
import random
import heapq
import string
import percolator
import shutil
from math import ceil
from Tkinter import *
import tkMessageBox
#from pylab import *
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,NavigationToolbar2TkAgg
# NEW DIALOGUE WINDOWS / JS / MAY-JUNE 09
class MySimpleDialog(Toplevel):
'''Master class for a dialog popup window.
Functions body() and apply() to be overridden
with whatever the dialog should be doing.'''
def __init__(self,parent,title=None):
Toplevel.__init__(self,parent)
self.transient(parent)
self.title(title)
self.parent=parent
self.result=None
body=Frame(self)
self.initial_focus=self.body(self,body)
body.pack(padx=5,pady=5)
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus(self)
self.protocol("WM_DELETE_WINDOW",self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
def body(self,masterclass,masterwindow):
pass
def buttonbox(self):
"""OK and Cancel buttons"""
box=Frame(self)
w=Button(box,text="OK",width=10,command=self.ok,default=ACTIVE)
w.pack(side=LEFT,padx=5,pady=5)
w=Button(box,text="Cancel",width=10,command=self.cancel)
w.pack(side=LEFT,padx=5,pady=5)
self.bind("<Return>",self.ok)
self.bind("<Escape",self.cancel)
box.pack()
def ok(self,event=None):
if not self.validate():
self.initial_focus.focus_set()
return
self.withdraw()
self.update_idletasks()
self.applyme()
self.cancel()
def cancel(self,event=None):
self.parent.focus_set()
self.destroy()
def validate(self):
return 1
def applyme(self):
pass
def displayBusyCursor(self):
self.parent.configure(cursor='watch')
self.parent.update()
self.parent.after_idle(self.removeBusyCursor)
def removeBusyCursor(self):
self.parent.configure(cursor='arrow')
class WLogbinDialog(MySimpleDialog):
"""Asks for the number of bins for log binning
and allows linear bins for 1...10"""
def __init__(self,parent,title=None):
Toplevel.__init__(self,parent)
self.configure(bg='Gray80')
self.transient(parent)
if title:
self.title=title
self.parent=parent
self.result=None
self.linfirst=IntVar()
self.numbins=StringVar()
body=Frame(self,bg='Gray80')
self.initial_focus=self.body(self,body)
body.pack(padx=5,pady=5)
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus(self)
self.protocol("WM_DELETE_WINDOW",self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
def body(self,masterclass,masterwindow):
self.b1=Checkbutton(masterwindow,text='Use linear bins for 1..10',variable=masterclass.linfirst,state=ACTIVE,bg='Gray80')
self.b1.grid(row=0,column=0,columnspan=2)
Label(masterwindow,text='Number of bins:',bg='Gray80').grid(row=1,column=0)
self.c1=Entry(masterwindow,textvariable=masterclass.numbins,bg='Gray95')
masterclass.numbins.set('30')
self.c1.grid(row=1,column=1)
return self.c1
def applyme(self):
self.result=[self.linfirst.get(),float(self.numbins.get())]
class LoadMatrixDialog(MySimpleDialog):
"""Asks for the number of bins for log binning
and allows linear bins for 1...10"""
def __init__(self,parent,title='Please provide information:'):
Toplevel.__init__(self,parent)
# self.configure(bg='Gray80')
# self.transient(parent)
self.title(title)
self.parent=parent
self.result=None
self.clones=StringVar()
self.measuretype=StringVar()
body=Frame(self)
self.initial_focus=self.body(self,body)
body.pack(padx=5,pady=5)
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus(self)
self.protocol("WM_DELETE_WINDOW",self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
def body(self,masterclass,masterwindow):
self.c1=Label(masterwindow,text='What distance measure has been used?',bg='DarkOliveGreen2',anchor=W)
self.c1.grid(row=0,column=0)
r1=Radiobutton(masterwindow,text='Non-shared alleles',value='nsa',variable=masterclass.measuretype)
r2=Radiobutton(masterwindow,text='Linear Manhattan',value='lm',variable=masterclass.measuretype)
r3=Radiobutton(masterwindow,text='Allele parsimony',value='ap',variable=masterclass.measuretype)
r4=Radiobutton(masterwindow,text='Hybrid',value="hybrid",variable=masterclass.measuretype)
r5=Radiobutton(masterwindow,text='Other',value="other",variable=masterclass.measuretype)
r1.grid(row=1,column=0,sticky=W)
r2.grid(row=2,column=0,sticky=W)
r3.grid(row=3,column=0,sticky=W)
r4.grid(row=4,column=0,sticky=W)
r5.grid(row=5,column=0,sticky=W)
self.c2=Label(masterwindow,text='How have clones been handled?',bg='DarkOliveGreen2',anchor=W)
self.c2.grid(row=6,column=0)
r6=Radiobutton(masterwindow,text='Removed',value='collapsed',variable=masterclass.clones)
r7=Radiobutton(masterwindow,text='Kept',value='included',variable=masterclass.clones)
r8=Radiobutton(masterwindow,text='Unknown',value='unknown',variable=masterclass.clones)
r6.grid(row=7,column=0,sticky=W)
r7.grid(row=8,column=0,sticky=W)
r8.grid(row=9,column=0,sticky=W)
masterclass.measuretype.set('other')
masterclass.clones.set('unknown')
return self.c1
def applyme(self):
self.result=[self.measuretype.get(),self.clones.get()]
class MetaHelpWindow(MySimpleDialog):
def __init__(self,parent,title=None,datatype='msat'):
Toplevel.__init__(self,parent)
self.configure(bg='Gray80')
self.transient(parent)
self.datatype=datatype
if title:
self.title=title
self.parent=parent
self.result=None
self.linfirst=IntVar()
self.numbins=StringVar()
body=Frame(self,bg='Gray80')
self.initial_focus=self.body(self,body)
body.pack(padx=5,pady=5)
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus(self)
self.protocol("WM_DELETE_WINDOW",self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
def body(self,masterclass,masterwindow):
self.text=Text(self,bg='Gray90')
self.text.pack(expand=YES,fill=BOTH)
str1="Auxiliary data files are used for reading node properties, such as labels, classes, and sampling sites. "
str2="File format is ASCII, such that each row lists properties for a node. \n"
str3="The first row must contain HEADERS, i.e. labels for the properties. \n\n"
str4="Example for the first row: \n node_label node_site node_latitude node_longitude node_geoclass \n"
if self.datatype=='net':
str4=str4+"\nWhen the input data is a network (.edg,.gml), THE FIRST HEADER COLUMN MUST BE node_label, "
str4=str4+"and there must be a row for each node in the original network, using original node labels."
str4=str4+"If you have saved the node properties in EDEN Analyzer, this has been taken care of already."
if self.datatype=='msat':
str4=str4+"\nThere must be one row for each row in the original microsatellite data file. "
if self.datatype=="dmat":
str4=str4+"\nThere must be one row for each row in the original distance matrix file. "
self.text.insert(INSERT,str1+str2+str3+str4)
class AskNumberOfBins(MySimpleDialog):
"""Asks for number of bins for binning"""
def __init__(self,parent,title=None):
Toplevel.__init__(self,parent)
#self.configure(bg='Gray80')
# self.transient(parent)
if title:
self.title=title
self.parent=parent
self.result=None
# self.linfirst=IntVar()
self.numbins=StringVar()
body=Frame(self)
self.initial_focus=self.body(self,body)
body.pack(padx=5,pady=5)
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus(self)
self.protocol("WM_DELETE_WINDOW",self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
def body(self,masterclass,masterwindow):
# self.b1=Checkbutton(masterwindow,text='Use linear bins for 1..10',variable=masterclass.linfirst,state=ACTIVE,bg='Gray80')
# self.b1.grid(row=0,column=0,columnspan=2)
Label(masterwindow,text='Number of bins:').grid(row=1,column=0)
self.c1=Entry(masterwindow,textvariable=masterclass.numbins,bg='Gray95')
masterclass.numbins.set('30')
self.c1.grid(row=1,column=1)
return self.c1
def applyme(self):
self.result=float(self.numbins.get())
def validate(self):
userstr=self.numbins.get()
try:
nbins=int(userstr)
except Exception:
tkMessageBox.showerror(
"Error:",
"Number of bins must be an integer.")
return 0
if nbins<2:
tkMessageBox.showerror(
"Error:",
"Number of bins must be larger than one.")
return 0
return 1
class ProjectLaunchDialog(MySimpleDialog):
"""First window shown when launching a new analysis wizard.
Inquires if the user wants to load microsatellite data,
a distance matrix, or a network file."""
def __init__(self,parent,title=None):
Toplevel.__init__(self,parent)
#self.configure(bg='Gray80')
# self.transient(parent)
self.title("New analysis project")
self.parent=parent
self.result=None
self.datatype=StringVar()
# self.linfirst=IntVar()
body=Frame(self)
self.initial_focus=self.body(self,body)
body.pack(padx=5,pady=5)
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus(self)
self.protocol("WM_DELETE_WINDOW",self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
def body(self,masterclass,masterwindow):
# self.b1=Checkbutton(masterwindow,text='Use linear bins for 1..10',variable=masterclass.linfirst,state=ACTIVE,bg='Gray80')
# self.b1.grid(row=0,column=0,columnspan=2)
self.wholeframe=Frame(masterwindow,relief='sunken',borderwidth=2)
self.clabel=Label(self.wholeframe,text="Select input data type:",justify=LEFT,anchor=W,bg='gray90',relief='groove',borderwidth=1)
self.clabel.pack(side=TOP,expand=YES,fill=X,ipadx=5,ipady=5)
self.bottompart=Frame(self.wholeframe)
r1=Radiobutton(self.bottompart,text='Genotype matrix, haploid, individual centred',value='ms_haploid',variable=masterclass.datatype)
r125=Radiobutton(self.bottompart,text='Genotype matrix, diploid, individual centred',value='ms_diploid',variable=masterclass.datatype)
r15=Radiobutton(self.bottompart,text='Genotype matrix, haploid, sampling site based',value='mpop_haploid',variable=masterclass.datatype)
r175=Radiobutton(self.bottompart,text='Genotype matrix, diploid, sampling site based',value='mpop_diploid',variable=masterclass.datatype)
r1875=Radiobutton(self.bottompart,text='Presence/absence matrix',value='presabs',variable=masterclass.datatype)
r19=Radiobutton(self.bottompart,text='Presence/abundancy matrix',value='presabu',variable=masterclass.datatype)
r2=Radiobutton(self.bottompart,text='Distance matrix',value='dmat',variable=masterclass.datatype)
r3=Radiobutton(self.bottompart,text='Network data',value='net',variable=masterclass.datatype)
r1.grid(row=1,column=0,sticky=W)
r125.grid(row=3,column=0,sticky=W)
r15.grid(row=2,column=0,sticky=W)
r175.grid(row=4,column=0,sticky=W)
r1875.grid(row=5,column=0,sticky=W)
r19.grid(row=6,column=0,sticky=W)
r2.grid(row=7,column=0,sticky=W)
r3.grid(row=8,column=0,sticky=W)
self.bottompart.pack(side=TOP,expand=YES,fill=BOTH,ipadx=7,ipady=7)
masterclass.datatype.set('ms_haploid')
self.wholeframe.pack(side=TOP,expand=YES,fill=BOTH)
return self.wholeframe
def applyme(self):
self.result=(self.datatype.get())
class ChooseMatrixNodeNames(MySimpleDialog):
"""First window shown when launching a new analysis wizard.
Inquires if the user wants to load microsatellite data,
a distance matrix, or a network file."""
def __init__(self,parent,title=None,titlemsg="How to set node labels?"):
Toplevel.__init__(self,parent)
#self.configure(bg='Gray80')
# self.transient(parent)
self.title(title)
self.titlemsg=titlemsg
self.parent=parent
self.result=None
self.measuretype=StringVar()
# self.linfirst=IntVar()
body=Frame(self)
self.initial_focus=self.body(self,body)
body.pack(padx=5,pady=5)
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus(self)
self.protocol("WM_DELETE_WINDOW",self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
def body(self,masterclass,masterwindow,titlemsg="How to set node labels?"):
self.wholeframe=Frame(masterwindow,relief='sunken',borderwidth=2)
self.clabel=Label(self.wholeframe,text=self.titlemsg,justify=LEFT,anchor=W,bg='gray90',relief='groove',borderwidth=1)
self.clabel.pack(side=TOP,expand=YES,fill=X,ipadx=5,ipady=5)
self.bottompart=Frame(self.wholeframe)
r1=Radiobutton(self.bottompart,text='From file',value='file',variable=masterclass.measuretype)
r2=Radiobutton(self.bottompart,text='1..N',value='numbers',variable=masterclass.measuretype)
r1.grid(row=1,column=0,sticky=W)
r2.grid(row=2,column=0,sticky=W)
self.bottompart.pack(side=TOP,expand=YES,fill=BOTH,ipadx=7,ipady=7)
masterclass.measuretype.set('nsa')
self.wholeframe.pack(side=TOP,expand=YES,fill=BOTH)
return self.wholeframe
def applyme(self):
self.result=(self.measuretype.get())
class ChooseDistanceMeasure(MySimpleDialog):
"""First window shown when launching a new analysis wizard.
Inquires if the user wants to load microsatellite data,
a distance matrix, or a network file."""
def __init__(self,parent,title=None,titlemsg="Choose genetic distance measure"):
Toplevel.__init__(self,parent)
#self.configure(bg='Gray80')
# self.transient(parent)
self.title(title)
self.titlemsg=titlemsg
self.parent=parent
self.result=None
self.measuretype=StringVar()
# self.linfirst=IntVar()
body=Frame(self)
self.initial_focus=self.body(self,body)
body.pack(padx=5,pady=5)
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus(self)
self.protocol("WM_DELETE_WINDOW",self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
def body(self,masterclass,masterwindow,titlemsg="Choose genetic distance measure"):
# self.b1=Checkbutton(masterwindow,text='Use linear bins for 1..10',variable=masterclass.linfirst,state=ACTIVE,bg='Gray80')
# self.b1.grid(row=0,column=0,columnspan=2)
self.wholeframe=Frame(masterwindow,relief='sunken',borderwidth=2)
self.clabel=Label(self.wholeframe,text=self.titlemsg,justify=LEFT,anchor=W,bg='gray90',relief='groove',borderwidth=1)
self.clabel.pack(side=TOP,expand=YES,fill=X,ipadx=5,ipady=5)
self.bottompart=Frame(self.wholeframe)
#r1=Radiobutton(self.bottompart,text='Non-shared alleles',value='nsa',variable=masterclass.measuretype)
r1=Radiobutton(self.bottompart,text='Allele Sharing',value='ap',variable=masterclass.measuretype)
r2=Radiobutton(self.bottompart,text='Linear Manhattan',value='lm',variable=masterclass.measuretype)
#r3=Radiobutton(self.bottompart,text='Allele parsimony',value='ap',variable=masterclass.measuretype)
#r4=Radiobutton(self.bottompart,text='Hybrid',value="hybrid",variable=masterclass.measuretype)
r1.grid(row=1,column=0,sticky=W)
r2.grid(row=2,column=0,sticky=W)
#r3.grid(row=3,column=0,sticky=W)
#r4.grid(row=4,column=0,sticky=W)
self.bottompart.pack(side=TOP,expand=YES,fill=BOTH,ipadx=7,ipady=7)
masterclass.measuretype.set('nsa')
self.wholeframe.pack(side=TOP,expand=YES,fill=BOTH)
return self.wholeframe
def applyme(self):
self.result=(self.measuretype.get())
class ImportMetadataYesNo(MySimpleDialog):
"""First window shown when launching a new analysis wizard.
Inquires if the user wants to load microsatellite data,
a distance matrix, or a network file."""
def __init__(self,parent,title=None,titlemsg="Do you want to import auxiliary node data?",datatype='msat'):
Toplevel.__init__(self,parent)
#self.configure(bg='Gray80')
# self.transient(parent)
self.title(title)
self.datatype=datatype
self.titlemsg=titlemsg
self.parent=parent
self.result=None
self.metatype=IntVar()
# self.linfirst=IntVar()
body=Frame(self)
self.initial_focus=self.body(self,body)
body.pack(padx=5,pady=5)
self.buttonbox(self.datatype)
self.grab_set()
if not self.initial_focus:
self.initial_focus(self)
self.protocol("WM_DELETE_WINDOW",self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
def buttonbox(self,datatype='msat'):
"""OK, Cancel and Help buttons"""
box=Frame(self)
w=Button(box,text="OK",width=10,command=self.ok,default=ACTIVE)
w.pack(side=LEFT,padx=5,pady=5)
w=Button(box,text="Cancel",width=10,command=self.cancel)
w.pack(side=LEFT,padx=5,pady=5)
w=Button(box,text="Help",width=10,command=lambda s=self,t=datatype: s.displayhelp(t))
w.pack(side=LEFT,padx=5,pady=5)
self.bind("<Return>",self.ok)
self.bind("<Escape",self.cancel)
box.pack()
def body(self,masterclass,masterwindow,titlemsg="Do you want to import auxiliary node data?"):
# self.b1=Checkbutton(masterwindow,text='Use linear bins for 1..10',variable=masterclass.linfirst,state=ACTIVE,bg='Gray80')
# self.b1.grid(row=0,column=0,columnspan=2)
self.wholeframe=Frame(masterwindow,relief='sunken',borderwidth=2)
self.clabel=Label(self.wholeframe,text=self.titlemsg,justify=LEFT,anchor=W,bg='gray90',relief='groove',borderwidth=1)
self.clabel.pack(side=TOP,expand=YES,fill=X,ipadx=5,ipady=5)
self.bottompart=Frame(self.wholeframe)
r1=Radiobutton(self.bottompart,text='Yes',value=1,variable=masterclass.metatype)
r2=Radiobutton(self.bottompart,text='No',value=0,variable=masterclass.metatype)
r1.grid(row=1,column=0,sticky=W)
r2.grid(row=2,column=0,sticky=W)
masterclass.metatype.set(1)
self.bottompart.pack(side=TOP,expand=YES,fill=BOTH,ipadx=7,ipady=7)
self.wholeframe.pack(side=TOP,expand=YES,fill=BOTH)
return self.wholeframe
def applyme(self):
self.result=(self.metatype.get())
def displayhelp(self,datatype):
MetaHelpWindow(self,datatype)
class MatrixDialog(MySimpleDialog):
"""Used when loading a matrix. Asks if the matrix contains weights or distances"""
def __init__(self,parent,title=None):
Toplevel.__init__(self,parent)
#self.configure(bg='Gray80')
# self.transient(parent)
if title:
self.title=title
self.parent=parent
self.result=None
self.mattype=IntVar()
# self.linfirst=IntVar()
body=Frame(self)
self.initial_focus=self.body(self,body)
body.pack(padx=5,pady=5)
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus(self)
self.protocol("WM_DELETE_WINDOW",self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
def body(self,masterclass,masterwindow):
# self.b1=Checkbutton(masterwindow,text='Use linear bins for 1..10',variable=masterclass.linfirst,state=ACTIVE,bg='Gray80')
# self.b1.grid(row=0,column=0,columnspan=2)
self.c1=Label(masterwindow,text='Matrix type:')
self.c1.grid(row=0,column=0)
r1=Radiobutton(masterwindow,text='Weight matrix',value=1,variable=masterclass.mattype)
r2=Radiobutton(masterwindow,text='Distance matrix',value=0,variable=masterclass.mattype)
r1.grid(row=0,column=1,sticky=W)
r2.grid(row=1,column=1,sticky=W)
masterclass.mattype.set(0)
return self.c1
def applyme(self):
self.result=(self.mattype.get())
class MsatDialog(MySimpleDialog):
"""Used when loading a matrix. Asks if the matrix contains weights or distances"""
def __init__(self,parent,title=None,titlemsg="Handling clones"):
Toplevel.__init__(self,parent)
#self.configure(bg='Gray80')
# self.transient(parent)
self.title(title)
self.titlemsg=titlemsg
self.parent=parent
self.result=None
self.mattype=IntVar()
# self.linfirst=IntVar()
body=Frame(self)
self.initial_focus=self.body(self,body)
body.pack(padx=5,pady=5)
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus(self)
self.protocol("WM_DELETE_WINDOW",self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
def body(self,masterclass,masterwindow,titlemsg="Handling clones"):
# self.b1=Checkbutton(masterwindow,text='Use linear bins for 1..10',variable=masterclass.linfirst,state=ACTIVE,bg='Gray80')
# self.b1.grid(row=0,column=0,columnspan=2)
self.wholeframe=Frame(masterwindow,relief='sunken',borderwidth=2)
self.clabel=Label(self.wholeframe,text=self.titlemsg,justify=LEFT,anchor=W,bg='gray90',relief='groove',borderwidth=1)
self.clabel.pack(side=TOP,expand=YES,fill=X,ipadx=5,ipady=5)
self.bottompart=Frame(self.wholeframe)
r1=Radiobutton(self.bottompart,text='Collapse clones',value=1,variable=masterclass.mattype)
r2=Radiobutton(self.bottompart,text='Leave clones',value=0,variable=masterclass.mattype)
r1.grid(row=1,column=0,sticky=W)
r2.grid(row=2,column=0,sticky=W)
self.bottompart.pack(side=TOP,expand=YES,fill=BOTH,ipadx=7,ipady=7)
self.wholeframe.pack(side=TOP,expand=YES,fill=BOTH)
masterclass.mattype.set(1)
return self.wholeframe
def applyme(self):
self.result=(self.mattype.get())
class VisualizationDialog(MySimpleDialog):
"""Asks options for network visualization"""
def __init__(self,parent,title=None):
Toplevel.__init__(self,parent)
#self.configure(bg='Gray80')
# self.transient(parent)
if title:
self.title=title
self.parent=parent
self.result=None
self.winsize=IntVar()
self.vtxsize=StringVar()
self.vtxcolor=StringVar()
self.bgcolor=StringVar()
self.showlabels=StringVar()
# self.linfirst=IntVar()
body=Frame(self)
self.initial_focus=self.body(self,body)
body.pack(padx=5,pady=5)
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus(self)
self.protocol("WM_DELETE_WINDOW",self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
def body(self,masterclass,masterwindow):
# self.b1=Checkbutton(masterwindow,text='Use linear bins for 1..10',variable=masterclass.linfirst,state=ACTIVE,bg='Gray80')
# self.b1.grid(row=0,column=0,columnspan=2)
self.c1=Label(masterwindow,text='Vertex color:')
self.c1.grid(row=0,column=0)
rowcount=-1
for text, value in [('Black','000000'),('White','999999'),('Red','990000'),('Green','009900'),('Blue','000099'),('By strength','-1')]:
rowcount+=1
Radiobutton(masterwindow,text=text,value=value,variable=masterclass.vtxcolor).grid(row=rowcount,column=1,sticky=W)
masterclass.vtxcolor.set('-1')
Label(masterwindow,text='Vertex size:').grid(row=rowcount+1,column=0)
for text, value in [('Small','0.4'),('Medium','0.7'),('Large','0.99'),('By strength','-1.0')]:
rowcount=rowcount+1
Radiobutton(masterwindow,text=text,value=value,variable=masterclass.vtxsize).grid(row=rowcount,column=1,sticky=W)
masterclass.vtxsize.set('-1.0')
Label(masterwindow,text='Show with:').grid(row=rowcount+1,column=0)
for text, value in [('White background','white'),('Black background','black')]:
rowcount=rowcount+1
Radiobutton(masterwindow,text=text,value=value,variable=masterclass.bgcolor).grid(row=rowcount,column=1,sticky=W)
masterclass.bgcolor.set('black')
Label(masterwindow,text="Vertex labels:").grid(row=rowcount+1,column=0)
for text, value in [('None','none'),('All','all'),('Top 10','top10')]:
rowcount=rowcount+1
Radiobutton(masterwindow,text=text,value=value,variable=masterclass.showlabels).grid(row=rowcount,column=1,sticky=W)
masterclass.showlabels.set('all')
return self.c1
def applyme(self):
self.result=(self.vtxcolor.get(),self.vtxsize.get(),self.bgcolor.get(),self.showlabels.get())
class AskThreshold(MySimpleDialog):
"""Asks threshold for thresholding"""
def __init__(self,parent,title=None):
Toplevel.__init__(self,parent)
#self.configure(bg='Gray80')
# self.transient(parent)
if title:
self.title=title
self.parent=parent
self.result=None
# self.linfirst=IntVar()
self.threshold=StringVar()
body=Frame(self)
self.initial_focus=self.body(self,body)
body.pack(padx=5,pady=5)
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus(self)
self.protocol("WM_DELETE_WINDOW",self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
def body(self,masterclass,masterwindow):
# self.b1=Checkbutton(masterwindow,text='Use linear bins for 1..10',variable=masterclass.linfirst,state=ACTIVE,bg='Gray80')
# self.b1.grid(row=0,column=0,columnspan=2)
Label(masterwindow,text='Threshold:').grid(row=1,column=0)
self.c1=Entry(masterwindow,textvariable=masterclass.threshold,bg='Gray95')
masterclass.threshold.set('0')
self.c1.grid(row=1,column=1)
return self.c1
def applyme(self):
self.result=float(self.threshold.get())
class PercolationDialog(MySimpleDialog):
"""First window shown when launching a new analysis wizard.
Inquires if the user wants to load microsatellite data,
a distance matrix, or a network file."""
def __init__(self,parent,title=None,titlemsg="Set threshold distance",pdata=[],suscmax_thresh=0.0):
Toplevel.__init__(self,parent)
#self.configure(bg='Gray80')
# self.transient(parent)
self.title(title)
self.titlemsg=titlemsg
self.parent=parent
self.result=None
self.data=pdata
self.default_thresh=suscmax_thresh
self.threshold=StringVar()
# self.linfirst=IntVar()
body=Frame(self)
self.initial_focus=self.body(self,body)
body.pack(padx=5,pady=5)
self.buttonbox()
self.grab_set()
if not self.initial_focus:
self.initial_focus(self)
self.protocol("WM_DELETE_WINDOW",self.cancel)
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,parent.winfo_rooty()+50))
self.initial_focus.focus_set()
self.wait_window(self)
def body(self,masterclass,masterwindow,titlemsg="Choose genetic distance measure"):
# self.b1=Checkbutton(masterwindow,text='Use linear bins for 1..10',variable=masterclass.linfirst,state=ACTIVE,bg='Gray80')
# self.b1.grid(row=0,column=0,columnspan=2)
self.wholeframe=Frame(masterwindow,relief='groove',borderwidth=2,bg="Gray95")
# self.clabel=Label(self.wholeframe,text=self.titlemsg,bg='DarkOliveGreen2',relief='groove',borderwidth=1)
# self.clabel.pack(side=TOP,expand=YES,fill=X,ipadx=5,ipady=5)
self.midpart=Frame(self.wholeframe)
myplot=visuals.ReturnPlotObject(self.data,plotcommand="plot",addstr=",color=\"#9e0b0f\"",titlestring="Largest component size:Susceptibility",xstring="Threshold distance",ystring="GCC size:Susceptibility",fontsize=9)
myplot.canvas=FigureCanvasTkAgg(myplot.thisFigure,master=self.midpart)
myplot.canvas.show()
myplot.canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=YES, padx=10,pady=10)
self.midpart.pack(side=TOP,expand=YES,fill=BOTH)
self.bottompart=Frame(self.wholeframe)
Label(self.bottompart,text='Estimated percolation threshold = %2.2f' % self.default_thresh).grid(row=1,column=0,columnspan=2)
Label(self.bottompart,text='Threshold: ').grid(row=2,column=0)
self.c1=Entry(self.bottompart,textvariable=masterclass.threshold,bg='Gray95')
masterclass.threshold.set(str(self.default_thresh))
self.c1.grid(row=2,column=1)
self.bottompart.pack(side=TOP,expand=YES,fill=BOTH,ipadx=7,ipady=7)
self.wholeframe.pack(side=TOP,expand=YES,fill=BOTH)
return self.wholeframe
def applyme(self):
self.result=(self.threshold.get())
class VisualizationOptions(MySimpleDialog):
"""First window shown when launching a new analysis wizard.
Inquires if the user wants to load microsatellite data,
a distance matrix, or a network file."""
def __init__(self,parent,network,title=None,titlemsg="Choose visualization options"):
Toplevel.__init__(self,parent)
#self.configure(bg='Gray80')
# self.transient(parent)