Repository navigation
Expand file tree
/
Copy pathSCOPE_GUI.py
More file actions
3286 lines (2917 loc) · 146 KB
/
Copy pathSCOPE_GUI.py
File metadata and controls
3286 lines (2917 loc) · 146 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
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1200, 800)
# Allow smaller minimum window size for vertical resizing
MainWindow.setMinimumSize(QtCore.QSize(600, 400))
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout_19 = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout_19.setObjectName("verticalLayout_19")
self.verticalLayout_utilres_status = QtWidgets.QVBoxLayout()
self.verticalLayout_utilres_status.setObjectName("verticalLayout_utilres_status")
self.horizontalLayout_utils_res = QtWidgets.QHBoxLayout()
self.horizontalLayout_utils_res.setObjectName("horizontalLayout_utils_res")
self.verticalLayout_utils = QtWidgets.QVBoxLayout()
self.verticalLayout_utils.setObjectName("verticalLayout_utils")
self.groupBox_input = QtWidgets.QGroupBox(self.centralwidget)
self.groupBox_input.setObjectName("groupBox_input")
self.verticalLayout = QtWidgets.QVBoxLayout(self.groupBox_input)
self.verticalLayout.setObjectName("verticalLayout")
# Direct file selection row inside input group (remove Upload File tab)
self.horizontalLayout_file = QtWidgets.QHBoxLayout()
self.horizontalLayout_file.setObjectName("horizontalLayout_file")
self.filename = QtWidgets.QLineEdit(self.groupBox_input)
self.filename.setObjectName("filename")
self.horizontalLayout_file.addWidget(self.filename)
self.pushButton_select_file = QtWidgets.QPushButton(self.groupBox_input)
self.pushButton_select_file.setObjectName("pushButton_select_file")
self.horizontalLayout_file.addWidget(self.pushButton_select_file)
self.verticalLayout.addLayout(self.horizontalLayout_file)
self.horizontalLayout_fasta = QtWidgets.QHBoxLayout()
self.horizontalLayout_fasta.setObjectName("horizontalLayout_fasta")
self.filename_fasta = QtWidgets.QLineEdit(self.groupBox_input)
self.filename_fasta.setObjectName("filename_fasta")
self.horizontalLayout_fasta.addWidget(self.filename_fasta)
self.pushButton_select_fasta = QtWidgets.QPushButton(self.groupBox_input)
self.pushButton_select_fasta.setObjectName("pushButton_select_fasta")
self.horizontalLayout_fasta.addWidget(self.pushButton_select_fasta)
self.verticalLayout.addLayout(self.horizontalLayout_fasta)
self.verticalLayout_utils.addWidget(self.groupBox_input)
# Step 1: feature extraction
self.groupBox_feature_extract = QtWidgets.QGroupBox(self.centralwidget)
self.groupBox_feature_extract.setObjectName("groupBox_feature_extract")
self.verticalLayout_feature = QtWidgets.QVBoxLayout(self.groupBox_feature_extract)
self.verticalLayout_feature.setObjectName("verticalLayout_feature")
self.widget_feature_body = QtWidgets.QWidget(self.groupBox_feature_extract)
self.widget_feature_body.setObjectName("widget_feature_body")
self.verticalLayout_feature_body = QtWidgets.QVBoxLayout(self.widget_feature_body)
self.verticalLayout_feature_body.setObjectName("verticalLayout_feature_body")
self.label_feature = QtWidgets.QLabel(self.widget_feature_body)
self.label_feature.setWordWrap(True)
self.label_feature.setObjectName("label_feature")
self.verticalLayout_feature_body.addWidget(self.label_feature)
self.button_extract_features = QtWidgets.QPushButton(self.widget_feature_body)
self.button_extract_features.setObjectName("button_extract_features")
self.verticalLayout_feature_body.addWidget(self.button_extract_features)
self.verticalLayout_feature.addWidget(self.widget_feature_body)
self.label_feature_hint = QtWidgets.QLabel(self.groupBox_feature_extract)
self.label_feature_hint.setObjectName("label_feature_hint")
self.label_feature_hint.setWordWrap(True)
self.verticalLayout_feature.addWidget(self.label_feature_hint)
self.verticalLayout_utils.addWidget(self.groupBox_feature_extract)
# Step 2: catalytic-site prediction (description panel)
self.groupBox_catalytic = QtWidgets.QGroupBox(self.centralwidget)
self.groupBox_catalytic.setObjectName("groupBox_catalytic")
self.verticalLayout_catalytic = QtWidgets.QVBoxLayout(self.groupBox_catalytic)
self.verticalLayout_catalytic.setObjectName("verticalLayout_catalytic")
self.widget_catalytic_body = QtWidgets.QWidget(self.groupBox_catalytic)
self.widget_catalytic_body.setObjectName("widget_catalytic_body")
self.verticalLayout_catalytic_body = QtWidgets.QVBoxLayout(self.widget_catalytic_body)
self.verticalLayout_catalytic_body.setObjectName("verticalLayout_catalytic_body")
self.label_catalytic = QtWidgets.QLabel(self.widget_catalytic_body)
self.label_catalytic.setWordWrap(True)
self.label_catalytic.setObjectName("label_catalytic")
self.verticalLayout_catalytic_body.addWidget(self.label_catalytic)
self.verticalLayout_catalytic.addWidget(self.widget_catalytic_body)
self.label_catalytic_hint = QtWidgets.QLabel(self.groupBox_catalytic)
self.label_catalytic_hint.setObjectName("label_catalytic_hint")
self.label_catalytic_hint.setWordWrap(True)
self.verticalLayout_catalytic.addWidget(self.label_catalytic_hint)
self.verticalLayout_utils.addWidget(self.groupBox_catalytic)
self.groupBox_parameters = QtWidgets.QGroupBox(self.centralwidget)
self.groupBox_parameters.setObjectName("groupBox_parameters")
# Collapsible body inside parameters group
self.verticalLayout_params_group = QtWidgets.QVBoxLayout(self.groupBox_parameters)
self.verticalLayout_params_group.setObjectName("verticalLayout_params_group")
self.widget_parameters_body = QtWidgets.QWidget(self.groupBox_parameters)
self.widget_parameters_body.setObjectName("widget_parameters_body")
self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.widget_parameters_body)
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
self.verticalLayout_7 = QtWidgets.QVBoxLayout()
self.verticalLayout_7.setObjectName("verticalLayout_7")
self.label_5 = QtWidgets.QLabel(self.groupBox_parameters)
self.label_5.setObjectName("label_5")
self.verticalLayout_7.addWidget(self.label_5)
self.label_6 = QtWidgets.QLabel(self.groupBox_parameters)
self.label_6.setObjectName("label_6")
self.verticalLayout_7.addWidget(self.label_6)
self.horizontalLayout_6.addLayout(self.verticalLayout_7)
self.verticalLayout_8 = QtWidgets.QVBoxLayout()
self.verticalLayout_8.setObjectName("verticalLayout_8")
self.LineEdit_num_workers = QtWidgets.QLineEdit(self.groupBox_parameters)
self.LineEdit_num_workers.setObjectName("LineEdit_num_workers")
self.LineEdit_num_workers.setText("1")
self.verticalLayout_8.addWidget(self.LineEdit_num_workers)
self.LineEdit_chain = QtWidgets.QLineEdit(self.groupBox_parameters)
self.LineEdit_chain.setObjectName("LineEdit_chain")
self.LineEdit_chain.setText("A")
self.verticalLayout_8.addWidget(self.LineEdit_chain)
self.horizontalLayout_6.addLayout(self.verticalLayout_8)
# Add parameters body to group
self.verticalLayout_params_group.addWidget(self.widget_parameters_body)
self.verticalLayout_utils.addWidget(self.groupBox_parameters)
self.groupBox_operator = QtWidgets.QGroupBox(self.centralwidget)
self.groupBox_operator.setObjectName("groupBox_operator")
self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.groupBox_operator)
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.button_predict = QtWidgets.QPushButton(self.groupBox_operator)
self.button_predict.setObjectName("button_predict")
self.horizontalLayout_4.addWidget(self.button_predict)
self.buttonn_save = QtWidgets.QPushButton(self.groupBox_operator)
self.buttonn_save.setObjectName("buttonn_save")
self.horizontalLayout_4.addWidget(self.buttonn_save)
self.buttonn_clean = QtWidgets.QPushButton(self.groupBox_operator)
self.buttonn_clean.setObjectName("buttonn_clean")
self.horizontalLayout_4.addWidget(self.buttonn_clean)
self.button_load_result = QtWidgets.QPushButton(self.groupBox_operator)
self.button_load_result.setObjectName("button_load_result")
self.horizontalLayout_4.addWidget(self.button_load_result)
self.horizontalLayout_5.addLayout(self.horizontalLayout_4)
self.verticalLayout_utils.addWidget(self.groupBox_operator)
self.verticalLayout_utils.setStretch(0, 2)
self.verticalLayout_utils.setStretch(1, 6)
self.verticalLayout_utils.setStretch(2, 1)
self.verticalLayout_utils.setStretch(3, 1)
self.horizontalLayout_utils_res.addLayout(self.verticalLayout_utils)
self.Tab_res = QtWidgets.QTabWidget(self.centralwidget)
self.Tab_res.setObjectName("Tab_res")
self.tab_meloculesdata = QtWidgets.QWidget()
self.tab_meloculesdata.setObjectName("tab_meloculesdata")
self.verticalLayout_20 = QtWidgets.QVBoxLayout(self.tab_meloculesdata)
self.verticalLayout_20.setObjectName("verticalLayout_20")
self.Tab_res.addTab(self.tab_meloculesdata, "")
self.horizontalLayout_utils_res.addWidget(self.Tab_res)
self.horizontalLayout_utils_res.setStretch(0, 4)
self.horizontalLayout_utils_res.setStretch(1, 6)
self.verticalLayout_utilres_status.addLayout(self.horizontalLayout_utils_res)
# Status area restored with titled group box
self.groupBox_status = QtWidgets.QGroupBox(self.centralwidget)
self.groupBox_status.setObjectName("groupBox_status")
self.verticalLayout_9 = QtWidgets.QVBoxLayout(self.groupBox_status)
self.verticalLayout_9.setObjectName("verticalLayout_9")
self.textBrowser_status = QtWidgets.QTextBrowser(self.groupBox_status)
self.textBrowser_status.setObjectName("textBrowser_status")
try:
self.groupBox_status.setMaximumHeight(90)
self.textBrowser_status.setMaximumHeight(30)
except Exception:
pass
self.verticalLayout_9.addWidget(self.textBrowser_status)
self.verticalLayout_utilres_status.addWidget(self.groupBox_status)
self.verticalLayout_utilres_status.setStretch(0, 9)
self.verticalLayout_utilres_status.setStretch(1, 1)
self.verticalLayout_19.addLayout(self.verticalLayout_utilres_status)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1614, 23))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.retranslateUi(MainWindow)
self.Tab_res.setCurrentIndex(0)
self.button_predict.clicked.connect(MainWindow.predict) # type: ignore
self.button_extract_features.clicked.connect(MainWindow.extractScopeFeatures) # type: ignore
self.buttonn_save.clicked.connect(MainWindow.getSavePath)
self.buttonn_clean.clicked.connect(MainWindow.clean)
self.button_load_result.clicked.connect(MainWindow.loadResultFile) # type: ignore
self.pushButton_select_file.clicked.connect(MainWindow.selectFile) # type: ignore
self.pushButton_select_fasta.clicked.connect(MainWindow.selectFastaFile) # type: ignore
self.LineEdit_chain.textChanged.connect(MainWindow.validate_chain_input)
self.LineEdit_num_workers.textChanged.connect(MainWindow.validate_num_workers_input)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "SCOPE — Catalytic Site Prediction"))
self.groupBox_input.setTitle(_translate("MainWindow", "Input: FASTA and PDB"))
self.pushButton_select_file.setText(_translate("MainWindow", "Select PDB"))
self.filename_fasta.setPlaceholderText(
_translate("MainWindow", "Required for catalytic prediction; header protein ID (e.g. >1chu-A)")
)
self.pushButton_select_fasta.setText(_translate("MainWindow", "Select FASTA"))
self.groupBox_feature_extract.setTitle(_translate("MainWindow", "Step 1: Feature extraction"))
self.label_feature.setText(
_translate(
"MainWindow",
"Select FASTA and PDB above, then extract and cache features (PSSM, DSSP, ProtT5, etc.; may take long).",
)
)
self.button_extract_features.setText(_translate("MainWindow", "Extract features"))
self.label_feature_hint.setText(
_translate("MainWindow", "Do not run Predict until feature extraction is done.")
)
self.groupBox_catalytic.setTitle(_translate("MainWindow", "Step 2: Catalytic site prediction"))
self.label_catalytic.setText(
_translate(
"MainWindow",
"Complete Step 1 first. Predict below loads cached features and runs inference only.",
)
)
self.label_catalytic_hint.setText(
_translate("MainWindow", "Use together with Step 1 after features are ready.")
)
# Step 1 / Step 2:始终展开,不折叠
try:
self.widget_feature_body.setVisible(True)
self.widget_catalytic_body.setVisible(True)
self.label_feature_hint.setVisible(False)
self.label_catalytic_hint.setVisible(False)
except Exception:
pass
try:
self.groupBox_parameters.mousePressEvent = lambda e: self._toggle_group_body(self.widget_parameters_body)
except Exception:
pass
self.groupBox_parameters.setTitle(_translate("MainWindow", "Paramenters"))
self.label_5.setText(_translate("MainWindow", "Num_workers:"))
self.label_6.setText(_translate("MainWindow", "Chain (A/B/...):"))
self.groupBox_operator.setTitle(_translate("MainWindow", "Operator"))
self.button_predict.setText(_translate("MainWindow", "Predict"))
self.buttonn_save.setText(_translate("MainWindow", "Save results"))
self.buttonn_clean.setText(_translate("MainWindow", "Clean"))
self.button_load_result.setText(_translate("MainWindow", "Load result file"))
# Results group removed; tabs are placed directly
self.Tab_res.setTabText(self.Tab_res.indexOf(self.tab_meloculesdata), _translate("MainWindow", "Prediction"))
self.groupBox_status.setTitle(_translate("MainWindow", "Status"))
def show_tabSon_meloculesdata(self):
# 重建嵌套 Tab 时丢弃旧的 Plot 页引用,避免指向已删除的 Qt 对象
for _plot_attr in (
"lineEdit_threshold",
"label_threshold",
"button_update_network",
"horizontalLayout_threshold",
"verticalLayout_tab_summaryplot",
"tabItem_plot",
"frame_plot",
"label_plot",
):
if hasattr(self, _plot_attr):
setattr(self, _plot_attr, None)
self.tabSon_meloculesdata = QtWidgets.QTabWidget(self.tab_meloculesdata)
self.tabSon_meloculesdata.setObjectName("tabSon_meloculesdata")
self.tabItem_alldata = QtWidgets.QWidget()
self.tabItem_alldata.setObjectName("tabItem_alldata")
self.verticalLayout_12 = QtWidgets.QVBoxLayout(self.tabItem_alldata)
self.verticalLayout_12.setObjectName("verticalLayout_12")
self.table_alldata = QtWidgets.QTableWidget(self.tabItem_alldata)
self.table_alldata.setObjectName("table_alldata")
self.verticalLayout_12.addWidget(self.table_alldata)
self.tabSon_meloculesdata.addTab(self.tabItem_alldata, "Results")
# self.tabItem_singlemelocule = QtWidgets.QWidget()
# self.tabItem_singlemelocule.setObjectName("tabItem_singlemelocule")
# self.verticalLayout_21 = QtWidgets.QVBoxLayout(self.tabItem_singlemelocule)
# self.verticalLayout_21.setObjectName("verticalLayout_21")
# self.label_selectmelocule = QtWidgets.QLabel(self.tabItem_singlemelocule)
# self.label_selectmelocule.setObjectName("label_selectmelocule")
# self.verticalLayout_21.addWidget(self.label_selectmelocule)
# self.label_selectmelocule.setText("Select Melocule by Id")
# self.comboBox_selectMelocule = QtWidgets.QComboBox(self.tabItem_singlemelocule)
# self.comboBox_selectMelocule.setObjectName("comboBox_selectMelocule")
# self.verticalLayout_21.addWidget(self.comboBox_selectMelocule)
# self.scrollArea_single = QtWidgets.QScrollArea(self.tabItem_singlemelocule)
# self.scrollArea_single.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
# self.scrollArea_single.setWidgetResizable(True)
# self.scrollArea_single.setObjectName("scrollArea_single")
self.scrollAreaWidgetContents_single = QtWidgets.QWidget()
# self.scrollAreaWidgetContents_single.setGeometry(QtCore.QRect(0, 0, 867, 849))
self.scrollAreaWidgetContents_single.setObjectName("scrollAreaWidgetContents_single")
self.verticalLayout_14 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents_single)
self.verticalLayout_14.setObjectName("verticalLayout_14")
# self.frame_image = QtWidgets.QFrame(self.scrollAreaWidgetContents_single)
# self.frame_image.setFrameShape(QtWidgets.QFrame.StyledPanel)
# self.frame_image.setFrameShadow(QtWidgets.QFrame.Raised)
# self.frame_image.setObjectName("frame_image")
# self.horizontalLayout_22 = QtWidgets.QVBoxLayout(self.frame_image)
# self.horizontalLayout_22.setObjectName("verticalLayout_22")
# self.label_image = QtWidgets.QLabel(self.frame_image)
# self.label_image.setObjectName("label_image")
# self.horizontalLayout_22.addWidget(self.label_image)
# self.verticalLayout_14.addWidget(self.frame_image)
self.frame_image = QtWidgets.QFrame(self.scrollAreaWidgetContents_single)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.frame_image.sizePolicy().hasHeightForWidth())
self.frame_image.setSizePolicy(sizePolicy)
self.frame_image.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_image.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_image.setObjectName("frame_image")
self.horizontalLayout_11 = QtWidgets.QHBoxLayout(self.frame_image)
self.horizontalLayout_11.setObjectName("horizontalLayout_11")
self.horizontalLayout_10 = QtWidgets.QHBoxLayout()
self.horizontalLayout_10.setObjectName("horizontalLayout_10")
self.label_image_1 = QtWidgets.QLabel(self.frame_image)
self.label_image_1.setObjectName("label_image_1")
self.label_image_1.setScaledContents(True)
self.label_image_1.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
self.horizontalLayout_10.addWidget(self.label_image_1)
self.label_image_2 = QtWidgets.QLabel(self.frame_image)
self.label_image_2.setObjectName("label_image_2")
self.label_image_2.setScaledContents(True)
self.label_image_2.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
self.horizontalLayout_10.addWidget(self.label_image_2)
self.horizontalLayout_10.setStretch(0, 5)
self.horizontalLayout_10.setStretch(1, 5)
self.horizontalLayout_11.addLayout(self.horizontalLayout_10)
self.verticalLayout_14.addWidget(self.frame_image)
self.horizontalLayout_7 = QtWidgets.QHBoxLayout()
self.horizontalLayout_7.setObjectName("horizontalLayout_7")
self.frame_PhyChe = QtWidgets.QFrame(self.scrollAreaWidgetContents_single)
self.frame_PhyChe.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_PhyChe.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_PhyChe.setObjectName("frame_PhyChe")
self.verticalLayout_13 = QtWidgets.QVBoxLayout(self.frame_PhyChe)
self.verticalLayout_13.setObjectName("verticalLayout_13")
self.label_phyche = QtWidgets.QLabel(self.frame_PhyChe)
self.label_phyche.setObjectName("label_phyche")
self.label_phyche.setText("Physicochemical")
self.verticalLayout_13.addWidget(self.label_phyche)
self.table_Phyche = QtWidgets.QTableWidget(self.frame_PhyChe)
self.table_Phyche.setObjectName("table_Phyche")
self.verticalLayout_13.addWidget(self.table_Phyche)
self.horizontalLayout_7.addWidget(self.frame_PhyChe)
self.frame_absorption = QtWidgets.QFrame(self.scrollAreaWidgetContents_single)
self.frame_absorption.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_absorption.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_absorption.setObjectName("frame_absorption")
self.verticalLayout_15 = QtWidgets.QVBoxLayout(self.frame_absorption)
self.verticalLayout_15.setObjectName("verticalLayout_15")
self.label_absorption = QtWidgets.QLabel(self.frame_absorption)
self.label_absorption.setObjectName("label_absorption")
self.label_absorption.setText("Absorption")
self.verticalLayout_15.addWidget(self.label_absorption)
self.table__absorption = QtWidgets.QTableWidget(self.frame_absorption)
self.table__absorption.setObjectName("table__absorption")
self.verticalLayout_15.addWidget(self.table__absorption)
self.horizontalLayout_7.addWidget(self.frame_absorption)
self.frame_distribution = QtWidgets.QFrame(self.scrollAreaWidgetContents_single)
self.frame_distribution.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_distribution.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_distribution.setObjectName("frame_distribution")
self.verticalLayout_frame_distribution = QtWidgets.QVBoxLayout(self.frame_distribution)
self.verticalLayout_frame_distribution.setObjectName("verticalLayout_frame_distribution")
self.label_distribution = QtWidgets.QLabel(self.frame_distribution)
self.label_distribution.setObjectName("label_distribution")
self.verticalLayout_frame_distribution.addWidget(self.label_distribution)
self.label_distribution.setText("Distribution")
self.table_distribution = QtWidgets.QTableWidget(self.frame_distribution)
self.table_distribution.setObjectName("table_distribution")
self.verticalLayout_frame_distribution.addWidget(self.table_distribution)
self.horizontalLayout_7.addWidget(self.frame_distribution)
self.verticalLayout_14.addLayout(self.horizontalLayout_7)
self.horizontalLayout_9 = QtWidgets.QHBoxLayout()
self.horizontalLayout_9.setObjectName("horizontalLayout_9")
self.frame_metabolism = QtWidgets.QFrame(self.scrollAreaWidgetContents_single)
self.frame_metabolism.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_metabolism.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_metabolism.setObjectName("frame_metabolism")
self.verticalLayout_16 = QtWidgets.QVBoxLayout(self.frame_metabolism)
self.verticalLayout_16.setObjectName("verticalLayout_16")
self.label_metabolism = QtWidgets.QLabel(self.frame_metabolism)
self.label_metabolism.setObjectName("label_metabolism")
self.verticalLayout_16.addWidget(self.label_metabolism)
self.label_metabolism.setText("Metabolism")
self.table_metabolism = QtWidgets.QTableWidget(self.frame_metabolism)
self.table_metabolism.setObjectName("table_metabolism")
self.verticalLayout_16.addWidget(self.table_metabolism)
self.horizontalLayout_9.addWidget(self.frame_metabolism)
self.frame_excretion = QtWidgets.QFrame(self.scrollAreaWidgetContents_single)
self.frame_excretion.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_excretion.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_excretion.setObjectName("frame_excretion")
self.verticalLayout_18 = QtWidgets.QVBoxLayout(self.frame_excretion)
self.verticalLayout_18.setObjectName("verticalLayout_18")
self.label_excretion = QtWidgets.QLabel(self.frame_excretion)
self.label_excretion.setObjectName("label_excretion")
self.label_excretion.setText("Excretion")
self.verticalLayout_18.addWidget(self.label_excretion)
self.table_excretion = QtWidgets.QTableWidget(self.frame_excretion)
self.table_excretion.setObjectName("table_excretion")
self.verticalLayout_18.addWidget(self.table_excretion)
self.horizontalLayout_9.addWidget(self.frame_excretion)
self.frame_toxicity = QtWidgets.QFrame(self.scrollAreaWidgetContents_single)
self.frame_toxicity.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_toxicity.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_toxicity.setObjectName("frame_toxicity")
self.verticalLayout_17 = QtWidgets.QVBoxLayout(self.frame_toxicity)
self.verticalLayout_17.setObjectName("verticalLayout_17")
self.label_toxicity = QtWidgets.QLabel(self.frame_toxicity)
self.label_toxicity.setObjectName("label_toxicity")
self.verticalLayout_17.addWidget(self.label_toxicity)
self.label_toxicity.setText("Toxicity")
self.table_toxicity = QtWidgets.QTableWidget(self.frame_toxicity)
self.table_toxicity.setObjectName("table_toxicity")
self.verticalLayout_17.addWidget(self.table_toxicity)
self.horizontalLayout_9.addWidget(self.frame_toxicity)
self.verticalLayout_14.addLayout(self.horizontalLayout_9)
self.verticalLayout_14.setStretch(0, 9)
self.verticalLayout_14.setStretch(1, 10)
self.verticalLayout_14.setStretch(2, 10)
# self.tabSon_meloculesdata.addTab(self.tabItem_singlemelocule, "Single Melocule")
self.verticalLayout_20.addWidget(self.tabSon_meloculesdata)
# self.comboBox_selectMelocule.currentTextChanged.connect(self.show_single_melocule)
self.table_Phyche.resizeColumnsToContents()
self.table__absorption.resizeColumnsToContents()
self.table_distribution.resizeColumnsToContents()
self.table_metabolism.resizeColumnsToContents()
self.table_excretion.resizeColumnsToContents()
self.table_toxicity.resizeColumnsToContents()
# self.show_preds_plot()
# self.scrollArea_single.setWidget(self.scrollAreaWidgetContents_single)
# self.verticalLayout_21.addWidget(self.scrollArea_single)
# self.verticalLayout_14.setStretch(0,2)
# self.verticalLayout_14.setStretch(1,5)
# self.verticalLayout_14.setStretch(2,5)
# 降低最小高度,便于整体窗口上下缩放
self.scrollAreaWidgetContents_single.setMinimumSize(600,1200)
# 调节scrollArea中的控件大小
# self.frame_image.setGeometry(9,9,100,100)
# self.frame_PhyChe.setGeometry(1,1,250,448)
# self.frame_absorption.setGeometry(257,1,250,448)
# self.frame_distribution.setGeometry(512,1,250,448)
# self.frame_metabolism.setGeometry(257,1,250,448)
# self.frame_excretion.setGeometry(1,1,250,448)
# self.frame_toxicity.setGeometry(512,1,250,448)
# self.Tab_res.setTabText(self.Tab_res.indexOf(self.tab_meloculesdata), _translate("MainWindow", "Melocules Data"))
from PyQt5.QtWidgets import QTreeWidgetItem, QSizePolicy
from PyQt5.QtCore import Qt, QSortFilterProxyModel, QUrl
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, QFileDialog, QInputDialog, QTableWidget, QTableWidgetItem, QLabel, QVBoxLayout, QHBoxLayout, QPushButton, QSpinBox, QTextEdit, QDialog
from PyQt5.QtGui import QPixmap
# from PyQt5.QtWebEngineWidgets import QWebEngineView
# 尝试导入PyQtWebEngine,如果失败则使用备用方案
try:
from PyQt5.QtWebEngineWidgets import QWebEngineView
WEBENGINE_AVAILABLE = True
except ImportError:
WEBENGINE_AVAILABLE = False
print("Warning: PyQtWebEngine is not installed; 3D view will use an external browser.")
from pathlib import Path
import pandas as pd
import numpy as np
import pickle
import json
import os
import subprocess
import tempfile
import datetime
from typing import Dict, List, Optional, Set
import re
from Bio import SeqIO
# SCOPE 催化位点:残基得分 ≥ 该阈值则 Pre_label=1
CATALYTIC_THRESHOLD = 0.5
try:
from SCOPE_GUI_infer import (
DATA_DIR as SCOPE_DATA_DIR,
check_scope_features_ready,
extract_features_and_cache_from_fasta_pdb,
load_fasta_sequences,
predict_results_for_protein_list,
)
except ImportError:
SCOPE_DATA_DIR = None
check_scope_features_ready = None
extract_features_and_cache_from_fasta_pdb = None
load_fasta_sequences = None
predict_results_for_protein_list = None
def clear_layout(layout):
while layout.count():
item = layout.takeAt(0)
widget = item.widget()
if widget is not None:
widget.deleteLater()
else:
clear_layout(item.layout())
class NumericSortProxyModel(QSortFilterProxyModel):
"""Custom sort proxy for numerical column sorting"""
def lessThan(self, left, right):
left_data = left.data(QtCore.Qt.UserRole)
right_data = right.data(QtCore.Qt.UserRole)
# If both data have UserRole (numerical), compare by value
if left_data is not None and right_data is not None:
try:
return float(left_data) < float(right_data)
except (ValueError, TypeError):
pass
# Otherwise compare by default string
return super().lessThan(left, right)
class MyDesigner(QMainWindow, Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.textBrowser_status.setText(
"\nWelcome to SCOPE catalytic site prediction: run Extract features first, then Predict."
)
self.predicting = False
self.extracting_features = False
# # 启用系统标题栏按钮并取消无边框,确保显示最小化/最大化/关闭
# try:
# self.setWindowFlag(QtCore.Qt.FramelessWindowHint, False)
# self.setWindowFlag(QtCore.Qt.WindowTitleHint, True)
# self.setWindowFlag(QtCore.Qt.WindowSystemMenuHint, True)
# self.setWindowFlag(QtCore.Qt.WindowMinimizeButtonHint, True)
# self.setWindowFlag(QtCore.Qt.WindowMaximizeButtonHint, True)
# self.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, True)
# # 重新应用窗口装饰
# self.showNormal()
# except Exception:
# pass
# #(移除旧的 Task 初始化)
def selectFile(self):
filePath,_ = QFileDialog.getOpenFileName(self.filename, "Open Files")
self.filename.setText(filePath)
# 设置PDB文件路径
if filePath:
self.pdb_path = filePath
self.textBrowser_status.setText(f"\nPDB file selected: {filePath}")
self.textBrowser_status.moveCursor(QtGui.QTextCursor.End)
def selectFastaFile(self):
filePath, _ = QFileDialog.getOpenFileName(
self,
"Select FASTA",
"",
"FASTA (*.fa *.fasta *.faa);;All files (*)",
)
if filePath:
self.filename_fasta.setText(filePath)
self.textBrowser_status.append(f"\nFASTA selected: {filePath}")
self.textBrowser_status.moveCursor(QtGui.QTextCursor.End)
def _scope_fasta_path(self) -> str:
if hasattr(self, "filename_fasta") and self.filename_fasta.text().strip():
return self.filename_fasta.text().strip()
return ""
def _aa_from_infer_line(self, protein_id: str, position: int) -> str:
"""从 InferResult/<protein_id> 第 position 行读取单字母氨基酸(与推理输出首列一致)。"""
if not SCOPE_DATA_DIR or position < 1:
return ""
fp = os.path.join(SCOPE_DATA_DIR, "InferResult", protein_id)
if not os.path.isfile(fp):
return ""
try:
with open(fp, "r") as f:
for idx, line in enumerate(f):
if idx + 1 != position:
continue
parts = line.strip().split("\t")
if not parts:
return ""
return str(parts[0]).strip()[:1] or ""
except OSError:
return ""
return ""
def _build_scope_catalytic_dataframe(
self,
protein_list: List[str],
prot_seq: Optional[Dict[str, str]] = None,
) -> pd.DataFrame:
"""将 SCOPE_data/InferResult/<prot> 转为与表格兼容的 DataFrame(含各位点氨基酸,来自推理文件首列)。"""
if not SCOPE_DATA_DIR:
return pd.DataFrame(
columns=["Proteases", "Protein|position", "AA", "Pre_Score", "Pre_label"]
)
infer_dir = os.path.join(SCOPE_DATA_DIR, "InferResult")
rows: List[dict] = []
for prot in protein_list:
fp = os.path.join(infer_dir, prot)
if not os.path.isfile(fp):
continue
with open(fp, "r") as f:
for idx, line in enumerate(f):
line = line.strip()
if not line:
continue
parts = line.split("\t")
if len(parts) < 2:
continue
try:
sc = float(parts[1])
except ValueError:
continue
pos = idx + 1
aa = str(parts[0]).strip()[:1] or ""
if not aa and prot_seq and prot in prot_seq:
s = prot_seq[prot]
if 1 <= pos <= len(s):
aa = s[pos - 1]
rows.append(
{
"Protease": "Catalytic_site",
"Protein|position": f"{prot}|{pos}",
"AA": aa,
"Pre_Score": sc,
"Pre_label": 1 if sc >= CATALYTIC_THRESHOLD else 0,
}
)
if not rows:
return pd.DataFrame(
columns=["Proteases", "Protein|position", "AA", "Pre_Score", "Pre_label"]
)
return pd.DataFrame(rows)
def _end_predict_session(self):
self.predicting = False
try:
self.LineEdit_chain.textChanged.connect(self.validate_chain_input)
except Exception:
pass
try:
self.LineEdit_num_workers.textChanged.connect(self.validate_num_workers_input)
except Exception:
pass
self.button_predict.setEnabled(True)
if hasattr(self, "button_extract_features"):
self.button_extract_features.setEnabled(True)
def _end_extract_session(self):
self.extracting_features = False
if hasattr(self, "button_extract_features"):
self.button_extract_features.setEnabled(True)
if hasattr(self, "button_predict"):
self.button_predict.setEnabled(True)
def extractScopeFeatures(self):
"""第一步:仅提取并缓存特征(不运行预测)。"""
from PyQt5.QtWidgets import QMessageBox
if self.extracting_features or self.predicting:
return
if extract_features_and_cache_from_fasta_pdb is None:
self.textBrowser_status.append("\nError: Could not load SCOPE_GUI_infer.")
return
vr = self._validate_scope_inputs_dict()
if not vr["valid"]:
self.textBrowser_status.setText(vr["message"])
self.textBrowser_status.moveCursor(QtGui.QTextCursor.End)
return
fasta_scope = self._scope_fasta_path()
pdb_path = str(Path(self.filename.text().strip()))
reply = QMessageBox.question(
self,
"Step 1: Feature extraction",
"This will run PSSM, DSSP, ProtT5, etc., and may take a long time.\n"
"If cached features already match the current PDB, redundant work will be skipped.\n\nStart now?",
QMessageBox.Yes | QMessageBox.No,
QMessageBox.Yes,
)
if reply == QMessageBox.No:
self.textBrowser_status.append("\nFeature extraction cancelled.")
return
self.extracting_features = True
self.button_extract_features.setEnabled(False)
self.button_predict.setEnabled(False)
self.textBrowser_status.setText("\nExtracting features, please wait…")
self.textBrowser_status.moveCursor(QtGui.QTextCursor.End)
QtWidgets.QApplication.processEvents()
try:
def _cb(msg: str):
self.textBrowser_status.append("\n" + msg)
self.textBrowser_status.moveCursor(QtGui.QTextCursor.End)
QtWidgets.QApplication.processEvents()
extract_features_and_cache_from_fasta_pdb(
fasta_scope,
pdb_path,
status_callback=_cb,
)
self.textBrowser_status.append(
"\nStep 1 finished: features are ready. Open Step 2 and click Predict."
)
self.textBrowser_status.moveCursor(QtGui.QTextCursor.End)
except Exception as e:
self.textBrowser_status.append(f"\nFeature extraction failed: {e}")
self.textBrowser_status.moveCursor(QtGui.QTextCursor.End)
finally:
self._end_extract_session()
def _validate_scope_inputs_dict(self):
"""与 validate_parameters 中 SCOPE 分支一致,返回 dict。"""
fasta_scope = self._scope_fasta_path()
if not fasta_scope:
return {"valid": False, "message": "Error: Please select both FASTA and PDB."}
if extract_features_and_cache_from_fasta_pdb is None:
return {"valid": False, "message": "Error: Could not load SCOPE_GUI_infer."}
fasta_file = Path(fasta_scope)
if not fasta_file.exists():
return {"valid": False, "message": f"Error: FASTA not found: {fasta_file}"}
if fasta_file.suffix.lower() not in [".fa", ".fasta", ".faa"]:
return {
"valid": False,
"message": f"Error: FASTA must use .fa / .fasta / .faa; got: {fasta_file.suffix}",
}
if not self.filename.text() or not self.filename.text().strip():
return {"valid": False, "message": "Error: Both PDB and FASTA are required."}
pdb_file = Path(self.filename.text().strip())
if not pdb_file.exists():
return {"valid": False, "message": f"Error: PDB not found: {pdb_file}"}
if pdb_file.suffix.lower() not in [".pdb", ".ent"]:
return {
"valid": False,
"message": f"Error: PDB must be .pdb or .ent; got: {pdb_file.suffix}",
}
return {"valid": True, "message": ""}
def loadResultFile(self):
"""Load local result file"""
filePath, _ = QFileDialog.getOpenFileName(
self,
"Select Result File",
"",
"CSV Files (*.csv);;All Files (*)"
)
if filePath:
try:
# 读取CSV文件
self.data_with_preds = pd.read_csv(filePath)
# 显示加载成功信息
self.textBrowser_status.setText(f"\nSuccessfully loaded result file: {filePath}")
self.textBrowser_status.setText(f"\nData shape: {self.data_with_preds.shape}")
self.textBrowser_status.moveCursor(QtGui.QTextCursor.End)
# 确保表格控件已创建
if not hasattr(self, "tabSon_meloculesdata") or self.tabSon_meloculesdata is None:
self.textBrowser_status.setText("\nCreating table controls...")
self.textBrowser_status.moveCursor(QtGui.QTextCursor.End)
self.show_tabSon_meloculesdata()
# elif not self._plot_controls_alive():
# self.show_preds_plot()
# 显示结果表格
self.textBrowser_status.setText("\nDisplaying table data...")
self.textBrowser_status.moveCursor(QtGui.QTextCursor.End)
self.show_preds_table()
self.textBrowser_status.setText("\nFile loading completed successfully!")
self.textBrowser_status.moveCursor(QtGui.QTextCursor.End)
except Exception as e:
self.textBrowser_status.setText(f"\nError loading file: {str(e)}")
self.textBrowser_status.moveCursor(QtGui.QTextCursor.End)
def _toggle_group_body(self, body_widget: QtWidgets.QWidget):
"""切换分组内部主体可见性(折叠/展开)"""
try:
body_widget.setVisible(not body_widget.isVisible())
except Exception:
pass
def clean(self):
# 清理动态创建的控件引用
if hasattr(self, 'comboBox_protein_pos'):
self.comboBox_protein_pos = None
if hasattr(self, 'horizontalLayout_filter'):
self.horizontalLayout_filter = None
if hasattr(self, 'button_save_table'):
self.button_save_table = None
if hasattr(self, 'lineEdit_threshold'):
self.lineEdit_threshold = None
if hasattr(self, 'label_threshold'):
self.label_threshold = None
if hasattr(self, 'button_update_network'):
self.button_update_network = None
if hasattr(self, 'button_zoom_plot'):
self.button_zoom_plot = None
if hasattr(self, 'button_save_plot'):
self.button_save_plot = None
if hasattr(self, 'horizontalLayout_threshold'):
self.horizontalLayout_threshold = None
if hasattr(self, 'verticalLayout_tab_summaryplot'):
self.verticalLayout_tab_summaryplot = None
if hasattr(self, 'frame_plot'):
self.frame_plot = None
if hasattr(self, 'label_plot'):
self.label_plot = None
if hasattr(self, 'verticalLayout_frameplot'):
self.verticalLayout_frameplot = None
if hasattr(self, 'tabSon_meloculesdata'):
self.tabSon_meloculesdata = None
if hasattr(self, 'table_alldata'):
self.table_alldata = None
# 清理数据
if hasattr(self, 'data_with_preds'):
self.data_with_preds = None
# 删除已经删除的 Qt 对象的引用
self.centralwidget.deleteLater()
self.centralwidget = None
self.layout = None
self.label = None
self.combo_box = None
self.button = None
# 重新初始化界面
self.setupUi(self)
self.show_tabSon_meloculesdata()
try:
self.LineEdit_atc_code.setReadOnly(False)
self.LineEdit_possr.setReadOnly(False)
except Exception:
pass
def on_task_mode_changed(self):
"""已弃用:保留空实现以防信号残留"""
return
def getSavePath(self):
time_str = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
savePath = QFileDialog.getExistingDirectory(self, "Save Results")
# savePath, ok = QInputDialog.getText(self, "Save Results", "Input Path")
#if ok:
self.save_path = Path(savePath+f'/predict_results_{time_str}.csv')
self.data_with_preds.to_csv(self.save_path)
self.textBrowser_status.setText("\nThe result has been saved to"+ savePath+f"/predict_results_{time_str}.csv !")
self.textBrowser_status.moveCursor(QtGui.QTextCursor.End)
def validate_parameters(self):
"""Validate all required parameters before prediction"""
fasta_scope = self._scope_fasta_path()
if fasta_scope:
if extract_features_and_cache_from_fasta_pdb is None or check_scope_features_ready is None:
return {
"valid": False,
"message": "Error: Could not load SCOPE_GUI_infer (catalytic-site prediction unavailable).",
}
fasta_file = Path(fasta_scope)
if not fasta_file.exists():
return {"valid": False, "message": f"Error: FASTA not found: {fasta_file}"}
if fasta_file.suffix.lower() not in [".fa", ".fasta", ".faa"]:
return {
"valid": False,
"message": f"Error: FASTA must use .fa / .fasta / .faa; got: {fasta_file.suffix}",
}
if not self.filename.text() or not self.filename.text().strip():
return {"valid": False, "message": "Error: Both PDB and FASTA are required."}
pdb_file = Path(self.filename.text().strip())
if not pdb_file.exists():
return {"valid": False, "message": f"Error: PDB not found: {pdb_file}"}
if pdb_file.suffix.lower() not in [".pdb", ".ent"]:
return {
"valid": False,
"message": f"Error: PDB must be .pdb or .ent; got: {pdb_file.suffix}",
}
ok, _, err = check_scope_features_ready(fasta_scope, str(pdb_file))
if not ok:
return {
"valid": False,
"message": err
or "Error: Feature extraction is not done or the current PDB does not match the cache. Run Extract features first.",
}
return {"valid": True, "message": "Ready for Step 2 prediction."}
# Check PDB file selection
if not self.filename.text() or self.filename.text().strip() == "":
return {
'valid': False,
'message': "Error: Please select a PDB file first!"
}
# Check if PDB file exists
pdb_file = Path(self.filename.text())
if not pdb_file.exists():
return {
'valid': False,
'message': f"Error: PDB file does not exist: {pdb_file}"
}
# Check file extension
if not pdb_file.suffix.lower() in ['.pdb', '.ent']:
return {
'valid': False,
'message': f"Error: Invalid file format. Please select a PDB file (.pdb or .ent), got: {pdb_file.suffix}"
}
atc_code = self.LineEdit_atc_code.text().strip()
if not atc_code:
return {
'valid': False,
'message': "Warning: No protease selected. Please select at least one protease."
}
proteases_list = [x.strip() for x in atc_code.split(',') if x.strip()]
if proteases_list:
for protease in proteases_list:
if not protease or len(protease) < 3:
return {
'valid': False,
'message': f"Error: Invalid protease ID format: '{protease}'. Please check your selection."
}
# Check chain parameter
chain = self.LineEdit_chain.text().strip()
if not chain:
return {
'valid': False,
'message': "Error: Chain parameter cannot be empty. Please specify a chain (e.g., A, B, C)."
}
# Validate chain format (should be single letter)
if len(chain) != 1 or not chain.isalpha():
return {
'valid': False,
'message': f"Error: Invalid chain format: '{chain}'. Chain should be a single letter (e.g., A, B, C)."
}
# Check positions parameter (optional but validate format if provided)
possr = self.LineEdit_possr.text().strip()
if possr:
try:
# Split by comma and validate each position
positions = [x.strip() for x in possr.split(',') if x.strip()]
for pos in positions:
pos_int = int(pos)
if pos_int < 1: