-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflypredictome.html
More file actions
3564 lines (3235 loc) · 179 KB
/
Copy pathflypredictome.html
File metadata and controls
3564 lines (3235 loc) · 179 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/svg+xml" href="favicon.svg">
<title>LIVIA — FlyPredictome Analysis</title>
<link rel="stylesheet" href="css/livia.css?v=20260604">
<style>
/* ── Page-specific styles for FlyPredictome ── */
.step-link { color: #2471A3; text-decoration: none; }
.step-link:hover { text-decoration: underline; }
/* ── Textarea ── */
textarea {
width: 100%;
min-height: 160px;
padding: 0.8rem;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-family: 'SF Mono', 'Fira Code', monospace;
font-size: 0.8rem;
resize: vertical;
transition: border-color 0.2s;
}
textarea:focus { outline: none; border-color: #2471A3; }
/* ── Rank select ── */
.rank-row {
display: flex;
gap: 0.75rem;
align-items: center;
margin-bottom: 1rem;
padding-left: 2.3rem;
}
.rank-row select {
padding: 0.5rem 0.8rem;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-size: 0.9rem;
background: white;
}
/* ── Help section ── */
.help-content {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1.5rem;
padding-left: 2.3rem;
}
.help-col h4 { font-size: 0.9rem; color: #1a5276; margin-bottom: 0.5rem; }
.help-col ol { padding-left: 1.2rem; font-size: 0.85rem; color: #555; line-height: 1.7; }
.help-col a { color: #2471A3; text-decoration: none; }
.help-col a:hover { text-decoration: underline; }
.help-table { font-size: 0.85rem; }
.help-table td { padding: 0.25rem 0.5rem 0.25rem 0; vertical-align: top; color: #555; }
.ref-list { list-style: none; padding: 0; font-size: 0.85rem; }
.ref-list li { margin-bottom: 0.3rem; color: #555; }
.ref-list a { color: #2471A3; text-decoration: none; font-weight: 600; }
.ref-list a:hover { text-decoration: underline; }
.color-presets { display: flex; flex-direction: column; gap: 0.4rem; }
.preset {
display: flex;
align-items: center;
gap: 0.6rem;
padding: 0.35rem 0.5rem;
border-radius: 6px;
cursor: pointer;
transition: background 0.2s;
}
.preset:hover { background: #f0f0f0; }
.preset-strip {
display: flex;
width: 80px;
height: 12px;
border-radius: 3px;
overflow: hidden;
flex-shrink: 0;
}
.preset-strip span { flex: 1; }
.preset-name { font-size: 0.82rem; color: #666; }
</style>
</head>
<body>
<div class="header">
<div class="container">
<h1><span style="color:#2471A3;">LIVIA</span> — FlyPredictome Analysis</h1>
<p>Analyze <em>Drosophila</em> protein interactions from <a href="https://www.flyrnai.org/tools/fly_predictome" target="_blank" style="color:#2471A3;">FlyPredictome</a> predictions (<a href="https://doi.org/10.64898/2026.04.14.718529" target="_blank" style="color:#2471A3;">Kim et al., 2026</a>)</p>
<div class="header-links">
<a href="index.html">Home</a>
<a href="universal.html">Prediction Analysis</a>
<a href="flypredictome.html" class="active">FlyPredictome</a>
<a href="ortholog_predictome.html">Ortholog Interactome</a>
<a href="dimer.html">AFDB Dimer</a>
<a href="monomer.html">AFDB Monomer Subdomain</a>
<a href="tutorials.html">Tutorials</a>
<a href="about.html">About</a>
<a href="bookmarklet.html" style="background:#2471A3; color:white; border-color:#2471A3; font-weight:600;">Bookmarklet ★</a>
<a href="https://github.com/flyark/LIVIA" target="_blank">GitHub</a>
</div>
</div>
</div>
<div class="container">
<!-- Input -->
<div class="card">
<div class="step-header"><a href="https://www.flyrnai.org/tools/fly_predictome" target="_blank" class="step-link">FlyPredictome</a> Interaction Lookup</div>
<div style="font-size:0.8rem; color:#888; margin-bottom:0.6rem;">Precomputed PPI predictions for <em>Drosophila</em> from <a href="https://www.flyrnai.org/tools/fly_predictome" target="_blank" style="color:#2471A3;">FlyPredictome</a>. Search by gene name or paste a prediction page URL.</div>
<div class="input-tabs">
<button class="input-tab" data-tab="search" onclick="switchTab('search')">Search by Gene</button>
<button class="input-tab" data-tab="pair" onclick="switchTab('pair')">Gene Pair</button>
<button class="input-tab active" data-tab="url" onclick="switchTab('url')">Paste URL</button>
</div>
<!-- Search by Gene panel -->
<div id="search-panel" style="display:none;">
<div class="url-row" style="position:relative;">
<div style="position:relative; flex:1;">
<input type="text" id="gene-search-input"
placeholder="e.g., Akt1, foxo, Dl, sgg..."
autocomplete="off"
oninput="geneAcIdx=-1;searchUniprotAc(this.value)"
onkeydown="handleGeneAcKey(event)">
<div id="gene-ac-list" class="ac-list" style="display:none; position:absolute; top:100%; left:0; right:0; background:white; border:1px solid #ddd; border-radius:0 0 8px 8px; max-height:250px; overflow-y:auto; z-index:100; box-shadow:0 4px 12px rgba(0,0,0,0.1);"></div>
</div>
<button class="btn btn-primary" onclick="hideGeneAc();searchGene()">Search</button>
</div>
<div style="display:flex; gap:0.4rem; flex-wrap:wrap; margin-top:0.5rem; align-items:center;">
<span style="font-size:0.8rem; color:#888;">Examples:</span>
<button class="example-btn" onclick="document.getElementById('gene-search-input').value='Akt1';searchGene()">Akt1</button>
<button class="example-btn" onclick="document.getElementById('gene-search-input').value='foxo';searchGene()">foxo</button>
<button class="example-btn" onclick="document.getElementById('gene-search-input').value='Dl';searchGene()">Dl</button>
<button class="example-btn" onclick="document.getElementById('gene-search-input').value='dpp';searchGene()">dpp</button>
<button class="example-btn" onclick="document.getElementById('gene-search-input').value='Egfr';searchGene()">Egfr</button>
<button class="example-btn" onclick="document.getElementById('gene-search-input').value='wg';searchGene()">wg</button>
</div>
<div id="search-status" style="font-size:0.85rem; color:#666; min-height:1.2rem; margin-top:0.5rem; margin-bottom:0.5rem;"></div>
<div id="search-results" style="display:none;"></div>
</div>
<!-- Gene Pair panel -->
<div id="pair-panel" style="display:none;">
<div class="url-row" style="position:relative;">
<div style="position:relative; flex:1;">
<input type="text" id="pair-gene-a"
placeholder="Gene A (e.g., Akt1)"
autocomplete="off"
oninput="pairAcIdx=-1;searchPairAc(this,'pair-ac-a')"
onkeydown="handlePairAcKey(event,'pair-gene-a','pair-ac-a')">
<div id="pair-ac-a" class="ac-list" style="display:none; position:absolute; top:100%; left:0; right:0; background:white; border:1px solid #ddd; border-radius:0 0 8px 8px; max-height:250px; overflow-y:auto; z-index:100; box-shadow:0 4px 12px rgba(0,0,0,0.1);"></div>
</div>
<div style="position:relative; flex:1;">
<input type="text" id="pair-gene-b"
placeholder="Gene B (e.g., foxo)"
autocomplete="off"
oninput="pairAcIdx=-1;searchPairAc(this,'pair-ac-b')"
onkeydown="handlePairAcKey(event,'pair-gene-b','pair-ac-b')">
<div id="pair-ac-b" class="ac-list" style="display:none; position:absolute; top:100%; left:0; right:0; background:white; border:1px solid #ddd; border-radius:0 0 8px 8px; max-height:250px; overflow-y:auto; z-index:100; box-shadow:0 4px 12px rgba(0,0,0,0.1);"></div>
</div>
<button class="btn btn-primary" onclick="searchGenePair()">Search Pair</button>
</div>
<div style="display:flex; gap:0.4rem; flex-wrap:wrap; margin-top:0.5rem; align-items:center;">
<span style="font-size:0.8rem; color:#888;">Examples:</span>
<button class="example-btn" onclick="setPairAndSearch('Akt1','foxo')">Akt1 & foxo</button>
<button class="example-btn" onclick="setPairAndSearch('Dl','N')">Dl & N</button>
<button class="example-btn" onclick="setPairAndSearch('yki','sd')">yki & sd</button>
<button class="example-btn" onclick="setPairAndSearch('dsh','Axn')">dsh & Axn</button>
<button class="example-btn" onclick="setPairAndSearch('Mad','Med')">Mad & Med</button>
<button class="example-btn" onclick="setPairAndSearch('spz','Tl')">spz & Tl</button>
</div>
<div id="pair-status" style="font-size:0.85rem; color:#666; min-height:1.2rem; margin-top:0.5rem; margin-bottom:0.5rem;"></div>
<div id="pair-results" style="display:none;"></div>
</div>
<!-- Paste URL panel -->
<div id="url-panel">
<div class="url-row">
<input type="text" id="url-input"
placeholder="https://www.flyrnai.org/tools/fly_predictome/web/famdb_details/..."
value="">
<button class="btn btn-primary" id="btn-generate" onclick="generate()">Generate</button>
</div>
<div style="display:flex; gap:0.4rem; flex-wrap:wrap; margin-top:0.5rem; align-items:center;">
<span style="font-size:0.8rem; color:#888;">Examples:</span>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details/Akt1/foxo/SET_47/';generate()">Akt1–Foxo</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details/FBgn0283499/FBgn0036046/SET_487/';generate()">Ilp2–InR</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details/FBgn0003731/FBgn0005672/SET_590/';generate()">Spi–Egfr</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details/Dl/N/SET_71/';generate()">Dl–N</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details/yki/sd/SET_49/';generate()">Yki–Sd</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details/dsh/Axn/SET_69/';generate()">Dsh–Axn</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details/FBgn0004644/FBgn0031872/SET_585/';generate()">Hh–Ihog</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details/FBgn0004107/FBgn0010382/SET_119/';generate()">Cdk2–CycE</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details/Mad/Med/SET_69/';generate()">Mad–Med</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details/FBgn0011706/FBgn0260635/SET_563/';generate()">Rpr–Diap1</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details/spz/Tl/SET_69/';generate()">Spz–Tl</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details/FBgn0032006/FBgn0030964/SET_454/';generate()">Pvr–Pvf1</button>
</div>
<div id="fetch-status" class="fetch-status"></div>
<textarea id="html-input" style="display:none"></textarea>
</div>
</div>
<!-- Error -->
<div class="error-msg" id="error-msg"></div>
<!-- Results -->
<div class="results" id="results">
<!-- All Ranks (click to select) -->
<div class="card result-card">
<div style="display:flex; align-items:center; gap:1rem; flex-wrap:wrap;">
<h2 id="result-title" style="margin-bottom:0;">Interaction Analysis Summary</h2>
<a style="font-size:0.8rem; color:#2471A3; cursor:pointer; text-decoration:none; border-bottom:1px dashed #2471A3;" onclick="downloadFlyCSV()">↓ Download CSV</a>
</div>
<div class="info-box">Click a row to switch ranks. This updates all visualizations and the script below.</div>
<div style="overflow-x:auto;">
<table class="data-table" id="ranks-table">
<thead>
<tr><th>Rank</th><th>Symbol 1</th><th>Symbol 2</th><th>iLIS</th><th>iLIA</th><th>iLISA</th><th>ipTM</th><th>LIR (A/B)</th><th>cLIR (A/B)</th><th>Len (A/B)</th></tr>
</thead>
<tbody id="ranks-tbody"></tbody>
</table>
</div>
<div style="margin-top:0.6rem; font-size:0.75rem; color:#999; line-height:1.8;">
<div style="display:flex; gap:0.8rem; flex-wrap:wrap; align-items:center;">
<strong style="min-width:90px;">iLIS:</strong>
<span><span style="color:#6B21A8; font-weight:700;">≥0.551</span> (1% FPR)</span>
<span><span style="color:#0e8a6e; font-weight:700;">≥0.339</span> (5% FPR)</span>
<span><span style="color:#bf8700; font-weight:700;">≥0.223</span> (10% FPR)</span>
<span><span style="color:#8b949e; font-weight:700;"><0.223</span> (below threshold)</span>
</div>
<div style="display:flex; gap:0.8rem; flex-wrap:wrap; align-items:center;">
<strong style="min-width:90px;">iLIS (average):</strong>
<span><span style="color:#6B21A8; font-weight:700;">≥0.303</span> (1% FPR)</span>
<span><span style="color:#0e8a6e; font-weight:700;">≥0.120</span> (5% FPR)</span>
<span><span style="color:#bf8700; font-weight:700;">≥0.073</span> (10% FPR)</span>
<span><span style="color:#8b949e; font-weight:700;"><0.073</span> (below threshold)</span>
</div>
<div>Thresholds based on large-scale Y2H reference sets in yeast, fly, and human predicted using ColabFold. See <a href="https://doi.org/10.64898/2026.04.14.718529" target="_blank" style="color:#2471A3;">Kim et al., 2026</a>, for iLIS benchmark details. Rank 1 (determined by ipTM) may not have the highest iLIS.</div>
</div>
</div>
<!-- Known Interactions (MIST) -->
<div class="card result-card" id="mist-card" style="display:none;">
<h2>Reported Interactions <span style="font-weight:400; font-size:0.8rem; color:#888;">(<a href="https://fgrtools.hms.harvard.edu/MIST/" target="_blank" style="color:#2471A3;">MIST</a>)</span></h2>
<div id="mist-content"></div>
<div id="mist-link" style="margin-top:0.5rem; font-size:0.82rem;"></div>
</div>
<!-- PAE Map -->
<div class="card result-card" id="pae-card" style="display:none;">
<h2>Predicted Aligned Error (PAE)</h2>
<div style="font-size:0.82rem; color:#888; margin-bottom:0.5rem;">PAE matrix showing prediction confidence between all residue pairs. Blue = low error (high confidence).</div>
<div style="text-align:center;">
<img id="pae-img" style="width:100%; border-radius:4px;" alt="PAE plot">
</div>
</div>
<!-- Sequence Viewer -->
<div class="card result-card" id="seq-viewer-card" style="display:none;">
<h2>Sequence Viewer <span class="model-badge" id="seq-model-badge"></span></h2>
<div style="font-size:0.82rem; color:#888; margin-bottom:0.5rem;">
Light background = LIR (PAE ≤ 12 Å). Dark background = cLIR (PAE ≤ 12 Å & Cβ ≤ 8 Å). Each chain uses its own color.
</div>
<div id="seq-viewer" style="overflow-x:auto;"></div>
</div>
<!-- Interaction Connection Diagram -->
<div class="card result-card" id="connection-diagram-card" style="display:none;">
<h2>Linear Contact Map <span class="model-badge" id="contact-model-badge"></span></h2>
<div style="font-size:0.82rem; color:#888; margin-bottom:0.5rem;">
Lines connect cLIR residue pairs within Cβ distance in the 3D structure. Per-rank structures fetched automatically.
</div>
<canvas id="connection-canvas"></canvas>
<div id="fly-domain-legend" style="margin-top:0.4rem; font-size:0.72rem; color:#666; display:flex; gap:0.8rem; flex-wrap:wrap;"></div>
</div>
<!-- Circular Contact Map (circular) -->
<div class="card result-card" id="chord-card" style="display:none;">
<h2>Circular Contact Map <span class="model-badge" id="chord-model-badge"></span></h2>
<div style="font-size:0.82rem; color:#888; margin-bottom:0.5rem;">
Arcs represent chains (proportional to length). Lines connect cLIR residue pairs in physical contact.
</div>
<div style="display:flex; justify-content:center; gap:2rem; flex-wrap:wrap;">
<div style="text-align:center;">
<canvas id="chord-canvas"></canvas>
<div style="font-size:0.75rem; color:#999; margin-top:0.25rem;">Selected Rank</div>
</div>
<div id="chord-all-wrap" style="text-align:center; display:none;">
<canvas id="chord-canvas-all"></canvas>
<div style="font-size:0.75rem; color:#999; margin-top:0.25rem;">All Ranks Combined</div>
</div>
</div>
</div>
<!-- 3D Structure Viewer -->
<div class="card result-card" id="viewer3d-card" style="display:none;">
<h2>3D Structure Viewer <span class="model-badge" id="viewer3d-model-badge"></span></h2>
<div style="font-size:0.82rem; color:#888; margin-bottom:0.5rem;">
Interactive 3D preview powered by <a href="https://molstar.org" target="_blank" style="color:#2471A3;">Mol*</a> (<a href="https://doi.org/10.1093/nar/gkab314" target="_blank" style="color:#2471A3;">Sehnal et al. 2021</a>). LIR regions shown as cartoons; cLIR residues highlighted. Drag to rotate, scroll to zoom.
</div>
<div id="chain-toggle-bar" style="display:none; align-items:center; gap:0.4rem; margin-bottom:0.5rem; flex-wrap:wrap; font-size:0.82rem; color:#555;">
<span>Chains shown in 3D:</span>
<div id="chain-toggle-buttons" style="display:flex; gap:0.25rem; flex-wrap:wrap;"></div>
<button id="chain-toggle-reset" onclick="resetChainVisibility()" style="padding:0.2rem 0.55rem; border:1px solid #ddd; border-radius:4px; background:#f8f9fa; cursor:pointer; font-size:0.75rem; color:#555;">Reset</button>
</div>
<iframe id="viewer3d-frame" style="width:100%; height:660px; border:1px solid #e0e0e0; border-radius:8px; background:#fff;" sandbox="allow-scripts allow-same-origin allow-downloads" allowfullscreen></iframe>
<div style="text-align:right; margin-top:0.3rem;">
<button onclick="document.getElementById('viewer3d-frame').requestFullscreen()" style="padding:0.25rem 0.6rem; border:1px solid #ddd; border-radius:4px; background:#f8f9fa; cursor:pointer; font-size:0.78rem; color:#555;">Fullscreen</button>
</div>
</div>
<!-- Script -->
<div class="card result-card">
<h2>Visualization Script <span class="model-badge" id="script-model-badge"></span></h2>
<div style="margin-bottom:1rem;">
<label>Local Interaction Residue (LIR) Display</label>
<div style="display:flex; align-items:baseline; gap:0.6rem; margin-bottom:0.5rem; font-size:0.85rem; color:#555; flex-wrap:wrap;">
<span>Fill gaps ≤</span>
<input type="number" id="gap-fill-input" value="10" min="0" max="200" style="width:55px; padding:0.3rem 0.4rem; border:2px solid #e0e0e0; border-radius:6px; font-size:0.85rem; text-align:center;">
<span>residues</span>
<span style="color:#ccc;">|</span>
<span>Min segment ≥</span>
<input type="number" id="min-segment-input" value="3" min="1" max="50" style="width:55px; padding:0.3rem 0.4rem; border:2px solid #e0e0e0; border-radius:6px; font-size:0.85rem; text-align:center;">
<span>residues</span>
<button class="btn btn-primary" style="font-size:0.82rem; padding:0.3rem 0.8rem;" onclick="updateGapFill()">Apply</button>
</div>
<div style="font-size:0.78rem; color:#999; margin-bottom:0.5rem;">Gap filling bridges short breaks for continuous cartoon. Min segment removes isolated LIR fragments shorter than the threshold.</div>
<label style="display:flex; align-items:center; gap:0.3rem; font-size:0.85rem; color:#555; cursor:pointer; user-select:none; margin-bottom:0.3rem;">
<input type="checkbox" class="show-complete-cb" onchange="toggleShowComplete(this)"> Show complete structure <span style="font-size:0.78rem; color:#999;">(display all residues instead of LIR only)</span>
</label>
<label style="display:flex; align-items:center; gap:0.3rem; font-size:0.85rem; color:#555; cursor:pointer; user-select:none; margin-bottom:1rem; padding-left:1.2rem;">
<input type="checkbox" class="gray-nonlir-cb" onchange="toggleGrayNonLir(this)"> Gray non-LIR <span style="font-size:0.78rem; color:#999;">(color non-interacting residues gray)</span>
</label>
<label>Color Scheme</label>
<div class="color-section">
<div class="color-group">
<h3>Chain A (Protein 1)</h3>
<div class="color-pair">
<input type="color" id="color-lir-a" value="#80CBC4">
<div>
<div class="color-label">LIR — confident domain <span class="color-def">(PAE ≤ 12)</span></div>
<div class="color-hex" id="hex-lir-a">#80CBC4</div>
</div>
</div>
<div class="color-pair">
<input type="color" id="color-clir-a" value="#00897B">
<div>
<div class="color-label">cLIR — confident interface <span class="color-def">(PAE ≤ 12 & Cβ ≤ 8 Å)</span></div>
<div class="color-hex" id="hex-clir-a">#00897B</div>
</div>
</div>
</div>
<div class="color-group">
<h3>Chain B (Protein 2)</h3>
<div class="color-pair">
<input type="color" id="color-lir-b" value="#FFAB91">
<div>
<div class="color-label">LIR — confident domain <span class="color-def">(PAE ≤ 12)</span></div>
<div class="color-hex" id="hex-lir-b">#FFAB91</div>
</div>
</div>
<div class="color-pair">
<input type="color" id="color-clir-b" value="#E64A19">
<div>
<div class="color-label">cLIR — confident interface <span class="color-def">(PAE ≤ 12 & Cβ ≤ 8 Å)</span></div>
<div class="color-hex" id="hex-clir-b">#E64A19</div>
</div>
</div>
</div>
</div>
<div style="display:flex; align-items:center; gap:0.8rem; margin-top:0.5rem;">
<div class="color-preview-strip" id="color-strip" style="flex:1; margin:0;">
<div style="background:#80CBC4"></div><div style="background:#00897B"></div><div style="background:#E64A19"></div><div style="background:#FFAB91"></div>
</div>
<button onclick="swapColors()" style="padding:0.3rem 0.8rem; border:2px solid #e0e0e0; border-radius:6px; background:white; cursor:pointer; font-size:0.82rem; color:#666; white-space:nowrap;">Swap A ↔ B</button>
</div>
<label style="margin-top:1rem">Presets — gradient (LIR light, cLIR dark)</label>
<div class="presets-row">
<div class="preset-chip active" onclick="applyPreset('#80CBC4','#00897B','#FFAB91','#E64A19',this)"><div class="preset-strip"><span style="background:#80CBC4"></span><span style="background:#00897B"></span><span style="background:#E64A19"></span><span style="background:#FFAB91"></span></div>Teal / Coral</div>
<div class="preset-chip" onclick="applyPreset('#b3d4e8','#2471A3','#f5cba7','#E67E22',this)"><div class="preset-strip"><span style="background:#b3d4e8"></span><span style="background:#2471A3"></span><span style="background:#E67E22"></span><span style="background:#f5cba7"></span></div>Blue / Orange</div>
<div class="preset-chip" onclick="applyPreset('#d1c4e9','#5e35b1','#fff3b0','#f9a825',this)"><div class="preset-strip"><span style="background:#d1c4e9"></span><span style="background:#5e35b1"></span><span style="background:#f9a825"></span><span style="background:#fff3b0"></span></div>Purple / Gold</div>
<div class="preset-chip" onclick="applyPreset('#cfd8dc','#546e7a','#f8bbd0','#c2185b',this)"><div class="preset-strip"><span style="background:#cfd8dc"></span><span style="background:#546e7a"></span><span style="background:#c2185b"></span><span style="background:#f8bbd0"></span></div>Slate / Rose</div>
<div class="preset-chip" onclick="applyPreset('#c5cae9','#303f9f','#ffe0b2','#e65100',this)"><div class="preset-strip"><span style="background:#c5cae9"></span><span style="background:#303f9f"></span><span style="background:#e65100"></span><span style="background:#ffe0b2"></span></div>Indigo / Tangerine</div>
<div class="preset-chip" onclick="applyPreset('#a8d5ba','#2e7d32','#ef9a9a','#c62828',this)"><div class="preset-strip"><span style="background:#a8d5ba"></span><span style="background:#2e7d32"></span><span style="background:#c62828"></span><span style="background:#ef9a9a"></span></div>Green / Red</div>
</div>
<label style="margin-top:0.5rem">Presets — high contrast (all 4 colors distinct)</label>
<div class="presets-row">
<div class="preset-chip" onclick="applyPreset('#4DD0E1','#1A237E','#FFAB91','#B71C1C',this)"><div class="preset-strip"><span style="background:#4DD0E1"></span><span style="background:#1A237E"></span><span style="background:#B71C1C"></span><span style="background:#FFAB91"></span></div>Cyan / Navy / Peach / Crimson</div>
<div class="preset-chip" onclick="applyPreset('#81D4FA','#283593','#EF9A9A','#C62828',this)"><div class="preset-strip"><span style="background:#81D4FA"></span><span style="background:#283593"></span><span style="background:#C62828"></span><span style="background:#EF9A9A"></span></div>Sky / Indigo / Salmon / Red</div>
<div class="preset-chip" onclick="applyPreset('#AED581','#1B5E20','#FFD54F','#B71C1C',this)"><div class="preset-strip"><span style="background:#AED581"></span><span style="background:#1B5E20"></span><span style="background:#B71C1C"></span><span style="background:#FFD54F"></span></div>Lime / Forest / Gold / Maroon</div>
<div class="preset-chip" onclick="applyPreset('#80CBC4','#004D40','#FFCC80','#BF360C',this)"><div class="preset-strip"><span style="background:#80CBC4"></span><span style="background:#004D40"></span><span style="background:#BF360C"></span><span style="background:#FFCC80"></span></div>Mint / DarkTeal / Apricot / Burnt</div>
<div class="preset-chip" onclick="applyPreset('#CE93D8','#4A148C','#FFF176','#E65100',this)"><div class="preset-strip"><span style="background:#CE93D8"></span><span style="background:#4A148C"></span><span style="background:#E65100"></span><span style="background:#FFF176"></span></div>Orchid / Purple / Yellow / Fire</div>
<div class="preset-chip" onclick="applyPreset('#BBDEFB','#0D47A1','#A5D6A7','#F4511E',this)"><div class="preset-strip"><span style="background:#BBDEFB"></span><span style="background:#0D47A1"></span><span style="background:#F4511E"></span><span style="background:#A5D6A7"></span></div>Blue / Navy / Sage / Ember</div>
</div>
<label style="margin-top:0.5rem">Presets — solid</label>
<div class="presets-row">
<div class="preset-chip" onclick="applyPreset('#00897B','#00897B','#E64A19','#E64A19',this)"><div class="preset-strip"><span style="background:#00897B"></span><span style="background:#00897B"></span><span style="background:#E64A19"></span><span style="background:#E64A19"></span></div>Teal / Coral</div>
<div class="preset-chip" onclick="applyPreset('#2471A3','#2471A3','#E67E22','#E67E22',this)"><div class="preset-strip"><span style="background:#2471A3"></span><span style="background:#2471A3"></span><span style="background:#E67E22"></span><span style="background:#E67E22"></span></div>Blue / Orange</div>
<div class="preset-chip" onclick="applyPreset('#5e35b1','#5e35b1','#f9a825','#f9a825',this)"><div class="preset-strip"><span style="background:#5e35b1"></span><span style="background:#5e35b1"></span><span style="background:#f9a825"></span><span style="background:#f9a825"></span></div>Purple / Gold</div>
<div class="preset-chip" onclick="applyPreset('#546e7a','#546e7a','#c2185b','#c2185b',this)"><div class="preset-strip"><span style="background:#546e7a"></span><span style="background:#546e7a"></span><span style="background:#c2185b"></span><span style="background:#c2185b"></span></div>Slate / Rose</div>
<div class="preset-chip" onclick="applyPreset('#6A9EC6','#6A9EC6','#D4A76A','#D4A76A',this)"><div class="preset-strip"><span style="background:#6A9EC6"></span><span style="background:#6A9EC6"></span><span style="background:#D4A76A"></span><span style="background:#D4A76A"></span></div>Steel / Wheat</div>
<div class="preset-chip" onclick="applyPreset('#6495ED','#6495ED','#FF6347','#FF6347',this)"><div class="preset-strip"><span style="background:#6495ED"></span><span style="background:#6495ED"></span><span style="background:#FF6347"></span><span style="background:#FF6347"></span></div>Cornflower / Tomato</div>
<div class="preset-chip" onclick="applyPreset('#87CEEB','#87CEEB','#FFD700','#FFD700',this)"><div class="preset-strip"><span style="background:#87CEEB"></span><span style="background:#87CEEB"></span><span style="background:#FFD700"></span><span style="background:#FFD700"></span></div>SkyBlue / Gold</div>
<div class="preset-chip" onclick="applyPreset('#90EE90','#90EE90','#DDA0DD','#DDA0DD',this)"><div class="preset-strip"><span style="background:#90EE90"></span><span style="background:#90EE90"></span><span style="background:#DDA0DD"></span><span style="background:#DDA0DD"></span></div>LightGreen / Plum</div>
<div class="preset-chip" onclick="applyPreset('#FFA07A','#FFA07A','#20B2AA','#20B2AA',this)"><div class="preset-strip"><span style="background:#FFA07A"></span><span style="background:#FFA07A"></span><span style="background:#20B2AA"></span><span style="background:#20B2AA"></span></div>Salmon / Teal</div>
</div>
<label style="margin-top:0.5rem">Presets — coloring modes</label>
<div class="presets-row">
<div class="preset-chip" onclick="applyCxcPreset('plddt',this)"><div class="preset-strip"><span style="background:#0053D6"></span><span style="background:#65CBF3"></span><span style="background:#FFDB13"></span><span style="background:#FF7D45"></span></div>pLDDT</div>
<div class="preset-chip" onclick="applyCxcPreset('bychain',this)"><div class="preset-strip"><span style="background:#6495ED"></span><span style="background:#FF6347"></span><span style="background:#90EE90"></span><span style="background:#DDA0DD"></span></div>bychain</div>
<div class="preset-chip" onclick="applyCxcPreset('bypolymer',this)"><div class="preset-strip"><span style="background:#87CEEB"></span><span style="background:#FFA07A"></span><span style="background:#98FB98"></span><span style="background:#DDA0DD"></span></div>bypolymer</div>
</div>
</div>
<hr style="border:none; border-top:1px solid #e0e0e0; margin-bottom:1rem;">
<div class="input-tabs" style="margin-bottom:0.8rem;">
<button class="input-tab active" data-tab="chimerax" onclick="switchScriptTab('chimerax')">ChimeraX</button>
<button class="input-tab" data-tab="pymol" onclick="switchScriptTab('pymol')">PyMOL</button>
</div>
<div class="script-preview" id="script-preview"></div>
<div class="download-row">
<a class="btn-download cxc" id="dl-script" download>↓ Download <span id="dl-script-ext">.cxc</span></a>
<a class="btn-download pdb" id="dl-pdb" target="_blank">↓ Download .pdb</a>
<button class="btn-download" id="btn-copy" style="background:white; color:#2471A3; border:2px solid #2471A3; cursor:pointer;" onclick="copyScript()">Copy to Clipboard</button>
</div>
<div class="info-box" style="margin-top: 1rem;">
The .pdb link opens the file from FlyPredictome. Save it in the same folder as the script file, then open the script in ChimeraX or PyMOL.
</div>
</div>
<!-- Per-Residue pLDDT -->
<div class="card result-card" id="plddt-card" style="display:none;">
<h2>Per-Residue pLDDT <span class="model-badge" id="plddt-model-badge"></span></h2>
<div style="font-size:0.82rem; color:#888; margin-bottom:0.5rem;">
Per-residue pLDDT for each chain across all ranks. Selected rank as solid line; other ranks as avg ± SD shading.
</div>
<div id="plddt-charts"></div>
</div>
</div>
<!-- Instructions -->
<div class="card" id="help-section">
<div class="step-header">How to Use <a href="about.html" style="font-size:0.8rem; font-weight:400; color:#2471A3;">(Full guide)</a></div>
<div class="help-content">
<div class="help-col">
<h4>Quick Start</h4>
<ol start="0">
<li>Go to <a href="https://www.flyrnai.org/tools/fly_predictome" target="_blank">FlyPredictome</a> and search for a protein pair</li>
<li>Copy the FlyPredictome result page URL</li>
<li>Paste the URL above and click <strong>Generate</strong></li>
<li>Download the script (.cxc or .pml) and structure file, place both in the same folder</li>
<li>Open the script in ChimeraX (<code>.cxc</code>) or PyMOL (<code>.pml</code>)</li>
</ol>
</div>
<div class="help-col">
<h4><a href="https://github.com/flyark/AFM-LIS" target="_blank" style="color:#2471A3; text-decoration:underline;">AFM-LIS</a> Metrics (<a href="https://doi.org/10.1101/2024.02.19.580970" target="_blank" style="color:#2471A3;">Kim et al. 2024</a>; <a href="https://doi.org/10.64898/2026.04.14.718529" target="_blank" style="color:#2471A3;">Kim et al. 2026</a>)</h4>
<table class="help-table">
<tr><td><strong>iLIS</strong></td><td>integrated LIS — √(LIS × cLIS)</td></tr>
<tr><td><strong>iLIA</strong></td><td>integrated LIA — √(LIA × cLIA), geometric mean of interface area counts</td></tr>
<tr><td><strong>iLISA</strong></td><td>integrated LISA — iLIS × iLIA, overall binding strength</td></tr>
<tr><td><strong>LIS</strong></td><td>Local Interaction Score — normalized PAE confidence (0–1)</td></tr>
<tr><td><strong>cLIS</strong></td><td>contact-filtered LIS — restricted to direct contacts</td></tr>
<tr><td><strong>LIR</strong></td><td>Local Interaction Residues (PAE ≤ 12 Å)</td></tr>
<tr><td><strong>cLIR</strong></td><td>contact-filtered LIR (PAE ≤ 12 Å & Cβ ≤ 8 Å)</td></tr>
</table>
<h4 style="margin-top:0.8rem;">Confidence Metric (from ColabFold)</h4>
<table class="help-table">
<tr><td><strong>ipTM</strong></td><td>interface predicted TM-score — global interface confidence from the prediction model</td></tr>
</table>
<p style="font-size:0.78rem; color:#888; margin-top:0.4rem; line-height:1.4;">PAE (Predicted Aligned Error) measures how confidently the model predicts the relative position of two residues — lower values indicate higher confidence.</p>
</div>
</div>
</div>
<div class="footer">
<a href="https://github.com/flyark/LIVIA" target="_blank">LIVIA GitHub</a> · <a href="https://github.com/flyark/AFM-LIS" target="_blank">AFM-LIS GitHub</a>
<br>
<a href="https://doi.org/10.64898/2026.05.01.721633" target="_blank">Kim & Perrimon (2026)</a>
<br>
Ah-Ram Kim · Harvard Medical School
</div>
</div>
<script src="js/livia-core.js"></script>
<script src="js/livia-scripts.js"></script>
<script src="js/livia-viewer.js"></script>
<script src="js/livia-colors.js"></script>
<script>
// Wire shared module callbacks
onColorChange = () => { if (flyParsed && flyCurrentRank) { loadRank(flyCurrentRank); updateCombinedChord(); renderChainToggleBar(); } };
onScriptTabSwitch = () => { updateScriptPreview(); };
// Initialize color pickers
document.addEventListener('DOMContentLoaded', () => {
initColorPickers();
// URL parameter support: ?gene=Akt1 or ?pair=Akt1,foxo
const params = new URLSearchParams(window.location.search);
if (params.get('gene')) {
switchTab('search');
document.getElementById('gene-search-input').value = params.get('gene');
setTimeout(() => searchGene(), 500);
} else if (params.get('pair')) {
const parts = params.get('pair').split(',');
if (parts.length === 2) {
switchTab('pair');
document.getElementById('pair-gene-a').value = parts[0].trim();
document.getElementById('pair-gene-b').value = parts[1].trim();
setTimeout(() => searchGenePair(), 500);
}
} else if (params.get('url')) {
switchTab('url');
document.getElementById('url-input').value = params.get('url');
setTimeout(() => generate(), 500);
}
});
// ── Tab switching ──
function switchTab(tab) {
document.getElementById('search-panel').style.display = tab === 'search' ? '' : 'none';
document.getElementById('pair-panel').style.display = tab === 'pair' ? '' : 'none';
document.getElementById('url-panel').style.display = tab === 'url' ? '' : 'none';
document.querySelectorAll('.input-tab').forEach(t => t.classList.remove('active'));
document.querySelector('.input-tab[data-tab="' + tab + '"]').classList.add('active');
}
// ── FlyPredictome JSON parser (strips leading MySQL DNS debug text) ──
// The debug block contains `[1002]` which fools a naive "first bracket" scan,
// so we anchor on the `<br>` that precedes the real payload.
function parseFpJson(text) {
if (!text) return null;
const m = text.match(/<br>\s*([\[{])/);
const start = m ? text.indexOf(m[1], m.index) : text.search(/[\[{]/);
if (start < 0) return null;
return JSON.parse(text.slice(start));
}
// ── Gene search ──
let geneAcDebounce = null;
let geneAcIdx = -1;
function hideGeneAc() { document.getElementById('gene-ac-list').style.display = 'none'; geneAcIdx = -1; }
function handleGeneAcKey(e) {
const list = document.getElementById('gene-ac-list');
const items = list.querySelectorAll('div');
if (list.style.display !== 'none' && items.length > 0) {
if (e.key === 'ArrowDown') {
e.preventDefault();
geneAcIdx = Math.min(geneAcIdx + 1, items.length - 1);
items.forEach((it, i) => { it.style.background = i === geneAcIdx ? '#eaf2f8' : ''; });
items[geneAcIdx].scrollIntoView({ block: 'nearest' });
return;
}
if (e.key === 'ArrowUp') {
e.preventDefault();
geneAcIdx = Math.max(geneAcIdx - 1, 0);
items.forEach((it, i) => { it.style.background = i === geneAcIdx ? '#eaf2f8' : ''; });
items[geneAcIdx].scrollIntoView({ block: 'nearest' });
return;
}
if (e.key === 'Enter') {
e.preventDefault();
if (geneAcIdx >= 0 && geneAcIdx < items.length) {
items[geneAcIdx].click();
} else {
hideGeneAc();
searchGene();
}
return;
}
if (e.key === 'Escape') {
hideGeneAc();
return;
}
} else if (e.key === 'Enter') {
hideGeneAc();
searchGene();
}
}
async function searchUniprotAc(query) {
clearTimeout(geneAcDebounce);
const list = document.getElementById('gene-ac-list');
if (query.length < 2) { list.style.display = 'none'; return; }
geneAcDebounce = setTimeout(async () => {
try {
const url = `https://rest.uniprot.org/uniprotkb/search?query=${encodeURIComponent('"' + query + '"')}+AND+organism_id:7227&fields=accession,gene_names,protein_name,organism_name,xref_flybase&size=8&format=json`;
const resp = await fetch(url);
if (!resp.ok) return;
const data = await resp.json();
const results = data.results || [];
list.innerHTML = '';
if (results.length === 0) { list.style.display = 'none'; return; }
for (const r of results) {
const acc = r.primaryAccession || '';
const gene = (r.genes || [{}])[0]?.geneName?.value || '';
const synonyms = (r.genes || [{}])[0]?.synonyms?.map(s => s.value).join(', ') || '';
const name = r.proteinDescription?.recommendedName?.fullName?.value
|| r.proteinDescription?.submissionNames?.[0]?.fullName?.value || '';
// Extract FBgn from FlyBase cross-reference
const flybaseXref = (r.uniProtKBCrossReferences || []).find(x => x.database === 'FlyBase');
const fbgn = flybaseXref?.id || '';
const item = document.createElement('div');
item.style.cssText = 'padding:0.5rem 0.8rem; cursor:pointer; border-bottom:1px solid #f0f0f0; font-size:0.85rem;';
item.innerHTML = '<strong style="color:#2471A3;">' + esc(gene) + '</strong>' +
(synonyms ? ' <span style="color:#999; font-size:0.75rem;">(' + esc(synonyms) + ')</span>' : '') +
(fbgn ? ' <span style="color:#bbb; font-size:0.7rem;">' + esc(fbgn) + '</span>' : '') +
'<br><span style="color:#555; font-size:0.78rem;">' + esc(name.substring(0, 60)) + '</span>' +
' <span style="color:#aaa; font-size:0.72rem;">' + esc(acc) + '</span>';
item.addEventListener('mouseenter', () => { item.style.background = '#eaf2f8'; });
item.addEventListener('mouseleave', () => { item.style.background = ''; });
item.addEventListener('click', ((g, f) => () => {
document.getElementById('gene-search-input').value = g;
list.style.display = 'none';
searchGene(f); // pass FBgn directly
})(gene, fbgn));
list.appendChild(item);
}
list.style.display = '';
} catch (e) { /* silent */ }
}, 300);
}
document.addEventListener('click', (e) => {
if (!e.target.closest('#search-panel')) hideGeneAc();
if (!e.target.closest('#pair-panel')) hidePairAc();
});
async function searchGene(presetFbgn) {
const query = document.getElementById('gene-search-input').value.trim();
if (!query) return;
const statusEl = document.getElementById('search-status');
const resultsEl = document.getElementById('search-results');
statusEl.textContent = 'Searching...';
statusEl.style.color = '#2471A3';
resultsEl.style.display = 'none';
try {
let fbgnId, geneSymbol;
if (presetFbgn) {
// FBgn provided from UniProt autocomplete — skip get_fbgns lookup
fbgnId = presetFbgn;
geneSymbol = query;
} else {
// Resolve gene symbol to FBgn via FlyPredictome
const fbgnText = await fetchTextViaProxy('https://www.flyrnai.org/tools/fly_predictome/web/get_fbgns/' + encodeURIComponent(query));
if (!fbgnText) throw new Error('Could not reach FlyPredictome. Try again.');
const fbgnData = parseFpJson(fbgnText);
if (!fbgnData.data || fbgnData.data.length === 0) {
statusEl.textContent = 'No genes found for "' + query + '".';
statusEl.style.color = '#c0392b';
return;
}
// Find exact gene symbol match (case-sensitive), fall back to first result
let bestRow = fbgnData.data[0];
for (const row of fbgnData.data) {
if (row[2] === query) { bestRow = row; break; }
}
if (bestRow[2] !== query) {
for (const row of fbgnData.data) {
if (row[2].toLowerCase() === query.toLowerCase()) { bestRow = row; break; }
}
}
const fbgnHtml = bestRow[1];
const fbgnMatch = fbgnHtml.match(/FBgn\d+/);
if (!fbgnMatch) {
statusEl.textContent = 'Could not resolve gene ID.';
statusEl.style.color = '#c0392b';
return;
}
fbgnId = fbgnMatch[0];
geneSymbol = bestRow[2] || query;
}
statusEl.textContent = 'Found: ' + geneSymbol + ' (' + fbgnId + '). Loading interaction partners...';
// Step 2: Fetch protein info to get canonical lengths for partial detection
let canonicalLengths = {};
try {
const protInfoText = await fetchTextViaProxy('https://www.flyrnai.org/tools/fly_predictome/web/get_protein_info/' + fbgnId);
if (protInfoText) {
const protInfo = parseFpJson(protInfoText);
// Get max sequence length across all isoforms as canonical
for (const iso of protInfo) {
const len = parseInt(iso.seq?.len) || 0;
if (len > (canonicalLengths[fbgnId] || 0)) canonicalLengths[fbgnId] = len;
}
}
} catch (e) { /* non-critical */ }
// Step 3: Fetch famdb_summary to get all partners
const summaryResp = await fetchTextViaProxy('https://www.flyrnai.org/tools/fly_predictome/web/famdb_summary/' + fbgnId + '/');
if (!summaryResp) throw new Error('Could not fetch interaction data.');
// Step 4: Parse the HTML table
const partners = parseFamdbSummary(summaryResp, fbgnId, geneSymbol);
if (partners.length === 0) {
statusEl.textContent = 'No interaction partners found for ' + geneSymbol + '.';
statusEl.style.color = '#c0392b';
return;
}
// Step 5: Detect partial predictions by comparing predicted length vs canonical
const queryCanonical = canonicalLengths[fbgnId] || 0;
for (const p of partners) {
// Query protein length in this prediction
const queryLen = (p.fbgn1 === fbgnId) ? p.lenA : p.lenB;
const partnerLen = (p.fbgn1 === fbgnId) ? p.lenB : p.lenA;
p.isQueryPartial = queryCanonical > 0 && queryLen < queryCanonical * 0.9;
// Partner partial detection: check if partner length is significantly shorter than any prediction of it
// We approximate by comparing against the max length seen for this partner across all rows
p.queryLen = queryLen;
p.partnerLen = partnerLen;
}
// Detect partner partial: find max length per partner FBgn across all rows
const partnerMaxLen = {};
for (const p of partners) {
const key = p.partnerFbgn;
if (!partnerMaxLen[key] || p.partnerLen > partnerMaxLen[key]) partnerMaxLen[key] = p.partnerLen;
}
for (const p of partners) {
const maxLen = partnerMaxLen[p.partnerFbgn] || p.partnerLen;
p.isPartnerPartial = p.partnerLen < maxLen * 0.9;
}
statusEl.textContent = geneSymbol + ' (' + fbgnId + '): ' + partners.length + ' predicted interaction partners. Click a row to analyze.';
statusEl.style.color = '#27ae60';
// Step 6: Display partner table
displayPartnerTable(partners, geneSymbol);
} catch (e) {
statusEl.textContent = 'Error: ' + e.message;
statusEl.style.color = '#c0392b';
}
}
// ── Gene Pair search ──
let pairAcDebounce = null;
let pairAcIdx = -1;
function hidePairAc() {
document.getElementById('pair-ac-a').style.display = 'none';
document.getElementById('pair-ac-b').style.display = 'none';
pairAcIdx = -1;
}
function searchPairAc(inputEl, listId) {
clearTimeout(pairAcDebounce);
const list = document.getElementById(listId);
const query = inputEl.value.trim();
if (query.length < 2) { list.style.display = 'none'; return; }
pairAcDebounce = setTimeout(async () => {
try {
const url = `https://rest.uniprot.org/uniprotkb/search?query=${encodeURIComponent('"' + query + '"')}+AND+organism_id:7227&fields=accession,gene_names,protein_name,organism_name,xref_flybase&size=8&format=json`;
const resp = await fetch(url);
if (!resp.ok) return;
const data = await resp.json();
const results = data.results || [];
list.innerHTML = '';
if (results.length === 0) { list.style.display = 'none'; return; }
for (const r of results) {
const acc = r.primaryAccession || '';
const gene = (r.genes || [{}])[0]?.geneName?.value || '';
const synonyms = (r.genes || [{}])[0]?.synonyms?.map(s => s.value).join(', ') || '';
const name = r.proteinDescription?.recommendedName?.fullName?.value
|| r.proteinDescription?.submissionNames?.[0]?.fullName?.value || '';
const flybaseXref = (r.uniProtKBCrossReferences || []).find(x => x.database === 'FlyBase');
const fbgn = flybaseXref?.id || '';
const item = document.createElement('div');
item.style.cssText = 'padding:0.5rem 0.8rem; cursor:pointer; border-bottom:1px solid #f0f0f0; font-size:0.85rem;';
item.innerHTML = '<strong style="color:#2471A3;">' + esc(gene) + '</strong>' +
(synonyms ? ' <span style="color:#999; font-size:0.75rem;">(' + esc(synonyms) + ')</span>' : '') +
(fbgn ? ' <span style="color:#bbb; font-size:0.7rem;">' + esc(fbgn) + '</span>' : '') +
'<br><span style="color:#555; font-size:0.78rem;">' + esc(name.substring(0, 60)) + '</span>' +
' <span style="color:#aaa; font-size:0.72rem;">' + esc(acc) + '</span>';
item.addEventListener('mouseenter', () => { item.style.background = '#eaf2f8'; });
item.addEventListener('mouseleave', () => { item.style.background = ''; });
item.addEventListener('click', ((g, f) => () => {
inputEl.value = g;
inputEl.dataset.fbgn = f;
list.style.display = 'none';
})(gene, fbgn));
list.appendChild(item);
}
list.style.display = '';
} catch (e) { /* silent */ }
}, 300);
}
function handlePairAcKey(e, inputId, listId) {
const list = document.getElementById(listId);
const items = list.querySelectorAll('div');
if (list.style.display !== 'none' && items.length > 0) {
if (e.key === 'ArrowDown') {
e.preventDefault();
pairAcIdx = Math.min(pairAcIdx + 1, items.length - 1);
items.forEach((it, i) => { it.style.background = i === pairAcIdx ? '#eaf2f8' : ''; });
items[pairAcIdx].scrollIntoView({ block: 'nearest' });
return;
}
if (e.key === 'ArrowUp') {
e.preventDefault();
pairAcIdx = Math.max(pairAcIdx - 1, 0);
items.forEach((it, i) => { it.style.background = i === pairAcIdx ? '#eaf2f8' : ''; });
items[pairAcIdx].scrollIntoView({ block: 'nearest' });
return;
}
if (e.key === 'Enter') {
e.preventDefault();
if (pairAcIdx >= 0 && pairAcIdx < items.length) {
items[pairAcIdx].click();
} else {
list.style.display = 'none';
}
return;
}
if (e.key === 'Escape') { list.style.display = 'none'; pairAcIdx = -1; return; }
} else if (e.key === 'Enter') {
searchGenePair();
}
}
function setPairAndSearch(a, b) {
const inputA = document.getElementById('pair-gene-a');
const inputB = document.getElementById('pair-gene-b');
inputA.value = a; inputA.dataset.fbgn = '';
inputB.value = b; inputB.dataset.fbgn = '';
searchGenePair();
}
async function resolveGeneToFbgn(query, presetFbgn) {
if (presetFbgn) return { fbgn: presetFbgn, symbol: query };
const fbgnText = await fetchTextViaProxy('https://www.flyrnai.org/tools/fly_predictome/web/get_fbgns/' + encodeURIComponent(query));
if (!fbgnText) throw new Error('Could not reach FlyPredictome.');
const fbgnData = parseFpJson(fbgnText);
if (!fbgnData.data || fbgnData.data.length === 0) throw new Error('Gene "' + query + '" not found.');
let bestRow = fbgnData.data[0];
for (const row of fbgnData.data) {
if (row[2] === query) { bestRow = row; break; }
}
if (bestRow[2] !== query) {
for (const row of fbgnData.data) {
if (row[2].toLowerCase() === query.toLowerCase()) { bestRow = row; break; }
}
}
const fbgnMatch = bestRow[1].match(/FBgn\d+/);
if (!fbgnMatch) throw new Error('Could not resolve gene ID for "' + query + '".');
return { fbgn: fbgnMatch[0], symbol: bestRow[2] || query };
}
async function searchGenePair() {
const inputA = document.getElementById('pair-gene-a');
const inputB = document.getElementById('pair-gene-b');
const queryA = inputA.value.trim();
const queryB = inputB.value.trim();
if (!queryA || !queryB) return;
const statusEl = document.getElementById('pair-status');
const resultsEl = document.getElementById('pair-results');
statusEl.textContent = 'Resolving gene pair...';
statusEl.style.color = '#2471A3';
resultsEl.style.display = 'none';
try {
// Step 1: Resolve both genes to FBgn IDs in parallel
const [geneA, geneB] = await Promise.all([
resolveGeneToFbgn(queryA, inputA.dataset.fbgn || ''),
resolveGeneToFbgn(queryB, inputB.dataset.fbgn || '')
]);
statusEl.textContent = 'Found: ' + geneA.symbol + ' (' + geneA.fbgn + ') & ' + geneB.symbol + ' (' + geneB.fbgn + '). Searching interaction...';
// Step 2: Fetch famdb_summary and canonical lengths in parallel
const [summaryResp, canonicalA, canonicalB] = await Promise.all([
fetchTextViaProxy('https://www.flyrnai.org/tools/fly_predictome/web/famdb_summary/' + geneA.fbgn + '/'),
fetchTextViaProxy('https://www.flyrnai.org/tools/fly_predictome/web/get_protein_info/' + geneA.fbgn).then(t => {
const arr = parseFpJson(t);
return arr ? Math.max(...arr.map(i => parseInt(i.seq?.len) || 0)) : 0;
}).catch(() => 0),
fetchTextViaProxy('https://www.flyrnai.org/tools/fly_predictome/web/get_protein_info/' + geneB.fbgn).then(t => {
const arr = parseFpJson(t);
return arr ? Math.max(...arr.map(i => parseInt(i.seq?.len) || 0)) : 0;
}).catch(() => 0)
]);
if (!summaryResp) throw new Error('Could not fetch interaction data.');
const partners = parseFamdbSummary(summaryResp, geneA.fbgn, geneA.symbol);
// Step 3: Find ALL matches for gene B in the partner list
const matches = partners.filter(p =>
p.partnerFbgn === geneB.fbgn ||
p.fbgn1 === geneB.fbgn || p.fbgn2 === geneB.fbgn ||
p.sym1.toLowerCase() === geneB.symbol.toLowerCase() ||
p.sym2.toLowerCase() === geneB.symbol.toLowerCase()
);
// Detect partial proteins (mapped to sym1/sym2 columns)
for (const p of matches) {
const isA1 = (p.fbgn1 === geneA.fbgn);
const canon1 = isA1 ? canonicalA : canonicalB;
const canon2 = isA1 ? canonicalB : canonicalA;
p.isPartial1 = canon1 > 0 && p.lenA < canon1 * 0.9;
p.isPartial2 = canon2 > 0 && p.lenB < canon2 * 0.9;
}
if (matches.length === 0) {
statusEl.textContent = 'No predicted interaction found between ' + geneA.symbol + ' and ' + geneB.symbol + '.';
statusEl.style.color = '#c0392b';
return;
}
// Single match → load directly
if (matches.length === 1 && matches[0].detailUrl) {
statusEl.textContent = geneA.symbol + ' \u2014 ' + geneB.symbol + ': loading analysis...';
statusEl.style.color = '#27ae60';
document.getElementById('url-input').value = matches[0].detailUrl;
switchTab('url');
generate();
return;
}
// Multiple matches → show selection table
statusEl.textContent = geneA.symbol + ' \u2014 ' + geneB.symbol + ': ' + matches.length + ' prediction sets found. Click a row to analyze.';
statusEl.style.color = '#27ae60';
displayPairResults(matches);
} catch (e) {
statusEl.textContent = 'Error: ' + e.message;
statusEl.style.color = '#c0392b';
}
}
function displayPairResults(matches) {
const container = document.getElementById('pair-results');
container.innerHTML = '';
container.style.display = '';
const tableWrap = document.createElement('div');
tableWrap.style.cssText = 'overflow-x:auto; max-height:300px; overflow-y:auto; border:1px solid #e0e0e0; border-radius:8px;';
const table = document.createElement('table');
table.className = 'data-table';
table.style.fontSize = '0.8rem';
table.innerHTML =
'<thead style="position:sticky; top:0; z-index:1;">' +
'<tr>' +
'<th>Protein A</th>' +
'<th>Protein B</th>' +
'<th>iLIS (best)</th>' +
'<th>ipTM (best)</th>' +
'<th>Len A</th>' +
'<th>Len B</th>' +
'<th>MIST</th>' +
'</tr>' +
'</thead>' +
'<tbody></tbody>';
const tbody = table.querySelector('tbody');
for (const p of matches) {
const tr = document.createElement('tr');
tr.className = 'clickable';
tr.style.cursor = 'pointer';
const mistStr = [p.mistPPI ? 'PPI' : '', p.mistGI ? 'GI' : ''].filter(Boolean).join(', ') || '\u2014';
const partial1 = p.isPartial1 ? ' <span style="color:#c0392b; font-size:0.7rem; font-weight:600;">(Partial)</span>' : '';
const partial2 = p.isPartial2 ? ' <span style="color:#c0392b; font-size:0.7rem; font-weight:600;">(Partial)</span>' : '';
tr.innerHTML =
'<td><strong>' + esc(p.sym1) + '</strong> <span style="color:#999; font-size:0.72rem;">' + esc(p.fbgn1) + '</span>' + partial1 + '</td>' +
'<td><strong>' + esc(p.sym2) + '</strong> <span style="color:#999; font-size:0.72rem;">' + esc(p.fbgn2) + '</span>' + partial2 + '</td>' +
'<td>' + ilisColor(p.ilisBest) + '</td>' +
'<td>' + p.iptmBest.toFixed(2) + '</td>' +
'<td>' + p.lenA + '</td>' +
'<td>' + p.lenB + '</td>' +
'<td>' + mistStr + '</td>';
if (p.detailUrl) {
tr.addEventListener('click', ((url) => (e) => {
if (e.ctrlKey || e.metaKey) {
window.open(window.location.pathname + '?url=' + encodeURIComponent(url), '_blank');
} else {
document.getElementById('url-input').value = url;
switchTab('url');
generate();
}
})(p.detailUrl));
}
tbody.appendChild(tr);
}