-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTRACS.py
More file actions
2134 lines (1707 loc) · 104 KB
/
Copy pathTRACS.py
File metadata and controls
2134 lines (1707 loc) · 104 KB
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
import tkinter as tk
from tkinter import font as tkfont
from tkinter import *
from tkinter import filedialog
from tkinter import messagebox
from tkinter.ttk import Button, Progressbar, Style
import os
import subprocess
import sys
import pandas as pd
import numpy as np
from scipy import stats
import webbrowser
from datetime import datetime
import _thread
import global_vars_v1 as global_vars
# version
app_version = "1.1.8"
# TRACS: Toolset for the Ranked Analysis of CRISPR Screens
# Created by Pirunthan Perampalam
# Please go to the official TRACS GitHub page for documentation and the latest updates
github_url = "https://github.com/developerpiru/TRACS"
# If you experience bugs/errors/other hurdles in your analyses, please leave a bug report on GitHub
# Data visualization and exploration for TRACS is enabled by VisualizeTRACS, a companion R shiny app
# You can launch VisualizeTRACS from its GitHub page
viz_url = "https://github.com/developerpiru/VisualizeTRACS"
# Help and documentation for VisualizeTRACS is available there
# Fixed lib log2FC calcs by addressing columns by NAME
# Fixed addressing columns by name for reg log2FC
# validated with Excel TRACS
# dynamic column naming and addressing working for all functions in read count processing
# implemented fixed replicate naming of -A, -B, -C, etc for replicates
# removed replicate naming stuff from window frame
# library trimming, alignment, read counts working
# adding input for library read file
# update summary working for all variables
# trimming with cutadapt working
# converting to fasta library working
# building bowtie2 index working
# implemented FILE_FLAGS[] global vars for all file attributes
# trimmed reads save in trimmed-reads folder
# bowtie2 alignments save in alignments folder
# processing for all initial and final replicate files working
# multicore method for cutadapt function working
# implemented replicate naming schema
# horizontal and vertical scrollbars for listboxes so filenames don't have to be split
# replicate naming and number working for cutadapt and bowtie2 functions based on replicate naming schema
# fixed bowtie2 alignment not working anymore
# working mageck count function
# added Cas9- integration
# loading Cas9- files into mageck working
# TRACS algorithm working parts:
# - DONE - get total read counts per sample
# - DONE - get lib log2FC for library
# - DONE - determine mean of replicates for log2FC
# - DONE - get log2FC per sample
# - DONE - get sgw per sample
# - DONE - get rank per sample
# - DONE - get Library, Initial, and Final ES per gene
# - DONE - get ES ratio (ER) (log2 fold change of Initial and Final ES) per gene
# TRACS algorithm functions work for n replicates
# improved statistics calculations for faster speed for p value and q values calculations
# fixed layout and UI in 1.0.2
# removed AnalyzeCounts function and bridged with TrimmingReads function
# cleaned summary box outputs version 1.1.1
# added option to set number of cpu cores
# version 1.1.3: use bowtie2 alignments to improve read depth for library reads only
# version 1.1.4: new theme, bug fixes
# version 1.1.4: added error checking for all user inputs
# version 1.1.5: bug fixes
# version 1.1.6: added error checking for all analysis steps; TRACS stops on any error now
# added new frame to show once TRACS completes
# TrimmingReads function/frame renamed to StartAnalysis
# version 1.1.7: added logging
# version 1.1.8: added threaded progress bar and status updates
def openURL(url):
webbrowser.open(url, new=1)
# function to write messages to log file and console
def write_to_log(message):
# log file path
file_path = os.path.join(global_vars.EXPERIMENT_SETTINGS['Experiment directory'],
global_vars.EXPERIMENT_SETTINGS['Experiment name'] +
global_vars.FILE_FLAGS['Log file'])
# write to console
# print(message)
# show message in status label
# global_vars.status_label.config(text="%s\n%s" % (global_vars.status_label.cget("text"), message))
# show message in status text box
global_vars.status_label.config(state="normal")
global_vars.status_label.insert(END, "\n%s" % message)
# scroll down on the text box
global_vars.status_label.see("end")
# disable status text box
global_vars.status_label.config(state=DISABLED)
try:
# write to log file
file = open(file_path, 'a+')
file.write("\n[%s] %s" % (str(datetime.now()), message))
file.close()
except IOError:
print("\nWarning: Cannot write to log file!")
# function to error check multi-file input for all read files
# make sure at least 2 files are selected
def check_read_inputs(source_object, condition, controller, next_frame, self):
if not source_object.get(1, END): # the first file path is 0, second is 1
messagebox.showerror(title="Error",
message="You must select at least 2 FASTQ read files for your %s" % condition)
else:
# if there were no errors, continue to the next frame/page/step
# check to see if the passed frame contains PROCESSINPUTS message, in which case it is the final file-loading
# frame and the FinalCas9Neg.process_inputs() should be run
if next_frame == "PROCESSINPUTS":
FinalCas9Neg.process_inputs(self)
else:
controller.show_frame(next_frame)
# function to check if the file located at file_path is accessible and be read
def check_file_access(file_path):
# returns True only if file can be accessed
try:
file = open(file_path, 'r')
file.close()
except IOError:
return False
return True
# main app class
class TRACSApp(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
# load global variables
global_vars.init_vars()
# widget styles
self.style = Style()
self.style.theme_use("clam")
# self.style.configure("progressbar_style", foreground="#0DD9A2", background="#0DD9A2")
self.frame_relief = FLAT
self.frame_borderwidth = 0
# app title
self.winfo_toplevel().title("TRACS " + app_version)
# set fonts
self.title_font = tkfont.Font(family='Arial', size=18, weight="bold")
self.label_font = tkfont.Font(family='Arial', size=12, weight="bold")
self.label_font_small = tkfont.Font(family='Arial', size=8, weight="bold")
self.intro_body_font = tkfont.Font(family='Arial', size=12, weight="normal")
self.status_label_font = tkfont.Font(family='Arial', size=12, weight="bold")
self.version_font = tkfont.Font(family='Arial', size=9, weight="normal")
# main container
container = tk.Frame(self, bg="#3d6fdb")
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
# define page frames
self.frames = {}
# create frames for each page
for F in (MainPage, NewExpSettings, LoadFiles, InitialCas9Pos, FinalCas9Pos, InitialCas9Neg, FinalCas9Neg,
SummaryPage, StartAnalysis, EndAnalysis):
page_name = F.__name__
frame = F(parent=container, controller=self)
self.frames[page_name] = frame
# draw all frames in same location
frame.grid(row=0, column=0, sticky="nsew")
# load main page\frame at startup
self.show_frame("MainPage")
def show_frame(self, page_name):
# brings selected frame to the top
frame = self.frames[page_name]
frame.tkraise()
# function to select experiment directory
def browse_folder(self, frame_name, target_name):
target_obj = getattr(self.frames[frame_name], target_name)
folder = filedialog.askdirectory(initialdir=os.getcwd(), title='Select folder...')
target_obj.delete(0, tk.END)
target_obj.insert(tk.END, folder)
# function to select files
def browse_file(self, multi_files, frame_name, target_name, file_type):
target_obj = getattr(self.frames[frame_name], target_name)
if file_type == "csv":
file_options = (("CSV", "*.csv"),
("All files", "*"))
elif file_type == "fastq":
file_options = (("FASTQ files", "*.fastq"),
("GZipped Fastq", "*.fastq.gz"),
("All files", "*"))
if multi_files == "TRUE":
files = filedialog.askopenfilenames(title='Select files...',
filetypes=(file_options))
for item in files:
target_obj.insert(END, item)
else:
file = filedialog.askopenfilename(title='Select file...',
filetypes=(file_options))
target_obj.delete(0, END)
target_obj.insert(END, file)
# function to delete selected file from file list
def delete_selected(self, frame_name, target_name):
target_obj = getattr(self.frames[frame_name], target_name)
selected = target_obj.curselection()
for i in selected[::-1]:
target_obj.delete(i)
# function to get next replicate alphabetical character (e.g. A, B, C, etc.)
# requires first replicate letter ('A') and incremental value (n)
# returns correct replicate letter for the A+nth replicate
def get_rep_char(self, n):
start_char = "A"
next_char = chr(ord(start_char) + int(n)).upper()
return str(next_char)
# frame start page
class MainPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
frame = tk.Frame(self, relief=GROOVE, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
frame.pack(fill=BOTH, padx=5, pady=5, expand=True)
# info
fr_1 = tk.Frame(frame, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_1.pack(fill=X, padx=5, pady=5, anchor=N, expand=True)
lbl_info = tk.Label(fr_1, text="TRACS: Toolset for the Ranked Analysis of CRISPR Screens",
wraplength="800", justify="left", font=controller.title_font, bg="#3d6fdb", fg="white")
lbl_info.pack(padx=5, pady=5)
fr_2 = tk.Frame(frame, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_2.pack(fill=X, side=TOP, padx=5, pady=5, anchor=N, expand=True)
lbl_info = tk.Label(fr_2, text="For help and documentation, please visit our GitHub page at:"
"\n" + github_url +
" or click the button below to open it in your browser."
"\n\n\nData visualization and exploration of data generated by TRACS is enabled by "
"its companion R shiny app, VisualizeTRACS."
"\nYou can download VisualizeTRACS at its "
"own GitHub page at " + viz_url +
"\n\n\nYou can find help and documentation for VisualizeTRACS there as well.",
wraplength="900", justify="left", font=controller.intro_body_font, bg="#3d6fdb", fg="white")
lbl_info.pack(side=TOP, padx=5, pady=5)
lbl_version = tk.Label(fr_2, text="\n\n TRACS version: " + app_version,
wraplength="800", justify="left", font=controller.version_font, bg="#3d6fdb", fg="white")
lbl_version.pack(side=TOP, padx=5, pady=5)
btnNewExp = Button(frame, text="Start New Experiment", command=lambda: controller.show_frame("NewExpSettings"))
btnNewExp.pack(padx=5, pady=5)
# btnLaunchGithub = Button(frame, text="Goto TRACS @ GitHub", command=lambda: openURL(github_url))
# btnLaunchGithub.pack(padx=5, pady=5)
#
# btnLaunchVisualizeTRACS = Button(frame, text="Goto VisualizeTRACS @ GitHub", command=lambda: openURL(viz_url))
# btnLaunchVisualizeTRACS.pack(padx=5, pady=5)
self.pack(fill=BOTH, expand=True)
btnBack = Button(self, text="Exit", command=lambda: app.destroy())
btnBack.pack(side=RIGHT, padx=5, pady=5)
#
# def openURL(self, url):
# webbrowser.open(url, new=1)
# frame for experiment settings
class NewExpSettings(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
# main frame for page body content
fr_main_1 = tk.Frame(self, relief=GROOVE, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_main_1.pack(fill=BOTH, padx=5, pady=5, expand=True)
# heading
fr_header_1 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_header_1.pack(fill=BOTH, padx=5, pady=5, anchor=N)
lbl_heading = tk.Label(fr_header_1, text="New experiment settings", font=controller.title_font, bg="#3d6fdb", fg="white")
lbl_heading.pack(padx=5, pady=5, expand=True)
# page banner
fr_banner = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_banner.pack(fill=BOTH, padx=5, pady=5, anchor=N)
img_banner = PhotoImage(file="images/banners/banner_exp_settings_Cas9_trans_800x175.png")
lbl_exp_design_image = tk.Label(fr_banner, image=img_banner, bg="#3d6fdb")
lbl_exp_design_image.image = img_banner
lbl_exp_design_image.pack(padx=5, pady=5, expand=True)
# experiment name
fr_1 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_1.pack(fill=X, padx=5, pady=5, anchor=N, expand=True)
lbl_exp_name = tk.Label(fr_1, text="Experiment name", width="40", font=controller.label_font, bg="#3d6fdb", fg="white")
lbl_exp_name.pack(side=LEFT, padx=5, pady=5)
self.txt_exp_name = Entry(fr_1)
self.txt_exp_name.pack(fill=X, padx=5, pady=5, expand=True)
# output directory
fr_2 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_2.pack(fill=X, padx=5, pady=5, anchor=N, expand=True)
lbl_expdir = tk.Label(fr_2, text="Experiment folder", width="40", font=controller.label_font, bg="#3d6fdb", fg="white")
lbl_expdir.pack(side=LEFT, anchor=N, padx=5, pady=5)
self.txt_expdir = Entry(fr_2, width="50")
self.txt_expdir.pack(fill=X, padx=5, pady=5, expand=True)
btn_browse = Button(fr_2, text="Browse", command=lambda: self.controller.browse_folder(
frame_name="NewExpSettings", target_name="txt_expdir"))
btn_browse.pack(side=RIGHT, padx=5, pady=5)
# library type
fr_3 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_3.pack(fill=X, padx=5, pady=5, anchor=N, expand=True)
# name of initial group
fr_4 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_4.pack(fill=X, padx=5, pady=5, anchor=N, expand=True)
lbl_name_initial = tk.Label(fr_4, text="Name of initial condition (T0)", width="40", font=controller.label_font, bg="#3d6fdb", fg="white")
lbl_name_initial.pack(side=LEFT, padx=5, pady=5)
self.txt_name_initial = Entry(fr_4)
self.txt_name_initial.pack(fill=X, padx=5, pady=5, expand=True)
# name of final group
fr_5 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_5.pack(fill=X, padx=5, pady=5, anchor=N, expand=True)
lbl_name_final = tk.Label(fr_5, text="Name of final condition (Tf)", width="40", font=controller.label_font, bg="#3d6fdb", fg="white")
lbl_name_final.pack(side=LEFT, padx=5, pady=5)
self.txt_name_final = Entry(fr_5)
self.txt_name_final.pack(fill=X, padx=5, pady=5, expand=True)
# false discovery rate (FDR) for stats
fr_6 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_6.pack(fill=X, padx=5, pady=5, anchor=N, expand=True)
lbl_fdr = tk.Label(fr_6, text="False discovery rate (e.g. 0.05 for 5%)", width="40", font=controller.label_font, bg="#3d6fdb", fg="white")
lbl_fdr.pack(side=LEFT, padx=5, pady=5)
self.txt_fdr = Entry(fr_6)
self.txt_fdr.pack(fill=X, padx=5, pady=5, expand=True)
# number of CPU cores to use
fr_7 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_7.pack(fill=X, padx=5, pady=5, anchor=N, expand=True)
lbl_cores = tk.Label(fr_7, text="Number of CPU cores to use", width="40", font=controller.label_font, bg="#3d6fdb", fg="white")
lbl_cores.pack(side=LEFT, padx=5, pady=5)
self.txt_cores = Entry(fr_7)
self.txt_cores.pack(fill=X, padx=5, pady=5, expand=True)
# navigation buttons
btn_Next = Button(self, text="Next", command=lambda: self.check_inputs())
btn_Next.pack(side=RIGHT)
btn_Back = Button(self, text="Back", command=lambda: controller.show_frame("MainPage"))
btn_Back.pack(side=RIGHT, padx=5, pady=5)
# function to error check inputs from NewExpSettings and save values to global variables
def check_inputs(self):
# variable to record user input errors
error_log = ""
# check each user input and save into global variables
# experiment name
if self.controller.frames['NewExpSettings'].txt_exp_name.get() != "":
global_vars.EXPERIMENT_SETTINGS['Experiment name'] = \
self.controller.frames['NewExpSettings'].txt_exp_name.get() # experiment name
else:
error_log = error_log + "Experiment name cannot be blank"
# experiment folder
if self.controller.frames['NewExpSettings'].txt_expdir.get() != "":
global_vars.EXPERIMENT_SETTINGS['Experiment directory'] = \
self.controller.frames['NewExpSettings'].txt_expdir.get() # experiment directory
else:
error_log = error_log + "\n\nExperiment folder cannot be blank"
# initial condition name
if self.controller.frames['NewExpSettings'].txt_name_initial.get() != "":
global_vars.EXPERIMENT_SETTINGS['Initial condition name'] = \
self.controller.frames['NewExpSettings'].txt_name_initial.get() # initial condition name (day 0)
else:
error_log = error_log + "\n\nInitial condition name cannot be blank"
# final condition name
if self.controller.frames['NewExpSettings'].txt_name_final.get() != "":
global_vars.EXPERIMENT_SETTINGS['Final condition name'] = \
self.controller.frames['NewExpSettings'].txt_name_final.get() # final condition name (day X)
else:
error_log = error_log + "\n\nFinal condition name cannot be blank"
# FDR
if self.controller.frames['NewExpSettings'].txt_fdr.get() != "":
try:
global_vars.EXPERIMENT_SETTINGS['FDR'] = \
float(int(self.controller.frames['NewExpSettings'].txt_fdr.get()) / 100) # FDR
except ValueError:
global_vars.EXPERIMENT_SETTINGS['FDR'] = 0
else:
error_log = error_log + "\n\nFalse discovery rate cannot be blank"
# CPU cores
if self.controller.frames['NewExpSettings'].txt_cores.get() != "":
try:
global_vars.EXPERIMENT_SETTINGS['CPU cores'] = \
int(self.controller.frames['NewExpSettings'].txt_cores.get()) # CPU cores
except ValueError:
global_vars.EXPERIMENT_SETTINGS['CPU cores'] = 0
else:
error_log = error_log + "\n\nCPU cores cannot be blank"
# additionally, check to make sure FDR and CPU cores have numerical values
# FDR
if self.controller.frames['NewExpSettings'].txt_fdr.get() != "":
if not self.controller.frames['NewExpSettings'].txt_fdr.get().isdigit():
error_log = error_log + "\n\nFalse discovery rate must be a number"
# CPU cores
if self.controller.frames['NewExpSettings'].txt_cores.get() != "":
if not self.controller.frames['NewExpSettings'].txt_cores.get().isdigit():
error_log = error_log + "\n\nNumber of CPU cores must be a number"
# check condition names and make sure they are unique (can't have same name for both)
if self.controller.frames['NewExpSettings'].txt_name_initial.get() != "" and \
self.controller.frames['NewExpSettings'].txt_name_initial.get() == self.controller.frames['NewExpSettings'].txt_name_final.get():
error_log = error_log + "\n\nInitial and final condition names must be different"
# if error_log logged any errors, display a warning message with the errors
if error_log != "":
messagebox.showerror(title="Error", message="%s" % error_log)
else:
# if there were no errors, continue to the next frame/page/step
self.controller.show_frame("LoadFiles")
# frame for loading library files
class LoadFiles(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
# main frame for page body content
fr_main_1 = tk.Frame(self, relief=GROOVE, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_main_1.pack(fill=BOTH, padx=5, pady=5, expand=True)
# heading
fr_header_1 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_header_1.pack(fill=BOTH, padx=5, pady=5, anchor=N)
lbl_heading = tk.Label(fr_header_1, text="Initial pooled sgRNA library files", font=controller.title_font, bg="#3d6fdb", fg="white")
lbl_heading.pack(padx=5, pady=5, expand=True)
# page banner
fr_banner = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_banner.pack(fill=BOTH, padx=5, pady=5, anchor=N)
img_banner = PhotoImage(file="images/banners/banner_load_files_trans_800x175.png")
lbl_exp_design_image = tk.Label(fr_banner, image=img_banner, bg="#3d6fdb")
lbl_exp_design_image.image = img_banner
lbl_exp_design_image.pack(padx=5, pady=5, expand=True)
# reference library
fr_2 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_2.pack(fill=X, padx=5, pady=5, anchor=N, expand=True)
lbl_reflibrary = tk.Label(fr_2, text="Library reference file (CSV)", width="40", font=controller.label_font, bg="#3d6fdb", fg="white")
lbl_reflibrary.pack(side=LEFT, anchor=N, padx=5, pady=5)
self.txt_reflibrary = tk.Entry(fr_2)
self.txt_reflibrary.pack(fill=X, padx=5, pady=5, expand=True)
btn_browse = Button(fr_2, text="Browse", command=lambda: self.controller.browse_file(multi_files="FALSE",
frame_name="LoadFiles",
target_name="txt_reflibrary",
file_type="csv"))
btn_browse.pack(side=RIGHT, padx=5, pady=5)
# library reads file
fr_6 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_6.pack(fill=X, padx=5, pady=5, anchor=N, expand=True)
lbl_libreads = tk.Label(fr_6, text="Initial library (L0) read file (FASTQ)", width="40", font=controller.label_font, bg="#3d6fdb", fg="white")
lbl_libreads.pack(side=LEFT, anchor=N, padx=5, pady=5)
self.txt_libreads = tk.Entry(fr_6)
self.txt_libreads.pack(fill=X, padx=5, pady=5, expand=True)
btn_browse = Button(fr_6, text="Browse", command=lambda: self.controller.browse_file(multi_files="FALSE",
frame_name="LoadFiles",
target_name="txt_libreads",
file_type="fastq"))
btn_browse.pack(side=RIGHT, padx=5, pady=5)
# navigation buttons
btn_Next = Button(self, text="Next", command=lambda: self.check_inputs())
btn_Next.pack(side=RIGHT)
btn_Back = Button(self, text="Back", command=lambda: controller.show_frame("NewExpSettings"))
btn_Back.pack(side=RIGHT, padx=5, pady=5)
# function to error check inputs from LoadFiles and save values to global variables
def check_inputs(self):
error_log = ""
# check user input and save into global variables
# sgRNA library csv file
if self.controller.frames['LoadFiles'].txt_reflibrary.get() != "":
global_vars.EXPERIMENT_SETTINGS['Library reference file'] = \
self.controller.frames['LoadFiles'].txt_reflibrary.get() # library reference file
else:
error_log = error_log + "\nLibrary reference file (CSV)"
# initial pooled sgRNA library reads fastq file
if self.controller.frames['LoadFiles'].txt_libreads.get() != "":
global_vars.LIBRARY_READ_PATH = self.controller.frames['LoadFiles'].txt_libreads.get()
else:
error_log = error_log + "\nInitial library (L0) read file (FASTQ)"
# if error_log logged any errors, then display a warning message with the errors
if error_log != "":
messagebox.showerror(title="Error",
message="You must select files for the following: \n%s" % error_log)
else:
# if there were no errors, continue to the next frame/page/step
self.controller.show_frame("InitialCas9Pos")
# frame for loading initial Cas9 positive files
class InitialCas9Pos(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
# main frame for page body content
fr_main_1 = tk.Frame(self, relief=GROOVE, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_main_1.pack(fill=BOTH, padx=5, pady=5, expand=True)
# heading
fr_header_1 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_header_1.pack(fill=BOTH, padx=5, pady=5, anchor=N)
lbl_heading = tk.Label(fr_header_1, text="Load initial Cas9-positive files", font=controller.title_font, bg="#3d6fdb", fg="white")
lbl_heading.pack(padx=5, pady=5, expand=True)
# page banner
fr_banner = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_banner.pack(fill=BOTH, padx=5, pady=5, anchor=N)
img_banner = PhotoImage(file="images/banners/banner_load_files_trans_800x175.png")
lbl_exp_design_image = tk.Label(fr_banner, image=img_banner, bg="#3d6fdb")
lbl_exp_design_image.image = img_banner
lbl_exp_design_image.pack(padx=5, pady=5, expand=True)
# container frame for listbox labels
fr_3 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_3.pack(fill=BOTH, padx=5, pady=5, anchor=N, expand=True)
# frame for initial label
fr_4 = tk.Frame(fr_3, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_4.pack(fill=X, padx=5, pady=5, side=LEFT, expand=True)
lbl_i_info = tk.Label(fr_4, text="Please select your initial condition (T0) Cas9-positive read files (FASTQ)", font=controller.label_font, bg="#3d6fdb", fg="white")
lbl_i_info.pack(padx=5, pady=5, side=LEFT)
# container frame for list boxes
list_container = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
list_container.pack(fill=BOTH, padx=5, pady=5, anchor=N, expand=True)
# frame for initial listbox
initial_list_container = tk.Frame(list_container, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#FFFFFF")
initial_list_container.pack(fill=BOTH, padx=0, pady=0, side=LEFT, expand=True)
# frame for initial listbox buttons
initial_btn_container = tk.Frame(initial_list_container, bg="#3d6fdb")
initial_btn_container.pack(fill=BOTH, padx=0, pady=0, side=RIGHT)
# initial listbox
self.lst_initial_files = Listbox(initial_list_container, height="18", width="900", selectmode=EXTENDED)
# y scroll for initial listbox
yscrl_lst_initial_files = Scrollbar(initial_list_container, orient=VERTICAL)
yscrl_lst_initial_files.pack(side=RIGHT, fill=Y)
yscrl_lst_initial_files.config(command=self.lst_initial_files.yview)
self.lst_initial_files.config(yscrollcommand=yscrl_lst_initial_files.set)
# x scroll for initial listbox
xscrl_lst_initial_files = Scrollbar(initial_list_container, orient=HORIZONTAL)
xscrl_lst_initial_files.pack(side=BOTTOM, fill=X)
xscrl_lst_initial_files.config(command=self.lst_initial_files.xview)
self.lst_initial_files.config(xscrollcommand=xscrl_lst_initial_files.set)
self.lst_initial_files.pack(side=LEFT, padx=0, pady=0)
# add
btn_i_add = Button(initial_btn_container, text="Add", command=lambda: self.controller.browse_file(multi_files="TRUE",
frame_name="InitialCas9Pos",
target_name="lst_initial_files",
file_type="fastq"))
btn_i_add.pack(side=TOP, padx=0, pady=0)
# remove
btn_i_rem = Button(initial_btn_container, text="Remove",
command=lambda: self.controller.delete_selected(frame_name="InitialCas9Pos",
target_name="lst_initial_files"))
btn_i_rem.pack(side=TOP, padx=0, pady=0)
# clear
btn_i_clear = Button(initial_btn_container, text="Clear", command=lambda: self.lst_initial_files.delete(0, END))
btn_i_clear.pack(side=TOP, padx=0, pady=0)
# navigation buttons
btn_Next = Button(self, text="Next", command=lambda: check_read_inputs(
source_object=self.controller.frames['InitialCas9Pos'].lst_initial_files,
condition="initial Cas9-positive (T0) condition",
controller=self.controller,
next_frame="FinalCas9Pos",
self=self))
btn_Next.pack(side=RIGHT)
btn_Back = Button(self, text="Back", command=lambda: controller.show_frame("LoadFiles"))
btn_Back.pack(side=RIGHT, padx=5, pady=5)
# frame for loading final Cas9 positive files
class FinalCas9Pos(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
# main frame for page body content
fr_main_1 = tk.Frame(self, relief=GROOVE, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_main_1.pack(fill=BOTH, padx=5, pady=5, expand=True)
# heading
fr_header_1 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_header_1.pack(fill=BOTH, padx=5, pady=5, anchor=N)
lbl_heading = tk.Label(fr_header_1, text="Load final Cas9-positive files", font=controller.title_font, bg="#3d6fdb", fg="white")
lbl_heading.pack(padx=5, pady=5, expand=True)
# page banner
fr_banner = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_banner.pack(fill=BOTH, padx=5, pady=5, anchor=N)
img_banner = PhotoImage(file="images/banners/banner_load_files_trans_800x175.png")
lbl_exp_design_image = tk.Label(fr_banner, image=img_banner, bg="#3d6fdb")
lbl_exp_design_image.image = img_banner
lbl_exp_design_image.pack(padx=5, pady=5, expand=True)
# container frame for listbox labels
fr_3 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_3.pack(fill=BOTH, padx=5, pady=5, anchor=N, expand=True)
# frame for final label
fr_5 = tk.Frame(fr_3, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_5.pack(fill=X, padx=5, pady=5, side=LEFT, expand=True)
lbl_f_info = tk.Label(fr_5, text="Please select your final condition (T0) Cas9-positive read files (FASTQ)", font=controller.label_font, bg="#3d6fdb", fg="white")
lbl_f_info.pack(padx=5, pady=5, side=LEFT)
# container frame for final list boxes
list_container = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
list_container.pack(fill=BOTH, padx=5, pady=5, anchor=N, expand=True)
# frame for final listbox
final_list_container = tk.Frame(list_container, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#FFFFFF")
final_list_container.pack(fill=BOTH, padx=0, pady=0, side=LEFT, expand=True)
# frame for final listbox buttons
final_btn_container = tk.Frame(final_list_container, bg="#3d6fdb")
final_btn_container.pack(fill=BOTH, padx=0, pady=0, side=RIGHT)
# final listbox
self.lst_final_files = Listbox(final_list_container, height="18", width="900", selectmode=EXTENDED)
# y scroll for final listbox
yscrl_lst_final_files = Scrollbar(final_list_container, orient=VERTICAL)
yscrl_lst_final_files.pack(side=RIGHT, fill=Y)
yscrl_lst_final_files.config(command=self.lst_final_files.yview)
self.lst_final_files.config(yscrollcommand=yscrl_lst_final_files.set)
# x scroll for final listbox
xscrl_lst_final_files = Scrollbar(final_list_container, orient=HORIZONTAL)
xscrl_lst_final_files.pack(side=BOTTOM, fill=X)
xscrl_lst_final_files.config(command=self.lst_final_files.xview)
self.lst_final_files.config(xscrollcommand=xscrl_lst_final_files.set)
self.lst_final_files.pack(side=LEFT, padx=0, pady=0)
# add
btn_f_add = Button(final_btn_container, text="Add",
command=lambda: self.controller.browse_file(multi_files="TRUE",
frame_name="FinalCas9Pos",
target_name="lst_final_files",
file_type="fastq"))
btn_f_add.pack(side=TOP, padx=0, pady=0)
# remove
btn_f_rem = Button(final_btn_container, text="Remove",
command=lambda: self.controller.delete_selected(frame_name="FinalCas9Pos",
target_name="lst_final_files"))
btn_f_rem.pack(side=TOP, padx=0, pady=0)
# clear
btn_f_clear = Button(final_btn_container, text="Clear", command=lambda: self.lst_final_files.delete(0, END))
btn_f_clear.pack(side=TOP, padx=0, pady=0)
# navigation buttons
btn_Next = Button(self, text="Next", command=lambda: check_read_inputs(
source_object=self.controller.frames['FinalCas9Pos'].lst_final_files,
condition="final Cas9-positive (Tf) condition",
controller=self.controller,
next_frame="InitialCas9Neg",
self=self))
btn_Next.pack(side=RIGHT)
btn_Back = Button(self, text="Back", command=lambda: controller.show_frame("InitialCas9Pos"))
btn_Back.pack(side=RIGHT, padx=5, pady=5)
# frame for loading initial Cas9 negative files
class InitialCas9Neg(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
# main frame for page body content
fr_main_1 = tk.Frame(self, relief=GROOVE, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_main_1.pack(fill=BOTH, padx=5, pady=5, expand=True)
# heading
fr_header_1 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_header_1.pack(fill=BOTH, padx=5, pady=5, anchor=N)
lbl_heading = tk.Label(fr_header_1, text="Load initial Cas9-negative files", font=controller.title_font, bg="#3d6fdb", fg="white")
lbl_heading.pack(padx=5, pady=5, expand=True)
# page banner
fr_banner = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_banner.pack(fill=BOTH, padx=5, pady=5, anchor=N)
img_banner = PhotoImage(file="images/banners/banner_load_files_trans_800x175.png")
lbl_exp_design_image = tk.Label(fr_banner, image=img_banner, bg="#3d6fdb")
lbl_exp_design_image.image = img_banner
lbl_exp_design_image.pack(padx=5, pady=5, expand=True)
# container frame for listbox labels
fr_3 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_3.pack(fill=BOTH, padx=5, pady=5, anchor=N, expand=True)
# frame for initial label
fr_4 = tk.Frame(fr_3, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_4.pack(fill=X, padx=5, pady=5, side=LEFT, expand=True)
lbl_i_info = tk.Label(fr_4, text="Please select your initial condition (T0) Cas9-negative read files (FASTQ)", font=controller.label_font, bg="#3d6fdb", fg="white")
lbl_i_info.pack(padx=5, pady=5, side=LEFT)
# container frame for list boxes
list_container = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
list_container.pack(fill=BOTH, padx=5, pady=5, anchor=N, expand=True)
# frame for initial listbox
initial_list_container = tk.Frame(list_container, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#FFFFFF")
initial_list_container.pack(fill=BOTH, padx=0, pady=0, side=LEFT, expand=True)
# frame for initial listbox buttons
initial_btn_container = tk.Frame(initial_list_container, bg="#3d6fdb")
initial_btn_container.pack(fill=BOTH, padx=0, pady=0, side=RIGHT)
# initial listbox
self.lst_initial_files = Listbox(initial_list_container, height="18", width="900", selectmode=EXTENDED)
# y scroll for initial listbox
yscrl_lst_initial_files = Scrollbar(initial_list_container, orient=VERTICAL)
yscrl_lst_initial_files.pack(side=RIGHT, fill=Y)
yscrl_lst_initial_files.config(command=self.lst_initial_files.yview)
self.lst_initial_files.config(yscrollcommand=yscrl_lst_initial_files.set)
# x scroll for initial listbox
xscrl_lst_initial_files = Scrollbar(initial_list_container, orient=HORIZONTAL)
xscrl_lst_initial_files.pack(side=BOTTOM, fill=X)
xscrl_lst_initial_files.config(command=self.lst_initial_files.xview)
self.lst_initial_files.config(xscrollcommand=xscrl_lst_initial_files.set)
self.lst_initial_files.pack(side=LEFT, padx=0, pady=0)
# add
btn_i_add = Button(initial_btn_container, text="Add",
command=lambda: self.controller.browse_file(multi_files="TRUE",
frame_name="InitialCas9Neg",
target_name="lst_initial_files",
file_type="fastq"))
btn_i_add.pack(side=TOP, padx=0, pady=0)
# remove
btn_i_rem = Button(initial_btn_container, text="Remove",
command=lambda: self.controller.delete_selected(frame_name="InitialCas9Neg",
target_name="lst_initial_files"))
btn_i_rem.pack(side=TOP, padx=0, pady=0)
# clear
btn_i_clear = Button(initial_btn_container, text="Clear", command=lambda: self.lst_initial_files.delete(0, END))
btn_i_clear.pack(side=TOP, padx=0, pady=0)
# navigation buttons
btn_Next = Button(self, text="Next", command=lambda: check_read_inputs(
source_object=self.controller.frames['InitialCas9Neg'].lst_initial_files,
condition="initial Cas9-negative (T0) condition",
controller=self.controller,
next_frame="FinalCas9Neg",
self=self))
btn_Next.pack(side=RIGHT)
btn_Back = Button(self, text="Back", command=lambda: controller.show_frame("FinalCas9Pos"))
btn_Back.pack(side=RIGHT, padx=5, pady=5)
# frame for loading final Cas9 negative files
class FinalCas9Neg(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
# main frame for page body content
fr_main_1 = tk.Frame(self, relief=GROOVE, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_main_1.pack(fill=BOTH, padx=5, pady=5, expand=True)
# heading
fr_header_1 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_header_1.pack(fill=BOTH, padx=5, pady=5, anchor=N)
lbl_heading = tk.Label(fr_header_1, text="Load final Cas9-negative files", font=controller.title_font, bg="#3d6fdb", fg="white")
lbl_heading.pack(padx=5, pady=5, expand=True)
# page banner
fr_banner = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_banner.pack(fill=BOTH, padx=5, pady=5, anchor=N)
img_banner = PhotoImage(file="images/banners/banner_load_files_trans_800x175.png")
lbl_exp_design_image = tk.Label(fr_banner, image=img_banner, bg="#3d6fdb")
lbl_exp_design_image.image = img_banner
lbl_exp_design_image.pack(padx=5, pady=5, expand=True)
# container frame for listbox labels
fr_3 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_3.pack(fill=BOTH, padx=5, pady=5, anchor=N, expand=True)
# frame for final label
fr_5 = tk.Frame(fr_3, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_5.pack(fill=X, padx=5, pady=5, side=LEFT, expand=True)
lbl_f_info = tk.Label(fr_5, text="Please select your final condition (T0) Cas9-negative read files (FASTQ)", font=controller.label_font, bg="#3d6fdb", fg="white")
lbl_f_info.pack(padx=5, pady=5, side=LEFT)
# container frame for final list boxes
list_container = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
list_container.pack(fill=BOTH, padx=5, pady=5, anchor=N, expand=True)
# frame for final listbox
final_list_container = tk.Frame(list_container, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#FFFFFF")
final_list_container.pack(fill=BOTH, padx=0, pady=0, side=LEFT, expand=True)
# frame for final listbox buttons
final_btn_container = tk.Frame(final_list_container, bg="#3d6fdb")
final_btn_container.pack(fill=BOTH, padx=0, pady=0, side=RIGHT)
# final listbox
self.lst_final_files = Listbox(final_list_container, height="18", width="900", selectmode=EXTENDED)
# y scroll for final listbox
yscrl_lst_final_files = Scrollbar(final_list_container, orient=VERTICAL)
yscrl_lst_final_files.pack(side=RIGHT, fill=Y)
yscrl_lst_final_files.config(command=self.lst_final_files.yview)
self.lst_final_files.config(yscrollcommand=yscrl_lst_final_files.set)
# x scroll for final listbox
xscrl_lst_final_files = Scrollbar(final_list_container, orient=HORIZONTAL)
xscrl_lst_final_files.pack(side=BOTTOM, fill=X)
xscrl_lst_final_files.config(command=self.lst_final_files.xview)
self.lst_final_files.config(xscrollcommand=xscrl_lst_final_files.set)
self.lst_final_files.pack(side=LEFT, padx=0, pady=0)
# add
btn_f_add = Button(final_btn_container, text="Add",
command=lambda: self.controller.browse_file(multi_files="TRUE",
frame_name="FinalCas9Neg",
target_name="lst_final_files",
file_type="fastq"))
btn_f_add.pack(side=TOP, padx=0, pady=0)
# remove
btn_f_rem = Button(final_btn_container, text="Remove",
command=lambda: self.controller.delete_selected(frame_name="FinalCas9Neg",
target_name="lst_final_files"))
btn_f_rem.pack(side=TOP, padx=0, pady=0)
# clear
btn_f_clear = Button(final_btn_container, text="Clear", command=lambda: self.lst_final_files.delete(0, END))
btn_f_clear.pack(side=TOP, padx=0, pady=0)
# navigation buttons
btn_Next = Button(self, text="Next", command=lambda: check_read_inputs(
source_object=self.controller.frames['FinalCas9Neg'].lst_final_files,
condition="final Cas9-negative (Tf) condition",
controller=self.controller,
next_frame="PROCESSINPUTS",
self=self))
btn_Next.pack(side=RIGHT)
btn_Back = Button(self, text="Back", command=lambda: controller.show_frame("InitialCas9Neg"))
btn_Back.pack(side=RIGHT, padx=5, pady=5)
# function to verify if the number of replicates provided for each condition matches
def check_replicates(self):
if len(global_vars.LIST_INITIAL_PATHS) and len(global_vars.LIST_FINAL_PATHS) and len(global_vars.LIST_CAS9_NEG_I_PATHS) == len(global_vars.LIST_CAS9_NEG_F_PATHS):
return True
else:
return False
def process_inputs(self):
# get Initial condition Cas9+ fastq files
global_vars.LIST_INITIAL_PATHS = self.controller.frames['InitialCas9Pos'].lst_initial_files.get(0, END)
# get Final condition Cas9+ fastq files
global_vars.LIST_FINAL_PATHS = self.controller.frames['FinalCas9Pos'].lst_final_files.get(0, END)
# get Initial condition Cas9- fastq files
global_vars.LIST_CAS9_NEG_I_PATHS = self.controller.frames['InitialCas9Neg'].lst_initial_files.get(0, END)
# get Final condition Cas9- fastq files
global_vars.LIST_CAS9_NEG_F_PATHS = self.controller.frames['FinalCas9Neg'].lst_final_files.get(0, END)
# reset status box
summary_box = self.controller.frames['SummaryPage'].txt_summary
summary_box.config(state=NORMAL)
summary_box.delete(1.0, END)
# print experiment settings into status text box
for keys, values in global_vars.EXPERIMENT_SETTINGS.items():
tmp_text = "%s: %s\n" % (keys, values)
summary_box.insert(END, tmp_text)
# print library read file manually since it's only a single file
summary_box.insert(END, "\n\nInitial Library read file: %s" % global_vars.LIBRARY_READ_PATH)
# call function to print files into status box
self.print_files(tar_name=global_vars.LIST_INITIAL_PATHS,
condition=global_vars.EXPERIMENT_SETTINGS['Initial condition name'], cas9_type="-positive")
self.print_files(tar_name=global_vars.LIST_FINAL_PATHS,
condition=global_vars.EXPERIMENT_SETTINGS['Final condition name'], cas9_type="-positive")
self.print_files(tar_name=global_vars.LIST_CAS9_NEG_I_PATHS,
condition=global_vars.EXPERIMENT_SETTINGS['Initial condition name'], cas9_type="-negative")
self.print_files(tar_name=global_vars.LIST_CAS9_NEG_F_PATHS,
condition=global_vars.EXPERIMENT_SETTINGS['Final condition name'], cas9_type="-negative")
summary_box.config(state=DISABLED)
# check if the number of files supplied for each condition matches
result = self.check_replicates()
if result is False:
msg = "\nYou have not provided the same number of samples/replicates for each condition. " \
"\nPlease ensure the number of samples provided for Initial and Final conditions for Cas9-positive " \
"and Cas9-negative sets are equal!" \
"\nStopping TRACS."
print(msg)
messagebox.showerror(title="Error",
message=msg)
return
else:
# show summary page after processing all inputs
self.controller.show_frame("SummaryPage")
# function to print selected files into status box
def print_files(self, tar_name, condition, cas9_type):
summary_box = self.controller.frames['SummaryPage'].txt_summary
tmp_text = "\n\nSample files for Cas9%s '%s' condition:\n" % (cas9_type, condition)
summary_box.insert(END, tmp_text)
for i in tar_name:
tmp_text = "\nFile %s: %s" % (tar_name.index(i) + 1, i)
summary_box.insert(END, tmp_text)
class SummaryPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
# main frame for page body content
fr_main_1 = tk.Frame(self, relief=GROOVE, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_main_1.pack(fill=BOTH, padx=5, pady=5, expand=True)
# heading
fr_header_1 = tk.Frame(fr_main_1, relief=controller.frame_relief, borderwidth=controller.frame_borderwidth, bg="#3d6fdb")
fr_header_1.pack(fill=BOTH, padx=5, pady=5, anchor=N)
lbl_heading = tk.Label(fr_header_1, text="Summary", font=controller.title_font, bg="#3d6fdb", fg="white")
lbl_heading.pack(padx=5, pady=5, expand=True)