jbrowse-plugin-protein3d 1.33.0 → 1.34.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.
Files changed (47) hide show
  1. package/dist/LaunchProteinViewExtensionPoint/launchProteinView.js +13 -3
  2. package/dist/ProteinView/markProblems.js +7 -1
  3. package/dist/ProteinView/residueMarks.js +41 -15
  4. package/dist/ProteinView/structureLoader.js +8 -6
  5. package/dist/ProteinView/structureModel.js +8 -5
  6. package/dist/ProteinView/structurePipeline.js +34 -2
  7. package/dist/chunks/{LaunchProteinViewDialog-OMCH6FKM.js → LaunchProteinViewDialog-Q6SFXKUZ.js} +2 -2
  8. package/dist/chunks/{chunk-22BDSJBC.js → chunk-LVHVCXMK.js} +2 -2
  9. package/dist/chunks/chunk-OGP4AJBI.js +2 -0
  10. package/dist/chunks/chunk-OGP4AJBI.js.map +7 -0
  11. package/dist/chunks/chunk-QDEJUSPX.js +2 -0
  12. package/dist/chunks/chunk-QDEJUSPX.js.map +7 -0
  13. package/dist/chunks/{launchAnnotationView-XZ7GDC3Z.js → launchAnnotationView-CJZQSB7U.js} +2 -2
  14. package/dist/chunks/launchProteinView-T72MMILS.js +2 -0
  15. package/dist/chunks/launchProteinView-T72MMILS.js.map +7 -0
  16. package/dist/chunks/model-Z6EC6DXU.js +2 -0
  17. package/dist/chunks/model-Z6EC6DXU.js.map +7 -0
  18. package/dist/jbrowse-plugin-protein3d.esm.js +1 -1
  19. package/dist/jbrowse-plugin-protein3d.esm.js.map +1 -1
  20. package/dist/version.js +1 -1
  21. package/package.json +1 -1
  22. package/src/LaunchProteinView/CLAUDE.md +12 -0
  23. package/src/LaunchProteinViewExtensionPoint/launchProteinView.ts +22 -6
  24. package/src/LaunchProteinViewExtensionPoint/launchViewSnapshot.test.ts +35 -1
  25. package/src/ProteinView/CLAUDE.md +25 -0
  26. package/src/ProteinView/markProblems.test.ts +9 -2
  27. package/src/ProteinView/markProblems.ts +7 -1
  28. package/src/ProteinView/residueMarks.test.ts +22 -0
  29. package/src/ProteinView/residueMarks.ts +62 -24
  30. package/src/ProteinView/structureLoader.test.ts +35 -3
  31. package/src/ProteinView/structureLoader.ts +9 -6
  32. package/src/ProteinView/structureModel.test.ts +1 -1
  33. package/src/ProteinView/structureModel.ts +8 -5
  34. package/src/ProteinView/structurePipeline.test.ts +67 -0
  35. package/src/ProteinView/structurePipeline.ts +47 -6
  36. package/src/version.ts +1 -1
  37. package/dist/chunks/chunk-BR44SFC2.js +0 -2
  38. package/dist/chunks/chunk-BR44SFC2.js.map +0 -7
  39. package/dist/chunks/chunk-ENW425OE.js +0 -2
  40. package/dist/chunks/chunk-ENW425OE.js.map +0 -7
  41. package/dist/chunks/launchProteinView-ZCQRFJXK.js +0 -2
  42. package/dist/chunks/launchProteinView-ZCQRFJXK.js.map +0 -7
  43. package/dist/chunks/model-J5LYRYAB.js +0 -2
  44. package/dist/chunks/model-J5LYRYAB.js.map +0 -7
  45. /package/dist/chunks/{LaunchProteinViewDialog-OMCH6FKM.js.map → LaunchProteinViewDialog-Q6SFXKUZ.js.map} +0 -0
  46. /package/dist/chunks/{chunk-22BDSJBC.js.map → chunk-LVHVCXMK.js.map} +0 -0
  47. /package/dist/chunks/{launchAnnotationView-XZ7GDC3Z.js.map → launchAnnotationView-CJZQSB7U.js.map} +0 -0
@@ -27,6 +27,18 @@ export function launchViewSettings({ alignmentAlgorithm, color, colorScheme, ...
27
27
  : colorOfScheme(colorScheme),
28
28
  };
29
29
  }
