"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[6621],{66621:(e,t,a)=>{a.r(t),a.d(t,{default:()=>h});var n=a(75466),s=a(350),i=a(46377),r=a(99546),o=a(99834),c=a(66885),l=a(95600);class h extends i.BaseFeatureDataAdapter{async configurePre(e){const t=this.getConf("vcfGzLocation"),a=this.getConf(["index","location"]),i=this.getConf(["index","indexType"]),r=(0,o.openLocation)(t,this.pluginManager),c="CSI"===i,l=new n.wD({filehandle:r,csiFilehandle:c?(0,o.openLocation)(a,this.pluginManager):void 0,tbiFilehandle:c?void 0:(0,o.openLocation)(a,this.pluginManager),chunkCacheSize:52428800});return{vcf:l,parser:new s.A({header:await l.getHeader()})}}async configurePre2(){return this.configured||(this.configured=this.configurePre().catch(e=>{throw this.configured=void 0,e})),this.configured}async configure(e){const{statusCallback:t=()=>{}}=e||{};return(0,r.updateStatus)("Downloading index",t,()=>this.configurePre2())}async getRefNames(e={}){const{vcf:t}=await this.configure(e);return t.getReferenceSequenceNames(e)}async getHeader(e){const{vcf:t}=await this.configure(e);return t.getHeader()}async getMetadata(e){const{parser:t}=await this.configure(e);return t.getMetadata()}getFeatures(e,t={}){return(0,c.ObservableCreate)(async a=>{const{refName:n,start:s,end:i}=e,{statusCallback:o=()=>{}}=t,{vcf:c,parser:h}=await this.configure(t);await(0,r.updateStatus)("Downloading variants",o,()=>c.getLines(n,s,i,{lineCallback:(e,t)=>{a.next(new l.A({variant:h.parseLine(e),parser:h,id:`${this.id}-vcf-${t}`}))},...t})),a.complete()},t.stopToken)}async getSources(){const e=this.getConf("samplesTsvLocation");if(""===e.uri||"/path/to/samples.tsv"===e.uri){const{parser:e}=await this.configure();return e.samples.map(e=>({name:e}))}{const t=(await(0,r.fetchAndMaybeUnzipText)((0,o.openLocation)(e,this.pluginManager))).split(/\n|\r\n|\r/),a=t[0].split("\t"),{parser:n}=await this.configure(),s=t.slice(1).filter(e=>!!e).map(e=>{const[t,...n]=e.split("\t");return{...Object.fromEntries(a.slice(1).map((e,t)=>[e,n[t]||""])),name:t}}),i=new Set(n.samples),c=new Set(s.map(e=>e.name)),l=[...c].filter(e=>!i.has(e)),h=[...i].filter(e=>!c.has(e));return l.length&&console.warn(`There are ${l.length} samples in metadata file (${s.length} lines) not in VCF (${n.samples.length} samples):`,(0,r.shorten2)(l.join(","))),h.length&&console.warn(`There are ${h.length} samples in VCF file (${n.samples.length} samples) not in metadata file (${s.length} lines):`,(0,r.shorten2)(h.map(e=>e).join(","))),s.filter(e=>i.has(e.name))}}}}}]);
//# sourceMappingURL=6621.1cc4a895.chunk.js.map