jbrowse-plugin-protein3d 1.13.1 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ProteinView/alignmentSites.js +4 -0
- package/dist/ProteinView/model.js +15 -0
- package/dist/ProteinView/sessionHighlights.js +142 -0
- package/dist/ProteinView/structureModel.js +24 -0
- package/dist/ProteinView/structurePipeline.js +22 -0
- package/dist/chunks/{LaunchProteinViewDialog-E5HWUFF7.js → LaunchProteinViewDialog-A73NNW5K.js} +2 -2
- package/dist/chunks/chunk-NOFPQXHZ.js +2 -0
- package/dist/chunks/chunk-NOFPQXHZ.js.map +7 -0
- package/dist/chunks/model-V2G4S6EP.js +2 -0
- package/dist/chunks/model-V2G4S6EP.js.map +7 -0
- package/dist/jbrowse-plugin-protein3d.esm.js +1 -1
- package/dist/jbrowse-plugin-protein3d.esm.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/ProteinView/alignmentSites.test.ts +4 -1
- package/src/ProteinView/alignmentSites.ts +5 -0
- package/src/ProteinView/model.ts +23 -0
- package/src/ProteinView/sessionHighlights.test.ts +175 -0
- package/src/ProteinView/sessionHighlights.ts +222 -0
- package/src/ProteinView/structureModel.ts +31 -0
- package/src/ProteinView/structurePipeline.test.ts +23 -0
- package/src/ProteinView/structurePipeline.ts +30 -0
- package/src/version.ts +1 -1
- package/dist/chunks/chunk-TILXEKR4.js +0 -2
- package/dist/chunks/chunk-TILXEKR4.js.map +0 -7
- package/dist/chunks/model-HOUBVNN6.js +0 -2
- package/dist/chunks/model-HOUBVNN6.js.map +0 -7
- /package/dist/chunks/{LaunchProteinViewDialog-E5HWUFF7.js.map → LaunchProteinViewDialog-A73NNW5K.js.map} +0 -0
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
import loadMolstar from './loadMolstar';
|
|
14
14
|
import { structureRootCell } from './structureCells';
|
|
15
15
|
export const SITES_TAG = 'jbrowse-alignment-sites';
|
|
16
|
+
// Over twice the preset's 0.15, so a site's side chains stand out from the
|
|
17
|
+
// ligand and focus sticks around them
|
|
18
|
+
export const SITE_STICKS = { sizeFactor: 0.35, sizeAspectRatio: 0.6 };
|
|
16
19
|
let revision = 0;
|
|
17
20
|
/**
|
|
18
21
|
* Make each structure's sticks match its sites: create, update, or remove
|
|
@@ -73,6 +76,7 @@ export async function syncSiteSticks({ plugin, structures, }) {
|
|
|
73
76
|
const representation = {
|
|
74
77
|
...createStructureRepresentationParams(plugin, molstarStructure, {
|
|
75
78
|
type: 'ball-and-stick',
|
|
79
|
+
typeParams: SITE_STICKS,
|
|
76
80
|
}),
|
|
77
81
|
colorTheme: createStructureColorThemeParams(plugin, molstarStructure, 'ball-and-stick', 'alignment-domains', { revision, color, mark: 'atoms' }),
|
|
78
82
|
};
|
|
@@ -15,6 +15,7 @@ import { checkedColor, colorOfScheme } from './proteinColor';
|
|
|
15
15
|
import { defaultDisplayName } from './proteinViewSpec';
|
|
16
16
|
import { removeMolstarStructure } from './removeStructure';
|
|
17
17
|
import { reportPluginFailure } from './reportPluginFailure';
|
|
18
|
+
import { syncSessionHighlightMarks } from './sessionHighlights';
|
|
18
19
|
import { showLoading } from './showLoading';
|
|
19
20
|
import { readStoredSettings, storeSetting, withStoredSettings, } from './storedSettings';
|
|
20
21
|
import { makeStructureLoader } from './structureLoader';
|
|
@@ -334,6 +335,20 @@ function stateModelFactory() {
|
|
|
334
335
|
syncSiteSticks({ plugin, structures }).catch(reportPluginFailure(self, plugin));
|
|
335
336
|
}
|
|
336
337
|
}));
|
|
338
|
+
// The session's highlights, labelled in 3D on the residues each
|
|
339
|
+
// genome region codes for
|
|
340
|
+
addDisposer(self, autorun(() => {
|
|
341
|
+
const plugin = self.molstarPluginContext;
|
|
342
|
+
const structures = self.structures.flatMap(s => s.entities
|
|
343
|
+
? s.molstarStructures.map(molstarStructure => ({
|
|
344
|
+
molstarStructure,
|
|
345
|
+
marks: s.sessionHighlightMarks,
|
|
346
|
+
}))
|
|
347
|
+
: []);
|
|
348
|
+
if (plugin && structures.length > 0) {
|
|
349
|
+
syncSessionHighlightMarks({ plugin, structures }).catch(reportPluginFailure(self, plugin));
|
|
350
|
+
}
|
|
351
|
+
}));
|
|
337
352
|
addDisposer(self, autorun(() => {
|
|
338
353
|
const plugin = self.molstarPluginContext;
|
|
339
354
|
for (const s of self.structures) {
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session's highlights on a structure. `session.highlights` is one list of
|
|
3
|
+
* labelled genome regions that every view draws on its own terms: a band on
|
|
4
|
+
* the genome, a column on the alignment, and here the residues the region
|
|
5
|
+
* codes for, drawn as sticks on every chain that has them with the
|
|
6
|
+
* highlight's label written once in 3D, so a figure or a shared session names
|
|
7
|
+
* the same position in each view.
|
|
8
|
+
*
|
|
9
|
+
* Each structure gets one component, one ball-and-stick and one label per
|
|
10
|
+
* highlight, all tagged `SESSION_HIGHLIGHTS_TAG`. A change rebuilds every one
|
|
11
|
+
* of them, since highlights change by hand and a structure holds a few.
|
|
12
|
+
*/
|
|
13
|
+
import loadMolstar from './loadMolstar';
|
|
14
|
+
import { structureRootCell } from './structureCells';
|
|
15
|
+
export const SESSION_HIGHLIGHTS_TAG = 'jbrowse-session-highlights';
|
|
16
|
+
// core's default highlight color, which the genome view's band draws in
|
|
17
|
+
export const DEFAULT_HIGHLIGHT_COLOR = '#FFB11D';
|
|
18
|
+
/**
|
|
19
|
+
* Each highlight's residues on the mapped entity: genome base → transcript
|
|
20
|
+
* residue (`g2p`) → structure residue → `label_seq_id`. A highlight on
|
|
21
|
+
* another assembly or chromosome, or on residues the structure lacks, marks
|
|
22
|
+
* nothing.
|
|
23
|
+
*/
|
|
24
|
+
export function sessionHighlightResidues({ highlights, mapping, naming, entity, transcriptToStructure, labels, }) {
|
|
25
|
+
const refName = naming.canonicalRefName(mapping.refName);
|
|
26
|
+
return highlights.flatMap(h => {
|
|
27
|
+
if (!naming.isAssembly(h.assemblyName) ||
|
|
28
|
+
naming.canonicalRefName(h.refName) !== refName) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
const labelSeqIds = new Set();
|
|
32
|
+
for (let base = h.start; base < h.end; base++) {
|
|
33
|
+
const residue = mapping.g2p[base];
|
|
34
|
+
const structurePos = residue === undefined ? undefined : transcriptToStructure[residue];
|
|
35
|
+
const labelSeqId = structurePos === undefined ? undefined : entity.seqIds[structurePos];
|
|
36
|
+
if (labelSeqId !== undefined) {
|
|
37
|
+
labelSeqIds.add(labelSeqId);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return labelSeqIds.size > 0
|
|
41
|
+
? [
|
|
42
|
+
{
|
|
43
|
+
entityId: entity.entityId,
|
|
44
|
+
labelSeqIds: [...labelSeqIds].sort((a, b) => a - b),
|
|
45
|
+
label: labels && h.label ? h.label : undefined,
|
|
46
|
+
color: h.color ?? DEFAULT_HIGHLIGHT_COLOR,
|
|
47
|
+
},
|
|
48
|
+
]
|
|
49
|
+
: [];
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Make each structure's highlight marks match `marks`: the old ones go, and
|
|
54
|
+
* each mark gets its residues as sticks in its color and, when it has a
|
|
55
|
+
* label, the label in 3D over them.
|
|
56
|
+
*/
|
|
57
|
+
export async function syncSessionHighlightMarks({ plugin, structures, }) {
|
|
58
|
+
const molstar = await loadMolstar();
|
|
59
|
+
const { Color, MolScriptBuilder: MS, StateSelection, StateTransforms, StructureElement, StructureProperties: SP, createStructureRepresentationParams, } = molstar;
|
|
60
|
+
// the first chain of an entity: a homo-oligomer such as haemoglobin's four
|
|
61
|
+
// β chains carries a highlighted residue once per chain, and one label per
|
|
62
|
+
// copy would stack four of them, so the label goes on the first
|
|
63
|
+
const firstChain = (structure, entityId) => {
|
|
64
|
+
const l = StructureElement.Location.create(structure);
|
|
65
|
+
for (const unit of structure.units) {
|
|
66
|
+
l.unit = unit;
|
|
67
|
+
l.element = unit.elements[0];
|
|
68
|
+
if (SP.entity.id(l) === entityId) {
|
|
69
|
+
return SP.chain.label_asym_id(l);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
};
|
|
74
|
+
const update = plugin.state.data.build();
|
|
75
|
+
const existing = plugin.state.data.select(StateSelection.Generators.root.subtree().withTag(SESSION_HIGHLIGHTS_TAG));
|
|
76
|
+
for (const cell of existing) {
|
|
77
|
+
update.delete(cell.transform.ref);
|
|
78
|
+
}
|
|
79
|
+
for (const { molstarStructure, marks } of structures) {
|
|
80
|
+
const root = structureRootCell(plugin, molstar, molstarStructure);
|
|
81
|
+
if (!root) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
for (const { entityId, labelSeqIds, label, color } of marks) {
|
|
85
|
+
const expression = MS.struct.generator.atomGroups({
|
|
86
|
+
'entity-test': MS.core.rel.eq([MS.ammp('label_entity_id'), entityId]),
|
|
87
|
+
'residue-test': MS.core.set.has([
|
|
88
|
+
MS.set(...labelSeqIds),
|
|
89
|
+
MS.ammp('label_seq_id'),
|
|
90
|
+
]),
|
|
91
|
+
});
|
|
92
|
+
update
|
|
93
|
+
.to(root)
|
|
94
|
+
.apply(StateTransforms.Model.StructureComponent, {
|
|
95
|
+
type: { name: 'expression', params: expression },
|
|
96
|
+
nullIfEmpty: true,
|
|
97
|
+
label: label ?? 'Session highlight',
|
|
98
|
+
}, { tags: [SESSION_HIGHLIGHTS_TAG] })
|
|
99
|
+
.apply(StateTransforms.Representation.StructureRepresentation3D, createStructureRepresentationParams(plugin, molstarStructure, {
|
|
100
|
+
type: 'ball-and-stick',
|
|
101
|
+
typeParams: { sizeFactor: 0.3, sizeAspectRatio: 0.6 },
|
|
102
|
+
color: 'uniform',
|
|
103
|
+
colorParams: { value: Color.fromHexStyle(color) },
|
|
104
|
+
}), { tags: [SESSION_HIGHLIGHTS_TAG] });
|
|
105
|
+
const chain = label ? firstChain(molstarStructure, entityId) : undefined;
|
|
106
|
+
if (label && chain) {
|
|
107
|
+
const labelled = MS.struct.generator.atomGroups({
|
|
108
|
+
'chain-test': MS.core.rel.eq([MS.ammp('label_asym_id'), chain]),
|
|
109
|
+
'residue-test': MS.core.set.has([
|
|
110
|
+
MS.set(...labelSeqIds),
|
|
111
|
+
MS.ammp('label_seq_id'),
|
|
112
|
+
]),
|
|
113
|
+
});
|
|
114
|
+
update
|
|
115
|
+
.toRoot()
|
|
116
|
+
.apply(StateTransforms.Model.MultiStructureSelectionFromExpression, {
|
|
117
|
+
selections: [
|
|
118
|
+
{ key: 'a', ref: root.transform.ref, expression: labelled },
|
|
119
|
+
],
|
|
120
|
+
isTransitive: true,
|
|
121
|
+
label,
|
|
122
|
+
}, {
|
|
123
|
+
dependsOn: [root.transform.ref],
|
|
124
|
+
tags: [SESSION_HIGHLIGHTS_TAG],
|
|
125
|
+
})
|
|
126
|
+
.apply(StateTransforms.Representation.StructureSelectionsLabel3D, {
|
|
127
|
+
customText: label,
|
|
128
|
+
textSize: 4,
|
|
129
|
+
attachment: 'bottom-left',
|
|
130
|
+
scaleByRadius: false,
|
|
131
|
+
textColor: Color(0x000000),
|
|
132
|
+
borderWidth: 0,
|
|
133
|
+
background: true,
|
|
134
|
+
backgroundColor: Color(0xffffff),
|
|
135
|
+
backgroundOpacity: 0.85,
|
|
136
|
+
offsetZ: 10,
|
|
137
|
+
}, { tags: [SESSION_HIGHLIGHTS_TAG] });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
await update.commit();
|
|
142
|
+
}
|
|
@@ -16,6 +16,7 @@ import { clickProteinToGenome, navigateToProteinPosition, structureRangesToGenom
|
|
|
16
16
|
import { RESIDUE_COLORS } from './residueColors';
|
|
17
17
|
import { positionRangeRuns, rangeList, residueRuns, transcriptRuns, } from './residueRanges';
|
|
18
18
|
import { kyteDoolittleScores, mapResidueValuesToColumns } from './residueTracks';
|
|
19
|
+
import { sessionHighlightResidues } from './sessionHighlights';
|
|
19
20
|
import { structureUniProt } from './structureUniProt';
|
|
20
21
|
import { assemblyNaming, errorMessage } from './util';
|
|
21
22
|
import { makeVariantEffectLoader } from './variantEffectLoader';
|
|
@@ -1061,6 +1062,29 @@ const Structure = types
|
|
|
1061
1062
|
})
|
|
1062
1063
|
: undefined;
|
|
1063
1064
|
},
|
|
1065
|
+
/**
|
|
1066
|
+
* #getter
|
|
1067
|
+
* The session's highlights on the mapped entity, each with the residues
|
|
1068
|
+
* its genome region codes for; see sessionHighlights
|
|
1069
|
+
*/
|
|
1070
|
+
get sessionHighlightMarks() {
|
|
1071
|
+
const session = getSession(self);
|
|
1072
|
+
const { genomeToTranscriptSeqMapping: mapping, mappedEntity: entity, transcriptSeqToStructureSeqPosition: transcriptToStructure, } = self;
|
|
1073
|
+
return session.highlightsVisible &&
|
|
1074
|
+
mapping &&
|
|
1075
|
+
entity &&
|
|
1076
|
+
transcriptToStructure
|
|
1077
|
+
? sessionHighlightResidues({
|
|
1078
|
+
highlights: session.highlights,
|
|
1079
|
+
mapping,
|
|
1080
|
+
naming: self.genomeNaming,
|
|
1081
|
+
entity,
|
|
1082
|
+
transcriptToStructure,
|
|
1083
|
+
labels: !('highlightLabelsVisible' in session &&
|
|
1084
|
+
session.highlightLabelsVisible === false),
|
|
1085
|
+
})
|
|
1086
|
+
: [];
|
|
1087
|
+
},
|
|
1064
1088
|
/**
|
|
1065
1089
|
* #getter
|
|
1066
1090
|
* The overview's "From the alignment" rows, one per accession, whatever
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isBinaryStructureUrl, structureFormatFromContent, structureFormatFromName, } from 'p2s_mapper';
|
|
2
|
+
import loadMolstar from './loadMolstar';
|
|
2
3
|
// Typed as always resolving to a trajectory, but Mol* reverts a parse that
|
|
3
4
|
// fails and resolves with nothing
|
|
4
5
|
function parseTrajectory(plugin, raw, format) {
|
|
@@ -40,6 +41,26 @@ function presetOutput(preset) {
|
|
|
40
41
|
? { models: [preset.model], structures: [preset.structure] }
|
|
41
42
|
: { models: preset?.models ?? [], structures: preset?.structures ?? [] };
|
|
42
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Drop the preset's water component. A crystal's ordered waters draw as a
|
|
46
|
+
* cloud of dots over the cartoon and every highlight, and nothing the view
|
|
47
|
+
* shows reads them.
|
|
48
|
+
*/
|
|
49
|
+
async function removeWater(plugin, structures) {
|
|
50
|
+
const { StateSelection, StateTransforms } = await loadMolstar();
|
|
51
|
+
const update = plugin.state.data.build();
|
|
52
|
+
for (const { ref } of structures) {
|
|
53
|
+
for (const cell of plugin.state.data.select(StateSelection.Generators.byRef(ref)
|
|
54
|
+
.subtree()
|
|
55
|
+
.withTransformer(StateTransforms.Model.StructureComponent))) {
|
|
56
|
+
const { type } = cell.transform.params ?? {};
|
|
57
|
+
if (type?.name === 'static' && type.params === 'water') {
|
|
58
|
+
update.delete(cell.transform.ref);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
await update.commit();
|
|
63
|
+
}
|
|
43
64
|
/**
|
|
44
65
|
* Build the trajectory's models, structures and representations. One load is
|
|
45
66
|
* one Mol* structure per model, so an NMR ensemble is twenty of them, and the
|
|
@@ -51,6 +72,7 @@ function presetOutput(preset) {
|
|
|
51
72
|
async function applyStructurePreset(plugin, trajectory, source) {
|
|
52
73
|
const preset = await plugin.builders.structure.hierarchy.applyPreset(trajectory, 'all-models', { useDefaultIfSingleModel: true });
|
|
53
74
|
const { models, structures } = presetOutput(preset);
|
|
75
|
+
await removeWater(plugin, structures);
|
|
54
76
|
const loaded = structures.flatMap(s => (s.obj ? [s.obj.data] : []));
|
|
55
77
|
if (loaded.length === 0) {
|
|
56
78
|
throw new Error(`No structure could be built from ${source} by Mol*'s all-models preset`);
|
package/dist/chunks/{LaunchProteinViewDialog-E5HWUFF7.js → LaunchProteinViewDialog-A73NNW5K.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as Ur}from"./chunk-TILXEKR4.js";import{a as $}from"./chunk-CU6NAWYQ.js";import{a as X,b as Y,c as xr}from"./chunk-X47I2IB5.js";import{a as Dr}from"./chunk-UTDQGJCS.js";import{a as Io,b as Pr,c as io,d as Fr}from"./chunk-UXGREKQA.js";import{a as U}from"./chunk-HAGLAQP5.js";import{a as fe}from"./chunk-NZ3TO6NV.js";import{a as Sr}from"./chunk-SIZG3XB4.js";import{a as Tt}from"./chunk-533QNNGN.js";import{a as Re}from"./chunk-LOG7ZCI7.js";import{a as we}from"./chunk-HLB63AD7.js";import{a as C}from"./chunk-GVEKA5YG.js";import{a as vr,b as Lr,j as Ee,l as Ae,m as no}from"./chunk-DIM277D5.js";import"./chunk-R64WXKZQ.js";import"./chunk-MJZSVHMS.js";import"./chunk-LZTO76OW.js";import"./chunk-OI77P32P.js";import"./chunk-2RFFBSIA.js";import"./chunk-INWFM3CY.js";import"./chunk-Z3277B6H.js";import"./chunk-5NBLSM7W.js";import"./chunk-ISVQX4IH.js";import"./chunk-UVDYWAS6.js";import{a as wr}from"./chunk-3LIMY6Z5.js";import{a as To,b as br}from"./chunk-ASJJTAZT.js";import{a as ro,c as yr,d as Tr,e as Ir,f as Cr,g as kr,h as to}from"./chunk-2LPERV4E.js";import{a as gr}from"./chunk-7UQOTULP.js";import{$a as ir,Ab as fr,Ga as Ro,Ka as Ne,Ma as er,Na as oo,Oa as or,Q as qe,R as Yo,Ra as rr,Sa as tr,Ta as nr,aa as Jo,b as Qo,bb as bo,cb as sr,e as Xo,hb as ar,mb as lr,nb as So,pb as yo,qb as ur,sb as dr,tb as cr,yb as mr,za as Zo,zb as pr}from"./chunk-WZCSPP5F.js";import{a as eo}from"./chunk-B3HKXTGK.js";import{a as yt,e as hr}from"./chunk-S6PS4I6X.js";import"./chunk-SPXMXPSC.js";import{c as a}from"./chunk-KVMUXFPB.js";var q=a(C()),gt=a(we()),ht=a(eo()),De=a(U());var V=a(C()),lo=a(we()),xe=a(U()),Qr=a(Re()),Xr=a(fe());var Me=a(C()),Co=a(U());function ko({uniprotId:e,url:o}){return Me.default.createElement("div",null,Me.default.createElement(Co.Typography,null,"UniProt link:"," ",Me.default.createElement($,{href:Ne(e)},e)),Me.default.createElement(Co.Typography,null,"AlphaFoldDB link: ",Me.default.createElement($,{href:o},o)))}var qr=a(C()),Nr=a(U());function te({message:e}){return e?qr.default.createElement(Nr.Typography,{variant:"body2",color:"warning.main"},e):null}var K=a(C()),_r=a(we());var Er=a(Tt(),1),Ar=(0,Sr.createSvgIcon)((0,Er.jsx)("path",{d:"m7 10 5 5 5-5z"}),"ArrowDropDown");var Ie=a(U());var Te=a(C()),oe=a(U());function vo({anchorEl:e,onClose:o,options:n,sideBySide:r,onSideBySideChange:i}){return Te.default.createElement(oe.Menu,{anchorEl:e,open:!!e,onClose:o,"data-testid":"protein-launch-options-menu"},n.map(t=>Te.default.createElement(oe.MenuItem,{key:t.key,"data-testid":`protein-launch-option-${t.key}`,onClick:t.onClick},Te.default.createElement(oe.ListItemText,{primary:t.title,secondary:t.description}))),Te.default.createElement(oe.Divider,null),Te.default.createElement(oe.MenuItem,{"data-testid":"protein-launch-side-by-side",onClick:()=>{i(!r)}},Te.default.createElement(oe.Checkbox,{checked:r,size:"small"}),Te.default.createElement(oe.ListItemText,{primary:"Open side by side",secondary:"Place the protein view right of the genome view instead of below it"})))}var Mr=a(C()),Br=a(U());function Ge(){return Mr.default.createElement(Br.Typography,{variant:"body2",sx:{mr:2}},"Transcript and structure sequences differ, will run"," ",Xo[Qo]," alignment")}var Lo=a(C());async function Vr(e,o,n){try{await e(),o?.()}catch(r){console.error(r),n?.(r)}}function Or({uniprotId:e,userSelectedProteinSequence:o,selectedTranscript:n,url:r,pdbId:i}){let t=!!r||!!i;return[!t&&!e&&"No UniProt ID found",!o?.seq&&"Could not compute protein sequence (feature may be missing CDS subfeatures)",!n&&"No transcript selected",!t&&"No structure selected"].filter(l=>typeof l=="string")}function Be(e,o){let[n,r]=(0,Lo.useState)(),[i,t]=(0,Lo.useState)(!1);return{runLaunch:u=>()=>{o?.(),i||(t(!0),r(void 0),Vr(u,e,r).then(()=>{t(!1)}))},launchError:n,launching:i}}function $e({handleClose:e,uniprotId:o,userSelectedProteinSequence:n,selectedTranscript:r,url:i,pdbId:t,confidenceUrl:l,feature:u,view:c,session:d,sideBySide:s,onSideBySideChange:p,sequencesMatch:g,isLoading:S,error:x}){let[m,T]=(0,K.useState)(null),P=()=>{T(null)},{runLaunch:v,launchError:N,launching:I}=Be(e,P),D=Or({uniprotId:o,userSelectedProteinSequence:n,selectedTranscript:r,url:i,pdbId:t}),E=!S&&!x&&!I&&D.length===0,A=!S&&!x&&D.length>0,M={session:d,view:c,feature:u,selectedTranscript:r,uniprotId:o,url:i,userProvidedTranscriptSequence:n?.seq,sideBySide:s},H=v(()=>Ee(M)),{launch1D:G}=no({session:d,view:c,feature:u,selectedTranscript:r,uniprotId:o,confidenceUrl:l}),J=[{key:"3d",title:Ae["3d"],description:"View protein structure with genome-to-structure coordinate mapping",onClick:H},...G?[{key:"1d",title:Ae["1d"],description:"View protein features and annotations as a linear track",onClick:v(G)}]:[]];return K.default.createElement(K.default.Fragment,null,N?K.default.createElement(_r.ErrorMessage,{error:N}):null,g===!1?K.default.createElement(Ge,null):null,K.default.createElement(Ie.Button,{variant:"contained",color:"secondary",size:"small",onClick:()=>{e()}},"Cancel"),A?K.default.createElement("div",{style:{marginRight:16}},D.map(Q=>K.default.createElement(Ie.Typography,{key:Q,variant:"body2",color:"error"},Q))):null,K.default.createElement(Ie.ButtonGroup,{variant:"contained",color:"primary",size:"small"},K.default.createElement(Ie.Button,{"data-testid":"protein-launch-button",disabled:!E,onClick:H},"Launch"),K.default.createElement(Ie.Button,{"data-testid":"protein-launch-options-button",disabled:!E,onClick:Q=>{T(Q.currentTarget)},"aria-label":"More launch options"},K.default.createElement(Ar,null))),K.default.createElement(vo,{anchorEl:m,onClose:P,options:J,sideBySide:s,onSideBySideChange:p}))}var so=a(C()),We=a(U());function ge({val:e,setVal:o,isoforms:n,ranking:r,structureSequence:i,feature:t,disabled:l}){let u=Cr(t),c=new Map(n.map(m=>[m.id(),m])),d=m=>Ir(c.get(m))||m,{matches:s,nonMatches:p,noData:g}=r,S=i?qe(i).length:void 0,x=({id:m,length:T,identical:P},v=P===void 0?"":` (${P}/${S} structure residues identical)`)=>so.default.createElement(We.MenuItem,{value:m,key:m},u," - ",d(m)," (",T,"aa)",v);return so.default.createElement(We.TextField,{value:e??"",onChange:m=>{o(m.target.value)},label:"Choose transcript isoform",select:!0,disabled:l},s.map(m=>x(m," (matches structure residues)")),p.map(m=>x(m)),g.map(m=>so.default.createElement(We.MenuItem,{value:m,key:m,disabled:!0},u," - ",d(m)," (no data)")))}var ce=a(C()),je=a(U()),zr=a(fe());var Ce=a(C()),de=a(U());function Po({recognizedIds:e,geneName:o,selectedId:n,onSelectedIdChange:r}){let[i,t]=(0,Ce.useState)(!1),l=[{value:"auto",label:"Auto (try all)"},...e.map(u=>({value:u,label:sr(u)}))];return o&&l.push({value:`gene:${o}`,label:`${o} (gene name)`}),e.length===0&&!o?null:i?Ce.default.createElement(de.FormControl,{size:"small"},Ce.default.createElement(de.InputLabel,null,"Query UniProt by"),Ce.default.createElement(de.Select,{value:n,label:"Query UniProt by",onChange:u=>{r(u.target.value)}},l.map(u=>Ce.default.createElement(de.MenuItem,{key:u.value,value:u.value},u.label)))):Ce.default.createElement(de.Button,{size:"small",variant:"text",onClick:()=>{t(!0)}},"Choose identifier to query...")}var _=a(C()),W=a(U());var It=["auto","manual","feature"];function Ct(e){return It.some(o=>o===e)}function wo({lookupMode:e,onLookupModeChange:o,manualUniprotId:n,onManualUniprotIdChange:r,manualUniprotIdInvalid:i,featureUniprotId:t,hasSearchableIdentifier:l=!0,endContent:u}){return _.default.createElement(_.default.Fragment,null,_.default.createElement("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap"}},_.default.createElement(W.FormControl,{component:"fieldset"},_.default.createElement(W.RadioGroup,{row:!0,value:e,onChange:c=>{Ct(c.target.value)&&o(c.target.value)}},t&&_.default.createElement(W.FormControlLabel,{value:"feature",control:_.default.createElement(W.Radio,null),label:`From feature (${t})`}),l&&_.default.createElement(W.FormControlLabel,{value:"auto",control:_.default.createElement(W.Radio,null),label:"Look up from the feature's identifiers"}),_.default.createElement(W.FormControlLabel,{value:"manual",control:_.default.createElement(W.Radio,null),label:"Enter manually"}))),u),e==="manual"&&_.default.createElement("div",null,_.default.createElement(W.TextField,{autoFocus:!0,label:"UniProt ID",variant:"outlined",placeholder:"e.g. P68871",size:"small",value:n,error:i,helperText:i?Pr:void 0,onChange:c=>{r(c.target.value)}})),e==="manual"&&!n&&_.default.createElement(W.Typography,{variant:"body2",color:"text.secondary"},"Search"," ",_.default.createElement($,{href:"https://www.uniprot.org/"},"UniProt")," or ",_.default.createElement($,{href:"https://alphafold.ebi.ac.uk/"},"AlphaFoldDB")))}var kt=(0,zr.makeStyles)()({endRow:{display:"flex",flexDirection:"row",gap:12,alignItems:"flex-start"}});function Ke({lookup:e}){let{classes:o}=kt();return ce.default.createElement(ce.default.Fragment,null,ce.default.createElement(wo,{lookupMode:e.lookupMode,onLookupModeChange:e.setLookupMode,manualUniprotId:e.manualUniprotId,onManualUniprotIdChange:e.setManualUniprotId,manualUniprotIdInvalid:e.manualUniprotIdInvalid,featureUniprotId:e.featureUniprotId,hasSearchableIdentifier:e.hasSearchableIdentifier,endContent:e.showIdentifierSelector?ce.default.createElement("div",{className:o.endRow},ce.default.createElement(Po,{recognizedIds:e.recognizedIds,geneName:e.geneName,selectedId:e.selectedQueryId,onSelectedIdChange:e.setSelectedQueryId}),ce.default.createElement(je.TextField,{size:"small",label:"NCBI taxon id",error:e.taxonIdError,helperText:e.taxonIdError?"Not a taxon id; searching every species":"Narrows the gene-name search to one species",value:e.taxonId,onChange:n=>{e.setTaxonId(n.target.value)},placeholder:"e.g. 9606",slotProps:{inputLabel:{shrink:!0}},sx:{width:180}})):null}),e.showIdentifierSelector?ce.default.createElement(je.Typography,{variant:"body2",color:"textSecondary"},e.organismDescription):null,e.nothingToSearch?ce.default.createElement(je.Typography,{variant:"body2",color:"textSecondary"},"This feature carries no Ensembl, RefSeq, CCDS or HGNC identifier and no gene name; enter a UniProt accession"):null,ce.default.createElement(te,{message:e.lookupPartialFailure}))}var me=a(C()),ao=a(U());var w=a(C()),y=a(U());var Hr=a(fe());var vt=(0,Hr.makeStyles)()(e=>({tableContainer:{maxHeight:200},headerCell:{fontWeight:"bold",backgroundColor:e.palette.mode==="dark"?e.palette.grey[900]:e.palette.grey[100]},selectedRow:{backgroundColor:e.palette.action.selected},clickableRow:{cursor:"pointer","&:hover":{backgroundColor:e.palette.action.hover}},reviewedChip:{backgroundColor:e.palette.success.main,color:e.palette.success.contrastText,fontSize:"0.7rem",height:20},unreviewedChip:{backgroundColor:e.palette.warning.main,color:e.palette.warning.contrastText,fontSize:"0.7rem",height:20}}));function xo({entries:e,selectedAccession:o,onSelect:n}){let{classes:r,cx:i}=vt();return e.length===0?null:w.default.createElement("div",null,w.default.createElement(y.Typography,{variant:"body2",sx:{mb:1}},"Found ",e.length," UniProt entries. Select one:"),w.default.createElement(y.TableContainer,{component:y.Paper,className:r.tableContainer},w.default.createElement(y.Table,{size:"small",stickyHeader:!0},w.default.createElement(y.TableHead,null,w.default.createElement(y.TableRow,null,w.default.createElement(y.TableCell,{className:r.headerCell,padding:"checkbox"}),w.default.createElement(y.TableCell,{className:r.headerCell},"Accession"),w.default.createElement(y.TableCell,{className:r.headerCell},"Gene"),w.default.createElement(y.TableCell,{className:r.headerCell},"Organism"),w.default.createElement(y.TableCell,{className:r.headerCell},"Protein"),w.default.createElement(y.TableCell,{className:r.headerCell},"Status"))),w.default.createElement(y.TableBody,null,e.map(t=>w.default.createElement(y.TableRow,{key:t.accession,onClick:()=>{n(t.accession)},className:i(r.clickableRow,o===t.accession&&r.selectedRow)},w.default.createElement(y.TableCell,{padding:"checkbox"},w.default.createElement(y.Radio,{checked:o===t.accession,size:"small"})),w.default.createElement(y.TableCell,null,w.default.createElement($,{href:Ne(t.accession)},t.accession)),w.default.createElement(y.TableCell,null,t.geneName??"-"),w.default.createElement(y.TableCell,null,t.organismName??"-"),w.default.createElement(y.TableCell,null,t.proteinName?t.proteinName.length>40?`${t.proteinName.slice(0,40)}...`:t.proteinName:"-"),w.default.createElement(y.TableCell,null,w.default.createElement(y.Chip,{label:t.isReviewed?"Reviewed":"Unreviewed",size:"small",className:t.isReviewed?r.reviewedChip:r.unreviewedChip}))))))))}function Gr(){return me.default.createElement($,{href:"https://www.uniprot.org/"},"UniProt")}function Qe({lookup:e}){let o=e.uniprotEntries.length>0;return e.isAutoMode?o?me.default.createElement(me.default.Fragment,null,me.default.createElement(ao.Typography,{variant:"body2",color:"textSecondary"},"Searched UniProt by ",e.searchDescription),me.default.createElement(xo,{entries:e.uniprotEntries,selectedAccession:e.selectedTableAccession,onSelect:e.setSelectedUniprotId}),me.default.createElement(ao.Typography,{variant:"body2",color:"textSecondary"},"If you don't see the entry you're looking for, try a different identifier above or search ",me.default.createElement(Gr,null),' directly and use "Enter manually".')):e.isLookupLoading||e.lookupError?null:me.default.createElement(ao.Typography,{variant:"body2",color:"textSecondary"},"No UniProt entries found for ",e.searchDescriptionOr,". Try a different identifier above, or search ",me.default.createElement(Gr,null),' directly and use "Enter manually".'):null}var Kr=a(C());var Wr=a(C());var $r=a(eo());function Xe({feature:e,view:o}){let{data:n,error:r,isLoading:i}=X(["isoform-sequences",e.id(),o?.assemblyNames?.[0]],async()=>{let l=ro(e),u=await hr({transcripts:l,session:(0,$r.getSession)(o),assemblyName:o?.assemblyNames?.[0]});for(let{feature:d,error:s}of u)s!==void 0&&console.error("[useIsoformProteinSequences] error for",d.id(),s);let c=u.flatMap(d=>d.seq===void 0?[]:[[d.feature.id(),{feature:d.feature,seq:d.seq}]]);return{sequences:Object.fromEntries(c),translated:c.length,total:u.length}},{...Y,keepPreviousData:!0}),t=n?n.total-n.translated:0;return{isLoading:i,isoformSequences:n?.sequences,error:r,partialFailure:t>0&&n?`${t} of ${n.total} transcripts have no protein sequence`:void 0}}function Fo({uniprotId:e,feature:o,view:n}){let{data:r,isLoading:i,isValidating:t,error:l}=X(e?["alphafold-models",e]:null,([,s])=>Ro(s),{...Y,keepPreviousData:!0}),{isoformSequences:u}=Xe({feature:o,view:n}),c=(0,Wr.useMemo)(()=>e&&(r||l)?wr(e,l?void 0:r,u):void 0,[e,r,l,u]);return{isLoading:i,isValidating:t,modelsUnreachable:e?l:void 0,model:c,noModel:!!e&&!i&&!l&&r?.length===0}}var jr=a(eo());function Uo({view:e,isoforms:o,structureSequences:n}){let r=!!e&&!!n?.length&&o.some(l=>l.seq),{data:i,error:t}=X(r?["isoform-ranking",o,n]:null,()=>gr({rpcManager:(0,jr.getSession)(e).rpcManager,name:"ProteinRankIsoforms",args:{isoforms:o,structureSequences:n??[]},inPlace:()=>To(o,n)}),Y);return r?{ranking:i,error:t}:{ranking:To(o,n)}}var Do=a(C());function Lt({options:e,isoformSequences:o,ranking:n,preferredTranscriptId:r}){return to(e,o).some(i=>i.id===r&&i.seq)?r:n&&br(n,yr(e))}function qo({options:e,isoformSequences:o,ranking:n,preferredTranscriptId:r,resetKey:i}){let[t,l]=(0,Do.useState)(),[u,c]=(0,Do.useState)(i);i!==u&&(c(i),l(void 0));let d=o!==void 0?Lt({options:e,isoformSequences:o,ranking:n,preferredTranscriptId:r}):void 0;return{userSelection:t??d,setUserSelection:l}}function he({feature:e,view:o,structureSequences:n,preferredTranscriptId:r,resetKey:i}){let t=ro(e),{isoformSequences:l,isLoading:u,error:c,partialFailure:d}=Xe({feature:e,view:o}),{ranking:s,error:p}=Uo({view:o,isoforms:to(t,l),structureSequences:n}),{userSelection:g,setUserSelection:S}=qo({options:t,isoformSequences:l,ranking:s?.ranking,preferredTranscriptId:r,resetKey:i}),x=t.find(T=>T.id()===g),m=g?l?.[g]:void 0;return{transcripts:t,isoformSequences:l,structureSequence:s?.structureSequence,ranking:s?.ranking,isLoading:u,isRanking:!!l&&!s&&!p&&!g,error:c??p,partialFailure:d,selectedTranscriptId:g,setSelectedTranscriptId:S,selectedTranscript:x,selectedIsoform:m}}function No({feature:e,view:o,lookup:n,preferredTranscriptId:r}){let{uniprotId:i,isLookupLoading:t}=n,{isLoading:l,isValidating:u,modelsUnreachable:c,model:d,noModel:s}=Fo({uniprotId:i,feature:e,view:o}),p=d?.sequence,g=(0,Kr.useMemo)(()=>p?[p]:void 0,[p]),{transcripts:S,isoformSequences:x,structureSequence:m,ranking:T,isLoading:P,isRanking:v,error:N,partialFailure:I,selectedTranscriptId:D,setSelectedTranscriptId:E,selectedTranscript:A,selectedIsoform:M}=he({feature:e,view:o,structureSequences:g,preferredTranscriptId:r,resetKey:d?.url}),H=[t&&"Looking up UniProt ID",P&&"Loading protein sequences from transcript isoforms",v&&"Aligning isoforms to the structure",l&&"Asking AlphaFold DB for models"].filter(Z=>typeof Z=="string"),G=H.length>0,J=N??n.lookupError,Q=G?void 0:J;return{...n,userSelection:D,setUserSelection:E,transcriptOptions:S,selectedTranscript:A,isoformSequences:x,ranking:T,isoformPartialFailure:I,userSelectedProteinSequence:M,url:d?.url,confidenceUrl:d?.confidenceUrl,modelAccession:d?.accession,structureSequence:m,noModel:s,modelsUnreachable:G?void 0:c,error:Q,loadingStatuses:H,sequencesMatch:!u&&M?.seq&&m?qe(M.seq)===m:void 0,isLoading:G}}var Pt=(0,Xr.makeStyles)()({dialogContent:{width:"80em","& > *":{marginBottom:20},"& > *:last-child":{marginBottom:0}},selectorsRow:{display:"flex",flexDirection:"row",gap:20,alignItems:"flex-start"}}),wt=(0,Qr.observer)(function({feature:o,preferredTranscriptId:n,session:r,view:i,handleClose:t,lookup:l,sideBySide:u,onSideBySideChange:c}){let{classes:d}=Pt(),s=No({feature:o,view:i,lookup:l,preferredTranscriptId:n});return V.default.createElement(V.default.Fragment,null,V.default.createElement(xe.DialogContent,{className:d.dialogContent},s.error?V.default.createElement(lo.ErrorMessage,{error:s.error}):null,s.noModel?V.default.createElement(xe.Typography,null,"AlphaFold DB has no model for ",s.uniprotId,". The PDB and Foldseek tabs may have a structure."):null,s.modelsUnreachable?V.default.createElement(xe.Typography,null,"AlphaFold DB's model list did not answer, so Launch opens the canonical model file for ",s.uniprotId,", without comparing its sequence to the isoforms."):null,V.default.createElement(Ke,{lookup:l}),s.loadingStatuses.map(p=>V.default.createElement(lo.LoadingEllipses,{key:p,variant:"subtitle2",message:p})),V.default.createElement(te,{message:s.isoformPartialFailure}),V.default.createElement(Qe,{lookup:l}),s.ranking&&s.selectedTranscript&&(s.structureSequence||s.modelsUnreachable)&&s.uniprotId?V.default.createElement(V.default.Fragment,null,V.default.createElement("div",{className:d.selectorsRow},V.default.createElement(ge,{val:s.userSelection,setVal:s.setUserSelection,structureSequence:s.structureSequence,feature:o,isoforms:s.transcriptOptions,ranking:s.ranking})),V.default.createElement(ko,{uniprotId:s.modelAccession??s.uniprotId,url:s.url})):null),V.default.createElement(xe.DialogActions,null,V.default.createElement($e,{handleClose:t,uniprotId:s.modelAccession??s.uniprotId,userSelectedProteinSequence:s.userSelectedProteinSequence,selectedTranscript:s.selectedTranscript,url:s.url,confidenceUrl:s.confidenceUrl,feature:o,view:i,session:r,sideBySide:u,onSideBySideChange:c,sequencesMatch:s.sequencesMatch,isLoading:s.isLoading,error:s.error})))}),Yr=wt;var L=a(C()),Ye=a(we()),j=a(U()),et=a(Re());var ot=a(fe());var pe=a(C()),ne=a(U());var Jr=a(fe()),xt=(0,Jr.makeStyles)()({root:{display:"flex",flexDirection:"column",gap:8},header:{display:"flex",alignItems:"center",gap:8},buttons:{display:"flex",gap:4},checkboxGroup:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:0}});function Eo({selected:e,onChange:o,disabled:n}){let{classes:r}=xt();return pe.default.createElement("div",{className:r.root},pe.default.createElement("div",{className:r.header},pe.default.createElement(ne.Typography,{variant:"subtitle2"},"Databases to search:"),pe.default.createElement("div",{className:r.buttons},pe.default.createElement(ne.Button,{size:"small",onClick:()=>{o(yo.map(i=>i.id))},disabled:n},"Select all"),pe.default.createElement(ne.Button,{size:"small",onClick:()=>{o([])},disabled:n},"Clear"))),pe.default.createElement(ne.FormGroup,{className:r.checkboxGroup},yo.map(i=>pe.default.createElement(ne.FormControlLabel,{key:i.id,control:pe.default.createElement(ne.Checkbox,{size:"small",checked:e.includes(i.id),onChange:()=>{e.includes(i.id)?o(e.filter(t=>t!==i.id)):o([...e,i.id])},disabled:n}),label:i.label}))))}var h=a(C()),f=a(U());var Rr=a(fe());var ie=a(C()),Zr=a(we()),Fe=a(U());function Ao({hit:e,session:o,view:n,feature:r,selectedTranscript:i,userProvidedTranscriptSequence:t,onClose:l}){let[u,c]=(0,ie.useState)(null),d=!!u,s=rr(e.target),p=I=>{c(I.currentTarget)},g=()=>{c(null)},{runLaunch:S,launchError:x,launching:m}=Be(l,g),T={session:o,view:n,feature:r,selectedTranscript:i,uniprotId:s},P=S(()=>{let I=!e.structureUrl&&So(e)?lr(e.tCa,e.tSeq,"A",e.target):void 0;return Ee({...T,url:e.structureUrl,data:I,userProvidedTranscriptSequence:t})}),{launch1D:v}=no({...T,confidenceUrl:nr(e.target)});return!!e.structureUrl||So(e)?ie.default.createElement(ie.default.Fragment,null,x?ie.default.createElement(Zr.ErrorMessage,{error:x}):null,ie.default.createElement(Fe.Button,{size:"small",variant:"outlined",disabled:m,onClick:p},"Load"),ie.default.createElement(Fe.Menu,{anchorEl:u,open:d,onClose:g},ie.default.createElement(Fe.MenuItem,{"data-testid":"protein-launch-option-3d",onClick:P},Ae["3d"]),v?ie.default.createElement(Fe.MenuItem,{"data-testid":"protein-launch-option-1d",onClick:S(v)},Ae["1d"]):null)):ie.default.createElement("span",null,"-")}var Ft=(0,Rr.makeStyles)()(e=>({root:{display:"flex",flexDirection:"column",gap:16},tableContainer:{maxHeight:400},headerCell:{fontWeight:"bold",backgroundColor:e.palette.mode==="dark"?e.palette.grey[900]:e.palette.grey[100]},noResults:{padding:16,textAlign:"center"}})),Ut=100;function Dt(e){let o=e.results.flatMap(n=>(n.alignments??[]).flat().map(r=>({...r,db:n.db,structureUrl:tr(r.target,n.db)})));return o.sort((n,r)=>(n.eval??1/0)-(r.eval??1/0)),o}function Mo({results:e,session:o,view:n,feature:r,selectedTranscript:i,userProvidedTranscriptSequence:t,onClose:l}){let{classes:u}=Ft(),c=Dt(e),d=c.slice(0,Ut);return d.length===0?h.default.createElement(f.Paper,{className:u.noResults},h.default.createElement(f.Typography,null,"No similar structures found")):h.default.createElement("div",{className:u.root},h.default.createElement(f.Typography,{variant:"subtitle2"},"Found ",c.length," similar structures",c.length>d.length?` (showing top ${d.length})`:""),h.default.createElement(f.TableContainer,{component:f.Paper,className:u.tableContainer},h.default.createElement(f.Table,{size:"small",stickyHeader:!0},h.default.createElement(f.TableHead,null,h.default.createElement(f.TableRow,null,h.default.createElement(f.TableCell,{className:u.headerCell},"Database"),h.default.createElement(f.TableCell,{className:u.headerCell},"Target"),h.default.createElement(f.TableCell,{className:u.headerCell},"Organism"),h.default.createElement(f.TableCell,{className:u.headerCell},h.default.createElement(f.Tooltip,{title:"Foldseek's estimated probability that the hit is a true structural homolog"},h.default.createElement("span",null,"Prob"))),h.default.createElement(f.TableCell,{className:u.headerCell},h.default.createElement(f.Tooltip,{title:"Percentage of aligned residues whose amino acid is identical; structural hits are often low here"},h.default.createElement("span",null,"Seq. Id."))),h.default.createElement(f.TableCell,{className:u.headerCell},"Coverage"),h.default.createElement(f.TableCell,{className:u.headerCell},h.default.createElement(f.Tooltip,{title:"Hits of this score expected by chance in a database this size; smaller is stronger"},h.default.createElement("span",null,"E-value"))),h.default.createElement(f.TableCell,{className:u.headerCell},"Actions"))),h.default.createElement(f.TableBody,null,d.map((s,p)=>h.default.createElement(f.TableRow,{key:`${s.db}-${s.target}-${p}`},h.default.createElement(f.TableCell,null,s.db),h.default.createElement(f.TableCell,null,s.target),h.default.createElement(f.TableCell,null,s.taxName??"-"),h.default.createElement(f.TableCell,null,s.prob!=null?`${(s.prob*100).toFixed(1)}%`:"-"),h.default.createElement(f.TableCell,null,s.seqId!=null?`${s.seqId.toFixed(1)}%`:"-"),h.default.createElement(f.TableCell,null,s.alnLength!=null&&s.qLen!=null?`${(s.alnLength/s.qLen*100).toFixed(1)}%`:"-"),h.default.createElement(f.TableCell,null,s.eval!=null?s.eval.toExponential(2):"-"),h.default.createElement(f.TableCell,null,h.default.createElement(Ao,{hit:s,session:o,view:n,feature:r,selectedTranscript:i,userProvidedTranscriptSequence:t,onClose:l}))))))))}var se=a(C());function Bo(){let[e,o]=(0,se.useState)(),[n,r]=(0,se.useState)(),[i,t]=(0,se.useState)(!1),[l,u]=(0,se.useState)(!1),[c,d]=(0,se.useState)(),[s,p]=(0,se.useState)(""),g=(0,se.useRef)(null);(0,se.useEffect)(()=>()=>{g.current?.abort()},[]);let S=()=>{g.current?.abort();let v=new AbortController;return g.current=v,v.signal},x=async v=>{let N=S();u(!0),d(void 0),p("Predicting 3Di structure...");try{let I=await mr(v,{signal:N});return r(I),I}catch(I){N.aborted||(console.error(I),d(I));return}finally{N.aborted||(u(!1),p(""))}},m=async(v,N,I)=>{let D=S();t(!0),d(void 0),p("Submitting search...");try{let E=await pr({aaSequence:v,di3Sequence:N,databases:I},{signal:D}),A=await fr(E.id,{onStatus:p,signal:D});return o(A),A}catch(E){D.aborted||(console.error(E),d(E));return}finally{D.aborted||(t(!1),p(""))}},T=()=>{g.current?.abort(),g.current=null,t(!1),u(!1),p("")},P=()=>{T(),o(void 0),r(void 0),d(void 0)};return{results:e,cleanedAaSequence:n?.aaSequence,di3Sequence:n?.di3Sequence,isLoading:i,isPredicting:l,error:c,statusMessage:s,predictStructure:x,search:m,cancel:T,reset:P}}var qt=(0,ot.makeStyles)()({dialogContent:{width:"80em",display:"flex",flexDirection:"column",gap:20},sequenceInput:{fontFamily:"monospace"},di3Section:{display:"flex",flexDirection:"column",gap:8,alignItems:"flex-start"}}),Nt=(0,et.observer)(function({feature:o,preferredTranscriptId:n,session:r,view:i,handleClose:t}){let{classes:l}=qt(),[u,c]=(0,L.useState)(),[d,s]=(0,L.useState)(ur),[p,g]=(0,L.useState)(!1),{results:S,cleanedAaSequence:x,di3Sequence:m,isLoading:T,isPredicting:P,error:v,statusMessage:N,predictStructure:I,search:D,cancel:E,reset:A}=Bo(),{transcripts:M,isoformSequences:H,ranking:G,isLoading:J,error:Q,partialFailure:Z,selectedTranscriptId:ae,setSelectedTranscriptId:be,selectedTranscript:Se,selectedIsoform:re}=he({feature:o,view:i,preferredTranscriptId:n}),Le=re?Yo(re.seq):"",ee=u??Le,Pe=()=>{(m!==void 0||S!==void 0)&&A()},ze=ue=>{be(ue),c(void 0),Pe()},le=T||P,He=cr(ee),Wo=dr(ee).length>0&&!He&&d.length>0&&!le,Ze=async()=>{let ue=x&&m?{aaSequence:x,di3Sequence:m}:await I(ee.trim());ue&&await D(ue.aaSequence,ue.di3Sequence,d)},fo=v??Q;return L.default.createElement(L.default.Fragment,null,L.default.createElement(j.DialogContent,{className:l.dialogContent},fo&&!J?L.default.createElement(Ye.ErrorMessage,{error:fo}):null,J?L.default.createElement(Ye.LoadingEllipses,{variant:"subtitle2",message:"Loading transcript sequences"}):null,L.default.createElement(te,{message:Z}),H&&G?L.default.createElement(L.default.Fragment,null,L.default.createElement(ge,{val:ae,setVal:ze,isoforms:M,ranking:G,feature:o,disabled:le}),L.default.createElement(j.TextField,{label:"Protein sequence (amino acids)",multiline:!0,rows:4,value:ee,onChange:ue=>{c(ue.target.value),Pe()},placeholder:"MKTVRQERLKSIVRILERSKEPVSGAQLAEEL...",disabled:le,error:!!He,helperText:He,slotProps:{input:{className:l.sequenceInput}}})):null,m?L.default.createElement("div",{className:l.di3Section},L.default.createElement(j.Link,{component:"button",type:"button",variant:"body2",onClick:()=>{g(!p)}},p?"Hide 3Di":"Show 3Di"),p?L.default.createElement(j.TextField,{label:"3Di structural alphabet (what the search runs on)",multiline:!0,rows:4,fullWidth:!0,value:m,slotProps:{input:{className:l.sequenceInput,readOnly:!0}}}):null):null,L.default.createElement(Eo,{selected:d,onChange:s,disabled:le}),N?L.default.createElement(Ye.LoadingEllipses,{variant:"subtitle2",message:N}):null,S?L.default.createElement(Mo,{results:S,session:r,view:i,feature:o,selectedTranscript:Se,userProvidedTranscriptSequence:re?.seq,onClose:t}):null,L.default.createElement(j.Typography,{variant:"body2",color:"textSecondary"},"Searching sends the protein sequence above to the foldseek.com servers, which predict its 3Di alphabet and run the structure search.")),L.default.createElement(j.DialogActions,null,L.default.createElement(j.Button,{variant:"contained",color:"secondary",onClick:()=>{t()}},"Close"),le?L.default.createElement(j.Button,{variant:"outlined",onClick:()=>{E()}},"Cancel search"):null,S?L.default.createElement(j.Button,{variant:"outlined",onClick:()=>{A()}},"New search"):null,L.default.createElement(j.Button,{variant:"contained",color:"primary",disabled:!Wo,onClick:()=>{Ze()}},P?"Predicting 3Di...":T?"Searching...":"Search Foldseek")))}),rt=Nt;var R=a(C());var tt=a(U()),Et=(0,R.lazy)(()=>import("./HelpDialog-XVM5IEP4.js"));function Je(){let[e,o]=(0,R.useState)(!1);return R.default.createElement(R.default.Fragment,null,R.default.createElement(tt.IconButton,{onClick:()=>{o(!0)}},R.default.createElement(xr,null)),e?R.default.createElement(R.Suspense,{fallback:null},R.default.createElement(Et,{handleClose:()=>{o(!1)}})):null)}var B=a(C()),co=a(we()),ve=a(U()),st=a(Re());var at=a(fe());var k=a(C()),b=a(U());var it=a(fe());var At=(0,it.makeStyles)()(e=>({tableContainer:{maxHeight:300},headerCell:{fontWeight:"bold",backgroundColor:e.palette.mode==="dark"?e.palette.grey[900]:e.palette.grey[100]},selectedRow:{backgroundColor:e.palette.action.selected},clickableRow:{cursor:"pointer","&:hover":{backgroundColor:e.palette.action.hover}}})),nt=100;function Vo({entries:e,selectedPdbId:o,onSelect:n}){let{classes:r}=At(),i=e.slice(0,nt);return k.default.createElement(k.default.Fragment,null,k.default.createElement(b.Typography,{variant:"body2",color:"textSecondary"},e.length," PDB entries, ranked on coverage, then resolution",e.length>i.length?` (showing the first ${nt})`:""),k.default.createElement(b.TableContainer,{component:b.Paper,className:r.tableContainer},k.default.createElement(b.Table,{size:"small",stickyHeader:!0,"data-testid":"pdb-results-table"},k.default.createElement(b.TableHead,null,k.default.createElement(b.TableRow,null,k.default.createElement(b.TableCell,{className:r.headerCell,padding:"checkbox"}),k.default.createElement(b.TableCell,{className:r.headerCell},"PDB ID"),k.default.createElement(b.TableCell,{className:r.headerCell},"Method"),k.default.createElement(b.TableCell,{className:r.headerCell},"Resolution"),k.default.createElement(b.TableCell,{className:r.headerCell},k.default.createElement(b.Tooltip,{title:"The span of the UniProt sequence this entry resolves, by RCSB's UniProt alignment. A crystal is usually one domain rather than the whole protein."},k.default.createElement("span",null,"UniProt residues"))),k.default.createElement(b.TableCell,{className:r.headerCell},"Coverage"),k.default.createElement(b.TableCell,{className:r.headerCell},"Chains"))),k.default.createElement(b.TableBody,null,i.map(t=>{let l=t.pdbId===o;return k.default.createElement(b.TableRow,{key:t.pdbId,className:`${r.clickableRow} ${l?r.selectedRow:""}`,onClick:()=>{n(t.pdbId)}},k.default.createElement(b.TableCell,{padding:"checkbox"},k.default.createElement(b.Radio,{checked:l,size:"small"})),k.default.createElement(b.TableCell,null,k.default.createElement($,{href:or(t.pdbId)},t.pdbId.toUpperCase())),k.default.createElement(b.TableCell,null,t.method),k.default.createElement(b.TableCell,null,t.resolution===void 0?"-":`${t.resolution.toFixed(2)} \xC5`),k.default.createElement(b.TableCell,null,t.start,"-",t.end),k.default.createElement(b.TableCell,null,(t.coverage*100).toFixed(0),"%"),k.default.createElement(b.TableCell,null,t.chains.join(", ")))})))))}var uo=a(C());function ke(e,o=300){let[n,r]=(0,uo.useState)(e);return(0,uo.useEffect)(()=>{let i=setTimeout(()=>{r(e)},o);return()=>{clearTimeout(i)}},[e,o]),n}function Oo(e){let{data:o,error:n,isLoading:r}=X(e?["experimental-structures",e]:null,([,i])=>ir(i),Y);return{entries:o,error:n,isLoading:r}}function _o(e){let{data:o,error:n,isLoading:r,isValidating:i}=X(e?["pdb-entry",e]:null,([,t])=>Zo(t),Y);return{entry:o,error:n,isLoading:r,isValidating:i}}var Mt=(0,at.makeStyles)()({dialogContent:{width:"80em","& > *":{marginBottom:20},"& > *:last-child":{marginBottom:0}}}),Bt=(0,st.observer)(function({feature:o,preferredTranscriptId:n,session:r,view:i,handleClose:t,lookup:l,sideBySide:u,onSideBySideChange:c}){let{classes:d}=Mt(),{uniprotId:s,isLookupLoading:p,lookupError:g}=l,{entries:S,error:x,isLoading:m}=Oo(s),[T,P]=(0,B.useState)(),[v,N]=(0,B.useState)(""),I=v.trim(),D=ke(I,400),E=I!==""&&!oo(I),A=oo(D)?D.toLowerCase():T&&S?.some(ye=>ye.pdbId===T)?T:S?.[0]?.pdbId,M=A?er(A):void 0,{entry:H,error:G,isValidating:J}=_o(A),Q=H?.proteinSequences,{transcripts:Z,structureSequence:ae,ranking:be,isLoading:Se,isRanking:re,error:Le,partialFailure:ee,selectedTranscriptId:Pe,setSelectedTranscriptId:ze,selectedTranscript:le,selectedIsoform:He}=he({feature:o,view:i,structureSequences:Q,preferredTranscriptId:n,resetKey:s}),Ze=[Se&&"Loading protein sequences from transcript isoforms",re&&"Aligning isoforms to the structure",J&&!G&&Pe!==n&&"Reading the chains of the entry from RCSB",I!==D&&"Reading the typed PDB ID"],ue=[...[p&&"Looking up UniProt ID",m&&"Listing PDB entries from RCSB"],...Ze].filter(ye=>!!ye),jo=ue.length>0,go=jo?void 0:Le??g??x,ho=oo(D),Ko=E||(ho?Ze.some(Boolean):jo),bt=ho?Ko?void 0:Le:go,St=ho&&(p||g)?void 0:s;return B.default.createElement(B.default.Fragment,null,B.default.createElement(ve.DialogContent,{className:d.dialogContent},go?B.default.createElement(co.ErrorMessage,{error:go}):null,B.default.createElement(Ke,{lookup:l}),ue.map(ye=>B.default.createElement(co.LoadingEllipses,{key:ye,variant:"subtitle2",message:ye})),B.default.createElement(te,{message:ee}),B.default.createElement(Qe,{lookup:l}),B.default.createElement(ve.TextField,{size:"small",label:"PDB ID",placeholder:"e.g. 1TUP",helperText:E?"A PDB ID is four characters beginning with a digit":"Overrides the selection below",error:E,value:v,onChange:ye=>{N(ye.target.value)},slotProps:{inputLabel:{shrink:!0}},sx:{width:240}}),s&&S&&!m?S.length>0?B.default.createElement(Vo,{entries:S,selectedPdbId:A,onSelect:P}):B.default.createElement(ve.Typography,null,"RCSB lists no experimental structure for"," ",B.default.createElement($,{href:Ne(s)},s),". The AlphaFoldDB tab has a predicted one."):null,be&&le?B.default.createElement(ge,{val:Pe,setVal:ze,structureSequence:ae,feature:o,isoforms:Z,ranking:be}):null),B.default.createElement(ve.DialogActions,null,B.default.createElement($e,{handleClose:t,uniprotId:St,userSelectedProteinSequence:He,selectedTranscript:le,url:M,pdbId:A,feature:o,view:i,session:r,sideBySide:u,onSideBySideChange:c,isLoading:Ko,error:bt})))}),lt=Bt;var mo=a(C());function Ve({children:e,value:o,index:n,...r}){let i=o===n,[t,l]=(0,mo.useState)(i);return i&&!t&&l(!0),mo.default.createElement("div",{role:"tabpanel",hidden:!i,...r},t?e:null)}var F=a(C()),Oe=a(we()),Ue=a(U()),dt=a(Re());var ct=a(fe());var z=a(C()),O=a(U());function zo({choice:e,setChoice:o,structureURL:n,setStructureURL:r,setFile:i}){return z.default.createElement("div",{style:{display:"flex",margin:30}},z.default.createElement(O.Typography,null,"Open your structure file ",z.default.createElement(Je,null)),z.default.createElement(O.FormControl,{component:"fieldset"},z.default.createElement(O.RadioGroup,{value:e,onChange:t=>{o(t.target.value)}},z.default.createElement(O.FormControlLabel,{value:"url",control:z.default.createElement(O.Radio,null),label:"URL"}),z.default.createElement(O.FormControlLabel,{value:"file",control:z.default.createElement(O.Radio,null),label:"File"}))),e==="url"?z.default.createElement("div",null,z.default.createElement(O.Typography,null,"Open a PDB/mmCIF/etc. file from remote URL"),z.default.createElement(O.TextField,{label:"URL",value:n,onChange:t=>{r(t.target.value)}})):z.default.createElement("div",{style:{paddingTop:20}},z.default.createElement(O.Typography,null,"Open a PDB/mmCIF/etc. file from your local drive"),z.default.createElement(O.Button,{variant:"outlined",component:"label"},"Choose file",z.default.createElement("input",{type:"file",hidden:!0,accept:Fr,onChange:({target:t})=>{let l=t.files?.[0];l&&i(l)}}))))}async function ut(e){let{PluginContext:o,DefaultPluginSpec:n}=await Dr(),r=new o(n());await r.init();try{return await e(r)}finally{r.dispose()}}async function Vt({file:e,url:o}){let n=e?await io(e):void 0;return ut(async r=>{let i=await Ur({plugin:r,data:n,url:o}),t=await r.builders.structure.createModel(i);return Jo(t)})}function Ho({file:e,url:o}){let n=e?["structure-file",e.name,e.size,e.lastModified]:o?["structure-url",o]:null,{data:r,error:i,isLoading:t}=X(n,async()=>{let l=await Vt({file:e,url:o});if(!l?.length)throw new Error("No protein sequence found in this structure");return l},Y);return{error:i,isLoading:t,sequences:r}}var Ot=(0,ct.makeStyles)()(e=>({dialogContent:{marginTop:e.spacing(6),width:"80em"}}));function _t(){return F.default.createElement("div",{style:{marginBottom:20}},"Manually supply a protein structure (PDB, mmCIF, etc) for a given transcript. You can open the file from the result of running, for example,"," ",F.default.createElement($,{href:"https://github.com/sokrypton/ColabFold"},"ColabFold"),". This plugin will align the protein sequence calculated from the genome to the protein sequence embedded in the structure file which allows for slight differences in these two representations.")}var zt=(0,dt.observer)(function({feature:o,preferredTranscriptId:n,session:r,view:i,handleClose:t}){let{classes:l}=Ot(),[u,c]=(0,F.useState)(),[d,s]=(0,F.useState)("file"),[p,g]=(0,F.useState)(""),{runLaunch:S,launchError:x,launching:m}=Be(t),T=d==="file"?u:void 0,P=d==="file"?"":p,v=ke(P,600),{sequences:N,isLoading:I,error:D}=Ho({file:T,url:v}),{transcripts:E,isoformSequences:A,structureSequence:M,ranking:H,isRanking:G,selectedTranscriptId:J,setSelectedTranscriptId:Q,selectedTranscript:Z,selectedIsoform:ae,error:be,partialFailure:Se}=he({feature:o,view:i,structureSequences:N,preferredTranscriptId:n}),re=be??D??x,ee=!!(P||T)&&!!ae&&!!Z&&!((I||P!==v||G)&&J!==n)&&!m,Pe=!!ae?.seq&&!!M&&qe(ae.seq)!==M,ze=S(async()=>{if(ae&&Z){let le=T?await io(T):void 0;await Ee({session:r,view:i,feature:o,selectedTranscript:Z,url:P||void 0,data:le,userProvidedTranscriptSequence:ae.seq})}});return F.default.createElement(F.default.Fragment,null,F.default.createElement(Ue.DialogContent,{className:l.dialogContent},re?F.default.createElement(Oe.ErrorMessage,{error:re}):null,F.default.createElement(_t,null),F.default.createElement(zo,{choice:d,setChoice:s,structureURL:p,setStructureURL:g,setFile:c}),F.default.createElement("div",{style:{margin:20}},I?F.default.createElement(Oe.LoadingEllipses,{variant:"subtitle2",message:"Reading residues from the structure"}):null,F.default.createElement(te,{message:Se}),G?F.default.createElement(Oe.LoadingEllipses,{variant:"subtitle2",message:"Aligning isoforms to the structure"}):null,A?M&&H?F.default.createElement(ge,{val:J,setVal:Q,structureSequence:M,isoforms:E,feature:o,ranking:H}):null:F.default.createElement(Oe.LoadingEllipses,{title:"Loading protein sequences",variant:"h6"}))),F.default.createElement(Ue.DialogActions,null,Pe?F.default.createElement(Ge,null):null,F.default.createElement(Ue.Button,{variant:"contained",color:"secondary",onClick:()=>{t()}},"Cancel"),F.default.createElement(Ue.Button,{variant:"contained",color:"primary",disabled:!ee,onClick:()=>{ze()}},"Launch 3D protein structure view")))}),mt=zt;var _e=a(C()),pt=a(yt()),ft=a(eo());function Ht({attemptedCount:e,failedCount:o}){return o>0&&o<e?`UniProt lookup failed for ${o} of ${e} identifiers`:void 0}function Go({recognizedIds:e=[],geneId:o,geneName:n,organismId:r,selectedQueryId:i="auto",enabled:t=!0}){let l=[],u;i==="auto"?(l=e,u=n):i.startsWith("gene:")?u=i.replace("gene:",""):bo(i)&&(l=[i]);let c=l.some(g=>bo(g))||!!u,{data:d,error:s,isLoading:p}=X(t&&c?["uniprotSearch",i,l.join(","),u,o,r]:null,async()=>ar({recognizedIds:l,geneId:o,geneName:u,organismId:r}),{...Y,keepPreviousData:!0});return{entries:d?.entries??[],isLoading:p,error:s,partialFailure:d?Ht(d):void 0}}function po({selectedQueryId:e,recognizedIds:o,geneName:n,joinWord:r="and"}){return e==="auto"?[o.length>0?`database ID${o.length>1?"s":""} "${o.join('", "')}"`:void 0,n?`gene name "${n}"`:void 0].filter(Boolean).join(` ${r} `):e.startsWith("gene:")?`gene name "${e.replace("gene:","")}"`:`database ID "${e}"`}function Gt(e,o){return e===void 0?"Organism: unknown, showing all species; type an NCBI taxon id to narrow":`Organism: ${e} (${o==="user"?"typed above":"from assembly"})`}function $o({feature:e,view:o,preferredTranscriptId:n}){let r=kr(e,n),i=r.uniprotId,t=r.recognizedIds.length>0||!!r.geneName,[l,u]=(0,_e.useState)(()=>i?"feature":t?"auto":"manual"),[c,d]=(0,_e.useState)(""),[s,p]=(0,_e.useState)(""),g=o.assemblyNames[0],S=g?(0,ft.getSession)(o).assemblyManager.get(g):void 0,x=S?Tr((0,pt.getConf)(S,["sequence","metadata"])):void 0,m=ke(s.trim(),400),T=Number(m),P=m!==""&&Number.isFinite(T)&&T>0,v=P?T:x,N=m!==""&&!P,[I,D]=(0,_e.useState)("auto"),[E,A]=(0,_e.useState)(),M=l==="auto",{entries:H,isLoading:G,error:J,partialFailure:Q}=Go({recognizedIds:r.recognizedIds,geneId:r.geneId,geneName:r.geneName,organismId:v,selectedQueryId:I,enabled:M}),Z=ke(c,400),be=G||l==="manual"&&c!==Z,Se=H.some(ee=>ee.accession===E)?E:void 0,re=H[0]?.accession,Le=l==="feature"?i:M?Se??re:Io(Z)?Z:void 0;return{lookupMode:l,setLookupMode:u,manualUniprotId:c,setManualUniprotId:ee=>{d(ee.trim().toUpperCase())},manualUniprotIdInvalid:c!==""&&!Io(c),taxonId:s,setTaxonId:p,taxonIdError:N,organismDescription:Gt(v,P?"user":"assembly"),selectedQueryId:I,setSelectedQueryId:D,setSelectedUniprotId:A,selectedTableAccession:Se??re,uniprotEntries:H,isLookupLoading:be,lookupError:J,lookupPartialFailure:Q,uniprotId:Le,featureUniprotId:i,recognizedIds:r.recognizedIds,geneName:r.geneName,isAutoMode:M,hasSearchableIdentifier:t,nothingToSearch:!t&&!i,showIdentifierSelector:M&&t,searchDescription:po({selectedQueryId:I,recognizedIds:r.recognizedIds,geneName:r.geneName}),searchDescriptionOr:po({selectedQueryId:I,recognizedIds:r.recognizedIds,geneName:r.geneName,joinWord:"or"})}}function $t({handleClose:e,feature:o,preferredTranscriptId:n,model:r,view:i}){let[t,l]=(0,q.useState)(0),u=(0,ht.getSession)(r),c=$o({feature:o,view:i,preferredTranscriptId:n}),[d,s]=(0,q.useState)(()=>vr()),p=g=>{s(g),Lr(g)};return q.default.createElement(gt.Dialog,{"data-testid":"launch-protein-view-dialog",maxWidth:"xl",title:"Launch protein view",titleNode:q.default.createElement(q.default.Fragment,null,"Launch protein view ",q.default.createElement(Je,null)),open:!0,onClose:e},q.default.createElement(De.Tabs,{value:t,onChange:(g,S)=>{l(S)}},q.default.createElement(De.Tab,{value:0,label:"AlphaFoldDB search"}),q.default.createElement(De.Tab,{value:1,label:"PDB search"}),q.default.createElement(De.Tab,{value:2,label:"Foldseek search"}),q.default.createElement(De.Tab,{value:3,label:"File or URL"})),q.default.createElement(Ve,{value:t,index:0},q.default.createElement(Yr,{session:u,view:i,feature:o,preferredTranscriptId:n,handleClose:e,lookup:c,sideBySide:d,onSideBySideChange:p})),q.default.createElement(Ve,{value:t,index:1},q.default.createElement(lt,{session:u,view:i,feature:o,preferredTranscriptId:n,handleClose:e,lookup:c,sideBySide:d,onSideBySideChange:p})),q.default.createElement(Ve,{value:t,index:2},q.default.createElement(rt,{session:u,view:i,feature:o,preferredTranscriptId:n,handleClose:e})),q.default.createElement(Ve,{value:t,index:3},q.default.createElement(mt,{session:u,view:i,feature:o,preferredTranscriptId:n,handleClose:e})))}export{$t as default};
|
|
2
|
-
//# sourceMappingURL=LaunchProteinViewDialog-
|
|
1
|
+
import{a as Dr}from"./chunk-NOFPQXHZ.js";import{a as $}from"./chunk-CU6NAWYQ.js";import{a as X,b as Y,c as xr}from"./chunk-X47I2IB5.js";import{a as Ur}from"./chunk-UTDQGJCS.js";import{a as Io,b as Pr,c as io,d as Fr}from"./chunk-UXGREKQA.js";import{a as U}from"./chunk-HAGLAQP5.js";import{a as fe}from"./chunk-NZ3TO6NV.js";import{a as Sr}from"./chunk-SIZG3XB4.js";import{a as Tt}from"./chunk-533QNNGN.js";import{a as Re}from"./chunk-LOG7ZCI7.js";import{a as we}from"./chunk-HLB63AD7.js";import{a as C}from"./chunk-GVEKA5YG.js";import{a as vr,b as Lr,j as Ee,l as Ae,m as no}from"./chunk-DIM277D5.js";import"./chunk-R64WXKZQ.js";import"./chunk-MJZSVHMS.js";import"./chunk-LZTO76OW.js";import"./chunk-OI77P32P.js";import"./chunk-2RFFBSIA.js";import"./chunk-INWFM3CY.js";import"./chunk-Z3277B6H.js";import"./chunk-5NBLSM7W.js";import"./chunk-ISVQX4IH.js";import"./chunk-UVDYWAS6.js";import{a as wr}from"./chunk-3LIMY6Z5.js";import{a as To,b as br}from"./chunk-ASJJTAZT.js";import{a as ro,c as yr,d as Tr,e as Ir,f as Cr,g as kr,h as to}from"./chunk-2LPERV4E.js";import{a as gr}from"./chunk-7UQOTULP.js";import{$a as ir,Ab as fr,Ga as Ro,Ka as Ne,Ma as er,Na as oo,Oa as or,Q as qe,R as Yo,Ra as rr,Sa as tr,Ta as nr,aa as Jo,b as Qo,bb as bo,cb as sr,e as Xo,hb as ar,mb as lr,nb as So,pb as yo,qb as ur,sb as dr,tb as cr,yb as mr,za as Zo,zb as pr}from"./chunk-WZCSPP5F.js";import{a as eo}from"./chunk-B3HKXTGK.js";import{a as yt,e as hr}from"./chunk-S6PS4I6X.js";import"./chunk-SPXMXPSC.js";import{c as a}from"./chunk-KVMUXFPB.js";var q=a(C()),gt=a(we()),ht=a(eo()),De=a(U());var V=a(C()),lo=a(we()),xe=a(U()),Qr=a(Re()),Xr=a(fe());var Me=a(C()),Co=a(U());function ko({uniprotId:e,url:o}){return Me.default.createElement("div",null,Me.default.createElement(Co.Typography,null,"UniProt link:"," ",Me.default.createElement($,{href:Ne(e)},e)),Me.default.createElement(Co.Typography,null,"AlphaFoldDB link: ",Me.default.createElement($,{href:o},o)))}var qr=a(C()),Nr=a(U());function te({message:e}){return e?qr.default.createElement(Nr.Typography,{variant:"body2",color:"warning.main"},e):null}var K=a(C()),_r=a(we());var Er=a(Tt(),1),Ar=(0,Sr.createSvgIcon)((0,Er.jsx)("path",{d:"m7 10 5 5 5-5z"}),"ArrowDropDown");var Ie=a(U());var Te=a(C()),oe=a(U());function vo({anchorEl:e,onClose:o,options:n,sideBySide:r,onSideBySideChange:i}){return Te.default.createElement(oe.Menu,{anchorEl:e,open:!!e,onClose:o,"data-testid":"protein-launch-options-menu"},n.map(t=>Te.default.createElement(oe.MenuItem,{key:t.key,"data-testid":`protein-launch-option-${t.key}`,onClick:t.onClick},Te.default.createElement(oe.ListItemText,{primary:t.title,secondary:t.description}))),Te.default.createElement(oe.Divider,null),Te.default.createElement(oe.MenuItem,{"data-testid":"protein-launch-side-by-side",onClick:()=>{i(!r)}},Te.default.createElement(oe.Checkbox,{checked:r,size:"small"}),Te.default.createElement(oe.ListItemText,{primary:"Open side by side",secondary:"Place the protein view right of the genome view instead of below it"})))}var Mr=a(C()),Br=a(U());function Ge(){return Mr.default.createElement(Br.Typography,{variant:"body2",sx:{mr:2}},"Transcript and structure sequences differ, will run"," ",Xo[Qo]," alignment")}var Lo=a(C());async function Vr(e,o,n){try{await e(),o?.()}catch(r){console.error(r),n?.(r)}}function Or({uniprotId:e,userSelectedProteinSequence:o,selectedTranscript:n,url:r,pdbId:i}){let t=!!r||!!i;return[!t&&!e&&"No UniProt ID found",!o?.seq&&"Could not compute protein sequence (feature may be missing CDS subfeatures)",!n&&"No transcript selected",!t&&"No structure selected"].filter(l=>typeof l=="string")}function Be(e,o){let[n,r]=(0,Lo.useState)(),[i,t]=(0,Lo.useState)(!1);return{runLaunch:u=>()=>{o?.(),i||(t(!0),r(void 0),Vr(u,e,r).then(()=>{t(!1)}))},launchError:n,launching:i}}function $e({handleClose:e,uniprotId:o,userSelectedProteinSequence:n,selectedTranscript:r,url:i,pdbId:t,confidenceUrl:l,feature:u,view:c,session:d,sideBySide:s,onSideBySideChange:p,sequencesMatch:g,isLoading:S,error:x}){let[m,T]=(0,K.useState)(null),P=()=>{T(null)},{runLaunch:v,launchError:N,launching:I}=Be(e,P),D=Or({uniprotId:o,userSelectedProteinSequence:n,selectedTranscript:r,url:i,pdbId:t}),E=!S&&!x&&!I&&D.length===0,A=!S&&!x&&D.length>0,M={session:d,view:c,feature:u,selectedTranscript:r,uniprotId:o,url:i,userProvidedTranscriptSequence:n?.seq,sideBySide:s},H=v(()=>Ee(M)),{launch1D:G}=no({session:d,view:c,feature:u,selectedTranscript:r,uniprotId:o,confidenceUrl:l}),J=[{key:"3d",title:Ae["3d"],description:"View protein structure with genome-to-structure coordinate mapping",onClick:H},...G?[{key:"1d",title:Ae["1d"],description:"View protein features and annotations as a linear track",onClick:v(G)}]:[]];return K.default.createElement(K.default.Fragment,null,N?K.default.createElement(_r.ErrorMessage,{error:N}):null,g===!1?K.default.createElement(Ge,null):null,K.default.createElement(Ie.Button,{variant:"contained",color:"secondary",size:"small",onClick:()=>{e()}},"Cancel"),A?K.default.createElement("div",{style:{marginRight:16}},D.map(Q=>K.default.createElement(Ie.Typography,{key:Q,variant:"body2",color:"error"},Q))):null,K.default.createElement(Ie.ButtonGroup,{variant:"contained",color:"primary",size:"small"},K.default.createElement(Ie.Button,{"data-testid":"protein-launch-button",disabled:!E,onClick:H},"Launch"),K.default.createElement(Ie.Button,{"data-testid":"protein-launch-options-button",disabled:!E,onClick:Q=>{T(Q.currentTarget)},"aria-label":"More launch options"},K.default.createElement(Ar,null))),K.default.createElement(vo,{anchorEl:m,onClose:P,options:J,sideBySide:s,onSideBySideChange:p}))}var so=a(C()),We=a(U());function ge({val:e,setVal:o,isoforms:n,ranking:r,structureSequence:i,feature:t,disabled:l}){let u=Cr(t),c=new Map(n.map(m=>[m.id(),m])),d=m=>Ir(c.get(m))||m,{matches:s,nonMatches:p,noData:g}=r,S=i?qe(i).length:void 0,x=({id:m,length:T,identical:P},v=P===void 0?"":` (${P}/${S} structure residues identical)`)=>so.default.createElement(We.MenuItem,{value:m,key:m},u," - ",d(m)," (",T,"aa)",v);return so.default.createElement(We.TextField,{value:e??"",onChange:m=>{o(m.target.value)},label:"Choose transcript isoform",select:!0,disabled:l},s.map(m=>x(m," (matches structure residues)")),p.map(m=>x(m)),g.map(m=>so.default.createElement(We.MenuItem,{value:m,key:m,disabled:!0},u," - ",d(m)," (no data)")))}var ce=a(C()),je=a(U()),zr=a(fe());var Ce=a(C()),de=a(U());function Po({recognizedIds:e,geneName:o,selectedId:n,onSelectedIdChange:r}){let[i,t]=(0,Ce.useState)(!1),l=[{value:"auto",label:"Auto (try all)"},...e.map(u=>({value:u,label:sr(u)}))];return o&&l.push({value:`gene:${o}`,label:`${o} (gene name)`}),e.length===0&&!o?null:i?Ce.default.createElement(de.FormControl,{size:"small"},Ce.default.createElement(de.InputLabel,null,"Query UniProt by"),Ce.default.createElement(de.Select,{value:n,label:"Query UniProt by",onChange:u=>{r(u.target.value)}},l.map(u=>Ce.default.createElement(de.MenuItem,{key:u.value,value:u.value},u.label)))):Ce.default.createElement(de.Button,{size:"small",variant:"text",onClick:()=>{t(!0)}},"Choose identifier to query...")}var _=a(C()),W=a(U());var It=["auto","manual","feature"];function Ct(e){return It.some(o=>o===e)}function wo({lookupMode:e,onLookupModeChange:o,manualUniprotId:n,onManualUniprotIdChange:r,manualUniprotIdInvalid:i,featureUniprotId:t,hasSearchableIdentifier:l=!0,endContent:u}){return _.default.createElement(_.default.Fragment,null,_.default.createElement("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap"}},_.default.createElement(W.FormControl,{component:"fieldset"},_.default.createElement(W.RadioGroup,{row:!0,value:e,onChange:c=>{Ct(c.target.value)&&o(c.target.value)}},t&&_.default.createElement(W.FormControlLabel,{value:"feature",control:_.default.createElement(W.Radio,null),label:`From feature (${t})`}),l&&_.default.createElement(W.FormControlLabel,{value:"auto",control:_.default.createElement(W.Radio,null),label:"Look up from the feature's identifiers"}),_.default.createElement(W.FormControlLabel,{value:"manual",control:_.default.createElement(W.Radio,null),label:"Enter manually"}))),u),e==="manual"&&_.default.createElement("div",null,_.default.createElement(W.TextField,{autoFocus:!0,label:"UniProt ID",variant:"outlined",placeholder:"e.g. P68871",size:"small",value:n,error:i,helperText:i?Pr:void 0,onChange:c=>{r(c.target.value)}})),e==="manual"&&!n&&_.default.createElement(W.Typography,{variant:"body2",color:"text.secondary"},"Search"," ",_.default.createElement($,{href:"https://www.uniprot.org/"},"UniProt")," or ",_.default.createElement($,{href:"https://alphafold.ebi.ac.uk/"},"AlphaFoldDB")))}var kt=(0,zr.makeStyles)()({endRow:{display:"flex",flexDirection:"row",gap:12,alignItems:"flex-start"}});function Ke({lookup:e}){let{classes:o}=kt();return ce.default.createElement(ce.default.Fragment,null,ce.default.createElement(wo,{lookupMode:e.lookupMode,onLookupModeChange:e.setLookupMode,manualUniprotId:e.manualUniprotId,onManualUniprotIdChange:e.setManualUniprotId,manualUniprotIdInvalid:e.manualUniprotIdInvalid,featureUniprotId:e.featureUniprotId,hasSearchableIdentifier:e.hasSearchableIdentifier,endContent:e.showIdentifierSelector?ce.default.createElement("div",{className:o.endRow},ce.default.createElement(Po,{recognizedIds:e.recognizedIds,geneName:e.geneName,selectedId:e.selectedQueryId,onSelectedIdChange:e.setSelectedQueryId}),ce.default.createElement(je.TextField,{size:"small",label:"NCBI taxon id",error:e.taxonIdError,helperText:e.taxonIdError?"Not a taxon id; searching every species":"Narrows the gene-name search to one species",value:e.taxonId,onChange:n=>{e.setTaxonId(n.target.value)},placeholder:"e.g. 9606",slotProps:{inputLabel:{shrink:!0}},sx:{width:180}})):null}),e.showIdentifierSelector?ce.default.createElement(je.Typography,{variant:"body2",color:"textSecondary"},e.organismDescription):null,e.nothingToSearch?ce.default.createElement(je.Typography,{variant:"body2",color:"textSecondary"},"This feature carries no Ensembl, RefSeq, CCDS or HGNC identifier and no gene name; enter a UniProt accession"):null,ce.default.createElement(te,{message:e.lookupPartialFailure}))}var me=a(C()),ao=a(U());var w=a(C()),y=a(U());var Hr=a(fe());var vt=(0,Hr.makeStyles)()(e=>({tableContainer:{maxHeight:200},headerCell:{fontWeight:"bold",backgroundColor:e.palette.mode==="dark"?e.palette.grey[900]:e.palette.grey[100]},selectedRow:{backgroundColor:e.palette.action.selected},clickableRow:{cursor:"pointer","&:hover":{backgroundColor:e.palette.action.hover}},reviewedChip:{backgroundColor:e.palette.success.main,color:e.palette.success.contrastText,fontSize:"0.7rem",height:20},unreviewedChip:{backgroundColor:e.palette.warning.main,color:e.palette.warning.contrastText,fontSize:"0.7rem",height:20}}));function xo({entries:e,selectedAccession:o,onSelect:n}){let{classes:r,cx:i}=vt();return e.length===0?null:w.default.createElement("div",null,w.default.createElement(y.Typography,{variant:"body2",sx:{mb:1}},"Found ",e.length," UniProt entries. Select one:"),w.default.createElement(y.TableContainer,{component:y.Paper,className:r.tableContainer},w.default.createElement(y.Table,{size:"small",stickyHeader:!0},w.default.createElement(y.TableHead,null,w.default.createElement(y.TableRow,null,w.default.createElement(y.TableCell,{className:r.headerCell,padding:"checkbox"}),w.default.createElement(y.TableCell,{className:r.headerCell},"Accession"),w.default.createElement(y.TableCell,{className:r.headerCell},"Gene"),w.default.createElement(y.TableCell,{className:r.headerCell},"Organism"),w.default.createElement(y.TableCell,{className:r.headerCell},"Protein"),w.default.createElement(y.TableCell,{className:r.headerCell},"Status"))),w.default.createElement(y.TableBody,null,e.map(t=>w.default.createElement(y.TableRow,{key:t.accession,onClick:()=>{n(t.accession)},className:i(r.clickableRow,o===t.accession&&r.selectedRow)},w.default.createElement(y.TableCell,{padding:"checkbox"},w.default.createElement(y.Radio,{checked:o===t.accession,size:"small"})),w.default.createElement(y.TableCell,null,w.default.createElement($,{href:Ne(t.accession)},t.accession)),w.default.createElement(y.TableCell,null,t.geneName??"-"),w.default.createElement(y.TableCell,null,t.organismName??"-"),w.default.createElement(y.TableCell,null,t.proteinName?t.proteinName.length>40?`${t.proteinName.slice(0,40)}...`:t.proteinName:"-"),w.default.createElement(y.TableCell,null,w.default.createElement(y.Chip,{label:t.isReviewed?"Reviewed":"Unreviewed",size:"small",className:t.isReviewed?r.reviewedChip:r.unreviewedChip}))))))))}function Gr(){return me.default.createElement($,{href:"https://www.uniprot.org/"},"UniProt")}function Qe({lookup:e}){let o=e.uniprotEntries.length>0;return e.isAutoMode?o?me.default.createElement(me.default.Fragment,null,me.default.createElement(ao.Typography,{variant:"body2",color:"textSecondary"},"Searched UniProt by ",e.searchDescription),me.default.createElement(xo,{entries:e.uniprotEntries,selectedAccession:e.selectedTableAccession,onSelect:e.setSelectedUniprotId}),me.default.createElement(ao.Typography,{variant:"body2",color:"textSecondary"},"If you don't see the entry you're looking for, try a different identifier above or search ",me.default.createElement(Gr,null),' directly and use "Enter manually".')):e.isLookupLoading||e.lookupError?null:me.default.createElement(ao.Typography,{variant:"body2",color:"textSecondary"},"No UniProt entries found for ",e.searchDescriptionOr,". Try a different identifier above, or search ",me.default.createElement(Gr,null),' directly and use "Enter manually".'):null}var Kr=a(C());var Wr=a(C());var $r=a(eo());function Xe({feature:e,view:o}){let{data:n,error:r,isLoading:i}=X(["isoform-sequences",e.id(),o?.assemblyNames?.[0]],async()=>{let l=ro(e),u=await hr({transcripts:l,session:(0,$r.getSession)(o),assemblyName:o?.assemblyNames?.[0]});for(let{feature:d,error:s}of u)s!==void 0&&console.error("[useIsoformProteinSequences] error for",d.id(),s);let c=u.flatMap(d=>d.seq===void 0?[]:[[d.feature.id(),{feature:d.feature,seq:d.seq}]]);return{sequences:Object.fromEntries(c),translated:c.length,total:u.length}},{...Y,keepPreviousData:!0}),t=n?n.total-n.translated:0;return{isLoading:i,isoformSequences:n?.sequences,error:r,partialFailure:t>0&&n?`${t} of ${n.total} transcripts have no protein sequence`:void 0}}function Fo({uniprotId:e,feature:o,view:n}){let{data:r,isLoading:i,isValidating:t,error:l}=X(e?["alphafold-models",e]:null,([,s])=>Ro(s),{...Y,keepPreviousData:!0}),{isoformSequences:u}=Xe({feature:o,view:n}),c=(0,Wr.useMemo)(()=>e&&(r||l)?wr(e,l?void 0:r,u):void 0,[e,r,l,u]);return{isLoading:i,isValidating:t,modelsUnreachable:e?l:void 0,model:c,noModel:!!e&&!i&&!l&&r?.length===0}}var jr=a(eo());function Uo({view:e,isoforms:o,structureSequences:n}){let r=!!e&&!!n?.length&&o.some(l=>l.seq),{data:i,error:t}=X(r?["isoform-ranking",o,n]:null,()=>gr({rpcManager:(0,jr.getSession)(e).rpcManager,name:"ProteinRankIsoforms",args:{isoforms:o,structureSequences:n??[]},inPlace:()=>To(o,n)}),Y);return r?{ranking:i,error:t}:{ranking:To(o,n)}}var Do=a(C());function Lt({options:e,isoformSequences:o,ranking:n,preferredTranscriptId:r}){return to(e,o).some(i=>i.id===r&&i.seq)?r:n&&br(n,yr(e))}function qo({options:e,isoformSequences:o,ranking:n,preferredTranscriptId:r,resetKey:i}){let[t,l]=(0,Do.useState)(),[u,c]=(0,Do.useState)(i);i!==u&&(c(i),l(void 0));let d=o!==void 0?Lt({options:e,isoformSequences:o,ranking:n,preferredTranscriptId:r}):void 0;return{userSelection:t??d,setUserSelection:l}}function he({feature:e,view:o,structureSequences:n,preferredTranscriptId:r,resetKey:i}){let t=ro(e),{isoformSequences:l,isLoading:u,error:c,partialFailure:d}=Xe({feature:e,view:o}),{ranking:s,error:p}=Uo({view:o,isoforms:to(t,l),structureSequences:n}),{userSelection:g,setUserSelection:S}=qo({options:t,isoformSequences:l,ranking:s?.ranking,preferredTranscriptId:r,resetKey:i}),x=t.find(T=>T.id()===g),m=g?l?.[g]:void 0;return{transcripts:t,isoformSequences:l,structureSequence:s?.structureSequence,ranking:s?.ranking,isLoading:u,isRanking:!!l&&!s&&!p&&!g,error:c??p,partialFailure:d,selectedTranscriptId:g,setSelectedTranscriptId:S,selectedTranscript:x,selectedIsoform:m}}function No({feature:e,view:o,lookup:n,preferredTranscriptId:r}){let{uniprotId:i,isLookupLoading:t}=n,{isLoading:l,isValidating:u,modelsUnreachable:c,model:d,noModel:s}=Fo({uniprotId:i,feature:e,view:o}),p=d?.sequence,g=(0,Kr.useMemo)(()=>p?[p]:void 0,[p]),{transcripts:S,isoformSequences:x,structureSequence:m,ranking:T,isLoading:P,isRanking:v,error:N,partialFailure:I,selectedTranscriptId:D,setSelectedTranscriptId:E,selectedTranscript:A,selectedIsoform:M}=he({feature:e,view:o,structureSequences:g,preferredTranscriptId:r,resetKey:d?.url}),H=[t&&"Looking up UniProt ID",P&&"Loading protein sequences from transcript isoforms",v&&"Aligning isoforms to the structure",l&&"Asking AlphaFold DB for models"].filter(Z=>typeof Z=="string"),G=H.length>0,J=N??n.lookupError,Q=G?void 0:J;return{...n,userSelection:D,setUserSelection:E,transcriptOptions:S,selectedTranscript:A,isoformSequences:x,ranking:T,isoformPartialFailure:I,userSelectedProteinSequence:M,url:d?.url,confidenceUrl:d?.confidenceUrl,modelAccession:d?.accession,structureSequence:m,noModel:s,modelsUnreachable:G?void 0:c,error:Q,loadingStatuses:H,sequencesMatch:!u&&M?.seq&&m?qe(M.seq)===m:void 0,isLoading:G}}var Pt=(0,Xr.makeStyles)()({dialogContent:{width:"80em","& > *":{marginBottom:20},"& > *:last-child":{marginBottom:0}},selectorsRow:{display:"flex",flexDirection:"row",gap:20,alignItems:"flex-start"}}),wt=(0,Qr.observer)(function({feature:o,preferredTranscriptId:n,session:r,view:i,handleClose:t,lookup:l,sideBySide:u,onSideBySideChange:c}){let{classes:d}=Pt(),s=No({feature:o,view:i,lookup:l,preferredTranscriptId:n});return V.default.createElement(V.default.Fragment,null,V.default.createElement(xe.DialogContent,{className:d.dialogContent},s.error?V.default.createElement(lo.ErrorMessage,{error:s.error}):null,s.noModel?V.default.createElement(xe.Typography,null,"AlphaFold DB has no model for ",s.uniprotId,". The PDB and Foldseek tabs may have a structure."):null,s.modelsUnreachable?V.default.createElement(xe.Typography,null,"AlphaFold DB's model list did not answer, so Launch opens the canonical model file for ",s.uniprotId,", without comparing its sequence to the isoforms."):null,V.default.createElement(Ke,{lookup:l}),s.loadingStatuses.map(p=>V.default.createElement(lo.LoadingEllipses,{key:p,variant:"subtitle2",message:p})),V.default.createElement(te,{message:s.isoformPartialFailure}),V.default.createElement(Qe,{lookup:l}),s.ranking&&s.selectedTranscript&&(s.structureSequence||s.modelsUnreachable)&&s.uniprotId?V.default.createElement(V.default.Fragment,null,V.default.createElement("div",{className:d.selectorsRow},V.default.createElement(ge,{val:s.userSelection,setVal:s.setUserSelection,structureSequence:s.structureSequence,feature:o,isoforms:s.transcriptOptions,ranking:s.ranking})),V.default.createElement(ko,{uniprotId:s.modelAccession??s.uniprotId,url:s.url})):null),V.default.createElement(xe.DialogActions,null,V.default.createElement($e,{handleClose:t,uniprotId:s.modelAccession??s.uniprotId,userSelectedProteinSequence:s.userSelectedProteinSequence,selectedTranscript:s.selectedTranscript,url:s.url,confidenceUrl:s.confidenceUrl,feature:o,view:i,session:r,sideBySide:u,onSideBySideChange:c,sequencesMatch:s.sequencesMatch,isLoading:s.isLoading,error:s.error})))}),Yr=wt;var L=a(C()),Ye=a(we()),j=a(U()),et=a(Re());var ot=a(fe());var pe=a(C()),ne=a(U());var Jr=a(fe()),xt=(0,Jr.makeStyles)()({root:{display:"flex",flexDirection:"column",gap:8},header:{display:"flex",alignItems:"center",gap:8},buttons:{display:"flex",gap:4},checkboxGroup:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:0}});function Eo({selected:e,onChange:o,disabled:n}){let{classes:r}=xt();return pe.default.createElement("div",{className:r.root},pe.default.createElement("div",{className:r.header},pe.default.createElement(ne.Typography,{variant:"subtitle2"},"Databases to search:"),pe.default.createElement("div",{className:r.buttons},pe.default.createElement(ne.Button,{size:"small",onClick:()=>{o(yo.map(i=>i.id))},disabled:n},"Select all"),pe.default.createElement(ne.Button,{size:"small",onClick:()=>{o([])},disabled:n},"Clear"))),pe.default.createElement(ne.FormGroup,{className:r.checkboxGroup},yo.map(i=>pe.default.createElement(ne.FormControlLabel,{key:i.id,control:pe.default.createElement(ne.Checkbox,{size:"small",checked:e.includes(i.id),onChange:()=>{e.includes(i.id)?o(e.filter(t=>t!==i.id)):o([...e,i.id])},disabled:n}),label:i.label}))))}var h=a(C()),f=a(U());var Rr=a(fe());var ie=a(C()),Zr=a(we()),Fe=a(U());function Ao({hit:e,session:o,view:n,feature:r,selectedTranscript:i,userProvidedTranscriptSequence:t,onClose:l}){let[u,c]=(0,ie.useState)(null),d=!!u,s=rr(e.target),p=I=>{c(I.currentTarget)},g=()=>{c(null)},{runLaunch:S,launchError:x,launching:m}=Be(l,g),T={session:o,view:n,feature:r,selectedTranscript:i,uniprotId:s},P=S(()=>{let I=!e.structureUrl&&So(e)?lr(e.tCa,e.tSeq,"A",e.target):void 0;return Ee({...T,url:e.structureUrl,data:I,userProvidedTranscriptSequence:t})}),{launch1D:v}=no({...T,confidenceUrl:nr(e.target)});return!!e.structureUrl||So(e)?ie.default.createElement(ie.default.Fragment,null,x?ie.default.createElement(Zr.ErrorMessage,{error:x}):null,ie.default.createElement(Fe.Button,{size:"small",variant:"outlined",disabled:m,onClick:p},"Load"),ie.default.createElement(Fe.Menu,{anchorEl:u,open:d,onClose:g},ie.default.createElement(Fe.MenuItem,{"data-testid":"protein-launch-option-3d",onClick:P},Ae["3d"]),v?ie.default.createElement(Fe.MenuItem,{"data-testid":"protein-launch-option-1d",onClick:S(v)},Ae["1d"]):null)):ie.default.createElement("span",null,"-")}var Ft=(0,Rr.makeStyles)()(e=>({root:{display:"flex",flexDirection:"column",gap:16},tableContainer:{maxHeight:400},headerCell:{fontWeight:"bold",backgroundColor:e.palette.mode==="dark"?e.palette.grey[900]:e.palette.grey[100]},noResults:{padding:16,textAlign:"center"}})),Ut=100;function Dt(e){let o=e.results.flatMap(n=>(n.alignments??[]).flat().map(r=>({...r,db:n.db,structureUrl:tr(r.target,n.db)})));return o.sort((n,r)=>(n.eval??1/0)-(r.eval??1/0)),o}function Mo({results:e,session:o,view:n,feature:r,selectedTranscript:i,userProvidedTranscriptSequence:t,onClose:l}){let{classes:u}=Ft(),c=Dt(e),d=c.slice(0,Ut);return d.length===0?h.default.createElement(f.Paper,{className:u.noResults},h.default.createElement(f.Typography,null,"No similar structures found")):h.default.createElement("div",{className:u.root},h.default.createElement(f.Typography,{variant:"subtitle2"},"Found ",c.length," similar structures",c.length>d.length?` (showing top ${d.length})`:""),h.default.createElement(f.TableContainer,{component:f.Paper,className:u.tableContainer},h.default.createElement(f.Table,{size:"small",stickyHeader:!0},h.default.createElement(f.TableHead,null,h.default.createElement(f.TableRow,null,h.default.createElement(f.TableCell,{className:u.headerCell},"Database"),h.default.createElement(f.TableCell,{className:u.headerCell},"Target"),h.default.createElement(f.TableCell,{className:u.headerCell},"Organism"),h.default.createElement(f.TableCell,{className:u.headerCell},h.default.createElement(f.Tooltip,{title:"Foldseek's estimated probability that the hit is a true structural homolog"},h.default.createElement("span",null,"Prob"))),h.default.createElement(f.TableCell,{className:u.headerCell},h.default.createElement(f.Tooltip,{title:"Percentage of aligned residues whose amino acid is identical; structural hits are often low here"},h.default.createElement("span",null,"Seq. Id."))),h.default.createElement(f.TableCell,{className:u.headerCell},"Coverage"),h.default.createElement(f.TableCell,{className:u.headerCell},h.default.createElement(f.Tooltip,{title:"Hits of this score expected by chance in a database this size; smaller is stronger"},h.default.createElement("span",null,"E-value"))),h.default.createElement(f.TableCell,{className:u.headerCell},"Actions"))),h.default.createElement(f.TableBody,null,d.map((s,p)=>h.default.createElement(f.TableRow,{key:`${s.db}-${s.target}-${p}`},h.default.createElement(f.TableCell,null,s.db),h.default.createElement(f.TableCell,null,s.target),h.default.createElement(f.TableCell,null,s.taxName??"-"),h.default.createElement(f.TableCell,null,s.prob!=null?`${(s.prob*100).toFixed(1)}%`:"-"),h.default.createElement(f.TableCell,null,s.seqId!=null?`${s.seqId.toFixed(1)}%`:"-"),h.default.createElement(f.TableCell,null,s.alnLength!=null&&s.qLen!=null?`${(s.alnLength/s.qLen*100).toFixed(1)}%`:"-"),h.default.createElement(f.TableCell,null,s.eval!=null?s.eval.toExponential(2):"-"),h.default.createElement(f.TableCell,null,h.default.createElement(Ao,{hit:s,session:o,view:n,feature:r,selectedTranscript:i,userProvidedTranscriptSequence:t,onClose:l}))))))))}var se=a(C());function Bo(){let[e,o]=(0,se.useState)(),[n,r]=(0,se.useState)(),[i,t]=(0,se.useState)(!1),[l,u]=(0,se.useState)(!1),[c,d]=(0,se.useState)(),[s,p]=(0,se.useState)(""),g=(0,se.useRef)(null);(0,se.useEffect)(()=>()=>{g.current?.abort()},[]);let S=()=>{g.current?.abort();let v=new AbortController;return g.current=v,v.signal},x=async v=>{let N=S();u(!0),d(void 0),p("Predicting 3Di structure...");try{let I=await mr(v,{signal:N});return r(I),I}catch(I){N.aborted||(console.error(I),d(I));return}finally{N.aborted||(u(!1),p(""))}},m=async(v,N,I)=>{let D=S();t(!0),d(void 0),p("Submitting search...");try{let E=await pr({aaSequence:v,di3Sequence:N,databases:I},{signal:D}),A=await fr(E.id,{onStatus:p,signal:D});return o(A),A}catch(E){D.aborted||(console.error(E),d(E));return}finally{D.aborted||(t(!1),p(""))}},T=()=>{g.current?.abort(),g.current=null,t(!1),u(!1),p("")},P=()=>{T(),o(void 0),r(void 0),d(void 0)};return{results:e,cleanedAaSequence:n?.aaSequence,di3Sequence:n?.di3Sequence,isLoading:i,isPredicting:l,error:c,statusMessage:s,predictStructure:x,search:m,cancel:T,reset:P}}var qt=(0,ot.makeStyles)()({dialogContent:{width:"80em",display:"flex",flexDirection:"column",gap:20},sequenceInput:{fontFamily:"monospace"},di3Section:{display:"flex",flexDirection:"column",gap:8,alignItems:"flex-start"}}),Nt=(0,et.observer)(function({feature:o,preferredTranscriptId:n,session:r,view:i,handleClose:t}){let{classes:l}=qt(),[u,c]=(0,L.useState)(),[d,s]=(0,L.useState)(ur),[p,g]=(0,L.useState)(!1),{results:S,cleanedAaSequence:x,di3Sequence:m,isLoading:T,isPredicting:P,error:v,statusMessage:N,predictStructure:I,search:D,cancel:E,reset:A}=Bo(),{transcripts:M,isoformSequences:H,ranking:G,isLoading:J,error:Q,partialFailure:Z,selectedTranscriptId:ae,setSelectedTranscriptId:be,selectedTranscript:Se,selectedIsoform:re}=he({feature:o,view:i,preferredTranscriptId:n}),Le=re?Yo(re.seq):"",ee=u??Le,Pe=()=>{(m!==void 0||S!==void 0)&&A()},ze=ue=>{be(ue),c(void 0),Pe()},le=T||P,He=cr(ee),Wo=dr(ee).length>0&&!He&&d.length>0&&!le,Ze=async()=>{let ue=x&&m?{aaSequence:x,di3Sequence:m}:await I(ee.trim());ue&&await D(ue.aaSequence,ue.di3Sequence,d)},fo=v??Q;return L.default.createElement(L.default.Fragment,null,L.default.createElement(j.DialogContent,{className:l.dialogContent},fo&&!J?L.default.createElement(Ye.ErrorMessage,{error:fo}):null,J?L.default.createElement(Ye.LoadingEllipses,{variant:"subtitle2",message:"Loading transcript sequences"}):null,L.default.createElement(te,{message:Z}),H&&G?L.default.createElement(L.default.Fragment,null,L.default.createElement(ge,{val:ae,setVal:ze,isoforms:M,ranking:G,feature:o,disabled:le}),L.default.createElement(j.TextField,{label:"Protein sequence (amino acids)",multiline:!0,rows:4,value:ee,onChange:ue=>{c(ue.target.value),Pe()},placeholder:"MKTVRQERLKSIVRILERSKEPVSGAQLAEEL...",disabled:le,error:!!He,helperText:He,slotProps:{input:{className:l.sequenceInput}}})):null,m?L.default.createElement("div",{className:l.di3Section},L.default.createElement(j.Link,{component:"button",type:"button",variant:"body2",onClick:()=>{g(!p)}},p?"Hide 3Di":"Show 3Di"),p?L.default.createElement(j.TextField,{label:"3Di structural alphabet (what the search runs on)",multiline:!0,rows:4,fullWidth:!0,value:m,slotProps:{input:{className:l.sequenceInput,readOnly:!0}}}):null):null,L.default.createElement(Eo,{selected:d,onChange:s,disabled:le}),N?L.default.createElement(Ye.LoadingEllipses,{variant:"subtitle2",message:N}):null,S?L.default.createElement(Mo,{results:S,session:r,view:i,feature:o,selectedTranscript:Se,userProvidedTranscriptSequence:re?.seq,onClose:t}):null,L.default.createElement(j.Typography,{variant:"body2",color:"textSecondary"},"Searching sends the protein sequence above to the foldseek.com servers, which predict its 3Di alphabet and run the structure search.")),L.default.createElement(j.DialogActions,null,L.default.createElement(j.Button,{variant:"contained",color:"secondary",onClick:()=>{t()}},"Close"),le?L.default.createElement(j.Button,{variant:"outlined",onClick:()=>{E()}},"Cancel search"):null,S?L.default.createElement(j.Button,{variant:"outlined",onClick:()=>{A()}},"New search"):null,L.default.createElement(j.Button,{variant:"contained",color:"primary",disabled:!Wo,onClick:()=>{Ze()}},P?"Predicting 3Di...":T?"Searching...":"Search Foldseek")))}),rt=Nt;var R=a(C());var tt=a(U()),Et=(0,R.lazy)(()=>import("./HelpDialog-XVM5IEP4.js"));function Je(){let[e,o]=(0,R.useState)(!1);return R.default.createElement(R.default.Fragment,null,R.default.createElement(tt.IconButton,{onClick:()=>{o(!0)}},R.default.createElement(xr,null)),e?R.default.createElement(R.Suspense,{fallback:null},R.default.createElement(Et,{handleClose:()=>{o(!1)}})):null)}var B=a(C()),co=a(we()),ve=a(U()),st=a(Re());var at=a(fe());var k=a(C()),b=a(U());var it=a(fe());var At=(0,it.makeStyles)()(e=>({tableContainer:{maxHeight:300},headerCell:{fontWeight:"bold",backgroundColor:e.palette.mode==="dark"?e.palette.grey[900]:e.palette.grey[100]},selectedRow:{backgroundColor:e.palette.action.selected},clickableRow:{cursor:"pointer","&:hover":{backgroundColor:e.palette.action.hover}}})),nt=100;function Vo({entries:e,selectedPdbId:o,onSelect:n}){let{classes:r}=At(),i=e.slice(0,nt);return k.default.createElement(k.default.Fragment,null,k.default.createElement(b.Typography,{variant:"body2",color:"textSecondary"},e.length," PDB entries, ranked on coverage, then resolution",e.length>i.length?` (showing the first ${nt})`:""),k.default.createElement(b.TableContainer,{component:b.Paper,className:r.tableContainer},k.default.createElement(b.Table,{size:"small",stickyHeader:!0,"data-testid":"pdb-results-table"},k.default.createElement(b.TableHead,null,k.default.createElement(b.TableRow,null,k.default.createElement(b.TableCell,{className:r.headerCell,padding:"checkbox"}),k.default.createElement(b.TableCell,{className:r.headerCell},"PDB ID"),k.default.createElement(b.TableCell,{className:r.headerCell},"Method"),k.default.createElement(b.TableCell,{className:r.headerCell},"Resolution"),k.default.createElement(b.TableCell,{className:r.headerCell},k.default.createElement(b.Tooltip,{title:"The span of the UniProt sequence this entry resolves, by RCSB's UniProt alignment. A crystal is usually one domain rather than the whole protein."},k.default.createElement("span",null,"UniProt residues"))),k.default.createElement(b.TableCell,{className:r.headerCell},"Coverage"),k.default.createElement(b.TableCell,{className:r.headerCell},"Chains"))),k.default.createElement(b.TableBody,null,i.map(t=>{let l=t.pdbId===o;return k.default.createElement(b.TableRow,{key:t.pdbId,className:`${r.clickableRow} ${l?r.selectedRow:""}`,onClick:()=>{n(t.pdbId)}},k.default.createElement(b.TableCell,{padding:"checkbox"},k.default.createElement(b.Radio,{checked:l,size:"small"})),k.default.createElement(b.TableCell,null,k.default.createElement($,{href:or(t.pdbId)},t.pdbId.toUpperCase())),k.default.createElement(b.TableCell,null,t.method),k.default.createElement(b.TableCell,null,t.resolution===void 0?"-":`${t.resolution.toFixed(2)} \xC5`),k.default.createElement(b.TableCell,null,t.start,"-",t.end),k.default.createElement(b.TableCell,null,(t.coverage*100).toFixed(0),"%"),k.default.createElement(b.TableCell,null,t.chains.join(", ")))})))))}var uo=a(C());function ke(e,o=300){let[n,r]=(0,uo.useState)(e);return(0,uo.useEffect)(()=>{let i=setTimeout(()=>{r(e)},o);return()=>{clearTimeout(i)}},[e,o]),n}function Oo(e){let{data:o,error:n,isLoading:r}=X(e?["experimental-structures",e]:null,([,i])=>ir(i),Y);return{entries:o,error:n,isLoading:r}}function _o(e){let{data:o,error:n,isLoading:r,isValidating:i}=X(e?["pdb-entry",e]:null,([,t])=>Zo(t),Y);return{entry:o,error:n,isLoading:r,isValidating:i}}var Mt=(0,at.makeStyles)()({dialogContent:{width:"80em","& > *":{marginBottom:20},"& > *:last-child":{marginBottom:0}}}),Bt=(0,st.observer)(function({feature:o,preferredTranscriptId:n,session:r,view:i,handleClose:t,lookup:l,sideBySide:u,onSideBySideChange:c}){let{classes:d}=Mt(),{uniprotId:s,isLookupLoading:p,lookupError:g}=l,{entries:S,error:x,isLoading:m}=Oo(s),[T,P]=(0,B.useState)(),[v,N]=(0,B.useState)(""),I=v.trim(),D=ke(I,400),E=I!==""&&!oo(I),A=oo(D)?D.toLowerCase():T&&S?.some(ye=>ye.pdbId===T)?T:S?.[0]?.pdbId,M=A?er(A):void 0,{entry:H,error:G,isValidating:J}=_o(A),Q=H?.proteinSequences,{transcripts:Z,structureSequence:ae,ranking:be,isLoading:Se,isRanking:re,error:Le,partialFailure:ee,selectedTranscriptId:Pe,setSelectedTranscriptId:ze,selectedTranscript:le,selectedIsoform:He}=he({feature:o,view:i,structureSequences:Q,preferredTranscriptId:n,resetKey:s}),Ze=[Se&&"Loading protein sequences from transcript isoforms",re&&"Aligning isoforms to the structure",J&&!G&&Pe!==n&&"Reading the chains of the entry from RCSB",I!==D&&"Reading the typed PDB ID"],ue=[...[p&&"Looking up UniProt ID",m&&"Listing PDB entries from RCSB"],...Ze].filter(ye=>!!ye),jo=ue.length>0,go=jo?void 0:Le??g??x,ho=oo(D),Ko=E||(ho?Ze.some(Boolean):jo),bt=ho?Ko?void 0:Le:go,St=ho&&(p||g)?void 0:s;return B.default.createElement(B.default.Fragment,null,B.default.createElement(ve.DialogContent,{className:d.dialogContent},go?B.default.createElement(co.ErrorMessage,{error:go}):null,B.default.createElement(Ke,{lookup:l}),ue.map(ye=>B.default.createElement(co.LoadingEllipses,{key:ye,variant:"subtitle2",message:ye})),B.default.createElement(te,{message:ee}),B.default.createElement(Qe,{lookup:l}),B.default.createElement(ve.TextField,{size:"small",label:"PDB ID",placeholder:"e.g. 1TUP",helperText:E?"A PDB ID is four characters beginning with a digit":"Overrides the selection below",error:E,value:v,onChange:ye=>{N(ye.target.value)},slotProps:{inputLabel:{shrink:!0}},sx:{width:240}}),s&&S&&!m?S.length>0?B.default.createElement(Vo,{entries:S,selectedPdbId:A,onSelect:P}):B.default.createElement(ve.Typography,null,"RCSB lists no experimental structure for"," ",B.default.createElement($,{href:Ne(s)},s),". The AlphaFoldDB tab has a predicted one."):null,be&&le?B.default.createElement(ge,{val:Pe,setVal:ze,structureSequence:ae,feature:o,isoforms:Z,ranking:be}):null),B.default.createElement(ve.DialogActions,null,B.default.createElement($e,{handleClose:t,uniprotId:St,userSelectedProteinSequence:He,selectedTranscript:le,url:M,pdbId:A,feature:o,view:i,session:r,sideBySide:u,onSideBySideChange:c,isLoading:Ko,error:bt})))}),lt=Bt;var mo=a(C());function Ve({children:e,value:o,index:n,...r}){let i=o===n,[t,l]=(0,mo.useState)(i);return i&&!t&&l(!0),mo.default.createElement("div",{role:"tabpanel",hidden:!i,...r},t?e:null)}var F=a(C()),Oe=a(we()),Ue=a(U()),dt=a(Re());var ct=a(fe());var z=a(C()),O=a(U());function zo({choice:e,setChoice:o,structureURL:n,setStructureURL:r,setFile:i}){return z.default.createElement("div",{style:{display:"flex",margin:30}},z.default.createElement(O.Typography,null,"Open your structure file ",z.default.createElement(Je,null)),z.default.createElement(O.FormControl,{component:"fieldset"},z.default.createElement(O.RadioGroup,{value:e,onChange:t=>{o(t.target.value)}},z.default.createElement(O.FormControlLabel,{value:"url",control:z.default.createElement(O.Radio,null),label:"URL"}),z.default.createElement(O.FormControlLabel,{value:"file",control:z.default.createElement(O.Radio,null),label:"File"}))),e==="url"?z.default.createElement("div",null,z.default.createElement(O.Typography,null,"Open a PDB/mmCIF/etc. file from remote URL"),z.default.createElement(O.TextField,{label:"URL",value:n,onChange:t=>{r(t.target.value)}})):z.default.createElement("div",{style:{paddingTop:20}},z.default.createElement(O.Typography,null,"Open a PDB/mmCIF/etc. file from your local drive"),z.default.createElement(O.Button,{variant:"outlined",component:"label"},"Choose file",z.default.createElement("input",{type:"file",hidden:!0,accept:Fr,onChange:({target:t})=>{let l=t.files?.[0];l&&i(l)}}))))}async function ut(e){let{PluginContext:o,DefaultPluginSpec:n}=await Ur(),r=new o(n());await r.init();try{return await e(r)}finally{r.dispose()}}async function Vt({file:e,url:o}){let n=e?await io(e):void 0;return ut(async r=>{let i=await Dr({plugin:r,data:n,url:o}),t=await r.builders.structure.createModel(i);return Jo(t)})}function Ho({file:e,url:o}){let n=e?["structure-file",e.name,e.size,e.lastModified]:o?["structure-url",o]:null,{data:r,error:i,isLoading:t}=X(n,async()=>{let l=await Vt({file:e,url:o});if(!l?.length)throw new Error("No protein sequence found in this structure");return l},Y);return{error:i,isLoading:t,sequences:r}}var Ot=(0,ct.makeStyles)()(e=>({dialogContent:{marginTop:e.spacing(6),width:"80em"}}));function _t(){return F.default.createElement("div",{style:{marginBottom:20}},"Manually supply a protein structure (PDB, mmCIF, etc) for a given transcript. You can open the file from the result of running, for example,"," ",F.default.createElement($,{href:"https://github.com/sokrypton/ColabFold"},"ColabFold"),". This plugin will align the protein sequence calculated from the genome to the protein sequence embedded in the structure file which allows for slight differences in these two representations.")}var zt=(0,dt.observer)(function({feature:o,preferredTranscriptId:n,session:r,view:i,handleClose:t}){let{classes:l}=Ot(),[u,c]=(0,F.useState)(),[d,s]=(0,F.useState)("file"),[p,g]=(0,F.useState)(""),{runLaunch:S,launchError:x,launching:m}=Be(t),T=d==="file"?u:void 0,P=d==="file"?"":p,v=ke(P,600),{sequences:N,isLoading:I,error:D}=Ho({file:T,url:v}),{transcripts:E,isoformSequences:A,structureSequence:M,ranking:H,isRanking:G,selectedTranscriptId:J,setSelectedTranscriptId:Q,selectedTranscript:Z,selectedIsoform:ae,error:be,partialFailure:Se}=he({feature:o,view:i,structureSequences:N,preferredTranscriptId:n}),re=be??D??x,ee=!!(P||T)&&!!ae&&!!Z&&!((I||P!==v||G)&&J!==n)&&!m,Pe=!!ae?.seq&&!!M&&qe(ae.seq)!==M,ze=S(async()=>{if(ae&&Z){let le=T?await io(T):void 0;await Ee({session:r,view:i,feature:o,selectedTranscript:Z,url:P||void 0,data:le,userProvidedTranscriptSequence:ae.seq})}});return F.default.createElement(F.default.Fragment,null,F.default.createElement(Ue.DialogContent,{className:l.dialogContent},re?F.default.createElement(Oe.ErrorMessage,{error:re}):null,F.default.createElement(_t,null),F.default.createElement(zo,{choice:d,setChoice:s,structureURL:p,setStructureURL:g,setFile:c}),F.default.createElement("div",{style:{margin:20}},I?F.default.createElement(Oe.LoadingEllipses,{variant:"subtitle2",message:"Reading residues from the structure"}):null,F.default.createElement(te,{message:Se}),G?F.default.createElement(Oe.LoadingEllipses,{variant:"subtitle2",message:"Aligning isoforms to the structure"}):null,A?M&&H?F.default.createElement(ge,{val:J,setVal:Q,structureSequence:M,isoforms:E,feature:o,ranking:H}):null:F.default.createElement(Oe.LoadingEllipses,{title:"Loading protein sequences",variant:"h6"}))),F.default.createElement(Ue.DialogActions,null,Pe?F.default.createElement(Ge,null):null,F.default.createElement(Ue.Button,{variant:"contained",color:"secondary",onClick:()=>{t()}},"Cancel"),F.default.createElement(Ue.Button,{variant:"contained",color:"primary",disabled:!ee,onClick:()=>{ze()}},"Launch 3D protein structure view")))}),mt=zt;var _e=a(C()),pt=a(yt()),ft=a(eo());function Ht({attemptedCount:e,failedCount:o}){return o>0&&o<e?`UniProt lookup failed for ${o} of ${e} identifiers`:void 0}function Go({recognizedIds:e=[],geneId:o,geneName:n,organismId:r,selectedQueryId:i="auto",enabled:t=!0}){let l=[],u;i==="auto"?(l=e,u=n):i.startsWith("gene:")?u=i.replace("gene:",""):bo(i)&&(l=[i]);let c=l.some(g=>bo(g))||!!u,{data:d,error:s,isLoading:p}=X(t&&c?["uniprotSearch",i,l.join(","),u,o,r]:null,async()=>ar({recognizedIds:l,geneId:o,geneName:u,organismId:r}),{...Y,keepPreviousData:!0});return{entries:d?.entries??[],isLoading:p,error:s,partialFailure:d?Ht(d):void 0}}function po({selectedQueryId:e,recognizedIds:o,geneName:n,joinWord:r="and"}){return e==="auto"?[o.length>0?`database ID${o.length>1?"s":""} "${o.join('", "')}"`:void 0,n?`gene name "${n}"`:void 0].filter(Boolean).join(` ${r} `):e.startsWith("gene:")?`gene name "${e.replace("gene:","")}"`:`database ID "${e}"`}function Gt(e,o){return e===void 0?"Organism: unknown, showing all species; type an NCBI taxon id to narrow":`Organism: ${e} (${o==="user"?"typed above":"from assembly"})`}function $o({feature:e,view:o,preferredTranscriptId:n}){let r=kr(e,n),i=r.uniprotId,t=r.recognizedIds.length>0||!!r.geneName,[l,u]=(0,_e.useState)(()=>i?"feature":t?"auto":"manual"),[c,d]=(0,_e.useState)(""),[s,p]=(0,_e.useState)(""),g=o.assemblyNames[0],S=g?(0,ft.getSession)(o).assemblyManager.get(g):void 0,x=S?Tr((0,pt.getConf)(S,["sequence","metadata"])):void 0,m=ke(s.trim(),400),T=Number(m),P=m!==""&&Number.isFinite(T)&&T>0,v=P?T:x,N=m!==""&&!P,[I,D]=(0,_e.useState)("auto"),[E,A]=(0,_e.useState)(),M=l==="auto",{entries:H,isLoading:G,error:J,partialFailure:Q}=Go({recognizedIds:r.recognizedIds,geneId:r.geneId,geneName:r.geneName,organismId:v,selectedQueryId:I,enabled:M}),Z=ke(c,400),be=G||l==="manual"&&c!==Z,Se=H.some(ee=>ee.accession===E)?E:void 0,re=H[0]?.accession,Le=l==="feature"?i:M?Se??re:Io(Z)?Z:void 0;return{lookupMode:l,setLookupMode:u,manualUniprotId:c,setManualUniprotId:ee=>{d(ee.trim().toUpperCase())},manualUniprotIdInvalid:c!==""&&!Io(c),taxonId:s,setTaxonId:p,taxonIdError:N,organismDescription:Gt(v,P?"user":"assembly"),selectedQueryId:I,setSelectedQueryId:D,setSelectedUniprotId:A,selectedTableAccession:Se??re,uniprotEntries:H,isLookupLoading:be,lookupError:J,lookupPartialFailure:Q,uniprotId:Le,featureUniprotId:i,recognizedIds:r.recognizedIds,geneName:r.geneName,isAutoMode:M,hasSearchableIdentifier:t,nothingToSearch:!t&&!i,showIdentifierSelector:M&&t,searchDescription:po({selectedQueryId:I,recognizedIds:r.recognizedIds,geneName:r.geneName}),searchDescriptionOr:po({selectedQueryId:I,recognizedIds:r.recognizedIds,geneName:r.geneName,joinWord:"or"})}}function $t({handleClose:e,feature:o,preferredTranscriptId:n,model:r,view:i}){let[t,l]=(0,q.useState)(0),u=(0,ht.getSession)(r),c=$o({feature:o,view:i,preferredTranscriptId:n}),[d,s]=(0,q.useState)(()=>vr()),p=g=>{s(g),Lr(g)};return q.default.createElement(gt.Dialog,{"data-testid":"launch-protein-view-dialog",maxWidth:"xl",title:"Launch protein view",titleNode:q.default.createElement(q.default.Fragment,null,"Launch protein view ",q.default.createElement(Je,null)),open:!0,onClose:e},q.default.createElement(De.Tabs,{value:t,onChange:(g,S)=>{l(S)}},q.default.createElement(De.Tab,{value:0,label:"AlphaFoldDB search"}),q.default.createElement(De.Tab,{value:1,label:"PDB search"}),q.default.createElement(De.Tab,{value:2,label:"Foldseek search"}),q.default.createElement(De.Tab,{value:3,label:"File or URL"})),q.default.createElement(Ve,{value:t,index:0},q.default.createElement(Yr,{session:u,view:i,feature:o,preferredTranscriptId:n,handleClose:e,lookup:c,sideBySide:d,onSideBySideChange:p})),q.default.createElement(Ve,{value:t,index:1},q.default.createElement(lt,{session:u,view:i,feature:o,preferredTranscriptId:n,handleClose:e,lookup:c,sideBySide:d,onSideBySideChange:p})),q.default.createElement(Ve,{value:t,index:2},q.default.createElement(rt,{session:u,view:i,feature:o,preferredTranscriptId:n,handleClose:e})),q.default.createElement(Ve,{value:t,index:3},q.default.createElement(mt,{session:u,view:i,feature:o,preferredTranscriptId:n,handleClose:e})))}export{$t as default};
|
|
2
|
+
//# sourceMappingURL=LaunchProteinViewDialog-A73NNW5K.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as m}from"./chunk-UTDQGJCS.js";import{jb as c,kb as n,lb as i}from"./chunk-WZCSPP5F.js";function f(t,r,e){return t.builders.structure.parseTrajectory(r,e)}async function S({plugin:t,data:r,url:e}){let o,a;if(r!==void 0)a=i(r),o=await t.builders.data.rawData({data:r},{state:{isGhost:!0}});else if(e!==void 0)a=c(e),o=await t.builders.data.download({url:e,isBinary:n(e)},{state:{isGhost:!0}});else throw new Error("a structure needs either data or a url");let u=await f(t,o,a);if(!u?.obj?.data.frameCount)throw new Error(`No model could be read from ${e??"the structure data"} as ${a}`);return u}function y(t){return t&&"structure"in t?{models:[t.model],structures:[t.structure]}:{models:t?.models??[],structures:t?.structures??[]}}async function b(t,r){let{StateSelection:e,StateTransforms:o}=await m(),a=t.state.data.build();for(let{ref:u}of r)for(let s of t.state.data.select(e.Generators.byRef(u).subtree().withTransformer(o.Model.StructureComponent))){let{type:l}=s.transform.params??{};l?.name==="static"&&l.params==="water"&&a.delete(s.transform.ref)}await a.commit()}async function p(t,r,e){let o=await t.builders.structure.hierarchy.applyPreset(r,"all-models",{useDefaultIfSingleModel:!0}),{models:a,structures:u}=y(o);await b(t,u);let s=u.flatMap(l=>l.obj?[l.obj.data]:[]);if(s.length===0)throw new Error(`No structure could be built from ${e} by Mol*'s all-models preset`);return{model:a[0],structures:s,modelIds:s.flatMap(l=>l.models.map(d=>d.id))}}async function g({plugin:t,data:r,url:e}){let o=await S({plugin:t,data:r,url:e});return p(t,o,e??"the structure data")}export{S as a,g as b};
|
|
2
|
+
//# sourceMappingURL=chunk-NOFPQXHZ.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ProteinView/structurePipeline.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n isBinaryStructureUrl,\n structureFormatFromContent,\n structureFormatFromName,\n} from 'p2s_mapper'\n\nimport loadMolstar from './loadMolstar'\n\nimport type { Structure } from 'molstar/lib/mol-model/structure'\nimport type { PluginContext } from 'molstar/lib/mol-plugin/context'\nimport type { BuiltInTrajectoryFormat } from 'molstar/lib/mol-plugin-state/formats/trajectory'\nimport type { PluginStateObject } from 'molstar/lib/mol-plugin-state/objects'\nimport type { StateObjectSelector } from 'molstar/lib/mol-state'\n\ntype RawStructure = StateObjectSelector<\n PluginStateObject.Data.String | PluginStateObject.Data.Binary\n>\n\n// Typed as always resolving to a trajectory, but Mol* reverts a parse that\n// fails and resolves with nothing\nfunction parseTrajectory(\n plugin: PluginContext,\n raw: RawStructure,\n format: BuiltInTrajectoryFormat,\n): Promise<\n StateObjectSelector<PluginStateObject.Molecule.Trajectory> | undefined\n> {\n return plugin.builders.structure.parseTrajectory(raw, format)\n}\n\n/** Download or ingest a structure and parse it into a trajectory, with the\n * format sniffed from the content or the url.\n * Needs no renderer, so a headless plugin can run it to read sequences.\n *\n * A parse that fails resolves with no trajectory, and a file read with the\n * wrong parser can yield one with no frames. Both used to reach the user as\n * `Cannot read properties of undefined` from a later call, so they are named\n * here, parser included. */\nexport async function parseStructureTrajectory({\n plugin,\n data,\n url,\n}: {\n plugin: PluginContext\n data?: string\n url?: string\n}) {\n let raw: RawStructure\n let parsedAs: BuiltInTrajectoryFormat\n if (data !== undefined) {\n parsedAs = structureFormatFromContent(data)\n raw = await plugin.builders.data.rawData(\n { data },\n { state: { isGhost: true } },\n )\n } else if (url !== undefined) {\n parsedAs = structureFormatFromName(url)\n raw = await plugin.builders.data.download(\n { url, isBinary: isBinaryStructureUrl(url) },\n { state: { isGhost: true } },\n )\n } else {\n throw new Error('a structure needs either data or a url')\n }\n const trajectory = await parseTrajectory(plugin, raw, parsedAs)\n if (!trajectory?.obj?.data.frameCount) {\n throw new Error(\n `No model could be read from ${url ?? 'the structure data'} as ${parsedAs}`,\n )\n }\n return trajectory\n}\n\ntype ModelSelector = StateObjectSelector<PluginStateObject.Molecule.Model>\n\ninterface StructureSelector {\n readonly ref: string\n readonly obj?: { data: Structure }\n}\n\n// The 'all-models' preset hands back { model, structure } through the default\n// preset for a single-model trajectory, { models, structures } for an\n// ensemble, and {} if the trajectory vanished.\nfunction presetOutput(\n preset:\n | { model: ModelSelector; structure: StructureSelector }\n | { models?: ModelSelector[]; structures?: StructureSelector[] }\n | undefined,\n) {\n return preset && 'structure' in preset\n ? { models: [preset.model], structures: [preset.structure] }\n : { models: preset?.models ?? [], structures: preset?.structures ?? [] }\n}\n\n/**\n * Drop the preset's water component. A crystal's ordered waters draw as a\n * cloud of dots over the cartoon and every highlight, and nothing the view\n * shows reads them.\n */\nasync function removeWater(\n plugin: PluginContext,\n structures: readonly StructureSelector[],\n) {\n const { StateSelection, StateTransforms } = await loadMolstar()\n const update = plugin.state.data.build()\n for (const { ref } of structures) {\n for (const cell of plugin.state.data.select(\n StateSelection.Generators.byRef(ref)\n .subtree()\n .withTransformer(StateTransforms.Model.StructureComponent),\n )) {\n const { type } = cell.transform.params ?? {}\n if (type?.name === 'static' && type.params === 'water') {\n update.delete(cell.transform.ref)\n }\n }\n }\n await update.commit()\n}\n\n/**\n * Build the trajectory's models, structures and representations. One load is\n * one Mol* structure per model, so an NMR ensemble is twenty of them, and the\n * load returns every one: a color, a highlight or a superposition that\n * addresses only the first leaves the other nineteen behind. They come from\n * the preset rather than `hierarchy.current.structures`, which also holds every\n * other load's.\n */\nasync function applyStructurePreset(\n plugin: PluginContext,\n trajectory: StateObjectSelector,\n source: string,\n) {\n const preset = await plugin.builders.structure.hierarchy.applyPreset(\n trajectory,\n 'all-models',\n { useDefaultIfSingleModel: true },\n )\n const { models, structures } = presetOutput(preset)\n await removeWater(plugin, structures)\n const loaded = structures.flatMap(s => (s.obj ? [s.obj.data] : []))\n if (loaded.length === 0) {\n throw new Error(\n `No structure could be built from ${source} by Mol*'s all-models preset`,\n )\n }\n return {\n model: models[0],\n structures: loaded,\n modelIds: loaded.flatMap(s => s.models.map(m => m.id)),\n }\n}\n\n/** Load a structure from its text or its url, as the view shows one. */\nexport async function loadStructure({\n plugin,\n data,\n url,\n}: {\n plugin: PluginContext\n data?: string\n url?: string\n}) {\n const trajectory = await parseStructureTrajectory({ plugin, data, url })\n return applyStructurePreset(plugin, trajectory, url ?? 'the structure data')\n}\n"],
|
|
5
|
+
"mappings": "iGAoBA,SAASA,EACPC,EACAC,EACAC,EAGA,CACA,OAAOF,EAAO,SAAS,UAAU,gBAAgBC,EAAKC,CAAM,CAC9D,CAUA,eAAsBC,EAAyB,CAC7C,OAAAH,EACA,KAAAI,EACA,IAAAC,CACF,EAIG,CACD,IAAIJ,EACAK,EACJ,GAAIF,IAAS,OACXE,EAAWC,EAA2BH,CAAI,EAC1CH,EAAM,MAAMD,EAAO,SAAS,KAAK,QAC/B,CAAE,KAAAI,CAAK,EACP,CAAE,MAAO,CAAE,QAAS,EAAK,CAAE,CAC7B,UACSC,IAAQ,OACjBC,EAAWE,EAAwBH,CAAG,EACtCJ,EAAM,MAAMD,EAAO,SAAS,KAAK,SAC/B,CAAE,IAAAK,EAAK,SAAUI,EAAqBJ,CAAG,CAAE,EAC3C,CAAE,MAAO,CAAE,QAAS,EAAK,CAAE,CAC7B,MAEA,OAAM,IAAI,MAAM,wCAAwC,EAE1D,IAAMK,EAAa,MAAMX,EAAgBC,EAAQC,EAAKK,CAAQ,EAC9D,GAAI,CAACI,GAAY,KAAK,KAAK,WACzB,MAAM,IAAI,MACR,+BAA+BL,GAAO,oBAAoB,OAAOC,CAAQ,EAC3E,EAEF,OAAOI,CACT,CAYA,SAASC,EACPC,EAIA,CACA,OAAOA,GAAU,cAAeA,EAC5B,CAAE,OAAQ,CAACA,EAAO,KAAK,EAAG,WAAY,CAACA,EAAO,SAAS,CAAE,EACzD,CAAE,OAAQA,GAAQ,QAAU,CAAC,EAAG,WAAYA,GAAQ,YAAc,CAAC,CAAE,CAC3E,CAOA,eAAeC,EACbb,EACAc,EACA,CACA,GAAM,CAAE,eAAAC,EAAgB,gBAAAC,CAAgB,EAAI,MAAMC,EAAY,EACxDC,EAASlB,EAAO,MAAM,KAAK,MAAM,EACvC,OAAW,CAAE,IAAAmB,CAAI,IAAKL,EACpB,QAAWM,KAAQpB,EAAO,MAAM,KAAK,OACnCe,EAAe,WAAW,MAAMI,CAAG,EAChC,QAAQ,EACR,gBAAgBH,EAAgB,MAAM,kBAAkB,CAC7D,EAAG,CACD,GAAM,CAAE,KAAAK,CAAK,EAAID,EAAK,UAAU,QAAU,CAAC,EACvCC,GAAM,OAAS,UAAYA,EAAK,SAAW,SAC7CH,EAAO,OAAOE,EAAK,UAAU,GAAG,CAEpC,CAEF,MAAMF,EAAO,OAAO,CACtB,CAUA,eAAeI,EACbtB,EACAU,EACAa,EACA,CACA,IAAMX,EAAS,MAAMZ,EAAO,SAAS,UAAU,UAAU,YACvDU,EACA,aACA,CAAE,wBAAyB,EAAK,CAClC,EACM,CAAE,OAAAc,EAAQ,WAAAV,CAAW,EAAIH,EAAaC,CAAM,EAClD,MAAMC,EAAYb,EAAQc,CAAU,EACpC,IAAMW,EAASX,EAAW,QAAQY,GAAMA,EAAE,IAAM,CAACA,EAAE,IAAI,IAAI,EAAI,CAAC,CAAE,EAClE,GAAID,EAAO,SAAW,EACpB,MAAM,IAAI,MACR,oCAAoCF,CAAM,8BAC5C,EAEF,MAAO,CACL,MAAOC,EAAO,CAAC,EACf,WAAYC,EACZ,SAAUA,EAAO,QAAQC,GAAKA,EAAE,OAAO,IAAIC,GAAKA,EAAE,EAAE,CAAC,CACvD,CACF,CAGA,eAAsBC,EAAc,CAClC,OAAA5B,EACA,KAAAI,EACA,IAAAC,CACF,EAIG,CACD,IAAMK,EAAa,MAAMP,EAAyB,CAAE,OAAAH,EAAQ,KAAAI,EAAM,IAAAC,CAAI,CAAC,EACvE,OAAOiB,EAAqBtB,EAAQU,EAAYL,GAAO,oBAAoB,CAC7E",
|
|
6
|
+
"names": ["parseTrajectory", "plugin", "raw", "format", "parseStructureTrajectory", "data", "url", "parsedAs", "structureFormatFromContent", "structureFormatFromName", "isBinaryStructureUrl", "trajectory", "presetOutput", "preset", "removeWater", "structures", "StateSelection", "StateTransforms", "loadMolstar", "update", "ref", "cell", "type", "applyStructurePreset", "source", "models", "loaded", "s", "m", "loadStructure"]
|
|
7
|
+
}
|