jbrowse-plugin-graphgenomeviewer 4.7.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +7 -1
  2. package/dist/chunks/ChooseWalksDialog-GVQLSGHX.js +2 -0
  3. package/dist/chunks/ChooseWalksDialog-GVQLSGHX.js.map +7 -0
  4. package/dist/chunks/GbzBaseSyntenyAdapter-CKKVHC2R.js +4 -0
  5. package/dist/chunks/GbzBaseSyntenyAdapter-CKKVHC2R.js.map +7 -0
  6. package/dist/chunks/{GraphGenomeView-HZ2EQUOC.js → GraphGenomeView-YYP4IFSI.js} +2 -2
  7. package/dist/chunks/{GraphTrackSettingsDialog-JVPM25GV.js → GraphTrackSettingsDialog-2WPJRAJC.js} +2 -2
  8. package/dist/chunks/LinearGraphDisplay-7YE624D5.js +2 -0
  9. package/dist/chunks/LinearGraphDisplay-7YE624D5.js.map +7 -0
  10. package/dist/chunks/chunk-2H7GDQ3R.js +6 -0
  11. package/dist/chunks/chunk-2H7GDQ3R.js.map +7 -0
  12. package/dist/chunks/chunk-BZOIENU5.js +2 -0
  13. package/dist/chunks/chunk-BZOIENU5.js.map +7 -0
  14. package/dist/chunks/{chunk-UTWFU4X6.js → chunk-H54W6OQQ.js} +2 -2
  15. package/dist/chunks/{chunk-UTWFU4X6.js.map → chunk-H54W6OQQ.js.map} +4 -4
  16. package/dist/chunks/{chunk-F2EPKNTV.js → chunk-O4XV3K35.js} +2 -2
  17. package/dist/chunks/{chunk-F2EPKNTV.js.map → chunk-O4XV3K35.js.map} +4 -4
  18. package/dist/chunks/chunk-SJNG2XK7.js +2 -0
  19. package/dist/chunks/chunk-SJNG2XK7.js.map +7 -0
  20. package/dist/chunks/chunk-WKVVIDCS.js +3 -0
  21. package/dist/chunks/{chunk-KCL5TF5X.js.map → chunk-WKVVIDCS.js.map} +3 -3
  22. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +5 -5
  23. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +4 -4
  24. package/package.json +3 -3
  25. package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.test.ts +36 -2
  26. package/src/GbzBaseSyntenyAdapter/GbzBaseSyntenyAdapter.ts +67 -1
  27. package/src/GbzBaseSyntenyAdapter/test_data/fragmented.haplotype-index.db +0 -0
  28. package/src/GbzBaseSyntenyAdapter/test_data/micb-kir3dl1.haplotype-index.db +0 -0
  29. package/src/GbzBaseSyntenyAdapter/test_data/micb-kir3dl1.sampled.haplotype-index.db +0 -0
  30. package/src/GetHaplotypeOverview.ts +77 -0
  31. package/src/GraphGenomeView/components/ChooseWalksDialog.tsx +86 -0
  32. package/src/GraphGenomeView/components/GraphSettingsDialog.tsx +205 -187
  33. package/src/GraphGenomeView/components/TubeMapLegend.test.tsx +29 -0
  34. package/src/GraphGenomeView/components/TubeMapOverlay.tsx +8 -0
  35. package/src/GraphGenomeView/host.ts +6 -0
  36. package/src/GraphGenomeView/model.ts +10 -4224
  37. package/src/GraphGenomeView/pane/fitViews.ts +589 -0
  38. package/src/GraphGenomeView/pane/graphViews.ts +829 -0
  39. package/src/GraphGenomeView/pane/hostViews.ts +193 -0
  40. package/src/GraphGenomeView/pane/launchActions.ts +407 -0
  41. package/src/GraphGenomeView/pane/launchViews.ts +191 -0
  42. package/src/GraphGenomeView/pane/loadActions.ts +701 -0
  43. package/src/GraphGenomeView/pane/paneBase.ts +479 -0
  44. package/src/GraphGenomeView/pane/renderingActions.ts +281 -0
  45. package/src/GraphGenomeView/pane/settingActions.ts +467 -0
  46. package/src/GraphGenomeView/pane/walkRowViews.ts +205 -0
  47. package/src/HaplotypeOverview/HaplotypeOverviewCanvas.tsx +203 -0
  48. package/src/HaplotypeOverview/draw.test.ts +136 -0
  49. package/src/HaplotypeOverview/draw.ts +433 -0
  50. package/src/HaplotypeOverview/model.ts +163 -0
  51. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +184 -0
  52. package/src/LinearGraphDisplay/components/LinearGraphDisplay.tsx +12 -2
  53. package/src/LinearGraphDisplay/model.ts +107 -3
  54. package/src/gaf/gafFile.ts +2 -0
  55. package/src/index.ts +2 -0
  56. package/src/version.ts +1 -1
  57. package/dist/chunks/GbzBaseSyntenyAdapter-AZBYMDIW.js +0 -8
  58. package/dist/chunks/GbzBaseSyntenyAdapter-AZBYMDIW.js.map +0 -7
  59. package/dist/chunks/LinearGraphDisplay-MJ4ZBJRX.js +0 -2
  60. package/dist/chunks/LinearGraphDisplay-MJ4ZBJRX.js.map +0 -7
  61. package/dist/chunks/chunk-BUXVOMDL.js +0 -2
  62. package/dist/chunks/chunk-BUXVOMDL.js.map +0 -7
  63. package/dist/chunks/chunk-KCL5TF5X.js +0 -3
  64. /package/dist/chunks/{GraphGenomeView-HZ2EQUOC.js.map → GraphGenomeView-YYP4IFSI.js.map} +0 -0
  65. /package/dist/chunks/{GraphTrackSettingsDialog-JVPM25GV.js.map → GraphTrackSettingsDialog-2WPJRAJC.js.map} +0 -0
package/README.md CHANGED
@@ -72,7 +72,9 @@ Needs JBrowse 5.0.0-beta.11 or later.
72
72
  ```
73
73
 
74
74
  - **File → Open track** opens an rGFA index (`.segs.bed.gz` from
75
- `build_rgfa_tabix.sh`) or a gbz-base database (`.gbz.db`) as a `GraphTrack`
75
+ `build_rgfa_tabix.sh`) or a gbz-base database (`.gbz.db`) as a `GraphTrack`.
76
+ It finds the links and indexes beside the url, which a presigned url's
77
+ signature doesn't cover; spell out each location in a config instead
76
78
  - A hand-written track needs only the adapter:
77
79
 
78
80
  ```json
@@ -96,6 +98,10 @@ Needs JBrowse 5.0.0-beta.11 or later.
96
98
  lane or, for gbz-base, the haplotype lanes
97
99
  - Cuts the window plus a window each side, up to 5 Mb; past `aboveBpPerPx`, the
98
100
  `coarse` tier (`build_bubble_tier.sh` in jbrowse-components)
