jbrowse-plugin-protein3d 0.4.9 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LaunchProteinView/hooks/useAlphaFoldDBSearch.js +1 -1
- package/dist/jbrowse-plugin-protein3d.umd.production.min.js +2 -2
- package/dist/jbrowse-plugin-protein3d.umd.production.min.js.map +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/LaunchProteinView/hooks/useAlphaFoldDBSearch.ts +1 -3
- package/src/version.ts +1 -1
|
@@ -11,7 +11,7 @@ export default function useAlphaFoldDBSearch({ feature, view, }) {
|
|
|
11
11
|
const [lookupMode, setLookupMode] = useState('auto');
|
|
12
12
|
const [manualUniprotId, setManualUniprotId] = useState('');
|
|
13
13
|
const geneIds = extractFeatureIdentifiers(feature);
|
|
14
|
-
const [selectedQueryId, setSelectedQueryId] = useState(
|
|
14
|
+
const [selectedQueryId, setSelectedQueryId] = useState('auto');
|
|
15
15
|
const [sequenceSearchType, setSequenceSearchType] = useState('md5');
|
|
16
16
|
const [selectedUniprotId, setSelectedUniprotId] = useState();
|
|
17
17
|
const transcriptOptions = getTranscriptFeatures(feature);
|
|
@@ -18,13 +18,13 @@ ${c}`)].join(`
|
|
|
18
18
|
`),slotProps:{input:{readOnly:!0,classes:{input:n.textAreaFont}}}}))}var hr=u(x());Gt();var ka=u(Ot(),1),Ca=(0,Ie.createSvgIcon)((0,ka.jsx)("path",{d:"M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3z"}),"OpenInNew");var Ma=u(L());function Ae(e){let{children:t,...o}=e;return hr.default.createElement(Ma.Link,{...o,target:"_blank",rel:"noreferrer"},t," ",hr.default.createElement(Ca,{fontSize:"small"}))}ye();function Vm({uniprotId:e}){return me.default.createElement(jt.Typography,null,"No structure found for this UniProtID in AlphaFoldDB"," ",me.default.createElement(Ae,{href:`https://alphafold.ebi.ac.uk/search/text/${e}`},"(search for results)"))}function br({uniprotId:e,selectedTranscript:t,structureSequence:o,isoformSequences:n,url:r}){let[i,s]=(0,me.useState)(!1);return e?me.default.createElement(me.default.Fragment,null,me.default.createElement("div",null,me.default.createElement(jt.Typography,null,"UniProt link:"," ",me.default.createElement(Ae,{href:`https://www.uniprot.org/uniprotkb/${e}/entry`},e)),me.default.createElement(jt.Typography,null,"AlphaFoldDB link: ",me.default.createElement(Ae,{href:r},r))),o?me.default.createElement("div",{style:{margin:20}},me.default.createElement(jt.Button,{variant:"contained",color:"primary",onClick:()=>{s(!i)}},i?"Hide all isoform protein sequences":"Show all isoform protein sequences"),i?me.default.createElement(Co,{structureSequence:o,structureName:e,isoformSequences:n}):null):me.default.createElement(Vm,{uniprotId:e})):me.default.createElement(jt.Typography,null,"Searching"," ",t?Is(t):"transcript"," ","for UniProt ID")}var At=u(x()),rt=u(L());ye();function Bm(e){let t=tn(e);return t==="refseq"?e.startsWith("NM_")||e.startsWith("XM_")?`${e} (RefSeq mRNA)`:e.startsWith("NR_")||e.startsWith("XR_")?`${e} (RefSeq ncRNA)`:e.startsWith("NP_")||e.startsWith("XP_")?`${e} (RefSeq protein)`:`${e} (RefSeq)`:t==="ensembl"?e.includes("G")?`${e} (Ensembl gene)`:e.includes("T")?`${e} (Ensembl transcript)`:e.includes("P")?`${e} (Ensembl protein)`:`${e} (Ensembl)`:t==="hgnc"?`${e} (HGNC)`:t==="ccds"?`${e} (CCDS)`:e}function yr({recognizedIds:e,geneName:t,selectedId:o,onSelectedIdChange:n}){let[r,i]=(0,At.useState)(!1),s=[{value:"auto",label:"Auto (try all)"},...e.map(a=>({value:a,label:Bm(a)}))];return t&&s.push({value:`gene:${t}`,label:`${t} (gene name)`}),e.length===0&&!t?null:r?At.default.createElement(rt.FormControl,{size:"small"},At.default.createElement(rt.InputLabel,null,"Query UniProt by"),At.default.createElement(rt.Select,{value:o,label:"Query UniProt by",onChange:a=>{n(a.target.value)}},s.map(a=>At.default.createElement(rt.MenuItem,{key:a.value,value:a.value},a.label)))):At.default.createElement(rt.Button,{size:"small",variant:"text",onClick:()=>{i(!0)}},"Choose identifier to query...")}var ke=u(x()),Za=u(Oe());Gt();var Fa=u(Ot(),1),Ea=(0,Ie.createSvgIcon)((0,Fa.jsx)("path",{d:"m7 10 5 5 5-5z"}),"ArrowDropDown");var kt=u(L());var ht=u(x()),Le=u(L());function wr({open:e,onClose:t,options:o}){return ht.default.createElement(Le.Dialog,{open:e,onClose:t},ht.default.createElement(Le.DialogTitle,null,"Launch options"),ht.default.createElement(Le.DialogContent,null,ht.default.createElement(Le.MenuList,null,o.map(n=>ht.default.createElement(Le.MenuItem,{key:n.key,onClick:n.onClick},ht.default.createElement("div",null,ht.default.createElement(Le.Typography,{variant:"body1"},n.title),ht.default.createElement(Le.Typography,{variant:"body2",color:"text.secondary"},n.description)))))))}var Ar=u(x()),Ha=u(L());var k=u(x());Gt();var Ia=u(Ot(),1),mn=(0,Ie.createSvgIcon)((0,Ia.jsx)("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"}),"Settings");var T=u(L());Sr();var Tr={NEEDLEMAN_WUNSCH:"needleman_wunsch",SMITH_WATERMAN:"smith_waterman"},Mo="smith_waterman",Om=["needleman_wunsch","smith_waterman"];function Va(e){return Om.find(t=>t===e)??Mo}var Ba={needleman_wunsch:"Needleman-Wunsch",smith_waterman:"Smith-Waterman"};function Pr({value:e,onChange:t,onManualAlignment:o}){let[n,r]=(0,k.useState)(!1),[i,s]=(0,k.useState)(0),[a,l]=(0,k.useState)(e),[p,m]=(0,k.useState)(""),[c,d]=(0,k.useState)(),y=()=>{l(e),m(""),d(void 0),s(0),r(!0)},w=()=>{if(i===0)t(a);else if(i===1&&p.trim()&&o)try{let h=cn(p.trim());o(h)}catch(h){d(`Failed to parse alignment: ${h}`);return}r(!1)},f=()=>{l(e),m(""),d(void 0),r(!1)};return k.default.createElement(k.default.Fragment,null,k.default.createElement(T.IconButton,{onClick:y,size:"small",title:"Alignment settings"},k.default.createElement(mn,null)),k.default.createElement(T.Dialog,{open:n,onClose:f,maxWidth:"sm",fullWidth:!0},k.default.createElement(T.DialogTitle,null,"Alignment Settings"),k.default.createElement(T.DialogContent,null,k.default.createElement(T.Tabs,{value:i,onChange:(h,b)=>{s(b)},sx:{mb:2}},k.default.createElement(T.Tab,{label:"Automatic"}),k.default.createElement(T.Tab,{label:"Manual",disabled:!o})),i===0?k.default.createElement(k.default.Fragment,null,k.default.createElement(T.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2}},"Choose the algorithm for aligning transcript sequences to protein structures."),k.default.createElement(T.FormControl,{component:"fieldset"},k.default.createElement(T.FormLabel,{component:"legend"},"Algorithm"),k.default.createElement(T.RadioGroup,{value:a,onChange:h=>{l(h.target.value)}},k.default.createElement(T.FormControlLabel,{value:Tr.SMITH_WATERMAN,control:k.default.createElement(T.Radio,null),label:"Smith-Waterman (local alignment)"}),k.default.createElement(T.Typography,{variant:"caption",color:"text.secondary",sx:{ml:4,mt:-1,mb:1}},"Finds best matching region. Recommended for most use cases."),k.default.createElement(T.FormControlLabel,{value:Tr.NEEDLEMAN_WUNSCH,control:k.default.createElement(T.Radio,null),label:"Needleman-Wunsch (global alignment)"}),k.default.createElement(T.Typography,{variant:"caption",color:"text.secondary",sx:{ml:4,mt:-1,mb:1}},"End-to-end alignment. Use when sequences should align completely.")))):k.default.createElement(k.default.Fragment,null,k.default.createElement(T.Typography,{variant:"body2",color:"text.secondary",sx:{mb:2}},"Paste a pre-computed alignment in Clustal format. The first sequence should be the transcript and the second should be the structure."),k.default.createElement(T.TextField,{multiline:!0,rows:10,fullWidth:!0,placeholder:`Example:
|
|
19
19
|
a MKAAYLSMFGKEDHKPFGD
|
|
20
20
|
|||||||||||||||||||
|
|
21
|
-
b MKAAYLSMFGKEDHKPFGD`,value:p,onChange:h=>{m(h.target.value),d(void 0)},sx:{fontFamily:"monospace",fontSize:12}}),c?k.default.createElement(T.Typography,{color:"error",variant:"body2",sx:{mt:1}},c):null)),k.default.createElement(T.DialogActions,null,k.default.createElement(T.Button,{onClick:f},"Cancel"),k.default.createElement(T.Button,{onClick:w,variant:"contained",color:"primary",disabled:i===1&&!p.trim()},i===0?"Save":"Apply Alignment"))))}function Fo({alignmentAlgorithm:e,onAlignmentAlgorithmChange:t}){return Ar.default.createElement(Ha.Typography,{variant:"body2",sx:{mr:2,display:"flex",alignItems:"center"}},"Transcript and structure sequences differ, will run"," ",Ba[e]??e," ","alignment",Ar.default.createElement(Pr,{value:e,onChange:t}))}async function dn(e,t,o){try{await e(),t?.()}catch(n){console.error(n),o?.(n)}}function Ua({uniprotId:e,userSelectedProteinSequence:t,selectedTranscript:o,isLoading:n,error:r}){return n||r?[]:[!e&&"No UniProt ID found",!t&&"Could not compute protein sequence (feature may be missing CDS subfeatures)",!o&&"No transcript selected"].filter(i=>typeof i=="string")}it();function Mr({handleClose:e,uniprotId:t,userSelectedProteinSequence:o,selectedTranscript:n,url:r,confidenceUrl:i,feature:s,view:a,session:l,alignmentAlgorithm:p,onAlignmentAlgorithmChange:m,sequencesMatch:c,isLoading:d,error:y}){let[w,f]=(0,ke.useState)(!1),[h,b]=(0,ke.useState)(),g=!d&&!!t&&!!o&&!!n,C=Ua({uniprotId:t,userSelectedProteinSequence:o,selectedTranscript:n,isLoading:d,error:y}),H=()=>{f(!1)},S={session:l,view:a,feature:s,selectedTranscript:n,uniprotId:t},U={...S,url:r,userProvidedTranscriptSequence:o?.seq,alignmentAlgorithm:p},J=Pe=>()=>{H(),dn(Pe,e,b)},re=J(()=>{Wt(U)}),M=J(async()=>{await bn({...S,confidenceUrl:i})}),fe=J(()=>{Io(S)}),ue=J(()=>{$a(U)}),Fe=[{key:"3d",title:"Launch 3D protein structure view",description:"View protein structure with genome-to-structure coordinate mapping",onClick:re},{key:"1d",title:"Launch 1D protein annotation view",description:"View protein features and annotations as a linear track",onClick:M},...yn()?[{key:"msa",title:"Launch MSA view",description:"View AlphaFold a3m multiple sequence alignment",onClick:fe},{key:"3d-msa",title:"Launch 3D structure + MSA view",description:"Launch both views with AlphaFold a3m MSA",onClick:ue}]:[]];return ke.default.createElement(ke.default.Fragment,null,h?ke.default.createElement(Za.ErrorMessage,{error:h}):null,c===!1?ke.default.createElement(Fo,{alignmentAlgorithm:p,onAlignmentAlgorithmChange:m}):null,ke.default.createElement(kt.Button,{variant:"contained",color:"secondary",size:"small",onClick:()=>{e()}},"Cancel"),!g&&C.length>0?ke.default.createElement(kt.Typography,{variant:"body2",color:"error",sx:{mr:2}},C.join(". ")):null,ke.default.createElement(kt.ButtonGroup,{variant:"contained",color:"primary",size:"small"},ke.default.createElement(kt.Button,{disabled:!g,onClick:re},"Launch"),ke.default.createElement(kt.Button,{disabled:!g,onClick:()=>{f(!0)},"aria-label":"More launch options"},ke.default.createElement(Ea,null))),ke.default.createElement(wr,{open:w,onClose:H,options:Fe}))}var ao=u(x()),Fr=u(L());function Er({isLoading:e,uniprotId:t,url:o,hasProteinSequence:n,sequenceSearchType:r}){return e?null:!t&&n?ao.default.createElement(Fr.Typography,{color:"warning.main"},"No AlphaFold structure found for this sequence (searched by"," ",r==="md5"?"MD5 checksum":"full sequence",")"):t?ao.default.createElement(Fr.Typography,{color:"success.main"},"Found AlphaFold structure: ",t,o?ao.default.createElement(ao.default.Fragment,null," ","-"," ",ao.default.createElement("a",{href:o,target:"_blank",rel:"noreferrer"},o)):null):null}var Lo=u(x()),lo=u(L());ye();function Rt({val:e,setVal:t,isoforms:o,isoformSequences:n,structureSequence:r,feature:i,disabled:s}){let a=io(i),l=[],p=[],m=[];for(let d of o){let y=n[d.id()];y?r&&se(y.seq)===r?l.push(d):p.push(d):m.push(d)}let c=(d,y)=>n[y.id()].seq.length-n[d.id()].seq.length;return Lo.default.createElement(lo.TextField,{value:e??"",onChange:d=>{t(d.target.value)},label:"Choose transcript isoform",select:!0,disabled:s},l.toSorted(c).map(d=>Lo.default.createElement(lo.MenuItem,{value:d.id(),key:d.id()},a," - ",Ee(d)," (",n[d.id()].seq.length,"aa) (matches structure residues)")),p.toSorted(c).map(d=>Lo.default.createElement(lo.MenuItem,{value:d.id(),key:d.id()},a," - ",Ee(d)," (",n[d.id()].seq.length,"aa)")),m.map(d=>Lo.default.createElement(lo.MenuItem,{value:d.id(),key:d.id(),disabled:!0},a," - ",Ee(d)," (no data)")))}var B=u(x()),O=u(L());function Ir({lookupMode:e,onLookupModeChange:t,manualUniprotId:o,onManualUniprotIdChange:n,featureUniprotId:r,hasProteinSequence:i,sequenceSearchType:s,onSequenceSearchTypeChange:a,endContent:l}){return B.default.createElement(B.default.Fragment,null,B.default.createElement("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap"}},B.default.createElement(O.FormControl,{component:"fieldset"},B.default.createElement(O.RadioGroup,{row:!0,value:e,onChange:p=>{t(p.target.value)}},r&&B.default.createElement(O.FormControlLabel,{value:"feature",control:B.default.createElement(O.Radio,null),label:`From feature (${r})`}),B.default.createElement(O.FormControlLabel,{value:"auto",control:B.default.createElement(O.Radio,null),label:"Auto-detect using UniProt ID mapping API"}),B.default.createElement(O.FormControlLabel,{value:"manual",control:B.default.createElement(O.Radio,null),label:"Enter manually"}),i&&B.default.createElement(O.FormControlLabel,{value:"sequence",control:B.default.createElement(O.Radio,null),label:"Search sequence against AlphaFoldDB API"}))),l),e==="manual"&&B.default.createElement("div",null,B.default.createElement(O.TextField,{label:"UniProt ID",variant:"outlined",placeholder:"e.g. P68871",size:"small",value:o,onChange:p=>{n(p.target.value)}})),e==="sequence"&&s&&a&&B.default.createElement("div",null,B.default.createElement(O.FormControl,{component:"fieldset"},B.default.createElement(O.RadioGroup,{row:!0,value:s,onChange:p=>{a(p.target.value)}},B.default.createElement(O.FormControlLabel,{value:"md5",control:B.default.createElement(O.Radio,null),label:"Exact match"}),B.default.createElement(O.FormControlLabel,{value:"sequence",control:B.default.createElement(O.Radio,null),label:"Fuzzy match"}))),B.default.createElement(O.Typography,{variant:"body2",color:"text.secondary"},"May not find the canonical UniProt entry.")),e==="manual"&&!o&&B.default.createElement(O.Typography,{variant:"body2",color:"text.secondary"},"Search"," ",B.default.createElement(Ae,{href:"https://www.uniprot.org/"},"UniProt")," or ",B.default.createElement(Ae,{href:"https://alphafold.ebi.ac.uk/"},"AlphaFoldDB")))}var W=u(x()),q=u(L()),Xa=u(ot());var Ym=(0,Xa.makeStyles)()({tableContainer:{maxHeight:200},headerCell:{fontWeight:"bold",backgroundColor:"#f5f5f5"},selectedRow:{backgroundColor:"#e3f2fd"},clickableRow:{cursor:"pointer","&:hover":{backgroundColor:"#f5f5f5"}},reviewedChip:{backgroundColor:"#4caf50",color:"white",fontSize:"0.7rem",height:20},unreviewedChip:{backgroundColor:"#ff9800",color:"white",fontSize:"0.7rem",height:20}});function Lr({entries:e,selectedAccession:t,onSelect:o}){let{classes:n,cx:r}=Ym();return e.length===0?null:W.default.createElement("div",null,W.default.createElement(q.Typography,{variant:"body2",sx:{mb:1}},"Found ",e.length," UniProt entries. Select one:"),W.default.createElement(q.TableContainer,{component:q.Paper,className:n.tableContainer},W.default.createElement(q.Table,{size:"small",stickyHeader:!0},W.default.createElement(q.TableHead,null,W.default.createElement(q.TableRow,null,W.default.createElement(q.TableCell,{className:n.headerCell,padding:"checkbox"}),W.default.createElement(q.TableCell,{className:n.headerCell},"Accession"),W.default.createElement(q.TableCell,{className:n.headerCell},"Gene"),W.default.createElement(q.TableCell,{className:n.headerCell},"Organism"),W.default.createElement(q.TableCell,{className:n.headerCell},"Protein"),W.default.createElement(q.TableCell,{className:n.headerCell},"Status"))),W.default.createElement(q.TableBody,null,e.map(i=>W.default.createElement(q.TableRow,{key:i.accession,onClick:()=>{o(i.accession)},className:r(n.clickableRow,t===i.accession&&n.selectedRow)},W.default.createElement(q.TableCell,{padding:"checkbox"},W.default.createElement(q.Radio,{checked:t===i.accession,size:"small"})),W.default.createElement(q.TableCell,null,W.default.createElement(Ae,{href:`https://www.uniprot.org/uniprotkb/${i.accession}`},i.accession)),W.default.createElement(q.TableCell,null,i.geneName??"-"),W.default.createElement(q.TableCell,null,i.organismName??"-"),W.default.createElement(q.TableCell,null,i.proteinName?i.proteinName.length>40?`${i.proteinName.slice(0,40)}...`:i.proteinName:"-"),W.default.createElement(q.TableCell,null,W.default.createElement(q.Chip,{label:i.isReviewed?"Reviewed":"Unreviewed",size:"small",className:i.isReviewed?n.reviewedChip:n.unreviewedChip}))))))))}var bo=u(x());_t();async function In({plugin:e,trajectory:t,options:o}){let n=await e.builders.structure.createModel(t);return await e.builders.structure.hierarchy.applyPreset(t,"all-models",{useDefaultIfSingleModel:!0,representationPresetParams:o?.representationParams}),{model:n}}async function Ln({url:e,format:t="mmcif",isBinary:o,options:n,plugin:r}){let i=await r.builders.data.download({url:e,isBinary:o},{state:{isGhost:!0}}),s=await r.builders.structure.parseTrajectory(i,t);return In({plugin:r,trajectory:s,options:n})}function fo(e){return e.obj?.data.sequence.sequences.map(t=>Array.from(t.sequence.label.toArray()).join(""))}Bt();async function qn(e){let{createPluginUI:t,renderReact18:o}=await be(),n=document.createElement("div"),r=await t({target:n,render:o});try{return await e(r)}finally{r.unmount(),n.remove()}}async function Tc(e){return qn(async t=>{let{model:o}=await Ln({url:e,plugin:t});return fo(o)})}function No({url:e}){let{data:t,error:o,isLoading:n}=ze(e?["remote-structure",e]:null,async()=>{if(!e)return;let r=await Tc(e);if(!r)throw new Error("no sequences detected in file");return r},{revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,keepPreviousData:!0});return{error:o,isLoading:n,sequences:t}}it();function $r({uniprotId:e}){let t=e?fn(e):void 0,o=e?Ja(e):void 0,{sequences:n,isLoading:r,error:i}=No({url:t});return{isLoading:r,error:i,url:t,confidenceUrl:o,structureSequence:n?.[0]}}var kl=u(x());_t();async function Pc(e,t){let o=await fetch(e,t);if(!o.ok)throw new Error(`HTTP ${o.status} fetching ${e} ${await o.text()}`);return o}async function ho(e,t){return(await Pc(e,t)).json()}function Pl(e){return new Promise(t=>setTimeout(t,e))}function Ft(e,t){let o=(e&65535)+(t&65535);return(e>>16)+(t>>16)+(o>>16)<<16|o&65535}function Ac(e,t){return e<<t|e>>>32-t}function Dn(e,t,o,n,r,i){return Ft(Ac(Ft(Ft(t,e),Ft(n,i)),r),o)}function we(e,t,o,n,r,i,s){return Dn(t&o|~t&n,e,t,r,i,s)}function xe(e,t,o,n,r,i,s){return Dn(t&n|o&~n,e,t,r,i,s)}function ve(e,t,o,n,r,i,s){return Dn(t^o^n,e,t,r,i,s)}function Se(e,t,o,n,r,i,s){return Dn(o^(t|~n),e,t,r,i,s)}function kc(e,t){e[t>>5]|=128<<t%32,e[(t+64>>>9<<4)+14]=t;let o=1732584193,n=-271733879,r=-1732584194,i=271733878;for(let s=0;s<e.length;s+=16){let a=o,l=n,p=r,m=i;o=we(o,n,r,i,e[s]??0,7,-680876936),i=we(i,o,n,r,e[s+1]??0,12,-389564586),r=we(r,i,o,n,e[s+2]??0,17,606105819),n=we(n,r,i,o,e[s+3]??0,22,-1044525330),o=we(o,n,r,i,e[s+4]??0,7,-176418897),i=we(i,o,n,r,e[s+5]??0,12,1200080426),r=we(r,i,o,n,e[s+6]??0,17,-1473231341),n=we(n,r,i,o,e[s+7]??0,22,-45705983),o=we(o,n,r,i,e[s+8]??0,7,1770035416),i=we(i,o,n,r,e[s+9]??0,12,-1958414417),r=we(r,i,o,n,e[s+10]??0,17,-42063),n=we(n,r,i,o,e[s+11]??0,22,-1990404162),o=we(o,n,r,i,e[s+12]??0,7,1804603682),i=we(i,o,n,r,e[s+13]??0,12,-40341101),r=we(r,i,o,n,e[s+14]??0,17,-1502002290),n=we(n,r,i,o,e[s+15]??0,22,1236535329),o=xe(o,n,r,i,e[s+1]??0,5,-165796510),i=xe(i,o,n,r,e[s+6]??0,9,-1069501632),r=xe(r,i,o,n,e[s+11]??0,14,643717713),n=xe(n,r,i,o,e[s]??0,20,-373897302),o=xe(o,n,r,i,e[s+5]??0,5,-701558691),i=xe(i,o,n,r,e[s+10]??0,9,38016083),r=xe(r,i,o,n,e[s+15]??0,14,-660478335),n=xe(n,r,i,o,e[s+4]??0,20,-405537848),o=xe(o,n,r,i,e[s+9]??0,5,568446438),i=xe(i,o,n,r,e[s+14]??0,9,-1019803690),r=xe(r,i,o,n,e[s+3]??0,14,-187363961),n=xe(n,r,i,o,e[s+8]??0,20,1163531501),o=xe(o,n,r,i,e[s+13]??0,5,-1444681467),i=xe(i,o,n,r,e[s+2]??0,9,-51403784),r=xe(r,i,o,n,e[s+7]??0,14,1735328473),n=xe(n,r,i,o,e[s+12]??0,20,-1926607734),o=ve(o,n,r,i,e[s+5]??0,4,-378558),i=ve(i,o,n,r,e[s+8]??0,11,-2022574463),r=ve(r,i,o,n,e[s+11]??0,16,1839030562),n=ve(n,r,i,o,e[s+14]??0,23,-35309556),o=ve(o,n,r,i,e[s+1]??0,4,-1530992060),i=ve(i,o,n,r,e[s+4]??0,11,1272893353),r=ve(r,i,o,n,e[s+7]??0,16,-155497632),n=ve(n,r,i,o,e[s+10]??0,23,-1094730640),o=ve(o,n,r,i,e[s+13]??0,4,681279174),i=ve(i,o,n,r,e[s]??0,11,-358537222),r=ve(r,i,o,n,e[s+3]??0,16,-722521979),n=ve(n,r,i,o,e[s+6]??0,23,76029189),o=ve(o,n,r,i,e[s+9]??0,4,-640364487),i=ve(i,o,n,r,e[s+12]??0,11,-421815835),r=ve(r,i,o,n,e[s+15]??0,16,530742520),n=ve(n,r,i,o,e[s+2]??0,23,-995338651),o=Se(o,n,r,i,e[s]??0,6,-198630844),i=Se(i,o,n,r,e[s+7]??0,10,1126891415),r=Se(r,i,o,n,e[s+14]??0,15,-1416354905),n=Se(n,r,i,o,e[s+5]??0,21,-57434055),o=Se(o,n,r,i,e[s+12]??0,6,1700485571),i=Se(i,o,n,r,e[s+3]??0,10,-1894986606),r=Se(r,i,o,n,e[s+10]??0,15,-1051523),n=Se(n,r,i,o,e[s+1]??0,21,-2054922799),o=Se(o,n,r,i,e[s+8]??0,6,1873313359),i=Se(i,o,n,r,e[s+15]??0,10,-30611744),r=Se(r,i,o,n,e[s+6]??0,15,-1560198380),n=Se(n,r,i,o,e[s+13]??0,21,1309151649),o=Se(o,n,r,i,e[s+4]??0,6,-145523070),i=Se(i,o,n,r,e[s+11]??0,10,-1120210379),r=Se(r,i,o,n,e[s+2]??0,15,718787259),n=Se(n,r,i,o,e[s+9]??0,21,-343485551),o=Ft(o,a),n=Ft(n,l),r=Ft(r,p),i=Ft(i,m)}return[o,n,r,i]}function Cc(e){let t="0123456789abcdef",o="";for(let n=0;n<e.length*4;n++)o+=t.charAt(e[n>>2]>>n%4*8+4&15)+t.charAt(e[n>>2]>>n%4*8&15);return o}function Mc(e){let t=[];for(let n=0;n<e.length*8;n+=8)t[n>>5]=(t[n>>5]??0)|(e.charCodeAt(n/8)&255)<<n%32;return t}function Al(e){return Cc(kc(Mc(e),e.length*8))}ye();function Zr({sequence:e,searchType:t,enabled:o=!0}){let n=(0,kl.useMemo)(()=>{if(!e)return;let a=se(e.toUpperCase());return t==="md5"?Al(a):a},[e,t]),{data:r,error:i,isLoading:s}=ze(o&&n?`https://alphafold.ebi.ac.uk/api/sequence/summary?id=${encodeURIComponent(n)}&type=${t}`:null,ho,{revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,keepPreviousData:!0});return{isLoading:s,result:r,uniprotId:r?.uniprotAccession,cifUrl:r?.cifUrl,plddtDocUrl:r?.plddtDocUrl,structureSequence:r?.sequence,error:i}}var Nn=u(x());function Xr(e,t=300){let[o,n]=(0,Nn.useState)(e);return(0,Nn.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(r)}},[e,t]),o}_t();var Ml=u(ko()),Et=u(X());function Fc(e,t){return e.map(o=>t.slice(o.start,o.end)).join("")}function Ec({cds:e,sequence:t,codonTable:o}){let n=Fc(e,t),r="";for(let i=0;i<n.length;i+=3)r+=o[n.slice(i,i+3)]??"&";return r}function Ic(e,t){return e.map(o=>({...o,start:t-o.end,end:t-o.start})).toSorted((o,n)=>o.start-n.start)}function Cl(e){return`${e.start}-${e.end}`}function Lc(e){return e.filter((t,o,n)=>!o||Cl(t)!==Cl(n[o-1]))}function qc({feature:e,seq:t}){let o=e.get("start"),n=e.get("strand"),r=e.get("subfeatures")??[],i=Lc(r.toSorted((s,a)=>s.get("start")-a.get("start")).map(s=>({start:s.get("start")-o,end:s.get("end")-o,type:s.get("type")})).filter(s=>s.type==="CDS"));return Ec({cds:n===-1?Ic(i,t.length):i,sequence:n===-1?(0,Et.revcom)(t):t,codonTable:(0,Et.generateCodonTable)(Et.defaultCodonTable)})}async function Fl({feature:e,view:t}){let o=e.get("start"),n=e.get("end"),r=e.get("refName"),i=(0,Et.getSession)(t),{assemblyManager:s,rpcManager:a}=i,l=t?.assemblyNames?.[0],p=l?await s.waitForAssembly(l):void 0;if(!p)throw new Error("assembly not found");let m="getSequence",c=await a.call(m,"CoreGetFeatures",{adapterConfig:(0,Ml.getConf)(p,["sequence","adapter"]),sessionId:m,regions:[{start:o,end:n,refName:p.getCanonicalRefName(r),assemblyName:l}]}),[d]=c,y=d?.get("seq");return y?qc({seq:y,feature:e}):void 0}ye();function Jt({feature:e,view:t}){let{data:o,error:n,isLoading:r}=ze(["isoform-sequences",e.id(),t?.assemblyNames?.[0]],async()=>{let i=gt(e),s=[],l=(await Promise.all(i.map(async p=>{try{let m=await Fl({view:t,feature:p});return m?[p.id(),{feature:p,seq:m}]:void 0}catch(m){console.error("[useIsoformProteinSequences] error for",p.id(),m),s.push(m);return}}))).filter(p=>p!==void 0);if(l.length===0&&s.length===i.length&&s.length>0)throw s[0];return Object.fromEntries(l)},{revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,keepPreviousData:!0});return{isLoading:r,isoformSequences:o,error:n}}var Vo=u(x());ye();function Kt({options:e,isoformSequences:t,structureSequence:o,resetKey:n}){let[r,i]=(0,Vo.useState)(),[s,a]=(0,Vo.useState)(n);n!==s&&(a(n),i(void 0));let l=(0,Vo.useMemo)(()=>t!==void 0?Us({options:e,isoformSequences:t,structureSequence:o})?.id():void 0,[e,o,t]);return{userSelection:r??l,setUserSelection:i}}_t();ye();var Dc="accession,id,gene_names,organism_name,protein_name,reviewed";function Nc(e){return{accession:e.primaryAccession,id:e.uniProtkbId,geneName:e.genes?.[0]?.geneName?.value,organismName:e.organism?.commonName??e.organism?.scientificName,proteinName:e.proteinDescription?.recommendedName?.fullName?.value,isReviewed:e.entryType==="UniProtKB reviewed (Swiss-Prot)"}}function Vc(e){switch(tn(e)){case"ensembl":return`xref:ensembl-${e}`;case"refseq":return`xref:refseq-${e}`;case"ccds":return`xref:ccds-${e}`;case"hgnc":return`xref:hgnc-${e.replace("HGNC:","")}`;default:return}}async function Il(e,t=10){let o=`https://rest.uniprot.org/uniprotkb/search?query=${encodeURIComponent(e)}&fields=${Dc}&size=${t}`;return(await ho(o)).results.map(Nc)}async function Bc(e){let t=Vc(e);if(!t)return{entries:[],error:void 0};try{return{entries:await Il(t),error:void 0}}catch(o){return console.error(`xref search failed for ${e}:`,o),{entries:[],error:o}}}function El(e){let t=new Set,o=[];for(let n of e)t.has(n.accession)||(t.add(n.accession),o.push(n));return o}async function Ll({recognizedIds:e=[],geneId:t,geneName:o,organismId:n=9606}){let r=new Set(e),i=t?Es(t):void 0;i&&Tt(i)&&r.add(i);let s=await Promise.all([...r].map(Bc)),a=El(s.flatMap(m=>m.entries)),l=s.filter(m=>m.error!==void 0),p;if(!a.some(m=>m.isReviewed)&&o)try{let m=`gene:${o}+AND+organism_id:${n}+AND+reviewed:true`,c=await Il(m,5);a=El([...a,...c])}catch(m){console.error(`gene name search failed for ${o}:`,m),p=m}if(a.length===0){let m=r.size+(o?1:0),c=l.length+(p?1:0);if(m>0&&m===c)throw p??l[0]?.error}return a.toSorted((m,c)=>Number(c.isReviewed)-Number(m.isReviewed))}ye();function Qr({recognizedIds:e=[],geneId:t,geneName:o,selectedQueryId:n="auto",enabled:r=!0}){let i=[],s;n==="auto"?(i=e,s=o):n.startsWith("gene:")?s=n.replace("gene:",""):Tt(n)&&(i=[n]);let a=i.some(c=>Tt(c))||!!s,{data:l,error:p,isLoading:m}=ze(r&&a?["uniprotSearch",n,i.join(","),s]:null,async()=>Ll({recognizedIds:i,geneId:t,geneName:s}),{revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,keepPreviousData:!0});return{entries:l??[],isLoading:m,error:p,hasValidId:a}}function Vn({selectedQueryId:e,recognizedIds:t,geneName:o,joinWord:n="and"}){return e==="auto"?[t.length>0?`database ID${t.length>1?"s":""} "${t.join('", "')}"`:void 0,o?`gene name "${o}"`:void 0].filter(Boolean).join(` ${n} `):e.startsWith("gene:")?`gene name "${e.replace("gene:","")}"`:`database ID "${e}"`}ye();function ei({feature:e,view:t}){let[o,n]=(0,bo.useState)("auto"),[r,i]=(0,bo.useState)(""),s=Hs(e),[a,l]=(0,bo.useState)(s.recognizedIds[0]??"auto"),[p,m]=(0,bo.useState)("md5"),[c,d]=(0,bo.useState)(),y=gt(e),w=s.uniprotId,f=o==="auto"&&w?"feature":o,h=f==="sequence",b=f==="auto",{isoformSequences:g,isLoading:C,error:H}=Jt({feature:e,view:t}),{entries:S,isLoading:U,error:J}=Qr({recognizedIds:s.recognizedIds,geneId:s.geneId,geneName:s.geneName,selectedQueryId:a,enabled:b}),re=Xr(r,400),M=S[0]?.accession,fe=f==="feature"?w:b?c??M:f==="manual"?re:void 0,{isLoading:ue,error:Fe,url:Pe,confidenceUrl:ee,structureSequence:Be}=$r({uniprotId:h?void 0:fe}),{userSelection:te,setUserSelection:We}=Kt({options:y,isoformSequences:g,structureSequence:Be,resetKey:fe}),Re=y.find(ct=>en(ct)===te),he=te?g?.[te]:void 0,{uniprotId:oe,cifUrl:oo,plddtDocUrl:et,structureSequence:_e,isLoading:ut,error:He}=Zr({sequence:he?.seq,searchType:p,enabled:h}),Vt=h?oo:Pe,mt=h?et:ee,Je=h?_e:Be,xo=h?oe:fe,vo=[U&&"Looking up UniProt ID",C&&"Loading protein sequences from transcript isoforms",!h&&ue&&"Fetching AlphaFold structure URL",h&&ut&&"Searching AlphaFoldDB by sequence"].filter(ct=>!!ct),So=vo.length>0,or=So?void 0:H??J??Fe??He;return{lookupMode:f,setLookupMode:n,manualUniprotId:r,setManualUniprotId:i,selectedQueryId:a,setSelectedQueryId:l,sequenceSearchType:p,setSequenceSearchType:m,selectedUniprotId:c,setSelectedUniprotId:d,userSelection:te,setUserSelection:We,transcriptOptions:y,selectedTranscript:Re,isoformSequences:g,userSelectedProteinSequence:he,uniprotEntries:S,recognizedIds:s.recognizedIds,geneName:s.geneName,featureUniprotId:w,uniprotId:xo,url:Vt,confidenceUrl:mt,structureSequence:Je,error:or,loadingStatuses:vo,isSequenceSearchLoading:ut,showIdentifierSelector:b&&(s.recognizedIds.length>0||!!s.geneName),showStructureSelectors:!!g&&!!Re&&(h||!!(Je&&xo)),sequencesMatch:he?.seq&&Je?se(he.seq)===Je:void 0,searchDescription:Vn({selectedQueryId:a,recognizedIds:s.recognizedIds,geneName:s.geneName}),searchDescriptionOr:Vn({selectedQueryId:a,recognizedIds:s.recognizedIds,geneName:s.geneName,joinWord:"or"}),selectedTableAccession:c??M,showUniprotResults:!!g&&b&&(S.length>0||U),showNoResults:!!g&&b&&!U&&S.length===0,showSequenceSearchStatus:h,showAlphaFoldDBSearchStatus:!!Je&&!!xo&&!h,isLoading:So}}var Hc=(0,Dl.makeStyles)()({dialogContent:{width:"80em","& > *":{marginBottom:20},"& > *:last-child":{marginBottom:0}},selectorsRow:{display:"flex",flexDirection:"row",gap:20,alignItems:"flex-start"}}),Uc=(0,ql.observer)(function({feature:t,model:o,handleClose:n,alignmentAlgorithm:r,onAlignmentAlgorithmChange:i}){let{classes:s}=Hc(),a=(0,Hn.getSession)(o),l=(0,Hn.getContainingView)(o),p=ei({feature:t,view:l});return R.default.createElement(R.default.Fragment,null,R.default.createElement(It.DialogContent,{className:s.dialogContent},p.error?R.default.createElement(Bn.ErrorMessage,{error:p.error}):null,R.default.createElement(Ir,{lookupMode:p.lookupMode,onLookupModeChange:p.setLookupMode,manualUniprotId:p.manualUniprotId,onManualUniprotIdChange:p.setManualUniprotId,featureUniprotId:p.featureUniprotId,hasProteinSequence:!!p.userSelectedProteinSequence?.seq,sequenceSearchType:p.sequenceSearchType,onSequenceSearchTypeChange:p.setSequenceSearchType,endContent:p.showIdentifierSelector?R.default.createElement(yr,{recognizedIds:p.recognizedIds,geneName:p.geneName,selectedId:p.selectedQueryId,onSelectedIdChange:p.setSelectedQueryId}):null}),p.loadingStatuses.map(m=>R.default.createElement(Bn.LoadingEllipses,{key:m,variant:"subtitle2",message:m})),p.showUniprotResults&&R.default.createElement(R.default.Fragment,null,R.default.createElement(It.Typography,{variant:"body2",color:"textSecondary"},"Searched UniProt by ",p.searchDescription),R.default.createElement(Lr,{entries:p.uniprotEntries,selectedAccession:p.selectedTableAccession,onSelect:p.setSelectedUniprotId}),R.default.createElement(It.Typography,{variant:"body2",color:"textSecondary"},"If you don't see the entry you're looking for, try a different identifier above or search"," ",R.default.createElement(Ae,{href:"https://www.uniprot.org/"},"UniProt")," ",'directly and use "Enter manually".')),p.showNoResults&&R.default.createElement(It.Typography,{variant:"body2",color:"textSecondary"},"No UniProt entries found for ",p.searchDescriptionOr,". Try a different identifier above, or search"," ",R.default.createElement(Ae,{href:"https://www.uniprot.org/"},"UniProt")," ",'directly and use "Enter manually" above, or use "Search sequence against AlphaFoldDB API" if available.'),p.showStructureSelectors&&R.default.createElement(R.default.Fragment,null,R.default.createElement("div",{className:s.selectorsRow},R.default.createElement(Rt,{val:p.userSelection,setVal:p.setUserSelection,structureSequence:p.structureSequence,feature:t,isoforms:p.transcriptOptions,isoformSequences:p.isoformSequences})),p.showSequenceSearchStatus&&R.default.createElement(Er,{isLoading:p.isSequenceSearchLoading,uniprotId:p.uniprotId,url:p.url,hasProteinSequence:!!p.userSelectedProteinSequence,sequenceSearchType:p.sequenceSearchType}),p.showAlphaFoldDBSearchStatus&&R.default.createElement(br,{uniprotId:p.uniprotId,selectedTranscript:p.selectedTranscript,structureSequence:p.structureSequence,isoformSequences:p.isoformSequences,url:p.url}))),R.default.createElement(It.DialogActions,null,R.default.createElement(Mr,{handleClose:n,uniprotId:p.uniprotId,userSelectedProteinSequence:p.userSelectedProteinSequence,selectedTranscript:p.selectedTranscript,url:p.url,confidenceUrl:p.confidenceUrl,feature:t,view:l,session:a,alignmentAlgorithm:r,onAlignmentAlgorithmChange:i,sequencesMatch:p.sequencesMatch,isLoading:p.isLoading,error:p.error})))}),Nl=Uc;var _=u(x()),Bo=u(Oe()),Gn=u(X()),Me=u(L()),Wl=u(j()),Rl=u(ot());var st=u(x()),Xe=u(L()),Ul=u(ot());var ti=[{id:"pdb100",label:"PDB (100% redundancy)"},{id:"afdb-swissprot",label:"AlphaFold DB (Swiss-Prot)"},{id:"afdb50",label:"AlphaFold DB (50% redundancy)"},{id:"afdb-proteome",label:"AlphaFold DB (Proteomes)"},{id:"cath50",label:"CATH (50% redundancy)"},{id:"mgnify_esm30",label:"MGnify ESM30"},{id:"bfmd",label:"BFMD"},{id:"gmgcl_id",label:"GMGCL"}],Un=["pdb100","afdb-swissprot"];async function Vl(e){let t=e.split(`
|
|
21
|
+
b MKAAYLSMFGKEDHKPFGD`,value:p,onChange:h=>{m(h.target.value),d(void 0)},sx:{fontFamily:"monospace",fontSize:12}}),c?k.default.createElement(T.Typography,{color:"error",variant:"body2",sx:{mt:1}},c):null)),k.default.createElement(T.DialogActions,null,k.default.createElement(T.Button,{onClick:f},"Cancel"),k.default.createElement(T.Button,{onClick:w,variant:"contained",color:"primary",disabled:i===1&&!p.trim()},i===0?"Save":"Apply Alignment"))))}function Fo({alignmentAlgorithm:e,onAlignmentAlgorithmChange:t}){return Ar.default.createElement(Ha.Typography,{variant:"body2",sx:{mr:2,display:"flex",alignItems:"center"}},"Transcript and structure sequences differ, will run"," ",Ba[e]??e," ","alignment",Ar.default.createElement(Pr,{value:e,onChange:t}))}async function dn(e,t,o){try{await e(),t?.()}catch(n){console.error(n),o?.(n)}}function Ua({uniprotId:e,userSelectedProteinSequence:t,selectedTranscript:o,isLoading:n,error:r}){return n||r?[]:[!e&&"No UniProt ID found",!t&&"Could not compute protein sequence (feature may be missing CDS subfeatures)",!o&&"No transcript selected"].filter(i=>typeof i=="string")}it();function Mr({handleClose:e,uniprotId:t,userSelectedProteinSequence:o,selectedTranscript:n,url:r,confidenceUrl:i,feature:s,view:a,session:l,alignmentAlgorithm:p,onAlignmentAlgorithmChange:m,sequencesMatch:c,isLoading:d,error:y}){let[w,f]=(0,ke.useState)(!1),[h,b]=(0,ke.useState)(),g=!d&&!!t&&!!o&&!!n,C=Ua({uniprotId:t,userSelectedProteinSequence:o,selectedTranscript:n,isLoading:d,error:y}),H=()=>{f(!1)},S={session:l,view:a,feature:s,selectedTranscript:n,uniprotId:t},U={...S,url:r,userProvidedTranscriptSequence:o?.seq,alignmentAlgorithm:p},J=Pe=>()=>{H(),dn(Pe,e,b)},re=J(()=>{Wt(U)}),M=J(async()=>{await bn({...S,confidenceUrl:i})}),fe=J(()=>{Io(S)}),ue=J(()=>{$a(U)}),Fe=[{key:"3d",title:"Launch 3D protein structure view",description:"View protein structure with genome-to-structure coordinate mapping",onClick:re},{key:"1d",title:"Launch 1D protein annotation view",description:"View protein features and annotations as a linear track",onClick:M},...yn()?[{key:"msa",title:"Launch MSA view",description:"View AlphaFold a3m multiple sequence alignment",onClick:fe},{key:"3d-msa",title:"Launch 3D structure + MSA view",description:"Launch both views with AlphaFold a3m MSA",onClick:ue}]:[]];return ke.default.createElement(ke.default.Fragment,null,h?ke.default.createElement(Za.ErrorMessage,{error:h}):null,c===!1?ke.default.createElement(Fo,{alignmentAlgorithm:p,onAlignmentAlgorithmChange:m}):null,ke.default.createElement(kt.Button,{variant:"contained",color:"secondary",size:"small",onClick:()=>{e()}},"Cancel"),!g&&C.length>0?ke.default.createElement(kt.Typography,{variant:"body2",color:"error",sx:{mr:2}},C.join(". ")):null,ke.default.createElement(kt.ButtonGroup,{variant:"contained",color:"primary",size:"small"},ke.default.createElement(kt.Button,{disabled:!g,onClick:re},"Launch"),ke.default.createElement(kt.Button,{disabled:!g,onClick:()=>{f(!0)},"aria-label":"More launch options"},ke.default.createElement(Ea,null))),ke.default.createElement(wr,{open:w,onClose:H,options:Fe}))}var ao=u(x()),Fr=u(L());function Er({isLoading:e,uniprotId:t,url:o,hasProteinSequence:n,sequenceSearchType:r}){return e?null:!t&&n?ao.default.createElement(Fr.Typography,{color:"warning.main"},"No AlphaFold structure found for this sequence (searched by"," ",r==="md5"?"MD5 checksum":"full sequence",")"):t?ao.default.createElement(Fr.Typography,{color:"success.main"},"Found AlphaFold structure: ",t,o?ao.default.createElement(ao.default.Fragment,null," ","-"," ",ao.default.createElement("a",{href:o,target:"_blank",rel:"noreferrer"},o)):null):null}var Lo=u(x()),lo=u(L());ye();function Rt({val:e,setVal:t,isoforms:o,isoformSequences:n,structureSequence:r,feature:i,disabled:s}){let a=io(i),l=[],p=[],m=[];for(let d of o){let y=n[d.id()];y?r&&se(y.seq)===r?l.push(d):p.push(d):m.push(d)}let c=(d,y)=>n[y.id()].seq.length-n[d.id()].seq.length;return Lo.default.createElement(lo.TextField,{value:e??"",onChange:d=>{t(d.target.value)},label:"Choose transcript isoform",select:!0,disabled:s},l.toSorted(c).map(d=>Lo.default.createElement(lo.MenuItem,{value:d.id(),key:d.id()},a," - ",Ee(d)," (",n[d.id()].seq.length,"aa) (matches structure residues)")),p.toSorted(c).map(d=>Lo.default.createElement(lo.MenuItem,{value:d.id(),key:d.id()},a," - ",Ee(d)," (",n[d.id()].seq.length,"aa)")),m.map(d=>Lo.default.createElement(lo.MenuItem,{value:d.id(),key:d.id(),disabled:!0},a," - ",Ee(d)," (no data)")))}var B=u(x()),O=u(L());function Ir({lookupMode:e,onLookupModeChange:t,manualUniprotId:o,onManualUniprotIdChange:n,featureUniprotId:r,hasProteinSequence:i,sequenceSearchType:s,onSequenceSearchTypeChange:a,endContent:l}){return B.default.createElement(B.default.Fragment,null,B.default.createElement("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap"}},B.default.createElement(O.FormControl,{component:"fieldset"},B.default.createElement(O.RadioGroup,{row:!0,value:e,onChange:p=>{t(p.target.value)}},r&&B.default.createElement(O.FormControlLabel,{value:"feature",control:B.default.createElement(O.Radio,null),label:`From feature (${r})`}),B.default.createElement(O.FormControlLabel,{value:"auto",control:B.default.createElement(O.Radio,null),label:"Auto-detect using UniProt ID mapping API"}),B.default.createElement(O.FormControlLabel,{value:"manual",control:B.default.createElement(O.Radio,null),label:"Enter manually"}),i&&B.default.createElement(O.FormControlLabel,{value:"sequence",control:B.default.createElement(O.Radio,null),label:"Search sequence against AlphaFoldDB API"}))),l),e==="manual"&&B.default.createElement("div",null,B.default.createElement(O.TextField,{label:"UniProt ID",variant:"outlined",placeholder:"e.g. P68871",size:"small",value:o,onChange:p=>{n(p.target.value)}})),e==="sequence"&&s&&a&&B.default.createElement("div",null,B.default.createElement(O.FormControl,{component:"fieldset"},B.default.createElement(O.RadioGroup,{row:!0,value:s,onChange:p=>{a(p.target.value)}},B.default.createElement(O.FormControlLabel,{value:"md5",control:B.default.createElement(O.Radio,null),label:"Exact match"}),B.default.createElement(O.FormControlLabel,{value:"sequence",control:B.default.createElement(O.Radio,null),label:"Fuzzy match"}))),B.default.createElement(O.Typography,{variant:"body2",color:"text.secondary"},"May not find the canonical UniProt entry.")),e==="manual"&&!o&&B.default.createElement(O.Typography,{variant:"body2",color:"text.secondary"},"Search"," ",B.default.createElement(Ae,{href:"https://www.uniprot.org/"},"UniProt")," or ",B.default.createElement(Ae,{href:"https://alphafold.ebi.ac.uk/"},"AlphaFoldDB")))}var W=u(x()),q=u(L()),Xa=u(ot());var Ym=(0,Xa.makeStyles)()({tableContainer:{maxHeight:200},headerCell:{fontWeight:"bold",backgroundColor:"#f5f5f5"},selectedRow:{backgroundColor:"#e3f2fd"},clickableRow:{cursor:"pointer","&:hover":{backgroundColor:"#f5f5f5"}},reviewedChip:{backgroundColor:"#4caf50",color:"white",fontSize:"0.7rem",height:20},unreviewedChip:{backgroundColor:"#ff9800",color:"white",fontSize:"0.7rem",height:20}});function Lr({entries:e,selectedAccession:t,onSelect:o}){let{classes:n,cx:r}=Ym();return e.length===0?null:W.default.createElement("div",null,W.default.createElement(q.Typography,{variant:"body2",sx:{mb:1}},"Found ",e.length," UniProt entries. Select one:"),W.default.createElement(q.TableContainer,{component:q.Paper,className:n.tableContainer},W.default.createElement(q.Table,{size:"small",stickyHeader:!0},W.default.createElement(q.TableHead,null,W.default.createElement(q.TableRow,null,W.default.createElement(q.TableCell,{className:n.headerCell,padding:"checkbox"}),W.default.createElement(q.TableCell,{className:n.headerCell},"Accession"),W.default.createElement(q.TableCell,{className:n.headerCell},"Gene"),W.default.createElement(q.TableCell,{className:n.headerCell},"Organism"),W.default.createElement(q.TableCell,{className:n.headerCell},"Protein"),W.default.createElement(q.TableCell,{className:n.headerCell},"Status"))),W.default.createElement(q.TableBody,null,e.map(i=>W.default.createElement(q.TableRow,{key:i.accession,onClick:()=>{o(i.accession)},className:r(n.clickableRow,t===i.accession&&n.selectedRow)},W.default.createElement(q.TableCell,{padding:"checkbox"},W.default.createElement(q.Radio,{checked:t===i.accession,size:"small"})),W.default.createElement(q.TableCell,null,W.default.createElement(Ae,{href:`https://www.uniprot.org/uniprotkb/${i.accession}`},i.accession)),W.default.createElement(q.TableCell,null,i.geneName??"-"),W.default.createElement(q.TableCell,null,i.organismName??"-"),W.default.createElement(q.TableCell,null,i.proteinName?i.proteinName.length>40?`${i.proteinName.slice(0,40)}...`:i.proteinName:"-"),W.default.createElement(q.TableCell,null,W.default.createElement(q.Chip,{label:i.isReviewed?"Reviewed":"Unreviewed",size:"small",className:i.isReviewed?n.reviewedChip:n.unreviewedChip}))))))))}var bo=u(x());_t();async function In({plugin:e,trajectory:t,options:o}){let n=await e.builders.structure.createModel(t);return await e.builders.structure.hierarchy.applyPreset(t,"all-models",{useDefaultIfSingleModel:!0,representationPresetParams:o?.representationParams}),{model:n}}async function Ln({url:e,format:t="mmcif",isBinary:o,options:n,plugin:r}){let i=await r.builders.data.download({url:e,isBinary:o},{state:{isGhost:!0}}),s=await r.builders.structure.parseTrajectory(i,t);return In({plugin:r,trajectory:s,options:n})}function fo(e){return e.obj?.data.sequence.sequences.map(t=>Array.from(t.sequence.label.toArray()).join(""))}Bt();async function qn(e){let{createPluginUI:t,renderReact18:o}=await be(),n=document.createElement("div"),r=await t({target:n,render:o});try{return await e(r)}finally{r.unmount(),n.remove()}}async function Tc(e){return qn(async t=>{let{model:o}=await Ln({url:e,plugin:t});return fo(o)})}function No({url:e}){let{data:t,error:o,isLoading:n}=ze(e?["remote-structure",e]:null,async()=>{if(!e)return;let r=await Tc(e);if(!r)throw new Error("no sequences detected in file");return r},{revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,keepPreviousData:!0});return{error:o,isLoading:n,sequences:t}}it();function $r({uniprotId:e}){let t=e?fn(e):void 0,o=e?Ja(e):void 0,{sequences:n,isLoading:r,error:i}=No({url:t});return{isLoading:r,error:i,url:t,confidenceUrl:o,structureSequence:n?.[0]}}var kl=u(x());_t();async function Pc(e,t){let o=await fetch(e,t);if(!o.ok)throw new Error(`HTTP ${o.status} fetching ${e} ${await o.text()}`);return o}async function ho(e,t){return(await Pc(e,t)).json()}function Pl(e){return new Promise(t=>setTimeout(t,e))}function Ft(e,t){let o=(e&65535)+(t&65535);return(e>>16)+(t>>16)+(o>>16)<<16|o&65535}function Ac(e,t){return e<<t|e>>>32-t}function Dn(e,t,o,n,r,i){return Ft(Ac(Ft(Ft(t,e),Ft(n,i)),r),o)}function we(e,t,o,n,r,i,s){return Dn(t&o|~t&n,e,t,r,i,s)}function xe(e,t,o,n,r,i,s){return Dn(t&n|o&~n,e,t,r,i,s)}function ve(e,t,o,n,r,i,s){return Dn(t^o^n,e,t,r,i,s)}function Se(e,t,o,n,r,i,s){return Dn(o^(t|~n),e,t,r,i,s)}function kc(e,t){e[t>>5]|=128<<t%32,e[(t+64>>>9<<4)+14]=t;let o=1732584193,n=-271733879,r=-1732584194,i=271733878;for(let s=0;s<e.length;s+=16){let a=o,l=n,p=r,m=i;o=we(o,n,r,i,e[s]??0,7,-680876936),i=we(i,o,n,r,e[s+1]??0,12,-389564586),r=we(r,i,o,n,e[s+2]??0,17,606105819),n=we(n,r,i,o,e[s+3]??0,22,-1044525330),o=we(o,n,r,i,e[s+4]??0,7,-176418897),i=we(i,o,n,r,e[s+5]??0,12,1200080426),r=we(r,i,o,n,e[s+6]??0,17,-1473231341),n=we(n,r,i,o,e[s+7]??0,22,-45705983),o=we(o,n,r,i,e[s+8]??0,7,1770035416),i=we(i,o,n,r,e[s+9]??0,12,-1958414417),r=we(r,i,o,n,e[s+10]??0,17,-42063),n=we(n,r,i,o,e[s+11]??0,22,-1990404162),o=we(o,n,r,i,e[s+12]??0,7,1804603682),i=we(i,o,n,r,e[s+13]??0,12,-40341101),r=we(r,i,o,n,e[s+14]??0,17,-1502002290),n=we(n,r,i,o,e[s+15]??0,22,1236535329),o=xe(o,n,r,i,e[s+1]??0,5,-165796510),i=xe(i,o,n,r,e[s+6]??0,9,-1069501632),r=xe(r,i,o,n,e[s+11]??0,14,643717713),n=xe(n,r,i,o,e[s]??0,20,-373897302),o=xe(o,n,r,i,e[s+5]??0,5,-701558691),i=xe(i,o,n,r,e[s+10]??0,9,38016083),r=xe(r,i,o,n,e[s+15]??0,14,-660478335),n=xe(n,r,i,o,e[s+4]??0,20,-405537848),o=xe(o,n,r,i,e[s+9]??0,5,568446438),i=xe(i,o,n,r,e[s+14]??0,9,-1019803690),r=xe(r,i,o,n,e[s+3]??0,14,-187363961),n=xe(n,r,i,o,e[s+8]??0,20,1163531501),o=xe(o,n,r,i,e[s+13]??0,5,-1444681467),i=xe(i,o,n,r,e[s+2]??0,9,-51403784),r=xe(r,i,o,n,e[s+7]??0,14,1735328473),n=xe(n,r,i,o,e[s+12]??0,20,-1926607734),o=ve(o,n,r,i,e[s+5]??0,4,-378558),i=ve(i,o,n,r,e[s+8]??0,11,-2022574463),r=ve(r,i,o,n,e[s+11]??0,16,1839030562),n=ve(n,r,i,o,e[s+14]??0,23,-35309556),o=ve(o,n,r,i,e[s+1]??0,4,-1530992060),i=ve(i,o,n,r,e[s+4]??0,11,1272893353),r=ve(r,i,o,n,e[s+7]??0,16,-155497632),n=ve(n,r,i,o,e[s+10]??0,23,-1094730640),o=ve(o,n,r,i,e[s+13]??0,4,681279174),i=ve(i,o,n,r,e[s]??0,11,-358537222),r=ve(r,i,o,n,e[s+3]??0,16,-722521979),n=ve(n,r,i,o,e[s+6]??0,23,76029189),o=ve(o,n,r,i,e[s+9]??0,4,-640364487),i=ve(i,o,n,r,e[s+12]??0,11,-421815835),r=ve(r,i,o,n,e[s+15]??0,16,530742520),n=ve(n,r,i,o,e[s+2]??0,23,-995338651),o=Se(o,n,r,i,e[s]??0,6,-198630844),i=Se(i,o,n,r,e[s+7]??0,10,1126891415),r=Se(r,i,o,n,e[s+14]??0,15,-1416354905),n=Se(n,r,i,o,e[s+5]??0,21,-57434055),o=Se(o,n,r,i,e[s+12]??0,6,1700485571),i=Se(i,o,n,r,e[s+3]??0,10,-1894986606),r=Se(r,i,o,n,e[s+10]??0,15,-1051523),n=Se(n,r,i,o,e[s+1]??0,21,-2054922799),o=Se(o,n,r,i,e[s+8]??0,6,1873313359),i=Se(i,o,n,r,e[s+15]??0,10,-30611744),r=Se(r,i,o,n,e[s+6]??0,15,-1560198380),n=Se(n,r,i,o,e[s+13]??0,21,1309151649),o=Se(o,n,r,i,e[s+4]??0,6,-145523070),i=Se(i,o,n,r,e[s+11]??0,10,-1120210379),r=Se(r,i,o,n,e[s+2]??0,15,718787259),n=Se(n,r,i,o,e[s+9]??0,21,-343485551),o=Ft(o,a),n=Ft(n,l),r=Ft(r,p),i=Ft(i,m)}return[o,n,r,i]}function Cc(e){let t="0123456789abcdef",o="";for(let n=0;n<e.length*4;n++)o+=t.charAt(e[n>>2]>>n%4*8+4&15)+t.charAt(e[n>>2]>>n%4*8&15);return o}function Mc(e){let t=[];for(let n=0;n<e.length*8;n+=8)t[n>>5]=(t[n>>5]??0)|(e.charCodeAt(n/8)&255)<<n%32;return t}function Al(e){return Cc(kc(Mc(e),e.length*8))}ye();function Zr({sequence:e,searchType:t,enabled:o=!0}){let n=(0,kl.useMemo)(()=>{if(!e)return;let a=se(e.toUpperCase());return t==="md5"?Al(a):a},[e,t]),{data:r,error:i,isLoading:s}=ze(o&&n?`https://alphafold.ebi.ac.uk/api/sequence/summary?id=${encodeURIComponent(n)}&type=${t}`:null,ho,{revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,keepPreviousData:!0});return{isLoading:s,result:r,uniprotId:r?.uniprotAccession,cifUrl:r?.cifUrl,plddtDocUrl:r?.plddtDocUrl,structureSequence:r?.sequence,error:i}}var Nn=u(x());function Xr(e,t=300){let[o,n]=(0,Nn.useState)(e);return(0,Nn.useEffect)(()=>{let r=setTimeout(()=>{n(e)},t);return()=>{clearTimeout(r)}},[e,t]),o}_t();var Ml=u(ko()),Et=u(X());function Fc(e,t){return e.map(o=>t.slice(o.start,o.end)).join("")}function Ec({cds:e,sequence:t,codonTable:o}){let n=Fc(e,t),r="";for(let i=0;i<n.length;i+=3)r+=o[n.slice(i,i+3)]??"&";return r}function Ic(e,t){return e.map(o=>({...o,start:t-o.end,end:t-o.start})).toSorted((o,n)=>o.start-n.start)}function Cl(e){return`${e.start}-${e.end}`}function Lc(e){return e.filter((t,o,n)=>!o||Cl(t)!==Cl(n[o-1]))}function qc({feature:e,seq:t}){let o=e.get("start"),n=e.get("strand"),r=e.get("subfeatures")??[],i=Lc(r.toSorted((s,a)=>s.get("start")-a.get("start")).map(s=>({start:s.get("start")-o,end:s.get("end")-o,type:s.get("type")})).filter(s=>s.type==="CDS"));return Ec({cds:n===-1?Ic(i,t.length):i,sequence:n===-1?(0,Et.revcom)(t):t,codonTable:(0,Et.generateCodonTable)(Et.defaultCodonTable)})}async function Fl({feature:e,view:t}){let o=e.get("start"),n=e.get("end"),r=e.get("refName"),i=(0,Et.getSession)(t),{assemblyManager:s,rpcManager:a}=i,l=t?.assemblyNames?.[0],p=l?await s.waitForAssembly(l):void 0;if(!p)throw new Error("assembly not found");let m="getSequence",c=await a.call(m,"CoreGetFeatures",{adapterConfig:(0,Ml.getConf)(p,["sequence","adapter"]),sessionId:m,regions:[{start:o,end:n,refName:p.getCanonicalRefName(r),assemblyName:l}]}),[d]=c,y=d?.get("seq");return y?qc({seq:y,feature:e}):void 0}ye();function Jt({feature:e,view:t}){let{data:o,error:n,isLoading:r}=ze(["isoform-sequences",e.id(),t?.assemblyNames?.[0]],async()=>{let i=gt(e),s=[],l=(await Promise.all(i.map(async p=>{try{let m=await Fl({view:t,feature:p});return m?[p.id(),{feature:p,seq:m}]:void 0}catch(m){console.error("[useIsoformProteinSequences] error for",p.id(),m),s.push(m);return}}))).filter(p=>p!==void 0);if(l.length===0&&s.length===i.length&&s.length>0)throw s[0];return Object.fromEntries(l)},{revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,keepPreviousData:!0});return{isLoading:r,isoformSequences:o,error:n}}var Vo=u(x());ye();function Kt({options:e,isoformSequences:t,structureSequence:o,resetKey:n}){let[r,i]=(0,Vo.useState)(),[s,a]=(0,Vo.useState)(n);n!==s&&(a(n),i(void 0));let l=(0,Vo.useMemo)(()=>t!==void 0?Us({options:e,isoformSequences:t,structureSequence:o})?.id():void 0,[e,o,t]);return{userSelection:r??l,setUserSelection:i}}_t();ye();var Dc="accession,id,gene_names,organism_name,protein_name,reviewed";function Nc(e){return{accession:e.primaryAccession,id:e.uniProtkbId,geneName:e.genes?.[0]?.geneName?.value,organismName:e.organism?.commonName??e.organism?.scientificName,proteinName:e.proteinDescription?.recommendedName?.fullName?.value,isReviewed:e.entryType==="UniProtKB reviewed (Swiss-Prot)"}}function Vc(e){switch(tn(e)){case"ensembl":return`xref:ensembl-${e}`;case"refseq":return`xref:refseq-${e}`;case"ccds":return`xref:ccds-${e}`;case"hgnc":return`xref:hgnc-${e.replace("HGNC:","")}`;default:return}}async function Il(e,t=10){let o=`https://rest.uniprot.org/uniprotkb/search?query=${encodeURIComponent(e)}&fields=${Dc}&size=${t}`;return(await ho(o)).results.map(Nc)}async function Bc(e){let t=Vc(e);if(!t)return{entries:[],error:void 0};try{return{entries:await Il(t),error:void 0}}catch(o){return console.error(`xref search failed for ${e}:`,o),{entries:[],error:o}}}function El(e){let t=new Set,o=[];for(let n of e)t.has(n.accession)||(t.add(n.accession),o.push(n));return o}async function Ll({recognizedIds:e=[],geneId:t,geneName:o,organismId:n=9606}){let r=new Set(e),i=t?Es(t):void 0;i&&Tt(i)&&r.add(i);let s=await Promise.all([...r].map(Bc)),a=El(s.flatMap(m=>m.entries)),l=s.filter(m=>m.error!==void 0),p;if(!a.some(m=>m.isReviewed)&&o)try{let m=`gene:${o}+AND+organism_id:${n}+AND+reviewed:true`,c=await Il(m,5);a=El([...a,...c])}catch(m){console.error(`gene name search failed for ${o}:`,m),p=m}if(a.length===0){let m=r.size+(o?1:0),c=l.length+(p?1:0);if(m>0&&m===c)throw p??l[0]?.error}return a.toSorted((m,c)=>Number(c.isReviewed)-Number(m.isReviewed))}ye();function Qr({recognizedIds:e=[],geneId:t,geneName:o,selectedQueryId:n="auto",enabled:r=!0}){let i=[],s;n==="auto"?(i=e,s=o):n.startsWith("gene:")?s=n.replace("gene:",""):Tt(n)&&(i=[n]);let a=i.some(c=>Tt(c))||!!s,{data:l,error:p,isLoading:m}=ze(r&&a?["uniprotSearch",n,i.join(","),s]:null,async()=>Ll({recognizedIds:i,geneId:t,geneName:s}),{revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,keepPreviousData:!0});return{entries:l??[],isLoading:m,error:p,hasValidId:a}}function Vn({selectedQueryId:e,recognizedIds:t,geneName:o,joinWord:n="and"}){return e==="auto"?[t.length>0?`database ID${t.length>1?"s":""} "${t.join('", "')}"`:void 0,o?`gene name "${o}"`:void 0].filter(Boolean).join(` ${n} `):e.startsWith("gene:")?`gene name "${e.replace("gene:","")}"`:`database ID "${e}"`}ye();function ei({feature:e,view:t}){let[o,n]=(0,bo.useState)("auto"),[r,i]=(0,bo.useState)(""),s=Hs(e),[a,l]=(0,bo.useState)("auto"),[p,m]=(0,bo.useState)("md5"),[c,d]=(0,bo.useState)(),y=gt(e),w=s.uniprotId,f=o==="auto"&&w?"feature":o,h=f==="sequence",b=f==="auto",{isoformSequences:g,isLoading:C,error:H}=Jt({feature:e,view:t}),{entries:S,isLoading:U,error:J}=Qr({recognizedIds:s.recognizedIds,geneId:s.geneId,geneName:s.geneName,selectedQueryId:a,enabled:b}),re=Xr(r,400),M=S[0]?.accession,fe=f==="feature"?w:b?c??M:f==="manual"?re:void 0,{isLoading:ue,error:Fe,url:Pe,confidenceUrl:ee,structureSequence:Be}=$r({uniprotId:h?void 0:fe}),{userSelection:te,setUserSelection:We}=Kt({options:y,isoformSequences:g,structureSequence:Be,resetKey:fe}),Re=y.find(ct=>en(ct)===te),he=te?g?.[te]:void 0,{uniprotId:oe,cifUrl:oo,plddtDocUrl:et,structureSequence:_e,isLoading:ut,error:He}=Zr({sequence:he?.seq,searchType:p,enabled:h}),Vt=h?oo:Pe,mt=h?et:ee,Je=h?_e:Be,xo=h?oe:fe,vo=[U&&"Looking up UniProt ID",C&&"Loading protein sequences from transcript isoforms",!h&&ue&&"Fetching AlphaFold structure URL",h&&ut&&"Searching AlphaFoldDB by sequence"].filter(ct=>!!ct),So=vo.length>0,or=So?void 0:H??J??Fe??He;return{lookupMode:f,setLookupMode:n,manualUniprotId:r,setManualUniprotId:i,selectedQueryId:a,setSelectedQueryId:l,sequenceSearchType:p,setSequenceSearchType:m,selectedUniprotId:c,setSelectedUniprotId:d,userSelection:te,setUserSelection:We,transcriptOptions:y,selectedTranscript:Re,isoformSequences:g,userSelectedProteinSequence:he,uniprotEntries:S,recognizedIds:s.recognizedIds,geneName:s.geneName,featureUniprotId:w,uniprotId:xo,url:Vt,confidenceUrl:mt,structureSequence:Je,error:or,loadingStatuses:vo,isSequenceSearchLoading:ut,showIdentifierSelector:b&&(s.recognizedIds.length>0||!!s.geneName),showStructureSelectors:!!g&&!!Re&&(h||!!(Je&&xo)),sequencesMatch:he?.seq&&Je?se(he.seq)===Je:void 0,searchDescription:Vn({selectedQueryId:a,recognizedIds:s.recognizedIds,geneName:s.geneName}),searchDescriptionOr:Vn({selectedQueryId:a,recognizedIds:s.recognizedIds,geneName:s.geneName,joinWord:"or"}),selectedTableAccession:c??M,showUniprotResults:!!g&&b&&(S.length>0||U),showNoResults:!!g&&b&&!U&&S.length===0,showSequenceSearchStatus:h,showAlphaFoldDBSearchStatus:!!Je&&!!xo&&!h,isLoading:So}}var Hc=(0,Dl.makeStyles)()({dialogContent:{width:"80em","& > *":{marginBottom:20},"& > *:last-child":{marginBottom:0}},selectorsRow:{display:"flex",flexDirection:"row",gap:20,alignItems:"flex-start"}}),Uc=(0,ql.observer)(function({feature:t,model:o,handleClose:n,alignmentAlgorithm:r,onAlignmentAlgorithmChange:i}){let{classes:s}=Hc(),a=(0,Hn.getSession)(o),l=(0,Hn.getContainingView)(o),p=ei({feature:t,view:l});return R.default.createElement(R.default.Fragment,null,R.default.createElement(It.DialogContent,{className:s.dialogContent},p.error?R.default.createElement(Bn.ErrorMessage,{error:p.error}):null,R.default.createElement(Ir,{lookupMode:p.lookupMode,onLookupModeChange:p.setLookupMode,manualUniprotId:p.manualUniprotId,onManualUniprotIdChange:p.setManualUniprotId,featureUniprotId:p.featureUniprotId,hasProteinSequence:!!p.userSelectedProteinSequence?.seq,sequenceSearchType:p.sequenceSearchType,onSequenceSearchTypeChange:p.setSequenceSearchType,endContent:p.showIdentifierSelector?R.default.createElement(yr,{recognizedIds:p.recognizedIds,geneName:p.geneName,selectedId:p.selectedQueryId,onSelectedIdChange:p.setSelectedQueryId}):null}),p.loadingStatuses.map(m=>R.default.createElement(Bn.LoadingEllipses,{key:m,variant:"subtitle2",message:m})),p.showUniprotResults&&R.default.createElement(R.default.Fragment,null,R.default.createElement(It.Typography,{variant:"body2",color:"textSecondary"},"Searched UniProt by ",p.searchDescription),R.default.createElement(Lr,{entries:p.uniprotEntries,selectedAccession:p.selectedTableAccession,onSelect:p.setSelectedUniprotId}),R.default.createElement(It.Typography,{variant:"body2",color:"textSecondary"},"If you don't see the entry you're looking for, try a different identifier above or search"," ",R.default.createElement(Ae,{href:"https://www.uniprot.org/"},"UniProt")," ",'directly and use "Enter manually".')),p.showNoResults&&R.default.createElement(It.Typography,{variant:"body2",color:"textSecondary"},"No UniProt entries found for ",p.searchDescriptionOr,". Try a different identifier above, or search"," ",R.default.createElement(Ae,{href:"https://www.uniprot.org/"},"UniProt")," ",'directly and use "Enter manually" above, or use "Search sequence against AlphaFoldDB API" if available.'),p.showStructureSelectors&&R.default.createElement(R.default.Fragment,null,R.default.createElement("div",{className:s.selectorsRow},R.default.createElement(Rt,{val:p.userSelection,setVal:p.setUserSelection,structureSequence:p.structureSequence,feature:t,isoforms:p.transcriptOptions,isoformSequences:p.isoformSequences})),p.showSequenceSearchStatus&&R.default.createElement(Er,{isLoading:p.isSequenceSearchLoading,uniprotId:p.uniprotId,url:p.url,hasProteinSequence:!!p.userSelectedProteinSequence,sequenceSearchType:p.sequenceSearchType}),p.showAlphaFoldDBSearchStatus&&R.default.createElement(br,{uniprotId:p.uniprotId,selectedTranscript:p.selectedTranscript,structureSequence:p.structureSequence,isoformSequences:p.isoformSequences,url:p.url}))),R.default.createElement(It.DialogActions,null,R.default.createElement(Mr,{handleClose:n,uniprotId:p.uniprotId,userSelectedProteinSequence:p.userSelectedProteinSequence,selectedTranscript:p.selectedTranscript,url:p.url,confidenceUrl:p.confidenceUrl,feature:t,view:l,session:a,alignmentAlgorithm:r,onAlignmentAlgorithmChange:i,sequencesMatch:p.sequencesMatch,isLoading:p.isLoading,error:p.error})))}),Nl=Uc;var _=u(x()),Bo=u(Oe()),Gn=u(X()),Me=u(L()),Wl=u(j()),Rl=u(ot());var st=u(x()),Xe=u(L()),Ul=u(ot());var ti=[{id:"pdb100",label:"PDB (100% redundancy)"},{id:"afdb-swissprot",label:"AlphaFold DB (Swiss-Prot)"},{id:"afdb50",label:"AlphaFold DB (50% redundancy)"},{id:"afdb-proteome",label:"AlphaFold DB (Proteomes)"},{id:"cath50",label:"CATH (50% redundancy)"},{id:"mgnify_esm30",label:"MGnify ESM30"},{id:"bfmd",label:"BFMD"},{id:"gmgcl_id",label:"GMGCL"}],Un=["pdb100","afdb-swissprot"];async function Vl(e){let t=e.split(`
|
|
22
22
|
`).filter(i=>!i.startsWith(">")).join("").replace(/\s/g,"").replace(/\*/g,"").toUpperCase().replace(/[^ACDEFGHIKLMNPQRSTVWY]/g,""),o=await fetch(`https://3di.foldseek.com/predict/${encodeURIComponent(t)}`);if(!o.ok)throw new Error(`3Di prediction failed: ${o.status} ${await o.text()}`);let r=(await o.text()).replace(/^["'/\s]+/,"").replace(/["'/\s]+$/,"").trim();return{aaSequence:t,di3Sequence:r}}async function Bl(e,t,o){let n=`>query
|
|
23
23
|
${e}
|
|
24
24
|
>3DI
|
|
25
25
|
${t}
|
|
26
26
|
`,r=new URLSearchParams;r.append("q",n),r.append("mode","3diaa"),r.append("email","");for(let a of o)r.append("database[]",a);let i=await fetch("https://search.foldseek.com/api/ticket",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r}),s=await i.json();if(!i.ok)throw new Error(`Foldseek submission failed: ${i.status} ${JSON.stringify(s)}`);return s}async function Gc(e){let t=new URLSearchParams;t.append("tickets[]",e);let o=await fetch("https://search.foldseek.com/api/tickets",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});if(!o.ok)throw new Error(`Failed to poll ticket status: ${o.status}`);let r=(await o.json())[0];if(!r)throw new Error("No ticket status returned");return r}async function Oc(e){return ho(`https://search.foldseek.com/api/result/${e}/0`)}async function Hl(e,t){let n=0;for(;n<180;){let r=await Gc(e);if(r.status==="ERROR")throw console.error("[Foldseek] Search error:",r),new Error(`Foldseek search failed: ${r.error??"Unknown error"}`);if(r.status==="COMPLETE"){t?.("Fetching results...");let i=await Oc(e);return{query:i.queries[0]??{header:"",sequence:""},results:i.results.map(a=>({db:a.db,alignments:a.alignments}))}}t?.(`Search ${r.status.toLowerCase()}... (${n+1}s)`),await Pl(1e3),n++}throw new Error("Foldseek search timed out")}var zc=(0,Ul.makeStyles)()({root:{display:"flex",flexDirection:"column",gap:8},header:{display:"flex",alignItems:"center",gap:8},buttons:{display:"flex",gap:4},checkboxGroup:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:0}});function oi({selected:e,onChange:t,disabled:o}){let{classes:n}=zc();return st.default.createElement("div",{className:n.root},st.default.createElement("div",{className:n.header},st.default.createElement(Xe.Typography,{variant:"subtitle2"},"Databases to search:"),st.default.createElement("div",{className:n.buttons},st.default.createElement(Xe.Button,{size:"small",onClick:()=>{t(ti.map(r=>r.id))},disabled:o},"Select all"),st.default.createElement(Xe.Button,{size:"small",onClick:()=>{t([])},disabled:o},"Clear"))),st.default.createElement(Xe.FormGroup,{className:n.checkboxGroup},ti.map(r=>st.default.createElement(Xe.FormControlLabel,{key:r.id,control:st.default.createElement(Xe.Checkbox,{size:"small",checked:e.includes(r.id),onChange:()=>{e.includes(r.id)?t(e.filter(i=>i!==r.id)):t([...e,r.id])},disabled:o}),label:r.label}))))}var D=u(x()),F=u(L()),jl=u(ot());var De=u(x()),zl=u(Oe()),Lt=u(L());var jc={A:"ALA",C:"CYS",D:"ASP",E:"GLU",F:"PHE",G:"GLY",H:"HIS",I:"ILE",K:"LYS",L:"LEU",M:"MET",N:"ASN",P:"PRO",Q:"GLN",R:"ARG",S:"SER",T:"THR",V:"VAL",W:"TRP",Y:"TYR",X:"UNK"};function Gl(e,t){return e.padStart(t," ")}function Wc(e,t){return e.padEnd(t," ")}function ni(e){return e.toFixed(3).padStart(8," ")}function Ol(e,t,o="A",n){let r=e.split(",").map(Number),i=[];n&&i.push(`TITLE ${n}`),i.push("REMARK 1 Generated from Foldseek C\u03B1 coordinates");let s=1,a=1;for(let l=0;l<r.length-2;l+=3){let p=r[l],m=r[l+1],c=r[l+2],d=t[a-1]??"X",y=jc[d]??"UNK";if(p===void 0||m===void 0||c===void 0)break;let w="ATOM "+Gl(String(s),5)+" CA "+Wc(y,3)+" "+o+Gl(String(a),4)+" "+ni(p)+ni(m)+ni(c)+" 1.00 0.00 C";i.push(w),s++,a++}return i.push("END"),i.join(`
|
|
27
|
-
`)}function ri(e,t){return!e||!t?!1:e.split(",").length>=3&&t.length>0}it();function ii({hit:e,session:t,view:o,feature:n,selectedTranscript:r,userProvidedTranscriptSequence:i,onClose:s}){let[a,l]=(0,De.useState)(null),[p,m]=(0,De.useState)(),c=!!a,d=hn(e.target),y=S=>{l(S.currentTarget)},w=()=>{l(null)},f={session:t,view:o,feature:n,selectedTranscript:r,uniprotId:d},h=S=>()=>{w(),dn(S,s,m)},b=h(()=>{let S=!e.structureUrl&&ri(e.tCa,e.tSeq)?Ol(e.tCa,e.tSeq,"A",e.target):void 0;Wt({...f,url:e.structureUrl,data:S,userProvidedTranscriptSequence:i})}),g=h(async()=>{await bn({...f,confidenceUrl:Ya(e.target)})}),C=h(()=>{Io(f)});return e.structureUrl??ri(e.tCa,e.tSeq)?De.default.createElement(De.default.Fragment,null,p?De.default.createElement(zl.ErrorMessage,{error:p}):null,De.default.createElement(Lt.Button,{size:"small",variant:"outlined",onClick:y},"Load"),De.default.createElement(Lt.Menu,{anchorEl:a,open:c,onClose:w},De.default.createElement(Lt.MenuItem,{onClick:b},"Launch 3D protein view"),d?De.default.createElement(Lt.MenuItem,{onClick:g},"Launch 1D protein annotation view"):null,d&&yn()?De.default.createElement(Lt.MenuItem,{onClick:C},"Launch MSA view (AlphaFoldDB a3m)"):null)):De.default.createElement("span",null,"-")}it();var Rc=(0,jl.makeStyles)()({root:{display:"flex",flexDirection:"column",gap:16},tableContainer:{maxHeight:400},headerCell:{fontWeight:"bold",backgroundColor:"#f5f5f5"},noResults:{padding:16,textAlign:"center"}});function _c(e){let t=e.results.flatMap(o=>(o.alignments??[]).flat().map(n=>({...n,db:o.db,structureUrl:Ka(n.target,o.db)})));return t.sort((o,n)=>(o.eval??1/0)-(n.eval??1/0)),t.slice(0,100)}function si({results:e,session:t,view:o,feature:n,selectedTranscript:r,userProvidedTranscriptSequence:i,onClose:s}){let{classes:a}=Rc(),l=_c(e);return l.length===0?D.default.createElement(F.Paper,{className:a.noResults},D.default.createElement(F.Typography,null,"No similar structures found")):D.default.createElement("div",{className:a.root},D.default.createElement(F.Typography,{variant:"subtitle2"},"Found ",l.length," similar structures"),D.default.createElement(F.TableContainer,{component:F.Paper,className:a.tableContainer},D.default.createElement(F.Table,{size:"small",stickyHeader:!0},D.default.createElement(F.TableHead,null,D.default.createElement(F.TableRow,null,D.default.createElement(F.TableCell,{className:a.headerCell},"Database"),D.default.createElement(F.TableCell,{className:a.headerCell},"Target"),D.default.createElement(F.TableCell,{className:a.headerCell},"Organism"),D.default.createElement(F.TableCell,{className:a.headerCell},"Prob"),D.default.createElement(F.TableCell,{className:a.headerCell},"Seq. Id."),D.default.createElement(F.TableCell,{className:a.headerCell},"Coverage"),D.default.createElement(F.TableCell,{className:a.headerCell},"E-value"),D.default.createElement(F.TableCell,{className:a.headerCell},"Actions"))),D.default.createElement(F.TableBody,null,l.map((p,m)=>D.default.createElement(F.TableRow,{key:`${p.db}-${p.target}-${m}`},D.default.createElement(F.TableCell,null,p.db),D.default.createElement(F.TableCell,null,p.target),D.default.createElement(F.TableCell,null,p.taxName??"-"),D.default.createElement(F.TableCell,null,p.prob!=null?`${(p.prob*100).toFixed(1)}%`:"-"),D.default.createElement(F.TableCell,null,p.seqId!=null?`${p.seqId.toFixed(1)}%`:"-"),D.default.createElement(F.TableCell,null,p.alnLength!=null&&p.qLen!=null?`${(p.alnLength/p.qLen*100).toFixed(1)}%`:"-"),D.default.createElement(F.TableCell,null,p.eval!=null?p.eval.toExponential(2):"-"),D.default.createElement(F.TableCell,null,D.default.createElement(ii,{hit:p,session:t,view:o,feature:n,selectedTranscript:r,userProvidedTranscriptSequence:i,onClose:s}))))))))}var Yt=u(x());function ai(){let[e,t]=(0,Yt.useState)(),[o,n]=(0,Yt.useState)(),[r,i]=(0,Yt.useState)(!1),[s,a]=(0,Yt.useState)(!1),[l,p]=(0,Yt.useState)(),[m,c]=(0,Yt.useState)(""),d=async f=>{a(!0),p(void 0),c("Predicting 3Di structure...");try{let h=await Vl(f);return n(h),h}catch(h){console.error(h),p(h);return}finally{a(!1),c("")}},y=async(f,h,b=Un)=>{i(!0),p(void 0),c("Submitting search...");try{let g=await Bl(f,h,b),C=await Hl(g.id,c);return t(C),C}catch(g){console.error(g),p(g);return}finally{i(!1),c("")}},w=()=>{t(void 0),n(void 0),p(void 0),c("")};return{results:e,cleanedAaSequence:o?.aaSequence,di3Sequence:o?.di3Sequence,isLoading:r,isPredicting:s,error:l,statusMessage:m,predictStructure:d,search:y,reset:w}}ye();var Jc=(0,Rl.makeStyles)()({dialogContent:{width:"80em",display:"flex",flexDirection:"column",gap:20},sequenceInput:{fontFamily:"monospace"},di3Section:{display:"flex",flexDirection:"column",gap:8}}),Kc=(0,Wl.observer)(function({feature:t,model:o,handleClose:n}){let{classes:r}=Jc(),i=(0,Gn.getSession)(o),s=(0,Gn.getContainingView)(o),[a,l]=(0,_.useState)(),[p,m]=(0,_.useState)(Un),{results:c,cleanedAaSequence:d,di3Sequence:y,isLoading:w,isPredicting:f,error:h,statusMessage:b,predictStructure:g,search:C,reset:H}=ai(),S=gt(t),{isoformSequences:U,isLoading:J,error:re}=Jt({feature:t,view:s}),{userSelection:M,setUserSelection:fe}=Kt({options:S,isoformSequences:U}),ue=S.find(oe=>oe.id()===M),Pe=(M?U?.[M]:void 0)?.seq.replace(/\*/g,"")??"",ee=a??Pe,Be=oe=>{fe(oe),l(void 0)},te=ee.trim().length>0&&!f&&!w,We=!!d&&!!y&&p.length>0&&!w,Re=h??re,he=w||f;return _.default.createElement(_.default.Fragment,null,_.default.createElement(Me.DialogContent,{className:r.dialogContent},Re&&!J?_.default.createElement(Bo.ErrorMessage,{error:Re}):null,J?_.default.createElement(Bo.LoadingEllipses,{variant:"subtitle2",message:"Loading transcript sequences"}):null,U?_.default.createElement(_.default.Fragment,null,_.default.createElement(Rt,{val:M,setVal:Be,isoforms:S,isoformSequences:U,feature:t,disabled:he}),_.default.createElement(Me.TextField,{label:"Protein sequence (amino acids)",multiline:!0,rows:4,value:ee,onChange:oe=>{l(oe.target.value)},placeholder:"MKTVRQERLKSIVRILERSKEPVSGAQLAEEL...",disabled:he,InputProps:{className:r.sequenceInput}})):null,y?_.default.createElement("div",{className:r.di3Section},_.default.createElement(Me.Typography,{variant:"subtitle2"},"3Di structural alphabet (used for searching):"),_.default.createElement(Me.TextField,{multiline:!0,rows:4,value:y,InputProps:{className:r.sequenceInput,readOnly:!0}})):null,_.default.createElement(oi,{selected:p,onChange:m,disabled:he}),b?_.default.createElement(Bo.LoadingEllipses,{variant:"subtitle2",message:b}):null,c?_.default.createElement(si,{results:c,session:i,view:s,feature:t,selectedTranscript:ue,userProvidedTranscriptSequence:ee,onClose:n}):null),_.default.createElement(Me.DialogActions,null,_.default.createElement(Me.Button,{variant:"contained",color:"secondary",onClick:()=>{n()}},"Cancel"),c?_.default.createElement(Me.Button,{variant:"outlined",onClick:()=>{H()}},"New search"):null,y?_.default.createElement(Me.Button,{variant:"contained",color:"primary",disabled:!We,onClick:()=>{C(d,y,p)}},w?"Searching...":"Search Foldseek"):_.default.createElement(Me.Button,{variant:"contained",color:"primary",disabled:!te,onClick:()=>{g(ee.trim())}},f?"Predicting...":"Predict 3Di structure")))}),_l=Kc;var Ne=u(x());li();var Ql=u(L()),Yc=(0,Ne.lazy)(()=>Promise.resolve().then(()=>(Xl(),Zl)));function Ho(){let[e,t]=(0,Ne.useState)(!1);return Ne.default.createElement(Ne.default.Fragment,null,Ne.default.createElement(Ql.IconButton,{onClick:()=>{t(!0)}},Ne.default.createElement(On,null)),e?Ne.default.createElement(Ne.Suspense,{fallback:null},Ne.default.createElement(Yc,{handleClose:()=>{t(!1)}})):null)}var pi=u(x());function Uo({children:e,value:t,index:o,...n}){return pi.default.createElement("div",{role:"tabpanel",hidden:t!==o,...n},t===o&&pi.default.createElement("div",null,e))}var N=u(x()),jn=u(Oe()),Wn=u(X()),qt=u(L()),ep=u(j()),tp=u(ot());var ne=u(x()),Q=u(L());it();function ui({choice:e,setChoice:t,structureURL:o,setStructureURL:n,file:r,setFile:i,pdbId:s,setPdbId:a}){return ne.default.createElement("div",{style:{display:"flex",margin:30}},ne.default.createElement(Q.Typography,null,"Open your structure file ",ne.default.createElement(Ho,null)),ne.default.createElement(Q.FormControl,{component:"fieldset"},ne.default.createElement(Q.RadioGroup,{value:e,onChange:l=>{t(l.target.value)}},ne.default.createElement(Q.FormControlLabel,{value:"url",control:ne.default.createElement(Q.Radio,null),label:"URL"}),ne.default.createElement(Q.FormControlLabel,{value:"file",control:ne.default.createElement(Q.Radio,null),label:"File"}),ne.default.createElement(Q.FormControlLabel,{value:"pdb",control:ne.default.createElement(Q.Radio,null),label:"PDB ID"}))),e==="url"?ne.default.createElement("div",null,ne.default.createElement(Q.Typography,null,"Open a PDB/mmCIF/etc. file from remote URL"),ne.default.createElement(Q.TextField,{label:"URL",value:o,onChange:l=>{n(l.target.value)}})):null,e==="file"?ne.default.createElement("div",{style:{paddingTop:20}},ne.default.createElement(Q.Typography,null,"Open a PDB/mmCIF/etc. file from your local drive"),ne.default.createElement(Q.Button,{variant:"outlined",component:"label"},"Choose File",ne.default.createElement("input",{type:"file",hidden:!0,onChange:({target:l})=>{let p=l.files?.[0];p&&i(p)}}))):null,e==="pdb"?ne.default.createElement(Q.TextField,{value:s,onChange:l=>{let p=l.target.value;a(p),n(Eo(p))},label:"PDB ID"}):null)}_t();async function zn({data:e,format:t="pdb",options:o,plugin:n}){let r=await n.builders.data.rawData({data:e,label:o?.dataLabel}),i=await n.builders.structure.parseTrajectory(r,t);return In({plugin:n,trajectory:i,options:o})}function $c(e){let t=e.lastIndexOf("."),o=t>=0?e.slice(t+1).toLowerCase():"";return o==="cif"||o==="mmcif"||o==="bcif"?"mmcif":"pdb"}async function Zc(e,t){return qn(async o=>{let{model:n}=await zn({data:await e.text(),plugin:o,format:t});return fo(n)})}function mi({file:e}){let{data:t,error:o,isLoading:n}=ze(e?["local-structure",e.name,e.size,e.lastModified]:null,async()=>{if(!e)return;let r=await Zc(e,$c(e.name));if(!r)throw new Error("no sequences detected in file");return r},{revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1});return{error:o,isLoading:n,sequences:t}}it();ye();var Xc=(0,tp.makeStyles)()(e=>({dialogContent:{marginTop:e.spacing(6),width:"80em"},textAreaFont:{fontFamily:"Courier New"}}));function Qc(){return N.default.createElement("div",{style:{marginBottom:20}},"Manually supply a protein structure (PDB, mmCIF, etc) for a given transcript. You can open the file from the result of running, for example,"," ",N.default.createElement(Ae,{href:"https://github.com/sokrypton/ColabFold"},"ColabFold"),". This plugin will align the protein sequence calculated from the genome to the protein sequence embedded in the structure file which allows for slight differences in these two representations.")}var ed=(0,ep.observer)(function({feature:t,model:o,handleClose:n,alignmentAlgorithm:r,onAlignmentAlgorithmChange:i}){let{classes:s}=Xc(),a=(0,Wn.getSession)(o),[l,p]=(0,N.useState)(),[m,c]=(0,N.useState)(""),[d,y]=(0,N.useState)("file"),[w,f]=(0,N.useState)(),[h,b]=(0,N.useState)(""),[g,C]=(0,N.useState)(!1),H=d==="file"?l:void 0,S=d==="file"?"":h,U=gt(t),J=(0,Wn.getContainingView)(o),{isoformSequences:re,error:M}=Jt({feature:t,view:J}),{sequences:fe,error:ue}=mi({file:H}),{sequences:Fe,error:Pe}=No({url:S}),ee=H?.name??S.slice(S.lastIndexOf("/")+1),te=(H?fe:Fe)?.[0],{userSelection:We,setUserSelection:Re}=Kt({options:U,isoformSequences:re,structureSequence:te}),he=U.find(He=>en(He)===We),oe=We?re?.[We]:void 0,oo=M??w??ue??Pe,et=!!(S||H)&&!!oe&&!!he,_e=!!oe?.seq&&!!te&&se(oe.seq)!==te,ut=async()=>{if(!(!oe||!he))try{let He=H?await H.text():void 0;Wt({session:a,view:J,feature:t,selectedTranscript:he,url:S||void 0,data:He,userProvidedTranscriptSequence:oe.seq,alignmentAlgorithm:r,displayName:`Protein view ${io(t)} - ${Ee(he)}`}),n()}catch(He){console.error(He),f(He)}};return N.default.createElement(N.default.Fragment,null,N.default.createElement(qt.DialogContent,{className:s.dialogContent},oo?N.default.createElement(jn.ErrorMessage,{error:oo}):null,N.default.createElement(Qc,null),N.default.createElement(ui,{choice:d,setChoice:y,structureURL:h,setStructureURL:b,file:l,setFile:p,pdbId:m,setPdbId:c}),N.default.createElement("div",{style:{margin:20}},re?te?N.default.createElement(N.default.Fragment,null,N.default.createElement(Rt,{val:We,setVal:Re,structureSequence:te,isoforms:U,feature:t,isoformSequences:re}),N.default.createElement("div",{style:{margin:10}},N.default.createElement(qt.Button,{variant:"contained",color:"primary",onClick:()=>{C(!g)}},g?"Hide all isoform protein sequences":"Show all isoform protein sequences"),g?N.default.createElement(Co,{structureSequence:te,structureName:ee,isoformSequences:re}):null)):null:N.default.createElement(jn.LoadingEllipses,{title:"Loading protein sequences",variant:"h6"}))),N.default.createElement(qt.DialogActions,null,_e?N.default.createElement(Fo,{alignmentAlgorithm:r,onAlignmentAlgorithmChange:i}):null,N.default.createElement(qt.Button,{variant:"contained",color:"secondary",onClick:()=>{n()}},"Cancel"),N.default.createElement(qt.Button,{variant:"contained",color:"primary",disabled:!et,onClick:()=>{ut()}},"Launch 3-D protein structure view")))}),op=ed;var np=u(x());function rp(e,t){let[o,n]=(0,np.useState)(()=>{let i=localStorage.getItem(e);if(i)try{return JSON.parse(i)}catch{return t}return t});function r(i){n(i),localStorage.setItem(e,JSON.stringify(i))}return[o,r]}function ci({handleClose:e,feature:t,model:o}){let[n,r]=(0,de.useState)(0),[i,s]=rp("jbrowse-protein3d-alignment-algorithm",Mo);return de.default.createElement(ip.Dialog,{maxWidth:"xl",title:"Launch protein view",titleNode:de.default.createElement(de.default.Fragment,null,"Launch protein view ",de.default.createElement(Ho,null)),open:!0,onClose:e},de.default.createElement(yo.Tabs,{value:n,onChange:(a,l)=>{r(l)}},de.default.createElement(yo.Tab,{value:0,label:"AlphaFoldDB search"}),de.default.createElement(yo.Tab,{value:1,label:"Foldseek search"}),de.default.createElement(yo.Tab,{value:2,label:"Open file manually"})),de.default.createElement(Uo,{value:n,index:0},de.default.createElement(Nl,{model:o,feature:t,handleClose:e,alignmentAlgorithm:i,onAlignmentAlgorithmChange:s})),de.default.createElement(Uo,{value:n,index:1},de.default.createElement(_l,{model:o,feature:t,handleClose:e})),de.default.createElement(Uo,{value:n,index:2},de.default.createElement(op,{model:o,feature:t,handleClose:e,alignmentAlgorithm:i,onAlignmentAlgorithmChange:s})))}function td(e){return e.name==="LinearBasicDisplay"}function od(e){return e.views(t=>{let o=t.contextMenuItems;return{contextMenuItems(){let n=t.contextMenuFeature,r=n!==void 0&&["gene","mRNA","transcript"].includes(n.get("type"));return[...o(),...r?[{label:"Launch protein view",icon:wa,onClick:()=>{let i=(0,Rn.getContainingTrack)(t);(0,Rn.getSession)(i).queueDialog(a=>[ci,{model:i,handleClose:a,feature:n}])}}]:[]]}}})}function di(e){e.addToExtensionPoint("Core-extendPluggableElement",t=>(td(t)&&(t.stateModel=od(t.stateModel)),t))}function gi(e){e.addToExtensionPoint("LaunchView-ProteinView",async({session:t,url:o,userProvidedTranscriptSequence:n,feature:r,connectedViewId:i,alignmentAlgorithm:s,displayName:a,height:l,showControls:p,showHighlight:m,zoomToBaseLevel:c})=>{if(!o)throw new Error("No URL provided when launching protein view");t.addView("ProteinView",{type:"ProteinView",alignmentAlgorithm:s,displayName:a,height:l,showControls:p,showHighlight:m,zoomToBaseLevel:c,structures:[{url:o,userProvidedTranscriptSequence:n??"",feature:r,connectedViewId:i}]})})}var tm=u(x()),om=u(fi());var qp=u(fi()),Dp=u(lp()),pe=u(hi());Gt();var up=u(Ot(),1),bi=(0,Ie.createSvgIcon)((0,up.jsx)("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"}),"Visibility");var jo=u(no());yi();function dp(e,t){let o=e.obj?.data;if(!o)return;let{B_iso_or_equiv:n}=o.atomicConformation,{offsets:r,count:i}=o.atomicHierarchy.residueAtomSegments,s=t===void 0?i:Math.min(i,t),a=[];for(let l=0;l<s;l++)a.push(n.value(r[l]));return a}function gp(e){return!!e&&e.length>1&&e.every(t=>t>=0&&t<=100)&&new Set(e).size>1}var zo=u(X()),K=u(hi()),$t=u(no());Si();Ao();Ht();var bp=e=>e;var Ti=e=>e;function yp(e){let{structureSeqToTranscriptSeqPosition:t,transcriptSeqToStructureSeqPosition:o}=ds(e),n=fs(e),r=hs(e),i=ir(n),s=ir(r);return{structureToTranscript:a=>t[a],transcriptToStructure:a=>o[a],structureToAlignment:a=>n[a],alignmentToStructure:a=>i[a],transcriptToAlignment:a=>r[a],alignmentToTranscript:a=>s[a],maps:{structureSeqToTranscriptSeqPosition:t,transcriptSeqToStructureSeqPosition:o,structurePositionToAlignmentMap:n,transcriptPositionToAlignmentMap:r,alignmentToStructurePosition:i,alignmentToTranscriptPosition:s}}}Ai();var _n=["A","R","N","D","C","Q","E","G","H","I","L","K","M","F","P","S","T","W","Y","V","B","Z","X","*"],nd=[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],xp={};for(let e=0;e<_n.length;e++){let t={};for(let o=0;o<_n.length;o++)t[_n[o]]=nd[e][o];xp[_n[e]]=t}function Go(e,t){return xp[e.toUpperCase()]?.[t.toUpperCase()]??-4}var vp=-10,Sp=-.5;function rd(e,t,o=vp,n=Sp){let r=e.length,i=t.length,s=[],a=[],l=[];for(let h=0;h<=r;h++){s[h]=[],a[h]=[],l[h]=[];for(let b=0;b<=i;b++)s[h][b]=-1/0,a[h][b]=-1/0,l[h][b]=-1/0}s[0][0]=0;for(let h=1;h<=r;h++)a[h][0]=o+(h-1)*n;for(let h=1;h<=i;h++)l[0][h]=o+(h-1)*n;for(let h=1;h<=r;h++)for(let b=1;b<=i;b++){let g=Go(e[h-1],t[b-1]);s[h][b]=Math.max(s[h-1][b-1],a[h-1][b-1],l[h-1][b-1])+g,a[h][b]=Math.max(s[h-1][b]+o,a[h-1][b]+n),l[h][b]=Math.max(s[h][b-1]+o,l[h][b-1]+n)}let p="",m="",c=r,d=i,y=[s[r][i],a[r][i],l[r][i]],w=Math.max(...y),f=w===s[r][i]?"M":w===a[r][i]?"Ix":"Iy";for(;c>0||d>0;)if(f==="M"&&c>0&&d>0){p=e[c-1]+p,m=t[d-1]+m;let h=Go(e[c-1],t[d-1]),b=s[c-1][d-1],g=a[c-1][d-1];s[c][d]===b+h?f="M":s[c][d]===g+h?f="Ix":f="Iy",c--,d--}else if(f==="Ix"&&c>0)p=e[c-1]+p,m="-"+m,f=a[c][d]===s[c-1][d]+o?"M":"Ix",c--;else if(d>0)p="-"+p,m=t[d-1]+m,f=l[c][d]===s[c][d-1]+o?"M":"Iy",d--;else break;return{alignedSeq1:p,alignedSeq2:m,score:w}}function id(e,t,o=vp,n=Sp){let r=e.length,i=t.length,s=[],a=[],l=[],p=0,m=0,c=0;for(let b=0;b<=r;b++){s[b]=[],a[b]=[],l[b]=[];for(let g=0;g<=i;g++)s[b][g]=0,a[b][g]=-1/0,l[b][g]=-1/0}for(let b=1;b<=r;b++)for(let g=1;g<=i;g++){let C=Go(e[b-1],t[g-1]);s[b][g]=Math.max(0,s[b-1][g-1]+C,a[b-1][g-1]+C,l[b-1][g-1]+C),a[b][g]=Math.max(s[b-1][g]+o,a[b-1][g]+n),l[b][g]=Math.max(s[b][g-1]+o,l[b][g-1]+n);let H=Math.max(s[b][g],a[b][g],l[b][g]);H>p&&(p=H,m=b,c=g)}let d="",y="",w=m,f=c,h=s[w][f]>=a[w][f]&&s[w][f]>=l[w][f]?"M":a[w][f]>=l[w][f]?"Ix":"Iy";for(let b=e.length;b>m;b--)d=e[b-1]+d,y="-"+y;for(let b=t.length;b>c;b--)d="-"+d,y=t[b-1]+y;for(;w>0&&f>0;)if(h==="M"){if(s[w][f]===0)break;d=e[w-1]+d,y=t[f-1]+y;let b=Go(e[w-1],t[f-1]),g=s[w-1][f-1],C=a[w-1][f-1];s[w][f]===g+b?h="M":s[w][f]===C+b?h="Ix":h="Iy",w--,f--}else h==="Ix"?(d=e[w-1]+d,y="-"+y,a[w][f]===s[w-1][f]+o&&(h="M"),w--):(d="-"+d,y=t[f-1]+y,l[w][f]===s[w][f-1]+o&&(h="M"),f--);for(;w>0;)d=e[w-1]+d,y="-"+y,w--;for(;f>0;)d="-"+d,y=t[f-1]+y,f--;return{alignedSeq1:d,alignedSeq2:y,score:p}}function sd(e,t){let o=[];for(let n=0;n<e.length;n++){let r=e[n],i=t[n];r!=="-"&&i!=="-"&&r.toUpperCase()===i.toUpperCase()?o.push("|"):r!=="-"&&i!=="-"&&Go(r,i)>0?o.push(":"):o.push(" ")}return o.join("")}function Tp(e,t,o){let{alignedSeq1:n,alignedSeq2:r}=o==="smith_waterman"?id(e,t):rd(e,t);return{consensus:sd(n,r),alns:[{id:"a",seq:n},{id:"b",seq:r}]}}var Pp=Object.fromEntries([{name:"alanine",abbreviation:"Ala",singleLetterCode:"A"},{name:"arginine",abbreviation:"Arg",singleLetterCode:"R"},{name:"asparagine",abbreviation:"Asn",singleLetterCode:"N"},{name:"aspartic acid",abbreviation:"Asp",singleLetterCode:"D"},{name:"cysteine",abbreviation:"Cys",singleLetterCode:"C"},{name:"glutamic acid",abbreviation:"Glu",singleLetterCode:"E"},{name:"glutamine",abbreviation:"Gln",singleLetterCode:"Q"},{name:"glycine",abbreviation:"Gly",singleLetterCode:"G"},{name:"histidine",abbreviation:"His",singleLetterCode:"H"},{name:"isoleucine",abbreviation:"Ile",singleLetterCode:"I"},{name:"leucine",abbreviation:"Leu",singleLetterCode:"L"},{name:"lysine",abbreviation:"Lys",singleLetterCode:"K"},{name:"methionine",abbreviation:"Met",singleLetterCode:"M"},{name:"phenylalanine",abbreviation:"Phe",singleLetterCode:"F"},{name:"proline",abbreviation:"Pro",singleLetterCode:"P"},{name:"serine",abbreviation:"Ser",singleLetterCode:"S"},{name:"threonine",abbreviation:"Thr",singleLetterCode:"T"},{name:"tryptophan",abbreviation:"Trp",singleLetterCode:"W"},{name:"tyrosine",abbreviation:"Tyr",singleLetterCode:"Y"},{name:"valine",abbreviation:"Val",singleLetterCode:"V"}].map(e=>[e.abbreviation.toUpperCase(),e]));Ci();Fi();Bt();function ud(e,t){return{structureSeqPos:e.StructureProperties.residue.auth_seq_id(t)-1,code:e.StructureProperties.atom.label_comp_id(t),chain:e.StructureProperties.chain.auth_asym_id(t)}}async function Kn({plugin:e,kind:t,onUpdate:o}){let n=await be(),r=e.behaviors.interaction[t].subscribe(i=>{if(n.StructureElement.Loci.is(i.current.loci)){let s=n.StructureElement.Loci.getFirstLocation(i.current.loci);o(s?ud(n,s):void 0)}else o(void 0)});return()=>{r.unsubscribe()}}Ht();it();ye();Ao();var md=K.types.model({url:K.types.maybe(K.types.string),data:K.types.maybe(K.types.string),connectedViewId:K.types.maybe(K.types.string),pairwiseAlignment:K.types.frozen(),feature:K.types.frozen(),userProvidedTranscriptSequence:K.types.string}).volatile(()=>({clickedStructureRange:void 0,hoverPosition:void 0,structureSequences:void 0,structureConfidence:void 0,isMouseInAlignment:!1,loadedToMolstar:!1,alignmentHoverRange:void 0,selectedFeatureId:void 0,hiddenFeatureTypes:new Set})).actions(e=>({setStructureData(t){e.structureSequences=t.sequences,e.structureConfidence=t.confidence},hideFeatureType(t){e.hiddenFeatureTypes=new Set([...e.hiddenFeatureTypes,t])},showFeatureType(t){let o=new Set(e.hiddenFeatureTypes);o.delete(t),e.hiddenFeatureTypes=o},showAllFeatureTypes(){e.hiddenFeatureTypes=new Set},setLoadedToMolstar(t){e.loadedToMolstar=t}})).views(e=>({get connectedView(){let{views:t}=(0,zo.getSession)(e);return t.find(o=>o.id===e.connectedViewId)}})).actions(e=>({setClickedStructureRange(t){e.clickedStructureRange=t},setAlignmentHoverRange(t){e.alignmentHoverRange=t},setSelectedFeatureId(t){e.selectedFeatureId=t},setHoveredPosition(t){e.hoverPosition=t},setAlignment(t){e.pairwiseAlignment=t},setIsMouseInAlignment(t){e.isMouseInAlignment=t}})).views(e=>({get uniprotId(){let{url:t}=e;if(t)return hn(t)},get coordinateMapper(){return e.pairwiseAlignment?yp(e.pairwiseAlignment):void 0},get structureSeqToTranscriptSeqPosition(){return this.coordinateMapper?.maps.structureSeqToTranscriptSeqPosition},get transcriptSeqToStructureSeqPosition(){return this.coordinateMapper?.maps.transcriptSeqToStructureSeqPosition},get structurePositionToAlignmentMap(){return this.coordinateMapper?.maps.structurePositionToAlignmentMap},get transcriptPositionToAlignmentMap(){return this.coordinateMapper?.maps.transcriptPositionToAlignmentMap},get confidenceCells(){let t=e.structureConfidence;return gp(t)?Mi(t,this.structurePositionToAlignmentMap):[]},get hydrophobicityCells(){let t=e.structureSequences?.[0];return t?Mi(Cp(se(t)),this.structurePositionToAlignmentMap):[]},get pairwiseAlignmentToTranscriptPosition(){return this.coordinateMapper?.maps.alignmentToTranscriptPosition},get pairwiseAlignmentToStructurePosition(){return this.coordinateMapper?.maps.alignmentToStructurePosition},get hoverString(){let t=e.hoverPosition;if(t===void 0)return"";let o=this.hoverStructureLetter,n=this.hoverGenomeLetter,r=[];return t.structureSeqPos!==void 0&&r.push(`${t.structureSeqPos+1}`),o&&r.push(`Structure: ${o}`),n&&o&&n!==o&&r.push(`Genome: ${n}`),t.chain&&r.push(`Chain: ${t.chain}`),r.join(", ")},get genomeToTranscriptSeqMapping(){return e.feature?ro(new zo.SimpleFeature(e.feature)):void 0},get structureSeqHoverPos(){return e.hoverPosition?.structureSeqPos},get alignmentHoverPos(){let t=this.structureSeqHoverPos;return t===void 0?void 0:this.coordinateMapper?.structureToAlignment(bp(t))},get hoverStructureRange(){let{alignmentHoverRange:t}=e,o=this.pairwiseAlignmentToStructurePosition;if(!t||!o)return;let n=o[t.start],r=o[t.end];return n===void 0||r===void 0?void 0:{start:n,end:r+1}},get clickAlignmentRange(){let t=e.clickedStructureRange,o=this.structurePositionToAlignmentMap;if(!t||!o)return;let n=o[t.start],r=o[t.end-1];return n===void 0||r===void 0?void 0:{start:n,end:r}},structureRangeToGenomeHighlight(t){let o=e.connectedView?.assemblyNames[0],n=this.genomeToTranscriptSeqMapping;if(!t||!o||!n)return[];let r={genomeToTranscriptSeqMapping:n,pairwiseAlignment:e.pairwiseAlignment,structureSeqToTranscriptSeqPosition:this.structureSeqToTranscriptSeqPosition},i=t.end>t.start+1?ki({model:r,structureSeqPos:t.start,structureSeqEndPos:t.end}):Jn({model:r,structureSeqPos:t.start});if(!i)return[];let[s,a]=i;return[{assemblyName:o,refName:n.refName,start:s,end:a}]},get hoverGenomeHighlights(){let t=this.hoverStructureRange;if(t)return this.structureRangeToGenomeHighlight(t);let o=this.structureSeqHoverPos;return o===void 0?[]:this.structureRangeToGenomeHighlight({start:o,end:o+1})},get clickGenomeHighlights(){return this.structureRangeToGenomeHighlight(e.clickedStructureRange)},get hoverStructureLetter(){let t=e.hoverPosition?.code;if(t)return Pp[t]?.singleLetterCode;let o=this.structureSeqHoverPos;if(o!==void 0&&e.structureSequences?.[0])return e.structureSequences[0][o]},get hoverGenomeLetter(){let t=this.structureSeqHoverPos;if(t===void 0)return;let o=this.structureSeqToTranscriptSeqPosition?.[t];if(o!==void 0)return e.userProvidedTranscriptSequence[o]},get alignmentMatchSet(){let t=e.pairwiseAlignment?.consensus;if(!t)return;let o=new Set;for(let n=0;n<t.length;n++)(t[n]==="|"||t[n]===":")&&o.add(n);return o},get exactMatch(){let t=se(e.userProvidedTranscriptSequence),o=e.structureSequences?.[0]?se(e.structureSequences[0]):void 0;return t===o},get parentView(){return(0,K.getParent)(e,2)},get zoomToBaseLevel(){return this.parentView.zoomToBaseLevel},get autoScrollAlignment(){return this.parentView.autoScrollAlignment},get showHighlight(){return this.parentView.showHighlight},get showProteinTracks(){return this.parentView.showProteinTracks},get alignmentAlgorithm(){return Va(this.parentView.alignmentAlgorithm)},get molstarPluginContext(){return this.parentView.molstarPluginContext},get structureIndex(){return this.parentView.structures.indexOf(e)},get molstarStructure(){let t=this.structureIndex;return e.loadedToMolstar&&t>=0?this.molstarPluginContext?.managers.structure.hierarchy.current.structures[t]?.cell.obj?.data:void 0}})).actions(e=>({setError(t){e.parentView.setError(t)},hoverAlignmentPosition(t){if(!e.alignmentHoverRange){let o=e.coordinateMapper?.alignmentToStructure(Ti(t));e.setHoveredPosition(o!==void 0?{structureSeqPos:o}:void 0)}},clickAlignmentPosition(t){let o=e.coordinateMapper?.alignmentToStructure(Ti(t));e.setSelectedFeatureId(void 0),o!==void 0?Oo({model:e,structureSeqPos:o}).catch(n=>{console.error(n),e.parentView.setError(n)}):e.setClickedStructureRange(void 0)}})).actions(e=>({afterAttach(){(0,K.addDisposer)(e,(0,$t.autorun)(async()=>{try{let{userProvidedTranscriptSequence:t,structureSequences:o,exactMatch:n,alignmentAlgorithm:r}=e,i=t,s=o?.[0];if(e.pairwiseAlignment||!i||!s)return;let a=se(i),l=se(s);if(n)e.setAlignment({consensus:"|".repeat(a.length),alns:[{id:"seq1",seq:a},{id:"seq2",seq:l}]});else{let p=Tp(a,l,r);e.setAlignment(p),e.parentView.setShowAlignment(!0)}}catch(t){console.error(t),e.parentView.setError(t)}})),(0,K.addDisposer)(e,(0,$t.autorun)(()=>{let{hovered:t}=(0,zo.getSession)(e),{transcriptSeqToStructureSeqPosition:o,genomeToTranscriptSeqMapping:n,connectedView:r}=e;if(r?.initialized&&n&&St(t)){let{hoverPosition:i}=t,s=n.g2p[i.coord-1];if(s!==void 0){let a=o?.[s];a!==void 0&&e.setHoveredPosition({structureSeqPos:a})}}})),(0,K.addDisposer)(e,(0,$t.autorun)(async()=>{let{molstarPluginContext:t}=e;if(t){let o=await Kn({plugin:t,kind:"click",onUpdate:n=>{n&&(e.setHoveredPosition(n),e.setSelectedFeatureId(void 0),Oo({model:e,structureSeqPos:n.structureSeqPos}).catch(r=>{console.error(r),e.parentView.setError(r)}))}});(0,K.addDisposer)(e,o)}})),(0,K.addDisposer)(e,(0,$t.autorun)(async()=>{let{molstarPluginContext:t}=e;if(t){let o=await Kn({plugin:t,kind:"hover",onUpdate:n=>{e.setHoveredPosition(n)}});(0,K.addDisposer)(e,o)}})),(0,K.addDisposer)(e,(0,$t.autorun)(async()=>{let{showHighlight:t,structureSeqToTranscriptSeqPosition:o,molstarPluginContext:n,molstarStructure:r}=e;if(r&&n&&o)if(t){let i=Object.keys(o).map(s=>+s+1);await fp({structure:r,residues:i,plugin:n,mode:"select"})}else n.managers.interactivity.lociSelects.deselectAll()})),(0,K.addDisposer)(e,(0,$t.autorun)(async()=>{let{molstarStructure:t,molstarPluginContext:o,hoverStructureRange:n,structureSeqHoverPos:r}=e;t&&o&&(n?await Pi({structure:t,plugin:o,startResidue:n.start+1,endResidue:n.end}):r!==void 0?await hp({structure:t,plugin:o,selectedResidue:r,mode:"highlight"}):o.managers.interactivity.lociHighlights.clearHighlights())}))}})),Yn=md;Bt();var cd="SuperpositionTransform";async function Ei(e){let{QueryContext:t,StructureElement:o,StructureSelection:n,StructureSelectionQueries:r,PluginCommands:i,PluginStateObject:s,tmAlign:a}=await be(),l=e.managers.structure.hierarchy.current.structures;if(l.length<2)return;let{query:p}=r.trace,c=l.map(w=>{let f=w.cell.obj?.data;if(!f)return;let h=e.helpers.substructureParent.get(f);if(!h)return;let b=e.state.data.selectQ(C=>C.byValue(h).rootOfType(s.Molecule.Structure))[0]?.obj?.data;if(!b)return;let g=n.toLociWithSourceUnits(p(new t(f)));return o.Loci.remap(g,b)}).filter(w=>w!==void 0);if(c.length<2)return;let y=e.managers.structure.hierarchy.findStructure(c[0]?.structure)?.transform?.cell.obj?.data.coordinateSystem;for(let w=1;w<c.length;w++){let f=a(c[0],c[w]),{bTransform:h,tmScoreA:b,tmScoreB:g,rmsd:C,alignedLength:H}=f;await dd(e,l[w].cell,h,y),e.log.info(`TM-align: TM-score=${b.toFixed(4)}/${g.toFixed(4)}, RMSD=${C.toFixed(2)} \xC5, aligned ${H} residues.`)}await new Promise(w=>requestAnimationFrame(w)),await i.Camera.Reset(e)}async function dd(e,t,o,n){let{Mat4:r,StateObjectRef:i,StateTransforms:s}=await be(),a=i.resolveAndCheck(e.state.data,t);if(!a)return;let l=e.state.data.selectQ(d=>d.byRef(a.transform.ref).subtree().withTransformer(s.Model.TransformStructureConformation))[0],m={transform:{name:"matrix",params:{data:n&&!r.isIdentity(n.matrix)?r.mul(r(),n.matrix,o):o,transpose:!1}}},c=l?e.state.data.build().to(l).update(m):e.state.data.build().to(t).insert(s.Model.TransformStructureConformation,m,{tags:cd});await e.runTask(e.state.data.updateTree(c))}var Ep="proteinView-settings",Ip=["showAlignment","showProteinTracks","showHighlight","zoomToBaseLevel","autoScrollAlignment"];async function Lp({structure:e,plugin:t}){let{model:o}=e.data?await zn({data:e.data,plugin:t}):e.url?await Ln({url:e.url,plugin:t}):{model:void 0},n=o?fo(o):void 0,r=o?dp(o,n?.[0]?.length):void 0;return{sequences:n,confidence:r}}function gd(){return pe.types.compose("ProteinView",qp.BaseViewModel,pe.types.model({id:Dp.ElementId,type:pe.types.literal("ProteinView"),structures:pe.types.array(Yn),showControls:!1,height:pe.types.optional(pe.types.number,650),showHighlight:!1,zoomToBaseLevel:!0,autoScrollAlignment:!1,colorScheme:pe.types.optional(pe.types.enumeration("ColorScheme",mp),"default"),showAlignment:!0,showProteinTracks:!0,alignmentAlgorithm:pe.types.optional(pe.types.string,Mo),connectedMsaViewId:pe.types.maybe(pe.types.string),init:pe.types.frozen()})).volatile(()=>({error:void 0,molstarPluginContext:void 0,showManualAlignmentDialog:!1,showAddStructureDialog:!1})).actions(e=>({setHeight(t){return e.height=t,t},setShowAlignment(t){e.showAlignment=t},setShowControls(t){e.showControls=t},setError(t){e.error=t},setShowHighlight(t){e.showHighlight=t},setShowProteinTracks(t){e.showProteinTracks=t},setZoomToBaseLevel(t){e.zoomToBaseLevel=t},setAutoScrollAlignment(t){e.autoScrollAlignment=t},setAlignmentAlgorithm(t){e.alignmentAlgorithm=t},setColorScheme(t){e.colorScheme=t},setMolstarPluginContext(t){if(t!==e.molstarPluginContext)for(let o of e.structures)o.setLoadedToMolstar(!1);e.molstarPluginContext=t},setShowManualAlignmentDialog(t){e.showManualAlignmentDialog=t},setShowAddStructureDialog(t){e.showAddStructureDialog=t},setInit(t){e.init=t},setConnectedMsaViewId(t){e.connectedMsaViewId=t},addStructure(t){e.structures.push(Yn.create({url:t.url,data:t.data,userProvidedTranscriptSequence:""}))}})).actions(e=>({async addStructureAndSuperpose(t){let{molstarPluginContext:o}=e;if(!o)return;let n=Yn.create({url:t.url,data:t.data,userProvidedTranscriptSequence:""});n.setLoadedToMolstar(!0),e.structures.push(n);try{n.setStructureData(await Lp({structure:t,plugin:o})),e.structures.length>1&&await Ei(o)}catch(r){e.setError(r),console.error(r)}}})).actions(e=>({afterAttach(){try{let t=localStorage.getItem(Ep);if(t){let o=JSON.parse(t);for(let n of Ip)o[n]!==void 0&&(e[n]=o[n])}}catch(t){console.error("Failed to restore protein view settings",t)}(0,pe.addDisposer)(e,(0,jo.autorun)(()=>{try{let t={};for(let o of Ip)t[o]=e[o];localStorage.setItem(Ep,JSON.stringify(t))}catch(t){console.error("Failed to save protein view settings",t)}})),(0,pe.addDisposer)(e,(0,jo.autorun)(()=>{let{init:t}=e;if(t){let{structures:o,showControls:n,showAlignment:r}=t;if(o)for(let i of o)e.addStructure(i);n!==void 0&&e.setShowControls(n),r!==void 0&&e.setShowAlignment(r),e.setInit(void 0)}})),(0,pe.addDisposer)(e,(0,jo.autorun)(()=>{let{molstarPluginContext:t,colorScheme:o}=e,n=e.structures.filter(r=>r.structureSequences!==void 0).length;t&&n>0&&cp({plugin:t,colorScheme:o}).catch(r=>{console.error(r),e.setError(r)})})),(0,pe.addDisposer)(e,(0,jo.autorun)(async()=>{let{structures:t,molstarPluginContext:o}=e;if(o){for(let n of t)if(!n.loadedToMolstar)try{n.setStructureData(await Lp({structure:n,plugin:o})),n.setLoadedToMolstar(!0)}catch(r){e.setError(r),console.error(r)}}}))}})).views(e=>({get primaryStructure(){return e.structures[0]},menuItems(){return[{label:"Pairwise alignment",icon:bi,type:"checkbox",checked:e.showAlignment,onClick:()=>{e.setShowAlignment(!e.showAlignment)}},{label:"Protein feature tracks",icon:bi,type:"checkbox",checked:e.showProteinTracks,onClick:()=>{e.setShowProteinTracks(!e.showProteinTracks)}},{label:"Color scheme...",subMenu:wo.map(t=>({label:t.label,type:"radio",checked:e.colorScheme===t.value,onClick:()=>{e.setColorScheme(t.value)}}))},{label:"Add structure...",onClick:()=>{e.setShowAddStructureDialog(!0)}},{label:"Advanced...",icon:mn,subMenu:[{label:"Pairwise alignment as green highlight",type:"checkbox",checked:e.showHighlight,onClick:()=>{e.setShowHighlight(!e.showHighlight)}},{label:"Show all protein feature tracks",onClick:()=>{for(let t of e.structures)t.showAllFeatureTypes()}},{label:"Import manual alignment...",onClick:()=>{e.setShowManualAlignmentDialog(!0)}},{label:"Re-align structures (TM-align)",onClick:()=>{e.molstarPluginContext&&Ei(e.molstarPluginContext).catch(t=>{console.error(t),e.setError(t)})}},{label:"Zoom to base level on click",type:"checkbox",checked:e.zoomToBaseLevel,onClick:()=>{e.setZoomToBaseLevel(!e.zoomToBaseLevel)}},{label:"Auto-scroll protein feature view on hover",type:"checkbox",checked:e.autoScrollAlignment,onClick:()=>{e.setAutoScrollAlignment(!e.autoScrollAlignment)}}]}]}}))}var Np=gd;var Gd=(0,tm.lazy)(()=>Promise.resolve().then(()=>(em(),Qu)));function Oi(e){e.addViewType(()=>new om.ViewType({name:"ProteinView",displayName:"Protein view",stateModel:Np(),ReactComponent:Gd}))}var um=u(on());var nm=u(ko());var Od=(0,nm.ConfigurationSchema)("UniProtVariationAdapter",{location:{type:"fileLocation",defaultValue:{uri:"/path/to/my.bed.gz",locationType:"UriLocation"}},scoreField:{type:"string",defaultValue:""}},{explicitlyTyped:!0}),rm=Od;function zi(e){e.addAdapterType(()=>new um.default({name:"UniProtVariationAdapter",displayName:"UniProtVariation adapter",configSchema:rm,getAdapterClass:()=>Promise.resolve().then(()=>(pm(),lm)).then(t=>t.default)}))}var mm="0.4.9";var tr=class extends cm.default{name="ProteinViewer";version=mm;install(t){Oi(t),di(t),gi(t),mr(t),cr(t),dr(t),zi(t)}configure(t){}};return wm(zd);})();
|
|
27
|
+
`)}function ri(e,t){return!e||!t?!1:e.split(",").length>=3&&t.length>0}it();function ii({hit:e,session:t,view:o,feature:n,selectedTranscript:r,userProvidedTranscriptSequence:i,onClose:s}){let[a,l]=(0,De.useState)(null),[p,m]=(0,De.useState)(),c=!!a,d=hn(e.target),y=S=>{l(S.currentTarget)},w=()=>{l(null)},f={session:t,view:o,feature:n,selectedTranscript:r,uniprotId:d},h=S=>()=>{w(),dn(S,s,m)},b=h(()=>{let S=!e.structureUrl&&ri(e.tCa,e.tSeq)?Ol(e.tCa,e.tSeq,"A",e.target):void 0;Wt({...f,url:e.structureUrl,data:S,userProvidedTranscriptSequence:i})}),g=h(async()=>{await bn({...f,confidenceUrl:Ya(e.target)})}),C=h(()=>{Io(f)});return e.structureUrl??ri(e.tCa,e.tSeq)?De.default.createElement(De.default.Fragment,null,p?De.default.createElement(zl.ErrorMessage,{error:p}):null,De.default.createElement(Lt.Button,{size:"small",variant:"outlined",onClick:y},"Load"),De.default.createElement(Lt.Menu,{anchorEl:a,open:c,onClose:w},De.default.createElement(Lt.MenuItem,{onClick:b},"Launch 3D protein view"),d?De.default.createElement(Lt.MenuItem,{onClick:g},"Launch 1D protein annotation view"):null,d&&yn()?De.default.createElement(Lt.MenuItem,{onClick:C},"Launch MSA view (AlphaFoldDB a3m)"):null)):De.default.createElement("span",null,"-")}it();var Rc=(0,jl.makeStyles)()({root:{display:"flex",flexDirection:"column",gap:16},tableContainer:{maxHeight:400},headerCell:{fontWeight:"bold",backgroundColor:"#f5f5f5"},noResults:{padding:16,textAlign:"center"}});function _c(e){let t=e.results.flatMap(o=>(o.alignments??[]).flat().map(n=>({...n,db:o.db,structureUrl:Ka(n.target,o.db)})));return t.sort((o,n)=>(o.eval??1/0)-(n.eval??1/0)),t.slice(0,100)}function si({results:e,session:t,view:o,feature:n,selectedTranscript:r,userProvidedTranscriptSequence:i,onClose:s}){let{classes:a}=Rc(),l=_c(e);return l.length===0?D.default.createElement(F.Paper,{className:a.noResults},D.default.createElement(F.Typography,null,"No similar structures found")):D.default.createElement("div",{className:a.root},D.default.createElement(F.Typography,{variant:"subtitle2"},"Found ",l.length," similar structures"),D.default.createElement(F.TableContainer,{component:F.Paper,className:a.tableContainer},D.default.createElement(F.Table,{size:"small",stickyHeader:!0},D.default.createElement(F.TableHead,null,D.default.createElement(F.TableRow,null,D.default.createElement(F.TableCell,{className:a.headerCell},"Database"),D.default.createElement(F.TableCell,{className:a.headerCell},"Target"),D.default.createElement(F.TableCell,{className:a.headerCell},"Organism"),D.default.createElement(F.TableCell,{className:a.headerCell},"Prob"),D.default.createElement(F.TableCell,{className:a.headerCell},"Seq. Id."),D.default.createElement(F.TableCell,{className:a.headerCell},"Coverage"),D.default.createElement(F.TableCell,{className:a.headerCell},"E-value"),D.default.createElement(F.TableCell,{className:a.headerCell},"Actions"))),D.default.createElement(F.TableBody,null,l.map((p,m)=>D.default.createElement(F.TableRow,{key:`${p.db}-${p.target}-${m}`},D.default.createElement(F.TableCell,null,p.db),D.default.createElement(F.TableCell,null,p.target),D.default.createElement(F.TableCell,null,p.taxName??"-"),D.default.createElement(F.TableCell,null,p.prob!=null?`${(p.prob*100).toFixed(1)}%`:"-"),D.default.createElement(F.TableCell,null,p.seqId!=null?`${p.seqId.toFixed(1)}%`:"-"),D.default.createElement(F.TableCell,null,p.alnLength!=null&&p.qLen!=null?`${(p.alnLength/p.qLen*100).toFixed(1)}%`:"-"),D.default.createElement(F.TableCell,null,p.eval!=null?p.eval.toExponential(2):"-"),D.default.createElement(F.TableCell,null,D.default.createElement(ii,{hit:p,session:t,view:o,feature:n,selectedTranscript:r,userProvidedTranscriptSequence:i,onClose:s}))))))))}var Yt=u(x());function ai(){let[e,t]=(0,Yt.useState)(),[o,n]=(0,Yt.useState)(),[r,i]=(0,Yt.useState)(!1),[s,a]=(0,Yt.useState)(!1),[l,p]=(0,Yt.useState)(),[m,c]=(0,Yt.useState)(""),d=async f=>{a(!0),p(void 0),c("Predicting 3Di structure...");try{let h=await Vl(f);return n(h),h}catch(h){console.error(h),p(h);return}finally{a(!1),c("")}},y=async(f,h,b=Un)=>{i(!0),p(void 0),c("Submitting search...");try{let g=await Bl(f,h,b),C=await Hl(g.id,c);return t(C),C}catch(g){console.error(g),p(g);return}finally{i(!1),c("")}},w=()=>{t(void 0),n(void 0),p(void 0),c("")};return{results:e,cleanedAaSequence:o?.aaSequence,di3Sequence:o?.di3Sequence,isLoading:r,isPredicting:s,error:l,statusMessage:m,predictStructure:d,search:y,reset:w}}ye();var Jc=(0,Rl.makeStyles)()({dialogContent:{width:"80em",display:"flex",flexDirection:"column",gap:20},sequenceInput:{fontFamily:"monospace"},di3Section:{display:"flex",flexDirection:"column",gap:8}}),Kc=(0,Wl.observer)(function({feature:t,model:o,handleClose:n}){let{classes:r}=Jc(),i=(0,Gn.getSession)(o),s=(0,Gn.getContainingView)(o),[a,l]=(0,_.useState)(),[p,m]=(0,_.useState)(Un),{results:c,cleanedAaSequence:d,di3Sequence:y,isLoading:w,isPredicting:f,error:h,statusMessage:b,predictStructure:g,search:C,reset:H}=ai(),S=gt(t),{isoformSequences:U,isLoading:J,error:re}=Jt({feature:t,view:s}),{userSelection:M,setUserSelection:fe}=Kt({options:S,isoformSequences:U}),ue=S.find(oe=>oe.id()===M),Pe=(M?U?.[M]:void 0)?.seq.replace(/\*/g,"")??"",ee=a??Pe,Be=oe=>{fe(oe),l(void 0)},te=ee.trim().length>0&&!f&&!w,We=!!d&&!!y&&p.length>0&&!w,Re=h??re,he=w||f;return _.default.createElement(_.default.Fragment,null,_.default.createElement(Me.DialogContent,{className:r.dialogContent},Re&&!J?_.default.createElement(Bo.ErrorMessage,{error:Re}):null,J?_.default.createElement(Bo.LoadingEllipses,{variant:"subtitle2",message:"Loading transcript sequences"}):null,U?_.default.createElement(_.default.Fragment,null,_.default.createElement(Rt,{val:M,setVal:Be,isoforms:S,isoformSequences:U,feature:t,disabled:he}),_.default.createElement(Me.TextField,{label:"Protein sequence (amino acids)",multiline:!0,rows:4,value:ee,onChange:oe=>{l(oe.target.value)},placeholder:"MKTVRQERLKSIVRILERSKEPVSGAQLAEEL...",disabled:he,InputProps:{className:r.sequenceInput}})):null,y?_.default.createElement("div",{className:r.di3Section},_.default.createElement(Me.Typography,{variant:"subtitle2"},"3Di structural alphabet (used for searching):"),_.default.createElement(Me.TextField,{multiline:!0,rows:4,value:y,InputProps:{className:r.sequenceInput,readOnly:!0}})):null,_.default.createElement(oi,{selected:p,onChange:m,disabled:he}),b?_.default.createElement(Bo.LoadingEllipses,{variant:"subtitle2",message:b}):null,c?_.default.createElement(si,{results:c,session:i,view:s,feature:t,selectedTranscript:ue,userProvidedTranscriptSequence:ee,onClose:n}):null),_.default.createElement(Me.DialogActions,null,_.default.createElement(Me.Button,{variant:"contained",color:"secondary",onClick:()=>{n()}},"Cancel"),c?_.default.createElement(Me.Button,{variant:"outlined",onClick:()=>{H()}},"New search"):null,y?_.default.createElement(Me.Button,{variant:"contained",color:"primary",disabled:!We,onClick:()=>{C(d,y,p)}},w?"Searching...":"Search Foldseek"):_.default.createElement(Me.Button,{variant:"contained",color:"primary",disabled:!te,onClick:()=>{g(ee.trim())}},f?"Predicting...":"Predict 3Di structure")))}),_l=Kc;var Ne=u(x());li();var Ql=u(L()),Yc=(0,Ne.lazy)(()=>Promise.resolve().then(()=>(Xl(),Zl)));function Ho(){let[e,t]=(0,Ne.useState)(!1);return Ne.default.createElement(Ne.default.Fragment,null,Ne.default.createElement(Ql.IconButton,{onClick:()=>{t(!0)}},Ne.default.createElement(On,null)),e?Ne.default.createElement(Ne.Suspense,{fallback:null},Ne.default.createElement(Yc,{handleClose:()=>{t(!1)}})):null)}var pi=u(x());function Uo({children:e,value:t,index:o,...n}){return pi.default.createElement("div",{role:"tabpanel",hidden:t!==o,...n},t===o&&pi.default.createElement("div",null,e))}var N=u(x()),jn=u(Oe()),Wn=u(X()),qt=u(L()),ep=u(j()),tp=u(ot());var ne=u(x()),Q=u(L());it();function ui({choice:e,setChoice:t,structureURL:o,setStructureURL:n,file:r,setFile:i,pdbId:s,setPdbId:a}){return ne.default.createElement("div",{style:{display:"flex",margin:30}},ne.default.createElement(Q.Typography,null,"Open your structure file ",ne.default.createElement(Ho,null)),ne.default.createElement(Q.FormControl,{component:"fieldset"},ne.default.createElement(Q.RadioGroup,{value:e,onChange:l=>{t(l.target.value)}},ne.default.createElement(Q.FormControlLabel,{value:"url",control:ne.default.createElement(Q.Radio,null),label:"URL"}),ne.default.createElement(Q.FormControlLabel,{value:"file",control:ne.default.createElement(Q.Radio,null),label:"File"}),ne.default.createElement(Q.FormControlLabel,{value:"pdb",control:ne.default.createElement(Q.Radio,null),label:"PDB ID"}))),e==="url"?ne.default.createElement("div",null,ne.default.createElement(Q.Typography,null,"Open a PDB/mmCIF/etc. file from remote URL"),ne.default.createElement(Q.TextField,{label:"URL",value:o,onChange:l=>{n(l.target.value)}})):null,e==="file"?ne.default.createElement("div",{style:{paddingTop:20}},ne.default.createElement(Q.Typography,null,"Open a PDB/mmCIF/etc. file from your local drive"),ne.default.createElement(Q.Button,{variant:"outlined",component:"label"},"Choose File",ne.default.createElement("input",{type:"file",hidden:!0,onChange:({target:l})=>{let p=l.files?.[0];p&&i(p)}}))):null,e==="pdb"?ne.default.createElement(Q.TextField,{value:s,onChange:l=>{let p=l.target.value;a(p),n(Eo(p))},label:"PDB ID"}):null)}_t();async function zn({data:e,format:t="pdb",options:o,plugin:n}){let r=await n.builders.data.rawData({data:e,label:o?.dataLabel}),i=await n.builders.structure.parseTrajectory(r,t);return In({plugin:n,trajectory:i,options:o})}function $c(e){let t=e.lastIndexOf("."),o=t>=0?e.slice(t+1).toLowerCase():"";return o==="cif"||o==="mmcif"||o==="bcif"?"mmcif":"pdb"}async function Zc(e,t){return qn(async o=>{let{model:n}=await zn({data:await e.text(),plugin:o,format:t});return fo(n)})}function mi({file:e}){let{data:t,error:o,isLoading:n}=ze(e?["local-structure",e.name,e.size,e.lastModified]:null,async()=>{if(!e)return;let r=await Zc(e,$c(e.name));if(!r)throw new Error("no sequences detected in file");return r},{revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1});return{error:o,isLoading:n,sequences:t}}it();ye();var Xc=(0,tp.makeStyles)()(e=>({dialogContent:{marginTop:e.spacing(6),width:"80em"},textAreaFont:{fontFamily:"Courier New"}}));function Qc(){return N.default.createElement("div",{style:{marginBottom:20}},"Manually supply a protein structure (PDB, mmCIF, etc) for a given transcript. You can open the file from the result of running, for example,"," ",N.default.createElement(Ae,{href:"https://github.com/sokrypton/ColabFold"},"ColabFold"),". This plugin will align the protein sequence calculated from the genome to the protein sequence embedded in the structure file which allows for slight differences in these two representations.")}var ed=(0,ep.observer)(function({feature:t,model:o,handleClose:n,alignmentAlgorithm:r,onAlignmentAlgorithmChange:i}){let{classes:s}=Xc(),a=(0,Wn.getSession)(o),[l,p]=(0,N.useState)(),[m,c]=(0,N.useState)(""),[d,y]=(0,N.useState)("file"),[w,f]=(0,N.useState)(),[h,b]=(0,N.useState)(""),[g,C]=(0,N.useState)(!1),H=d==="file"?l:void 0,S=d==="file"?"":h,U=gt(t),J=(0,Wn.getContainingView)(o),{isoformSequences:re,error:M}=Jt({feature:t,view:J}),{sequences:fe,error:ue}=mi({file:H}),{sequences:Fe,error:Pe}=No({url:S}),ee=H?.name??S.slice(S.lastIndexOf("/")+1),te=(H?fe:Fe)?.[0],{userSelection:We,setUserSelection:Re}=Kt({options:U,isoformSequences:re,structureSequence:te}),he=U.find(He=>en(He)===We),oe=We?re?.[We]:void 0,oo=M??w??ue??Pe,et=!!(S||H)&&!!oe&&!!he,_e=!!oe?.seq&&!!te&&se(oe.seq)!==te,ut=async()=>{if(!(!oe||!he))try{let He=H?await H.text():void 0;Wt({session:a,view:J,feature:t,selectedTranscript:he,url:S||void 0,data:He,userProvidedTranscriptSequence:oe.seq,alignmentAlgorithm:r,displayName:`Protein view ${io(t)} - ${Ee(he)}`}),n()}catch(He){console.error(He),f(He)}};return N.default.createElement(N.default.Fragment,null,N.default.createElement(qt.DialogContent,{className:s.dialogContent},oo?N.default.createElement(jn.ErrorMessage,{error:oo}):null,N.default.createElement(Qc,null),N.default.createElement(ui,{choice:d,setChoice:y,structureURL:h,setStructureURL:b,file:l,setFile:p,pdbId:m,setPdbId:c}),N.default.createElement("div",{style:{margin:20}},re?te?N.default.createElement(N.default.Fragment,null,N.default.createElement(Rt,{val:We,setVal:Re,structureSequence:te,isoforms:U,feature:t,isoformSequences:re}),N.default.createElement("div",{style:{margin:10}},N.default.createElement(qt.Button,{variant:"contained",color:"primary",onClick:()=>{C(!g)}},g?"Hide all isoform protein sequences":"Show all isoform protein sequences"),g?N.default.createElement(Co,{structureSequence:te,structureName:ee,isoformSequences:re}):null)):null:N.default.createElement(jn.LoadingEllipses,{title:"Loading protein sequences",variant:"h6"}))),N.default.createElement(qt.DialogActions,null,_e?N.default.createElement(Fo,{alignmentAlgorithm:r,onAlignmentAlgorithmChange:i}):null,N.default.createElement(qt.Button,{variant:"contained",color:"secondary",onClick:()=>{n()}},"Cancel"),N.default.createElement(qt.Button,{variant:"contained",color:"primary",disabled:!et,onClick:()=>{ut()}},"Launch 3-D protein structure view")))}),op=ed;var np=u(x());function rp(e,t){let[o,n]=(0,np.useState)(()=>{let i=localStorage.getItem(e);if(i)try{return JSON.parse(i)}catch{return t}return t});function r(i){n(i),localStorage.setItem(e,JSON.stringify(i))}return[o,r]}function ci({handleClose:e,feature:t,model:o}){let[n,r]=(0,de.useState)(0),[i,s]=rp("jbrowse-protein3d-alignment-algorithm",Mo);return de.default.createElement(ip.Dialog,{maxWidth:"xl",title:"Launch protein view",titleNode:de.default.createElement(de.default.Fragment,null,"Launch protein view ",de.default.createElement(Ho,null)),open:!0,onClose:e},de.default.createElement(yo.Tabs,{value:n,onChange:(a,l)=>{r(l)}},de.default.createElement(yo.Tab,{value:0,label:"AlphaFoldDB search"}),de.default.createElement(yo.Tab,{value:1,label:"Foldseek search"}),de.default.createElement(yo.Tab,{value:2,label:"Open file manually"})),de.default.createElement(Uo,{value:n,index:0},de.default.createElement(Nl,{model:o,feature:t,handleClose:e,alignmentAlgorithm:i,onAlignmentAlgorithmChange:s})),de.default.createElement(Uo,{value:n,index:1},de.default.createElement(_l,{model:o,feature:t,handleClose:e})),de.default.createElement(Uo,{value:n,index:2},de.default.createElement(op,{model:o,feature:t,handleClose:e,alignmentAlgorithm:i,onAlignmentAlgorithmChange:s})))}function td(e){return e.name==="LinearBasicDisplay"}function od(e){return e.views(t=>{let o=t.contextMenuItems;return{contextMenuItems(){let n=t.contextMenuFeature,r=n!==void 0&&["gene","mRNA","transcript"].includes(n.get("type"));return[...o(),...r?[{label:"Launch protein view",icon:wa,onClick:()=>{let i=(0,Rn.getContainingTrack)(t);(0,Rn.getSession)(i).queueDialog(a=>[ci,{model:i,handleClose:a,feature:n}])}}]:[]]}}})}function di(e){e.addToExtensionPoint("Core-extendPluggableElement",t=>(td(t)&&(t.stateModel=od(t.stateModel)),t))}function gi(e){e.addToExtensionPoint("LaunchView-ProteinView",async({session:t,url:o,userProvidedTranscriptSequence:n,feature:r,connectedViewId:i,alignmentAlgorithm:s,displayName:a,height:l,showControls:p,showHighlight:m,zoomToBaseLevel:c})=>{if(!o)throw new Error("No URL provided when launching protein view");t.addView("ProteinView",{type:"ProteinView",alignmentAlgorithm:s,displayName:a,height:l,showControls:p,showHighlight:m,zoomToBaseLevel:c,structures:[{url:o,userProvidedTranscriptSequence:n??"",feature:r,connectedViewId:i}]})})}var tm=u(x()),om=u(fi());var qp=u(fi()),Dp=u(lp()),pe=u(hi());Gt();var up=u(Ot(),1),bi=(0,Ie.createSvgIcon)((0,up.jsx)("path",{d:"M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3"}),"Visibility");var jo=u(no());yi();function dp(e,t){let o=e.obj?.data;if(!o)return;let{B_iso_or_equiv:n}=o.atomicConformation,{offsets:r,count:i}=o.atomicHierarchy.residueAtomSegments,s=t===void 0?i:Math.min(i,t),a=[];for(let l=0;l<s;l++)a.push(n.value(r[l]));return a}function gp(e){return!!e&&e.length>1&&e.every(t=>t>=0&&t<=100)&&new Set(e).size>1}var zo=u(X()),K=u(hi()),$t=u(no());Si();Ao();Ht();var bp=e=>e;var Ti=e=>e;function yp(e){let{structureSeqToTranscriptSeqPosition:t,transcriptSeqToStructureSeqPosition:o}=ds(e),n=fs(e),r=hs(e),i=ir(n),s=ir(r);return{structureToTranscript:a=>t[a],transcriptToStructure:a=>o[a],structureToAlignment:a=>n[a],alignmentToStructure:a=>i[a],transcriptToAlignment:a=>r[a],alignmentToTranscript:a=>s[a],maps:{structureSeqToTranscriptSeqPosition:t,transcriptSeqToStructureSeqPosition:o,structurePositionToAlignmentMap:n,transcriptPositionToAlignmentMap:r,alignmentToStructurePosition:i,alignmentToTranscriptPosition:s}}}Ai();var _n=["A","R","N","D","C","Q","E","G","H","I","L","K","M","F","P","S","T","W","Y","V","B","Z","X","*"],nd=[[4,-1,-2,-2,0,-1,-1,0,-2,-1,-1,-1,-1,-2,-1,1,0,-3,-2,0,-2,-1,0,-4],[-1,5,0,-2,-3,1,0,-2,0,-3,-2,2,-1,-3,-2,-1,-1,-3,-2,-3,-1,0,-1,-4],[-2,0,6,1,-3,0,0,0,1,-3,-3,0,-2,-3,-2,1,0,-4,-2,-3,3,0,-1,-4],[-2,-2,1,6,-3,0,2,-1,-1,-3,-4,-1,-3,-3,-1,0,-1,-4,-3,-3,4,1,-1,-4],[0,-3,-3,-3,9,-3,-4,-3,-3,-1,-1,-3,-1,-2,-3,-1,-1,-2,-2,-1,-3,-3,-2,-4],[-1,1,0,0,-3,5,2,-2,0,-3,-2,1,0,-3,-1,0,-1,-2,-1,-2,0,3,-1,-4],[-1,0,0,2,-4,2,5,-2,0,-3,-3,1,-2,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-2,0,-1,-3,-2,-2,6,-2,-4,-4,-2,-3,-3,-2,0,-2,-2,-3,-3,-1,-2,-1,-4],[-2,0,1,-1,-3,0,0,-2,8,-3,-3,-1,-2,-1,-2,-1,-2,-2,2,-3,0,0,-1,-4],[-1,-3,-3,-3,-1,-3,-3,-4,-3,4,2,-3,1,0,-3,-2,-1,-3,-1,3,-3,-3,-1,-4],[-1,-2,-3,-4,-1,-2,-3,-4,-3,2,4,-2,2,0,-3,-2,-1,-2,-1,1,-4,-3,-1,-4],[-1,2,0,-1,-3,1,1,-2,-1,-3,-2,5,-1,-3,-1,0,-1,-3,-2,-2,0,1,-1,-4],[-1,-1,-2,-3,-1,0,-2,-3,-2,1,2,-1,5,0,-2,-1,-1,-1,-1,1,-3,-1,-1,-4],[-2,-3,-3,-3,-2,-3,-3,-3,-1,0,0,-3,0,6,-4,-2,-2,1,3,-1,-3,-3,-1,-4],[-1,-2,-2,-1,-3,-1,-1,-2,-2,-3,-3,-1,-2,-4,7,-1,-1,-4,-3,-2,-2,-1,-2,-4],[1,-1,1,0,-1,0,0,0,-1,-2,-2,0,-1,-2,-1,4,1,-3,-2,-2,0,0,0,-4],[0,-1,0,-1,-1,-1,-1,-2,-2,-1,-1,-1,-1,-2,-1,1,5,-2,-2,0,-1,-1,0,-4],[-3,-3,-4,-4,-2,-2,-3,-2,-2,-3,-2,-3,-1,1,-4,-3,-2,11,2,-3,-4,-3,-2,-4],[-2,-2,-2,-3,-2,-1,-2,-3,2,-1,-1,-2,-1,3,-3,-2,-2,2,7,-1,-3,-2,-1,-4],[0,-3,-3,-3,-1,-2,-2,-3,-3,3,1,-2,1,-1,-2,-2,0,-3,-1,4,-3,-2,-1,-4],[-2,-1,3,4,-3,0,1,-1,0,-3,-4,0,-3,-3,-2,0,-1,-4,-3,-3,4,1,-1,-4],[-1,0,0,1,-3,3,4,-2,0,-3,-3,1,-1,-3,-1,0,-1,-3,-2,-2,1,4,-1,-4],[0,-1,-1,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-2,0,0,-2,-1,-1,-1,-1,-1,-4],[-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,1]],xp={};for(let e=0;e<_n.length;e++){let t={};for(let o=0;o<_n.length;o++)t[_n[o]]=nd[e][o];xp[_n[e]]=t}function Go(e,t){return xp[e.toUpperCase()]?.[t.toUpperCase()]??-4}var vp=-10,Sp=-.5;function rd(e,t,o=vp,n=Sp){let r=e.length,i=t.length,s=[],a=[],l=[];for(let h=0;h<=r;h++){s[h]=[],a[h]=[],l[h]=[];for(let b=0;b<=i;b++)s[h][b]=-1/0,a[h][b]=-1/0,l[h][b]=-1/0}s[0][0]=0;for(let h=1;h<=r;h++)a[h][0]=o+(h-1)*n;for(let h=1;h<=i;h++)l[0][h]=o+(h-1)*n;for(let h=1;h<=r;h++)for(let b=1;b<=i;b++){let g=Go(e[h-1],t[b-1]);s[h][b]=Math.max(s[h-1][b-1],a[h-1][b-1],l[h-1][b-1])+g,a[h][b]=Math.max(s[h-1][b]+o,a[h-1][b]+n),l[h][b]=Math.max(s[h][b-1]+o,l[h][b-1]+n)}let p="",m="",c=r,d=i,y=[s[r][i],a[r][i],l[r][i]],w=Math.max(...y),f=w===s[r][i]?"M":w===a[r][i]?"Ix":"Iy";for(;c>0||d>0;)if(f==="M"&&c>0&&d>0){p=e[c-1]+p,m=t[d-1]+m;let h=Go(e[c-1],t[d-1]),b=s[c-1][d-1],g=a[c-1][d-1];s[c][d]===b+h?f="M":s[c][d]===g+h?f="Ix":f="Iy",c--,d--}else if(f==="Ix"&&c>0)p=e[c-1]+p,m="-"+m,f=a[c][d]===s[c-1][d]+o?"M":"Ix",c--;else if(d>0)p="-"+p,m=t[d-1]+m,f=l[c][d]===s[c][d-1]+o?"M":"Iy",d--;else break;return{alignedSeq1:p,alignedSeq2:m,score:w}}function id(e,t,o=vp,n=Sp){let r=e.length,i=t.length,s=[],a=[],l=[],p=0,m=0,c=0;for(let b=0;b<=r;b++){s[b]=[],a[b]=[],l[b]=[];for(let g=0;g<=i;g++)s[b][g]=0,a[b][g]=-1/0,l[b][g]=-1/0}for(let b=1;b<=r;b++)for(let g=1;g<=i;g++){let C=Go(e[b-1],t[g-1]);s[b][g]=Math.max(0,s[b-1][g-1]+C,a[b-1][g-1]+C,l[b-1][g-1]+C),a[b][g]=Math.max(s[b-1][g]+o,a[b-1][g]+n),l[b][g]=Math.max(s[b][g-1]+o,l[b][g-1]+n);let H=Math.max(s[b][g],a[b][g],l[b][g]);H>p&&(p=H,m=b,c=g)}let d="",y="",w=m,f=c,h=s[w][f]>=a[w][f]&&s[w][f]>=l[w][f]?"M":a[w][f]>=l[w][f]?"Ix":"Iy";for(let b=e.length;b>m;b--)d=e[b-1]+d,y="-"+y;for(let b=t.length;b>c;b--)d="-"+d,y=t[b-1]+y;for(;w>0&&f>0;)if(h==="M"){if(s[w][f]===0)break;d=e[w-1]+d,y=t[f-1]+y;let b=Go(e[w-1],t[f-1]),g=s[w-1][f-1],C=a[w-1][f-1];s[w][f]===g+b?h="M":s[w][f]===C+b?h="Ix":h="Iy",w--,f--}else h==="Ix"?(d=e[w-1]+d,y="-"+y,a[w][f]===s[w-1][f]+o&&(h="M"),w--):(d="-"+d,y=t[f-1]+y,l[w][f]===s[w][f-1]+o&&(h="M"),f--);for(;w>0;)d=e[w-1]+d,y="-"+y,w--;for(;f>0;)d="-"+d,y=t[f-1]+y,f--;return{alignedSeq1:d,alignedSeq2:y,score:p}}function sd(e,t){let o=[];for(let n=0;n<e.length;n++){let r=e[n],i=t[n];r!=="-"&&i!=="-"&&r.toUpperCase()===i.toUpperCase()?o.push("|"):r!=="-"&&i!=="-"&&Go(r,i)>0?o.push(":"):o.push(" ")}return o.join("")}function Tp(e,t,o){let{alignedSeq1:n,alignedSeq2:r}=o==="smith_waterman"?id(e,t):rd(e,t);return{consensus:sd(n,r),alns:[{id:"a",seq:n},{id:"b",seq:r}]}}var Pp=Object.fromEntries([{name:"alanine",abbreviation:"Ala",singleLetterCode:"A"},{name:"arginine",abbreviation:"Arg",singleLetterCode:"R"},{name:"asparagine",abbreviation:"Asn",singleLetterCode:"N"},{name:"aspartic acid",abbreviation:"Asp",singleLetterCode:"D"},{name:"cysteine",abbreviation:"Cys",singleLetterCode:"C"},{name:"glutamic acid",abbreviation:"Glu",singleLetterCode:"E"},{name:"glutamine",abbreviation:"Gln",singleLetterCode:"Q"},{name:"glycine",abbreviation:"Gly",singleLetterCode:"G"},{name:"histidine",abbreviation:"His",singleLetterCode:"H"},{name:"isoleucine",abbreviation:"Ile",singleLetterCode:"I"},{name:"leucine",abbreviation:"Leu",singleLetterCode:"L"},{name:"lysine",abbreviation:"Lys",singleLetterCode:"K"},{name:"methionine",abbreviation:"Met",singleLetterCode:"M"},{name:"phenylalanine",abbreviation:"Phe",singleLetterCode:"F"},{name:"proline",abbreviation:"Pro",singleLetterCode:"P"},{name:"serine",abbreviation:"Ser",singleLetterCode:"S"},{name:"threonine",abbreviation:"Thr",singleLetterCode:"T"},{name:"tryptophan",abbreviation:"Trp",singleLetterCode:"W"},{name:"tyrosine",abbreviation:"Tyr",singleLetterCode:"Y"},{name:"valine",abbreviation:"Val",singleLetterCode:"V"}].map(e=>[e.abbreviation.toUpperCase(),e]));Ci();Fi();Bt();function ud(e,t){return{structureSeqPos:e.StructureProperties.residue.auth_seq_id(t)-1,code:e.StructureProperties.atom.label_comp_id(t),chain:e.StructureProperties.chain.auth_asym_id(t)}}async function Kn({plugin:e,kind:t,onUpdate:o}){let n=await be(),r=e.behaviors.interaction[t].subscribe(i=>{if(n.StructureElement.Loci.is(i.current.loci)){let s=n.StructureElement.Loci.getFirstLocation(i.current.loci);o(s?ud(n,s):void 0)}else o(void 0)});return()=>{r.unsubscribe()}}Ht();it();ye();Ao();var md=K.types.model({url:K.types.maybe(K.types.string),data:K.types.maybe(K.types.string),connectedViewId:K.types.maybe(K.types.string),pairwiseAlignment:K.types.frozen(),feature:K.types.frozen(),userProvidedTranscriptSequence:K.types.string}).volatile(()=>({clickedStructureRange:void 0,hoverPosition:void 0,structureSequences:void 0,structureConfidence:void 0,isMouseInAlignment:!1,loadedToMolstar:!1,alignmentHoverRange:void 0,selectedFeatureId:void 0,hiddenFeatureTypes:new Set})).actions(e=>({setStructureData(t){e.structureSequences=t.sequences,e.structureConfidence=t.confidence},hideFeatureType(t){e.hiddenFeatureTypes=new Set([...e.hiddenFeatureTypes,t])},showFeatureType(t){let o=new Set(e.hiddenFeatureTypes);o.delete(t),e.hiddenFeatureTypes=o},showAllFeatureTypes(){e.hiddenFeatureTypes=new Set},setLoadedToMolstar(t){e.loadedToMolstar=t}})).views(e=>({get connectedView(){let{views:t}=(0,zo.getSession)(e);return t.find(o=>o.id===e.connectedViewId)}})).actions(e=>({setClickedStructureRange(t){e.clickedStructureRange=t},setAlignmentHoverRange(t){e.alignmentHoverRange=t},setSelectedFeatureId(t){e.selectedFeatureId=t},setHoveredPosition(t){e.hoverPosition=t},setAlignment(t){e.pairwiseAlignment=t},setIsMouseInAlignment(t){e.isMouseInAlignment=t}})).views(e=>({get uniprotId(){let{url:t}=e;if(t)return hn(t)},get coordinateMapper(){return e.pairwiseAlignment?yp(e.pairwiseAlignment):void 0},get structureSeqToTranscriptSeqPosition(){return this.coordinateMapper?.maps.structureSeqToTranscriptSeqPosition},get transcriptSeqToStructureSeqPosition(){return this.coordinateMapper?.maps.transcriptSeqToStructureSeqPosition},get structurePositionToAlignmentMap(){return this.coordinateMapper?.maps.structurePositionToAlignmentMap},get transcriptPositionToAlignmentMap(){return this.coordinateMapper?.maps.transcriptPositionToAlignmentMap},get confidenceCells(){let t=e.structureConfidence;return gp(t)?Mi(t,this.structurePositionToAlignmentMap):[]},get hydrophobicityCells(){let t=e.structureSequences?.[0];return t?Mi(Cp(se(t)),this.structurePositionToAlignmentMap):[]},get pairwiseAlignmentToTranscriptPosition(){return this.coordinateMapper?.maps.alignmentToTranscriptPosition},get pairwiseAlignmentToStructurePosition(){return this.coordinateMapper?.maps.alignmentToStructurePosition},get hoverString(){let t=e.hoverPosition;if(t===void 0)return"";let o=this.hoverStructureLetter,n=this.hoverGenomeLetter,r=[];return t.structureSeqPos!==void 0&&r.push(`${t.structureSeqPos+1}`),o&&r.push(`Structure: ${o}`),n&&o&&n!==o&&r.push(`Genome: ${n}`),t.chain&&r.push(`Chain: ${t.chain}`),r.join(", ")},get genomeToTranscriptSeqMapping(){return e.feature?ro(new zo.SimpleFeature(e.feature)):void 0},get structureSeqHoverPos(){return e.hoverPosition?.structureSeqPos},get alignmentHoverPos(){let t=this.structureSeqHoverPos;return t===void 0?void 0:this.coordinateMapper?.structureToAlignment(bp(t))},get hoverStructureRange(){let{alignmentHoverRange:t}=e,o=this.pairwiseAlignmentToStructurePosition;if(!t||!o)return;let n=o[t.start],r=o[t.end];return n===void 0||r===void 0?void 0:{start:n,end:r+1}},get clickAlignmentRange(){let t=e.clickedStructureRange,o=this.structurePositionToAlignmentMap;if(!t||!o)return;let n=o[t.start],r=o[t.end-1];return n===void 0||r===void 0?void 0:{start:n,end:r}},structureRangeToGenomeHighlight(t){let o=e.connectedView?.assemblyNames[0],n=this.genomeToTranscriptSeqMapping;if(!t||!o||!n)return[];let r={genomeToTranscriptSeqMapping:n,pairwiseAlignment:e.pairwiseAlignment,structureSeqToTranscriptSeqPosition:this.structureSeqToTranscriptSeqPosition},i=t.end>t.start+1?ki({model:r,structureSeqPos:t.start,structureSeqEndPos:t.end}):Jn({model:r,structureSeqPos:t.start});if(!i)return[];let[s,a]=i;return[{assemblyName:o,refName:n.refName,start:s,end:a}]},get hoverGenomeHighlights(){let t=this.hoverStructureRange;if(t)return this.structureRangeToGenomeHighlight(t);let o=this.structureSeqHoverPos;return o===void 0?[]:this.structureRangeToGenomeHighlight({start:o,end:o+1})},get clickGenomeHighlights(){return this.structureRangeToGenomeHighlight(e.clickedStructureRange)},get hoverStructureLetter(){let t=e.hoverPosition?.code;if(t)return Pp[t]?.singleLetterCode;let o=this.structureSeqHoverPos;if(o!==void 0&&e.structureSequences?.[0])return e.structureSequences[0][o]},get hoverGenomeLetter(){let t=this.structureSeqHoverPos;if(t===void 0)return;let o=this.structureSeqToTranscriptSeqPosition?.[t];if(o!==void 0)return e.userProvidedTranscriptSequence[o]},get alignmentMatchSet(){let t=e.pairwiseAlignment?.consensus;if(!t)return;let o=new Set;for(let n=0;n<t.length;n++)(t[n]==="|"||t[n]===":")&&o.add(n);return o},get exactMatch(){let t=se(e.userProvidedTranscriptSequence),o=e.structureSequences?.[0]?se(e.structureSequences[0]):void 0;return t===o},get parentView(){return(0,K.getParent)(e,2)},get zoomToBaseLevel(){return this.parentView.zoomToBaseLevel},get autoScrollAlignment(){return this.parentView.autoScrollAlignment},get showHighlight(){return this.parentView.showHighlight},get showProteinTracks(){return this.parentView.showProteinTracks},get alignmentAlgorithm(){return Va(this.parentView.alignmentAlgorithm)},get molstarPluginContext(){return this.parentView.molstarPluginContext},get structureIndex(){return this.parentView.structures.indexOf(e)},get molstarStructure(){let t=this.structureIndex;return e.loadedToMolstar&&t>=0?this.molstarPluginContext?.managers.structure.hierarchy.current.structures[t]?.cell.obj?.data:void 0}})).actions(e=>({setError(t){e.parentView.setError(t)},hoverAlignmentPosition(t){if(!e.alignmentHoverRange){let o=e.coordinateMapper?.alignmentToStructure(Ti(t));e.setHoveredPosition(o!==void 0?{structureSeqPos:o}:void 0)}},clickAlignmentPosition(t){let o=e.coordinateMapper?.alignmentToStructure(Ti(t));e.setSelectedFeatureId(void 0),o!==void 0?Oo({model:e,structureSeqPos:o}).catch(n=>{console.error(n),e.parentView.setError(n)}):e.setClickedStructureRange(void 0)}})).actions(e=>({afterAttach(){(0,K.addDisposer)(e,(0,$t.autorun)(async()=>{try{let{userProvidedTranscriptSequence:t,structureSequences:o,exactMatch:n,alignmentAlgorithm:r}=e,i=t,s=o?.[0];if(e.pairwiseAlignment||!i||!s)return;let a=se(i),l=se(s);if(n)e.setAlignment({consensus:"|".repeat(a.length),alns:[{id:"seq1",seq:a},{id:"seq2",seq:l}]});else{let p=Tp(a,l,r);e.setAlignment(p),e.parentView.setShowAlignment(!0)}}catch(t){console.error(t),e.parentView.setError(t)}})),(0,K.addDisposer)(e,(0,$t.autorun)(()=>{let{hovered:t}=(0,zo.getSession)(e),{transcriptSeqToStructureSeqPosition:o,genomeToTranscriptSeqMapping:n,connectedView:r}=e;if(r?.initialized&&n&&St(t)){let{hoverPosition:i}=t,s=n.g2p[i.coord-1];if(s!==void 0){let a=o?.[s];a!==void 0&&e.setHoveredPosition({structureSeqPos:a})}}})),(0,K.addDisposer)(e,(0,$t.autorun)(async()=>{let{molstarPluginContext:t}=e;if(t){let o=await Kn({plugin:t,kind:"click",onUpdate:n=>{n&&(e.setHoveredPosition(n),e.setSelectedFeatureId(void 0),Oo({model:e,structureSeqPos:n.structureSeqPos}).catch(r=>{console.error(r),e.parentView.setError(r)}))}});(0,K.addDisposer)(e,o)}})),(0,K.addDisposer)(e,(0,$t.autorun)(async()=>{let{molstarPluginContext:t}=e;if(t){let o=await Kn({plugin:t,kind:"hover",onUpdate:n=>{e.setHoveredPosition(n)}});(0,K.addDisposer)(e,o)}})),(0,K.addDisposer)(e,(0,$t.autorun)(async()=>{let{showHighlight:t,structureSeqToTranscriptSeqPosition:o,molstarPluginContext:n,molstarStructure:r}=e;if(r&&n&&o)if(t){let i=Object.keys(o).map(s=>+s+1);await fp({structure:r,residues:i,plugin:n,mode:"select"})}else n.managers.interactivity.lociSelects.deselectAll()})),(0,K.addDisposer)(e,(0,$t.autorun)(async()=>{let{molstarStructure:t,molstarPluginContext:o,hoverStructureRange:n,structureSeqHoverPos:r}=e;t&&o&&(n?await Pi({structure:t,plugin:o,startResidue:n.start+1,endResidue:n.end}):r!==void 0?await hp({structure:t,plugin:o,selectedResidue:r,mode:"highlight"}):o.managers.interactivity.lociHighlights.clearHighlights())}))}})),Yn=md;Bt();var cd="SuperpositionTransform";async function Ei(e){let{QueryContext:t,StructureElement:o,StructureSelection:n,StructureSelectionQueries:r,PluginCommands:i,PluginStateObject:s,tmAlign:a}=await be(),l=e.managers.structure.hierarchy.current.structures;if(l.length<2)return;let{query:p}=r.trace,c=l.map(w=>{let f=w.cell.obj?.data;if(!f)return;let h=e.helpers.substructureParent.get(f);if(!h)return;let b=e.state.data.selectQ(C=>C.byValue(h).rootOfType(s.Molecule.Structure))[0]?.obj?.data;if(!b)return;let g=n.toLociWithSourceUnits(p(new t(f)));return o.Loci.remap(g,b)}).filter(w=>w!==void 0);if(c.length<2)return;let y=e.managers.structure.hierarchy.findStructure(c[0]?.structure)?.transform?.cell.obj?.data.coordinateSystem;for(let w=1;w<c.length;w++){let f=a(c[0],c[w]),{bTransform:h,tmScoreA:b,tmScoreB:g,rmsd:C,alignedLength:H}=f;await dd(e,l[w].cell,h,y),e.log.info(`TM-align: TM-score=${b.toFixed(4)}/${g.toFixed(4)}, RMSD=${C.toFixed(2)} \xC5, aligned ${H} residues.`)}await new Promise(w=>requestAnimationFrame(w)),await i.Camera.Reset(e)}async function dd(e,t,o,n){let{Mat4:r,StateObjectRef:i,StateTransforms:s}=await be(),a=i.resolveAndCheck(e.state.data,t);if(!a)return;let l=e.state.data.selectQ(d=>d.byRef(a.transform.ref).subtree().withTransformer(s.Model.TransformStructureConformation))[0],m={transform:{name:"matrix",params:{data:n&&!r.isIdentity(n.matrix)?r.mul(r(),n.matrix,o):o,transpose:!1}}},c=l?e.state.data.build().to(l).update(m):e.state.data.build().to(t).insert(s.Model.TransformStructureConformation,m,{tags:cd});await e.runTask(e.state.data.updateTree(c))}var Ep="proteinView-settings",Ip=["showAlignment","showProteinTracks","showHighlight","zoomToBaseLevel","autoScrollAlignment"];async function Lp({structure:e,plugin:t}){let{model:o}=e.data?await zn({data:e.data,plugin:t}):e.url?await Ln({url:e.url,plugin:t}):{model:void 0},n=o?fo(o):void 0,r=o?dp(o,n?.[0]?.length):void 0;return{sequences:n,confidence:r}}function gd(){return pe.types.compose("ProteinView",qp.BaseViewModel,pe.types.model({id:Dp.ElementId,type:pe.types.literal("ProteinView"),structures:pe.types.array(Yn),showControls:!1,height:pe.types.optional(pe.types.number,650),showHighlight:!1,zoomToBaseLevel:!0,autoScrollAlignment:!1,colorScheme:pe.types.optional(pe.types.enumeration("ColorScheme",mp),"default"),showAlignment:!0,showProteinTracks:!0,alignmentAlgorithm:pe.types.optional(pe.types.string,Mo),connectedMsaViewId:pe.types.maybe(pe.types.string),init:pe.types.frozen()})).volatile(()=>({error:void 0,molstarPluginContext:void 0,showManualAlignmentDialog:!1,showAddStructureDialog:!1})).actions(e=>({setHeight(t){return e.height=t,t},setShowAlignment(t){e.showAlignment=t},setShowControls(t){e.showControls=t},setError(t){e.error=t},setShowHighlight(t){e.showHighlight=t},setShowProteinTracks(t){e.showProteinTracks=t},setZoomToBaseLevel(t){e.zoomToBaseLevel=t},setAutoScrollAlignment(t){e.autoScrollAlignment=t},setAlignmentAlgorithm(t){e.alignmentAlgorithm=t},setColorScheme(t){e.colorScheme=t},setMolstarPluginContext(t){if(t!==e.molstarPluginContext)for(let o of e.structures)o.setLoadedToMolstar(!1);e.molstarPluginContext=t},setShowManualAlignmentDialog(t){e.showManualAlignmentDialog=t},setShowAddStructureDialog(t){e.showAddStructureDialog=t},setInit(t){e.init=t},setConnectedMsaViewId(t){e.connectedMsaViewId=t},addStructure(t){e.structures.push(Yn.create({url:t.url,data:t.data,userProvidedTranscriptSequence:""}))}})).actions(e=>({async addStructureAndSuperpose(t){let{molstarPluginContext:o}=e;if(!o)return;let n=Yn.create({url:t.url,data:t.data,userProvidedTranscriptSequence:""});n.setLoadedToMolstar(!0),e.structures.push(n);try{n.setStructureData(await Lp({structure:t,plugin:o})),e.structures.length>1&&await Ei(o)}catch(r){e.setError(r),console.error(r)}}})).actions(e=>({afterAttach(){try{let t=localStorage.getItem(Ep);if(t){let o=JSON.parse(t);for(let n of Ip)o[n]!==void 0&&(e[n]=o[n])}}catch(t){console.error("Failed to restore protein view settings",t)}(0,pe.addDisposer)(e,(0,jo.autorun)(()=>{try{let t={};for(let o of Ip)t[o]=e[o];localStorage.setItem(Ep,JSON.stringify(t))}catch(t){console.error("Failed to save protein view settings",t)}})),(0,pe.addDisposer)(e,(0,jo.autorun)(()=>{let{init:t}=e;if(t){let{structures:o,showControls:n,showAlignment:r}=t;if(o)for(let i of o)e.addStructure(i);n!==void 0&&e.setShowControls(n),r!==void 0&&e.setShowAlignment(r),e.setInit(void 0)}})),(0,pe.addDisposer)(e,(0,jo.autorun)(()=>{let{molstarPluginContext:t,colorScheme:o}=e,n=e.structures.filter(r=>r.structureSequences!==void 0).length;t&&n>0&&cp({plugin:t,colorScheme:o}).catch(r=>{console.error(r),e.setError(r)})})),(0,pe.addDisposer)(e,(0,jo.autorun)(async()=>{let{structures:t,molstarPluginContext:o}=e;if(o){for(let n of t)if(!n.loadedToMolstar)try{n.setStructureData(await Lp({structure:n,plugin:o})),n.setLoadedToMolstar(!0)}catch(r){e.setError(r),console.error(r)}}}))}})).views(e=>({get primaryStructure(){return e.structures[0]},menuItems(){return[{label:"Pairwise alignment",icon:bi,type:"checkbox",checked:e.showAlignment,onClick:()=>{e.setShowAlignment(!e.showAlignment)}},{label:"Protein feature tracks",icon:bi,type:"checkbox",checked:e.showProteinTracks,onClick:()=>{e.setShowProteinTracks(!e.showProteinTracks)}},{label:"Color scheme...",subMenu:wo.map(t=>({label:t.label,type:"radio",checked:e.colorScheme===t.value,onClick:()=>{e.setColorScheme(t.value)}}))},{label:"Add structure...",onClick:()=>{e.setShowAddStructureDialog(!0)}},{label:"Advanced...",icon:mn,subMenu:[{label:"Pairwise alignment as green highlight",type:"checkbox",checked:e.showHighlight,onClick:()=>{e.setShowHighlight(!e.showHighlight)}},{label:"Show all protein feature tracks",onClick:()=>{for(let t of e.structures)t.showAllFeatureTypes()}},{label:"Import manual alignment...",onClick:()=>{e.setShowManualAlignmentDialog(!0)}},{label:"Re-align structures (TM-align)",onClick:()=>{e.molstarPluginContext&&Ei(e.molstarPluginContext).catch(t=>{console.error(t),e.setError(t)})}},{label:"Zoom to base level on click",type:"checkbox",checked:e.zoomToBaseLevel,onClick:()=>{e.setZoomToBaseLevel(!e.zoomToBaseLevel)}},{label:"Auto-scroll protein feature view on hover",type:"checkbox",checked:e.autoScrollAlignment,onClick:()=>{e.setAutoScrollAlignment(!e.autoScrollAlignment)}}]}]}}))}var Np=gd;var Gd=(0,tm.lazy)(()=>Promise.resolve().then(()=>(em(),Qu)));function Oi(e){e.addViewType(()=>new om.ViewType({name:"ProteinView",displayName:"Protein view",stateModel:Np(),ReactComponent:Gd}))}var um=u(on());var nm=u(ko());var Od=(0,nm.ConfigurationSchema)("UniProtVariationAdapter",{location:{type:"fileLocation",defaultValue:{uri:"/path/to/my.bed.gz",locationType:"UriLocation"}},scoreField:{type:"string",defaultValue:""}},{explicitlyTyped:!0}),rm=Od;function zi(e){e.addAdapterType(()=>new um.default({name:"UniProtVariationAdapter",displayName:"UniProtVariation adapter",configSchema:rm,getAdapterClass:()=>Promise.resolve().then(()=>(pm(),lm)).then(t=>t.default)}))}var mm="0.4.10";var tr=class extends cm.default{name="ProteinViewer";version=mm;install(t){Oi(t),di(t),gi(t),mr(t),cr(t),dr(t),zi(t)}configure(t){}};return wm(zd);})();
|
|
28
28
|
/*! Bundled license information:
|
|
29
29
|
|
|
30
30
|
use-sync-external-store/cjs/use-sync-external-store-shim.production.js:
|