-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathortholog_predictome.html
More file actions
3281 lines (2995 loc) · 189 KB
/
Copy pathortholog_predictome.html
File metadata and controls
3281 lines (2995 loc) · 189 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 — Ortholog Interactome</title>
<link rel="stylesheet" href="css/livia.css?v=20260717">
<style>
/* ── Page-specific styles for Ortholog Predictome ── */
.step-link { color: #2471A3; text-decoration: none; }
.step-link:hover { text-decoration: underline; }
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-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;
}
.fetch-status { font-size: 0.82rem; }
.data-table { font-size: 0.82rem; }
.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> — Ortholog Interactome</h1>
<p>Analyze ortholog protein interactions, primarily human kinase-TF predictions (<a href="https://www.biorxiv.org/content/10.1101/2025.10.10.681672" target="_blank" style="color:#2471A3;">Kim et al., 2025</a>), from <a href="https://www.flyrnai.org/tools/fly_predictome" target="_blank" style="color:#2471A3;">FlyPredictome</a> ortholog predictions</p>
<div class="header-links">
<a href="index.html">Home</a>
<a href="universal.html">Prediction Analysis</a>
<a href="flypredictome.html">FlyPredictome</a>
<a href="ortholog_predictome.html" class="active">Ortholog Interactome</a>
<a href="dimer.html">AFDB Dimer</a>
<a href="monomer.html">AFDB Monomer Subdomain</a>
<a href="clip.html">cLIP</a>
<a href="network.html">PPI Network</a>
<a href="tutorials.html">Tutorials</a>
<a href="about.html">About</a>
<a href="https://github.com/flyark/LIVIA" target="_blank">GitHub</a>
</div>
</div>
</div>
<div class="container">
<!-- Bookmarklet tip -->
<a href="tutorials.html#bm-install" style="display:flex; align-items:center; gap:0.6rem; background:#eaf2f8; border:1px solid #d4e3f0; border-radius:8px; padding:0.5rem 0.9rem; margin-bottom:1rem; text-decoration:none; color:#1a5276; font-size:0.85rem;">
<span style="font-size:1rem; line-height:1;">🔖</span>
<span style="flex:1;">On a <b>FlyPredictome ortholog</b> page? Jump straight to this analysis with the <b>LIVIA bookmarklet</b> — one click, no copy-paste.</span>
<span style="color:#2471A3; font-weight:600; white-space:nowrap;">Get it →</span>
</a>
<!-- Input -->
<div class="card">
<div class="step-header"><a href="https://www.flyrnai.org/tools/fly_predictome" target="_blank" class="step-link">FlyPredictome</a> Ortholog Interaction Lookup</div>
<div style="font-size:0.8rem; color:#888; margin-bottom:0.6rem;">Precomputed PPI predictions for human (and other species) from <a href="https://www.flyrnai.org/tools/fly_predictome" target="_blank" style="color:#2471A3;">FlyPredictome</a> ortholog search. Search by gene name or paste a prediction page URL.</div>
<div class="input-tabs">
<button class="input-tab active" data-tab="search" onclick="switchTab('search')">Search by Gene</button>
<button class="input-tab" 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;">
<select id="species-select" style="padding:0.5rem 0.4rem; border:2px solid #e0e0e0; border-radius:8px; font-size:0.85rem; background:white;">
<option value="9606" selected>Human</option>
<option value="10090">Mouse</option>
<option value="7955">Zebrafish</option>
<option value="6239">Worm</option>
<option value="4932">Yeast</option>
</select>
<div style="position:relative; flex:1;">
<input type="text" id="gene-search-input"
placeholder="e.g., TP53, CDK2, AKT1, BRAF..."
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='CDK2';searchGene()">CDK2</button>
<button class="example-btn" onclick="document.getElementById('gene-search-input').value='TP53';searchGene()">TP53</button>
<button class="example-btn" onclick="document.getElementById('gene-search-input').value='CSNK2A1';searchGene()">CSNK2A1</button>
<button class="example-btn" onclick="document.getElementById('gene-search-input').value='GSK3B';searchGene()">GSK3B</button>
<button class="example-btn" onclick="document.getElementById('gene-search-input').value='DYRK1A';searchGene()">DYRK1A</button>
<button class="example-btn" onclick="document.getElementById('gene-search-input').value='CDK7';searchGene()">CDK7</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>
<!-- 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_all/.../9606/9606/"
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_all/P24941/P20248/SET_183/9606/9606/';generate()">CDK2–CCNA2</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details_all/P53_HUMAN/MDM2_HUMAN/SET_393/9606/9606/';generate()">TP53–MDM2</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details_all/MK14_HUMAN/MKNK1_HUMAN/SET_259/9606/9606/';generate()">MAPK14–MKNK1</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details_all/P00519/P46108/SET_185/9606/9606/';generate()">ABL1–CRK</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details_all/P01106_HUMAN/DYR1A_HUMAN/SET_216/9606/9606/';generate()">DYRK1A–MYC</button>
<button class="example-btn" onclick="document.getElementById('url-input').value='https://www.flyrnai.org/tools/fly_predictome/web/famdb_details_all/AURKA_HUMAN/ATF5_HUMAN/SET_2272/9606/9606/';generate()">AURKA–ATF5</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="downloadCSV()">↓ 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;">
<div style="display:flex; align-items:center; gap:0.9rem; flex-wrap:wrap; margin-bottom:0.5rem;">
<h2 style="margin-bottom:0;">Sequence Viewer</h2>
<div class="model-selector" id="seq-model-selector"></div>
</div>
<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;">
<div style="display:flex; align-items:center; gap:0.9rem; flex-wrap:wrap; margin-bottom:0.5rem;">
<h2 style="margin-bottom:0;">Linear Contact Map</h2>
<div class="model-selector" id="contact-model-selector"></div>
</div>
<div style="display:flex; align-items:center; gap:0.9rem 1.2rem; flex-wrap:wrap; font-size:0.82rem; color:#888; margin-bottom:0.5rem;">
<span>Lines connect cLIR residue pairs within Cβ distance in the 3D structure. Per-rank structures fetched automatically.</span>
<div style="flex-basis:100%; height:0;"></div><!-- controls on their own line, below the description -->
<span style="font-size:0.82rem; color:#555; white-space:nowrap; display:inline-flex; align-items:center;">domains:</span>
<label style="display:inline-flex; align-items:center; gap:4px; cursor:pointer; white-space:nowrap;"><input type="checkbox" id="contact-show-domains" checked onchange="window.__redrawConn&&window.__redrawConn()"> UniProt/Pfam</label>
<label style="display:inline-flex; align-items:center; gap:4px; cursor:pointer; white-space:nowrap;"><input type="checkbox" id="contact-show-ted" checked onchange="window.__redrawConn&&window.__redrawConn()"> TED</label>
<label style="display:inline-flex; align-items:center; gap:4px; cursor:pointer; white-space:nowrap;" title="Per-residue pLDDT confidence strip beside each chain bar (AlphaFold color scale)"><input type="checkbox" id="contact-show-plddt" checked onchange="window.__redrawConn&&window.__redrawConn()"> pLDDT</label>
<label style="display:inline-flex; align-items:center; gap:4px; cursor:pointer; white-space:nowrap;"><input type="checkbox" id="contact-show-ids" checked onchange="window.showConnIDs=this.checked; window.__redrawConn&&window.__redrawConn()"> chain IDs</label>
<label style="display:inline-flex; align-items:center; gap:4px; cursor:pointer; white-space:nowrap;"><input type="checkbox" id="contact-swap-ab" onchange="window.__redrawConn&&window.__redrawConn()"> swap chains (top↔bottom)</label>
<label style="display:inline-flex; align-items:center; gap:4px; white-space:nowrap;">x-ticks <input type="number" id="contact-xticks" min="2" max="30" value="5" style="width:48px; font-size:0.8rem; padding:1px 3px;" onchange="window.__redrawConn&&window.__redrawConn()"></label>
</div>
<canvas id="connection-canvas"></canvas>
<div id="contact-count-text" style="font-size:0.8rem; color:#888; text-align:center; margin-top:4px;"></div>
<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 -->
<div class="card result-card" id="chord-card" style="display:none;">
<div style="display:flex; align-items:center; gap:0.9rem; flex-wrap:wrap; margin-bottom:0.5rem;">
<h2 style="margin-bottom:0;">Circular Contact Map</h2>
<div class="model-selector" id="chord-model-selector"></div>
<div style="flex-basis:100%; height:0; margin:0;"></div><!-- force the toggles onto their own line, below the model selector -->
<label style="font-size:0.8rem; color:#555; display:inline-flex; align-items:center; gap:0.3rem; cursor:pointer;"><input type="checkbox" id="chord-show-labels" checked onchange="orthoShowChordLabels=this.checked; window.__redrawOrthoChord&&window.__redrawOrthoChord();"> labels</label>
<label style="font-size:0.8rem; color:#555; display:inline-flex; align-items:center; gap:0.3rem; cursor:pointer;"><input type="checkbox" id="chord-show-ids" checked onchange="orthoShowChordIDs=this.checked; window.__redrawOrthoChord&&window.__redrawOrthoChord();"> chain IDs</label>
<label style="font-size:0.8rem; color:#555; display:inline-flex; align-items:center; gap:0.3rem; cursor:pointer;"><input type="checkbox" id="chord-show-length" checked onchange="orthoShowChordLength=this.checked; window.__redrawOrthoChord&&window.__redrawOrthoChord();"> length</label>
<label style="font-size:0.8rem; color:#555; display:inline-flex; align-items:center; gap:0.3rem; cursor:pointer;" title="Circos-style residue-position ruler around each arc"><input type="checkbox" id="chord-show-ticks" checked onchange="orthoShowChordTicks=this.checked; window.__redrawOrthoChord&&window.__redrawOrthoChord();"> ticks</label>
<label style="font-size:0.8rem; color:#555; display:inline-flex; align-items:center; gap:0.3rem; cursor:pointer;" title="Per-residue pLDDT confidence ring, between the arc and the domain rings (AlphaFold color scale)"><input type="checkbox" id="chord-show-plddt" checked onchange="orthoShowChordPlddt=this.checked; window.__redrawOrthoChord&&window.__redrawOrthoChord();"> pLDDT</label>
<span style="font-size:0.8rem; color:#555; display:inline-flex; align-items:center; position:relative; top:-3px;">domains:</span>
<label style="font-size:0.8rem; color:#555; display:inline-flex; align-items:center; gap:0.3rem; cursor:pointer;"><input type="checkbox" id="chord-show-dom" checked onchange="orthoShowChordDom=this.checked; window.__redrawOrthoChord&&window.__redrawOrthoChord();"> UniProt/Pfam</label>
<label style="font-size:0.8rem; color:#555; display:inline-flex; align-items:center; gap:0.3rem; cursor:pointer;"><input type="checkbox" id="chord-show-ted" checked onchange="orthoShowChordTed=this.checked; window.__redrawOrthoChord&&window.__redrawOrthoChord();"> TED</label>
<span style="display:inline-flex; align-items:center; gap:5px; margin-bottom:0.4rem; font-size:0.8rem; color:#555;" title="Direction of the arc labels: along the arc, or pointing outward"><span style="font-weight:600;">label direction</span><span style="display:inline-flex; align-items:center; border:1px solid #ccd; border-radius:5px; overflow:hidden; font-size:0.78rem;"><button type="button" onclick="orthoShowChordRadial=false; LiviaMaps.segPick(this); window.__redrawOrthoChord&&window.__redrawOrthoChord();" style="border:0; padding:2px 8px; cursor:pointer; background:#2471A3; color:#fff; font:inherit;">along arc</button><button type="button" onclick="orthoShowChordRadial=true; LiviaMaps.segPick(this); window.__redrawOrthoChord&&window.__redrawOrthoChord();" style="border:0; padding:2px 8px; cursor:pointer; background:transparent; color:#555; font:inherit;">outward</button></span></span>
</div>
<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 id="chord-plddt-legend" style="display:none; align-items:center; gap:0.6rem; flex-wrap:wrap; font-size:0.72rem; color:#666; margin-bottom:0.5rem;"></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;">
<div style="display:flex; align-items:center; gap:0.9rem; flex-wrap:wrap; margin-bottom:0.5rem;">
<h2 style="margin-bottom:0;">3D Structure Viewer</h2>
<div class="model-selector" id="viewer3d-model-selector"></div>
</div>
<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</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 id="chain-color-upload" style="margin-top:6px"></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 pdb" id="dl-pdb" target="_blank">↓ Full structure .pdb</a>
<a class="btn-download cxc" id="dl-script-full" download>↓ .cxc · for full</a>
<a class="btn-download pdb" id="dl-pdb-conf" download style="background:white; color:#8e44ad; border-color:#8e44ad;">↓ Partial structure .pdb</a>
<a class="btn-download cxc" id="dl-script-partial" download style="background:#8e44ad; border-color:#8e44ad;">↓ .cxc · for partial</a>
<button class="btn-download" id="btn-copy" style="background:white; color:#2471A3; border:2px solid #2471A3; cursor:pointer;" onclick="copyScript()">Copy script</button>
</div>
<div style="font-size:0.72rem; color:#999; margin-top:0.5rem; line-height:1.45;">
<b>Full structure .pdb</b> = full length (surfaces include the floppy N/C-terminal tails). <b style="color:#8e44ad;">Partial structure .pdb</b> = both chains trimmed to exactly the LIR segments shown (Fill gaps / Min segment honored) — clean surfaces for post-processing; residue numbers preserved so the script still colors correctly. Download <b>one</b> structure file.
</div>
<div class="info-box" style="margin-top: 1rem;">
Download the structure file (.pdb) and the script, place both in the same folder. Double-click the script to launch the viewer automatically.
</div>
</div>
<!-- Per-Residue pLDDT -->
<div class="card result-card" id="plddt-card" style="display:none;">
<div style="display:flex; align-items:center; gap:0.9rem; flex-wrap:wrap; margin-bottom:0.5rem;">
<h2 style="margin-bottom:0;">Per-Residue pLDDT</h2>
<div class="model-selector" id="plddt-model-selector"></div>
</div>
<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/web/famdb_ortho_search/9606" target="_blank">FlyPredictome Ortholog Search</a> and search for a human gene</li>
<li>Click a predicted interaction pair to open the detail page</li>
<li>Copy the detail page URL and paste it above</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?v=20260902"></script>
<script src="js/livia-scripts.js?v=20260627"></script>
<script src="js/livia-viewer.js?v=20260716e"></script>
<script src="js/livia-colors.js?v=20260716b"></script>
<script src="js/canvas2svg.js?v=20260720"></script>
<script src="js/livia-maps.js?v=20260816"></script>
<script>
// ── Callbacks for shared modules ──
onColorChange = () => { if (flyParsed && flyCurrentRank) { loadRank(flyCurrentRank); updateCombinedChord(); renderChainToggleBar(); } };
attachChainColorUpload(document.getElementById('chain-color-upload'), { // CSV/paste chain colors (A/B or gene symbol)
geneOf: () => { try { if (!flyParsed || !flyCurrentRank) return {}; const isAvg = flyCurrentRank === 'avg'; const t = isAvg ? flyAverageRow : (flyParsed.rows.find(r => parseInt(r['Rank']) === flyCurrentRank) || flyParsed.rows[0]); return t ? { A: t['Symbol 1'], B: t['Symbol 2'] } : {}; } catch (e) { return {}; } },
});
onScriptTabSwitch = () => { updateScriptPreview(); };
document.addEventListener('DOMContentLoaded', () => {
initColorPickers();
// Deep link: ?gene=CDK2 or ?url=https://www.flyrnai.org/.../SET_xxx/
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('url')) {
switchTab('url');
document.getElementById('url-input').value = params.get('url');
setTimeout(() => generate(), 500);
} else {
switchTab('search');
}
});
// ── Tab switching ──
function switchTab(tab) {
document.getElementById('search-panel').style.display = tab === 'search' ? '' : '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');
}
// ── 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();
}
}
function getSpeciesId() {
return document.getElementById('species-select')?.value || '9606';
}
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 speciesId = getSpeciesId();
const url = `https://rest.uniprot.org/uniprotkb/search?query=${encodeURIComponent('"' + query + '"')}+AND+organism_id:${speciesId}&fields=accession,gene_names,protein_name,organism_name&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 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>' : '') +
'<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) => () => {
document.getElementById('gene-search-input').value = g;
list.style.display = 'none';
searchGene();
})(gene));
list.appendChild(item);
}
list.style.display = '';
} catch (e) { /* silent */ }
}, 300);
}
document.addEventListener('click', (e) => {
if (!e.target.closest('#search-panel')) hideGeneAc();
});
// ── Ortho search ──
const ORTHO_BASE = 'https://www.flyrnai.org/tools/fly_predictome/web/famdb_ortho_search/';
// Google Apps Script proxy — handles CSRF + session cookies server-side
let ORTHO_PROXY_URL = 'https://script.google.com/macros/s/AKfycbwPxNUJq8elIPLAmSdBLEe4oWQyUMiGXmcnyWmOqGmMaDUR--d2q50oNzcRIEZ3MRaGuQ/exec';
function setProxyUrl(url) {
url = (url || '').trim();
ORTHO_PROXY_URL = url;
if (url) localStorage.setItem('ortho_proxy_url', url);
else localStorage.removeItem('ortho_proxy_url');
}
async function searchGene() {
const query = document.getElementById('gene-search-input').value.trim();
if (!query) return;
const speciesId = getSpeciesId();
const statusEl = document.getElementById('search-status');
const resultsEl = document.getElementById('search-results');
statusEl.textContent = 'Searching for ' + query + '...';
statusEl.style.color = '#2471A3';
resultsEl.style.display = 'none';
try {
let resultHtml = null;
// Try Google Apps Script proxy first
if (ORTHO_PROXY_URL) {
try {
statusEl.textContent = 'Searching FlyPredictome for ' + query + '...';
const proxyUrl = ORTHO_PROXY_URL + '?gene=' + encodeURIComponent(query) + '&species=' + speciesId + '&type=Gene+Symbol';
const resp = await fetch(proxyUrl, { signal: AbortSignal.timeout(60000) }); // Apps Script cold starts can exceed 30 s
if (resp.ok) {
const text = await resp.text();
if (text.includes('famdb_summary_results') || text.includes('fam_summary_table')) {
resultHtml = text;
} else {
// Check if it's a JSON error
try {
const err = JSON.parse(text);
if (err.error) throw new Error(err.error);
} catch (e) {
if (e.message && !e.message.includes('JSON')) throw e;
}
}
}
} catch (e) {
console.warn('Proxy search failed:', e);
}
}
if (!resultHtml) {
const orthoUrl = ORTHO_BASE + speciesId;
const hasProxy = !!ORTHO_PROXY_URL;
statusEl.innerHTML = '';
resultsEl.style.display = '';
resultsEl.innerHTML =
'<div style="background:white; border:1px solid #e0e0e0; border-radius:12px; padding:1.2rem 1.5rem; font-size:0.88rem; color:#333;">' +
// Step 1
'<div style="display:flex; gap:0.8rem; margin-bottom:1rem; align-items:flex-start;">' +
'<span style="display:inline-flex; align-items:center; justify-content:center; width:26px; height:26px; border-radius:50%; background:#2471A3; color:white; font-weight:700; font-size:0.82rem; flex-shrink:0;">1</span>' +
'<div>' +
'<div style="font-weight:600; color:#1a5276; margin-bottom:0.2rem;">Search on FlyPredictome</div>' +
'<div style="font-size:0.82rem; color:#666;">Select <strong>Gene name</strong> identifier, type <code style="background:#f0f0f0; padding:0.1rem 0.3rem; border-radius:3px;">' + esc(query.toLowerCase()) + '</code>, and click <strong>Submit</strong>.</div>' +
'<a href="' + orthoUrl + '" target="_blank" class="btn btn-primary" style="text-decoration:none; font-size:0.82rem; padding:0.35rem 0.8rem; display:inline-block; margin-top:0.4rem;">Open FlyPredictome Ortholog Search</a>' +
'</div></div>' +
// Step 2
'<div style="display:flex; gap:0.8rem; margin-bottom:1rem; align-items:flex-start;">' +
'<span style="display:inline-flex; align-items:center; justify-content:center; width:26px; height:26px; border-radius:50%; background:#2471A3; color:white; font-weight:700; font-size:0.82rem; flex-shrink:0;">2</span>' +
'<div>' +
'<div style="font-weight:600; color:#1a5276; margin-bottom:0.2rem;">Copy the detail URL</div>' +
'<div style="font-size:0.82rem; color:#666;">In the results table, right-click <strong>See Details</strong> on any pair → <strong>Copy Link Address</strong>.</div>' +
'</div></div>' +
// Step 3
'<div style="display:flex; gap:0.8rem; align-items:flex-start;">' +
'<span style="display:inline-flex; align-items:center; justify-content:center; width:26px; height:26px; border-radius:50%; background:#2471A3; color:white; font-weight:700; font-size:0.82rem; flex-shrink:0;">3</span>' +
'<div style="flex:1;">' +
'<div style="font-weight:600; color:#1a5276; margin-bottom:0.3rem;">Paste URL here</div>' +
'<div class="url-row" style="margin:0;">' +
'<input type="text" id="inline-url-input" placeholder="https://www.flyrnai.org/tools/fly_predictome/web/famdb_details_all/.../9606/9606/" style="flex:1; padding:0.6rem 0.8rem; border:2px solid #e0e0e0; border-radius:8px; font-size:0.85rem;" onkeydown="if(event.key===\'Enter\'){var u=this.value.trim();if(u){document.getElementById(\'url-input\').value=u;switchTab(\'url\');generate();}}">' +
'<button class="btn btn-primary" style="font-size:0.85rem;" onclick="var u=document.getElementById(\'inline-url-input\').value.trim();if(u){document.getElementById(\'url-input\').value=u;switchTab(\'url\');generate();}">Analyze</button>' +
'</div>' +
'</div></div>' +
// Proxy setup (collapsible)
'<details style="margin-top:1rem; border-top:1px solid #eee; padding-top:0.8rem;">' +
'<summary style="font-size:0.82rem; color:#2471A3; cursor:pointer; font-weight:600;">Enable automatic search (optional, one-time setup)</summary>' +
'<div style="font-size:0.8rem; color:#666; line-height:1.7; margin-top:0.5rem;">' +
'Deploy a small proxy to search FlyPredictome directly from this page:' +
'<ol style="padding-left:1.2rem; margin:0.3rem 0;">' +
'<li>Go to <a href="https://script.google.com" target="_blank" style="color:#2471A3;">script.google.com</a> → New Project</li>' +
'<li>Paste the code from <a href="proxy/ortho_search_proxy.gs" target="_blank" style="color:#2471A3;">ortho_search_proxy.gs</a></li>' +
'<li>Deploy → New Deployment → Web App (Execute as: Me, Access: Anyone)</li>' +
'<li>Paste the URL below:</li>' +
'</ol>' +
'<div class="url-row" style="margin:0.3rem 0 0;">' +
'<input type="text" id="proxy-url-input" value="' + esc(ORTHO_PROXY_URL) + '" placeholder="https://script.google.com/macros/s/.../exec" style="flex:1; padding:0.4rem 0.6rem; border:2px solid #e0e0e0; border-radius:6px; font-size:0.8rem;">' +
'<button class="btn btn-primary" style="font-size:0.8rem; padding:0.4rem 0.8rem;" onclick="setProxyUrl(document.getElementById(\'proxy-url-input\').value);searchGene();">Save & Search</button>' +
'</div>' +
'</div>' +
'</details>' +
'</div>';
return;
}
// Step 3: Parse the results
const partners = parseOrthoSummary(resultHtml, query);
if (partners === null) {
statusEl.innerHTML = 'Gene-name search is temporarily unavailable while FlyPredictome updates its data format. Open the <a href="javascript:void(0)" onclick="switchTab(\'url\')" style="color:#2471A3; font-weight:600;">Paste URL</a> tab to analyze a pair from a prediction details-page URL (ready examples are there).';
statusEl.style.color = '#c0392b';
return;
}
if (partners.length === 0) {
statusEl.textContent = 'No interaction partners found for ' + query + '.';
statusEl.style.color = '#c0392b';
return;
}
statusEl.textContent = query + ': ' + partners.length + ' predicted interaction partners. Click a row to analyze.';
statusEl.style.color = '#27ae60';
// Display partner table
displayPartnerTable(partners, query);
} catch (e) {
statusEl.textContent = 'Error: ' + e.message;
statusEl.style.color = '#c0392b';
}
}
function parseOrthoSummary(html, querySymbol) {
// FlyPredictome redesign: the ortholog partner list is now #famdb_summary_results, a compact ~17-column
// DataTable (fewer columns than the fly summary — no separate fbgn/taxon/SET data cells). Everything
// needed to open a pair lives in the FIRST cell's detail link:
// /tools/fly_predictome/web/famdb_details_all/<prot1>/<prot2>/SET_n/<taxon>/<taxon>/
// Visible metric columns: 0 partner(link), 1 rank/count, 2 iLIS_best, 3 iLIS_avg, 4 iLISA_best,
// 5 iLISA_avg, 6 ipSAE_best, 7 ipSAE_avg, 8 actifpTM_best, 9 actifpTM_avg, 10 ipTM_best, 11 ipTM_avg,
// 12 Length_ij ("lenQuery/lenPartner"), 13 fPPI, 14 fGI, 15 iPPI, 16 iGI (MIST).
const doc = new DOMParser().parseFromString(html, 'text/html');
const table = doc.getElementById('famdb_summary_results') || doc.getElementById('fam_summary_table');
// If the table is gone entirely, signal that (null) rather than a misleading "no partners" ([]).
if (!table) return null;
const num = (v) => { const n = parseFloat(v); return isNaN(n) ? 0 : n; };
const int = (v) => { const n = parseInt(v, 10); return isNaN(n) ? 0 : n; };
const raw = [];
const seen = new Set();
for (const row of table.querySelectorAll('tbody tr')) {
const cells = row.querySelectorAll('td');
if (cells.length < 13) continue;
const link = cells[0].querySelector('a[href*="famdb_details"]');
if (!link) continue;
let detailUrl = link.getAttribute('href') || '';
if (!detailUrl) continue;
if (!detailUrl.startsWith('http')) detailUrl = 'https://www.flyrnai.org' + detailUrl;
// Pull accessions + SET out of the link (taxon suffix already in the URL, so it resolves as-is).
const m = detailUrl.match(/famdb_details(?:_all)?(?:_ortho)?\/([^/]+)\/([^/]+)\/([^/]+)\//);
if (!m) continue;
const prot1 = m[1], prot2 = m[2], dirName = m[3];
const dkey = prot1 + '|' + prot2 + '|' + dirName;
if (seen.has(dkey)) continue; // FlyPredictome collapses repeated (pair, SET) rows; match that
seen.add(dkey);
raw.push({
prot1, prot2, dirName, detailUrl,
partnerSymbol: (link.textContent || '').trim(),
ilisBest: num(cells[2]?.textContent), ilisAvg: num(cells[3]?.textContent),
iptmBest: num(cells[10]?.textContent), iptmAvg: num(cells[11]?.textContent),
lenTxt: (cells[12]?.textContent || '').trim(),
mistPPI: int(cells[13]?.textContent), mistGI: int(cells[14]?.textContent),
mistInterologPPI: int(cells[15]?.textContent), mistInterologGI: int(cells[16]?.textContent),
});
}
// The two accessions in each detail URL are (query, partner) in an inconsistent order. The query
// protein pairs with every partner, so it is the accession common to (nearly) all rows — the mode.
const freq = {};
for (const r of raw) { freq[r.prot1] = (freq[r.prot1] || 0) + 1; freq[r.prot2] = (freq[r.prot2] || 0) + 1; }
let queryAcc = '', best = -1;
for (const k in freq) if (freq[k] > best) { best = freq[k]; queryAcc = k; }
const partners = raw.map((r) => {
const partnerProt = r.prot1 === queryAcc ? r.prot2 : r.prot1;
const lm = r.lenTxt.split('/'); // Length_ij = len(prot1)/len(prot2)
return {
sym1: querySymbol, sym2: r.partnerSymbol || partnerProt,
prot1: r.prot1, prot2: r.prot2,
partnerSymbol: r.partnerSymbol || partnerProt, partnerProt,
ilisAvg: r.ilisAvg, ilisBest: r.ilisBest, iptmAvg: r.iptmAvg, iptmBest: r.iptmBest,
lisAvg: 0, clisAvg: 0, lirAvg: 0, clirAvg: 0, liaAvg: 0,
lenA: int(lm[0]), lenB: int(lm[1]),
mistPPI: r.mistPPI, mistGI: r.mistGI, mistInterologPPI: r.mistInterologPPI, mistInterologGI: r.mistInterologGI,
dirName: r.dirName, detailUrl: r.detailUrl,
};
});
partners.sort((a, b) => b.ilisBest - a.ilisBest);
return partners;
}
function displayPartnerTable(partners, querySymbol) {
const container = document.getElementById('search-results');
container.innerHTML = '';
container.style.display = '';
// Filter controls
const filterDiv = document.createElement('div');
filterDiv.style.cssText = 'display:flex; gap:1rem; align-items:center; margin-bottom:0.5rem; flex-wrap:wrap;';
filterDiv.innerHTML =
'<label style="font-size:0.82rem; color:#555;">' +
'<input type="checkbox" id="filter-positive" checked onchange="filterPartnerTable()"> ' +
'iLIS > 0 only' +
'</label>' +
'<label style="font-size:0.82rem; color:#555;">' +
'<input type="checkbox" id="filter-threshold" onchange="filterPartnerTable()"> ' +
'iLIS ≥ 0.223' +
'</label>' +
'<span style="font-size:0.78rem; color:#999;" id="filter-count"></span>';
container.appendChild(filterDiv);
// → cLIP handoff: gather this gene's interactome and cluster by shared contact residues
const clipDiv = document.createElement('div');
clipDiv.style.cssText = 'display:flex; gap:0.5rem; align-items:center; margin-bottom:0.6rem; flex-wrap:wrap;';
const clipBtn = document.createElement('button');
clipBtn.textContent = '🧬 Analyze interactome in cLIP →';
clipBtn.style.cssText = 'padding:0.45rem 0.9rem; border:none; border-radius:8px; background:#2471A3; color:#fff; cursor:pointer; font-size:0.85rem; font-weight:600;';
const capSel = document.createElement('select');
capSel.style.cssText = 'padding:0.4rem; border:1px solid #ccc; border-radius:6px; font-size:0.82rem;';
capSel.innerHTML = '<option value="100">Top 100 by iLIS</option><option value="200">Top 200</option><option value="300">Top 300</option><option value="99999">All</option>';
clipBtn.onclick = () => handoffToClip(parseInt(capSel.value, 10));
clipDiv.appendChild(clipBtn);
clipDiv.appendChild(capSel);
const uniqLabel = document.createElement('label');
uniqLabel.style.cssText = 'font-size:0.8rem; color:#555; display:flex; align-items:center; gap:3px; cursor:pointer;';
uniqLabel.innerHTML = '<input type="checkbox" id="clip-unique" checked style="accent-color:#1a5276"> unique partners';
clipDiv.appendChild(uniqLabel);
const clipHint = document.createElement('span');
clipHint.style.cssText = 'font-size:0.76rem; color:#999;';
clipHint.textContent = 'clusters partners by shared contact residues (cLIR)';
clipDiv.appendChild(clipHint);
container.appendChild(clipDiv);
// Table
const tableWrap = document.createElement('div');
tableWrap.style.cssText = 'overflow-x:auto; max-height:400px; overflow-y:auto; border:1px solid #e0e0e0; border-radius:8px;';
const table = document.createElement('table');
table.className = 'data-table';
table.id = 'partner-list-table';
table.style.fontSize = '0.8rem';
table.innerHTML =
'<thead style="position:sticky; top:0; z-index:1;">' +
'<tr>' +
'<th>Partner</th>' +
'<th>iLIS (best)</th>' +
'<th>iLIS (avg)</th>' +
'<th>ipTM (best)</th>' +
'<th>ipTM (avg)</th>' +
'<th>Len A/B</th>' +
'</tr>' +
'</thead>' +
'<tbody id="partner-tbody"></tbody>';
tableWrap.appendChild(table);
container.appendChild(tableWrap);
// Store partners for filtering
window._searchPartners = partners;
window._searchQuery = querySymbol;
filterPartnerTable();
makeSortable(table);
}
function filterPartnerTable() {
const partners = window._searchPartners || [];
const tbody = document.getElementById('partner-tbody');
if (!tbody) return;
const positiveOnly = document.getElementById('filter-positive')?.checked;
const thresholdOnly = document.getElementById('filter-threshold')?.checked;
tbody.innerHTML = '';
let count = 0;
for (const p of partners) {
if (positiveOnly && p.ilisBest <= 0) continue;
if (thresholdOnly && p.ilisBest < 0.223) continue;
count++;
const tr = document.createElement('tr');
tr.className = 'clickable';
tr.style.cursor = 'pointer';
tr.innerHTML =
'<td><strong>' + esc(p.partnerSymbol) + '</strong> <span style="color:#999; font-size:0.72rem;">' + esc(p.partnerProt) + '</span></td>' +
'<td>' + ilisColor(p.ilisBest) + '</td>' +
'<td>' + ilisColor(p.ilisAvg, true) + '</td>' +
'<td>' + p.iptmBest.toFixed(2) + '</td>' +
'<td>' + p.iptmAvg.toFixed(2) + '</td>' +
'<td>' + p.lenA + ' / ' + p.lenB + '</td>';
if (p.detailUrl) {
tr.addEventListener('click', ((url) => (e) => {
if (e.ctrlKey || e.metaKey) {
const pageUrl = window.location.pathname + '?url=' + encodeURIComponent(url);
window.open(pageUrl, '_blank');
} else {
document.getElementById('url-input').value = url;
switchTab('url');
generate();
}
})(p.detailUrl));
}
tbody.appendChild(tr);
}
const countEl = document.getElementById('filter-count');
if (countEl) countEl.textContent = 'Showing ' + count + ' of ' + partners.length;
}
function updateScriptPreview() {
if (!flyParsed) return;
const isAvg = flyCurrentRank === 'avg';
const target = isAvg ? flyAverageRow : (flyParsed.rows.find(r => parseInt(r['Rank']) === flyCurrentRank) || flyParsed.rows[0]);
if (!target) return;
const sym1 = target['Symbol 1'] || '?';
const sym2 = target['Symbol 2'] || '?';
const colors = {
lir_a: document.getElementById('color-lir-a').value,
lir_b: document.getElementById('color-lir-b').value,
clir_a: document.getElementById('color-clir-a').value,
clir_b: document.getElementById('color-clir-b').value,
};
orthoWireDownloads(target, colors);
}
let flyParsed = null;
let flyChainSeqs = null;
let flyPdbText = null;
let flyPdbPerRank = {};
let flyBaseUrl = '';
let flyCurrentRank = 1;
let flyAverageRow = null;
let flyDomains = { A: [], B: [] };
let flyTedDomains = { A: [], B: [] };
let flyPlddt = { A: [], B: [] }; // per-residue pLDDT per chain (B-factors) for the chord pLDDT ring
let flyDomainInfo = { A: null, B: null };
let domainCache = new Map();
let tedCache = new Map();
let viewer3dBlobUrl = null;
let viewer3dStructText = null; // cached structure text — postMessage fast-path detection
let orthoHiddenChains = new Set(); // chain names toggled off — hides them in the 3D viewer
// ── Chain visibility toggle (3D viewer only — ortho page has no chord) ──
function renderChainToggleBar() {
const bar = document.getElementById('chain-toggle-bar');
const btnHolder = document.getElementById('chain-toggle-buttons');
if (!bar || !btnHolder || !flyParsed) { if (bar) bar.style.display = 'none'; return; }
bar.style.display = 'flex';
btnHolder.innerHTML = '';
for (const name of ['A', 'B']) {