101
+ - gbz-base past the cut (5 Mb, or the adapter's `nodeLimit`) draws the haplotype
102
+ index's overview instead: a band of how many haplotypes diverge from the
103
+ reference by 50 bp or more, then a row per haplotype, the track's lanes first.
104
+ Needs an index from `gbz-haplotype-index` 0.3 or later
99
105
  - gbz-base swaps in `{ "type": "GbzBaseSyntenyAdapter", "uri": "….gbz.db" }`; an
100
106
  `hg38` or `hs1` track finds the graph's GRCh38 or CHM13 reference sample, and
101
107
  `assemblyNameToPanSN` covers other names
@@ -0,0 +1,2 @@
1
+ import{a as y}from"./chunk-J6KYLXRD.js";import{a as c,b as u,c as w,d as C}from"./chunk-TYJTJGPO.js";import{b as t}from"./chunk-FY3BTKY4.js";var k=t(y(),1),p=t(u(),1),e=t(C(),1),h=t(w(),1),a=t(c(),1),b=(0,h.observer)(function({model:l,onClose:i}){let{walkChoices:n}=l,d=new Set(n.map(o=>o.name)),[r,g]=(0,k.useState)(()=>l.walkLayers.map(o=>o.walk).filter(o=>d.has(o)));return(0,a.jsxs)(p.Dialog,{open:!0,onClose:i,title:"Choose walks",children:[(0,a.jsxs)(e.DialogContent,{children:[(0,a.jsx)(e.Autocomplete,{multiple:!0,disableCloseOnSelect:!0,"data-testid":"graph-choose-walks",options:n.map(o=>o.name),getOptionLabel:o=>l.walkLabel(o),value:r,onChange:(o,s)=>{g(s)},renderOption:({key:o,...s},m,{selected:f})=>(0,a.jsxs)("li",{...s,children:[(0,a.jsx)(e.Checkbox,{size:"small",checked:f}),l.walkLabel(m)]},o),renderInput:o=>(0,a.jsx)(e.TextField,{...o,autoFocus:!0,label:"Walks",placeholder:"type to search"})}),(0,a.jsxs)(e.Typography,{variant:"caption",color:"text.secondary",children:[n.length.toLocaleString()," walks in this cut. The ones picked are lifted out of the drawing in this order, and the rest fades."]})]}),(0,a.jsxs)(e.DialogActions,{children:[(0,a.jsx)(e.Button,{onClick:i,children:"Cancel"}),(0,a.jsx)(e.Button,{variant:"contained",onClick:()=>{l.liftWalks(r),i()},children:"Lift these walks"})]})]})}),L=b;export{L as default};
2
+ //# sourceMappingURL=ChooseWalksDialog-GVQLSGHX.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/GraphGenomeView/components/ChooseWalksDialog.tsx"],
4
+ "sourcesContent": ["import { useState } from 'react'\n\nimport { Dialog } from '@jbrowse/core/ui'\nimport {\n Autocomplete,\n Button,\n Checkbox,\n DialogActions,\n DialogContent,\n TextField,\n Typography,\n} from '@mui/material'\nimport { observer } from 'mobx-react'\n\nimport type { GraphPaneModel } from '../model'\n\ntype WalkPicker = Pick<\n GraphPaneModel,\n 'walkChoices' | 'walkLayers' | 'walkLabel' | 'liftWalks'\n>\n\n// Which walks to lift, searched by name, for a graph with more walks than a\n// menu can list\nconst ChooseWalksDialog = observer(function ChooseWalksDialog({\n model,\n onClose,\n}: {\n model: WalkPicker\n onClose: () => void\n}) {\n const { walkChoices } = model\n const names = new Set(walkChoices.map(c => c.name))\n const [picked, setPicked] = useState(() =>\n model.walkLayers.map(l => l.walk).filter(name => names.has(name)),\n )\n return (\n <Dialog open onClose={onClose} title=\"Choose walks\">\n <DialogContent>\n <Autocomplete\n multiple\n disableCloseOnSelect\n data-testid=\"graph-choose-walks\"\n options={walkChoices.map(c => c.name)}\n getOptionLabel={name => model.walkLabel(name)}\n value={picked}\n onChange={(_, value) => {\n setPicked(value)\n }}\n renderOption={({ key, ...props }, name, { selected }) => (\n <li key={key} {...props}>\n <Checkbox size=\"small\" checked={selected} />\n {model.walkLabel(name)}\n </li>\n )}\n renderInput={params => (\n <TextField\n {...params}\n autoFocus\n label=\"Walks\"\n placeholder=\"type to search\"\n />\n )}\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {walkChoices.length.toLocaleString()} walks in this cut. The ones\n picked are lifted out of the drawing in this order, and the rest\n fades.\n </Typography>\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose}>Cancel</Button>\n <Button\n variant=\"contained\"\n onClick={() => {\n model.liftWalks(picked)\n onClose()\n }}\n >\n Lift these walks\n </Button>\n </DialogActions>\n </Dialog>\n )\n})\n\nexport default ChooseWalksDialog\n"],
5
+ "mappings": "6IAAA,IAAAA,EAAyB,SAEzBC,EAAuB,SACvBC,EAQO,SACPC,EAAyB,SAqCbC,EAAA,SA1BNC,KAAoB,YAAS,SAA2B,CAC5D,MAAAC,EACA,QAAAC,CACF,EAGG,CACD,GAAM,CAAE,YAAAC,CAAY,EAAIF,EAClBG,EAAQ,IAAI,IAAID,EAAY,IAAIE,GAAKA,EAAE,IAAI,CAAC,EAC5C,CAACC,EAAQC,CAAS,KAAI,YAAS,IACnCN,EAAM,WAAW,IAAIO,GAAKA,EAAE,IAAI,EAAE,OAAOC,GAAQL,EAAM,IAAIK,CAAI,CAAC,CAClE,EACA,SACE,QAAC,UAAO,KAAI,GAAC,QAASP,EAAS,MAAM,eACnC,qBAAC,iBACC,oBAAC,gBACC,SAAQ,GACR,qBAAoB,GACpB,cAAY,qBACZ,QAASC,EAAY,IAAIE,GAAKA,EAAE,IAAI,EACpC,eAAgBI,GAAQR,EAAM,UAAUQ,CAAI,EAC5C,MAAOH,EACP,SAAU,CAACI,EAAGC,IAAU,CACtBJ,EAAUI,CAAK,CACjB,EACA,aAAc,CAAC,CAAE,IAAAC,EAAK,GAAGC,CAAM,EAAGJ,EAAM,CAAE,SAAAK,CAAS,OACjD,QAAC,MAAc,GAAGD,EAChB,oBAAC,YAAS,KAAK,QAAQ,QAASC,EAAU,EACzCb,EAAM,UAAUQ,CAAI,IAFdG,CAGT,EAEF,YAAaG,MACX,OAAC,aACE,GAAGA,EACJ,UAAS,GACT,MAAM,QACN,YAAY,iBACd,EAEJ,KACA,QAAC,cAAW,QAAQ,UAAU,MAAM,iBACjC,UAAAZ,EAAY,OAAO,eAAe,EAAE,wGAGvC,GACF,KACA,QAAC,iBACC,oBAAC,UAAO,QAASD,EAAS,kBAAM,KAChC,OAAC,UACC,QAAQ,YACR,QAAS,IAAM,CACbD,EAAM,UAAUK,CAAM,EACtBJ,EAAQ,CACV,EACD,4BAED,GACF,GACF,CAEJ,CAAC,EAEMc,EAAQhB",
6
+ "names": ["import_react", "import_ui", "import_material", "import_mobx_react", "import_jsx_runtime", "ChooseWalksDialog", "model", "onClose", "walkChoices", "names", "c", "picked", "setPicked", "l", "name", "_", "value", "key", "props", "selected", "params", "ChooseWalksDialog_default"]
7
+ }
@@ -0,0 +1,4 @@
1
+ import{a as ke,b as Ar,c as bt,d as wt}from"./chunk-S3X3QFQD.js";import{e as vr,f as wr,g as T,h as Pe,i as Le,j as te,k as Ne,l as re,n as Ge}from"./chunk-LGFKHSVJ.js";import{e as dt}from"./chunk-2H7GDQ3R.js";import{a as ht}from"./chunk-KWAXLUPQ.js";import"./chunk-E7J6SB5P.js";import{a as Cr,d as xt,e as yt,f as gt}from"./chunk-4T7DPQTR.js";import{a as q}from"./chunk-J4OLMLS5.js";import{a as St,b as vt}from"./chunk-SCMIJAAX.js";import"./chunk-7BKUWQE5.js";import{e as V,f as k,g as ee}from"./chunk-KULNKXPT.js";import{a as Sr,b as A}from"./chunk-FY3BTKY4.js";var dr=Sr((Ha,mr)=>{mr.exports=JBrowseExports["@jbrowse/core/util/installClearHoverOnSurfaceMove"]});var at=A(ke(),1),st=A(q(),1),Te=A(ht(),1),br=A(Ar(),1);function De(e){let r=/\.gbz\.db$/i;return r.test(e)?e.replace(r,".haplotype-index.db"):void 0}var At=A(ht(),1);function Ir(e){return yt(e)&&De(xt(e))?gt(e,r=>De(r)):void 0}function _r(e){return e instanceof Error&&(/\bHTTP 40[34]\b/.test(e.message)||e.code==="ENOENT")}async function Ct(e,r){let t=Ir(e);if(!t)return{};try{return await(0,At.openLocation)(t,r).stat(),{location:t}}catch(o){return _r(o)?{}:{unreadable:String(o)}}}var _t=A(ke(),1),Er=5e3,Or=50*2**20,Be=class extends Error{constructor(t){super(`this GAF is ${(t/2**20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`);this.name="UnindexedGafTooLargeError"}};function Rr(e,r){if(e.length<=r)return e;let t=e.length/r;return Array.from({length:r},(o,n)=>e[Math.floor(n*t)])}var It=(e,r)=>e.path.some(t=>r.has(t.name)),oe=class{constructor(r,t){this.file=r;this.tabix=t;this.whole=(0,_t.cachedSetup)({setup:async()=>{let{size:r}=await this.file.stat();if(r>Or)throw new Be(r);let t=await this.file.readFile(),o=new TextDecoder().decode(t[0]===31&&t[1]===139?await bt(t):t);return vt(o)}})}async readIndexed(r,t,o){let n=1/0,i=-1/0;for(let s of t){let p=Number(s);Number.isInteger(p)&&(n=Math.min(n,p),i=Math.max(i,p))}let a=[];return n<=i&&await r.getLines("{node}",n,i+1,{signal:o,lineCallback:s=>{let p=St(s);p&&It(p,t)&&a.push(p)}}),a}async readsOver(r,{signal:t}={}){let o=this.tabix?await this.readIndexed(this.tabix,r,t):(await this.whole({signal:t})).filter(n=>It(n,r));return{records:Rr(o,Er),total:o.length}}};var yr=A(ke(),1),gr=A(q(),1);var je=function(e,r){return je=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,o){t.__proto__=o}||function(t,o){for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])},je(e,r)};function Q(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");je(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}function Et(e,r,t,o){function n(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function s(c){try{f(o.next(c))}catch(l){a(l)}}function p(c){try{f(o.throw(c))}catch(l){a(l)}}function f(c){c.done?i(c.value):n(c.value).then(s,p)}f((o=o.apply(e,r||[])).next())})}function ne(e,r){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(f){return function(c){return p([f,c])}}function p(f){if(o)throw new TypeError("Generator is already executing.");for(;a&&(a=0,f[0]&&(t=0)),t;)try{if(o=1,n&&(i=f[0]&2?n.return:f[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,f[1])).done)return i;switch(n=0,i&&(f=[f[0]&2,i.value]),f[0]){case 0:case 1:i=f;break;case 4:return t.label++,{value:f[1],done:!1};case 5:t.label++,n=f[1],f=[0];continue;case 7:f=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(f[0]===6||f[0]===2)){t=0;continue}if(f[0]===3&&(!i||f[1]>i[0]&&f[1]<i[3])){t.label=f[1];break}if(f[0]===6&&t.label<i[1]){t.label=i[1],i=f;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(f);break}i[2]&&t.ops.pop(),t.trys.pop();continue}f=r.call(e,t)}catch(c){f=[6,c],n=0}finally{o=i=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}function D(e){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&e[r],o=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function $(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var o=t.call(e),n,i=[],a;try{for(;(r===void 0||r-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(t=o.return)&&t.call(o)}finally{if(a)throw a.error}}return i}function z(e,r,t){if(t||arguments.length===2)for(var o=0,n=r.length,i;o<n;o++)(i||!(o in r))&&(i||(i=Array.prototype.slice.call(r,0,o)),i[o]=r[o]);return e.concat(i||Array.prototype.slice.call(r))}function B(e){return this instanceof B?(this.v=e,this):new B(e)}function Ot(e,r,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=t.apply(e,r||[]),n,i=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(m){return function(y){return Promise.resolve(y).then(m,l)}}function s(m,y){o[m]&&(n[m]=function(d){return new Promise(function(h,g){i.push([m,d,h,g])>1||p(m,d)})},y&&(n[m]=y(n[m])))}function p(m,y){try{f(o[m](y))}catch(d){u(i[0][3],d)}}function f(m){m.value instanceof B?Promise.resolve(m.value.v).then(c,l):u(i[0][2],m)}function c(m){p("next",m)}function l(m){p("throw",m)}function u(m,y){m(y),i.shift(),i.length&&p(i[0][0],i[0][1])}}function Rt(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e[Symbol.asyncIterator],t;return r?r.call(e):(e=typeof D=="function"?D(e):e[Symbol.iterator](),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(i){t[i]=e[i]&&function(a){return new Promise(function(s,p){a=e[i](a),n(s,p,a.done,a.value)})}}function n(i,a,s,p){Promise.resolve(p).then(function(f){i({value:f,done:s})},a)}}function b(e){return typeof e=="function"}function Tt(e){var r=function(o){Error.call(o),o.stack=new Error().stack},t=e(r);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var ie=Tt(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
2
+ `+t.map(function(o,n){return n+1+") "+o.toString()}).join(`
3
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function $e(e,r){if(e){var t=e.indexOf(r);0<=t&&e.splice(t,1)}}var ae=(function(){function e(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var r,t,o,n,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var s=D(a),p=s.next();!p.done;p=s.next()){var f=p.value;f.remove(this)}}catch(d){r={error:d}}finally{try{p&&!p.done&&(t=s.return)&&t.call(s)}finally{if(r)throw r.error}}else a.remove(this);var c=this.initialTeardown;if(b(c))try{c()}catch(d){i=d instanceof ie?d.errors:[d]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var u=D(l),m=u.next();!m.done;m=u.next()){var y=m.value;try{Mt(y)}catch(d){i=i??[],d instanceof ie?i=z(z([],$(i)),$(d.errors)):i.push(d)}}}catch(d){o={error:d}}finally{try{m&&!m.done&&(n=u.return)&&n.call(u)}finally{if(o)throw o.error}}}if(i)throw new ie(i)}},e.prototype.add=function(r){var t;if(r&&r!==this)if(this.closed)Mt(r);else{if(r instanceof e){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(r)}},e.prototype._hasParent=function(r){var t=this._parentage;return t===r||Array.isArray(t)&&t.includes(r)},e.prototype._addParent=function(r){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(r),t):t?[t,r]:r},e.prototype._removeParent=function(r){var t=this._parentage;t===r?this._parentage=null:Array.isArray(t)&&$e(t,r)},e.prototype.remove=function(r){var t=this._finalizers;t&&$e(t,r),r instanceof e&&r._removeParent(this)},e.EMPTY=(function(){var r=new e;return r.closed=!0,r})(),e})();var No=ae.EMPTY;function se(e){return e instanceof ae||e&&"closed"in e&&b(e.remove)&&b(e.add)&&b(e.unsubscribe)}function Mt(e){b(e)?e():e.unsubscribe()}var R={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var H={setTimeout:function(e,r){for(var t=[],o=2;o<arguments.length;o++)t[o-2]=arguments[o];var n=H.delegate;return n?.setTimeout?n.setTimeout.apply(n,z([e,r],$(t))):setTimeout.apply(void 0,z([e,r],$(t)))},clearTimeout:function(e){var r=H.delegate;return(r?.clearTimeout||clearTimeout)(e)},delegate:void 0};function fe(e){H.setTimeout(function(){var r=R.onUnhandledError;if(r)r(e);else throw e})}function ze(){}var Ft=(function(){return He("C",void 0,void 0)})();function Pt(e){return He("E",void 0,e)}function Lt(e){return He("N",e,void 0)}function He(e,r,t){return{kind:e,value:r,error:t}}var j=null;function Nt(e){if(R.useDeprecatedSynchronousErrorHandling){var r=!j;if(r&&(j={errorThrown:!1,error:null}),e(),r){var t=j,o=t.errorThrown,n=t.error;if(j=null,o)throw n}}else e()}function Gt(e){R.useDeprecatedSynchronousErrorHandling&&j&&(j.errorThrown=!0,j.error=e)}var K=(function(e){Q(r,e);function r(t){var o=e.call(this)||this;return o.isStopped=!1,t?(o.destination=t,se(t)&&t.add(o)):o.destination=Pr,o}return r.create=function(t,o,n){return new ce(t,o,n)},r.prototype.next=function(t){this.isStopped?We(Lt(t),this):this._next(t)},r.prototype.error=function(t){this.isStopped?We(Pt(t),this):(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped?We(Ft,this):(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r})(ae);var Tr=Function.prototype.bind;function Ue(e,r){return Tr.call(e,r)}var Mr=(function(){function e(r){this.partialObserver=r}return e.prototype.next=function(r){var t=this.partialObserver;if(t.next)try{t.next(r)}catch(o){pe(o)}},e.prototype.error=function(r){var t=this.partialObserver;if(t.error)try{t.error(r)}catch(o){pe(o)}else pe(r)},e.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(t){pe(t)}},e})(),ce=(function(e){Q(r,e);function r(t,o,n){var i=e.call(this)||this,a;if(b(t)||!t)a={next:t??void 0,error:o??void 0,complete:n??void 0};else{var s;i&&R.useDeprecatedNextContext?(s=Object.create(t),s.unsubscribe=function(){return i.unsubscribe()},a={next:t.next&&Ue(t.next,s),error:t.error&&Ue(t.error,s),complete:t.complete&&Ue(t.complete,s)}):a=t}return i.destination=new Mr(a),i}return r})(K);function pe(e){R.useDeprecatedSynchronousErrorHandling?Gt(e):fe(e)}function Fr(e){throw e}function We(e,r){var t=R.onStoppedNotification;t&&H.setTimeout(function(){return t(e,r)})}var Pr={closed:!0,next:ze,error:Fr,complete:ze};var U=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function kt(e){return e}function Dt(e){return e.length===0?kt:e.length===1?e[0]:function(t){return e.reduce(function(o,n){return n(o)},t)}}var C=(function(){function e(r){r&&(this._subscribe=r)}return e.prototype.lift=function(r){var t=new e;return t.source=this,t.operator=r,t},e.prototype.subscribe=function(r,t,o){var n=this,i=Nr(r)?r:new ce(r,t,o);return Nt(function(){var a=n,s=a.operator,p=a.source;i.add(s?s.call(i,p):p?n._subscribe(i):n._trySubscribe(i))}),i},e.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(t){r.error(t)}},e.prototype.forEach=function(r,t){var o=this;return t=Bt(t),new t(function(n,i){var a=new ce({next:function(s){try{r(s)}catch(p){i(p),a.unsubscribe()}},error:i,complete:n});o.subscribe(a)})},e.prototype._subscribe=function(r){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(r)},e.prototype[U]=function(){return this},e.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return Dt(r)(this)},e.prototype.toPromise=function(r){var t=this;return r=Bt(r),new r(function(o,n){var i;t.subscribe(function(a){return i=a},function(a){return n(a)},function(){return o(i)})})},e.create=function(r){return new e(r)},e})();function Bt(e){var r;return(r=e??R.Promise)!==null&&r!==void 0?r:Promise}function Lr(e){return e&&b(e.next)&&b(e.error)&&b(e.complete)}function Nr(e){return e&&e instanceof K||Lr(e)&&se(e)}function Gr(e){return b(e?.lift)}function E(e){return function(r){if(Gr(r))return r.lift(function(t){try{return e(t,this)}catch(o){this.error(o)}});throw new TypeError("Unable to lift unknown Observable type")}}function P(e,r,t,o,n){return new kr(e,r,t,o,n)}var kr=(function(e){Q(r,e);function r(t,o,n,i,a,s){var p=e.call(this,t)||this;return p.onFinalize=a,p.shouldUnsubscribe=s,p._next=o?function(f){try{o(f)}catch(c){t.error(c)}}:e.prototype._next,p._error=i?function(f){try{i(f)}catch(c){t.error(c)}finally{this.unsubscribe()}}:e.prototype._error,p._complete=n?function(){try{n()}catch(f){t.error(f)}finally{this.unsubscribe()}}:e.prototype._complete,p}return r.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var o=this.closed;e.prototype.unsubscribe.call(this),!o&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},r})(K);var le=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function ue(e){return b(e?.then)}function me(e){return b(e[U])}function de(e){return Symbol.asyncIterator&&b(e?.[Symbol.asyncIterator])}function he(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Dr(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var xe=Dr();function ye(e){return b(e?.[xe])}function ge(e){return Ot(this,arguments,function(){var t,o,n,i;return ne(this,function(a){switch(a.label){case 0:t=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,B(t.read())];case 3:return o=a.sent(),n=o.value,i=o.done,i?[4,B(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,B(n)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function be(e){return b(e?.getReader)}function M(e){if(e instanceof C)return e;if(e!=null){if(me(e))return Br(e);if(le(e))return jr(e);if(ue(e))return $r(e);if(de(e))return jt(e);if(ye(e))return zr(e);if(be(e))return Hr(e)}throw he(e)}function Br(e){return new C(function(r){var t=e[U]();if(b(t.subscribe))return t.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function jr(e){return new C(function(r){for(var t=0;t<e.length&&!r.closed;t++)r.next(e[t]);r.complete()})}function $r(e){return new C(function(r){e.then(function(t){r.closed||(r.next(t),r.complete())},function(t){return r.error(t)}).then(null,fe)})}function zr(e){return new C(function(r){var t,o;try{for(var n=D(e),i=n.next();!i.done;i=n.next()){var a=i.value;if(r.next(a),r.closed)return}}catch(s){t={error:s}}finally{try{i&&!i.done&&(o=n.return)&&o.call(n)}finally{if(t)throw t.error}}r.complete()})}function jt(e){return new C(function(r){Ur(e,r).catch(function(t){return r.error(t)})})}function Hr(e){return jt(ge(e))}function Ur(e,r){var t,o,n,i;return Et(this,void 0,void 0,function(){var a,s;return ne(this,function(p){switch(p.label){case 0:p.trys.push([0,5,6,11]),t=Rt(e),p.label=1;case 1:return[4,t.next()];case 2:if(o=p.sent(),!!o.done)return[3,4];if(a=o.value,r.next(a),r.closed)return[2];p.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=p.sent(),n={error:s},[3,11];case 6:return p.trys.push([6,,9,10]),o&&!o.done&&(i=t.return)?[4,i.call(t)]:[3,8];case 7:p.sent(),p.label=8;case 8:return[3,10];case 9:if(n)throw n.error;return[7];case 10:return[7];case 11:return r.complete(),[2]}})})}function O(e,r,t,o,n){o===void 0&&(o=0),n===void 0&&(n=!1);var i=r.schedule(function(){t(),n?e.add(this.schedule(null,o)):this.unsubscribe()},o);if(e.add(i),!n)return i}function Se(e,r){return r===void 0&&(r=0),E(function(t,o){t.subscribe(P(o,function(n){return O(o,e,function(){return o.next(n)},r)},function(){return O(o,e,function(){return o.complete()},r)},function(n){return O(o,e,function(){return o.error(n)},r)}))})}function ve(e,r){return r===void 0&&(r=0),E(function(t,o){o.add(e.schedule(function(){return t.subscribe(o)},r))})}function $t(e,r){return M(e).pipe(ve(r),Se(r))}function zt(e,r){return M(e).pipe(ve(r),Se(r))}function Ht(e,r){return new C(function(t){var o=0;return r.schedule(function(){o===e.length?t.complete():(t.next(e[o++]),t.closed||this.schedule())})})}function Ut(e,r){return new C(function(t){var o;return O(t,r,function(){o=e[xe](),O(t,r,function(){var n,i,a;try{n=o.next(),i=n.value,a=n.done}catch(s){t.error(s);return}a?t.complete():t.next(i)},0,!0)}),function(){return b(o?.return)&&o.return()}})}function we(e,r){if(!e)throw new Error("Iterable cannot be null");return new C(function(t){O(t,r,function(){var o=e[Symbol.asyncIterator]();O(t,r,function(){o.next().then(function(n){n.done?t.complete():t.next(n.value)})},0,!0)})})}function Wt(e,r){return we(ge(e),r)}function Yt(e,r){if(e!=null){if(me(e))return $t(e,r);if(le(e))return Ht(e,r);if(ue(e))return zt(e,r);if(de(e))return we(e,r);if(ye(e))return Ut(e,r);if(be(e))return Wt(e,r)}throw he(e)}function Ye(e,r){return r?Yt(e,r):M(e)}function X(e,r){return E(function(t,o){var n=0;t.subscribe(P(o,function(i){o.next(e.call(r,i,n++))}))})}function qt(e,r,t,o,n,i,a,s){var p=[],f=0,c=0,l=!1,u=function(){l&&!p.length&&!f&&r.complete()},m=function(d){return f<o?y(d):p.push(d)},y=function(d){i&&r.next(d),f++;var h=!1;M(t(d,c++)).subscribe(P(r,function(g){n?.(g),i?m(g):r.next(g)},function(){h=!0},void 0,function(){if(h)try{f--;for(var g=function(){var x=p.shift();a?O(r,a,function(){return y(x)}):y(x)};p.length&&f<o;)g();u()}catch(x){r.error(x)}}))};return e.subscribe(P(r,m,function(){l=!0,u()})),function(){s?.()}}function W(e,r,t){return t===void 0&&(t=1/0),b(r)?W(function(o,n){return X(function(i,a){return r(o,i,n,a)})(M(e(o,n)))},t):(typeof r=="number"&&(t=r),E(function(o,n){return qt(o,n,e,t)}))}function Vt(e,r,t,o,n){return function(i,a){var s=t,p=r,f=0;i.subscribe(P(a,function(c){var l=f++;p=s?e(p,c,l):(s=!0,c),o&&a.next(p)},n&&(function(){s&&a.next(p),a.complete()})))}}function Qt(e,r){return E(Vt(e,r,arguments.length>=2,!1,!0))}var Wr=function(e,r){return e.push(r),e};function Ae(){return E(function(e,r){Qt(Wr,[])(e).subscribe(r)})}function Kt(e){let r=[],t=0,o;for(let n=0,i=e.length;n<i;n++){let a=e.charCodeAt(n);if(a>=48&&a<=57)t=t*10+a-48;else if(a===58)o=t,t=0;else{let s=e[n];s==="M"||s==="="||s==="X"?r.push({own:o===void 0?t:o,mate:t,op:"M"}):s==="I"?r.push({own:0,mate:t,op:s}):(s==="D"||s==="N")&&r.push({own:t,mate:0,op:s}),o=void 0,t=0}}return r}function Qe(e){let r="";for(let{own:t,mate:o,op:n}of Kt(e))r+=n==="M"?t===0?`${o}I`:o===0?`${t}D`:`${t}M`:`${n==="I"?o:t}${n}`;return r}var qe=2**28-1;function Ve(e,r,t){for(let o=r;o>0;o-=qe)e.push((Math.min(o,qe)<<4|t)>>>0)}function Yr(e,r,t){if(r===t)Ve(e,r,0);else{let o=Math.ceil(Math.max(r,t)/qe);for(let n=0;n<o;n++){let i=Math.floor(r*(n+1)/o)-Math.floor(r*n/o),a=Math.floor(t*(n+1)/o)-Math.floor(t*n/o);e.push((i<<4|9)>>>0,(a<<4|9)>>>0)}}}function Ke(e){let r=[];for(let{own:t,mate:o,op:n}of Kt(e))n==="M"?Yr(r,t,o):n==="I"?Ve(r,o,1):Ve(r,t,n==="N"?3:2);return Uint32Array.from(r)}function qr(e){return e>=48&&e<=57}function Vr(e){return e!==void 0&&/[A-Za-z]/.test(e)}function Xt(e,r){let t=r;for(;t<e.length&&Vr(e[t]);)t++;return t}function Zt(e,r){let t=r,o=0;for(;t<e.length&&qr(e.charCodeAt(t));)o=o*10+(e.charCodeAt(t)-48),t++;return{value:o,next:t}}function or(e,r){let t=0;for(;t<e.length;){let o=e[t];if(o===":"){let{value:n,next:i}=Zt(e,t+1);r(":",n,n,t+1,i),t=i}else if(o==="="){let n=Xt(e,t+1),i=n-t-1;r("=",i,i,t+1,n),t=n}else if(o==="*")r("*",1,1,t+1,Math.min(t+3,e.length)),t+=3;else if(o==="+"||o==="-"){let n=Xt(e,t+1),i=n-t-1;r(o,o==="-"?i:0,o==="+"?i:0,t+1,n),t=n}else if(o==="~"){let{value:n,next:i}=Zt(e,t+3),a=Math.min(i+2,e.length);r("~",n,0,t+1,a),t=a}else t++}}function Xe(e,r,t,o){let n=t??Number.NEGATIVE_INFINITY,i=o??Number.POSITIVE_INFINITY,a=0;or(e,(s,p,f,c,l)=>{if(s==="*")a>=n&&a<i&&r(88,a,1,e[c+1]??"",-1,0,0);else if(s==="+"){if(a>=n&&a<=i){let u=e.slice(c,l);r(73,a,f,u,-1,0,f)}}else(s==="-"||s==="~")&&a<i&&a+p>n&&r(s==="-"?68:78,a,p,"",-1,0,0);a+=p})}function nr(e,r,t,o){let n=0,i=0,a=[],s=t&&r;for(let p=0,f=e.length;p<f;p++){let c=e[p],l=c>>>4,u=c&15;if(u===0||u===7){if(s)for(let m=0;m<l;m++)(r.charCodeAt(i+m)|32)!==(t.charCodeAt(n+m)|32)&&a.push({start:n+m,type:"mismatch",base:r[i+m],altbase:t[n+m],length:1});i+=l,n+=l}else if(u===1)a.push({start:n,type:"insertion",insertlen:l,insertedBases:r?.slice(i,i+l),length:0}),i+=l;else if(u===2)a.push({start:n,type:"deletion",length:l}),n+=l;else if(u===3)a.push({start:n,type:"skip",length:l}),n+=l;else if(u===8){for(let m=0;m<l;m++)a.push({start:n+m,type:"mismatch",base:r?.[i+m]||"X",qual:o?.[i+m],length:1});i+=l,n+=l}else u===5?a.push({start:n,type:"hardclip",cliplen:l,length:1}):u===4&&(a.push({start:n,type:"softclip",cliplen:l,length:1}),i+=l)}return a}function ir(e,r,t,o,n){if(!r)return[];let i=[],a=r.length,s=o.length,p=n!==void 0,f=t.length,c=!1;for(let x=0;x<f;x++)if(t[x].type==="skip"){c=!0;break}let l=0,u=0,m=0,y=0,d=0,h=0,g=e.length;for(;h<g;){let x=e.charCodeAt(h);if(x>=48&&x<=57){let S=0;for(;h<g;){let v=e.charCodeAt(h);if(v>=48&&v<=57)S=S*10+(v-48),h++;else break}l+=S}else if(x===94)for(h++;h<g&&e.charCodeAt(h)>=65;)h++,l++;else if(x>=65){let S=e[h];if(h++,c&&f>0)for(let _=d;_<f;_++){let F=t[_];F.type==="skip"&&l>=F.start&&(l+=F.length,d=_+1)}let v=m,I=y;for(let _=u;_<a&&I<=l;_++,u=_){let F=r[_],G=F>>>4,w=F&15;w===4||w===1?v+=G:w===2||w===6||w===3?I+=G:w!==5&&(v+=G,I+=G)}m=v,y=I;let N=v-(I-l),J=N<s?o[N]:"X";i.push({start:l,base:J,qual:p?n[N]:void 0,altbase:S,length:1,type:"mismatch"}),l++}else h++}return i}var ar={77:0,73:1,68:2,78:3,83:4,72:5,80:6,61:7,88:8};function sr(e=""){let r=0,t=[];for(let o=0,n=e.length;o<n;o++){let i=e.charCodeAt(o);if(i>=48&&i<=57)r=r*10+(i-48);else{let a=ar[i];t.push(r<<4|a),r=0}}return t}function et(e=""){let r=0;for(let i=0,a=e.length;i<a;i++){let s=e.charCodeAt(i);(s<48||s>57)&&r++}let t=new Uint32Array(r),o=0,n=0;for(let i=0,a=e.length;i<a;i++){let s=e.charCodeAt(i);s>=48&&s<=57?o=o*10+(s-48):(t[n++]=o<<4|ar[s],o=0)}return t}function Oe(e,r,t,o,n){let i=sr(e),a=e?nr(i,t,o,n):[];return r&&t?a.concat(ir(r,i,a,t,n)):a}var Xr=397,Zr=387,Jr=385;function fr(e){return(1<<e&Xr)!==0}function pr(e){return(1<<e&Zr)!==0}function cr(e){return(1<<e&Jr)!==0}function tt(e,r,t,o,n,i,a){let s=n===-1?-1:1,p=r,f=n===-1?o:t,c=[],l=1/0,u=-1/0,m=1/0,y=-1/0,d=(h,g)=>{m=Math.min(m,h,g),y=Math.max(y,h,g)};for(let h=0;h<e.length;h++){let g=e[h],x=g>>>4,S=g&15,v=S===9,I=v||fr(S)?x:0,N=v?e[++h]>>>4:pr(S)?x:0,J=p+I,_=f+N*s,F=p,G=J;if(G>=i&&F<=a)if(I>0){let w=Math.max(F,i),Y=Math.min(G,a);if(Y>w)if(l=Math.min(l,w),u=Math.max(u,Y),v){let ct=N/x,lt=Y-w,ut=Math.round(lt*ct),mt=Math.round(f+(w-p)*ct*s);c.push(lt<<4|9,ut<<4|9),d(mt,mt+ut*s)}else c.push(Y-w<<4|S),cr(S)?d(f+(w-p)*s,f+(Y-p)*s):d(f,f)}else N>0&&(v?c.push(g,e[h]):c.push(g),l=Math.min(l,p),u=Math.max(u,p),d(f,_));if(p=J,f=_,p>a)break}if(c.length!==0)return{start:l,end:u,mateStart:m,mateEnd:y,cigar:Uint32Array.from(c)}}function eo(e){return e===1||e===2||e===3}function rt(e,r,t,o,n,i){let a=n===-1?-1:1,s=[],p=r,f=n===-1?o:t,c,l=!1,u=()=>{c!==void 0&&l&&c.qHi>c.qLo&&s.push({start:c.qLo,end:c.qHi,mateStart:c.tLo,mateEnd:c.tHi,cigar:Uint32Array.from(c.ops)}),c=void 0,l=!1};for(let m=0;m<e.length;m++){let y=e[m],d=y>>>4,h=y&15,g=h===9,x=g?e[++m]:void 0,S=g||fr(h)?d:0,v=x!==void 0?x>>>4:pr(h)?d:0,I=f+v*a;eo(h)&&d>=i?u():(S>0||v>0)&&(c===void 0&&(c={qLo:p,qHi:p,tLo:f,tHi:f,ops:[]}),c.qHi=p+S,c.tLo=Math.min(c.tLo,f,I),c.tHi=Math.max(c.tHi,f,I),c.ops.push(y),x!==void 0&&c.ops.push(x),l=l||g||cr(h)),p+=S,f=I}return u(),s}function lr(e){let r=e.get("CIGAR");return typeof r=="string"?r:void 0}function ur(e){let r=e.get("coarseCigar");return typeof r=="string"?r:void 0}function ot(e){let r=lr(e),t=r===void 0?ur(e):void 0;return r!==void 0?et(r):t!==void 0?Ke(t):void 0}var to=A(q(),1),ro=A(dr(),1);var oo=A(q(),1);var no=A(Cr(),1);var hr=A(q(),1),L=class extends hr.SimpleFeature{get(r){return r==="mismatches"?Oe(this.walkableCigar):r==="clipLengthAtStartOfRead"?this.clipLengthAtStartOfRead:r==="name"?super.get("name")??this.mate?.refName:super.get(r)}get mate(){return super.get("mate")}get walkableCigar(){let r=super.get("CIGAR"),t=super.get("coarseCigar");return typeof r=="string"?r:typeof t=="string"?Qe(t):void 0}get clipLengthAtStartOfRead(){return this.mate?.start??0}forEachMismatch(r,t){let o=this.get("start"),n=t?.start===void 0?void 0:t.start-o,i=t?.end===void 0?void 0:t.end-o,a=this.get("cs");if(a)Xe(a,r,n,i);else{let s=n??Number.NEGATIVE_INFINITY,p=i??Number.POSITIVE_INFINITY;for(let f of Oe(this.walkableCigar))(f.type==="deletion"||f.type==="skip"?f.start<p&&f.start+f.length>s:f.start>=s&&f.start<=p)&&(f.type==="mismatch"?r(88,f.start,f.length,f.base,f.qual??-1,0,0):f.type==="insertion"?r(73,f.start,f.length,f.insertedBases??"",-1,0,f.insertlen):f.type==="deletion"?r(68,f.start,f.length,"",-1,0,0):f.type==="skip"&&r(78,f.start,f.length,"",-1,0,0))}}};var io=["CIGAR","cs","coarseCigar","cg","cr"];function ao(e){return typeof e=="object"&&e!==null&&"refName"in e&&"start"in e&&"end"in e&&typeof e.refName=="string"&&typeof e.start=="number"&&typeof e.end=="number"}function so(e){let r=e.get("mate");return ao(r)?r:void 0}function fo(e,r,t,o){let n=Math.max(e.start,o.start),i=Math.min(e.end,o.end),a=(r.end-r.start)/Math.max(e.end-e.start,1),s=c=>t===-1?r.end-(c-e.start)*a:r.start+(c-e.start)*a,p=Math.round(s(n)),f=Math.round(s(i));return i>n?{start:n,end:i,mateStart:Math.min(p,f),mateEnd:Math.max(p,f)}:void 0}function po(e,r,t,o,n){let i={start:e.get("start"),end:e.get("end")},a=e.get("strand")===-1?-1:1,s=i.start>=t.start&&i.end<=t.end,p=s&&o===void 0&&!n?void 0:ot(e);if(p===void 0){let f=s?{...i,mateStart:r.start,mateEnd:r.end}:fo(i,r,a,t);return f===void 0?[]:[f]}else return(o===void 0?[{...i,mateStart:r.start,mateEnd:r.end,cigar:p}]:rt(p,i.start,r.start,r.end,a,o)).flatMap(c=>{let l=tt(c.cigar,c.start,c.mateStart,c.mateEnd,a,t.start,t.end);return l===void 0?[]:[l]})}function co(e,r,t,o,n,i){let a=`:${o.start}-${o.end}${n}`,s=e.toJSON(),p={...s,uniqueId:`${e.id()}${a}`,start:t.start,end:t.end,mate:{...r,start:t.mateStart,end:t.mateEnd}};s.syntenyId!==void 0&&(p.syntenyId=`${String(s.syntenyId)}${a}`);for(let f of io)delete p[f];return i&&t.cigar&&(p.alignmentOps=t.cigar),new L(p)}function xr(e,r,t,o=!1){let n=so(e);if(n===void 0)return[e];{let i=po(e,n,r,t,o);return i.map((a,s)=>co(e,n,a,r,i.length>1?`/${s}`:"",o))}}var Re=class extends yr.BaseFeatureDataAdapter{constructor(){super(...arguments);this.recordsAreAlignments=!0}static{this.capabilities=["getFeatures","getRefNames"]}async hasDataForRefName(){return!0}getFeaturesInMultipleRegions(t,o={}){let{clipToRegion:n,splitAtGapBp:i,keepAlignment:a,...s}=o,p=n&&this.recordsAreAlignments,f=(0,gr.createStatusFanOut)(s.statusCallback);return Ye(t).pipe(W((c,l)=>this.getFeatures(c,{...s,statusCallback:f()}).pipe(W(u=>p?xr(u,u.get("assemblyName")===c.assemblyName?c:{start:u.get("start"),end:u.get("end")},i,a):[u]),Ae(),X(u=>({index:l,features:u})))),Ae(),W(c=>c.sort((l,u)=>l.index-u.index).flatMap(l=>l.features)))}};var Me=class extends Error{constructor(t){super(t===void 0?"no haplotype index is set, so the walks cannot be named; build one with gbz-haplotype-index (cargo install gbz-haplotype-index) and set it as haplotypeIndexLocation":`the haplotype index beside the graph database could not be checked (${t}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`);this.name="NoHaplotypeIndexError"}},ft=class extends Error{constructor(t){super(`a pair query names both lanes: queryAssemblyName ${t} came without a targetAssemblyName`);this.name="PairTargetError"}},Fe=class extends Error{constructor(t,o){super(`the graph is cut on its reference, ${o}; a window on ${t} has no reference coordinates to cut at. Open the graph from a ${o} view, and find this haplotype's lane there`);this.name="HaplotypeWindowError"}};function nt(e,r){let t=T(r);return e[t]??e[r.sample]??t}function lo(e,r){return`${T(e)}#${e.contig}@${r.start.node}.${r.start.offset}`}function uo({alignment:e,assemblyName:r,refName:t,lane:o}){let{refStart:n,refEnd:i,strand:a,cigar:s}=e;if(!(!e.resolved||i<=n)){let{name:p,hapStart:f,hapEnd:c}=e,l=lo(p,e),u={uniqueId:l,assemblyName:r,refName:t,start:n,end:i,type:"match",strand:a==="-"?-1:1,CIGAR:s,syntenyId:l,mate:{refName:p.contig,start:f,end:c,assemblyName:o}};return new L(u)}}function mo({pair:e,lane:r,mateLane:t}){let o=`${T(e.target)}#${e.target.contig}:${e.targetStart}-${e.targetEnd}|${T(e.query)}#${e.query.contig}:${e.queryStart}-${e.queryEnd}`;return new L({uniqueId:o,assemblyName:r,refName:e.target.contig,start:e.targetStart,end:e.targetEnd,type:"match",strand:e.strand==="-"?-1:1,CIGAR:e.cigar,syntenyId:o,identity:e.matches/Math.max(e.columns,1),numMatches:e.matches,blockLen:e.columns,mate:{refName:e.query.contig,start:e.queryStart,end:e.queryEnd,assemblyName:t}})}function ho(e,r,t){let o=re(e,r,t);return o&&(o.message+="; the track's Graph display draws every haplotype's overview at any size"),o}var it=e=>!("uri"in e)||e.uri!=="",pt=class extends Re{constructor(){super(...arguments);this.graph=(0,at.cachedSetup)({label:"Opening pangenome database",setup:async()=>{let t=this.getConf("gbzDbLocation"),o=this.getConf("haplotypeIndexLocation"),n=it(o)?{location:o}:await Ct(t,this.pluginManager),i=n.location,a=await dt.open({source:(0,Te.openLocation)(t,this.pluginManager),haplotypeIndex:i?(0,Te.openLocation)(i,this.pluginManager):void 0}),s=this.getConf("assemblyNames")[0];if(s===void 0)throw new Error("GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");let p=await Le(a),f=te({configured:this.getConf("referenceSample"),anchorPrefix:k(this,s),referenceSamples:p});return{db:a,anchor:s,referenceSample:f,referenceSamples:p,unreadableIndex:n.unreadable}}});this.gaf=(0,at.cachedSetup)({label:"Opening reads",setup:async()=>{let t=this.getConf("readsLocation"),o=this.getConf(["readsIndex","location"]);return it(t)?new oe((0,Te.openLocation)(t,this.pluginManager),it(o)?wt(this,["readsLocation"],["readsIndex"]):void 0):void 0}})}async referenceQuery(t,o){let{db:n,referenceSample:i}=await this.graph(o);return Ne(n,i,t)}async getHaplotypes(t={}){let{db:o,referenceSamples:n}=await this.graph(t),i=new Map;for(let a of await o.paths()){let s=T(a.name),p=i.get(s);p?p.contigs.includes(a.name.contig)||p.contigs.push(a.name.contig):i.set(s,{prefix:s,sample:a.name.sample,haplotype:a.name.haplotype,contigs:[a.name.contig],isReference:n.includes(a.name.sample)})}return[...i.values()]}async getHeader(t={}){let{anchor:o,referenceSample:n,referenceSamples:i}=await this.graph(t),a=ee(this),s=[];for(let p of await this.getHaplotypes(t))p.sample!==n&&s.push({name:nt(a,p),label:p.prefix,group:p.sample});return{hasCoarseTier:!1,anchorAssemblyName:o,referenceSample:n,referenceSamples:i,lanes:s}}async getRefNames(t={}){let{db:o,anchor:n,referenceSample:i}=await this.graph(t),{assemblyName:a}=t,s=a===n?void 0:k(this,a),p=(await o.paths()).filter(f=>a===n?f.isIndexed&&f.name.sample===i:V(T(f.name),s)).map(f=>f.name.contig);return[...new Set(p)]}keepPredicate(t,o){let n=t===void 0||t.length===0?void 0:t.map(i=>k(this,i));return n===void 0&&o===void 0?void 0:i=>Pe(i,n)&&(o===void 0||V(T(i),o))}async getSubgraph(t,o={}){let{db:n,anchor:i,unreadableIndex:a}=await this.graph(),{assemblyName:s,refName:p,start:f,end:c}=t;if(s!==i)throw new Fe(s,i);let l=await this.referenceQuery(p,{}),u=this.keepPredicate(o.haplotypes);if(u!==void 0&&!n.hasHaplotypeIndex)throw new Me(a);return Ge(n,l,f,c,{context:this.getConf("context"),snarls:o.snarls??this.getConf("subgraphSnarls"),limit:this.getConf("nodeLimit"),signal:o.signal,keep:u})}async getOverview(t,o){let{db:n,anchor:i,referenceSample:a}=await this.graph(),{assemblyName:s,refName:p,start:f,end:c}=t;if(s!==i)throw new Fe(s,i);let l=await this.referenceQuery(p,{}),u=l?await n.haplotypeOverview({path:l,start:f,end:c,bpPerPixel:o.bpPerPx}):void 0;if(!u)return;let m=ee(this),y=u.haplotypes.map(h=>T(h)),d=new Set;for(let h of o.haplotypes??[]){let g=k(this,h);y.forEach((x,S)=>{V(x,g)&&d.add(S)})}return{level:u.level,bin:u.bin,rows:u.haplotypes.map(h=>nt(m,h)),pinned:[...d],reference:u.haplotypes.flatMap((h,g)=>h.sample===a?[g]:[]),bins:u.bins,cells:u.cells}}async getReads(t,o={}){let n=await this.gaf(o);return n?n.readsOver(new Set(t),o):{records:[],total:0}}async laneHaplotypes(t,o){let n=k(this,t);return(await this.getHaplotypes(o)).filter(i=>V(i.prefix,n))}async anchorFeatures(t,o){let{db:n}=await this.graph(o),{assemblyName:i,refName:a,start:s,end:p}=t,f=k(this,o.targetAssemblyName),c=ee(this),l=this.keepPredicate(o.haplotypes,f),u=await this.referenceQuery(a,o),m=this.getConf("nodeLimit");return(u?await(0,st.updateStatus)(`Reading graph ${a}:${s.toLocaleString()}-${p.toLocaleString()}`,o.statusCallback,()=>n.getAlignments({path:u,start:s,end:p,context:this.getConf("context"),haplotypes:"all",limit:m,signal:o.signal,keep:l}).catch(d=>{throw ho(d,m,p-s)??d})):[]).flatMap(d=>{let h=d.resolved?uo({alignment:d,assemblyName:i,refName:a,lane:nt(c,d.name)}):void 0;return h===void 0?[]:[h]})}async pairFeatures(t,o,n){let{targetAssemblyName:i}=n;if(i===void 0)throw new ft(o);let{db:a}=await this.graph(n),{refName:s,start:p,end:f}=t,c=await this.laneHaplotypes(o,n),l=await this.laneHaplotypes(i,n),u=[...c,...l],m=await this.referenceQuery(s,n),y=this.getConf("nodeLimit"),d=g=>a.getSubgraphs({path:g,start:p,end:f,context:this.getConf("context"),snarls:this.getConf("subgraphSnarls"),haplotypes:"all",limit:y,signal:n.signal,keep:x=>u.some(S=>S.sample===x.sample&&S.haplotype===x.haplotype)}).catch(x=>{throw re(x,y,f-p)??x});return(m&&c.length>0&&l.length>0?await(0,st.updateStatus)(`Reading ${o} against ${i}`,n.statusCallback,()=>d(m)):[]).flatMap(g=>c.flatMap(x=>l.flatMap(S=>g.pairAlignments({target:x,query:S,bases:!1}).map(v=>mo({pair:v,lane:o,mateLane:i})))))}getFeatures(t,o={}){return(0,br.ObservableCreate)(async n=>{let{db:i,anchor:a,unreadableIndex:s}=await this.graph(o);if(!i.hasHaplotypeIndex)throw new Me(s);if(t.assemblyName===a){let p=o.queryAssemblyName===void 0?await this.anchorFeatures(t,o):await this.pairFeatures(t,o.queryAssemblyName,o);for(let f of p)n.next(f)}n.complete()},o.signal)}};export{Fe as HaplotypeWindowError,Me as NoHaplotypeIndexError,vr as NoReferenceSampleError,wr as NodeLimitError,ft as PairTargetError,pt as default,uo as fragmentFeature,T as haplotypePrefix,nt as laneAssemblyName,re as nodeLimitError,mo as pairFeature,te as resolveReferenceSample};
4
+ //# sourceMappingURL=GbzBaseSyntenyAdapter-CKKVHC2R.js.map