30
+ /**
31
+ * The structures a launch opens, given the AlphaFold model its `gene` lookup
32
+ * picked for the transcript, an isoform's for an isoform transcript. That
33
+ * model fills only the structure the launch leaves to the gene; every entry of
34
+ * `structures` names its own source, so `{ uniprotId: 'P04637' }` there opens
35
+ * the canonical model beside any transcript.
36
+ */
37
+ export function withGeneModel({ requested, geneModel }, named) {
38
+ return named && geneModel
39
+ ? requested.map(s => ({ ...s, url: named.url }))
40
+ : requested;
41
+ }
30
42
  /**
31
43
  * A LaunchView point is a transformer, so the launch returns its extendee. A
32
44
  * failure throws: the host launches a spec through
@@ -63,9 +75,7 @@ export async function launchProteinView(args) {
63
75
  throw new Error(`${describeMissingStructure(gene, named)}; name a ${named.uniprotId ? 'pdbId or url' : 'uniprotId or pdbId'}`);
64
76
  }
65
77
  const launchFeature = resolved?.feature ?? feature;
66
- const withTranscripts = (named && geneModel
67
- ? normalized.requested.map(s => ({ ...s, url: named.url }))
68
- : normalized.requested).map(s => ({
78
+ const withTranscripts = withGeneModel(normalized, named).map(s => ({
69
79
  ...s,
70
80
  userProvidedTranscriptSequence: s.userProvidedTranscriptSequence ??
71
81
  resolved?.userProvidedTranscriptSequence ??
@@ -1,6 +1,6 @@
1
1
  import { narrowsChains } from './residueFilter';
2
2
  import { parseSite } from './residueSpec';
3
- const MARK_TYPES = ['spheres', 'sticks', 'cartoon'];
3
+ const MARK_TYPES = ['spheres', 'sticks', 'cartoon', 'none'];
4
4
  const HEX_COLOR = /^#[0-9a-f]{6}$/i;
5
5
  function isRecord(x) {
6
6
  return typeof x === 'object' && x !== null && !Array.isArray(x);
@@ -58,6 +58,12 @@ export function markProblems(marks, structures = []) {
58
58
  `${where}.mark is one of ${MARK_TYPES.join(', ')}, not ${JSON.stringify(mark.mark)}`,
59
59
  ]
60
60
  : []),
61
+ ...(mark.label !== undefined &&
62
+ (typeof mark.label !== 'string' || mark.label.trim() === '')
63
+ ? [
64
+ `${where}.label is the text to write, not ${JSON.stringify(mark.label)}`,
65
+ ]
66
+ : []),
61
67
  ...encodingProblems(where, mark),
62
68
  ...(mark.mark === 'cartoon' &&
63
69
  site?.kind === 'chain' &&
@@ -16,10 +16,10 @@ function markRepresentation(mark) {
16
16
  : { type: 'spacefill', typeParams: { sizeFactor: 1 } };
17
17
  }
18
18
  export const DEFAULT_MARK_COLOR = '#f28e2b';
19
- export function syncResidueMarks({ plugin, structures, marks, }) {
19
+ export function syncResidueMarks({ plugin, structures, marks, labels = true, }) {
20
20
  return serialPerPlugin(plugin, async () => {
21
21
  const molstar = await loadMolstar();
22
- const { Color, MolScriptBuilder: MS, StateSelection, StateTransforms, createStructureRepresentationParams, } = molstar;
22
+ const { Color, MolScriptBuilder: MS, Script, StateSelection, StructureSelection, StateTransforms, createStructureRepresentationParams, } = molstar;
23
23
  const update = plugin.state.data.build();
24
24
  for (const cell of plugin.state.data.select(StateSelection.Generators.root.subtree().withTag(RESIDUE_MARKS_TAG))) {
25
25
  update.delete(cell.transform.ref);
@@ -33,20 +33,46 @@ export function syncResidueMarks({ plugin, structures, marks, }) {
33
33
  if (!structure || !site || !root) {
34
34
  continue;
35
35
  }
36
- const color = encodedColor(mark.encoding, DEFAULT_MARK_COLOR);
37
- update
38
- .to(root)
39
- .apply(StateTransforms.Model.StructureComponent, {
40
- type: { name: 'expression', params: siteExpression(MS, site) },
41
- nullIfEmpty: true,
42
- label: mark.site,
43
- }, drawnUnder(root, RESIDUE_MARKS_TAG))
44
- .apply(StateTransforms.Representation.StructureRepresentation3D, createStructureRepresentationParams(plugin, structure, {
45
- ...markRepresentation(mark.mark),
46
- color: 'uniform',
47
- colorParams: { value: Color.fromHexStyle(color) },
48
- }), drawnUnder(root, RESIDUE_MARKS_TAG));
36
+ if (mark.mark !== 'none') {
37
+ const color = encodedColor(mark.encoding, DEFAULT_MARK_COLOR);
38
+ update
39
+ .to(root)
40
+ .apply(StateTransforms.Model.StructureComponent, {
41
+ type: { name: 'expression', params: siteExpression(MS, site) },
42
+ nullIfEmpty: true,
43
+ label: mark.site,
44
+ }, drawnUnder(root, RESIDUE_MARKS_TAG))
45
+ .apply(StateTransforms.Representation.StructureRepresentation3D, createStructureRepresentationParams(plugin, structure, {
46
+ ...markRepresentation(mark.mark),
47
+ color: 'uniform',
48
+ colorParams: { value: Color.fromHexStyle(color) },
49
+ }), drawnUnder(root, RESIDUE_MARKS_TAG));
50
+ }
49
51
  }
50
52
  await update.commit();
53
+ if (labels) {
54
+ for (const mark of marks) {
55
+ const structure = structures[mark.structure ?? 0];
56
+ const site = parseSite(mark.site);
57
+ if (mark.label && structure && site) {
58
+ const loci = StructureSelection.toLociWithSourceUnits(Script.getStructureSelection(siteExpression(MS, site), structure));
59
+ await plugin.managers.structure.measurement.addLabel(loci, {
60
+ selectionTags: [RESIDUE_MARKS_TAG],
61
+ reprTags: [RESIDUE_MARKS_TAG],
62
+ labelParams: {
63
+ customText: mark.label,
64
+ textColor: Color.fromHexStyle(encodedColor(mark.encoding, DEFAULT_MARK_COLOR)),
65
+ textSize: 0.14,
66
+ borderWidth: 0,
67
+ offsetZ: 4,
68
+ background: true,
69
+ backgroundColor: Color.fromHexStyle('#ffffff'),
70
+ backgroundOpacity: 0.85,
71
+ backgroundMargin: 0.2,
72
+ },
73
+ });
74
+ }
75
+ }
76
+ }
51
77
  });
52
78
  }
@@ -52,9 +52,10 @@ export function makeStructureLoader(host, fetchModels = fetchAlphaFoldModels, fe
52
52
  /**
53
53
  * Which AlphaFold file an accession opens. Asked rather than spelled: a
54
54
  * protein folded past the length cap has no F1 fragment, and the model
55
- * version moves, so a hardcoded name 404s. The transcript's own translation
56
- * goes to the picker, so an isoform AlphaFold folded exactly maps as an
57
- * identity.
55
+ * version moves, so a hardcoded name 404s. The accession's own model wins,
56
+ * so `P04637` opens the canonical model beside an isoform's transcript and
57
+ * `P04637-4` the isoform's. Only an accession AlphaFold DB folded as
58
+ * isoforms alone goes to the picker, with the transcript's translation.
58
59
  *
59
60
  * The two ways that can come back empty are not the same answer. An
60
61
  * unreachable API says nothing about the accession, so the spelled canonical
@@ -72,9 +73,10 @@ export function makeStructureLoader(host, fetchModels = fetchAlphaFoldModels, fe
72
73
  structure.setUrl(getAlphaFoldStructureUrl(uniprotId));
73
74
  return;
74
75
  }
75
- const picked = pickAlphaFoldModel(models, {
76
- transcript: { seq: structure.userProvidedTranscriptSequence },
77
- });
76
+ const picked = models.find(m => m.accession === uniprotId) ??
77
+ pickAlphaFoldModel(models, {
78
+ transcript: { seq: structure.userProvidedTranscriptSequence },
79
+ });
78
80
  if (!picked) {
79
81
  throw new Error(`AlphaFold DB has no model for ${uniprotId}`);
80
82
  }
@@ -1905,11 +1905,14 @@ const Structure = types
1905
1905
  // carries an already-set url, so it passes through unchanged.
1906
1906
  //
1907
1907
  // A given accession outranks the one the url spells, because they differ
1908
- // exactly when it matters: asked for P04637, the loader may open the isoform
1909
- // file AF-P04637-2-F1, and reading the accession back off that url would
1910
- // save P04637-2 — which UniProt's GFF endpoint does not serve, so a reopened
1911
- // session lost its entry link. The entry's features are numbered for the
1912
- // entry, not the isoform file, so `structureUniProt` withholds them.
1908
+ // exactly when it matters. `{ gene: 'TP53', transcriptId: 'NM_001126118.2',
1909
+ // uniprotId: 'P04637' }` opens the isoform file AF-P04637-4-F1 its transcript
1910
+ // was folded from, as the launch dialog does for an isoform, and the loader
1911
+ // opens an isoform file such as AF-P11532-2-F1 for an accession AlphaFold DB
1912
+ // folded as isoforms alone. Reading the accession back off that url would
1913
+ // save the isoform's, which UniProt's GFF endpoint does not serve, so a
1914
+ // reopened session lost its entry link. The entry's features are numbered for
1915
+ // the entry, not the isoform file, so `structureUniProt` withholds them.
1913
1916
  //
1914
1917
  // A snapshot carrying an alignment but no alignmentImported predates the
1915
1918
  // flag or was written by hand; either way the alignment is used as given.
@@ -9,6 +9,36 @@ import { serialPerPlugin } from './serialPerPlugin';
9
9
  function parseTrajectory(plugin, raw, format) {
10
10
  return plugin.builders.structure.parseTrajectory(raw, format);
11
11
  }
12
+ // Typed as always resolving to a selector, but a commit that reverts resolves
13
+ // with nothing
14
+ function commitDownload(built) {
15
+ return built.commit({ revertOnError: true });
16
+ }
17
+ /** Mol*'s download reverts a failed request, as it must: a failed update left
18
+ * in the tree flags any data transaction open beside it, which then rolls
19
+ * back. The revert takes the cell's error with it, so the parse after it said
20
+ * only "Invalid data cell"; the error is read off the cell as it fails. */
21
+ async function download(plugin, url) {
22
+ const molstar = await loadMolstar();
23
+ const state = plugin.state.data;
24
+ const built = state
25
+ .build()
26
+ .toRoot()
27
+ .apply(molstar.StateTransforms.Data.Download, { url, isBinary: isBinaryStructureUrl(url) }, { state: { isGhost: true } });
28
+ const failures = [];
29
+ const watch = state.events.cell.stateUpdated.subscribe(({ ref, cell }) => {
30
+ if (ref === built.ref && cell.status === 'error') {
31
+ failures.push(cell.errorText?.replace(/^Error: /, '') ?? 'no data');
32
+ }
33
+ });
34
+ const raw = await commitDownload(built).finally(() => {
35
+ watch.unsubscribe();
36
+ });
37
+ if (!raw?.isOk) {
38
+ throw new Error(`Could not download ${url}: ${failures.at(-1) ?? 'no data'}`);
39
+ }
40
+ return raw;
41
+ }
12
42
  /** Download or ingest a structure and parse it into a trajectory, with the
13
43
  * format sniffed from the content or the url.
14
44
  * Needs no renderer, so a headless plugin can run it to read sequences.
@@ -26,14 +56,16 @@ export async function parseStructureTrajectory({ plugin, data, url, }) {
26
56
  }
27
57
  else if (url !== undefined) {
28
58
  parsedAs = structureFormatFromName(url);
29
- raw = await plugin.builders.data.download({ url, isBinary: isBinaryStructureUrl(url) }, { state: { isGhost: true } });
59
+ raw = await download(plugin, url);
30
60
  }
31
61
  else {
32
62
  throw new Error('a structure needs either data or a url');
33
63
  }
34
64
  const trajectory = await parseTrajectory(plugin, raw, parsedAs);
35
65
  if (!trajectory?.obj?.data.frameCount) {
36
- await removeWithGhosts(plugin, await loadMolstar(), raw.ref);
66
+ // a plugin disposed mid-load fails the removal too, and the parse's own
67
+ // error is the one to report
68
+ await removeWithGhosts(plugin, await loadMolstar(), raw.ref).catch(() => { });
37
69
  throw new Error(`No model could be read from ${url ?? 'the structure data'} as ${parsedAs}`);
38
70
  }
39
71
  return trajectory;
@@ -1,3 +1,3 @@
1
- import{a as et,b as fr,c as He,d as vr}from"./chunk-UXGREKQA.js";import{b as Tr}from"./chunk-ENW425OE.js";import{a as mr}from"./chunk-ENPYAI4H.js";import{a as Y}from"./chunk-RPRTWFVS.js";import{a as yr,c as br,d as Sr,e as kr}from"./chunk-EKHBUHHM.js";import{a as E,b as M,c as Cr}from"./chunk-4F53HQBL.js";import{a as xr}from"./chunk-53Z5PTMG.js";import"./chunk-NY22OOJ6.js";import{A as _e,B as Ge,C as be,D as ur,E as _,F as Ve,G as y,a as A,b as or,c as fe,d as ge,f as he,g as De,j as ye,k as Z,l as nr,m as ir,n as sr,o as ee,p as ar,q as Ue,r as Q,s as ve,t as te,u as qe,v as lr,w as $e,x as Be,y as Oe,z as P}from"./chunk-SB4F5EHZ.js";import{a as D}from"./chunk-3VLTXPRJ.js";import{a as Xt}from"./chunk-CFGPSBOM.js";import{b as Rt}from"./chunk-R3GQXMDR.js";import"./chunk-SEVYWN5I.js";import{a as St,b as H,c as W}from"./chunk-VQ5X2CAU.js";import{a as m}from"./chunk-BWRMG55K.js";import{d as kt,i as xt,n as Pe,p as K,q as Tt,r as h,s as e,u as T}from"./chunk-INAB36B4.js";import"./chunk-HNO3QZD6.js";import{a as dr,b as cr,j as Se,l as ke,m as ze}from"./chunk-MBUM32YU.js";import"./chunk-LVAZFGE6.js";import"./chunk-NCH7IJII.js";import"./chunk-MJZSVHMS.js";import"./chunk-46MRJY2F.js";import{h as pr}from"./chunk-THJLCDMW.js";import"./chunk-TZ54BAT7.js";import{e as pe}from"./chunk-2RFFBSIA.js";import"./chunk-INWFM3CY.js";import"./chunk-A4XT2SQ7.js";import"./chunk-BWZ7PSFU.js";import"./chunk-G67ZYVWG.js";import"./chunk-OU2GWGJP.js";import{a as gr,c as hr}from"./chunk-A73LEL2C.js";import{a as Re,b as Jt}from"./chunk-Q5QGMPYL.js";import{a as Ae,c as er,e as tr,f as me,g as Ee,h as rr,i as Me}from"./chunk-7GELEOAH.js";import{a as Qt}from"./chunk-MYRDDDAG.js";import{g as oe}from"./chunk-Y5T7GSKP.js";import{d as Yt}from"./chunk-6AA7U2KU.js";import{d as bt}from"./chunk-LGVXT66Y.js";import{$ as Lt,Ab as Qe,Bb as Ot,Hb as _t,M as Fe,Mb as Gt,N as It,Nb as Je,O as we,Oa as Pt,Pb as Xe,Qb as Vt,Sb as zt,Tb as Ht,Va as Ft,Vb as jt,Ya as wt,Yb as Wt,Zb as Kt,_a as Nt,_b as Zt,b as vt,bb as Ne,db as At,e as Ct,eb as Ye,fb as Et,ib as Mt,jb as Dt,kb as Ut,ub as qt,xb as $t,yb as Bt}from"./chunk-JKKI7LFR.js";import"./chunk-XBJKSIMP.js";T();T();T();var io=D()({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}}),so=m(function({selected:t,onChange:n,disabled:o}){let{classes:i}=io();return e.createElement("div",{className:i.root},e.createElement("div",{className:i.header},e.createElement(y,{variant:"subtitle2"},"Databases to search:"),e.createElement("div",{className:i.buttons},e.createElement(A,{size:"small",onClick:()=>{n(Xe.map(s=>s.id))},disabled:o},"Select all"),e.createElement(A,{size:"small",onClick:()=>{n([])},disabled:o},"Clear"))),e.createElement(nr,{className:i.checkboxGroup},Xe.map(s=>e.createElement(Z,{key:s.id,control:e.createElement(fe,{size:"small",checked:t.includes(s.id),onChange:()=>{t.includes(s.id)?n(t.filter(a=>a!==s.id)):n([...t,s.id])},disabled:o}),label:s.label}))))}),Ir=so;T();T();T();async function Lr(r,t,n){try{await r(),t?.()}catch(o){console.error(o),n?.(o)}}function Pr({structureCount:r,userSelectedProteinSequence:t,selectedTranscript:n}){return[r===0&&"No structure checked",!t?.seq&&"Could not compute protein sequence (feature may be missing CDS subfeatures)",!n&&"No transcript selected"].filter(o=>typeof o=="string")}function xe(r,t){let[n,o]=h(),[i,s]=h(!1);return{runLaunch:u=>()=>{t?.(),i||(s(!0),o(void 0),Lr(u,r,o).then(()=>{s(!1)}))},launchError:n,launching:i}}var ao=m(function({hit:t,session:n,view:o,feature:i,selectedTranscript:s,userProvidedTranscriptSequence:a,onClose:u}){let[l,d]=h(null),p=!!l,c=Mt(t.target),g=F=>{d(F.currentTarget)},v=()=>{d(null)},{runLaunch:k,launchError:C,launching:S}=xe(u,v),f={session:n,view:o,feature:i,selectedTranscript:s,uniprotId:c},b=k(()=>{let F=!t.structureUrl&&Je(t)?Gt(t.tCa,t.tSeq,"A",t.target):void 0;return Se({...f,sources:[{url:t.structureUrl,data:F}],userProvidedTranscriptSequence:a})}),{launch1D:I}=ze({...f,confidenceUrl:Ut(t.target)});return!!t.structureUrl||Je(t)?e.createElement(e.Fragment,null,C?e.createElement(H,{error:C}):null,e.createElement(A,{size:"small",variant:"outlined",disabled:S,onClick:g},"Load"),e.createElement(Ue,{anchorEl:l,open:p,onClose:v},e.createElement(Q,{"data-testid":"protein-launch-option-3d",onClick:b},ke["3d"]),I?e.createElement(Q,{"data-testid":"protein-launch-option-1d",onClick:k(I)},ke["1d"]):null)):e.createElement("span",null,"-")}),Fr=ao;var lo=D()(r=>({root:{display:"flex",flexDirection:"column",gap:16},tableContainer:{maxHeight:400},headerCell:{fontWeight:"bold",backgroundColor:r.palette.mode==="dark"?r.palette.grey[900]:r.palette.grey[100]},noResults:{padding:16,textAlign:"center"}})),uo=100;function co(r){return jt(r).map(t=>({...t,structureUrl:Dt(t.target,t.db)})).toSorted((t,n)=>(t.eval??1/0)-(n.eval??1/0))}var po=m(function({results:t,session:n,view:o,feature:i,selectedTranscript:s,userProvidedTranscriptSequence:a,onClose:u}){let{classes:l}=lo(),d=co(t),p=d.slice(0,uo);return p.length===0?e.createElement(ve,{className:l.noResults},e.createElement(y,null,"No similar structures found")):e.createElement("div",{className:l.root},e.createElement(y,{variant:"subtitle2"},"Found ",d.length," similar structures",d.length>p.length?` (showing top ${p.length})`:""),e.createElement(_e,{component:ve,className:l.tableContainer},e.createElement(Be,{size:"small",stickyHeader:!0},e.createElement(Ge,null,e.createElement(be,null,e.createElement(P,{className:l.headerCell},"Database"),e.createElement(P,{className:l.headerCell},"Target"),e.createElement(P,{className:l.headerCell},"Organism"),e.createElement(P,{className:l.headerCell},e.createElement(Ve,{title:"Foldseek's estimated probability that the hit is a true structural homolog"},e.createElement("span",null,"Prob"))),e.createElement(P,{className:l.headerCell},e.createElement(Ve,{title:"Percentage of aligned residues whose amino acid is identical; structural hits are often low here"},e.createElement("span",null,"Seq. Id."))),e.createElement(P,{className:l.headerCell},"Coverage"),e.createElement(P,{className:l.headerCell},e.createElement(Ve,{title:"Hits of this score expected by chance in a database this size; smaller is stronger"},e.createElement("span",null,"E-value"))),e.createElement(P,{className:l.headerCell},"Actions"))),e.createElement(Oe,null,p.map((c,g)=>e.createElement(be,{key:`${c.db}-${c.target}-${g}`},e.createElement(P,null,c.db),e.createElement(P,null,c.target),e.createElement(P,null,c.taxName??"-"),e.createElement(P,null,c.prob!=null?`${(c.prob*100).toFixed(1)}%`:"-"),e.createElement(P,null,c.seqId!=null?`${c.seqId.toFixed(1)}%`:"-"),e.createElement(P,null,c.alnLength!=null&&c.qLen!=null?`${(c.alnLength/c.qLen*100).toFixed(1)}%`:"-"),e.createElement(P,null,c.eval!=null?c.eval.toExponential(2):"-"),e.createElement(P,null,e.createElement(Fr,{hit:c,session:n,view:o,feature:i,selectedTranscript:s,userProvidedTranscriptSequence:a,onClose:u}))))))))}),wr=po;T();var mo=m(function({message:t}){return t?e.createElement(y,{variant:"body2",color:"warning.main"},t):null}),ne=mo;T();var fo=m(function({val:t,setVal:n,isoforms:o,ranking:i,structureSequence:s,feature:a,disabled:u,size:l}){let d=Ee(a),p=new Map(o.map(f=>[f.id(),f])),c=f=>me(p.get(f))||f,{matches:g,nonMatches:v,noData:k}=i,C=s?Fe(s).length:void 0,S=({id:f,length:b,identical:I},L=I===void 0?"":` (${I}/${C} structure residues identical)`)=>e.createElement(Q,{value:f,key:f},d," - ",c(f)," (",b,"aa)",L);return e.createElement(_,{value:t??"",onChange:f=>{n(f.target.value)},label:"Choose transcript isoform",select:!0,disabled:u,size:l},g.map(f=>S(f," (matches structure residues)")),v.map(f=>S(f)),k.map(f=>e.createElement(Q,{value:f,key:f,disabled:!0},d," - ",c(f)," (no data)")))}),Te=fo;T();function tt(){let[r,t]=h(),[n,o]=h(),[i,s]=h(!1),[a,u]=h(!1),[l,d]=h(),[p,c]=h(""),g=Tt(null);Pe(()=>()=>{g.current?.abort()},[]);let v=()=>{g.current?.abort();let b=new AbortController;return g.current=b,b.signal},k=async b=>{let I=v();u(!0),d(void 0),c("Predicting 3Di structure...");try{let L=await Wt(b,{signal:I});return o(L),L}catch(L){I.aborted||(console.error(L),d(L));return}finally{I.aborted||(u(!1),c(""))}},C=async(b,I,L)=>{let F=v();s(!0),d(void 0),c("Submitting search...");try{let N=await Kt({aaSequence:b,di3Sequence:I,databases:L},{signal:F}),G=await Zt(N.id,{onStatus:c,signal:F});return t(G),G}catch(N){F.aborted||(console.error(N),d(N));return}finally{F.aborted||(s(!1),c(""))}},S=()=>{g.current?.abort(),g.current=null,s(!1),u(!1),c("")},f=()=>{S(),t(void 0),o(void 0),d(void 0)};return{results:r,cleanedAaSequence:n?.aaSequence,di3Sequence:n?.di3Sequence,isLoading:i,isPredicting:a,error:l,statusMessage:p,predictStructure:k,search:C,cancel:S,reset:f}}function Ce({feature:r,view:t}){let{data:n,error:o,isLoading:i}=E(["isoform-sequences",r.id(),t?.assemblyNames?.[0]],async()=>{let a=Ae(r),u=await Yt({transcripts:a,session:oe(t),assemblyName:t?.assemblyNames?.[0]});for(let{feature:d,error:p}of u)p!==void 0&&console.error("[useIsoformProteinSequences] error for",d.id(),p);let l=u.flatMap(d=>d.seq===void 0?[]:[[d.feature.id(),{feature:d.feature,seq:d.seq}]]);return{sequences:Object.fromEntries(l),translated:l.length,total:u.length}},{...M,keepPreviousData:!0}),s=n?n.total-n.translated:0;return{isLoading:i,isoformSequences:n?.sequences,error:o,partialFailure:s>0&&n?`${s} of ${n.total} transcripts have no protein sequence`:void 0}}function rt({view:r,isoforms:t,structureSequences:n}){let o=!!r&&!!n?.length&&t.some(a=>a.seq),{data:i,error:s}=E(o?["isoform-ranking",t,n]:null,()=>Qt({rpcManager:oe(r).rpcManager,name:"ProteinRankIsoforms",args:{isoforms:t,structureSequences:n??[]},inPlace:()=>Re(t,n)}),M);return o?{ranking:i,error:s}:{ranking:Re(t,n)}}T();function go({options:r,isoformSequences:t,ranking:n,preferredTranscriptId:o}){return Me(r,t).some(i=>i.id===o&&i.seq)?o:n&&Jt(n,er(r))}function ot({options:r,isoformSequences:t,ranking:n,preferredTranscriptId:o,resetKey:i}){let[s,a]=h(),[u,l]=h(i);i!==u&&(l(i),a(void 0));let d=t!==void 0?go({options:r,isoformSequences:t,ranking:n,preferredTranscriptId:o}):void 0;return{userSelection:s??d,setUserSelection:a}}function le({feature:r,view:t,structureSequences:n,preferredTranscriptId:o,resetKey:i}){let s=Ae(r),{isoformSequences:a,isLoading:u,error:l,partialFailure:d}=Ce({feature:r,view:t}),{ranking:p,error:c}=rt({view:t,isoforms:Me(s,a),structureSequences:n}),{userSelection:g,setUserSelection:v}=ot({options:s,isoformSequences:a,ranking:p?.ranking,preferredTranscriptId:o,resetKey:i}),k=s.find(S=>S.id()===g),C=g?a?.[g]:void 0;return{transcripts:s,isoformSequences:a,structureSequence:p?.structureSequence,ranking:p?.ranking,isLoading:u,isRanking:!!a&&!p&&!c&&!g,error:l??c,partialFailure:d,selectedTranscriptId:g,setSelectedTranscriptId:v,selectedTranscript:k,selectedIsoform:C}}var ho=D()({dialogContent:{width:"80em",display:"flex",flexDirection:"column",gap:20},sequenceInput:{fontFamily:"monospace"},di3Section:{display:"flex",flexDirection:"column",gap:8,alignItems:"flex-start"}}),yo=m(function({feature:t,preferredTranscriptId:n,session:o,view:i,handleClose:s}){let{classes:a}=ho(),[u,l]=h(),[d,p]=h(Vt),[c,g]=h(!1),{results:v,cleanedAaSequence:k,di3Sequence:C,isLoading:S,isPredicting:f,error:b,statusMessage:I,predictStructure:L,search:F,cancel:N,reset:G}=tt(),{transcripts:q,isoformSequences:B,ranking:j,isLoading:U,error:$,partialFailure:V,selectedTranscriptId:x,setSelectedTranscriptId:J,selectedTranscript:re,selectedIsoform:z}=le({feature:t,view:i,preferredTranscriptId:n}),X=z?It(z.seq):"",O=u??X,ue=()=>{(C!==void 0||v!==void 0)&&G()},de=ae=>{J(ae),l(void 0),ue()},R=S||f,se=Ht(O),w=zt(O).length>0&&!se&&d.length>0&&!R,ce=async()=>{let ae=k&&C?{aaSequence:k,di3Sequence:C}:await L(O.trim());ae&&await F(ae.aaSequence,ae.di3Sequence,d)},yt=b??$;return e.createElement(e.Fragment,null,e.createElement(De,{className:a.dialogContent},yt&&!U?e.createElement(H,{error:yt}):null,U?e.createElement(W,{variant:"subtitle2",message:"Loading transcript sequences"}):null,e.createElement(ne,{message:V}),B&&j?e.createElement(e.Fragment,null,e.createElement(Te,{val:x,setVal:de,isoforms:q,ranking:j,feature:t,disabled:R}),e.createElement(_,{label:"Protein sequence (amino acids)",multiline:!0,rows:4,value:O,onChange:ae=>{l(ae.target.value),ue()},placeholder:"MKTVRQERLKSIVRILERSKEPVSGAQLAEEL...",disabled:R,error:!!se,helperText:se,slotProps:{input:{className:a.sequenceInput}}})):null,C?e.createElement("div",{className:a.di3Section},e.createElement(ee,{component:"button",type:"button",variant:"body2",onClick:()=>{g(!c)}},c?"Hide 3Di":"Show 3Di"),c?e.createElement(_,{label:"3Di structural alphabet (what the search runs on)",multiline:!0,rows:4,fullWidth:!0,value:C,slotProps:{input:{className:a.sequenceInput,readOnly:!0}}}):null):null,e.createElement(Ir,{selected:d,onChange:p,disabled:R}),I?e.createElement(W,{variant:"subtitle2",message:I}):null,v?e.createElement(wr,{results:v,session:o,view:i,feature:t,selectedTranscript:re,userProvidedTranscriptSequence:z?.seq,onClose:s}):null,e.createElement(y,{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.")),e.createElement(he,null,e.createElement(A,{variant:"contained",color:"secondary",onClick:()=>{s()}},"Close"),R?e.createElement(A,{variant:"outlined",onClick:()=>{N()}},"Cancel search"):null,v?e.createElement(A,{variant:"outlined",onClick:()=>{G()}},"New search"):null,e.createElement(A,{variant:"contained",color:"primary",disabled:!w,onClick:()=>{ce()}},f?"Predicting 3Di...":S?"Searching...":"Search Foldseek")))}),Nr=yo;T();T();var Ar=Xt(Rt("path",{d:"m7 10 5 5 5-5z"}),"ArrowDropDown");T();var bo=m(function({anchorEl:t,onClose:n,options:o}){return e.createElement(Ue,{anchorEl:t,open:!!t,onClose:n,"data-testid":"protein-launch-options-menu"},o.map(i=>e.createElement(Q,{key:i.key,"data-testid":`protein-launch-option-${i.key}`,onClick:i.onClick},e.createElement(ar,{primary:i.title,secondary:i.description}))))}),Er=bo;var So=m(function({handleClose:t,ready:n,uniprotId:o,userSelectedProteinSequence:i,selectedTranscript:s,sources:a,confidenceUrl:u,feature:l,view:d,session:p,sideBySide:c}){let[g,v]=h(null),k=()=>{v(null)},{runLaunch:C,launchError:S,launching:f}=xe(t,k),b=n&&!f,I=C(()=>Se({session:p,view:d,feature:l,selectedTranscript:s,uniprotId:o,sources:a,userProvidedTranscriptSequence:i?.seq,sideBySide:c})),{launch1D:L}=ze({session:p,view:d,feature:l,selectedTranscript:s,uniprotId:o,confidenceUrl:u}),F=[{key:"3d",title:ke["3d"],description:"View protein structure with genome-to-structure coordinate mapping",onClick:I},...L?[{key:"1d",title:ke["1d"],description:"View protein features and annotations as a linear track",onClick:C(L)}]:[]];return e.createElement(e.Fragment,null,S?e.createElement(H,{error:S}):null,e.createElement(A,{variant:"contained",color:"secondary",size:"small",onClick:()=>{t()}},"Cancel"),e.createElement(or,{variant:"contained",color:"primary",size:"small"},e.createElement(A,{"data-testid":"protein-launch-button",disabled:!b,onClick:I},"Launch"),e.createElement(A,{"data-testid":"protein-launch-options-button",disabled:!b,onClick:N=>{v(N.currentTarget)},"aria-label":"More launch options"},e.createElement(Ar,null))),e.createElement(Er,{anchorEl:g,onClose:k,options:F}))}),Mr=So;T();var ko=m(function(){return e.createElement(y,{variant:"body2",sx:{mr:2}},"Transcript and structure sequences differ, will run"," ",Ct[vt]," alignment")}),je=ko;T();T();var xo="32px 150px minmax(0, 1fr) 170px 150px",Ie=D()(r=>{let t=r.palette.mode==="dark";return{row:{display:"grid",gridTemplateColumns:xo,gap:12,alignItems:"center",padding:"6px 24px 6px 16px",borderBottom:`1px solid ${r.palette.divider}`,cursor:"pointer","&:hover":{backgroundColor:r.palette.action.hover}},checked:{backgroundColor:r.palette.action.selected},idCell:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:3},id:{fontFamily:"monospace",fontWeight:600,whiteSpace:"nowrap"},badge:{fontSize:"0.65rem",fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",padding:"0 6px",borderRadius:3},experimental:{color:t?"#8fd19c":"#2f6b3a",background:t?"#1c2e21":"#e4f1e6"},predicted:{color:t?"#f0c27a":"#7a4c0f",background:t?"#33281a":"#fbf0dc"},what:{display:"flex",flexDirection:"column",gap:4,minWidth:0},tags:{display:"flex",flexWrap:"wrap",gap:4},tag:{fontSize:"0.72rem",padding:"0 6px",border:`1px solid ${r.palette.divider}`,borderRadius:3,color:r.palette.text.secondary},partner:{color:r.palette.text.primary,borderColor:r.palette.primary.main},ligand:{fontFamily:"monospace"},quality:{display:"flex",flexDirection:"column",gap:2,fontVariantNumeric:"tabular-nums"},dot:{display:"inline-block",width:9,height:9,borderRadius:2,marginRight:5},coverage:{display:"flex",flexDirection:"column",gap:3,fontVariantNumeric:"tabular-nums"},bar:{position:"relative",height:8,border:`1px solid ${r.palette.divider}`,borderRadius:2},span:{position:"absolute",top:0,bottom:0,background:r.palette.primary.main,borderRadius:1}}});function To(r){let{domain:t,range:n}=pr.plddt;return n[t.filter(o=>r>o).length]}var Dr=m(function({value:t}){let{classes:n}=Ie();return t===void 0?null:e.createElement(y,{variant:"body2"},e.createElement("span",{className:n.dot,style:{background:To(t)}}),"pLDDT ",t.toFixed(1))}),vo=m(function({row:t}){let{classes:n}=Ie(),o=t.kind==="alphafold"?/model_v(\d+)/.exec(t.model.url)?.[1]:void 0;return e.createElement("div",{className:n.quality},t.kind==="alphafold"?e.createElement(e.Fragment,null,e.createElement(Dr,{value:t.model.meanPlddt}),e.createElement(y,{variant:"caption",color:"textSecondary"},"AlphaFold DB",o?` v${o}`:"")):t.kind==="dataset"?e.createElement(e.Fragment,null,e.createElement(y,{variant:"body2"},t.match.dataset.name),t.match.dataset.description?e.createElement(y,{variant:"caption",color:"textSecondary"},t.match.dataset.description):null):t.kind==="complex"?e.createElement(e.Fragment,null,t.complex.iptm===void 0?null:e.createElement(y,{variant:"body2"},"ipTM ",t.complex.iptm.toFixed(2)),e.createElement(Dr,{value:t.complex.meanPlddt})):e.createElement(e.Fragment,null,e.createElement(y,{variant:"body2"},t.entry.method,t.entry.resolution===void 0?"":` \xB7 ${t.entry.resolution.toFixed(2)} \xC5`),e.createElement(y,{variant:"caption",color:"textSecondary"},t.entry.chains.length===1?"chain":"chains"," ",t.entry.chains.join(", "))))}),Co=m(function({start:t,end:n,length:o}){let{classes:i}=Ie(),s=(n-t+1)/o;return e.createElement("div",{className:i.coverage},e.createElement("div",{className:i.bar,"aria-hidden":!0},e.createElement("span",{className:i.span,style:{left:`${(t-1)/o*100}%`,width:`${Math.min(s,1)*100}%`}})),e.createElement(y,{variant:"caption",color:"textSecondary"},t,"\u2013",n," of ",o," \xB7 ",Math.round(s*100),"%"))}),nt=m(function({tags:t,className:n}){let{classes:o,cx:i}=Ie();return e.createElement(e.Fragment,null,t.map(s=>e.createElement("span",{key:s.label,className:i(o.tag,n),title:s.title},s.label)))}),Io=m(function({row:t,checked:n,uniprotLength:o,onToggle:i}){let{classes:s,cx:a}=Ie(),u=t.partners.length+t.ligands.length+t.notes.length>0;return e.createElement("div",{className:a(s.row,n&&s.checked),"data-testid":`structure-row-${t.key}`,onClick:i},e.createElement(fe,{size:"small",checked:n,onClick:l=>{l.stopPropagation()},onChange:i,slotProps:{input:{"aria-label":`Open ${t.label}`}}}),e.createElement("div",{className:s.idCell},e.createElement(ee,{href:t.href,target:"_blank",rel:"noreferrer",variant:"body2",className:s.id,onClick:l=>{l.stopPropagation()}},t.label),e.createElement("span",{className:a(s.badge,t.predicted?s.predicted:s.experimental)},t.predicted?"Predicted":"Experimental")),e.createElement("div",{className:s.what},e.createElement(y,{variant:"body2"},t.title),u?e.createElement("div",{className:s.tags},e.createElement(nt,{tags:t.partners,className:s.partner}),e.createElement(nt,{tags:t.ligands,className:s.ligand}),e.createElement(nt,{tags:t.notes})):null),e.createElement(vo,{row:t}),t.kind==="dataset"?e.createElement(y,{variant:"caption",color:"textSecondary"},"listed as ",t.match.structure.id):e.createElement(Co,{start:t.start,end:t.end,length:o}))}),Ur=Io;var Lo=.5,Po={ADP:"ADP",AMP:"AMP",ANP:"AMP-PNP",ATP:"ATP",CA:"Ca\xB2\u207A",CD:"Cd\xB2\u207A",CO:"Co\xB2\u207A",CU:"Cu\xB2\u207A",FAD:"FAD",FE:"Fe\xB3\u207A",FE2:"Fe\xB2\u207A",GCP:"GppCp",GDP:"GDP",GNP:"GppNHp",GSP:"GTP\u03B3S",GTP:"GTP",HEM:"heme",MG:"Mg\xB2\u207A",MN:"Mn\xB2\u207A",NAD:"NAD\u207A",NAP:"NADP\u207A",NDP:"NADPH",NI:"Ni\xB2\u207A",SAH:"SAH",SAM:"SAM",ZN:"Zn\xB2\u207A"},Fo=["ATP","ADP","CoA","DNA","EM","Fab","GDP","GTP","HLA","MHC","mRNA","NAD","NADP","NMR","RNA","scFv","TCR","tRNA"];function wo(r,t=[]){let n=new Map([...Fo,...t].map(i=>[i.toUpperCase(),i])),o=r.replace(/[A-Za-z0-9]+(?:[-*:'.][A-Za-z0-9]+)*/g,i=>/\d/.test(i)?i:i.replace(/[A-Za-z]+/g,s=>n.get(s)??s.toLowerCase()));return r===r.toUpperCase()?o.charAt(0).toUpperCase()+o.slice(1):r}function No(r){return r.ligands.filter(t=>!mr.has(t.id)).map(t=>({label:Po[t.id]??t.id,title:t.name}))}function Ao(r,t){let n=Bt(r,t),o=n.filter(a=>a.type==="Protein"),i=n.filter(a=>a.type!=="Protein"),s=[...o.map(a=>({label:a.description??a.entityId,title:a.uniprotIds.join(", ")||void 0})),...[...new Set(i.map(a=>a.type??"Other"))].map(a=>({label:a,title:i.filter(u=>(u.type??"Other")===a).map(u=>u.description??u.entityId).join(`
1
+ import{a as et,b as fr,c as He,d as vr}from"./chunk-UXGREKQA.js";import{b as Tr}from"./chunk-OGP4AJBI.js";import{a as mr}from"./chunk-ENPYAI4H.js";import{a as Y}from"./chunk-RPRTWFVS.js";import{a as yr,c as br,d as Sr,e as kr}from"./chunk-EKHBUHHM.js";import{a as E,b as M,c as Cr}from"./chunk-4F53HQBL.js";import{a as xr}from"./chunk-53Z5PTMG.js";import"./chunk-NY22OOJ6.js";import{A as _e,B as Ge,C as be,D as ur,E as _,F as Ve,G as y,a as A,b as or,c as fe,d as ge,f as he,g as De,j as ye,k as Z,l as nr,m as ir,n as sr,o as ee,p as ar,q as Ue,r as Q,s as ve,t as te,u as qe,v as lr,w as $e,x as Be,y as Oe,z as P}from"./chunk-SB4F5EHZ.js";import{a as D}from"./chunk-3VLTXPRJ.js";import{a as Xt}from"./chunk-CFGPSBOM.js";import{b as Rt}from"./chunk-R3GQXMDR.js";import"./chunk-SEVYWN5I.js";import{a as St,b as H,c as W}from"./chunk-VQ5X2CAU.js";import{a as m}from"./chunk-BWRMG55K.js";import{d as kt,i as xt,n as Pe,p as K,q as Tt,r as h,s as e,u as T}from"./chunk-INAB36B4.js";import"./chunk-HNO3QZD6.js";import{a as dr,b as cr,j as Se,l as ke,m as ze}from"./chunk-MBUM32YU.js";import"./chunk-LVAZFGE6.js";import"./chunk-NCH7IJII.js";import"./chunk-MJZSVHMS.js";import"./chunk-46MRJY2F.js";import{h as pr}from"./chunk-THJLCDMW.js";import"./chunk-TZ54BAT7.js";import{e as pe}from"./chunk-2RFFBSIA.js";import"./chunk-INWFM3CY.js";import"./chunk-A4XT2SQ7.js";import"./chunk-BWZ7PSFU.js";import"./chunk-G67ZYVWG.js";import"./chunk-OU2GWGJP.js";import{a as gr,c as hr}from"./chunk-A73LEL2C.js";import{a as Re,b as Jt}from"./chunk-Q5QGMPYL.js";import{a as Ae,c as er,e as tr,f as me,g as Ee,h as rr,i as Me}from"./chunk-7GELEOAH.js";import{a as Qt}from"./chunk-MYRDDDAG.js";import{g as oe}from"./chunk-Y5T7GSKP.js";import{d as Yt}from"./chunk-6AA7U2KU.js";import{d as bt}from"./chunk-LGVXT66Y.js";import{$ as Lt,Ab as Qe,Bb as Ot,Hb as _t,M as Fe,Mb as Gt,N as It,Nb as Je,O as we,Oa as Pt,Pb as Xe,Qb as Vt,Sb as zt,Tb as Ht,Va as Ft,Vb as jt,Ya as wt,Yb as Wt,Zb as Kt,_a as Nt,_b as Zt,b as vt,bb as Ne,db as At,e as Ct,eb as Ye,fb as Et,ib as Mt,jb as Dt,kb as Ut,ub as qt,xb as $t,yb as Bt}from"./chunk-JKKI7LFR.js";import"./chunk-XBJKSIMP.js";T();T();T();var io=D()({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}}),so=m(function({selected:t,onChange:n,disabled:o}){let{classes:i}=io();return e.createElement("div",{className:i.root},e.createElement("div",{className:i.header},e.createElement(y,{variant:"subtitle2"},"Databases to search:"),e.createElement("div",{className:i.buttons},e.createElement(A,{size:"small",onClick:()=>{n(Xe.map(s=>s.id))},disabled:o},"Select all"),e.createElement(A,{size:"small",onClick:()=>{n([])},disabled:o},"Clear"))),e.createElement(nr,{className:i.checkboxGroup},Xe.map(s=>e.createElement(Z,{key:s.id,control:e.createElement(fe,{size:"small",checked:t.includes(s.id),onChange:()=>{t.includes(s.id)?n(t.filter(a=>a!==s.id)):n([...t,s.id])},disabled:o}),label:s.label}))))}),Ir=so;T();T();T();async function Lr(r,t,n){try{await r(),t?.()}catch(o){console.error(o),n?.(o)}}function Pr({structureCount:r,userSelectedProteinSequence:t,selectedTranscript:n}){return[r===0&&"No structure checked",!t?.seq&&"Could not compute protein sequence (feature may be missing CDS subfeatures)",!n&&"No transcript selected"].filter(o=>typeof o=="string")}function xe(r,t){let[n,o]=h(),[i,s]=h(!1);return{runLaunch:u=>()=>{t?.(),i||(s(!0),o(void 0),Lr(u,r,o).then(()=>{s(!1)}))},launchError:n,launching:i}}var ao=m(function({hit:t,session:n,view:o,feature:i,selectedTranscript:s,userProvidedTranscriptSequence:a,onClose:u}){let[l,d]=h(null),p=!!l,c=Mt(t.target),g=F=>{d(F.currentTarget)},v=()=>{d(null)},{runLaunch:k,launchError:C,launching:S}=xe(u,v),f={session:n,view:o,feature:i,selectedTranscript:s,uniprotId:c},b=k(()=>{let F=!t.structureUrl&&Je(t)?Gt(t.tCa,t.tSeq,"A",t.target):void 0;return Se({...f,sources:[{url:t.structureUrl,data:F}],userProvidedTranscriptSequence:a})}),{launch1D:I}=ze({...f,confidenceUrl:Ut(t.target)});return!!t.structureUrl||Je(t)?e.createElement(e.Fragment,null,C?e.createElement(H,{error:C}):null,e.createElement(A,{size:"small",variant:"outlined",disabled:S,onClick:g},"Load"),e.createElement(Ue,{anchorEl:l,open:p,onClose:v},e.createElement(Q,{"data-testid":"protein-launch-option-3d",onClick:b},ke["3d"]),I?e.createElement(Q,{"data-testid":"protein-launch-option-1d",onClick:k(I)},ke["1d"]):null)):e.createElement("span",null,"-")}),Fr=ao;var lo=D()(r=>({root:{display:"flex",flexDirection:"column",gap:16},tableContainer:{maxHeight:400},headerCell:{fontWeight:"bold",backgroundColor:r.palette.mode==="dark"?r.palette.grey[900]:r.palette.grey[100]},noResults:{padding:16,textAlign:"center"}})),uo=100;function co(r){return jt(r).map(t=>({...t,structureUrl:Dt(t.target,t.db)})).toSorted((t,n)=>(t.eval??1/0)-(n.eval??1/0))}var po=m(function({results:t,session:n,view:o,feature:i,selectedTranscript:s,userProvidedTranscriptSequence:a,onClose:u}){let{classes:l}=lo(),d=co(t),p=d.slice(0,uo);return p.length===0?e.createElement(ve,{className:l.noResults},e.createElement(y,null,"No similar structures found")):e.createElement("div",{className:l.root},e.createElement(y,{variant:"subtitle2"},"Found ",d.length," similar structures",d.length>p.length?` (showing top ${p.length})`:""),e.createElement(_e,{component:ve,className:l.tableContainer},e.createElement(Be,{size:"small",stickyHeader:!0},e.createElement(Ge,null,e.createElement(be,null,e.createElement(P,{className:l.headerCell},"Database"),e.createElement(P,{className:l.headerCell},"Target"),e.createElement(P,{className:l.headerCell},"Organism"),e.createElement(P,{className:l.headerCell},e.createElement(Ve,{title:"Foldseek's estimated probability that the hit is a true structural homolog"},e.createElement("span",null,"Prob"))),e.createElement(P,{className:l.headerCell},e.createElement(Ve,{title:"Percentage of aligned residues whose amino acid is identical; structural hits are often low here"},e.createElement("span",null,"Seq. Id."))),e.createElement(P,{className:l.headerCell},"Coverage"),e.createElement(P,{className:l.headerCell},e.createElement(Ve,{title:"Hits of this score expected by chance in a database this size; smaller is stronger"},e.createElement("span",null,"E-value"))),e.createElement(P,{className:l.headerCell},"Actions"))),e.createElement(Oe,null,p.map((c,g)=>e.createElement(be,{key:`${c.db}-${c.target}-${g}`},e.createElement(P,null,c.db),e.createElement(P,null,c.target),e.createElement(P,null,c.taxName??"-"),e.createElement(P,null,c.prob!=null?`${(c.prob*100).toFixed(1)}%`:"-"),e.createElement(P,null,c.seqId!=null?`${c.seqId.toFixed(1)}%`:"-"),e.createElement(P,null,c.alnLength!=null&&c.qLen!=null?`${(c.alnLength/c.qLen*100).toFixed(1)}%`:"-"),e.createElement(P,null,c.eval!=null?c.eval.toExponential(2):"-"),e.createElement(P,null,e.createElement(Fr,{hit:c,session:n,view:o,feature:i,selectedTranscript:s,userProvidedTranscriptSequence:a,onClose:u}))))))))}),wr=po;T();var mo=m(function({message:t}){return t?e.createElement(y,{variant:"body2",color:"warning.main"},t):null}),ne=mo;T();var fo=m(function({val:t,setVal:n,isoforms:o,ranking:i,structureSequence:s,feature:a,disabled:u,size:l}){let d=Ee(a),p=new Map(o.map(f=>[f.id(),f])),c=f=>me(p.get(f))||f,{matches:g,nonMatches:v,noData:k}=i,C=s?Fe(s).length:void 0,S=({id:f,length:b,identical:I},L=I===void 0?"":` (${I}/${C} structure residues identical)`)=>e.createElement(Q,{value:f,key:f},d," - ",c(f)," (",b,"aa)",L);return e.createElement(_,{value:t??"",onChange:f=>{n(f.target.value)},label:"Choose transcript isoform",select:!0,disabled:u,size:l},g.map(f=>S(f," (matches structure residues)")),v.map(f=>S(f)),k.map(f=>e.createElement(Q,{value:f,key:f,disabled:!0},d," - ",c(f)," (no data)")))}),Te=fo;T();function tt(){let[r,t]=h(),[n,o]=h(),[i,s]=h(!1),[a,u]=h(!1),[l,d]=h(),[p,c]=h(""),g=Tt(null);Pe(()=>()=>{g.current?.abort()},[]);let v=()=>{g.current?.abort();let b=new AbortController;return g.current=b,b.signal},k=async b=>{let I=v();u(!0),d(void 0),c("Predicting 3Di structure...");try{let L=await Wt(b,{signal:I});return o(L),L}catch(L){I.aborted||(console.error(L),d(L));return}finally{I.aborted||(u(!1),c(""))}},C=async(b,I,L)=>{let F=v();s(!0),d(void 0),c("Submitting search...");try{let N=await Kt({aaSequence:b,di3Sequence:I,databases:L},{signal:F}),G=await Zt(N.id,{onStatus:c,signal:F});return t(G),G}catch(N){F.aborted||(console.error(N),d(N));return}finally{F.aborted||(s(!1),c(""))}},S=()=>{g.current?.abort(),g.current=null,s(!1),u(!1),c("")},f=()=>{S(),t(void 0),o(void 0),d(void 0)};return{results:r,cleanedAaSequence:n?.aaSequence,di3Sequence:n?.di3Sequence,isLoading:i,isPredicting:a,error:l,statusMessage:p,predictStructure:k,search:C,cancel:S,reset:f}}function Ce({feature:r,view:t}){let{data:n,error:o,isLoading:i}=E(["isoform-sequences",r.id(),t?.assemblyNames?.[0]],async()=>{let a=Ae(r),u=await Yt({transcripts:a,session:oe(t),assemblyName:t?.assemblyNames?.[0]});for(let{feature:d,error:p}of u)p!==void 0&&console.error("[useIsoformProteinSequences] error for",d.id(),p);let l=u.flatMap(d=>d.seq===void 0?[]:[[d.feature.id(),{feature:d.feature,seq:d.seq}]]);return{sequences:Object.fromEntries(l),translated:l.length,total:u.length}},{...M,keepPreviousData:!0}),s=n?n.total-n.translated:0;return{isLoading:i,isoformSequences:n?.sequences,error:o,partialFailure:s>0&&n?`${s} of ${n.total} transcripts have no protein sequence`:void 0}}function rt({view:r,isoforms:t,structureSequences:n}){let o=!!r&&!!n?.length&&t.some(a=>a.seq),{data:i,error:s}=E(o?["isoform-ranking",t,n]:null,()=>Qt({rpcManager:oe(r).rpcManager,name:"ProteinRankIsoforms",args:{isoforms:t,structureSequences:n??[]},inPlace:()=>Re(t,n)}),M);return o?{ranking:i,error:s}:{ranking:Re(t,n)}}T();function go({options:r,isoformSequences:t,ranking:n,preferredTranscriptId:o}){return Me(r,t).some(i=>i.id===o&&i.seq)?o:n&&Jt(n,er(r))}function ot({options:r,isoformSequences:t,ranking:n,preferredTranscriptId:o,resetKey:i}){let[s,a]=h(),[u,l]=h(i);i!==u&&(l(i),a(void 0));let d=t!==void 0?go({options:r,isoformSequences:t,ranking:n,preferredTranscriptId:o}):void 0;return{userSelection:s??d,setUserSelection:a}}function le({feature:r,view:t,structureSequences:n,preferredTranscriptId:o,resetKey:i}){let s=Ae(r),{isoformSequences:a,isLoading:u,error:l,partialFailure:d}=Ce({feature:r,view:t}),{ranking:p,error:c}=rt({view:t,isoforms:Me(s,a),structureSequences:n}),{userSelection:g,setUserSelection:v}=ot({options:s,isoformSequences:a,ranking:p?.ranking,preferredTranscriptId:o,resetKey:i}),k=s.find(S=>S.id()===g),C=g?a?.[g]:void 0;return{transcripts:s,isoformSequences:a,structureSequence:p?.structureSequence,ranking:p?.ranking,isLoading:u,isRanking:!!a&&!p&&!c&&!g,error:l??c,partialFailure:d,selectedTranscriptId:g,setSelectedTranscriptId:v,selectedTranscript:k,selectedIsoform:C}}var ho=D()({dialogContent:{width:"80em",display:"flex",flexDirection:"column",gap:20},sequenceInput:{fontFamily:"monospace"},di3Section:{display:"flex",flexDirection:"column",gap:8,alignItems:"flex-start"}}),yo=m(function({feature:t,preferredTranscriptId:n,session:o,view:i,handleClose:s}){let{classes:a}=ho(),[u,l]=h(),[d,p]=h(Vt),[c,g]=h(!1),{results:v,cleanedAaSequence:k,di3Sequence:C,isLoading:S,isPredicting:f,error:b,statusMessage:I,predictStructure:L,search:F,cancel:N,reset:G}=tt(),{transcripts:q,isoformSequences:B,ranking:j,isLoading:U,error:$,partialFailure:V,selectedTranscriptId:x,setSelectedTranscriptId:J,selectedTranscript:re,selectedIsoform:z}=le({feature:t,view:i,preferredTranscriptId:n}),X=z?It(z.seq):"",O=u??X,ue=()=>{(C!==void 0||v!==void 0)&&G()},de=ae=>{J(ae),l(void 0),ue()},R=S||f,se=Ht(O),w=zt(O).length>0&&!se&&d.length>0&&!R,ce=async()=>{let ae=k&&C?{aaSequence:k,di3Sequence:C}:await L(O.trim());ae&&await F(ae.aaSequence,ae.di3Sequence,d)},yt=b??$;return e.createElement(e.Fragment,null,e.createElement(De,{className:a.dialogContent},yt&&!U?e.createElement(H,{error:yt}):null,U?e.createElement(W,{variant:"subtitle2",message:"Loading transcript sequences"}):null,e.createElement(ne,{message:V}),B&&j?e.createElement(e.Fragment,null,e.createElement(Te,{val:x,setVal:de,isoforms:q,ranking:j,feature:t,disabled:R}),e.createElement(_,{label:"Protein sequence (amino acids)",multiline:!0,rows:4,value:O,onChange:ae=>{l(ae.target.value),ue()},placeholder:"MKTVRQERLKSIVRILERSKEPVSGAQLAEEL...",disabled:R,error:!!se,helperText:se,slotProps:{input:{className:a.sequenceInput}}})):null,C?e.createElement("div",{className:a.di3Section},e.createElement(ee,{component:"button",type:"button",variant:"body2",onClick:()=>{g(!c)}},c?"Hide 3Di":"Show 3Di"),c?e.createElement(_,{label:"3Di structural alphabet (what the search runs on)",multiline:!0,rows:4,fullWidth:!0,value:C,slotProps:{input:{className:a.sequenceInput,readOnly:!0}}}):null):null,e.createElement(Ir,{selected:d,onChange:p,disabled:R}),I?e.createElement(W,{variant:"subtitle2",message:I}):null,v?e.createElement(wr,{results:v,session:o,view:i,feature:t,selectedTranscript:re,userProvidedTranscriptSequence:z?.seq,onClose:s}):null,e.createElement(y,{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.")),e.createElement(he,null,e.createElement(A,{variant:"contained",color:"secondary",onClick:()=>{s()}},"Close"),R?e.createElement(A,{variant:"outlined",onClick:()=>{N()}},"Cancel search"):null,v?e.createElement(A,{variant:"outlined",onClick:()=>{G()}},"New search"):null,e.createElement(A,{variant:"contained",color:"primary",disabled:!w,onClick:()=>{ce()}},f?"Predicting 3Di...":S?"Searching...":"Search Foldseek")))}),Nr=yo;T();T();var Ar=Xt(Rt("path",{d:"m7 10 5 5 5-5z"}),"ArrowDropDown");T();var bo=m(function({anchorEl:t,onClose:n,options:o}){return e.createElement(Ue,{anchorEl:t,open:!!t,onClose:n,"data-testid":"protein-launch-options-menu"},o.map(i=>e.createElement(Q,{key:i.key,"data-testid":`protein-launch-option-${i.key}`,onClick:i.onClick},e.createElement(ar,{primary:i.title,secondary:i.description}))))}),Er=bo;var So=m(function({handleClose:t,ready:n,uniprotId:o,userSelectedProteinSequence:i,selectedTranscript:s,sources:a,confidenceUrl:u,feature:l,view:d,session:p,sideBySide:c}){let[g,v]=h(null),k=()=>{v(null)},{runLaunch:C,launchError:S,launching:f}=xe(t,k),b=n&&!f,I=C(()=>Se({session:p,view:d,feature:l,selectedTranscript:s,uniprotId:o,sources:a,userProvidedTranscriptSequence:i?.seq,sideBySide:c})),{launch1D:L}=ze({session:p,view:d,feature:l,selectedTranscript:s,uniprotId:o,confidenceUrl:u}),F=[{key:"3d",title:ke["3d"],description:"View protein structure with genome-to-structure coordinate mapping",onClick:I},...L?[{key:"1d",title:ke["1d"],description:"View protein features and annotations as a linear track",onClick:C(L)}]:[]];return e.createElement(e.Fragment,null,S?e.createElement(H,{error:S}):null,e.createElement(A,{variant:"contained",color:"secondary",size:"small",onClick:()=>{t()}},"Cancel"),e.createElement(or,{variant:"contained",color:"primary",size:"small"},e.createElement(A,{"data-testid":"protein-launch-button",disabled:!b,onClick:I},"Launch"),e.createElement(A,{"data-testid":"protein-launch-options-button",disabled:!b,onClick:N=>{v(N.currentTarget)},"aria-label":"More launch options"},e.createElement(Ar,null))),e.createElement(Er,{anchorEl:g,onClose:k,options:F}))}),Mr=So;T();var ko=m(function(){return e.createElement(y,{variant:"body2",sx:{mr:2}},"Transcript and structure sequences differ, will run"," ",Ct[vt]," alignment")}),je=ko;T();T();var xo="32px 150px minmax(0, 1fr) 170px 150px",Ie=D()(r=>{let t=r.palette.mode==="dark";return{row:{display:"grid",gridTemplateColumns:xo,gap:12,alignItems:"center",padding:"6px 24px 6px 16px",borderBottom:`1px solid ${r.palette.divider}`,cursor:"pointer","&:hover":{backgroundColor:r.palette.action.hover}},checked:{backgroundColor:r.palette.action.selected},idCell:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:3},id:{fontFamily:"monospace",fontWeight:600,whiteSpace:"nowrap"},badge:{fontSize:"0.65rem",fontWeight:600,letterSpacing:"0.05em",textTransform:"uppercase",padding:"0 6px",borderRadius:3},experimental:{color:t?"#8fd19c":"#2f6b3a",background:t?"#1c2e21":"#e4f1e6"},predicted:{color:t?"#f0c27a":"#7a4c0f",background:t?"#33281a":"#fbf0dc"},what:{display:"flex",flexDirection:"column",gap:4,minWidth:0},tags:{display:"flex",flexWrap:"wrap",gap:4},tag:{fontSize:"0.72rem",padding:"0 6px",border:`1px solid ${r.palette.divider}`,borderRadius:3,color:r.palette.text.secondary},partner:{color:r.palette.text.primary,borderColor:r.palette.primary.main},ligand:{fontFamily:"monospace"},quality:{display:"flex",flexDirection:"column",gap:2,fontVariantNumeric:"tabular-nums"},dot:{display:"inline-block",width:9,height:9,borderRadius:2,marginRight:5},coverage:{display:"flex",flexDirection:"column",gap:3,fontVariantNumeric:"tabular-nums"},bar:{position:"relative",height:8,border:`1px solid ${r.palette.divider}`,borderRadius:2},span:{position:"absolute",top:0,bottom:0,background:r.palette.primary.main,borderRadius:1}}});function To(r){let{domain:t,range:n}=pr.plddt;return n[t.filter(o=>r>o).length]}var Dr=m(function({value:t}){let{classes:n}=Ie();return t===void 0?null:e.createElement(y,{variant:"body2"},e.createElement("span",{className:n.dot,style:{background:To(t)}}),"pLDDT ",t.toFixed(1))}),vo=m(function({row:t}){let{classes:n}=Ie(),o=t.kind==="alphafold"?/model_v(\d+)/.exec(t.model.url)?.[1]:void 0;return e.createElement("div",{className:n.quality},t.kind==="alphafold"?e.createElement(e.Fragment,null,e.createElement(Dr,{value:t.model.meanPlddt}),e.createElement(y,{variant:"caption",color:"textSecondary"},"AlphaFold DB",o?` v${o}`:"")):t.kind==="dataset"?e.createElement(e.Fragment,null,e.createElement(y,{variant:"body2"},t.match.dataset.name),t.match.dataset.description?e.createElement(y,{variant:"caption",color:"textSecondary"},t.match.dataset.description):null):t.kind==="complex"?e.createElement(e.Fragment,null,t.complex.iptm===void 0?null:e.createElement(y,{variant:"body2"},"ipTM ",t.complex.iptm.toFixed(2)),e.createElement(Dr,{value:t.complex.meanPlddt})):e.createElement(e.Fragment,null,e.createElement(y,{variant:"body2"},t.entry.method,t.entry.resolution===void 0?"":` \xB7 ${t.entry.resolution.toFixed(2)} \xC5`),e.createElement(y,{variant:"caption",color:"textSecondary"},t.entry.chains.length===1?"chain":"chains"," ",t.entry.chains.join(", "))))}),Co=m(function({start:t,end:n,length:o}){let{classes:i}=Ie(),s=(n-t+1)/o;return e.createElement("div",{className:i.coverage},e.createElement("div",{className:i.bar,"aria-hidden":!0},e.createElement("span",{className:i.span,style:{left:`${(t-1)/o*100}%`,width:`${Math.min(s,1)*100}%`}})),e.createElement(y,{variant:"caption",color:"textSecondary"},t,"\u2013",n," of ",o," \xB7 ",Math.round(s*100),"%"))}),nt=m(function({tags:t,className:n}){let{classes:o,cx:i}=Ie();return e.createElement(e.Fragment,null,t.map(s=>e.createElement("span",{key:s.label,className:i(o.tag,n),title:s.title},s.label)))}),Io=m(function({row:t,checked:n,uniprotLength:o,onToggle:i}){let{classes:s,cx:a}=Ie(),u=t.partners.length+t.ligands.length+t.notes.length>0;return e.createElement("div",{className:a(s.row,n&&s.checked),"data-testid":`structure-row-${t.key}`,onClick:i},e.createElement(fe,{size:"small",checked:n,onClick:l=>{l.stopPropagation()},onChange:i,slotProps:{input:{"aria-label":`Open ${t.label}`}}}),e.createElement("div",{className:s.idCell},e.createElement(ee,{href:t.href,target:"_blank",rel:"noreferrer",variant:"body2",className:s.id,onClick:l=>{l.stopPropagation()}},t.label),e.createElement("span",{className:a(s.badge,t.predicted?s.predicted:s.experimental)},t.predicted?"Predicted":"Experimental")),e.createElement("div",{className:s.what},e.createElement(y,{variant:"body2"},t.title),u?e.createElement("div",{className:s.tags},e.createElement(nt,{tags:t.partners,className:s.partner}),e.createElement(nt,{tags:t.ligands,className:s.ligand}),e.createElement(nt,{tags:t.notes})):null),e.createElement(vo,{row:t}),t.kind==="dataset"?e.createElement(y,{variant:"caption",color:"textSecondary"},"listed as ",t.match.structure.id):e.createElement(Co,{start:t.start,end:t.end,length:o}))}),Ur=Io;var Lo=.5,Po={ADP:"ADP",AMP:"AMP",ANP:"AMP-PNP",ATP:"ATP",CA:"Ca\xB2\u207A",CD:"Cd\xB2\u207A",CO:"Co\xB2\u207A",CU:"Cu\xB2\u207A",FAD:"FAD",FE:"Fe\xB3\u207A",FE2:"Fe\xB2\u207A",GCP:"GppCp",GDP:"GDP",GNP:"GppNHp",GSP:"GTP\u03B3S",GTP:"GTP",HEM:"heme",MG:"Mg\xB2\u207A",MN:"Mn\xB2\u207A",NAD:"NAD\u207A",NAP:"NADP\u207A",NDP:"NADPH",NI:"Ni\xB2\u207A",SAH:"SAH",SAM:"SAM",ZN:"Zn\xB2\u207A"},Fo=["ATP","ADP","CoA","DNA","EM","Fab","GDP","GTP","HLA","MHC","mRNA","NAD","NADP","NMR","RNA","scFv","TCR","tRNA"];function wo(r,t=[]){let n=new Map([...Fo,...t].map(i=>[i.toUpperCase(),i])),o=r.replace(/[A-Za-z0-9]+(?:[-*:'.][A-Za-z0-9]+)*/g,i=>/\d/.test(i)?i:i.replace(/[A-Za-z]+/g,s=>n.get(s)??s.toLowerCase()));return r===r.toUpperCase()?o.charAt(0).toUpperCase()+o.slice(1):r}function No(r){return r.ligands.filter(t=>!mr.has(t.id)).map(t=>({label:Po[t.id]??t.id,title:t.name}))}function Ao(r,t){let n=Bt(r,t),o=n.filter(a=>a.type==="Protein"),i=n.filter(a=>a.type!=="Protein"),s=[...o.map(a=>({label:a.description??a.entityId,title:a.uniprotIds.join(", ")||void 0})),...[...new Set(i.map(a=>a.type??"Other"))].map(a=>({label:a,title:i.filter(u=>(u.type??"Other")===a).map(u=>u.description??u.entityId).join(`
2
2
  `)}))];return{tags:s.filter((a,u)=>s.findIndex(l=>l.label===a.label)===u),withProtein:o.length>0}}function Eo({entry:r,summary:t,geneName:n,uniprotId:o}){let i=t?Ao(t,o):void 0,s=t?No(t):[],a=r.pdbId.toUpperCase();return{kind:"pdb",key:`pdb:${r.pdbId}`,entry:r,section:r.coverage<Lo?"fragment":i?.withProtein?"partner":"alone",predicted:!1,label:a,href:Et(r.pdbId),title:t?.title?wo(t.title,[n,...t.ligands.map(u=>u.id)]):`PDB entry ${a}`,partners:i?.tags??[],ligands:s,notes:[],start:r.start,end:r.end}}function $r(r){return`https://alphafold.ebi.ac.uk/entry/${r}`}function Mo({complex:r,geneName:t,uniprotId:n,uniprotLength:o}){let i=n.replace(/-\d+$/,""),s=r.homomer?[]:r.members.filter(a=>a.accession!==i);return{kind:"complex",key:`complex:${r.entity}`,complex:r,section:"partner",predicted:!0,label:r.entity,href:$r(r.entity),title:r.homomer?r.name??`${t} ${r.oligomericState??"homomer"}`:`${t} with ${s.map(a=>a.description??a.gene??a.accession).join(", ")}`,partners:s.map(a=>({label:a.gene??a.accession,title:[a.description,a.accession].filter(Boolean).join(", ")})),ligands:[],notes:[{label:`${r.homomer?"homo":"hetero"}${r.oligomericState??"mer"}`}],start:1,end:o}}function Do({model:r,uniprotId:t,uniprotLength:n}){let o=r.accession!==t.replace(/-\d+$/,"");return{kind:"alphafold",key:"alphafold",model:r,section:"alone",predicted:!0,label:`AF-${r.accession}-F1`,href:$r(r.accession),title:o?`AlphaFold model of isoform ${r.accession}`:"AlphaFold model of the full-length protein",partners:[],ligands:[],notes:[],start:1,end:Math.min(r.sequence?.length??n,n)}}function qr(r){return decodeURIComponent(new URL(r).pathname.split("/").pop()??r)}function Br({match:r,geneName:t,uniprotLength:n}){let{dataset:o,structure:i,transcript:s}=r;return{kind:"dataset",key:`dataset:${o.datasetId}:${i.id}:${qr(i.url)}`,match:r,section:"alone",predicted:!0,label:i.label??qr(i.url),href:i.url,title:s?`${o.name} model of transcript ${me(s)||i.id}`:`${o.name} model of ${t}`,partners:[],ligands:[],notes:[],start:1,end:n}}function Or({geneName:r,uniprotId:t,uniprotLength:n,alphaFold:o,entries:i=[],summaries:s,complexes:a=[]}){return[...o?[Do({model:o,uniprotId:t,uniprotLength:n})]:[],...i.map(u=>Eo({entry:u,summary:s?.get(u.pdbId),geneName:r,uniprotId:t})),...a.map(u=>Mo({complex:u,geneName:r,uniprotId:t,uniprotLength:n}))]}function it(r,t){return t==="all"||t==="predicted"===r.predicted}function _r(r,t,n){let o=new Set(n.filter(i=>i.section==="fragment").map(i=>i.key));return r.includes(t.key)?r.filter(i=>i!==t.key):t.section==="fragment"?[t.key]:[...r.filter(i=>!o.has(i)),t.key]}var st=["alone","partner","fragment"];function at(r){return st.flatMap(t=>r.filter(n=>n.section===t))}function Gr(r){let t=r.find(n=>n.kind==="dataset")??r.find(n=>n.kind==="alphafold")??at(r)[0];return t?[t.key]:[]}var Vr=D()(r=>({list:{flex:"1 1 auto",minHeight:160,overflowY:"auto",borderTop:`1px solid ${r.palette.divider}`},header:{position:"sticky",top:0,zIndex:1,display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:12,padding:"8px 24px 4px",background:r.palette.background.paper,borderBottom:`1px solid ${r.palette.divider}`},heading:{fontSize:"0.8rem",fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:r.palette.text.secondary},line:{padding:"6px 24px",borderBottom:`1px solid ${r.palette.divider}`}})),Uo=5;function qo(r,t){return r==="alone"?{title:`${t} on its own`,note:"whole protein or most of it, with any bound nucleotide or drug"}:r==="partner"?{title:`${t} with another protein`,note:"experimental complexes first, then AlphaFold DB predictions"}:{title:"Short fragments",note:"under half the protein, so each opens on its own"}}var $o=m(function({section:t,geneName:n,rows:o,status:i,checked:s,uniprotLength:a,onToggle:u}){let{classes:l}=Vr(),[d,p]=h(!1),{title:c,note:g}=qo(t,n),v=t==="fragment"&&!d&&!o.some(b=>s.includes(b.key)),k=t==="alone"&&!d?o.slice(0,Uo):o,C=o.length-k.length,S=i?.loading??[],f=i?.notices??[];return o.length+S.length+f.length===0?null:e.createElement("div",{"data-testid":`structure-section-${t}`},e.createElement("div",{className:l.header},e.createElement("span",{className:l.heading},c," \xB7 ",o.length),e.createElement(y,{variant:"caption",color:"textSecondary"},g)),v?o.length>0?e.createElement("div",{className:l.line},e.createElement(ee,{component:"button",variant:"body2",onClick:()=>{p(!0)}},"Show ",o.length," short fragment",o.length===1?"":"s")):null:e.createElement(e.Fragment,null,k.map(b=>e.createElement(Ur,{key:b.key,row:b,checked:s.includes(b.key),uniprotLength:a,onToggle:()=>{u(b)}})),C>0?e.createElement("div",{className:l.line},e.createElement(ee,{component:"button",variant:"body2",onClick:()=>{p(!0)}},"Show ",C," more")):null),S.map(b=>e.createElement("div",{className:l.line,key:b},e.createElement(W,{variant:"body2",message:b}))),f.map(b=>e.createElement(y,{key:b,className:l.line,variant:"body2",color:"textSecondary"},b)))}),Bo=m(function({rows:t,sections:n,geneName:o,checked:i,uniprotLength:s,onToggle:a}){let{classes:u}=Vr();return e.createElement("div",{className:u.list,"data-testid":"structure-list"},st.map(l=>e.createElement($o,{key:l,section:l,geneName:o,rows:t.filter(d=>d.section===l),status:n?.[l],checked:i,uniprotLength:s,onToggle:a})))}),zr=Bo;T();T();T();var Oo=m(function({recognizedIds:t,geneName:n,selectedId:o,onSelectedIdChange:i}){let[s,a]=h(!1),u=[{value:"auto",label:"Auto (try all)"},...t.map(l=>({value:l,label:Ot(l)}))];return n&&u.push({value:`gene:${n}`,label:`${n} (gene name)`}),t.length===0&&!n?null:s?e.createElement(ye,{size:"small"},e.createElement(sr,null,"Query UniProt by"),e.createElement(lr,{value:o,label:"Query UniProt by",onChange:l=>{i(l.target.value)}},u.map(l=>e.createElement(Q,{key:l.value,value:l.value},l.label)))):e.createElement(A,{size:"small",variant:"text",onClick:()=>{a(!0)}},"Choose identifier to query...")}),Hr=Oo;T();var _o=["auto","manual","feature"];function Go(r){return _o.some(t=>t===r)}var Vo=m(function({lookupMode:t,onLookupModeChange:n,manualUniprotId:o,onManualUniprotIdChange:i,manualUniprotIdInvalid:s,featureUniprotId:a,hasSearchableIdentifier:u=!0,endContent:l}){return e.createElement(e.Fragment,null,e.createElement("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap"}},e.createElement(ye,{component:"fieldset"},e.createElement(qe,{row:!0,value:t,onChange:d=>{Go(d.target.value)&&n(d.target.value)}},a&&e.createElement(Z,{value:"feature",control:e.createElement(te,null),label:`From feature (${a})`}),u&&e.createElement(Z,{value:"auto",control:e.createElement(te,null),label:"Look up from the feature's identifiers"}),e.createElement(Z,{value:"manual",control:e.createElement(te,null),label:"Enter manually"}))),l),t==="manual"&&e.createElement("div",null,e.createElement(_,{autoFocus:!0,label:"UniProt ID",variant:"outlined",placeholder:"e.g. P68871",size:"small",value:o,error:s,helperText:s?fr:void 0,onChange:d=>{i(d.target.value)}})),t==="manual"&&!o&&e.createElement(y,{variant:"body2",color:"text.secondary"},"Search"," ",e.createElement(Y,{href:"https://www.uniprot.org/"},"UniProt")," or ",e.createElement(Y,{href:"https://alphafold.ebi.ac.uk/"},"AlphaFoldDB")))}),jr=Vo;var zo=D()({endRow:{display:"flex",flexDirection:"row",gap:12,alignItems:"flex-start"}}),Ho=m(function({lookup:t}){let{classes:n}=zo();return e.createElement(e.Fragment,null,e.createElement(jr,{lookupMode:t.lookupMode,onLookupModeChange:t.setLookupMode,manualUniprotId:t.manualUniprotId,onManualUniprotIdChange:t.setManualUniprotId,manualUniprotIdInvalid:t.manualUniprotIdInvalid,featureUniprotId:t.featureUniprotId,hasSearchableIdentifier:t.hasSearchableIdentifier,endContent:t.showIdentifierSelector?e.createElement("div",{className:n.endRow},e.createElement(Hr,{recognizedIds:t.recognizedIds,geneName:t.geneName,selectedId:t.selectedQueryId,onSelectedIdChange:t.setSelectedQueryId}),e.createElement(_,{size:"small",label:"NCBI taxon id",error:t.taxonIdError,helperText:t.taxonIdError?"Not a taxon id; searching every species":"Narrows the gene-name search to one species",value:t.taxonId,onChange:o=>{t.setTaxonId(o.target.value)},placeholder:"e.g. 9606",slotProps:{inputLabel:{shrink:!0}},sx:{width:180}})):null}),t.showIdentifierSelector?e.createElement(y,{variant:"body2",color:"textSecondary"},t.organismDescription):null,t.nothingToSearch?e.createElement(y,{variant:"body2",color:"textSecondary"},"This feature carries no Ensembl, RefSeq, CCDS or HGNC identifier and no gene name; enter a UniProt accession"):null,e.createElement(ne,{message:t.lookupPartialFailure}))}),Wr=Ho;T();T();var jo=D()(r=>({tableContainer:{maxHeight:200},headerCell:{fontWeight:"bold",backgroundColor:r.palette.mode==="dark"?r.palette.grey[900]:r.palette.grey[100]},selectedRow:{backgroundColor:r.palette.action.selected},clickableRow:{cursor:"pointer","&:hover":{backgroundColor:r.palette.action.hover}},reviewedChip:{backgroundColor:r.palette.success.main,color:r.palette.success.contrastText,fontSize:"0.7rem",height:20},unreviewedChip:{backgroundColor:r.palette.warning.main,color:r.palette.warning.contrastText,fontSize:"0.7rem",height:20}})),Wo=m(function({entries:t,selectedAccession:n,onSelect:o}){let{classes:i,cx:s}=jo();return t.length===0?null:e.createElement("div",null,e.createElement(y,{variant:"body2",sx:{mb:1}},"Found ",t.length," UniProt entries. Select one:"),e.createElement(_e,{component:ve,className:i.tableContainer},e.createElement(Be,{size:"small",stickyHeader:!0,"data-testid":"uniprot-results-table"},e.createElement(Ge,null,e.createElement(be,null,e.createElement(P,{className:i.headerCell,padding:"checkbox"}),e.createElement(P,{className:i.headerCell},"Accession"),e.createElement(P,{className:i.headerCell},"Gene"),e.createElement(P,{className:i.headerCell},"Organism"),e.createElement(P,{className:i.headerCell},"Protein"),e.createElement(P,{className:i.headerCell},"Status"))),e.createElement(Oe,null,t.map(a=>e.createElement(be,{key:a.accession,onClick:()=>{o(a.accession)},className:s(i.clickableRow,n===a.accession&&i.selectedRow)},e.createElement(P,{padding:"checkbox"},e.createElement(te,{checked:n===a.accession,size:"small"})),e.createElement(P,null,e.createElement(Y,{href:Ne(a.accession)},a.accession)),e.createElement(P,null,a.geneName??"-"),e.createElement(P,null,a.organismName??"-"),e.createElement(P,null,a.proteinName?a.proteinName.length>40?`${a.proteinName.slice(0,40)}...`:a.proteinName:"-"),e.createElement(P,null,e.createElement(ge,{label:a.isReviewed?"Reviewed":"Unreviewed",size:"small",className:a.isReviewed?i.reviewedChip:i.unreviewedChip}))))))))}),Kr=Wo;var Zr=m(function(){return e.createElement(Y,{href:"https://www.uniprot.org/"},"UniProt")}),Ko=m(function({lookup:t}){let n=t.uniprotEntries.length>0;return t.isAutoMode?n?e.createElement(e.Fragment,null,e.createElement(y,{variant:"body2",color:"textSecondary"},"Searched UniProt by ",t.searchDescription),e.createElement(Kr,{entries:t.uniprotEntries,selectedAccession:t.selectedTableAccession,onSelect:t.setSelectedUniprotId}),e.createElement(y,{variant:"body2",color:"textSecondary"},"If you don't see the entry you're looking for, try a different identifier above or search ",e.createElement(Zr,null),' directly and use "Enter manually".')):t.isLookupLoading||t.lookupError?null:e.createElement(y,{variant:"body2",color:"textSecondary"},"No UniProt entries found for ",t.searchDescriptionOr,". Try a different identifier above, or search ",e.createElement(Zr,null),' directly and use "Enter manually".'):null}),Yr=Ko;var Zo=D()(r=>({bar:{flex:"none",display:"flex",flexWrap:"wrap",alignItems:"center",gap:"4px 12px",padding:"8px 24px",background:r.palette.mode==="dark"?r.palette.grey[900]:r.palette.grey[100]},accession:{fontFamily:"monospace",fontWeight:600},reviewed:{backgroundColor:r.palette.success.main,color:r.palette.success.contrastText,fontSize:"0.7rem",height:20},unreviewed:{backgroundColor:r.palette.warning.main,color:r.palette.warning.contrastText,fontSize:"0.7rem",height:20},panel:{flex:"none",maxHeight:"40vh",overflowY:"auto",display:"flex",flexDirection:"column",gap:12,padding:"4px 24px 12px",background:r.palette.mode==="dark"?r.palette.grey[900]:r.palette.grey[100]}}));function Yo(r){return r.isAutoMode?!r.isLookupLoading&&(!!r.lookupError||!hr(r.uniprotEntries)):!r.uniprotId}var Qo=m(function({lookup:t}){let n=t.uniprotEntries.length;return e.createElement(y,{variant:"body2",color:"textSecondary"},t.lookupMode==="feature"?"named by the feature's own UniProt attribute":t.lookupMode==="manual"?"entered by hand":n===1?`the one UniProt match for ${t.searchDescription}`:`picked from ${n} UniProt matches for ${t.searchDescription}`)}),Jo=m(function({lookup:t}){let{classes:n}=Zo(),[o,i]=h(),s=o??Yo(t),{uniprotId:a}=t,u=t.uniprotEntries.find(l=>l.accession===a);return e.createElement(e.Fragment,null,e.createElement("div",{className:n.bar,"data-testid":"uniprot-summary"},a?e.createElement(e.Fragment,null,e.createElement(y,{variant:"body2"},"Protein"," ",e.createElement(Y,{href:Ne(a),className:n.accession},a),[u?.proteinName,u?.organismName].filter(Boolean).map(l=>` \xB7 ${l}`).join("")),u?e.createElement(ge,{label:u.isReviewed?"Reviewed":"Unreviewed",size:"small",className:u.isReviewed?n.reviewed:n.unreviewed}):null,e.createElement(Qo,{lookup:t})):e.createElement(y,{variant:"body2"},t.isLookupLoading?`Looking up the UniProt entry for ${t.searchDescription}\u2026`:t.lookupMode==="auto"?`No single UniProt entry for ${t.searchDescriptionOr}`:"Enter a UniProt accession to list its structures"),e.createElement(ee,{component:"button",variant:"body2","data-testid":"uniprot-change","aria-expanded":s,onClick:()=>{i(!s)}},s?"Done":"Change")),s?e.createElement("div",{className:n.panel,"data-testid":"uniprot-chooser"},t.lookupError?e.createElement(H,{error:t.lookupError}):null,e.createElement(Wr,{lookup:t}),e.createElement(Yr,{lookup:t})):null)}),Qr=Jo;T();function ie(r,t=300){let[n,o]=h(r);return Pe(()=>{let i=setTimeout(()=>{o(r)},t);return()=>{clearTimeout(i)}},[r,t]),n}T();T();function Xo(r){return[...r].sort((t,n)=>Number(n.homomer)-Number(t.homomer)||(n.iptm??0)-(t.iptm??0))}function Jr(r){let t=r?.replace(/-\d+$/,""),{data:n,error:o,isLoading:i}=E(t?["alphafold-complexes",t]:null,([,u])=>wt(u),M);return{complexes:K(()=>n?Xo(n):void 0,[n]),error:o,isLoading:i}}function Xr(r){let{data:t,error:n,isLoading:o}=E(r?["alphafold-complex-model",r]:null,async([,s])=>{let a=await Nt(s);if(!a)throw new Error(`AlphaFold DB has no files for complex ${s}`);return a},M);return{model:t,error:n,isLoading:o}}T();function lt({uniprotId:r,feature:t,view:n,preferredTranscriptId:o}){let{data:i,isLoading:s,isValidating:a,error:u}=E(r?["alphafold-models",r]:null,([,g])=>Ft(g),{...M,keepPreviousData:!0}),{isoformSequences:l}=Ce({feature:t,view:n}),d=K(()=>r&&(i||u)?gr(r,u?void 0:i,l,o):void 0,[r,i,u,l,o]),p=r?u:void 0,c=r?.replace(/-\d+$/,"");return{isLoading:s,isValidating:a,modelsUnreachable:p,model:d,entryLength:r&&!u?i?.find(g=>g.accession===c)?.sequence.length:void 0,noModel:!!r&&!s&&!u&&i?.length===0}}T();function ut({jbrowse:r,feature:t,preferredTranscriptId:n}){let o=K(()=>yr(r),[r]),i=Sr(r),{data:s,isLoading:a}=E(o.length>0?["structure-datasets",...o.map(d=>`${d.datasetId} ${JSON.stringify(d.mappingLocation)}`)]:null,()=>Promise.allSettled(o.map(d=>kr(d,i))),M),u=K(()=>o.flatMap((d,p)=>{let c=s?.[p];return c?.status==="fulfilled"?br({dataset:d,mapping:c.value,feature:t,preferredTranscriptId:n}):[]}),[o,s,t,n]),l=o.flatMap((d,p)=>{let c=s?.[p];return c?.status==="rejected"?[`${d.name}'s structure list did not load: ${pe(c.reason)}`]:[]});return{matches:u,notices:l,isLoading:a,loadingMessage:`Reading ${o.map(d=>d.name).join(", ")}`}}function dt(r){let{data:t,error:n,isLoading:o}=E(r?["experimental-structures",r]:null,([,i])=>qt(i),M);return{entries:t,error:n,isLoading:o}}function ct(r){let t=r?.map(a=>a.pdbId).join(","),{data:n,error:o,isLoading:i}=E(t?["pdb-entry-summaries",t]:null,([,a])=>$t(a.split(",")),M);return{summaries:n,error:o,isLoading:i}}function Rr(r){return typeof r=="string"}function Ro(r){let t=n=>{let o=r.filter(i=>i.sections.includes(n));return{loading:o.map(i=>i.loading).filter(Rr),notices:o.map(i=>i.notice).filter(Rr)}};return{alone:t("alone"),partner:t("partner"),fragment:t("fragment")}}function pt({jbrowse:r,uniprotId:t,uniprotPending:n,geneName:o,feature:i,view:s,preferredTranscriptId:a}){let u=ut({jbrowse:r,feature:i,preferredTranscriptId:a}),l=lt({uniprotId:t,feature:i,view:s,preferredTranscriptId:a}),d=Jr(t),p=dt(t),c=ct(p.entries),g=p.entries,v=!!g&&(g.length===0||!c.isLoading),k=l.entryLength??l.model?.sequence?.length??Math.max(1,...(g??[]).map(F=>F.end)),C=K(()=>at([...u.matches.map(F=>Br({match:F,geneName:o,uniprotLength:k})),...t?Or({geneName:o,uniprotId:t,uniprotLength:k,alphaFold:l.isLoading?void 0:l.model,entries:v?g:void 0,summaries:c.summaries,complexes:d.complexes}):[]]),[u.matches,t,o,k,l.isLoading,l.model,v,g,c.summaries,d.complexes]),S=["alone","partner","fragment"],f=[{sections:["alone"],loading:u.isLoading&&u.loadingMessage},...u.notices.map(F=>({sections:["alone"],notice:F}))],b=t?[{sections:["alone"],loading:l.isLoading&&"Asking AlphaFold DB for models",notice:l.noModel?`AlphaFold DB has no model for ${t}`:l.modelsUnreachable!==void 0&&`AlphaFold DB's model list did not answer, so its row opens the canonical model file for ${t}, without comparing its sequence to the isoforms`},{sections:S,loading:(p.isLoading||c.isLoading)&&"Listing PDB entries from RCSB",notice:p.error!==void 0&&`RCSB did not list the PDB entries: ${pe(p.error)}`},{sections:["alone","partner"],notice:c.error!==void 0&&`RCSB did not describe the PDB entries, so they are placed by coverage alone: ${pe(c.error)}`},{sections:["alone"],notice:g?.length===0&&`RCSB lists no experimental structure for ${t}`},{sections:["partner"],loading:d.isLoading&&"Asking AlphaFold DB for predicted complexes",notice:d.error!==void 0&&`AlphaFold DB's complex list did not answer: ${pe(d.error)}`}]:[],I=Ro([...f,...b]),L=u.matches.length>0;return{rows:C,uniprotLength:k,sections:I,alphaFold:l,defaultSettled:!u.isLoading&&(L||!n&&!l.isLoading&&(!!l.model||!(p.isLoading||c.isLoading||d.isLoading)))}}T();function mt(r){let{data:t,error:n,isLoading:o,isValidating:i}=E(r?["pdb-entry",r]:null,([,s])=>Pt(s),M);return{entry:t,error:n,isLoading:o,isValidating:i}}async function eo(r){let{PluginContext:t,DefaultPluginSpec:n}=await xr(),o=new t(n());await o.init();try{return await r(o)}finally{o.dispose()}}async function en({file:r,url:t}){let n=r?await He(r):void 0;return eo(async o=>{let i=await Tr({plugin:o,data:n,url:t}),s=await o.builders.structure.createModel(i);return Lt(s)})}function Le({file:r,url:t}){let n=r?["structure-file",r.name,r.size,r.lastModified]:t?["structure-url",t]:null,{data:o,error:i,isLoading:s}=E(n,async()=>{let a=await en({file:r,url:t});if(!a?.length)throw new Error("No protein sequence found in this structure");return a},M);return{error:i,isLoading:s,sequences:o}}function to(r){return r.kind==="alphafold"?{url:r.model.url}:r.kind==="pdb"?{url:At(r.pdbId)}:r.kind==="url"?{url:r.url,uniprotId:r.uniprotId}:{alphaFoldComplexId:r.entity}}function ft({structures:r,uniprotId:t,feature:n,view:o,preferredTranscriptId:i}){let s=r[0],a=mt(s?.kind==="pdb"?s.pdbId:void 0),u=Xr(s?.kind==="complex"?s.entity:void 0),l=Le({url:s?.kind==="url"?s.url:void 0}),d=t?.replace(/-\d+$/,""),p=u.model?.chains,c=p?.find(N=>N.accession===d),g=s?.kind==="alphafold"?s.model.sequence:void 0,v=a.entry?.proteinSequences,k=l.sequences,C=K(()=>s?.kind==="alphafold"?g?[g]:void 0:s?.kind==="pdb"?v:s?.kind==="url"?k:c?[c.sequence]:p?.map(N=>N.sequence),[s?.kind,g,v,k,c,p]),S=le({feature:n,view:o,structureSequences:C,preferredTranscriptId:i,resetKey:s?.key}),f=S.selectedTranscriptId!==i&&(a.isValidating&&!a.error||u.isLoading||l.isLoading),b=[S.isLoading&&"Loading protein sequences from transcript isoforms",S.isRanking&&"Aligning isoforms to the structure",f&&(s?.kind==="pdb"?"Reading the chains of the entry from RCSB":s?.kind==="url"?"Reading residues from the structure":"Asking AlphaFold DB for the complex")].filter(N=>typeof N=="string"),I=b.length>0,L=s?.kind==="alphafold"||s?.kind==="complex"||s?.kind==="url",F=S.selectedIsoform?.seq;return{...S,loadingStatuses:b,isLoading:I,error:I?void 0:S.error??u.error??l.error,pdbEntryError:a.error,sequencesMatch:L&&!u.isLoading&&F&&S.structureSequence?we(F,S.structureSequence):void 0}}T();function tn({attemptedCount:r,failedCount:t}){return t>0&&t<r?`UniProt lookup failed for ${t} of ${r} identifiers`:void 0}function gt({recognizedIds:r=[],geneId:t,geneName:n,organismId:o,selectedQueryId:i="auto",enabled:s=!0}){let a=[],u;i==="auto"?(a=r,u=n):i.startsWith("gene:")?u=i.replace("gene:",""):Qe(i)&&(a=[i]);let l=a.some(g=>Qe(g))||!!u,{data:d,error:p,isLoading:c}=E(s&&l?["uniprotSearch",i,a.join(","),u,t,o]:null,async()=>_t({recognizedIds:a,geneId:t,geneName:u,organismId:o}),{...M,keepPreviousData:!0});return{entries:d?.entries??[],isLoading:c,error:p,partialFailure:d?tn(d):void 0}}function We({selectedQueryId:r,recognizedIds:t,geneName:n,joinWord:o="and"}){return r==="auto"?[t.length>0?`database ID${t.length>1?"s":""} "${t.join('", "')}"`:void 0,n?`gene name "${n}"`:void 0].filter(Boolean).join(` ${o} `):r.startsWith("gene:")?`gene name "${r.replace("gene:","")}"`:`database ID "${r}"`}function rn(r,t){return r===void 0?"Organism: unknown, showing all species; type an NCBI taxon id to narrow":`Organism: ${r} (${t==="user"?"typed above":"from assembly"})`}function ht({feature:r,view:t,preferredTranscriptId:n}){let o=rr(r,n),i=o.uniprotId,s=o.recognizedIds.length>0||!!o.geneName,[a,u]=h(()=>i?"feature":s?"auto":"manual"),[l,d]=h(""),[p,c]=h(""),g=t.assemblyNames[0],v=g?oe(t).assemblyManager.get(g)?.configuration:void 0,k=v?tr(bt(v,["sequence","metadata"])):void 0,C=ie(p.trim(),400),S=Number(C),f=C!==""&&Number.isFinite(S)&&S>0,b=f?S:k,I=C!==""&&!f,[L,F]=h("auto"),[N,G]=h(),q=a==="auto",{entries:B,isLoading:j,error:U,partialFailure:$}=gt({recognizedIds:o.recognizedIds,geneId:o.geneId,geneName:o.geneName,organismId:b,selectedQueryId:L,enabled:q}),V=ie(l,400),J=j||a==="manual"&&l!==V,re=B.some(O=>O.accession===N)?N:void 0,z=B[0]?.accession,X=a==="feature"?i:q?re??z:et(V)?V:void 0;return{lookupMode:a,setLookupMode:u,manualUniprotId:l,setManualUniprotId:O=>{d(O.trim().toUpperCase())},manualUniprotIdInvalid:l!==""&&!et(l),taxonId:p,setTaxonId:c,taxonIdError:I,organismDescription:rn(b,f?"user":"assembly"),selectedQueryId:L,setSelectedQueryId:F,setSelectedUniprotId:G,selectedTableAccession:re??z,uniprotEntries:B,isLookupLoading:J,lookupError:U,lookupPartialFailure:$,uniprotId:X,featureUniprotId:i,recognizedIds:o.recognizedIds,geneName:o.geneName,isAutoMode:q,hasSearchableIdentifier:s,nothingToSearch:!s&&!i,showIdentifierSelector:q&&s,searchDescription:We({selectedQueryId:L,recognizedIds:o.recognizedIds,geneName:o.geneName}),searchDescriptionOr:We({selectedQueryId:L,recognizedIds:o.recognizedIds,geneName:o.geneName,joinWord:"or"})}}var on=D()(r=>({root:{width:"80em",maxWidth:"100%",maxHeight:"calc(100vh - 180px)",display:"flex",flexDirection:"column"},toolbar:{flex:"none",display:"flex",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",gap:10,padding:"8px 24px"},chips:{display:"flex",gap:6},footer:{flex:"none",display:"flex",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",gap:12,padding:"8px 24px",borderTop:`1px solid ${r.palette.divider}`},summary:{display:"flex",flexDirection:"column",gap:6,minWidth:0,flex:"1 1 400px"},actions:{padding:0,flexWrap:"wrap"}})),nn=[{filter:"all",label:"All"},{filter:"experimental",label:"Experimental"},{filter:"predicted",label:"Predicted"}];function sn(r){return r.kind==="alphafold"?{key:r.key,kind:"alphafold",model:r.model}:r.kind==="pdb"?{key:r.key,kind:"pdb",pdbId:r.entry.pdbId}:r.kind==="dataset"?{key:r.key,kind:"url",url:r.match.structure.url,uniprotId:r.match.structure.uniprotId}:{key:r.key,kind:"complex",entity:r.complex.entity}}function an(r,t,n){let[o,...i]=r;return t?`PDB ${t.toUpperCase()}, typed above, in place of the checked rows`:o?i.length>0?`${r.map(s=>s.label).join(" + ")}, superposed onto ${o.label}`:o.section==="fragment"?`${o.label}, a short fragment, on its own`:`${o.label}: ${o.title}`:n?"Finding structures\u2026":"Check a structure to open it"}var ln=m(function({feature:t,geneName:n,preferredTranscriptId:o,session:i,view:s,handleClose:a}){let{classes:u}=on(),l=ht({feature:t,view:s,preferredTranscriptId:o}),{uniprotId:d}=l,p=pt({jbrowse:i.jbrowse,uniprotId:d,uniprotPending:l.isLookupLoading,geneName:n,feature:t,view:s,preferredTranscriptId:o}),{rows:c}=p,[g,v]=h("all"),[k,C]=h(),S=k&&k.uniprotId===d?k.keys:void 0,f=!p.defaultSettled,b=S??(f?[]:Gr(c)),I=c.filter(w=>b.includes(w.key)),[L,F]=h(()=>dr()),[N,G]=h(""),q=N.trim(),B=ie(q,400),j=q!==""&&!Ye(q),U=Ye(B)?B.toLowerCase():void 0,$=U?[{key:`typed:${U}`,kind:"pdb",pdbId:U}]:I.map(sn),V=U?void 0:I[0],x=ft({structures:$,uniprotId:d,feature:t,view:s,preferredTranscriptId:(V?.kind==="dataset"?V.match.transcript?.id():void 0)??o}),J=!!U&&x.pdbEntryError instanceof Error&&"status"in x.pdbEntryError&&x.pdbEntryError.status===404,re=q!==B,z=x.isLoading||re||!U&&!S&&f,X=x.error??(J?x.pdbEntryError:void 0),O=Pr({structureCount:$.length,userSelectedProteinSequence:x.selectedIsoform,selectedTranscript:x.selectedTranscript}),ue=!z&&!X&&!j&&O.length===0,de=$.find(w=>w.kind==="alphafold"),R=U&&(l.isLookupLoading||l.lookupError)?void 0:$[0]?.kind==="alphafold"?$[0].model.accession:$[0]?.kind==="url"?$[0].uniprotId??d:d,se=w=>{C({uniprotId:d,keys:_r(b,w,c)})};return e.createElement("div",{className:u.root},e.createElement(Qr,{lookup:l}),e.createElement("div",{className:u.toolbar},e.createElement("div",{className:u.chips,role:"group","aria-label":"Source"},nn.map(w=>e.createElement(ge,{key:w.filter,"data-testid":`structure-filter-${w.filter}`,label:`${w.label} ${c.filter(ce=>it(ce,w.filter)).length}`,color:g===w.filter?"primary":"default",variant:g===w.filter?"filled":"outlined","aria-pressed":g===w.filter,onClick:()=>{v(w.filter)}}))),e.createElement(_,{size:"small",label:"Open by PDB ID",placeholder:"e.g. 1TUP","data-testid":"pdb-id-input",error:j||J,helperText:j?"Four characters beginning with a digit":J?`RCSB has no entry ${B.toUpperCase()}`:void 0,value:N,onChange:w=>{G(w.target.value)},slotProps:{inputLabel:{shrink:!0}},sx:{width:200}})),e.createElement(zr,{rows:c.filter(w=>it(w,g)),sections:p.sections,geneName:n,checked:U?[]:b,uniprotLength:p.uniprotLength,onToggle:w=>{G(""),se(w)}}),e.createElement("div",{className:u.footer},e.createElement("div",{className:u.summary},e.createElement(y,{variant:"body2","data-testid":"launch-summary"},e.createElement("strong",null,an(I,U,!S&&f))),X?e.createElement(H,{error:X}):null,x.loadingStatuses.map(w=>e.createElement(W,{key:w,variant:"caption",message:w})),e.createElement(ne,{message:x.partialFailure}),x.ranking&&x.selectedTranscript?e.createElement(Te,{val:x.selectedTranscriptId,setVal:x.setSelectedTranscriptId,structureSequence:x.structureSequence,feature:t,isoforms:x.transcripts,ranking:x.ranking,size:"small"}):x.selectedTranscript&&x.selectedIsoform?e.createElement(y,{variant:"caption",color:"textSecondary"},"Mapped through transcript"," ",me(x.selectedTranscript)," (",Fe(x.selectedIsoform.seq).length," aa)"):null,x.sequencesMatch===!1?e.createElement(je,null):null,!z&&!X&&O.length>0?e.createElement(y,{variant:"body2",color:"error"},O.join("; ")):null),e.createElement(he,{className:u.actions},e.createElement(Z,{control:e.createElement(fe,{size:"small",checked:L,"data-testid":"protein-launch-side-by-side",onChange:(w,ce)=>{F(ce),cr(ce)}}),label:e.createElement(y,{variant:"body2"},"Open beside the genome view")}),e.createElement(Mr,{handleClose:a,ready:ue,uniprotId:R,userSelectedProteinSequence:x.selectedIsoform,selectedTranscript:x.selectedTranscript,sources:$.map(to),confidenceUrl:de?.kind==="alphafold"?de.model.confidenceUrl:void 0,feature:t,view:s,session:i,sideBySide:L}))))}),ro=ln;T();var un=xt(()=>import("./HelpDialog-ZGLXAIOU.js")),dn=m(function(){let[t,n]=h(!1);return e.createElement(e.Fragment,null,e.createElement(ir,{onClick:()=>{n(!0)}},e.createElement(Cr,null)),t?e.createElement(kt,{fallback:null},e.createElement(un,{handleClose:()=>{n(!1)}})):null)}),Ke=dn;T();var cn=m(function({children:t,value:n,index:o,...i}){let s=n===o,[a,u]=h(s);return s&&!a&&u(!0),e.createElement("div",{role:"tabpanel",hidden:!s,...i},a?t:null)}),Ze=cn;T();T();var pn=m(function({choice:t,setChoice:n,structureURL:o,setStructureURL:i,file:s,setFile:a}){return e.createElement("div",{style:{display:"flex",margin:30}},e.createElement(y,null,"Open your structure file ",e.createElement(Ke,null)),e.createElement(ye,{component:"fieldset"},e.createElement(qe,{value:t,onChange:u=>{n(u.target.value)}},e.createElement(Z,{value:"file",control:e.createElement(te,null),label:"File"}),e.createElement(Z,{value:"url",control:e.createElement(te,null),label:"URL"}))),t==="url"?e.createElement("div",null,e.createElement(y,null,"Open a PDB/mmCIF/etc. file from remote URL"),e.createElement(_,{label:"URL",value:o,onChange:u=>{i(u.target.value)}})):e.createElement("div",{style:{paddingTop:20}},e.createElement(y,null,"Open a PDB/mmCIF/etc. file from your local drive"),e.createElement(A,{variant:"outlined",component:"label"},"Choose file",e.createElement("input",{type:"file",hidden:!0,accept:vr,onChange:({target:u})=>{let l=u.files?.[0];l&&a(l),u.value=""}})),s?e.createElement(y,{variant:"body2"},s.name):null))}),oo=pn;var mn=D()(r=>({dialogContent:{marginTop:r.spacing(6),width:"80em"}})),fn=m(function(){return e.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,"," ",e.createElement(Y,{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.")}),gn=m(function({feature:t,preferredTranscriptId:n,session:o,view:i,handleClose:s}){let{classes:a}=mn(),[u,l]=h(),[d,p]=h("file"),[c,g]=h(""),{runLaunch:v,launchError:k,launching:C}=xe(s),S=d==="file"?u:void 0,f=d==="file"?"":c,b=ie(f,600),{sequences:I,isLoading:L,error:F}=Le({file:S,url:b}),{transcripts:N,isoformSequences:G,structureSequence:q,ranking:B,isRanking:j,selectedTranscriptId:U,setSelectedTranscriptId:$,selectedTranscript:V,selectedIsoform:x,error:J,partialFailure:re}=le({feature:t,view:i,structureSequences:I,preferredTranscriptId:n}),z=k??J??F,ue=!!(f||S)&&!!x&&!!V&&!((L||f!==b||j)&&U!==n)&&!(!!F&&f===b)&&!C,de=!!x?.seq&&!!q&&!we(x.seq,q),R=v(async()=>{if(x&&V){let se=S?await He(S):void 0;await Se({session:o,view:i,feature:t,selectedTranscript:V,sources:[{url:f||void 0,data:se}],userProvidedTranscriptSequence:x.seq})}});return e.createElement(e.Fragment,null,e.createElement(De,{className:a.dialogContent},z?e.createElement(H,{error:z}):null,e.createElement(fn,null),e.createElement(oo,{choice:d,setChoice:p,structureURL:c,setStructureURL:g,file:u,setFile:l}),e.createElement("div",{style:{margin:20}},L?e.createElement(W,{variant:"subtitle2",message:"Reading residues from the structure"}):null,e.createElement(ne,{message:re}),j?e.createElement(W,{variant:"subtitle2",message:"Aligning isoforms to the structure"}):null,G?B?e.createElement(Te,{val:U,setVal:$,structureSequence:q,isoforms:N,feature:t,ranking:B}):null:e.createElement(W,{title:"Loading protein sequences",variant:"h6"}))),e.createElement(he,null,de?e.createElement(je,null):null,e.createElement(A,{variant:"contained",color:"secondary",onClick:()=>{s()}},"Cancel"),e.createElement(A,{variant:"contained",color:"primary",disabled:!ue,onClick:()=>{R()}},"Launch 3D protein structure view")))}),no=gn;var hn=m(function({handleClose:t,feature:n,preferredTranscriptId:o,model:i,view:s}){let[a,u]=h(0),l=oe(i),d=Ee(n)||"this gene";return e.createElement(St,{"data-testid":"launch-protein-view-dialog",maxWidth:"xl",title:"Launch protein view",titleNode:e.createElement(e.Fragment,null,"Launch protein view ",e.createElement(Ke,null)),open:!0,onClose:t},e.createElement(ur,{value:a,onChange:(p,c)=>{u(c)}},e.createElement($e,{value:0,label:`Structures for ${d}`}),e.createElement($e,{value:1,label:"Similar structures (Foldseek)"}),e.createElement($e,{value:2,label:"Your file or URL"})),e.createElement(Ze,{value:a,index:0},e.createElement(ro,{session:l,view:s,feature:n,geneName:d,preferredTranscriptId:o,handleClose:t})),e.createElement(Ze,{value:a,index:1},e.createElement(Nr,{session:l,view:s,feature:n,preferredTranscriptId:o,handleClose:t})),e.createElement(Ze,{value:a,index:2},e.createElement(no,{session:l,view:s,feature:n,preferredTranscriptId:o,handleClose:t})))}),Bu=hn;export{Bu as default};
3
- //# sourceMappingURL=LaunchProteinViewDialog-OMCH6FKM.js.map
3
+ //# sourceMappingURL=LaunchProteinViewDialog-Q6SFXKUZ.js.map
@@ -1,2 +1,2 @@
1
- import{c as v,d as x}from"./chunk-BR44SFC2.js";import{i as Q}from"./chunk-MBUM32YU.js";import{a as Z}from"./chunk-NCH7IJII.js";import{a as z,e as K}from"./chunk-2RFFBSIA.js";import{a as J}from"./chunk-A4XT2SQ7.js";import{i as D,j as Y}from"./chunk-BWZ7PSFU.js";import{a as U}from"./chunk-OU2GWGJP.js";import{d as X,e as ee}from"./chunk-A73LEL2C.js";import{a as b,b as W}from"./chunk-7GELEOAH.js";import{a as G,m as T}from"./chunk-Y5T7GSKP.js";import{a as _,b as B,c as H}from"./chunk-6AA7U2KU.js";import{d as L}from"./chunk-LGVXT66Y.js";import{Db as C,f as O,gb as A}from"./chunk-JKKI7LFR.js";var $="'chr17:7674220 C>T' or 'chr17:7674220'",fe=/^([^\s:]+):([\d,]+)(?:\s*([ACGT])\s*>\s*([ACGT]))?$/i;function ne(e){let t=e.trim(),[,n,r,i,s]=fe.exec(t)??[],c=r?Number(r.replaceAll(",",""))-1:-1,o=i&&s?{ref:i.toUpperCase(),alt:s.toUpperCase()}:void 0;return n&&c>=0&&(!o||o.ref!==o.alt)?{text:t,refName:n,start:c,change:o}:void 0}function me(e,t,n){return`${e}${t}${n===void 0?"":n===e?"=":n}`}function ge({variant:e,mapping:t,onTranscriptChromosome:n,genomeBase:r,codonTable:i,transcriptName:s}){let c=D({...t,genomeBase:r}),o=n?c.at(e.start):void 0,u=o?i[o.codon.join("")]:void 0,{change:a}=e,d=a?Y(c,{start:e.start,...a},i):void 0;if(!o||!u)throw new Error(`\`variant\` ${e.text} is not in the coding sequence of ${s}`);if(u==="*")throw new Error(`\`variant\` ${e.text} is in the stop codon of ${s}, which no residue stands for`);if(a&&d?.kind==="refMismatch")throw new Error(`\`variant\` ${e.text} names ${a.ref} as the reference base, and the genome has ${r(e.start)?.toUpperCase()} there`);let l=o.residue+1;return{transcriptResidue:l,label:me(u,l,d?.kind==="translated"?d.to:void 0)}}function he(e){let t=e.get("name"),n=e.get("id");return t??n??e.id()}function we(e){return[e.initialSelection,e.initialResidues,e.initialTranscriptResidues].some(t=>t!==void 0)}function te(e){return new Error(`\`variant\` ${e.text} is placed through each structure's transcript, and neither the launch nor any structure names one; give \`gene\`, \`transcriptId\` or \`feature\``)}async function Se({variant:e,structures:t,launchFeature:n,place:r}){let i=[...new Set(t.flatMap(a=>a.feature?[a.feature]:[]))];if(i.length===0)throw te(e);let s=await Promise.allSettled(i.map(a=>r(a))),c=new Map(i.flatMap((a,d)=>{let l=s[d];return l?.status==="fulfilled"?[[a,l.value]]:[]})),o=t.map(a=>a.feature?c.get(a.feature):void 0),u=(n?c.get(n):void 0)??o.find(a=>a!==void 0);if(!u){let a=s.flatMap(d=>d.status==="rejected"?[K(d.reason)]:[]);throw new Error([...new Set(a)].join("; "))}return{label:u.label,structures:t.map((a,d)=>{let l=o[d];return l&&!we(a)?{...a,initialTranscriptResidues:{start:l.transcriptResidue,end:l.transcriptResidue}}:a})}}async function Ue({session:e,variant:t,structures:n,launchFeature:r,assemblyName:i}){if(!n.some(a=>a.feature))throw te(t);if(!i)throw new Error(`\`variant\` ${t.text} is highlighted on the connected genome view, and this launch connects none with an assembly`);let s=await e.assemblyManager.waitForAssembly(i);if(!s)throw new Error(`assembly "${i}" not found`);let c=s.getCanonicalRefName(t.refName);if(!c)throw new Error(`\`variant\` ${t.text} names ${t.refName}, which ${i} has no sequence for`);let o=await Se({variant:t,structures:n,launchFeature:r,place:async a=>{let d=new G(a),l=U(d),m=s.getCanonicalRefName(l.refName)===c,p=m?l.g2p[t.start]:void 0,g=[t.start,...p===void 0?[]:l.p2gCodon[p]??[]],h=Math.min(...g),w=Math.max(...g)+1,{seq:k,assemblyGeneticCodeId:S}=await B({session:e,assemblyName:i,refName:c,start:h,end:w});return ge({variant:t,mapping:l,onTranscriptChromosome:m,genomeBase:V=>k?.[V-h],codonTable:J(_(d,S)).codonTable,transcriptName:he(d)})}}),u={assemblyName:i,refName:c,start:t.start,end:t.start+1,label:o.label};return{structures:o.structures,highlight:u}}var R={url:"source",data:"source",uniprotId:"source",alphaFoldComplexId:"source",pdbId:"source",initialSelection:"selection",initialResidues:"selection",initialTranscriptResidues:"selection",mappedEntityId:"setting",pairwiseAlignment:"setting",alignmentImported:"setting",hidden:"setting",assembly:"setting",chains:"setting",filter:"setting",feature:"launchWide",userProvidedTranscriptSequence:"launchWide",connectedViewId:"launchWide"};function P(e){return Object.hasOwn(R,e)}var re=Object.keys(R).filter(P),ye={source:"names no structure; add it as an entry of `structures`",selection:"applies to no structure; put it on the one it selects in",setting:"applies to no structure; put it on the one it describes"};function y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function f(e){return typeof e=="string"}function ke(e){return Array.isArray(e)&&e.every(f)}function I(e){return typeof e=="boolean"}function ie(e){return typeof e=="number"&&Number.isFinite(e)}function ue(e){return y(e)}function be(e){return Array.isArray(e)&&e.every(y)}function Ve(e){return Array.isArray(e)&&e.every(y)}function Le(e){return Array.isArray(e)&&e.every(y)}function Te(e){return e!==void 0&&v(e).length===0}function Re(e){return e!==void 0&&x(e).length===0}function oe(e){return y(e)&&typeof e.start=="number"&&typeof e.end=="number"}function M(e){return Array.isArray(e)?e.every(oe):oe(e)}function Ie(e){return f(e)||y(e)}function Ae(e){return y(e)&&(e.loc===void 0||f(e.loc))&&(e.assembly===void 0||f(e.assembly))&&(e.tracks===void 0||Array.isArray(e.tracks)&&e.tracks.every(Ie))}var N="{ start, end } numbers or an array of them";function F(e,t,n){return function(i,s,c){let o=e.get(i);if(o===void 0||s(o))return o;n.push(`${t(i)} is not ${c} and was ignored`)}}function Ce(e,t){return function(r,i,s){let c=e.get(r),o=c!==void 0&&i(c)?c:void 0;return c!==void 0&&o===void 0&&t.push(`\`${r}\` was ignored: ${s(c).join("; ")}`),o}}var ve=["structures","gene","transcriptId","connectedView","sideBySide","variant"];function xe(e,t){let n=F(e,s=>`\`${s}\``,t),r=e.get("uniprotId"),i=n("variant",f,`a string such as ${$}`);return{gene:n("gene",f,"a string"),transcriptId:n("transcriptId",f,"a string"),uniprotId:f(r)?r:void 0,connectedView:n("connectedView",Ae,"{ assembly, loc, tracks }"),connectedViewId:n("connectedViewId",f,"a string"),sideBySide:n("sideBySide",I,"true or false"),feature:n("feature",ue,"a feature object"),userProvidedTranscriptSequence:n("userProvidedTranscriptSequence",f,"a string"),variant:i===void 0?void 0:ne(i)}}function $e(e,t){let n=F(e,s=>`\`${s}\``,t),r=Ce(e,t),i=s=>n(s,I,"true or false");return{id:n("id",f,"a string"),displayName:n("displayName",f,"a string"),height:n("height",ie,"a number"),trackHeight:n("trackHeight",ie,"a number"),showControls:i("showControls"),showAlignment:i("showAlignment"),showHighlight:i("showHighlight"),showProteinTracks:i("showProteinTracks"),compactTracks:i("compactTracks"),showAllFeatureTracks:i("showAllFeatureTracks"),zoomToBaseLevel:i("zoomToBaseLevel"),autoScrollAlignment:i("autoScrollAlignment"),alignmentAlgorithm:n("alignmentAlgorithm",f,"a string"),color:e.get("color"),colorScheme:n("colorScheme",f,"a string"),camera:r("camera",Te,v),surface:r("surface",Re,x),distances:n("distances",Le,"a list such as [{ a: 'A:46@NZ', b: 'A:80@NZ' }]"),marks:n("marks",Ve,"a list such as [{ site: 'A:248', mark: 'spheres' }]"),silhouettes:i("silhouettes"),occlusion:i("occlusion")}}function se(e,t,n){let r=F(e,t,n);return{url:r("url",f,"a string"),data:r("data",f,"a string"),uniprotId:r("uniprotId",f,"a string"),alphaFoldComplexId:r("alphaFoldComplexId",f,"a string"),pdbId:r("pdbId",f,"a string"),initialSelection:r("initialSelection",M,N),initialResidues:r("initialResidues",M,N),initialTranscriptResidues:r("initialTranscriptResidues",M,N),mappedEntityId:r("mappedEntityId",f,"a string"),pairwiseAlignment:r("pairwiseAlignment",O,"{ consensus, alns: [{ id, seq }, { id, seq }] }"),alignmentImported:r("alignmentImported",I,"true or false"),hidden:r("hidden",I,"true or false"),assembly:r("assembly",f,"a string"),chains:r("chains",ke,"a list of chain ids"),filter:r("filter",be,"a list of predicates such as [{ field: 'residue', lte: 184 }]"),feature:r("feature",ue,"a feature object"),userProvidedTranscriptSequence:r("userProvidedTranscriptSequence",f,"a string"),connectedViewId:r("connectedViewId",f,"a string")}}function ae(e){return!!A(e)||e.data!==void 0||!!e.uniprotId||!!e.alphaFoldComplexId}function ce(e){return{...e,url:A(e)}}function De(e){let t=new Map(Object.entries(e)),n=[],r=$e(t,n),i=xe(t,n),s=new Set([...Object.keys(r),...re,...ve]),c=[...t.keys()].filter(p=>!s.has(p));c.length>0&&n.push(`ignored unknown key(s): ${c.join(", ")}`);let o=t.get("variant");if(f(o)&&!i.variant)return{error:`\`variant\` "${o}" is not a genome position or substitution such as ${$}`,warnings:n};let u=!!i.gene&&!i.userProvidedTranscriptSequence,a=i.gene?"the launch names no structure, and `gene` is not looked up beside `userProvidedTranscriptSequence`":"No url, data, uniprotId, alphaFoldComplexId, pdbId or gene provided when launching protein view",d=t.get("structures");d!==void 0&&!Array.isArray(d)&&n.push("`structures` is not an array and was ignored");let l=Array.isArray(d)?d:[];if(l.length===0){let p=se(new Map([...t].filter(([g])=>P(g)&&R[g]!=="launchWide")),g=>`\`${g}\``,n);return ae(p)?{requested:[ce(p)],settings:r,linkage:i,warnings:n,geneModel:u&&p.uniprotId&&p.alphaFoldComplexId===void 0&&p.url===void 0&&p.data===void 0?"preferred":void 0}:u?{requested:[p],settings:r,linkage:i,warnings:n,geneModel:"required"}:{error:a,warnings:n}}for(let p of re){let g=R[p],h=p==="uniprotId"&&u;t.get(p)!==void 0&&g!=="launchWide"&&!h&&n.push(`\`${p}\` beside \`structures\` ${ye[g]}`)}let m=l.flatMap((p,g)=>{if(!y(p))return n.push(`structures[${g}] is not an object and was omitted`),[];let h=new Map(Object.entries(p)),w=[...h.keys()].filter(S=>!P(S));w.length>0&&n.push(`structures[${g}] ignored unknown key(s): ${w.join(", ")}`);let k=se(h,S=>`\`structures[${g}].${S}\``,n);return ae(k)?[ce(k)]:(n.push(`structures[${g}] names no url, data, uniprotId, alphaFoldComplexId or pdbId and was omitted`),[])});return m.length>0?{requested:m,settings:r,linkage:i,warnings:n}:u?{requested:[{}],settings:r,linkage:i,warnings:n,geneModel:"required"}:{error:i.gene?a:"no entry of `structures` names a url, data, uniprotId, alphaFoldComplexId or pdbId",warnings:n}}function E(e){if(typeof e=="string")return e;let{trackId:t}=e;return typeof t=="string"?t:void 0}function q(e,t){let n=C(t);return[e.get("name"),e.get("id"),e.get("transcript_id"),e.id()].some(r=>typeof r=="string"&&(r===t||C(r)===n))}function j(e,t){let n=e.getTrackById(t);return n?.type==="FeatureTrack"?Z(e,n):void 0}async function Me({session:e,trackConfs:t,region:n,transcriptId:r}){for(let i of t){let s=await e.rpcManager.call("getFeatures","CoreGetFeatures",{adapterConfig:L(i,"adapter"),regions:[n]});for(let c of s){let o=b(c).find(u=>q(u,r));if(o)return o}}}async function de({session:e,transcriptId:t,connectedView:n}){let r=n?.assembly,i=n?.loc,s=n?.tracks??[];if(!r||!i)throw new Error("`transcriptId` is looked up through `connectedView: { assembly, loc, tracks }`, and this launch gives no `connectedView` with an assembly and loc; a `connectedViewId` alone does not supply them");let c=await e.assemblyManager.waitForAssembly(r);if(!c)throw new Error(`assembly "${r}" not found`);let o=T(i,m=>c.isValidRefName(m));if(o.start===void 0||o.end===void 0)throw new Error(`could not parse a start-end region from loc "${i}"`);let u={assemblyName:r,refName:c.getCanonicalRefName(o.refName)??o.refName,start:o.start,end:o.end},a=s.map(E).filter(m=>m!==void 0),d=await Me({session:e,trackConfs:a.flatMap(m=>{let p=j(e,m);return p?[p]:[]}),region:u,transcriptId:t});if(!d)throw new Error(`transcript "${t}" not found at ${i} in the feature tracks of [${a.join(", ")}]`);let l=await H({session:e,assemblyName:r,feature:d});if(!l)throw new Error(`could not translate a protein sequence for "${t}"`);return{feature:d.toJSON(),userProvidedTranscriptSequence:l}}var Ne=["gene_name","gene","name","id","gene_id"];function le(e,t){return Ne.some(n=>{let r=e.get(n);return typeof r=="string"&&r.toLowerCase()===t})}function Pe(e,t){return e.find(n=>W(n)&&(le(n,t)||b(n).some(r=>le(r,t))))}async function pe({session:e,gene:t,transcriptId:n,uniprotId:r,findStructure:i,connectedView:s,connectedViewId:c}){let o=(c?z(e,c):void 0)??s?.assembly??e.assemblyNames[0];if(!o)throw new Error("no assembly to look the gene up on");let{feature:u,trackId:a}=await Fe({session:e,gene:t,assemblyName:o,trackIds:(s?.tracks??[]).map(E).filter(m=>m!==void 0)}),d=n?b(u).find(m=>q(m,n)):void 0;if(n&&!d)throw new Error(`transcript "${n}" not found in ${t}`);let l=await ee({host:X(e,o),feature:u,preferredTranscriptId:d?.id(),uniprotId:r,findStructure:i});return{feature:l.transcript.toJSON(),userProvidedTranscriptSequence:l.userProvidedTranscriptSequence,uniprotId:l.uniprotId,lookupError:l.lookupError,url:l.url,displayName:Q("Protein view",u,l.transcript,l.uniprotId),connectedView:{...s,assembly:o,loc:s?.loc??`${u.get("refName")}:${u.get("start")+1}-${u.get("end")}`,tracks:s?.tracks??[a]}}}async function Fe({session:e,gene:t,assemblyName:n,trackIds:r=[]}){let{textSearchManager:i,assemblyManager:s,rpcManager:c}=e;if(!i)throw new Error("this session has no text search to look a gene up with");let o=await s.waitForAssembly(n);if(!o)throw new Error(`assembly "${n}" not found`);let u=await i.search({queryString:t,searchType:"exact"},n),a=t.toLowerCase();for(let d of u){let l=d.getLocation(),m=d.getTrackId();if(l){let p=T(l,w=>o.isValidRefName(w)),{start:g,end:h}=p;if(g!==void 0&&h!==void 0){let w={assemblyName:n,refName:o.getCanonicalRefName(p.refName)??p.refName,start:g,end:h};for(let k of new Set([...m?[m]:[],...r])){let S=j(e,k);if(S){let V=Pe(await c.call("getFeatures","CoreGetFeatures",{adapterConfig:L(S,"adapter"),regions:[w]}),a);if(V)return{feature:V,trackId:k}}}}}}throw new Error(u.length>0?`no coding gene named "${t}" in the tracks the ${n} search index names`:`no search result for "${t}" on ${n}; the assembly needs a text search index covering a gene track`)}async function mn(e,{gene:t,transcriptId:n,uniprotId:r,userProvidedTranscriptSequence:i,connectedView:s,connectedViewId:c},{findStructure:o}){let u=t&&!i?await pe({session:e,gene:t,transcriptId:n,uniprotId:r,findStructure:o,connectedView:s,connectedViewId:c}):void 0,a=c?s:u?.connectedView??s,d=u??(!i&&n?await de({session:e,transcriptId:n,connectedView:a}):void 0);return{named:u,resolved:d,connectedView:a}}async function gn(e,{connectedViewId:t,connectedView:n},r){let i=t||!n?void 0:e.addView("LinearGenomeView",{...n,type:"LinearGenomeView"});try{return await r(t??i?.id,!!i)}catch(s){throw i&&e.views.includes(i)&&e.removeView(i),s}}export{Ue as a,y as b,f as c,Ae as d,De as e,mn as f,gn as g};
2
- //# sourceMappingURL=chunk-22BDSJBC.js.map
1
+ import{c as v,d as x}from"./chunk-QDEJUSPX.js";import{i as Q}from"./chunk-MBUM32YU.js";import{a as Z}from"./chunk-NCH7IJII.js";import{a as z,e as K}from"./chunk-2RFFBSIA.js";import{a as J}from"./chunk-A4XT2SQ7.js";import{i as D,j as Y}from"./chunk-BWZ7PSFU.js";import{a as U}from"./chunk-OU2GWGJP.js";import{d as X,e as ee}from"./chunk-A73LEL2C.js";import{a as b,b as W}from"./chunk-7GELEOAH.js";import{a as G,m as T}from"./chunk-Y5T7GSKP.js";import{a as _,b as B,c as H}from"./chunk-6AA7U2KU.js";import{d as L}from"./chunk-LGVXT66Y.js";import{Db as C,f as O,gb as A}from"./chunk-JKKI7LFR.js";var $="'chr17:7674220 C>T' or 'chr17:7674220'",fe=/^([^\s:]+):([\d,]+)(?:\s*([ACGT])\s*>\s*([ACGT]))?$/i;function ne(e){let t=e.trim(),[,n,r,i,s]=fe.exec(t)??[],c=r?Number(r.replaceAll(",",""))-1:-1,o=i&&s?{ref:i.toUpperCase(),alt:s.toUpperCase()}:void 0;return n&&c>=0&&(!o||o.ref!==o.alt)?{text:t,refName:n,start:c,change:o}:void 0}function me(e,t,n){return`${e}${t}${n===void 0?"":n===e?"=":n}`}function ge({variant:e,mapping:t,onTranscriptChromosome:n,genomeBase:r,codonTable:i,transcriptName:s}){let c=D({...t,genomeBase:r}),o=n?c.at(e.start):void 0,u=o?i[o.codon.join("")]:void 0,{change:a}=e,d=a?Y(c,{start:e.start,...a},i):void 0;if(!o||!u)throw new Error(`\`variant\` ${e.text} is not in the coding sequence of ${s}`);if(u==="*")throw new Error(`\`variant\` ${e.text} is in the stop codon of ${s}, which no residue stands for`);if(a&&d?.kind==="refMismatch")throw new Error(`\`variant\` ${e.text} names ${a.ref} as the reference base, and the genome has ${r(e.start)?.toUpperCase()} there`);let l=o.residue+1;return{transcriptResidue:l,label:me(u,l,d?.kind==="translated"?d.to:void 0)}}function he(e){let t=e.get("name"),n=e.get("id");return t??n??e.id()}function we(e){return[e.initialSelection,e.initialResidues,e.initialTranscriptResidues].some(t=>t!==void 0)}function te(e){return new Error(`\`variant\` ${e.text} is placed through each structure's transcript, and neither the launch nor any structure names one; give \`gene\`, \`transcriptId\` or \`feature\``)}async function Se({variant:e,structures:t,launchFeature:n,place:r}){let i=[...new Set(t.flatMap(a=>a.feature?[a.feature]:[]))];if(i.length===0)throw te(e);let s=await Promise.allSettled(i.map(a=>r(a))),c=new Map(i.flatMap((a,d)=>{let l=s[d];return l?.status==="fulfilled"?[[a,l.value]]:[]})),o=t.map(a=>a.feature?c.get(a.feature):void 0),u=(n?c.get(n):void 0)??o.find(a=>a!==void 0);if(!u){let a=s.flatMap(d=>d.status==="rejected"?[K(d.reason)]:[]);throw new Error([...new Set(a)].join("; "))}return{label:u.label,structures:t.map((a,d)=>{let l=o[d];return l&&!we(a)?{...a,initialTranscriptResidues:{start:l.transcriptResidue,end:l.transcriptResidue}}:a})}}async function Ue({session:e,variant:t,structures:n,launchFeature:r,assemblyName:i}){if(!n.some(a=>a.feature))throw te(t);if(!i)throw new Error(`\`variant\` ${t.text} is highlighted on the connected genome view, and this launch connects none with an assembly`);let s=await e.assemblyManager.waitForAssembly(i);if(!s)throw new Error(`assembly "${i}" not found`);let c=s.getCanonicalRefName(t.refName);if(!c)throw new Error(`\`variant\` ${t.text} names ${t.refName}, which ${i} has no sequence for`);let o=await Se({variant:t,structures:n,launchFeature:r,place:async a=>{let d=new G(a),l=U(d),m=s.getCanonicalRefName(l.refName)===c,p=m?l.g2p[t.start]:void 0,g=[t.start,...p===void 0?[]:l.p2gCodon[p]??[]],h=Math.min(...g),w=Math.max(...g)+1,{seq:k,assemblyGeneticCodeId:S}=await B({session:e,assemblyName:i,refName:c,start:h,end:w});return ge({variant:t,mapping:l,onTranscriptChromosome:m,genomeBase:V=>k?.[V-h],codonTable:J(_(d,S)).codonTable,transcriptName:he(d)})}}),u={assemblyName:i,refName:c,start:t.start,end:t.start+1,label:o.label};return{structures:o.structures,highlight:u}}var R={url:"source",data:"source",uniprotId:"source",alphaFoldComplexId:"source",pdbId:"source",initialSelection:"selection",initialResidues:"selection",initialTranscriptResidues:"selection",mappedEntityId:"setting",pairwiseAlignment:"setting",alignmentImported:"setting",hidden:"setting",assembly:"setting",chains:"setting",filter:"setting",feature:"launchWide",userProvidedTranscriptSequence:"launchWide",connectedViewId:"launchWide"};function P(e){return Object.hasOwn(R,e)}var re=Object.keys(R).filter(P),ye={source:"names no structure; add it as an entry of `structures`",selection:"applies to no structure; put it on the one it selects in",setting:"applies to no structure; put it on the one it describes"};function y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function f(e){return typeof e=="string"}function ke(e){return Array.isArray(e)&&e.every(f)}function I(e){return typeof e=="boolean"}function ie(e){return typeof e=="number"&&Number.isFinite(e)}function ue(e){return y(e)}function be(e){return Array.isArray(e)&&e.every(y)}function Ve(e){return Array.isArray(e)&&e.every(y)}function Le(e){return Array.isArray(e)&&e.every(y)}function Te(e){return e!==void 0&&v(e).length===0}function Re(e){return e!==void 0&&x(e).length===0}function oe(e){return y(e)&&typeof e.start=="number"&&typeof e.end=="number"}function M(e){return Array.isArray(e)?e.every(oe):oe(e)}function Ie(e){return f(e)||y(e)}function Ae(e){return y(e)&&(e.loc===void 0||f(e.loc))&&(e.assembly===void 0||f(e.assembly))&&(e.tracks===void 0||Array.isArray(e.tracks)&&e.tracks.every(Ie))}var N="{ start, end } numbers or an array of them";function F(e,t,n){return function(i,s,c){let o=e.get(i);if(o===void 0||s(o))return o;n.push(`${t(i)} is not ${c} and was ignored`)}}function Ce(e,t){return function(r,i,s){let c=e.get(r),o=c!==void 0&&i(c)?c:void 0;return c!==void 0&&o===void 0&&t.push(`\`${r}\` was ignored: ${s(c).join("; ")}`),o}}var ve=["structures","gene","transcriptId","connectedView","sideBySide","variant"];function xe(e,t){let n=F(e,s=>`\`${s}\``,t),r=e.get("uniprotId"),i=n("variant",f,`a string such as ${$}`);return{gene:n("gene",f,"a string"),transcriptId:n("transcriptId",f,"a string"),uniprotId:f(r)?r:void 0,connectedView:n("connectedView",Ae,"{ assembly, loc, tracks }"),connectedViewId:n("connectedViewId",f,"a string"),sideBySide:n("sideBySide",I,"true or false"),feature:n("feature",ue,"a feature object"),userProvidedTranscriptSequence:n("userProvidedTranscriptSequence",f,"a string"),variant:i===void 0?void 0:ne(i)}}function $e(e,t){let n=F(e,s=>`\`${s}\``,t),r=Ce(e,t),i=s=>n(s,I,"true or false");return{id:n("id",f,"a string"),displayName:n("displayName",f,"a string"),height:n("height",ie,"a number"),trackHeight:n("trackHeight",ie,"a number"),showControls:i("showControls"),showAlignment:i("showAlignment"),showHighlight:i("showHighlight"),showProteinTracks:i("showProteinTracks"),compactTracks:i("compactTracks"),showAllFeatureTracks:i("showAllFeatureTracks"),zoomToBaseLevel:i("zoomToBaseLevel"),autoScrollAlignment:i("autoScrollAlignment"),alignmentAlgorithm:n("alignmentAlgorithm",f,"a string"),color:e.get("color"),colorScheme:n("colorScheme",f,"a string"),camera:r("camera",Te,v),surface:r("surface",Re,x),distances:n("distances",Le,"a list such as [{ a: 'A:46@NZ', b: 'A:80@NZ' }]"),marks:n("marks",Ve,"a list such as [{ site: 'A:248', mark: 'spheres' }]"),silhouettes:i("silhouettes"),occlusion:i("occlusion")}}function se(e,t,n){let r=F(e,t,n);return{url:r("url",f,"a string"),data:r("data",f,"a string"),uniprotId:r("uniprotId",f,"a string"),alphaFoldComplexId:r("alphaFoldComplexId",f,"a string"),pdbId:r("pdbId",f,"a string"),initialSelection:r("initialSelection",M,N),initialResidues:r("initialResidues",M,N),initialTranscriptResidues:r("initialTranscriptResidues",M,N),mappedEntityId:r("mappedEntityId",f,"a string"),pairwiseAlignment:r("pairwiseAlignment",O,"{ consensus, alns: [{ id, seq }, { id, seq }] }"),alignmentImported:r("alignmentImported",I,"true or false"),hidden:r("hidden",I,"true or false"),assembly:r("assembly",f,"a string"),chains:r("chains",ke,"a list of chain ids"),filter:r("filter",be,"a list of predicates such as [{ field: 'residue', lte: 184 }]"),feature:r("feature",ue,"a feature object"),userProvidedTranscriptSequence:r("userProvidedTranscriptSequence",f,"a string"),connectedViewId:r("connectedViewId",f,"a string")}}function ae(e){return!!A(e)||e.data!==void 0||!!e.uniprotId||!!e.alphaFoldComplexId}function ce(e){return{...e,url:A(e)}}function De(e){let t=new Map(Object.entries(e)),n=[],r=$e(t,n),i=xe(t,n),s=new Set([...Object.keys(r),...re,...ve]),c=[...t.keys()].filter(p=>!s.has(p));c.length>0&&n.push(`ignored unknown key(s): ${c.join(", ")}`);let o=t.get("variant");if(f(o)&&!i.variant)return{error:`\`variant\` "${o}" is not a genome position or substitution such as ${$}`,warnings:n};let u=!!i.gene&&!i.userProvidedTranscriptSequence,a=i.gene?"the launch names no structure, and `gene` is not looked up beside `userProvidedTranscriptSequence`":"No url, data, uniprotId, alphaFoldComplexId, pdbId or gene provided when launching protein view",d=t.get("structures");d!==void 0&&!Array.isArray(d)&&n.push("`structures` is not an array and was ignored");let l=Array.isArray(d)?d:[];if(l.length===0){let p=se(new Map([...t].filter(([g])=>P(g)&&R[g]!=="launchWide")),g=>`\`${g}\``,n);return ae(p)?{requested:[ce(p)],settings:r,linkage:i,warnings:n,geneModel:u&&p.uniprotId&&p.alphaFoldComplexId===void 0&&p.url===void 0&&p.data===void 0?"preferred":void 0}:u?{requested:[p],settings:r,linkage:i,warnings:n,geneModel:"required"}:{error:a,warnings:n}}for(let p of re){let g=R[p],h=p==="uniprotId"&&u;t.get(p)!==void 0&&g!=="launchWide"&&!h&&n.push(`\`${p}\` beside \`structures\` ${ye[g]}`)}let m=l.flatMap((p,g)=>{if(!y(p))return n.push(`structures[${g}] is not an object and was omitted`),[];let h=new Map(Object.entries(p)),w=[...h.keys()].filter(S=>!P(S));w.length>0&&n.push(`structures[${g}] ignored unknown key(s): ${w.join(", ")}`);let k=se(h,S=>`\`structures[${g}].${S}\``,n);return ae(k)?[ce(k)]:(n.push(`structures[${g}] names no url, data, uniprotId, alphaFoldComplexId or pdbId and was omitted`),[])});return m.length>0?{requested:m,settings:r,linkage:i,warnings:n}:u?{requested:[{}],settings:r,linkage:i,warnings:n,geneModel:"required"}:{error:i.gene?a:"no entry of `structures` names a url, data, uniprotId, alphaFoldComplexId or pdbId",warnings:n}}function E(e){if(typeof e=="string")return e;let{trackId:t}=e;return typeof t=="string"?t:void 0}function q(e,t){let n=C(t);return[e.get("name"),e.get("id"),e.get("transcript_id"),e.id()].some(r=>typeof r=="string"&&(r===t||C(r)===n))}function j(e,t){let n=e.getTrackById(t);return n?.type==="FeatureTrack"?Z(e,n):void 0}async function Me({session:e,trackConfs:t,region:n,transcriptId:r}){for(let i of t){let s=await e.rpcManager.call("getFeatures","CoreGetFeatures",{adapterConfig:L(i,"adapter"),regions:[n]});for(let c of s){let o=b(c).find(u=>q(u,r));if(o)return o}}}async function de({session:e,transcriptId:t,connectedView:n}){let r=n?.assembly,i=n?.loc,s=n?.tracks??[];if(!r||!i)throw new Error("`transcriptId` is looked up through `connectedView: { assembly, loc, tracks }`, and this launch gives no `connectedView` with an assembly and loc; a `connectedViewId` alone does not supply them");let c=await e.assemblyManager.waitForAssembly(r);if(!c)throw new Error(`assembly "${r}" not found`);let o=T(i,m=>c.isValidRefName(m));if(o.start===void 0||o.end===void 0)throw new Error(`could not parse a start-end region from loc "${i}"`);let u={assemblyName:r,refName:c.getCanonicalRefName(o.refName)??o.refName,start:o.start,end:o.end},a=s.map(E).filter(m=>m!==void 0),d=await Me({session:e,trackConfs:a.flatMap(m=>{let p=j(e,m);return p?[p]:[]}),region:u,transcriptId:t});if(!d)throw new Error(`transcript "${t}" not found at ${i} in the feature tracks of [${a.join(", ")}]`);let l=await H({session:e,assemblyName:r,feature:d});if(!l)throw new Error(`could not translate a protein sequence for "${t}"`);return{feature:d.toJSON(),userProvidedTranscriptSequence:l}}var Ne=["gene_name","gene","name","id","gene_id"];function le(e,t){return Ne.some(n=>{let r=e.get(n);return typeof r=="string"&&r.toLowerCase()===t})}function Pe(e,t){return e.find(n=>W(n)&&(le(n,t)||b(n).some(r=>le(r,t))))}async function pe({session:e,gene:t,transcriptId:n,uniprotId:r,findStructure:i,connectedView:s,connectedViewId:c}){let o=(c?z(e,c):void 0)??s?.assembly??e.assemblyNames[0];if(!o)throw new Error("no assembly to look the gene up on");let{feature:u,trackId:a}=await Fe({session:e,gene:t,assemblyName:o,trackIds:(s?.tracks??[]).map(E).filter(m=>m!==void 0)}),d=n?b(u).find(m=>q(m,n)):void 0;if(n&&!d)throw new Error(`transcript "${n}" not found in ${t}`);let l=await ee({host:X(e,o),feature:u,preferredTranscriptId:d?.id(),uniprotId:r,findStructure:i});return{feature:l.transcript.toJSON(),userProvidedTranscriptSequence:l.userProvidedTranscriptSequence,uniprotId:l.uniprotId,lookupError:l.lookupError,url:l.url,displayName:Q("Protein view",u,l.transcript,l.uniprotId),connectedView:{...s,assembly:o,loc:s?.loc??`${u.get("refName")}:${u.get("start")+1}-${u.get("end")}`,tracks:s?.tracks??[a]}}}async function Fe({session:e,gene:t,assemblyName:n,trackIds:r=[]}){let{textSearchManager:i,assemblyManager:s,rpcManager:c}=e;if(!i)throw new Error("this session has no text search to look a gene up with");let o=await s.waitForAssembly(n);if(!o)throw new Error(`assembly "${n}" not found`);let u=await i.search({queryString:t,searchType:"exact"},n),a=t.toLowerCase();for(let d of u){let l=d.getLocation(),m=d.getTrackId();if(l){let p=T(l,w=>o.isValidRefName(w)),{start:g,end:h}=p;if(g!==void 0&&h!==void 0){let w={assemblyName:n,refName:o.getCanonicalRefName(p.refName)??p.refName,start:g,end:h};for(let k of new Set([...m?[m]:[],...r])){let S=j(e,k);if(S){let V=Pe(await c.call("getFeatures","CoreGetFeatures",{adapterConfig:L(S,"adapter"),regions:[w]}),a);if(V)return{feature:V,trackId:k}}}}}}throw new Error(u.length>0?`no coding gene named "${t}" in the tracks the ${n} search index names`:`no search result for "${t}" on ${n}; the assembly needs a text search index covering a gene track`)}async function mn(e,{gene:t,transcriptId:n,uniprotId:r,userProvidedTranscriptSequence:i,connectedView:s,connectedViewId:c},{findStructure:o}){let u=t&&!i?await pe({session:e,gene:t,transcriptId:n,uniprotId:r,findStructure:o,connectedView:s,connectedViewId:c}):void 0,a=c?s:u?.connectedView??s,d=u??(!i&&n?await de({session:e,transcriptId:n,connectedView:a}):void 0);return{named:u,resolved:d,connectedView:a}}async function gn(e,{connectedViewId:t,connectedView:n},r){let i=t||!n?void 0:e.addView("LinearGenomeView",{...n,type:"LinearGenomeView"});try{return await r(t??i?.id,!!i)}catch(s){throw i&&e.views.includes(i)&&e.removeView(i),s}}export{Ue as a,y as b,f as c,Ae as d,De as e,mn as f,gn as g};
2
+ //# sourceMappingURL=chunk-LVHVCXMK.js.map
@@ -0,0 +1,2 @@
1
+ import{a as P}from"./chunk-ENPYAI4H.js";import{a as u,b as p,f as h}from"./chunk-53Z5PTMG.js";import{b as j}from"./chunk-NY22OOJ6.js";import{Jb as w,Kb as b,Lb as g}from"./chunk-JKKI7LFR.js";function L({plugin:t,molstarStructure:r}){return p(t,async()=>{if(!r)return;let o=await u(),{PluginStateObject:e}=o,a=h(t,o,r),s=(a&&t.state.data.selectQ(i=>i.byValue(a).ancestorOfType(e.Molecule.Trajectory))[0])??a;s&&await y(t,o,s.transform.ref)})}async function y(t,r,o){await r.PluginCommands.State.RemoveObject(t,{state:t.state.data,ref:o,removeParentGhosts:!0})}function D(t,r,o){return t.builders.structure.parseTrajectory(r,o)}function C(t){return t.commit({revertOnError:!0})}async function O(t,r){let o=await u(),e=t.state.data,a=e.build().toRoot().apply(o.StateTransforms.Data.Download,{url:r,isBinary:b(r)},{state:{isGhost:!0}}),n=[],s=e.events.cell.stateUpdated.subscribe(({ref:c,cell:l})=>{c===a.ref&&l.status==="error"&&n.push(l.errorText?.replace(/^Error: /,"")??"no data")}),i=await C(a).finally(()=>{s.unsubscribe()});if(!i?.isOk)throw new Error(`Could not download ${r}: ${n.at(-1)??"no data"}`);return i}async function R({plugin:t,data:r,url:o}){let e,a;if(r!==void 0)a=g(r),e=await t.builders.data.rawData({data:r},{state:{isGhost:!0}});else if(o!==void 0)a=w(o),e=await O(t,o);else throw new Error("a structure needs either data or a url");let n=await D(t,e,a);if(!n?.obj?.data.frameCount)throw await y(t,await u(),e.ref).catch(()=>{}),new Error(`No model could be read from ${o??"the structure data"} as ${a}`);return n}var x="Polymer, drawn chains";function M({chains:t,filter:r}){return!!t?.length||!!r?.length}var I="deposited";function E(t){return t===void 0?void 0:t===I?{name:"model",params:{}}:{name:"assembly",params:{id:t}}}function F(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:o,StateTransforms:e}=await u(),a=t.state.data.build();for(let{ref:n}of r)for(let s of t.state.data.select(o.Generators.byRef(n).subtree().withTransformer(e.Model.StructureComponent))){let{type:i}=s.transform.params??{};i?.name==="static"&&i.params==="water"&&a.delete(s.transform.ref)}await a.commit()}async function G(t,r,o,e,a){let n={useDefaultIfSingleModel:!0,structure:E(e)};return A(t,o,await t.builders.structure.hierarchy.applyPreset(r,"all-models",n),a)}async function v(t,r,o){let{MolScriptBuilder:e,StateSelection:a,StateTransforms:n}=await u(),{chainTest:s,residueTest:i}=j(e,o),c=d=>d?e.core.rel.eq([e.ammp("entityType"),"polymer"]):e.core.logic.and([e.core.rel.neq([e.ammp("entityType"),"polymer"]),e.core.rel.neq([e.ammp("entityType"),"water"]),e.core.logic.not([e.core.set.has([e.set(...P),e.ammp("label_comp_id")])])]),l=t.state.data.build();for(let{ref:d}of r)for(let f of t.state.data.select(a.Generators.byRef(d).subtree().withTransformer(n.Model.StructureComponent))){let{type:m}=f.transform.params??{};if(m?.name==="static"){let S=m.params==="polymer";l.to(f).update(T=>({...T,...S?{label:x}:{},type:{name:"expression",params:e.struct.generator.atomGroups({...s?{"chain-test":s}:{},...i?{"residue-test":i}:{},"entity-test":c(S)})}}))}}for(let{ref:d}of r)for(let f of t.state.data.select(a.Generators.byRef(d).subtree().withTransformer(n.Representation.StructureRepresentation3D)))f.transform.params?.type.name==="cartoon"&&l.to(f).update(m=>({...m,type:{...m.type,params:{...m.type.params,sizeFactor:.45}}}));await l.commit()}async function A(t,r,o,e){let{models:a,structures:n}=F(o);await B(t,n),M(e)&&await v(t,n,e);let s=n.flatMap(i=>i.obj?[i.obj.data]:[]);if(s.length===0)throw new Error(`No structure could be built from ${r} by Mol*'s all-models preset`);return{model:a[0],structures:s,modelIds:s.flatMap(i=>i.models.map(c=>c.id))}}function H({plugin:t,data:r,url:o,assembly:e,chains:a,filter:n}){return p(t,async()=>{let s=await R({plugin:t,data:r,url:o}),i=o??"the structure data";try{return await G(t,s,i,e,{chains:a,filter:n})}catch(c){throw await y(t,await u(),s.ref).catch(()=>{}),c}})}export{L as a,R as b,x as c,I as d,H as e};
2
+ //# sourceMappingURL=chunk-OGP4AJBI.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/ProteinView/removeStructure.ts", "../../src/ProteinView/structurePipeline.ts"],
4
+ "sourcesContent": ["import loadMolstar from './loadMolstar'\nimport { serialPerPlugin } from './serialPerPlugin'\nimport { structureRootCell } from './structureCells'\n\nimport type { Structure } from 'molstar/lib/mol-model/structure'\nimport type { PluginCommands } from 'molstar/lib/mol-plugin/commands'\nimport type { PluginContext } from 'molstar/lib/mol-plugin/context'\n\n/**\n * Take one load out of Mol*, by the trajectory it came from: removing the\n * structure node alone would leave the download, trajectory and model nodes\n * behind, and an NMR ensemble's other models with them. The ghost nodes above\n * the trajectory go too, the download or pasted text and its parse, or the\n * file stays in the state tree. The cell is found in the live tree, so a\n * structure a superposition has transformed, or one that finished loading an\n * instant ago, is still found.\n */\nexport function removeMolstarStructure({\n plugin,\n molstarStructure,\n}: {\n plugin: PluginContext\n molstarStructure: Structure | undefined\n}) {\n return serialPerPlugin(plugin, async () => {\n if (!molstarStructure) {\n return\n }\n const molstar = await loadMolstar()\n const { PluginStateObject } = molstar\n const cell = structureRootCell(plugin, molstar, molstarStructure)\n const trajectory =\n cell &&\n plugin.state.data.selectQ(q =>\n q.byValue(cell).ancestorOfType(PluginStateObject.Molecule.Trajectory),\n )[0]\n const target = trajectory ?? cell\n if (target) {\n await removeWithGhosts(plugin, molstar, target.transform.ref)\n }\n })\n}\n\n/** Remove a cell and the ghost nodes above it, the download or pasted text\n * and its parse. Unserialized, for a task already in the plugin's lane. */\nexport async function removeWithGhosts(\n plugin: PluginContext,\n molstar: { PluginCommands: typeof PluginCommands },\n ref: string,\n) {\n await molstar.PluginCommands.State.RemoveObject(plugin, {\n state: plugin.state.data,\n ref,\n removeParentGhosts: true,\n })\n}\n", "import {\n isBinaryStructureUrl,\n structureFormatFromContent,\n structureFormatFromName,\n} from 'p2s_mapper'\n\nimport { CRYSTALLIZATION_ADDITIVES } from './crystallizationAdditives'\nimport loadMolstar from './loadMolstar'\nimport { removeWithGhosts } from './removeStructure'\nimport { drawnTests } from './residueFilter'\nimport { serialPerPlugin } from './serialPerPlugin'\n\nimport type { StructureFilter } from './residueFilter'\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 { RootStructureDefinition } from 'molstar/lib/mol-plugin-state/helpers/root-structure'\nimport type { PluginStateObject } from 'molstar/lib/mol-plugin-state/objects'\nimport type { StateBuilder, 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// Typed as always resolving to a selector, but a commit that reverts resolves\n// with nothing\nfunction commitDownload(\n built: StateBuilder.To<\n PluginStateObject.Data.String | PluginStateObject.Data.Binary\n >,\n): Promise<RawStructure | undefined> {\n return built.commit({ revertOnError: true })\n}\n\n/** Mol*'s download reverts a failed request, as it must: a failed update left\n * in the tree flags any data transaction open beside it, which then rolls\n * back. The revert takes the cell's error with it, so the parse after it said\n * only \"Invalid data cell\"; the error is read off the cell as it fails. */\nasync function download(plugin: PluginContext, url: string) {\n const molstar = await loadMolstar()\n const state = plugin.state.data\n const built = state\n .build()\n .toRoot()\n .apply(\n molstar.StateTransforms.Data.Download,\n { url, isBinary: isBinaryStructureUrl(url) },\n { state: { isGhost: true } },\n )\n const failures: string[] = []\n const watch = state.events.cell.stateUpdated.subscribe(({ ref, cell }) => {\n if (ref === built.ref && cell.status === 'error') {\n failures.push(cell.errorText?.replace(/^Error: /, '') ?? 'no data')\n }\n })\n const raw = await commitDownload(built).finally(() => {\n watch.unsubscribe()\n })\n if (!raw?.isOk) {\n throw new Error(\n `Could not download ${url}: ${failures.at(-1) ?? 'no data'}`,\n )\n }\n return raw\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 download(plugin, url)\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 // a plugin disposed mid-load fails the removal too, and the parse's own\n // error is the one to report\n await removeWithGhosts(plugin, await loadMolstar(), raw.ref).catch(() => {})\n throw new Error(\n `No model could be read from ${url ?? 'the structure data'} as ${parsedAs}`,\n )\n }\n return trajectory\n}\n\n/** The label of a polymer component narrowed to part of the structure, which\n * other drawing (the surface) finds it by in place of its static type. */\nexport const DRAWN_CHAINS_POLYMER = 'Polymer, drawn chains'\n\n/** Which of a structure's residues are drawn: the chains `chains` lists, and\n * among them those every predicate of `filter` passes. */\nexport interface DrawnResidues {\n chains?: readonly string[]\n filter?: StructureFilter\n}\n\nfunction drawsPart({ chains, filter }: DrawnResidues) {\n return !!chains?.length || !!filter?.length\n}\n\n/** The `assembly` value that builds the deposited model, every chain the file\n * holds, rather than one of the entry's biological assemblies. */\nexport const DEPOSITED_MODEL = 'deposited'\n\nfunction rootStructure(\n assembly: string | undefined,\n): RootStructureDefinition.Params | undefined {\n return assembly === undefined\n ? undefined\n : assembly === DEPOSITED_MODEL\n ? { name: 'model', params: {} }\n : { name: 'assembly', params: { id: assembly } }\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 *\n * A single-model file falls through to Mol*'s default preset, which takes the\n * `structure` param: absent, it builds the first assembly. An ensemble builds\n * each model whole and ignores it.\n */\nasync function applyStructurePreset(\n plugin: PluginContext,\n trajectory: StateObjectSelector,\n source: string,\n assembly: string | undefined,\n drawn: DrawnResidues,\n) {\n const params: {\n useDefaultIfSingleModel: boolean\n structure?: RootStructureDefinition.Params\n } = { useDefaultIfSingleModel: true, structure: rootStructure(assembly) }\n return collectPreset(\n plugin,\n source,\n await plugin.builders.structure.hierarchy.applyPreset(\n trajectory,\n 'all-models',\n params,\n ),\n drawn,\n )\n}\n\n/**\n * Narrow the preset's polymer and ligand components to the residues the spec\n * draws. The structure itself stays whole, so mapping, highlights and colors\n * address it as before; only what is drawn shrinks.\n *\n * A `filter` narrows the ligand component too: a bound ligand is numbered in\n * the same author series as the polymer, well above its last residue, so a\n * residue bound leaves the ligand out as well.\n */\nasync function drawOnlyPart(\n plugin: PluginContext,\n structures: readonly StructureSelector[],\n drawn: DrawnResidues,\n) {\n const {\n MolScriptBuilder: MS,\n StateSelection,\n StateTransforms,\n } = await loadMolstar()\n const { chainTest, residueTest } = drawnTests(MS, drawn)\n const entityTest = (polymer: boolean) =>\n polymer\n ? MS.core.rel.eq([MS.ammp('entityType'), 'polymer'])\n : MS.core.logic.and([\n MS.core.rel.neq([MS.ammp('entityType'), 'polymer']),\n MS.core.rel.neq([MS.ammp('entityType'), 'water']),\n MS.core.logic.not([\n MS.core.set.has([\n MS.set(...CRYSTALLIZATION_ADDITIVES),\n MS.ammp('label_comp_id'),\n ]),\n ]),\n ])\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') {\n const polymer = type.params === 'polymer'\n update.to(cell).update(prev => ({\n ...prev,\n ...(polymer ? { label: DRAWN_CHAINS_POLYMER } : {}),\n type: {\n name: 'expression',\n params: MS.struct.generator.atomGroups({\n ...(chainTest ? { 'chain-test': chainTest } : {}),\n ...(residueTest ? { 'residue-test': residueTest } : {}),\n 'entity-test': entityTest(polymer),\n }),\n },\n }))\n }\n }\n }\n // a lone rung of a filament has no strand partners, so Mol* draws it as\n // thin coil; drawn thicker it reads at figure size\n for (const { ref } of structures) {\n for (const cell of plugin.state.data.select(\n StateSelection.Generators.byRef(ref)\n .subtree()\n .withTransformer(\n StateTransforms.Representation.StructureRepresentation3D,\n ),\n )) {\n if (cell.transform.params?.type.name === 'cartoon') {\n update.to(cell).update(prev => ({\n ...prev,\n type: {\n ...prev.type,\n params: { ...prev.type.params, sizeFactor: 0.45 },\n },\n }))\n }\n }\n }\n await update.commit()\n}\n\nasync function collectPreset(\n plugin: PluginContext,\n source: string,\n preset: Parameters<typeof presetOutput>[0],\n drawn: DrawnResidues,\n) {\n const { models, structures } = presetOutput(preset)\n await removeWater(plugin, structures)\n if (drawsPart(drawn)) {\n await drawOnlyPart(plugin, structures, drawn)\n }\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/**\n * Load a structure from its text or its url, as the view shows one. A load\n * that fails after parsing takes its trajectory back out, or Mol* would draw a\n * structure no model of the view owns and none can remove.\n */\nexport function loadStructure({\n plugin,\n data,\n url,\n assembly,\n chains,\n filter,\n}: {\n plugin: PluginContext\n data?: string\n url?: string\n assembly?: string\n} & DrawnResidues) {\n return serialPerPlugin(plugin, async () => {\n const trajectory = await parseStructureTrajectory({ plugin, data, url })\n const source = url ?? 'the structure data'\n try {\n return await applyStructurePreset(plugin, trajectory, source, assembly, {\n chains,\n filter,\n })\n } catch (e) {\n // a plugin disposed mid-load fails the removal too, and the load's\n // own error is the one to report\n await removeWithGhosts(plugin, await loadMolstar(), trajectory.ref).catch(\n () => {},\n )\n throw e\n }\n })\n}\n"],
5
+ "mappings": "+LAiBO,SAASA,EAAuB,CACrC,OAAAC,EACA,iBAAAC,CACF,EAGG,CACD,OAAOC,EAAgBF,EAAQ,SAAY,CACzC,GAAI,CAACC,EACH,OAEF,IAAME,EAAU,MAAMC,EAAY,EAC5B,CAAE,kBAAAC,CAAkB,EAAIF,EACxBG,EAAOC,EAAkBP,EAAQG,EAASF,CAAgB,EAM1DO,GAJJF,GACAN,EAAO,MAAM,KAAK,QAAQS,GACxBA,EAAE,QAAQH,CAAI,EAAE,eAAeD,EAAkB,SAAS,UAAU,CACtE,EAAE,CAAC,IACwBC,EACzBE,GACF,MAAME,EAAiBV,EAAQG,EAASK,EAAO,UAAU,GAAG,CAEhE,CAAC,CACH,CAIA,eAAsBE,EACpBV,EACAG,EACAQ,EACA,CACA,MAAMR,EAAQ,eAAe,MAAM,aAAaH,EAAQ,CACtD,MAAOA,EAAO,MAAM,KACpB,IAAAW,EACA,mBAAoB,EACtB,CAAC,CACH,CC7BA,SAASC,EACPC,EACAC,EACAC,EAGA,CACA,OAAOF,EAAO,SAAS,UAAU,gBAAgBC,EAAKC,CAAM,CAC9D,CAIA,SAASC,EACPC,EAGmC,CACnC,OAAOA,EAAM,OAAO,CAAE,cAAe,EAAK,CAAC,CAC7C,CAMA,eAAeC,EAASL,EAAuBM,EAAa,CAC1D,IAAMC,EAAU,MAAMC,EAAY,EAC5BC,EAAQT,EAAO,MAAM,KACrBI,EAAQK,EACX,MAAM,EACN,OAAO,EACP,MACCF,EAAQ,gBAAgB,KAAK,SAC7B,CAAE,IAAAD,EAAK,SAAUI,EAAqBJ,CAAG,CAAE,EAC3C,CAAE,MAAO,CAAE,QAAS,EAAK,CAAE,CAC7B,EACIK,EAAqB,CAAC,EACtBC,EAAQH,EAAM,OAAO,KAAK,aAAa,UAAU,CAAC,CAAE,IAAAI,EAAK,KAAAC,CAAK,IAAM,CACpED,IAAQT,EAAM,KAAOU,EAAK,SAAW,SACvCH,EAAS,KAAKG,EAAK,WAAW,QAAQ,WAAY,EAAE,GAAK,SAAS,CAEtE,CAAC,EACKb,EAAM,MAAME,EAAeC,CAAK,EAAE,QAAQ,IAAM,CACpDQ,EAAM,YAAY,CACpB,CAAC,EACD,GAAI,CAACX,GAAK,KACR,MAAM,IAAI,MACR,sBAAsBK,CAAG,KAAKK,EAAS,GAAG,EAAE,GAAK,SAAS,EAC5D,EAEF,OAAOV,CACT,CAUA,eAAsBc,EAAyB,CAC7C,OAAAf,EACA,KAAAgB,EACA,IAAAV,CACF,EAIG,CACD,IAAIL,EACAgB,EACJ,GAAID,IAAS,OACXC,EAAWC,EAA2BF,CAAI,EAC1Cf,EAAM,MAAMD,EAAO,SAAS,KAAK,QAC/B,CAAE,KAAAgB,CAAK,EACP,CAAE,MAAO,CAAE,QAAS,EAAK,CAAE,CAC7B,UACSV,IAAQ,OACjBW,EAAWE,EAAwBb,CAAG,EACtCL,EAAM,MAAMI,EAASL,EAAQM,CAAG,MAEhC,OAAM,IAAI,MAAM,wCAAwC,EAE1D,IAAMc,EAAa,MAAMrB,EAAgBC,EAAQC,EAAKgB,CAAQ,EAC9D,GAAI,CAACG,GAAY,KAAK,KAAK,WAGzB,YAAMC,EAAiBrB,EAAQ,MAAMQ,EAAY,EAAGP,EAAI,GAAG,EAAE,MAAM,IAAM,CAAC,CAAC,EACrE,IAAI,MACR,+BAA+BK,GAAO,oBAAoB,OAAOW,CAAQ,EAC3E,EAEF,OAAOG,CACT,CAIO,IAAME,EAAuB,wBASpC,SAASC,EAAU,CAAE,OAAAC,EAAQ,OAAAC,CAAO,EAAkB,CACpD,MAAO,CAAC,CAACD,GAAQ,QAAU,CAAC,CAACC,GAAQ,MACvC,CAIO,IAAMC,EAAkB,YAE/B,SAASC,EACPC,EAC4C,CAC5C,OAAOA,IAAa,OAChB,OACAA,IAAaF,EACX,CAAE,KAAM,QAAS,OAAQ,CAAC,CAAE,EAC5B,CAAE,KAAM,WAAY,OAAQ,CAAE,GAAIE,CAAS,CAAE,CACrD,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,EACb/B,EACAgC,EACA,CACA,GAAM,CAAE,eAAAC,EAAgB,gBAAAC,CAAgB,EAAI,MAAM1B,EAAY,EACxD2B,EAASnC,EAAO,MAAM,KAAK,MAAM,EACvC,OAAW,CAAE,IAAAa,CAAI,IAAKmB,EACpB,QAAWlB,KAAQd,EAAO,MAAM,KAAK,OACnCiC,EAAe,WAAW,MAAMpB,CAAG,EAChC,QAAQ,EACR,gBAAgBqB,EAAgB,MAAM,kBAAkB,CAC7D,EAAG,CACD,GAAM,CAAE,KAAAE,CAAK,EAAItB,EAAK,UAAU,QAAU,CAAC,EACvCsB,GAAM,OAAS,UAAYA,EAAK,SAAW,SAC7CD,EAAO,OAAOrB,EAAK,UAAU,GAAG,CAEpC,CAEF,MAAMqB,EAAO,OAAO,CACtB,CAcA,eAAeE,EACbrC,EACAoB,EACAkB,EACAV,EACAW,EACA,CACA,IAAMC,EAGF,CAAE,wBAAyB,GAAM,UAAWb,EAAcC,CAAQ,CAAE,EACxE,OAAOa,EACLzC,EACAsC,EACA,MAAMtC,EAAO,SAAS,UAAU,UAAU,YACxCoB,EACA,aACAoB,CACF,EACAD,CACF,CACF,CAWA,eAAeG,EACb1C,EACAgC,EACAO,EACA,CACA,GAAM,CACJ,iBAAkBI,EAClB,eAAAV,EACA,gBAAAC,CACF,EAAI,MAAM1B,EAAY,EAChB,CAAE,UAAAoC,EAAW,YAAAC,CAAY,EAAIC,EAAWH,EAAIJ,CAAK,EACjDQ,EAAcC,GAClBA,EACIL,EAAG,KAAK,IAAI,GAAG,CAACA,EAAG,KAAK,YAAY,EAAG,SAAS,CAAC,EACjDA,EAAG,KAAK,MAAM,IAAI,CAChBA,EAAG,KAAK,IAAI,IAAI,CAACA,EAAG,KAAK,YAAY,EAAG,SAAS,CAAC,EAClDA,EAAG,KAAK,IAAI,IAAI,CAACA,EAAG,KAAK,YAAY,EAAG,OAAO,CAAC,EAChDA,EAAG,KAAK,MAAM,IAAI,CAChBA,EAAG,KAAK,IAAI,IAAI,CACdA,EAAG,IAAI,GAAGM,CAAyB,EACnCN,EAAG,KAAK,eAAe,CACzB,CAAC,CACH,CAAC,CACH,CAAC,EACDR,EAASnC,EAAO,MAAM,KAAK,MAAM,EACvC,OAAW,CAAE,IAAAa,CAAI,IAAKmB,EACpB,QAAWlB,KAAQd,EAAO,MAAM,KAAK,OACnCiC,EAAe,WAAW,MAAMpB,CAAG,EAChC,QAAQ,EACR,gBAAgBqB,EAAgB,MAAM,kBAAkB,CAC7D,EAAG,CACD,GAAM,CAAE,KAAAE,CAAK,EAAItB,EAAK,UAAU,QAAU,CAAC,EAC3C,GAAIsB,GAAM,OAAS,SAAU,CAC3B,IAAMY,EAAUZ,EAAK,SAAW,UAChCD,EAAO,GAAGrB,CAAI,EAAE,OAAOoC,IAAS,CAC9B,GAAGA,EACH,GAAIF,EAAU,CAAE,MAAO1B,CAAqB,EAAI,CAAC,EACjD,KAAM,CACJ,KAAM,aACN,OAAQqB,EAAG,OAAO,UAAU,WAAW,CACrC,GAAIC,EAAY,CAAE,aAAcA,CAAU,EAAI,CAAC,EAC/C,GAAIC,EAAc,CAAE,eAAgBA,CAAY,EAAI,CAAC,EACrD,cAAeE,EAAWC,CAAO,CACnC,CAAC,CACH,CACF,EAAE,CACJ,CACF,CAIF,OAAW,CAAE,IAAAnC,CAAI,IAAKmB,EACpB,QAAWlB,KAAQd,EAAO,MAAM,KAAK,OACnCiC,EAAe,WAAW,MAAMpB,CAAG,EAChC,QAAQ,EACR,gBACCqB,EAAgB,eAAe,yBACjC,CACJ,EACMpB,EAAK,UAAU,QAAQ,KAAK,OAAS,WACvCqB,EAAO,GAAGrB,CAAI,EAAE,OAAOoC,IAAS,CAC9B,GAAGA,EACH,KAAM,CACJ,GAAGA,EAAK,KACR,OAAQ,CAAE,GAAGA,EAAK,KAAK,OAAQ,WAAY,GAAK,CAClD,CACF,EAAE,EAIR,MAAMf,EAAO,OAAO,CACtB,CAEA,eAAeM,EACbzC,EACAsC,EACAR,EACAS,EACA,CACA,GAAM,CAAE,OAAAY,EAAQ,WAAAnB,CAAW,EAAIH,EAAaC,CAAM,EAClD,MAAMC,EAAY/B,EAAQgC,CAAU,EAChCT,EAAUgB,CAAK,GACjB,MAAMG,EAAa1C,EAAQgC,EAAYO,CAAK,EAE9C,IAAMa,EAASpB,EAAW,QAAQqB,GAAMA,EAAE,IAAM,CAACA,EAAE,IAAI,IAAI,EAAI,CAAC,CAAE,EAClE,GAAID,EAAO,SAAW,EACpB,MAAM,IAAI,MACR,oCAAoCd,CAAM,8BAC5C,EAEF,MAAO,CACL,MAAOa,EAAO,CAAC,EACf,WAAYC,EACZ,SAAUA,EAAO,QAAQC,GAAKA,EAAE,OAAO,IAAIC,GAAKA,EAAE,EAAE,CAAC,CACvD,CACF,CAOO,SAASC,EAAc,CAC5B,OAAAvD,EACA,KAAAgB,EACA,IAAAV,EACA,SAAAsB,EACA,OAAAJ,EACA,OAAAC,CACF,EAKmB,CACjB,OAAO+B,EAAgBxD,EAAQ,SAAY,CACzC,IAAMoB,EAAa,MAAML,EAAyB,CAAE,OAAAf,EAAQ,KAAAgB,EAAM,IAAAV,CAAI,CAAC,EACjEgC,EAAShC,GAAO,qBACtB,GAAI,CACF,OAAO,MAAM+B,EAAqBrC,EAAQoB,EAAYkB,EAAQV,EAAU,CACtE,OAAAJ,EACA,OAAAC,CACF,CAAC,CACH,OAASgC,EAAG,CAGV,YAAMpC,EAAiBrB,EAAQ,MAAMQ,EAAY,EAAGY,EAAW,GAAG,EAAE,MAClE,IAAM,CAAC,CACT,EACMqC,CACR,CACF,CAAC,CACH",
6
+ "names": ["removeMolstarStructure", "plugin", "molstarStructure", "serialPerPlugin", "molstar", "loadMolstar", "PluginStateObject", "cell", "structureRootCell", "target", "q", "removeWithGhosts", "ref", "parseTrajectory", "plugin", "raw", "format", "commitDownload", "built", "download", "url", "molstar", "loadMolstar", "state", "isBinaryStructureUrl", "failures", "watch", "ref", "cell", "parseStructureTrajectory", "data", "parsedAs", "structureFormatFromContent", "structureFormatFromName", "trajectory", "removeWithGhosts", "DRAWN_CHAINS_POLYMER", "drawsPart", "chains", "filter", "DEPOSITED_MODEL", "rootStructure", "assembly", "presetOutput", "preset", "removeWater", "structures", "StateSelection", "StateTransforms", "update", "type", "applyStructurePreset", "source", "drawn", "params", "collectPreset", "drawOnlyPart", "MS", "chainTest", "residueTest", "drawnTests", "entityTest", "polymer", "CRYSTALLIZATION_ADDITIVES", "prev", "models", "loaded", "s", "m", "loadStructure", "serialPerPlugin", "e"]
7
+ }