"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[3416],{3416:(e,a,n)=>{n.r(a),n.d(a,{default:()=>x});var t=n(7552),r=n(68584),s=n(67112),i=n(99546),o=n(91468),c=n(27087),l=n(76218),d=n(61282),g=n(44928),y=n(93062),m=n(30698),f=n(69092),p=n(75785),u=n(69500);const{featurizeSA:h,getClip:w,getLength:S,getLengthSansClipping:b,getTag:C}=c.aF,k=(0,p.n9)()({root:{width:300}});function x({track:e,feature:a,handleClose:n}){const{classes:c}=k(),[p,x]=(0,t.useState)("0"),[A,$]=(0,t.useState)(),[N,v]=(0,t.useState)(),q=+p;return(0,t.useEffect)((()=>{(async()=>{$(void 0);try{if(2048&a.get("flags")){const n=(C(a,"SA")||"").split(";")[0],[t,s]=n.split(","),{rpcManager:c}=(0,i.getSession)(e),l=(0,r.getConf)(e,"adapter"),d=(0,o.getRpcSessionId)(e),g=(await c.call(d,"CoreGetFeatures",{adapterConfig:l,sessionId:d,regions:[{refName:t,start:+s-1,end:+s}]})).find((e=>!(e.get("name")!==a.get("name")||2048&e.get("flags")||256&e.get("flags"))));if(!g)throw new Error("primary feature not found");v(g)}else v(a)}catch(e){console.error(e),$(e)}})()}),[a,e]),(0,u.jsxs)(s.Dialog,{open:!0,onClose:n,title:"Set window size",children:[(0,u.jsx)(l.A,{children:A?(0,u.jsx)(d.A,{color:"error",children:`${A}`}):N?(0,u.jsxs)("div",{className:c.root,children:[256&N.get("flags")?(0,u.jsx)(d.A,{style:{color:"orange"},children:"Note: You selected a secondary alignment (which generally does not have SA tags or SEQ fields) so do a full reconstruction of the alignment"}):null,(0,u.jsx)(d.A,{children:"Show an extra window size around each part of the split alignment. Using a larger value can allow you to see more genomic context."}),(0,u.jsx)(y.A,{value:q,onChange:e=>{x(e.target.value)},label:"Set window size"})]}):(0,u.jsxs)("div",{children:[(0,u.jsx)(d.A,{children:"To accurately perform comparison we are fetching the primary alignment. Loading primary feature..."}),(0,u.jsx)(g.A,{})]})}),(0,u.jsxs)(m.A,{children:[(0,u.jsx)(f.A,{variant:"contained",color:"secondary",onClick:n,children:"Cancel"}),(0,u.jsx)(f.A,{disabled:!N,variant:"contained",color:"primary",onClick:function(){try{if(!N)return;const a=N,t=(0,i.getSession)(e),s=(0,i.getContainingView)(e),o=a.get("CIGAR"),c=a.get("flags"),l=a.get("strand"),d=C(a,"SA")||"",g=a.get("name"),y=w(o,1),m=`${g}_assembly_${Date.now()}`,[f]=(0,r.getConf)(e,"assemblyNames"),p=[f,m],u=`track-${Date.now()}`,k=`${g}_vs_${f}`,{assemblyManager:x}=t,A=x.get(f);if(!A)throw new Error("assembly not found");const $=h(d,a.id(),l,g,!0),v=a.toJSON();v.clipPos=y,v.strand=1,v.mate={refName:g,start:y,end:y+b(o)};const R=S(2048&c?$[0].CIGAR:o),j=[v,...$];for(const[e,a]of j.entries())a.refName=A.getCanonicalRefName(a.refName)||a.refName,a.syntenyId=e,a.mate.syntenyId=e,a.mate.uniqueId=`${a.uniqueId}_mate`;j.sort(((e,a)=>e.clipPos-a.clipPos));const L=a.get("seq"),T=[...j,...j.map((e=>e.mate))],I=2*q,D=j.reduce(((e,a)=>e+a.end-a.start+I),0),_=`${g}_${Date.now()}`,M=(0,r.getConf)(A,"sequence"),P=(0,i.gatherOverlaps)(j.map((e=>({...e,start:Math.max(0,e.start-q),end:e.end+q,assemblyName:f}))));t.addTemporaryAssembly?.({name:m,sequence:{type:"ReferenceSequenceTrack",name:"Read sequence",trackId:_,assemblyNames:[m],adapter:{type:"FromConfigSequenceAdapter",noAssemblyManager:!0,features:[{start:0,end:R,seq:L||"",refName:g,uniqueId:`${Math.random()}`}]}}}),t.addView("LinearSyntenyView",{type:"LinearSyntenyView",views:[{type:"LinearGenomeView",hideHeader:!0,offsetPx:0,bpPerPx:D/s.width,displayedRegions:P,tracks:[{id:`${Math.random()}`,type:"ReferenceSequenceTrack",assemblyNames:[f],configuration:M.trackId,displays:[{id:`${Math.random()}`,type:"LinearReferenceSequenceDisplay",showReverse:!0,showTranslation:!1,height:35,configuration:`${_}-LinearReferenceSequenceDisplay`}]}]},{type:"LinearGenomeView",hideHeader:!0,offsetPx:0,bpPerPx:R/s.width,displayedRegions:[{assemblyName:m,start:0,end:R,refName:g}],tracks:[{id:`${Math.random()}`,type:"ReferenceSequenceTrack",configuration:_,displays:[{id:`${Math.random()}`,type:"LinearReferenceSequenceDisplay",showReverse:!0,showTranslation:!1,height:35,configuration:`${_}-LinearReferenceSequenceDisplay`}]}]}],viewTrackConfigs:[{type:"SyntenyTrack",assemblyNames:p,adapter:{type:"FromConfigAdapter",features:T},trackId:u,name:k}],tracks:[{configuration:u,type:"SyntenyTrack",displays:[{type:"LinearSyntenyDisplay",configuration:`${u}-LinearSyntenyDisplay`}]}],displayName:`${g} vs ${f}`}),n()}catch(e){console.error(e),$(e)}},children:"Submit"})]})]})}}}]);
//# sourceMappingURL=3416.f0510c6f.chunk.js.map