-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLARS_2.00.py
2372 lines (2261 loc) · 121 KB
/
LARS_2.00.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
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 6 14:02:59 2014
@author: Lars Sørensen
"""
#=======================================================================================
# Several globally defined values are used through out the program they are listed here:
# RT
# pre_selection_list
# filelocation_list
# key_list
# Dialog
# Prot_ident
# MinInt
# ScrMinInt
# MinSeqLen
# MaxSeqLen
# MinProd
# ScrMinProd
# MinProdPAA
# ScrMinProdPAA
# MinConProd
# ScrMinConProd
# MinScr
# ScrMinScr
# MaxMHHErr
# NoOffRep
# ScrNoOffRep
# Allowed_SD
# Sequence_Length
# MinSeqScr
# Show caution when using these
#=======================================================================================
#The necessary modules are importede
import sys
import csv
import re
import os
import datetime
import ntpath
import tkinter as tk
import tkinter.font as tkFont
from tkinter import filedialog
from tkinter import StringVar
from tkinter import ttk
from tkinter import Event
from tkinter import messagebox
class ToolTip(object):
"""
This class is a modified version of the one found here http://www.voidspace.org.uk/python/weblog/arch_d7_2006_07_01.shtml
it allows for the attachement of tool tip to entryboxes, labels and all other widgets from tkinter
"""
def __init__(self, widget):
self.widget = widget
self.tipwindow = None
self.id = None
self.x = self.y = 0
def showtip(self, text):
"Display text in tooltip window"
self.text = text
if self.tipwindow or not self.text:
return
x, y, cx, cy = self.widget.bbox("insert")
x = x + self.widget.winfo_rootx() + 27
y = y + cy + self.widget.winfo_rooty() +27
self.tipwindow = tw = tk.Toplevel(self.widget)
tw.wm_overrideredirect(1)
tw.wm_geometry("+%d+%d" % (x, y))
try:
# For Mac OS
tw.tk.call("::tk::unsupported::MacWindowStyle",
"style", tw._w,
"help", "noActivates")
except tk.TclError:
pass
label = tk.Label(tw, text=self.text, justify="left",
background="#ffffe0", relief="solid", borderwidth=1,
font=("tahoma", "8", "normal"))
label.pack(ipadx=1)
def hidetip(self):
"""
Removes the tool tip. called upon exiting the widgets
"""
tw = self.tipwindow
self.tipwindow = None
if tw:
tw.destroy()
def createToolTip(widget, text):
"""
Creates the tooltip from the tooltip class, and displays the text given to the function when the cursor enters
or exit the widget
"""
toolTip = ToolTip(widget)
def enter(event):
toolTip.showtip(text)
def leave(event):
toolTip.hidetip()
widget.bind('<Enter>', enter)
widget.bind('<Leave>', leave)
class RT_Selection_Treeview(object):
"""
When an RT SD fails to meet the users input this class is called
The class contains the window settings, a function that builds the treeview and a function that allows
the user to select the RT that they want
"""
def __init__(self,root):
"""
The __init__ builds the window and the treeview widget
"""
# The settings for the geometry of the window and column names
self.top = tk.Toplevel()
self.top.geometry("800x300")
self.top.focus()
self.label=tk.Label(self.top,text="Select your RT")
self.label.pack()
self.columns = ["Sequence", "No. Products", "Intensity", "RT", "IM", " z ", "Delta mass"]#The items in this list are used for column headers
self.tree = tk.ttk.Treeview(self.top, columns=self.columns, show="headings")
self.tree.pack(fill='both', expand=True)
# The select button, the buttons functionality can also be acces by double clicking on mouse button 1
self.button=tk.Button(self.top,text='Select',command=self.select)
self.button.pack()
self.top.bind('<Double-Button-1>', self.select)
#The columns are set a minimum width to ensure easy readability for the header and the value
self.tree.column(0, anchor="center", minwidth = 100)
self.tree.column(1, anchor="center", minwidth = 50)
self.tree.column(2, anchor="center", minwidth = 50)
self.tree.column(3, anchor="center", minwidth = 50)
self.tree.column(4, anchor="center", minwidth = 50)
self.tree.column(5, anchor="center", minwidth = 50)
self.tree.column(6, anchor="center", minwidth = 50)
#Calls the building of the treeview widget
self._build_tree()
def _build_tree(self):
"""
This function builds the tree and populates it with the values in the globaly defined pre_selection_list, from the FunctionLibrary class
RT selection function. This gives the user the overview of how the individual sequence indentifications values
Furthermore it contains the possibility to adjust the column width to the len of the column header strings
"""
for col in self.columns:
self.tree.heading(col, text=col.title())
# adjust the column's width to the header string
self.tree.column(col,
width=tkFont.Font().measure(col.title()))
for item in pre_selection_list:
self.tree.insert('', 'end', values=item)
def select(self, event=None):
"""
This selects the item that the cursor has been pressed on and uses the row index to retrive the RT value from the globaly defined pre_selection_list,
from the FunctionLibrary class, RT selection function. The RT is gloablly defined an is extracted.
"""
row = self.tree.selection()
row_index =self.tree.index(row)
global RT
RT = pre_selection_list[row_index][3]
self.top.destroy()
class Application(tk.Frame):
"""
This Class is used to build up the frame/GUI of the PLGS assistant :)
The __init__ function is called by the class calls in the end of the editor. Furthermore certain global variables are defined and created
These are used in the following class FunctionLibrary and should not be changed since this will ceartainly break the software
The menubar is also made in the init function
The CreateWidgets function is used to generate the buttons, listbox and labels for the various input/output operations of the frame/GUI
furthermore some global variables are defined, this is done so they can be used in the sorting of the loaded PLGS files.
"""
def __init__(self, root):
"""
Class call --> Tkinter frame
When the class is called the frame is initiated. The global values from the user input are made
and defined. These values are used in the functioncs in the FunctionLibrary Class.
"""
tk.Frame.__init__(self, root)
#Scrollbar and startup geometry
self.canvas = tk.Canvas(root, width = 1070, height = 722, borderwidth=0, background="gray94")
self.frame = tk.Frame(self.canvas, background="gray94")
self.vsb = tk.Scrollbar(root, orient="vertical", command=self.canvas.yview)
self.canvas.configure(yscrollcommand=self.vsb.set)
self.vsb.pack(side="right", fill="y")
self.canvas.pack(side="left", fill="both", expand=True)
self.canvas.create_window((4,4),window=self.frame, anchor="nw", tags="self.frame")
self.frame.bind("<Configure>", self.OnFrameConfigure)
self.frame.focus_force()
#To allow the Popwindow to be a toplevel frame
self.root = root
#Initiating the widgets
self.createWidgets()
# Global variables are defined to be manipulated and transfered between Class's/Functions's
#PLGS, The key and location lists are used in the cvs_parser function in the FunctionLibrary class
global filelocation_list
filelocation_list = []
global key_list
key_list = []
global protein_identifiers # Used to show the protein identifiers in the protein identifier listbox
protein_identifiers = []
global added_identifiers
added_identifiers = set()
# Menu constructor
self.menubar = tk.Menu(self)
#Help Menu
menu = tk.Menu(self.menubar)
menu.add_command(label = "Save", command = self.save)
menu.add_command(label = "Load", command = self.load)
menu.add_command(label = "About", command = self.About)
self.menubar.add_cascade(label = "File", menu = menu)
root.config(menu = self.menubar)
self.Dialog_insert("Hi there friend.\nThis is where i am going to show you the results of your LARS analysis.\nIf something goes wrong i should be able to help you fix it.\n\n")
def createToolTip(widget, text):
"""
Call the functions within the ToolTip class and modifies the text so it reflect the widget
"""
toolTip = ToolTip(widget)
def enter(event):
toolTip.showtip(text)
def leave(event):
toolTip.hidetip()
widget.bind('<Enter>', enter)
widget.bind('<Leave>', leave)
def OnFrameConfigure(self, event):
'''
Reset the scroll region to encompass the inner frame.
'''
self.canvas.configure(scrollregion=self.canvas.bbox("all"))
def RT_Selection_popup(self):
"""
This function makes sure that the RT_Selection_Treeview class is a toplevel window of the main GUI class
"""
self.RT_window=RT_Selection_Treeview(root)
root.wait_window(self.RT_window.top)
def createWidgets(self):
"""
All the widgets that are present when the frame is started are defined below.
"""
#The textbox for keeping track of the program's progress
global Dialog
Dialog_scrollbar = tk.Scrollbar(self.frame)
Dialog_scrollbar.grid(row=13, column=7, rowspan =5, sticky='n,s')
Dialog = tk.Text(self.frame, height = 11, relief = 'groove', bd = 2, width = 80, yscrollcommand=Dialog_scrollbar.set)
Dialog.grid(column = 3, row = 13, columnspan = 4, rowspan = 5, sticky = "n,e", padx = 5, pady = 5)
Dialog_scrollbar.config(command=Dialog.yview)
Dialog.config(state=tk.DISABLED) #The box is keept in active so the user cannot write anything into it
#The listbox for the PLGS file upload
self.listbox_PLGS = tk.Listbox(self.frame, height = 12, width = 62, bd = 3, relief = "groove")
self.listbox_PLGS.grid(column = 0, row = 0, rowspan = 5, columnspan = 3, padx = 5, pady = 5)
#The listbox for the Protein Identifiers
self.listbox_Protein_Identifier = tk.Listbox(self.frame, height = 12, width = 62, bd = 3, relief = "groove")
self.listbox_Protein_Identifier.grid(column = 0, row = 6, rowspan = 5, columnspan = 2, padx = 5, pady = 5)
#The add PLGS button
self.button_add = tk.Button(self.frame, text = "Add an Ion Accounting File", command = self.Add_PLGS)
self.button_add.grid(column = 0, row = 5, padx = 5, pady = 5, sticky = "n, w",)
#The remove PLGS button
self.button_remove = tk.Button(self.frame, text = "Remove an Ion Accounting File", command = self.Delete_PLGS)
self.button_remove.grid(column = 1, row = 5, padx = 5, pady = 5, sticky = "n, w",)
#The process button
self.button_process = tk.Button(self.frame, text = "Run the LARS processing", command = self.Process)
self.button_process.grid(column = 0, row = 15, padx = 5, pady = 5, sticky = "n, w")
createToolTip(self.button_process, "Start the Scoring and Sorting of the Ion accounting files. You will be prompted to make a folder,\nall of the processing output is stored here")
#The Update button
self.button_pre_process = tk.Button(self.frame, text = "Update", command = self.Pre_Process)
self.button_pre_process.grid(column = 3, row = 5, padx = 5, pady = 5, sticky = "n,e")
createToolTip(self.button_pre_process, "Test the sorting abilities of your current values")
#The header for the filter section
self.FilterHeader = tk.Label(self.frame, text = "Insert your filter values")
self.FilterHeader.grid(column = 3, row = 0, sticky = "n, w", padx = 5, pady = 5)
#The cutoff text
self.cutoff = tk.Label(self.frame, text = "Cut-off value ")
self.cutoff.grid(column = 4, row = 5, sticky = "n, e", padx = 5, pady = 5)
createToolTip(self.cutoff,"Values lower or not meeting your selection\nwill be excluded from further treatment")
self.Scrcutoff= tk.Label(self.frame, text = "Minimum scoring value")
self.Scrcutoff.grid(column = 5, row = 5, sticky = "n, e", padx = 5, pady = 5)
createToolTip(self.Scrcutoff,"Values meeting or exceeding your selection grants a point")
#Value labels and boxes
#The protein identifier entry
Protien_identifier_str = tk.StringVar()
self.ProteinIdentifier_Entry = tk.Entry(self.frame, width=50)
self.ProteinIdentifier_Entry.grid(column = 4, columnspan = 2, row = 1, sticky = "n, w", padx = 5, pady = 5)
self.ProteinIdentifier_Label = tk.Label(self.frame, text = "Protein Identifier")
self.ProteinIdentifier_Label.grid(column = 3, row = 1, sticky = "n, w", padx = 5, pady = 5)
self.ProteinIdentifier_Entry.insert(0, string = "No protein identifier has been selected")
#createToolTip(self.ProteinIdentifier_Entry, "The Protein identifier is the name given\n when creating the PLGS database")
#The Maximum MH+ Error (ppm) Entry
self.MaximumMHErrorPPM_Entry = tk.Entry(self.frame, width=50)
self.MaximumMHErrorPPM_Entry.grid(column = 4, columnspan = 2, row = 2, sticky = "n,w", padx = 5, pady = 5)
self.MaximumMHErrorPPM_Label = tk.Label(self.frame, text = "Maximum MH+ Error (ppm)")
self.MaximumMHErrorPPM_Label.grid(column = 3, row = 2, sticky = "n,w", padx = 5, pady = 5)
self.MaximumMHErrorPPM_Entry.insert(0,10)
#The Minimum Sequence length Entry
self.MinimumSequenceLength_Entry = tk.Entry(self.frame, width=50)
self.MinimumSequenceLength_Entry.grid(column = 4, columnspan = 2, row = 3, sticky = "n, w", padx = 5, pady = 5)
self.MinimumSequenceLength_Label = tk.Label(self.frame, text="Minimum Sequence Length")
self.MinimumSequenceLength_Label.grid(column = 3, row = 3, sticky = "n, w", padx = 5, pady = 5)
self.MinimumSequenceLength_Entry.insert(0,7)
#The Maximum Sequence legnth Entry
self.MaximumSequenceLength_Entry = tk.Entry(self.frame, width=50)
self.MaximumSequenceLength_Entry.grid(column = 4, columnspan = 2, row = 4, sticky = "n, w", padx = 5, pady = 5)
self.MaximumSequenceLength_Label = tk.Label(self.frame, text = "Maximum Sequence Length")
self.MaximumSequenceLength_Label.grid(column = 3, row = 4, sticky = "n, w", padx = 5, pady = 5)
self.MaximumSequenceLength_Entry.insert(0, 55)
#The minimum intensity entry
self.MinimumIntensity_Entry = tk.Entry(self.frame)
self.MinimumIntensity_Entry.grid(column = 4, row = 6, sticky = "n, w", padx = 5, pady = 5)
self.MinimumIntensity_Label = tk.Label(self.frame, text = "Minimum Intensity")
self.MinimumIntensity_Label.grid(column = 3, row = 6, sticky = "n, w", padx = 5, pady = 5)
self.MinimumIntensity_Entry.insert(0, 0)
#The Minimum products Entry
self.MinimumProducts_Entry = tk.Entry(self.frame)
self.MinimumProducts_Entry.grid(column = 4, row = 7, sticky = "n, w", padx = 5, pady = 5)
self.MinimumProducts_Label = tk.Label(self.frame, text = "Minimum Products")
self.MinimumProducts_Label.grid(column = 3, row = 7, sticky = "n, w", padx = 5, pady = 5)
self.MinimumProducts_Entry.insert(0, 0)
#The minimum products per amino acid Entry
self.MinimumProductsPerAminoAcid_Entry = tk.Entry(self.frame)
self.MinimumProductsPerAminoAcid_Entry.grid(column = 4, row = 8, sticky = "n,w", padx = 5, pady = 5)
self.MinimumProductsPerAminoAcid_Label = tk.Label(self.frame, text = "Minimum Products Per Amino Acid")
self.MinimumProductsPerAminoAcid_Label.grid(column = 3, row = 8, sticky = "n,w", padx = 5, pady = 5)
self.MinimumProductsPerAminoAcid_Entry.insert(0, 0)
#The minimum Consecutive Products Entry
self.MinimumConsecutiveProducts_Entry = tk.Entry(self.frame)
self.MinimumConsecutiveProducts_Entry.grid(column = 4, row = 9, sticky = "n,w", padx = 5, pady = 5)
self.MinimumConsecutiveProducts_Label = tk.Label(self.frame, text = "Minimum Consecutive Products")
self.MinimumConsecutiveProducts_Label.grid(column = 3, row = 9, sticky = "n,w", padx = 5, pady = 5)
self.MinimumConsecutiveProducts_Entry.insert(0, 0)
#The minimum int sum of indentified products
self.MinimumProdIntSum_Entry = tk.Entry(self.frame)
self.MinimumProdIntSum_Entry.grid(column = 4, row = 10, sticky = "n,w", padx = 5, pady = 5)
self.MinimumProdIntSum_Label = tk.Label(self.frame, text = "Minimum Sum for Identified Products")
self.MinimumProdIntSum_Label.grid(column = 3, row = 10, sticky = "n,w", padx = 5, pady = 5)
self.MinimumProdIntSum_Entry.insert(0, 0)
#The minimum score entry
self.MinimumScore_Entry = tk.Entry(self.frame)
self.MinimumScore_Entry.grid(column = 4, row = 11, sticky = "n,w", padx = 5, pady = 5)
self.MinimumScore_Label = tk.Label(self.frame, text = "Minimum Peptide Score")
self.MinimumScore_Label.grid(column = 3, row = 11, sticky = "n,w", padx = 5, pady = 5)
self.MinimumScore_Entry.insert(0, 0)
#The Number of identifications meeting filter criteria's Entry
self.NoOffReplicates_Entry = tk.Entry(self.frame)
self.NoOffReplicates_Entry.grid(column = 4, row = 12, sticky = "n,w", padx = 5, pady = 5)
self.NoOffReplicates_Label = tk.Label(self.frame, text = "Minimum Number of Replicates")
self.NoOffReplicates_Label.grid(column = 3, row = 12, sticky = "n,w", padx = 5, pady = 5)
self.NoOffReplicates_Entry.insert(0, 0)
# Score header
self.ScrMinimumIntensity_Entry = tk.Entry(self.frame)
self.ScrMinimumIntensity_Entry.grid(column = 5, row = 6, sticky = "n, e", padx = 5, pady = 5)
self.ScrMinimumIntensity_Entry.insert(0, 1000)
self.ScrMinimumProducts_Entry = tk.Entry(self.frame)
self.ScrMinimumProducts_Entry.grid(column = 5, row = 7, sticky = "n, e", padx = 5, pady = 5)
self.ScrMinimumProducts_Entry.insert(0, 2)
self.ScrMinimumProductsPerAminoAcid_Entry = tk.Entry(self.frame)
self.ScrMinimumProductsPerAminoAcid_Entry.grid(column = 5, row = 8, sticky = "n,e", padx = 5, pady = 5)
self.ScrMinimumProductsPerAminoAcid_Entry.insert(0, 0.15)
self.ScrMinimumConsecutiveProducts_Entry = tk.Entry(self.frame)
self.ScrMinimumConsecutiveProducts_Entry.grid(column = 5, row = 9, sticky = "n,e", padx = 5, pady = 5)
self.ScrMinimumConsecutiveProducts_Entry.insert(0, 1)
self.ScrMinimumProdIntSum_Entry = tk.Entry(self.frame)
self.ScrMinimumProdIntSum_Entry.grid(column = 5, row = 10, sticky = "n,e", padx = 5, pady = 5)
self.ScrMinimumProdIntSum_Entry.insert(0, 500)
self.ScrMinimumScore_Entry = tk.Entry(self.frame)
self.ScrMinimumScore_Entry.grid(column = 5, row = 11, sticky = "n,e", padx = 5, pady = 5)
self.ScrMinimumScore_Entry.insert(0, 6.4)
self.ScrNoOffReplicates_Entry = tk.Entry(self.frame)
self.ScrNoOffReplicates_Entry.grid(column = 5, row = 12, sticky = "n,e", padx = 5, pady = 5)
self.ScrNoOffReplicates_Entry.insert(0, 2)
#Score overview
self.ScrOvw_Header = tk.Label(self.frame,text = "Sequence Passes")
self.ScrOvw_Header.grid(column = 6, row = 5, sticky = "n, e", padx = 5, pady = 5)
self.ScrOvw_MinimumIntenstity=tk.Label(self.frame, text="Press Update")
self.ScrOvw_MinimumIntenstity.grid(column = 6, row = 6, sticky = "n, e", padx = 5, pady = 5)
self.ScrOvw_ScrMinimumProducts=tk.Label(self.frame, text="Press Update")
self.ScrOvw_ScrMinimumProducts.grid(column = 6, row = 7, sticky = "n, e", padx = 5, pady = 5)
self.ScrOvw_ScrMinimumProductsPerAminoAcid=tk.Label(self.frame, text="Press Update")
self.ScrOvw_ScrMinimumProductsPerAminoAcid.grid(column = 6, row = 8, sticky = "n, e", padx = 5, pady = 5)
self.ScrOvw_ScrMinimumConsecutiveProducts=tk.Label(self.frame, text="Press Update")
self.ScrOvw_ScrMinimumConsecutiveProducts.grid(column = 6, row = 9, sticky = "n, e", padx = 5, pady = 5)
self.ScrOvw_ScrMinimumProdIntSum=tk.Label(self.frame, text="Press Update")
self.ScrOvw_ScrMinimumProdIntSum.grid(column = 6, row = 10, sticky = "n, e", padx = 5, pady = 5)
self.ScrOvw_ScrMinimumScore=tk.Label(self.frame, text="Press Update")
self.ScrOvw_ScrMinimumScore.grid(column = 6, row = 11, sticky = "n, e", padx = 5, pady = 5)
self.ScrOvw_ScrNoOffReplicates=tk.Label(self.frame, text="Press Update")
self.ScrOvw_ScrNoOffReplicates.grid(column = 6, row = 12, sticky = "n, e", padx = 5, pady = 5)
#The minimum sequence score
self.MinSeqScr_Entry = tk.Entry(self.frame, width = 5)
self.MinSeqScr_Entry.grid(column = 1, row = 13, sticky = "n,w", padx = 5, pady = 5)
self.MinSeqScr_Label = tk.Label(self.frame, text = "The minimum sequence score (0-7)")
self.MinSeqScr_Label.grid(column = 0, row = 13, sticky = "n,w", padx = 5, pady = 5)
self.MinSeqScr_Entry.insert(0, 4)
createToolTip(self.MinSeqScr_Entry, "Set the lowest score that will be incorporated into the output files")
#Allowed RT SD
self.RT_SD_Entry = tk.Entry(self.frame, width = 5)
self.RT_SD_Entry.grid(column = 1, row = 14, sticky = "n,w", padx = 5, pady = 5)
self.RT_SD_Label = tk.Label(self.frame, text = "Maximum allowed RT SD")
self.RT_SD_Label.grid(column = 0, row = 14, sticky = "n,w", padx = 5, pady = 5)
self.RT_SD_Entry.insert(0, 0.5)
createToolTip(self.RT_SD_Entry, "Set the max standard deviation for the retention time for a peptide identification.\nFor peptides exceeding this, the user will be prompted to make a decision")
#Select a protein identifier
self.Protein_Identifier_Select = tk.Button(self.frame, text = "Select Protein Identifier" ,command = self.Select_Protein_identfier)
self.Protein_Identifier_Select.grid(column = 0, row = 11, sticky = "n,w", padx = 5, pady = 5 )
self.listbox_Protein_Identifier.bind('<Double-1>', lambda x: self.Protein_Identifier_Select.invoke())
def Dialog_insert(self, text):
"""
text --> text inserted in a dialogbox
This function is used to insert text into the dialogbox in the base GUI. The function works by unlocking the dialog box,
inserting the desired text and closes the box for further input
"""
Dialog.config(state=tk.NORMAL)
Dialog.insert(tk.END, text)
Dialog.see(tk.END)
Dialog.config(state=tk.DISABLED)
def Get(self):
"""
This functions purpose is to extract the values typed into the entry boxes, and make sure that
"""
#Block Start
#Gets the Protein Identifier from the entry box and Tests whether or not it can be used
global Prot_ident
Prot_ident = self.ProteinIdentifier_Entry.get()
if type(Prot_ident) is str:
pass
else:
self.Dialog_insert("The Protein identifier is not a string, use the select Protein Identifier window.\nRun aborted\n\n")
raise ValueError
#Block end
#Block Start
#Gets the cutoff minimum intensity from the entry box and Tests whether or not it can be used
global MinInt
s = self.MinimumIntensity_Entry.get()
try:
MinInt = int(s)
except:
self.Dialog_insert("The Cutoff minimun intensity is not an integer.\nIt should be a whole number like 1000.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the score minimum intensity from the entry box and Tests whether or not it can be used
global ScrMinInt
s = self.ScrMinimumIntensity_Entry.get()
try:
ScrMinInt = int(s)
except:
self.Dialog_insert("The Score minimun intensity is not an integer.\nIt should be a whole number like 1000.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the minimum seqeunce length from the entry box and Tests whether or it not can be used
global MinSeqLen
s = self.MinimumSequenceLength_Entry.get()
try:
MinSeqLen = int(s)
except:
self.Dialog_insert("The minimun sequence length is not an integer.\nIt should be a whole number like 7.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the maximum seqeunce length from the entry box and Tests whether or it not can be used
global MaxSeqLen
s = self.MaximumSequenceLength_Entry.get()
try:
MaxSeqLen = int(s)
except:
self.Dialog_insert("The maximum sequence length is not an integer.\nIt should be a whole number like 30.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the cutoff minimum product from the entry box and Tests whether or it not can be used
global MinProd
s = self.MinimumProducts_Entry.get()
try:
MinProd = int(s)
except:
self.Dialog_insert("The cutoff minimum product is not not an integer.\nIt should be a whole number like 1.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the Score minimum product from the entry box and Tests whether or it not can be used
global ScrMinProd
s = self.ScrMinimumProducts_Entry.get()
try:
ScrMinProd = int(s)
except:
self.Dialog_insert("The Score minimum product is not not a integer.\nIt should be a whole number like 1.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the cutoff minimum products per amino acid from the entry box and Tests whether or it not can be used
global MinProdPAA
s = self.MinimumProductsPerAminoAcid_Entry.get()
try:
MinProdPAA = float(s)
except:
self.Dialog_insert("The Cutoff minimum products per amino acid is not not a float.\nIt should be a whole number like 1 or a decimal like 1.2.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the score minimum products per amino acid from the entry box and Tests whether or it not can be used
global ScrMinProdPAA
s = self.ScrMinimumProductsPerAminoAcid_Entry.get()
try:
ScrMinProdPAA = float(s)
except:
self.Dialog_insert("The Score minimum products per amino acid is not not a float.\nIt should be a whole number like 1 or a decimal like 1.2.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the cutoff minimum consecutive products from the entry box and Tests whether or not it can be used
global MinConProd
s = self.MinimumConsecutiveProducts_Entry.get()
try:
MinConProd = int(s)
except:
self.Dialog_insert("The Cutoff mminimum consecutive products is not not an integer.\nIt should be a whole number like 1.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the Score minimum consecutive products from the entry box and Tests whether or not it can be used
global ScrMinConProd
s = self.ScrMinimumConsecutiveProducts_Entry.get()
try:
ScrMinConProd = int(s)
except:
self.Dialog_insert("The Score mminimum consecutive products is not not an integer.\nIt should be a whole number like 1.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the Cutoff minimum product sum intensity from the entry box and Tests whether or not it can be used
global MinProdSum
s= self.MinimumProdIntSum_Entry.get()
try:
MinProdSum = int(s)
except:
self.Dialog_insert("The Cutoff minimum product sum intensity is not not an integer.\nIt should be a whole number like 100.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the Score minimum product sum intensity from the entry box and Tests whether or not it can be used
global ScrMinProdSum
s= self.ScrMinimumProdIntSum_Entry.get()
try:
ScrMinProdSum = int(s)
except:
self.Dialog_insert("The Score minimum product sum intensity is not not an integer.\nIt should be a whole number like 100.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the Cutoff minimum peptide Score from the entry box and Tests whether or not it can be used
global MinScr
s = self.MinimumScore_Entry.get()
try:
MinScr = float(s)
except:
self.Dialog_insert("The Cutoff minimum peptide Score is not not a float.\nIt should be a whole number like 5 or a decimal like 5.4.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the Score minimum peptide Score from the entry box and Tests whether or not it can be used
global ScrMinScr
s = self.ScrMinimumScore_Entry.get()
try:
ScrMinScr = float(s)
except:
self.Dialog_insert("The Score minimum peptide Score is not not a float.\nIt should be a whole number like 5 or a decimal like 5.4.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the maximum mass error from the entry box and Tests whether or not it can be used
global MaxMHHErr
s = self.MaximumMHErrorPPM_Entry.get()
try:
MaxMHHErr = int(s)
except:
self.Dialog_insert("The maximum mass error is not not an integer.\nIt should be a whole number like 5.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the cutoff number of replicates from the entry box and Tests whether or not it can be used
global NoOffRep
s = self.NoOffReplicates_Entry.get()
try:
NoOffRep = int(s)
except:
self.Dialog_insert("The cutoff number of replicates is not not an integer.\nIt should be a whole number like 2.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the Score number of replicates from the entry box and Tests whether or not it can be used
global ScrNoOffRep
s = self.ScrNoOffReplicates_Entry.get()
try:
ScrNoOffRep = int(s)
except:
self.Dialog_insert("The Score number of replicates is not not an integer.\nIt should be a whole number like 2.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the Minimum sequence score from the entry box and Tests whether or not it can be used
global MinSeqScr
s = self.MinSeqScr_Entry.get()
try:
MinSeqScr = int(s)
except:
self.Dialog_insert("The Minimum sequence score is not not an integer.\nIt should be a whole number like 2.\nRun Aborted.\n\n")
raise ValueError
#Block end
#Block Start
#Gets the Allowed Standard deviation from the entry box and Tests whether or not it can be used
global Allowed_SD
s = self.RT_SD_Entry.get()
try:
Allowed_SD = float(s)
except:
self.Dialog_insert("The Allowed Standard deviation is not not an integer.\nIt should be a whole number like 2.\nRun Aborted.\n\n")
raise ValueError
Allowed_SD = float(s)
#Block end
def Pre_Process(self):
"""
This function allows for the pre determination of the sequence coverage at the different scores, the number of peptides identified and
the average amino acid redundancy.
"""
self.Get()
self.dict_to_be_sorted = {}
self.sorted_dict = {}
self.score_dict = {}
self.score_tracking_dict = {}
FunctionLibrary.csv_parser(self)
FunctionLibrary.csv_sorter(self)
FunctionLibrary.Score_counter(self)
FunctionLibrary.Score_sorter_pre_process(self)
self.changing_labels()
def changing_labels(self):
"""
Changes the labels of the scoring parameters in the score overview column
"""
keys = self.score_tracking_dict.keys()
seq_set = set()
for item in keys:
value = self.score_tracking_dict[item]
for ite in value:
seq_set.add(ite[0])
number_of_unique_sequences = len(seq_set)
for key in keys: ## Slow! Look at possible rework
value = self.score_tracking_dict[key]
value_len = len(value)
value_count = 0
for item in seq_set:
pass_count = 0
entry = 0
while entry < value_len:
if item == value[entry][0]:
if value[entry][1] == "pass":
pass_count += 1
else:
pass
else:
pass
entry += 1
if pass_count > 0:
value_count += 1
string = "{0} out of {1}".format(value_count, number_of_unique_sequences)
if key == 'MinInt':
self.ScrOvw_MinimumIntenstity.config(text = string)
elif key == 'MinProd':
self.ScrOvw_ScrMinimumProducts.config(text = string)
elif key == 'MinMinProdPAA':
self.ScrOvw_ScrMinimumProductsPerAminoAcid.config(text = string)
elif key == 'MinConProd':
self.ScrOvw_ScrMinimumConsecutiveProducts.config(text = string)
elif key == 'MinProdSum':
self.ScrOvw_ScrMinimumProdIntSum.config(text = string)
elif key == 'MinScr':
self.ScrOvw_ScrMinimumScore.config(text = string)
elif key == 'MinNoOffRep' :
self.ScrOvw_ScrNoOffReplicates.config(text = string)
else:
print("You done fuck'ed up buddy")
def Process(self):
"""
This function determines what happens when the Process button is pressed
When the Procces button is pressed the FunctionLibrary is called and the values typed into the boxes are stored
"""
self.Get()
FunctionLibrary()
def save(self):
"""
From the filemenu this function is initiated by pressing the save name in the dropdown menu
The user is prompted were to save the log file. The log file is given the default extension _log.txt
so it can, by deault, be found by the load function
The date and time for the creation of the file is written in and so is the values of all the entryboxes, furthermore the filelocation and keys
from the PLGS files is saved so they can be loaded in
"""
self.Get()
self.log_loc = tk.filedialog.asksaveasfilename(defaultextension = "_log.txt")
self.file_log = open(self.log_loc, 'w')
date_and_time = str(datetime.datetime.now())
self.file_log.write(date_and_time + "\n")
self.file_log.write("{0} | {1}\n".format("The Protein Identier was set to", self.ProteinIdentifier_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Cut-off Intensity was set to", self.MinimumIntensity_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Awarding Intensity was set to", self.ScrMinimumIntensity_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Cut-off Sequence Length was set to", self.MinimumSequenceLength_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Maximum Cut-off Sequence Length was set to", self.MaximumSequenceLength_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Cut-off number of Products was set to", self.MinimumProducts_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Awarding number of Products was set to", self.ScrMinimumProducts_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Cut-off number of Products Per Amino Acid was set to", self.MinimumProductsPerAminoAcid_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Awarding number of Products Per Amino Acid was set to", self.ScrMinimumProductsPerAminoAcid_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Cut-off number of Consecutive Products was set to", self.MinimumConsecutiveProducts_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Awarding number of Consecutive Products was set to", self.ScrMinimumConsecutiveProducts_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Cut-off intensity sum for the identified products was set to", self.MinimumProdIntSum_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Awarding intensity sum for the identified products was set to", self.ScrMinimumProdIntSum_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Cut-off peptide Score was set to", self.MinimumScore_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Awarding peptide Score was set to", self.ScrMinimumScore_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Cut-off Mass delta Error was set to", self.MaximumMHErrorPPM_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Cut-off number of replicates was set to", self.NoOffReplicates_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum point awarding number of replicates was set to", self.ScrNoOffReplicates_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The Minimum Sequence score was set to",self.MinSeqScr_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The allowed SD was set to", self.RT_SD_Entry.get()))
self.file_log.write("{0} | {1}\n".format("The number of PLGS files loaded were",len(filelocation_list)))
for item in filelocation_list:
self.file_log.write("{0}\n".format(item))
for item in key_list:
self.file_log.write("{0}\n".format(item))
self.file_log.close()
def load(self):
"""
From the filemenu this function is initiated by pressing the load name in the dropdown menu
The askopenfile dialog asks for the a file with the _log.txt extension, since this will ensure a corret file format is being loaded
The values from the entry boxes are first cleared and then the value from the log file is inserted, furthermore the PLGS locations and keys
are loaded in
"""
self.listbox_PLGS.delete(0,"end")
filelocation_list.clear()
key_list.clear()
file_load = tk.filedialog.askopenfile(filetypes =[("txt", "_log.txt"),('All files','*.*')])
Regular_expression = re.compile("\w.+was set to.+ (\w.*)")
Regular_expression2 = re.compile("\w.+loaded were.+ (\w.*)")
lines = file_load.readlines()
lines_clean = []
for item in lines:
clean = item.strip('\n')
lines_clean.append(clean)
# Protein identifier
match = re.match(Regular_expression, lines_clean[1])
Load_value = match.group(1)
self.ProteinIdentifier_Entry.delete(0, tk.END)
self.ProteinIdentifier_Entry.insert(0, Load_value)
# Minimum intensity
match = re.match(Regular_expression, lines_clean[2])
Load_value = match.group(1)
self.MinimumIntensity_Entry.delete(0, tk.END)
self.MinimumIntensity_Entry.insert(0, Load_value)
# Minimum Score Intensity
match = re.match(Regular_expression, lines_clean[3])
Load_value = match.group(1)
self.ScrMinimumIntensity_Entry.delete(0, tk.END)
self.ScrMinimumIntensity_Entry.insert(0, Load_value)
# Minimum sequence length
match = re.match(Regular_expression, lines_clean[4])
Load_value = match.group(1)
self.MinimumSequenceLength_Entry.delete(0, tk.END)
self.MinimumSequenceLength_Entry.insert(0, Load_value)
# Maximum sequence length
match = re.match(Regular_expression, lines_clean[5])
Load_value = match.group(1)
self.MaximumSequenceLength_Entry.delete(0, tk.END)
self.MaximumSequenceLength_Entry.insert(0, Load_value)
# Minimum number of products
match = re.match(Regular_expression, lines_clean[6])
Load_value = match.group(1)
self.MinimumProducts_Entry.delete(0, tk.END)
self.MinimumProducts_Entry.insert(0, Load_value)
# Minimum Scoring number of products
match = re.match(Regular_expression, lines_clean[7])
Load_value = match.group(1)
self.ScrMinimumProducts_Entry.delete(0, tk.END)
self.ScrMinimumProducts_Entry.insert(0, Load_value)
# Minimum products per amino acid
match = re.match(Regular_expression, lines_clean[8])
Load_value = match.group(1)
self.MinimumProductsPerAminoAcid_Entry.delete(0, tk.END)
self.MinimumProductsPerAminoAcid_Entry.insert(0, Load_value)
# Minimum Scoring products per amino acid
match = re.match(Regular_expression, lines_clean[9])
Load_value = match.group(1)
self.ScrMinimumProductsPerAminoAcid_Entry.delete(0, tk.END)
self.ScrMinimumProductsPerAminoAcid_Entry.insert(0, Load_value)
# Minimum number of consecutive products
match = re.match(Regular_expression, lines_clean[10])
Load_value = match.group(1)
self.MinimumConsecutiveProducts_Entry.delete(0, tk.END)
self.MinimumConsecutiveProducts_Entry.insert(0, Load_value)
# Minimum Scoring number of consecutive products
match = re.match(Regular_expression, lines_clean[11])
Load_value = match.group(1)
self.ScrMinimumConsecutiveProducts_Entry.delete(0, tk.END)
self.ScrMinimumConsecutiveProducts_Entry.insert(0, Load_value)
# Minimum intensity sum for identified products
match = re.match(Regular_expression, lines_clean[12])
Load_value = match.group(1)
self.MinimumProdIntSum_Entry.delete(0, tk.END)
self.MinimumProdIntSum_Entry.insert(0, Load_value)
# Minimum Score intensity sum for identified products
match = re.match(Regular_expression, lines_clean[13])
Load_value = match.group(1)
self.ScrMinimumProdIntSum_Entry.delete(0, tk.END)
self.ScrMinimumProdIntSum_Entry.insert(0, Load_value)
# Minimum peptide Score
match = re.match(Regular_expression, lines_clean[14])
Load_value = match.group(1)
self.MinimumScore_Entry.delete(0, tk.END)
self.MinimumScore_Entry.insert(0, Load_value)
# Minimum scoring Score
match = re.match(Regular_expression, lines_clean[15])
Load_value = match.group(1)
self.ScrMinimumScore_Entry.delete(0, tk.END)
self.ScrMinimumScore_Entry.insert(0, Load_value)
# Maximum Mass delta error
match = re.match(Regular_expression, lines_clean[16])
Load_value = match.group(1)
self.MaximumMHErrorPPM_Entry.delete(0, tk.END)
self.MaximumMHErrorPPM_Entry.insert(0, Load_value)
# The minimum number of identifications that meet the sorting criterias
match = re.match(Regular_expression, lines_clean[17])
Load_value = match.group(1)
self.NoOffReplicates_Entry.delete(0, tk.END)
self.NoOffReplicates_Entry.insert(0, Load_value)
# The minimum number of identifications that meet the sorting criterias
match = re.match(Regular_expression, lines_clean[18])
Load_value = match.group(1)
self.ScrNoOffReplicates_Entry.delete(0, tk.END)
self.ScrNoOffReplicates_Entry.insert(0, Load_value)
# The minimum number of identifications
match = re.match(Regular_expression, lines_clean[19])
Load_value = match.group(1)
self.MinSeqScr_Entry.delete(0, tk.END)
self.MinSeqScr_Entry.insert(0, Load_value)
# SD cutoff limit
match = re.match(Regular_expression, lines_clean[20])
Load_value = match.group(1)
self.RT_SD_Entry.delete(0, tk.END)
self.RT_SD_Entry.insert(0, Load_value)
# Use of the pepsin cleavage rules
Number_of_files_id = re.match(Regular_expression2, lines_clean[21])
Number_of_files = int(Number_of_files_id.group(1))
if Number_of_files == 0:
pass
else:
line_counter = 22
end_line = line_counter + Number_of_files
while line_counter < end_line:
filelocation_list.append(lines_clean[line_counter])
line_counter += 1
end_line = end_line + Number_of_files
while line_counter < end_line:
key_list.append(lines_clean[line_counter])
self.listbox_PLGS.insert(tk.END, lines_clean[line_counter])
line_counter += 1
file_load.close()
def About(self):
"""
.txt file --> tkinter messagebox
At this stage in the development the .txt file is hardcoded in. This will lead to an issue when
the program is used on a different system
This functions dictate the the content of the about button in the menubar information.
The function is actived from the menubar --> Information --> About
"""
about_txt = open('About.txt', 'r')
about = about_txt.readlines()
message = ''
for item in about:
message += item
self.messagebox = messagebox.showinfo(title = "About", message = message)
def Add_PLGS(self):
"""
This function adds a PLGS file into the listbox defined in the __init__ function.
The loaded filelocation is changed into a normpath so it can be used in the .csv parser in
the FunctionLibrary Class
The filelocation is furthermore changed into a norm_path to make regular expression possible.
From the norm_path the characters between the \ and _IA_final_peptide.csv will be the name
that shows up in the listbox. This string sequence is also used as a key in the csv_parser
"""
Regular_expression = re.compile('(\w.*)(_IA_final_peptide.csv)')
filelocation = tk.filedialog.askopenfilename(filetypes =[("csv","_IA_final_peptide.csv"), ('All files','*.*')])
if filelocation == '':
self.Dialog_insert("No ion accounting file was added file was added")# Used to inform the user and prevent an error message
else:
#This block changes the working directory so the user will have fewer folders to press to load their files
dir_list = filelocation.split('/')
working_dict = ''
for item in dir_list[:-2]:
if item == dir_list[-3]:
working_dict += item
else:
working_dict += "{0}/".format(item)
os.chdir(working_dict)
#Block end
#This block saves the file path into the list that is used both in the save file and in the processing functions
path = os.path.normpath(filelocation)
filelocation_list.append(path)
elements_list = path.split('\\')
pre_filename = elements_list[-1]
match = re.match(Regular_expression, pre_filename)
filename = match.group(1)
key_list.append(filename)
self.listbox_PLGS.insert(tk.END, filename)
#Block end
# In this block the file is read and Protein Identifiers are pulled out
self.dict_to_be_sorted = {}
FunctionLibrary.csv_parser(self)
for item in protein_identifiers:
if item in added_identifiers:
pass
else:
self.listbox_Protein_Identifier.insert(tk.END, item)
added_identifiers.add(item)
def Delete_PLGS(self):
"""
This function is used when the Delete PLGS button is pushed
This function deletes the PLGS entry from the listbox, filelocation list and key list
"""
pre_index = self.listbox_PLGS.curselection()
index = int(pre_index[0])
filelocation_list.pop(index)
key_list.pop(index)
self.listbox_PLGS.delete(index)
def Select_Protein_identfier(self):
"""
This function allows the user to select the desired protein identfier
"""
pre_index = self.listbox_Protein_Identifier.curselection()
index = int(pre_index[0])
identifier = str(protein_identifiers[index])
self.ProteinIdentifier_Entry.delete(0, tk.END)
self.ProteinIdentifier_Entry.insert(0, string = identifier)