jbrowse-plugin-graphgenomeviewer 6.24.1 → 6.25.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 (36) hide show
  1. package/README.md +22 -19
  2. package/dist/chunks/AddTrackWorkflow-ZKAN5JYJ.js +2 -0
  3. package/dist/chunks/AddTrackWorkflow-ZKAN5JYJ.js.map +7 -0
  4. package/dist/chunks/{GbzBaseSyntenyAdapter-KX7DZETX.js → GbzBaseSyntenyAdapter-RLEI3RDF.js} +2 -2
  5. package/dist/chunks/{MinigraphBubbleAdapter-T7I4AEYT.js → MinigraphBubbleAdapter-OEOJKDBZ.js} +2 -2
  6. package/dist/chunks/{RgfaTabixAdapter-QCQRXP4Z.js → RgfaTabixAdapter-Q2URYHKT.js} +2 -2
  7. package/dist/chunks/{WalkTabixSyntenyAdapter-H7MKUBJ6.js → WalkTabixSyntenyAdapter-RXTCCCDB.js} +2 -2
  8. package/dist/chunks/chunk-2I4VPDLZ.js +2 -0
  9. package/dist/chunks/chunk-2I4VPDLZ.js.map +7 -0
  10. package/dist/chunks/{chunk-ROD6PMOR.js → chunk-AHE4Y2TX.js} +2 -2
  11. package/dist/chunks/{chunk-PNHULAAZ.js → chunk-O5GO45MS.js} +2 -2
  12. package/dist/chunks/{chunk-KX6CASVE.js → chunk-W7UGHWWS.js} +2 -2
  13. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +5 -5
  14. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +3 -3
  15. package/package.json +1 -1
  16. package/src/GraphAddTrackWorkflow/AddTrackWorkflow.tsx +25 -6
  17. package/src/GraphAddTrackWorkflow/buildTrackConfig.test.ts +74 -0
  18. package/src/GraphAddTrackWorkflow/buildTrackConfig.ts +40 -2
  19. package/src/GraphAddTrackWorkflow/graphManifest.test.ts +143 -0
  20. package/src/GraphAddTrackWorkflow/graphManifest.ts +101 -0
  21. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +35 -9
  22. package/src/LinearGraphDisplay/model.ts +16 -5
  23. package/src/RgfaTabixAdapter/RgfaTabixAdapter.test.ts +14 -3
  24. package/src/RgfaTabixAdapter/configSchema.ts +16 -6
  25. package/src/version.ts +1 -1
  26. package/dist/chunks/AddTrackWorkflow-HNHYSVGK.js +0 -2
  27. package/dist/chunks/AddTrackWorkflow-HNHYSVGK.js.map +0 -7
  28. package/dist/chunks/chunk-NXMRRZJI.js +0 -2
  29. package/dist/chunks/chunk-NXMRRZJI.js.map +0 -7
  30. /package/dist/chunks/{GbzBaseSyntenyAdapter-KX7DZETX.js.map → GbzBaseSyntenyAdapter-RLEI3RDF.js.map} +0 -0
  31. /package/dist/chunks/{MinigraphBubbleAdapter-T7I4AEYT.js.map → MinigraphBubbleAdapter-OEOJKDBZ.js.map} +0 -0
  32. /package/dist/chunks/{RgfaTabixAdapter-QCQRXP4Z.js.map → RgfaTabixAdapter-Q2URYHKT.js.map} +0 -0
  33. /package/dist/chunks/{WalkTabixSyntenyAdapter-H7MKUBJ6.js.map → WalkTabixSyntenyAdapter-RXTCCCDB.js.map} +0 -0
  34. /package/dist/chunks/{chunk-ROD6PMOR.js.map → chunk-AHE4Y2TX.js.map} +0 -0
  35. /package/dist/chunks/{chunk-PNHULAAZ.js.map → chunk-O5GO45MS.js.map} +0 -0
  36. /package/dist/chunks/{chunk-KX6CASVE.js.map → chunk-W7UGHWWS.js.map} +0 -0
package/README.md CHANGED
@@ -33,19 +33,18 @@ Build the graph with [minigraph](https://github.com/lh3/minigraph) (rGFA),
33
33
  [Minigraph-Cactus](https://github.com/ComparativeGenomicsToolkit/cactus/blob/master/doc/pangenome.md)
34
34
  (GFA and GBZ), then index what you have:
35
35
 
36
- - **rGFA** — run
37
- [`build_pangenome_graph.sh`](https://github.com/GMOD/jbrowse-components/blob/main/scripts/build_pangenome_graph.sh).
38
- It calls [gfa-to-tabix](https://github.com/GMOD/gfa-to-tabix) and
39
- [gfatools](https://github.com/lh3/gfatools) and writes `.segs.bed.gz`,
40
- `.links.bed.gz`, `.bubbles.bed.gz`, a coarse tier and a track config. Adapter:
41
- `RgfaTabixAdapter`
42
- - **Plain GFA** (pggb, odgi, vg, base-level Minigraph-Cactus) — the same script,
43
- with `--reference`, `--assembly` and `--snarls`, a VCF from `vg deconstruct`
44
- or `pggb -V`
45
- - **Alleles, with a CIGAR each** — `gfa-to-tabix alleles <prefix>` (0.7.0+)
46
- reads a `--layout contig` segment and link index (`build_pangenome_graph.sh`
47
- writes one as `.contig.*`) and writes `.alleles.bed.gz`, which an alignments
48
- track draws
36
+ - **rGFA** — `gfa-to-tabix build graph.rgfa.gz -o out` (0.11.0+). It calls
37
+ [gfatools](https://github.com/lh3/gfatools) for the bubbles and writes
38
+ `.segs.bed.gz`, `.links.bed.gz`, `.bubbles.bed.gz`, `.alleles.bed.gz`, a
39
+ coarse tier, a `.graph.json` manifest and a track config. Opening
40
+ `out.segs.bed.gz` in **Add pangenome graph track** reads the manifest.
41
+ Adapter: `RgfaTabixAdapter`
42
+ - **Plain GFA** (pggb, odgi, vg, base-level Minigraph-Cactus) — the same
43
+ command, with `--reference`, `--assembly` and `--snarls`, a VCF from
44
+ `vg deconstruct -a` or `pggb -V`
45
+ - **Alleles, with a CIGAR each** — `build` writes `.alleles.bed.gz`, which an
46
+ alignments track draws; `gfa-to-tabix alleles <prefix>` makes one from a
47
+ `--layout contig` index
49
48
  - **Haplotype walks, as tabix files** — `vg convert -f graph.gbz`, then
50
49
  `gfa-to-tabix --walks`. Adapter: `WalkTabixSyntenyAdapter`, or
51
50
  `RgfaTabixAdapter` with `walksUri`
@@ -54,8 +53,8 @@ Build the graph with [minigraph](https://github.com/lh3/minigraph) (rGFA),
54
53
  `GbzBaseSyntenyAdapter`
55
54
  - **Reads** — `vg giraffe -o gaf`, `vg gamsort -G`, `bgzip`, `tabix` make a
56
55
  `.gaf.gz` for a gbz-base adapter's `reads`
57
- - **Minigraph paths per assembly** — `minigraph -cxasm --call`, which
58
- `build_minigraph_paths.sh` runs per sample
56
+ - **Minigraph paths per assembly** — `minigraph -cxasm --call` per sample, then
57
+ `gfa-to-tabix paths` (0.9.0+) writes one row per bubble and sample
59
58
 
60
59
  [vg](https://github.com/vgteam/vg) 1.69.0 or later covers the GBZ steps.
61
60
 
@@ -138,6 +137,10 @@ Needs JBrowse 5.0.0-beta.11 or later.
138
137
  (`.gbz.db`) as a `GraphTrack`. It finds the links and indexes beside the url,
139
138
  which a presigned url's signature doesn't cover; spell out each location in a
140
139
  config instead
140
+ - Open track's **Add pangenome graph track** workflow also reads
141
+ `<prefix>.graph.json` beside a `<prefix>.segs.bed.gz` (written by
142
+ `gfa-to-tabix build`) for the coarse tier and the reference's PanSN sample;
143
+ without one, the track has no coarse tier
141
144
  - A hand-written track needs only the adapter:
142
145
 
143
146
  ```json
@@ -150,8 +153,8 @@ Needs JBrowse 5.0.0-beta.11 or later.
150
153
  "type": "RgfaTabixAdapter",
151
154
  "uri": "https://example.com/hprc",
152
155
  "coarse": {
153
- "uri": "https://example.com/hprc.tier10000",
154
- "aboveBpPerPx": 1000
156
+ "uri": "https://example.com/hprc.fold10000",
157
+ "foldBelowBp": 10000
155
158
  }
156
159
  }
157
160
  }
@@ -160,8 +163,8 @@ Needs JBrowse 5.0.0-beta.11 or later.
160
163
  - The track menu picks layout, colour and highlighted haplotypes, and switches
161
164
  to the segments lane or, for gbz-base and walk-indexed graphs, the haplotype
162
165
  lanes
163
- - Cuts the window plus a window each side, up to 5 Mb; past `aboveBpPerPx`, the
164
- `coarse` tier (`build_fold_tier.sh` in jbrowse-components)
166
+ - Cuts the window plus a window each side, up to 5 Mb; past `aboveBpPerPx`
167
+ (default `foldBelowBp / 10`), the `coarse` tier (`gfa-to-tabix fold`)
165
168
  - Past the cut (5 Mb, or a gbz-base adapter's `nodeLimit`) the track asks you to
166
169
  zoom in. For a population view of a wide window, add the graph's VCF as a
167
170
  variant track (`vg deconstruct` makes one from a GBZ)
@@ -0,0 +1,2 @@
1
+ import{a as H,b as j,c as O,d as z,g as J}from"./chunk-2I4VPDLZ.js";import{d as w,e as R}from"./chunk-NDRLCGPC.js";import"./chunk-R3TRNF7N.js";import"./chunk-7WIBGKBU.js";import"./chunk-OGQ6OQDN.js";import{b as T,h as G,j as S,m as A}from"./chunk-TENPGIPX.js";import{g as r}from"./chunk-6OPB7FOJ.js";import{A as _,B as W,E as b,a as v,e as x,f as p,n as E,r as B,s as I,t as P,z as N}from"./chunk-ECD5B2ZM.js";import{b as t,c as g,d as M}from"./chunk-JMBDTNUR.js";var s=JBrowseExports["@jbrowse/core/util/tss-react"],$=o=>s!=null&&o in Object(s)?s[o]:Object.assign(function(){throw new Error("This JBrowse does not provide '"+o+"' from '@jbrowse/core/util/tss-react' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse")},{jbrowseHostMissing:o});var D=$("makeStyles"),oe=s&&s.__esModule?s.default:s;var ee=D()(o=>({paper:{margin:o.spacing(),padding:o.spacing()},field:{marginTop:o.spacing(2)},submit:{marginTop:25,marginBottom:100,display:"block"}})),te=["RgfaTabixAdapter","GbzBaseSyntenyAdapter","MinigraphBubbleAdapter"],ae=M(function({model:a}){let{classes:l}=ee(),f=S(a),d=w(a),[n,V]=r("RgfaTabixAdapter"),[i,X]=r(),[y,q]=r(),[k,K]=r(),m=n==="GbzBaseSyntenyAdapter",[C,Q]=r(""),[h,U]=r("Pangenome graph"),[F,u]=r(),[Y,L]=r(!1);async function Z(){if(!i||!a.assembly)return;u(void 0),L(!0);let e=n==="RgfaTabixAdapter"?await H(i,G(a).pluginManager):void 0;if(L(!1),!(!R(a)||!a.assembly))try{let c=h.trim();T({model:a,session:f,conf:J({choice:n,loc:i,indexLoc:y,readsLoc:m?k:void 0,manifest:e,assembly:a.assembly,sample:C,trackId:A({name:c}),name:c})})}catch(c){u(c)}}return g(N,{className:l.paper,children:[F?t(x,{error:F}):null,g(B,{children:[t(P,{children:"File type"}),t(W,{value:n,onChange:e=>{V(e.target.value),u(void 0)},children:te.map(e=>t(I,{value:e,control:t(_,{}),label:j[e]},e))})]}),t(p,{location:i,name:O[n],rootModel:d,setLocation:X}),t(p,{location:y,name:z[n],rootModel:d,setLocation:q}),m?t(p,{location:k,name:"Path to reads aligned to the graph as GAF (optional; a .gz is read by the .tbi beside it)",rootModel:d,setLocation:K}):null,t(b,{className:l.field,value:C,onChange:e=>{Q(e.target.value)},label:"Sample name in the graph",slotProps:{htmlInput:{"data-testid":"graph-sample-input"}},helperText:m?"Optional. The graph's sample for this assembly, e.g. GRCh38 where the assembly is hg38; leave blank when they share a name or the graph has one reference sample":"Optional. The PanSN prefix the graph gives this assembly, e.g. GRCh38 for HPRC's GRCh38#0#chr1; leave blank when the graph's stable names are bare",placeholder:"GRCh38",fullWidth:!0}),t(b,{className:l.field,value:h,helperText:"Track name",slotProps:{htmlInput:{"data-testid":"graph-track-name-input"}},onChange:e=>{U(e.target.value)}}),t(v,{session:f,helperText:"Select assembly to add track to",selected:a.assembly,onChange:e=>{a.setAssembly(e)},fullWidth:!0}),t(E,{variant:"contained",className:l.submit,disabled:!i||!h.trim()||!a.assembly||Y,onClick:()=>{Z()},children:"Submit"})]})}),ue=ae;export{ue as default};
2
+ //# sourceMappingURL=AddTrackWorkflow-ZKAN5JYJ.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["host:@jbrowse/core/util/tss-react", "../../src/GraphAddTrackWorkflow/AddTrackWorkflow.tsx"],
4
+ "sourcesContent": ["const host = JBrowseExports[\"@jbrowse/core/util/tss-react\"]\nconst read = name =>\n host != null && name in Object(host)\n ? host[name]\n : Object.assign(\n function () {\n throw new Error(\n \"This JBrowse does not provide '\" + name + \"' from '\" + \"@jbrowse/core/util/tss-react\" + \"' to plugins: GraphGenomeView was built for a different JBrowse version, so update the plugin or JBrowse\",\n )\n },\n { jbrowseHostMissing: name },\n )\nexport const cx = /* @__PURE__ */ read(\"cx\")\nexport const keyframes = /* @__PURE__ */ read(\"keyframes\")\nexport const makeStyles = /* @__PURE__ */ read(\"makeStyles\")\nexport default host && host.__esModule ? host.default : host", "import { useState } from 'react'\n\nimport { AssemblySelector, ErrorMessage, FileSelector } from '@jbrowse/core/ui'\nimport {\n addTrackFromWidget,\n getEnv,\n getSession,\n makeTrackId,\n} from '@jbrowse/core/util'\nimport { makeStyles } from '@jbrowse/core/util/tss-react'\nimport { getRoot, isAlive } from '@jbrowse/mobx-state-tree'\nimport {\n Button,\n FormControl,\n FormControlLabel,\n FormLabel,\n Paper,\n Radio,\n RadioGroup,\n TextField,\n} from '@mui/material'\nimport { observer } from 'mobx-react'\n\nimport {\n GRAPH_FILE_FIELDS,\n GRAPH_FILE_LABELS,\n GRAPH_INDEX_FIELDS,\n buildTrackConfig,\n} from './buildTrackConfig'\nimport { readGraphManifest } from './graphManifest'\n\nimport type { GraphFileChoice } from './buildTrackConfig'\nimport type {\n AbstractRootModel,\n AddTrackWorkflowModel,\n FileLocation,\n} from '@jbrowse/core/util'\n\nconst useStyles = makeStyles()(theme => ({\n paper: {\n margin: theme.spacing(),\n padding: theme.spacing(),\n },\n field: {\n marginTop: theme.spacing(2),\n },\n submit: {\n marginTop: 25,\n marginBottom: 100,\n display: 'block',\n },\n}))\n\nconst CHOICES: GraphFileChoice[] = [\n 'RgfaTabixAdapter',\n 'GbzBaseSyntenyAdapter',\n 'MinigraphBubbleAdapter',\n]\n\nconst GraphAddTrackWidget = observer(function GraphAddTrackWidget({\n model,\n}: {\n model: AddTrackWorkflowModel\n}) {\n const { classes } = useStyles()\n const session = getSession(model)\n const rootModel = getRoot<AbstractRootModel>(model)\n const [choice, setChoice] = useState<GraphFileChoice>('RgfaTabixAdapter')\n const [loc, setLoc] = useState<FileLocation>()\n const [indexLoc, setIndexLoc] = useState<FileLocation>()\n const [readsLoc, setReadsLoc] = useState<FileLocation>()\n const gbz = choice === 'GbzBaseSyntenyAdapter'\n const [sample, setSample] = useState('')\n const [trackName, setTrackName] = useState('Pangenome graph')\n const [error, setError] = useState<unknown>()\n const [submitting, setSubmitting] = useState(false)\n\n async function handleSubmit() {\n if (!loc || !model.assembly) {\n return\n }\n setError(undefined)\n setSubmitting(true)\n const manifest =\n choice === 'RgfaTabixAdapter'\n ? await readGraphManifest(loc, getEnv(model).pluginManager)\n : undefined\n setSubmitting(false)\n if (!isAlive(model) || !model.assembly) {\n return\n }\n try {\n const name = trackName.trim()\n addTrackFromWidget({\n model,\n session,\n conf: buildTrackConfig({\n choice,\n loc,\n indexLoc,\n readsLoc: gbz ? readsLoc : undefined,\n manifest,\n assembly: model.assembly,\n sample,\n trackId: makeTrackId({ name }),\n name,\n }),\n })\n } catch (e) {\n setError(e)\n }\n }\n\n return (\n <Paper className={classes.paper}>\n {error ? <ErrorMessage error={error} /> : null}\n <FormControl>\n <FormLabel>File type</FormLabel>\n <RadioGroup\n value={choice}\n onChange={event => {\n setChoice(event.target.value as GraphFileChoice)\n setError(undefined)\n }}\n >\n {CHOICES.map(option => (\n <FormControlLabel\n key={option}\n value={option}\n control={<Radio />}\n label={GRAPH_FILE_LABELS[option]}\n />\n ))}\n </RadioGroup>\n </FormControl>\n <FileSelector\n location={loc}\n name={GRAPH_FILE_FIELDS[choice]}\n rootModel={rootModel}\n setLocation={setLoc}\n />\n <FileSelector\n location={indexLoc}\n name={GRAPH_INDEX_FIELDS[choice]}\n rootModel={rootModel}\n setLocation={setIndexLoc}\n />\n {gbz ? (\n <FileSelector\n location={readsLoc}\n name=\"Path to reads aligned to the graph as GAF (optional; a .gz is read by the .tbi beside it)\"\n rootModel={rootModel}\n setLocation={setReadsLoc}\n />\n ) : null}\n <TextField\n className={classes.field}\n value={sample}\n onChange={event => {\n setSample(event.target.value)\n }}\n label=\"Sample name in the graph\"\n slotProps={{ htmlInput: { 'data-testid': 'graph-sample-input' } }}\n helperText={\n gbz\n ? \"Optional. The graph's sample for this assembly, e.g. GRCh38 where the assembly is hg38; leave blank when they share a name or the graph has one reference sample\"\n : \"Optional. The PanSN prefix the graph gives this assembly, e.g. GRCh38 for HPRC's GRCh38#0#chr1; leave blank when the graph's stable names are bare\"\n }\n placeholder=\"GRCh38\"\n fullWidth\n />\n <TextField\n className={classes.field}\n value={trackName}\n helperText=\"Track name\"\n slotProps={{ htmlInput: { 'data-testid': 'graph-track-name-input' } }}\n onChange={event => {\n setTrackName(event.target.value)\n }}\n />\n <AssemblySelector\n session={session}\n helperText=\"Select assembly to add track to\"\n selected={model.assembly}\n onChange={arg => {\n model.setAssembly(arg)\n }}\n fullWidth\n />\n <Button\n variant=\"contained\"\n className={classes.submit}\n disabled={!loc || !trackName.trim() || !model.assembly || submitting}\n onClick={() => {\n void handleSubmit()\n }}\n >\n Submit\n </Button>\n </Paper>\n )\n})\n\nexport default GraphAddTrackWidget\n"],
5
+ "mappings": "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",
6
+ "names": ["host", "read", "name", "makeStyles", "read", "tss_react_default", "host", "useStyles", "makeStyles", "theme", "CHOICES", "GraphAddTrackWidget", "observer", "model", "classes", "session", "getSession", "rootModel", "getRoot", "choice", "setChoice", "useState", "loc", "setLoc", "indexLoc", "setIndexLoc", "readsLoc", "setReadsLoc", "gbz", "sample", "setSample", "trackName", "setTrackName", "error", "setError", "submitting", "setSubmitting", "handleSubmit", "manifest", "readGraphManifest", "getEnv", "isAlive", "name", "addTrackFromWidget", "buildTrackConfig", "makeTrackId", "e", "jsxs", "Paper", "jsx", "ErrorMessage", "FormControl", "FormLabel", "RadioGroup", "event", "option", "FormControlLabel", "Radio", "GRAPH_FILE_LABELS", "FileSelector", "GRAPH_FILE_FIELDS", "GRAPH_INDEX_FIELDS", "TextField", "AssemblySelector", "arg", "Button", "AddTrackWorkflow_default"]
7
+ }
@@ -1,2 +1,2 @@
1
- import{a as H,b as ae,c as fe,d as re}from"./chunk-KX6CASVE.js";import{b as G,c as V,d as te,e as ne}from"./chunk-ROD6PMOR.js";import{a as E,b as O}from"./chunk-ANYQG5I7.js";import{h as W,i as Z,j as de,k as U,l as u,m as B,n as M,o as F,p as k,q as z,s as X,t as ee}from"./chunk-BPN3IL3K.js";import"./chunk-WAGGHKBL.js";import"./chunk-D257CI4F.js";import{a as N}from"./chunk-OGQ6OQDN.js";import"./chunk-YBLNN5FU.js";import{e as R,f as P,g as C}from"./chunk-E2GK6JEL.js";import"./chunk-E7J6SB5P.js";import{b as Y,c as J,d as K}from"./chunk-R3TRNF7N.js";import"./chunk-7WIBGKBU.js";import{e as j,o as $}from"./chunk-TENPGIPX.js";function A(t){let s=/\.gbz\.db$/i;return s.test(t)?t.replace(s,".haplotype-index.db"):void 0}function he(t){return J(t)&&A(Y(t))?K(t,s=>A(s)):void 0}function ue(t){return t instanceof Error&&(/\bHTTP 40[34]\b/.test(t.message)||t.code==="ENOENT")}async function oe(t,s){let n=he(t);if(!n)return{};try{return await N(n,s).stat(),{location:n}}catch(e){return ue(e)?{}:{unreadable:String(e)}}}var ge=5e3,ye=50*2**20,q=class extends Error{constructor(n){super(`this GAF is ${(n/2**20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`);this.name="UnindexedGafTooLargeError"}};function be(t,s){if(t.length<=s)return t;let n=t.length/s;return Array.from({length:s},(e,a)=>t[Math.floor(a*n)])}var se=(t,s)=>t.path.some(n=>s.has(n.name)),I=class{constructor(s,n){this.file=s;this.tabix=n;this.whole=G({setup:async({signal:s})=>{let{size:n}=await this.file.stat();if(n>ye)throw new q(n);let e=await this.file.readFile({signal:s}),a=new TextDecoder().decode(e[0]===31&&e[1]===139?await te(e):e);return O(a)}})}async readIndexed(s,n,e){let a=1/0,r=-1/0;for(let c of n){let i=Number(c);Number.isInteger(i)&&(a=Math.min(a,i),r=Math.max(r,i))}let o=[];return a<=r&&await s.getLines("{node}",a,r+1,{signal:e,lineCallback:c=>{let i=E(c);i&&se(i,n)&&o.push(i)}}),o}async readsOver(s,{signal:n}={}){let e=this.tabix?await this.readIndexed(this.tabix,s,n):(await this.whole({signal:n})).filter(a=>se(a,s));return{records:be(e,ge),total:e.length}}};var v=class extends Error{constructor(n){super(n===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 (${n}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`);this.name="NoHaplotypeIndexError"}},Q=class extends Error{constructor(n,e){super(`the graph is cut on its reference, ${e}; a window on ${n} has no reference coordinates to cut at. Open the graph from a ${e} view, and find this haplotype's lane there`);this.name="HaplotypeWindowError"}};function ie(t,s){let n=u(s);return t[n]??t[s.sample]??n}function we(t,s){return`${u(t)}#${t.contig}@${s.start.node}.${s.start.offset}`}function xe({alignment:t,assemblyName:s,refName:n,lane:e}){let{refStart:a,refEnd:r,strand:o,cigar:c}=t;if(!(!t.resolved||r<=a)){let{name:i,hapStart:p,hapEnd:d}=t,f=we(i,t),g={uniqueId:f,assemblyName:s,refName:n,start:a,end:r,type:"match",strand:o==="-"?-1:1,CIGAR:c,syntenyId:f,mate:{refName:i.contig,start:p,end:d,assemblyName:e}};return new H(g)}}function Se({pair:t,lane:s,mateLane:n}){let e=`${u(t.target)}#${t.target.contig}:${t.targetStart}-${t.targetEnd}|${u(t.query)}#${t.query.contig}:${t.queryStart}-${t.queryEnd}`;return new H({uniqueId:e,assemblyName:s,refName:t.target.contig,start:t.targetStart,end:t.targetEnd,type:"match",strand:t.strand==="-"?-1:1,CIGAR:t.cigar,syntenyId:e,identity:t.matches/Math.max(t.columns,1),numMatches:t.matches,blockLen:t.columns,mate:{refName:t.query.contig,start:t.queryStart,end:t.queryEnd,assemblyName:n}})}var Pe=12e4;function Ne(t,s){let n=new Map;for(let a of t)for(let{name:r,start:o,end:c}of a.walkSpans()){let i=u(r);if(s.has(i)){let p=`${i}#${r.contig}`;n.set(p,[...n.get(p)??[],[o,c]])}}let e=0;for(let a of n.values()){a.sort((r,o)=>r[0]-o[0]);for(let r=1;r<a.length;r++){let o=a[r][0]-a[r-1][1];o>0&&o<=Pe&&(e=Math.max(e,o))}}return e}function T(t,s){return t instanceof U&&(t.message=`Zoom in to about ${j(t.fitsBp)} to see ${s}`),t}var ce=t=>({...t,start:Math.floor(t.start),end:Math.ceil(t.end)}),_=t=>!("uri"in t)||t.uri!=="",D=class extends ae{constructor(){super(...arguments);this.graph=G({label:"Opening pangenome database",setup:async()=>{let n=this.getConf("gbzDbLocation"),e=this.getConf("haplotypeIndexLocation"),a=_(e)?{location:e}:await oe(n,this.pluginManager),r=a.location,o=await Z.open({source:N(n,this.pluginManager),haplotypeIndex:r?N(r,this.pluginManager):void 0}),c=this.getConf("assemblyNames")[0];if(c===void 0)throw new Error("GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");let i=await M(o),p=F({configured:this.getConf("referenceSample"),anchorPrefix:P(this,c),referenceSamples:i});return{db:o,anchor:c,referenceSample:p,referenceSamples:i,unreadableIndex:a.unreadable}}});this.gaf=G({label:"Opening reads",setup:async()=>{let n=this.getConf("readsLocation"),e=this.getConf(["readsIndex","location"]);return _(n)?new I(N(n,this.pluginManager),_(e)?ne(this,["readsLocation"],["readsIndex"]):void 0):void 0}})}async referenceQuery(n,e){let{db:a,referenceSample:r}=await this.graph(e);return k(a,r,n)}async getHaplotypes(n={}){let{db:e,referenceSamples:a}=await this.graph(n),r=new Map;for(let o of await e.paths()){let c=u(o.name),i=r.get(c);i?i.contigs.includes(o.name.contig)||i.contigs.push(o.name.contig):r.set(c,{prefix:c,sample:o.name.sample,haplotype:o.name.haplotype,contigs:[o.name.contig],isReference:a.includes(o.name.sample)})}return[...r.values()]}async getHeader(n={}){let{anchor:e,referenceSample:a,referenceSamples:r}=await this.graph(n),o=C(this),c=[];for(let i of await this.getHaplotypes(n))i.sample!==a&&c.push({name:ie(o,i),label:i.prefix,group:i.sample});return{hasCoarseTier:!1,anchorAssemblyName:e,referenceSample:a,referenceSamples:r,lanes:c}}async getRefNames(n={}){let{db:e,anchor:a,referenceSample:r}=await this.graph(n),{assemblyName:o}=n,c=o===a?void 0:P(this,o),i=(await e.paths()).filter(p=>o===a?p.isIndexed&&p.name.sample===r:R(u(p.name),c)).map(p=>p.name.contig);return[...new Set(i)]}keepPredicate(n,e){let a=n===void 0||n.length===0?void 0:n.map(r=>P(this,r));return a===void 0&&e===void 0?void 0:r=>B(r,a)&&(e===void 0||R(u(r),e))}async getSubgraph(n,e={}){let{signal:a}=e,{db:r,anchor:o,referenceSample:c,unreadableIndex:i}=await this.graph({signal:a}),{assemblyName:p,refName:d,start:f,end:g}=ce(n);if(p!==o)throw new Q(p,o);let y=await this.referenceQuery(d,{signal:a});if(!y)throw new Error(`${c} has no indexed path ${d} in this graph`);let x=this.keepPredicate(e.haplotypes);if(x!==void 0&&!r.hasHaplotypeIndex)throw new v(i);let l=await X(r,y,f,g,{context:this.getConf("context"),snarls:e.snarls??this.getConf("subgraphSnarls"),limit:this.getConf("nodeLimit"),signal:e.signal,keep:x}).catch(b=>{throw T(b,"the graph")});return typeof l=="string"?l:ee(l,{start:f,end:g},e.walkRows)}async getReads(n,e={}){let a=await this.gaf(e);return a?a.readsOver(new Set(n),e):{records:[],total:0}}async laneHaplotypes(n,e){let a=P(this,n);return(await this.getHaplotypes(e)).filter(r=>R(r.prefix,a))}async anchorFeatures(n,e){let{db:a}=await this.graph(e),{assemblyName:r,refName:o,start:c,end:i}=n,p=P(this,e.targetAssemblyName),d=C(this),f=this.keepPredicate(e.haplotypes,p),g=await this.referenceQuery(o,e),y=this.getConf("nodeLimit");return(g?await $(`Reading graph ${o}:${c.toLocaleString()}-${i.toLocaleString()}`,e.statusCallback,()=>a.getAlignments({path:g,start:c,end:i,context:this.getConf("context"),haplotypes:"all",limit:y,signal:e.signal,keep:f}).catch(l=>{throw T(z(l,y,i-c)??l,"lanes")})):[]).flatMap(l=>{let b=l.resolved?xe({alignment:l,assemblyName:r,refName:o,lane:ie(d,l.name)}):void 0;return b===void 0?[]:[b]})}async pairFeatures(n,e,a){let{db:r}=await this.graph(a),{refName:o,start:c,end:i}=n,d=(await Promise.all(e.map(async m=>({pair:m,featureSide:await this.laneHaplotypes(m.queryAssemblyName,a),mateSide:await this.laneHaplotypes(m.targetAssemblyName,a)})))).filter(({featureSide:m,mateSide:h})=>m.length>0&&h.length>0),f=new Set(d.flatMap(({featureSide:m,mateSide:h})=>[...m,...h].map(u))),g=await this.referenceQuery(o,a),y=this.getConf("nodeLimit"),x=this.getConf("context"),[l]=e,b=(m,h)=>r.getSubgraphs({path:m,start:c,end:i,context:h,snarls:this.getConf("subgraphSnarls"),haplotypes:"all",limit:y,signal:a.signal,keep:S=>f.has(u(S))}),pe=async m=>{let h=await b(m,x).catch(w=>{throw T(z(w,y,i-c)??w,"lanes")}),S=Ne(h,f),L=Math.ceil(S/2)+2e3;return S>0&&L>x?b(m,L).catch(w=>{if(w instanceof W)return h;throw w}):h};return(g&&l&&d.length>0?await $(e.length===1?`Reading ${l.queryAssemblyName} against ${l.targetAssemblyName}`:`Reading ${e.length} lane pairs`,a.statusCallback,()=>pe(g)):[]).flatMap(m=>d.flatMap(({pair:h,featureSide:S,mateSide:L})=>S.flatMap(w=>L.flatMap(le=>m.pairAlignments({target:w,query:le,bases:!1}).map(me=>Se({pair:me,lane:h.queryAssemblyName,mateLane:h.targetAssemblyName}))))))}getFeatures(n,e={}){let a=ce(n);return V(async r=>{let{db:o,anchor:c,unreadableIndex:i}=await this.graph(e);if(!o.hasHaplotypeIndex)throw new v(i);if(a.assemblyName===c){let p=re(e),d=p.length>0?await this.pairFeatures(a,p,e):await this.anchorFeatures(a,e);for(let f of d)r.next(f)}r.complete()},e.signal)}};export{Q as HaplotypeWindowError,v as NoHaplotypeIndexError,de as NoReferenceSampleError,fe as PairTargetError,D as default,xe as fragmentFeature,ie as laneAssemblyName,Se as pairFeature,F as resolveReferenceSample,Ne as widestWalkGap};
2
- //# sourceMappingURL=GbzBaseSyntenyAdapter-KX7DZETX.js.map
1
+ import{a as H,b as ae,c as fe,d as re}from"./chunk-W7UGHWWS.js";import{b as G,c as V,d as te,e as ne}from"./chunk-AHE4Y2TX.js";import{a as E,b as O}from"./chunk-ANYQG5I7.js";import{h as W,i as Z,j as de,k as U,l as u,m as B,n as M,o as F,p as k,q as z,s as X,t as ee}from"./chunk-BPN3IL3K.js";import"./chunk-WAGGHKBL.js";import"./chunk-D257CI4F.js";import"./chunk-YBLNN5FU.js";import{e as R,f as P,g as C}from"./chunk-E2GK6JEL.js";import"./chunk-E7J6SB5P.js";import{b as Y,c as J,d as K}from"./chunk-R3TRNF7N.js";import"./chunk-7WIBGKBU.js";import{a as N}from"./chunk-OGQ6OQDN.js";import{e as j,o as $}from"./chunk-TENPGIPX.js";function A(t){let s=/\.gbz\.db$/i;return s.test(t)?t.replace(s,".haplotype-index.db"):void 0}function he(t){return J(t)&&A(Y(t))?K(t,s=>A(s)):void 0}function ue(t){return t instanceof Error&&(/\bHTTP 40[34]\b/.test(t.message)||t.code==="ENOENT")}async function oe(t,s){let n=he(t);if(!n)return{};try{return await N(n,s).stat(),{location:n}}catch(e){return ue(e)?{}:{unreadable:String(e)}}}var ge=5e3,ye=50*2**20,q=class extends Error{constructor(n){super(`this GAF is ${(n/2**20).toFixed(0)} MB without an index; bgzip it and index it with tabix -p gaf`);this.name="UnindexedGafTooLargeError"}};function be(t,s){if(t.length<=s)return t;let n=t.length/s;return Array.from({length:s},(e,a)=>t[Math.floor(a*n)])}var se=(t,s)=>t.path.some(n=>s.has(n.name)),I=class{constructor(s,n){this.file=s;this.tabix=n;this.whole=G({setup:async({signal:s})=>{let{size:n}=await this.file.stat();if(n>ye)throw new q(n);let e=await this.file.readFile({signal:s}),a=new TextDecoder().decode(e[0]===31&&e[1]===139?await te(e):e);return O(a)}})}async readIndexed(s,n,e){let a=1/0,r=-1/0;for(let c of n){let i=Number(c);Number.isInteger(i)&&(a=Math.min(a,i),r=Math.max(r,i))}let o=[];return a<=r&&await s.getLines("{node}",a,r+1,{signal:e,lineCallback:c=>{let i=E(c);i&&se(i,n)&&o.push(i)}}),o}async readsOver(s,{signal:n}={}){let e=this.tabix?await this.readIndexed(this.tabix,s,n):(await this.whole({signal:n})).filter(a=>se(a,s));return{records:be(e,ge),total:e.length}}};var v=class extends Error{constructor(n){super(n===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 (${n}), so the walks cannot be named; if it is there, reload to try again, or set haplotypeIndexLocation`);this.name="NoHaplotypeIndexError"}},Q=class extends Error{constructor(n,e){super(`the graph is cut on its reference, ${e}; a window on ${n} has no reference coordinates to cut at. Open the graph from a ${e} view, and find this haplotype's lane there`);this.name="HaplotypeWindowError"}};function ie(t,s){let n=u(s);return t[n]??t[s.sample]??n}function we(t,s){return`${u(t)}#${t.contig}@${s.start.node}.${s.start.offset}`}function xe({alignment:t,assemblyName:s,refName:n,lane:e}){let{refStart:a,refEnd:r,strand:o,cigar:c}=t;if(!(!t.resolved||r<=a)){let{name:i,hapStart:p,hapEnd:d}=t,f=we(i,t),g={uniqueId:f,assemblyName:s,refName:n,start:a,end:r,type:"match",strand:o==="-"?-1:1,CIGAR:c,syntenyId:f,mate:{refName:i.contig,start:p,end:d,assemblyName:e}};return new H(g)}}function Se({pair:t,lane:s,mateLane:n}){let e=`${u(t.target)}#${t.target.contig}:${t.targetStart}-${t.targetEnd}|${u(t.query)}#${t.query.contig}:${t.queryStart}-${t.queryEnd}`;return new H({uniqueId:e,assemblyName:s,refName:t.target.contig,start:t.targetStart,end:t.targetEnd,type:"match",strand:t.strand==="-"?-1:1,CIGAR:t.cigar,syntenyId:e,identity:t.matches/Math.max(t.columns,1),numMatches:t.matches,blockLen:t.columns,mate:{refName:t.query.contig,start:t.queryStart,end:t.queryEnd,assemblyName:n}})}var Pe=12e4;function Ne(t,s){let n=new Map;for(let a of t)for(let{name:r,start:o,end:c}of a.walkSpans()){let i=u(r);if(s.has(i)){let p=`${i}#${r.contig}`;n.set(p,[...n.get(p)??[],[o,c]])}}let e=0;for(let a of n.values()){a.sort((r,o)=>r[0]-o[0]);for(let r=1;r<a.length;r++){let o=a[r][0]-a[r-1][1];o>0&&o<=Pe&&(e=Math.max(e,o))}}return e}function T(t,s){return t instanceof U&&(t.message=`Zoom in to about ${j(t.fitsBp)} to see ${s}`),t}var ce=t=>({...t,start:Math.floor(t.start),end:Math.ceil(t.end)}),_=t=>!("uri"in t)||t.uri!=="",D=class extends ae{constructor(){super(...arguments);this.graph=G({label:"Opening pangenome database",setup:async()=>{let n=this.getConf("gbzDbLocation"),e=this.getConf("haplotypeIndexLocation"),a=_(e)?{location:e}:await oe(n,this.pluginManager),r=a.location,o=await Z.open({source:N(n,this.pluginManager),haplotypeIndex:r?N(r,this.pluginManager):void 0}),c=this.getConf("assemblyNames")[0];if(c===void 0)throw new Error("GbzBaseSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");let i=await M(o),p=F({configured:this.getConf("referenceSample"),anchorPrefix:P(this,c),referenceSamples:i});return{db:o,anchor:c,referenceSample:p,referenceSamples:i,unreadableIndex:a.unreadable}}});this.gaf=G({label:"Opening reads",setup:async()=>{let n=this.getConf("readsLocation"),e=this.getConf(["readsIndex","location"]);return _(n)?new I(N(n,this.pluginManager),_(e)?ne(this,["readsLocation"],["readsIndex"]):void 0):void 0}})}async referenceQuery(n,e){let{db:a,referenceSample:r}=await this.graph(e);return k(a,r,n)}async getHaplotypes(n={}){let{db:e,referenceSamples:a}=await this.graph(n),r=new Map;for(let o of await e.paths()){let c=u(o.name),i=r.get(c);i?i.contigs.includes(o.name.contig)||i.contigs.push(o.name.contig):r.set(c,{prefix:c,sample:o.name.sample,haplotype:o.name.haplotype,contigs:[o.name.contig],isReference:a.includes(o.name.sample)})}return[...r.values()]}async getHeader(n={}){let{anchor:e,referenceSample:a,referenceSamples:r}=await this.graph(n),o=C(this),c=[];for(let i of await this.getHaplotypes(n))i.sample!==a&&c.push({name:ie(o,i),label:i.prefix,group:i.sample});return{hasCoarseTier:!1,anchorAssemblyName:e,referenceSample:a,referenceSamples:r,lanes:c}}async getRefNames(n={}){let{db:e,anchor:a,referenceSample:r}=await this.graph(n),{assemblyName:o}=n,c=o===a?void 0:P(this,o),i=(await e.paths()).filter(p=>o===a?p.isIndexed&&p.name.sample===r:R(u(p.name),c)).map(p=>p.name.contig);return[...new Set(i)]}keepPredicate(n,e){let a=n===void 0||n.length===0?void 0:n.map(r=>P(this,r));return a===void 0&&e===void 0?void 0:r=>B(r,a)&&(e===void 0||R(u(r),e))}async getSubgraph(n,e={}){let{signal:a}=e,{db:r,anchor:o,referenceSample:c,unreadableIndex:i}=await this.graph({signal:a}),{assemblyName:p,refName:d,start:f,end:g}=ce(n);if(p!==o)throw new Q(p,o);let y=await this.referenceQuery(d,{signal:a});if(!y)throw new Error(`${c} has no indexed path ${d} in this graph`);let x=this.keepPredicate(e.haplotypes);if(x!==void 0&&!r.hasHaplotypeIndex)throw new v(i);let l=await X(r,y,f,g,{context:this.getConf("context"),snarls:e.snarls??this.getConf("subgraphSnarls"),limit:this.getConf("nodeLimit"),signal:e.signal,keep:x}).catch(b=>{throw T(b,"the graph")});return typeof l=="string"?l:ee(l,{start:f,end:g},e.walkRows)}async getReads(n,e={}){let a=await this.gaf(e);return a?a.readsOver(new Set(n),e):{records:[],total:0}}async laneHaplotypes(n,e){let a=P(this,n);return(await this.getHaplotypes(e)).filter(r=>R(r.prefix,a))}async anchorFeatures(n,e){let{db:a}=await this.graph(e),{assemblyName:r,refName:o,start:c,end:i}=n,p=P(this,e.targetAssemblyName),d=C(this),f=this.keepPredicate(e.haplotypes,p),g=await this.referenceQuery(o,e),y=this.getConf("nodeLimit");return(g?await $(`Reading graph ${o}:${c.toLocaleString()}-${i.toLocaleString()}`,e.statusCallback,()=>a.getAlignments({path:g,start:c,end:i,context:this.getConf("context"),haplotypes:"all",limit:y,signal:e.signal,keep:f}).catch(l=>{throw T(z(l,y,i-c)??l,"lanes")})):[]).flatMap(l=>{let b=l.resolved?xe({alignment:l,assemblyName:r,refName:o,lane:ie(d,l.name)}):void 0;return b===void 0?[]:[b]})}async pairFeatures(n,e,a){let{db:r}=await this.graph(a),{refName:o,start:c,end:i}=n,d=(await Promise.all(e.map(async m=>({pair:m,featureSide:await this.laneHaplotypes(m.queryAssemblyName,a),mateSide:await this.laneHaplotypes(m.targetAssemblyName,a)})))).filter(({featureSide:m,mateSide:h})=>m.length>0&&h.length>0),f=new Set(d.flatMap(({featureSide:m,mateSide:h})=>[...m,...h].map(u))),g=await this.referenceQuery(o,a),y=this.getConf("nodeLimit"),x=this.getConf("context"),[l]=e,b=(m,h)=>r.getSubgraphs({path:m,start:c,end:i,context:h,snarls:this.getConf("subgraphSnarls"),haplotypes:"all",limit:y,signal:a.signal,keep:S=>f.has(u(S))}),pe=async m=>{let h=await b(m,x).catch(w=>{throw T(z(w,y,i-c)??w,"lanes")}),S=Ne(h,f),L=Math.ceil(S/2)+2e3;return S>0&&L>x?b(m,L).catch(w=>{if(w instanceof W)return h;throw w}):h};return(g&&l&&d.length>0?await $(e.length===1?`Reading ${l.queryAssemblyName} against ${l.targetAssemblyName}`:`Reading ${e.length} lane pairs`,a.statusCallback,()=>pe(g)):[]).flatMap(m=>d.flatMap(({pair:h,featureSide:S,mateSide:L})=>S.flatMap(w=>L.flatMap(le=>m.pairAlignments({target:w,query:le,bases:!1}).map(me=>Se({pair:me,lane:h.queryAssemblyName,mateLane:h.targetAssemblyName}))))))}getFeatures(n,e={}){let a=ce(n);return V(async r=>{let{db:o,anchor:c,unreadableIndex:i}=await this.graph(e);if(!o.hasHaplotypeIndex)throw new v(i);if(a.assemblyName===c){let p=re(e),d=p.length>0?await this.pairFeatures(a,p,e):await this.anchorFeatures(a,e);for(let f of d)r.next(f)}r.complete()},e.signal)}};export{Q as HaplotypeWindowError,v as NoHaplotypeIndexError,de as NoReferenceSampleError,fe as PairTargetError,D as default,xe as fragmentFeature,ie as laneAssemblyName,Se as pairFeature,F as resolveReferenceSample,Ne as widestWalkGap};
2
+ //# sourceMappingURL=GbzBaseSyntenyAdapter-RLEI3RDF.js.map
@@ -1,2 +1,2 @@
1
- import{a as g,d as f,f as c}from"./chunk-7ANVPYX5.js";import{a as b,c as p,e as u,f as m}from"./chunk-ROD6PMOR.js";import"./chunk-OGQ6OQDN.js";import"./chunk-YBLNN5FU.js";import"./chunk-E2GK6JEL.js";import{a as i,o as l}from"./chunk-TENPGIPX.js";var r=class extends b{static{this.capabilities=["getFeatures","getRefNames"]}constructor(t,a,s){super(t,a,s),this.bubbles=u(this,["bubblesLocation"],["index"]),this.refNames=new m(this.bubbles,this)}async getRefNames(t={}){return this.refNames.assemblyRefNames(t)}async hasDataForRefName(){return!0}getFeatures(t,a={}){let{signal:s,statusCallback:d}=a;return p(async n=>{let o=await this.refNames.resolve(t,a);o!==void 0&&await l("Downloading bubbles",d,()=>this.bubbles.getLines(o,t.start,t.end,{signal:s,lineCallback:(h,A)=>{let e=g(h);n.next(new i({uniqueId:`bubble-${A}`,refName:t.refName,start:e.start,end:e.end,name:f(e),description:c(e),type:"bubble",score:e.segmentCount,segmentCount:e.segmentCount,pathCount:e.pathCount,inversion:e.inversion,shortestAlleleLength:e.shortestAlleleLength,longestAlleleLength:e.longestAlleleLength,segments:e.segments,shortestAllele:e.shortestAllele,longestAllele:e.longestAllele}))}})),n.complete()},s)}};export{r as default};
2
- //# sourceMappingURL=MinigraphBubbleAdapter-T7I4AEYT.js.map
1
+ import{a as g,d as f,f as c}from"./chunk-7ANVPYX5.js";import{a as b,c as p,e as u,f as m}from"./chunk-AHE4Y2TX.js";import"./chunk-YBLNN5FU.js";import"./chunk-E2GK6JEL.js";import"./chunk-OGQ6OQDN.js";import{a as i,o as l}from"./chunk-TENPGIPX.js";var r=class extends b{static{this.capabilities=["getFeatures","getRefNames"]}constructor(t,a,s){super(t,a,s),this.bubbles=u(this,["bubblesLocation"],["index"]),this.refNames=new m(this.bubbles,this)}async getRefNames(t={}){return this.refNames.assemblyRefNames(t)}async hasDataForRefName(){return!0}getFeatures(t,a={}){let{signal:s,statusCallback:d}=a;return p(async n=>{let o=await this.refNames.resolve(t,a);o!==void 0&&await l("Downloading bubbles",d,()=>this.bubbles.getLines(o,t.start,t.end,{signal:s,lineCallback:(h,A)=>{let e=g(h);n.next(new i({uniqueId:`bubble-${A}`,refName:t.refName,start:e.start,end:e.end,name:f(e),description:c(e),type:"bubble",score:e.segmentCount,segmentCount:e.segmentCount,pathCount:e.pathCount,inversion:e.inversion,shortestAlleleLength:e.shortestAlleleLength,longestAlleleLength:e.longestAlleleLength,segments:e.segments,shortestAllele:e.shortestAllele,longestAllele:e.longestAllele}))}})),n.complete()},s)}};export{r as default};
2
+ //# sourceMappingURL=MinigraphBubbleAdapter-OEOJKDBZ.js.map
@@ -1,3 +1,3 @@
1
- import{a as u,b as P,c as O}from"./chunk-PNHULAAZ.js";import{a as B,c as I,e as R,f as v}from"./chunk-ROD6PMOR.js";import{t as T}from"./chunk-BPN3IL3K.js";import"./chunk-WAGGHKBL.js";import"./chunk-D257CI4F.js";import"./chunk-OGQ6OQDN.js";import"./chunk-YBLNN5FU.js";import{c as F,f as M}from"./chunk-E2GK6JEL.js";import{a as $,o as A}from"./chunk-TENPGIPX.js";function y(i){let e=i.split(" "),a=e.length>=8,r=a?5:0;return{anchored:a,segment:{refName:e[r],start:+e[r+1],end:+e[r+2],id:e[3],rank:+e[4],tags:e[a?8:5]??""}}}function G(i){let e=i.tags.split(" ").find(r=>r.startsWith("SM:Z:"));if(e===void 0)return;let a=e.slice(5).split(",").map(r=>r.trim()).filter(Boolean);return a.length>0?a:void 0}function W(i){return{id:i.slice(0,-1),strand:i.slice(-1)}}function w(i){let e=i.split(" "),a=W(e[3]),r=W(e[4]);return{source:a.id,sourceStrand:a.strand,target:r.id,targetStrand:r.strand,sourceSegment:{id:a.id,refName:e[5],start:+e[6],end:+e[7],rank:+e[8],tags:e[13]??""},targetSegment:{id:r.id,refName:e[9],start:+e[10],end:+e[11],rank:+e[12],tags:e[14]??""}}}function S(i){return`${i.source}${i.sourceStrand}${i.target}${i.targetStrand}`}function Z(i,e,a){let r=n=>n.rank!==0||n.refName!==a.refName?0:n.end<=a.start?-1:n.start>=a.end?1:0,t=new Map(i),s=new Map;for(let n of e)if(i.has(n.source)||i.has(n.target)||r(n.sourceSegment)*r(n.targetSegment)===-1){s.set(S(n),n);for(let o of[n.sourceSegment,n.targetSegment])t.has(o.id)||t.set(o.id,o)}for(let n of e)t.has(n.source)&&t.has(n.target)&&s.set(S(n),n);return{segments:t,links:s}}function H(i,e,a){let r=t=>t.refName!==a.refName||t.end<=a.start||t.start>=a.end;return[...j(i.filter(t=>t.rank>0),e,a.end-a.start),...j(i.filter(t=>t.rank===0&&r(t)),new Set(i.map(t=>t.id)),0)]}function j(i,e,a){let r=[...i].sort((s,n)=>b(s.refName,n.refName)||s.start-n.start),t=[];for(let s of r){let n=t.at(-1);n?.refName===s.refName&&s.start-n.end<=a?(n.needed||=s.start>n.end||e.has(s.id),n.end=Math.max(n.end,s.end)):t.push({refName:s.refName,start:s.start,end:s.end,needed:e.has(s.id)})}return t.filter(s=>s.needed).map(({refName:s,start:n,end:o})=>({refName:s,start:n,end:o}))}function _(i,e,a){let r=t=>e.has(t.id)||a.some(s=>s.refName===t.refName&&t.start>=s.start&&t.end<=s.end);return i.filter(t=>r(t.sourceSegment)&&r(t.targetSegment))}var K=/^[A-Za-z][A-Za-z0-9]:[AifZJHB]:/;function z(i){let{id:e,refName:a,start:r,end:t,rank:s,tags:n}=i,o=n.split(" ").filter(f=>K.test(f)),c=o.length===0?"":` ${o.join(" ")}`;return`S ${e} * LN:i:${t-r} SN:Z:${a} SO:i:${r} SR:i:${s}${c}`}function J(i){let{source:e,sourceStrand:a,target:r,targetStrand:t}=i;return`L ${e} ${a} ${r} ${t} 0M`}function b(i,e){return i<e?-1:i>e?1:0}function L(i,e){let a=[...i.values()].sort((t,s)=>b(t.refName,s.refName)||t.start-s.start||b(t.id,s.id)),r=[...e.keys()].sort((t,s)=>b(t,s));return["H VN:Z:1.0",...a.map(t=>z(t)),...r.map(t=>J(e.get(t)))].join(`
1
+ import{a as u,b as P,c as O}from"./chunk-O5GO45MS.js";import{a as B,c as I,e as R,f as v}from"./chunk-AHE4Y2TX.js";import{t as T}from"./chunk-BPN3IL3K.js";import"./chunk-WAGGHKBL.js";import"./chunk-D257CI4F.js";import"./chunk-YBLNN5FU.js";import{c as F,f as M}from"./chunk-E2GK6JEL.js";import"./chunk-OGQ6OQDN.js";import{a as $,o as A}from"./chunk-TENPGIPX.js";function y(i){let e=i.split(" "),a=e.length>=8,r=a?5:0;return{anchored:a,segment:{refName:e[r],start:+e[r+1],end:+e[r+2],id:e[3],rank:+e[4],tags:e[a?8:5]??""}}}function G(i){let e=i.tags.split(" ").find(r=>r.startsWith("SM:Z:"));if(e===void 0)return;let a=e.slice(5).split(",").map(r=>r.trim()).filter(Boolean);return a.length>0?a:void 0}function W(i){return{id:i.slice(0,-1),strand:i.slice(-1)}}function w(i){let e=i.split(" "),a=W(e[3]),r=W(e[4]);return{source:a.id,sourceStrand:a.strand,target:r.id,targetStrand:r.strand,sourceSegment:{id:a.id,refName:e[5],start:+e[6],end:+e[7],rank:+e[8],tags:e[13]??""},targetSegment:{id:r.id,refName:e[9],start:+e[10],end:+e[11],rank:+e[12],tags:e[14]??""}}}function S(i){return`${i.source}${i.sourceStrand}${i.target}${i.targetStrand}`}function Z(i,e,a){let r=n=>n.rank!==0||n.refName!==a.refName?0:n.end<=a.start?-1:n.start>=a.end?1:0,t=new Map(i),s=new Map;for(let n of e)if(i.has(n.source)||i.has(n.target)||r(n.sourceSegment)*r(n.targetSegment)===-1){s.set(S(n),n);for(let o of[n.sourceSegment,n.targetSegment])t.has(o.id)||t.set(o.id,o)}for(let n of e)t.has(n.source)&&t.has(n.target)&&s.set(S(n),n);return{segments:t,links:s}}function H(i,e,a){let r=t=>t.refName!==a.refName||t.end<=a.start||t.start>=a.end;return[...j(i.filter(t=>t.rank>0),e,a.end-a.start),...j(i.filter(t=>t.rank===0&&r(t)),new Set(i.map(t=>t.id)),0)]}function j(i,e,a){let r=[...i].sort((s,n)=>b(s.refName,n.refName)||s.start-n.start),t=[];for(let s of r){let n=t.at(-1);n?.refName===s.refName&&s.start-n.end<=a?(n.needed||=s.start>n.end||e.has(s.id),n.end=Math.max(n.end,s.end)):t.push({refName:s.refName,start:s.start,end:s.end,needed:e.has(s.id)})}return t.filter(s=>s.needed).map(({refName:s,start:n,end:o})=>({refName:s,start:n,end:o}))}function _(i,e,a){let r=t=>e.has(t.id)||a.some(s=>s.refName===t.refName&&t.start>=s.start&&t.end<=s.end);return i.filter(t=>r(t.sourceSegment)&&r(t.targetSegment))}var K=/^[A-Za-z][A-Za-z0-9]:[AifZJHB]:/;function z(i){let{id:e,refName:a,start:r,end:t,rank:s,tags:n}=i,o=n.split(" ").filter(f=>K.test(f)),c=o.length===0?"":` ${o.join(" ")}`;return`S ${e} * LN:i:${t-r} SN:Z:${a} SO:i:${r} SR:i:${s}${c}`}function J(i){let{source:e,sourceStrand:a,target:r,targetStrand:t}=i;return`L ${e} ${a} ${r} ${t} 0M`}function b(i,e){return i<e?-1:i>e?1:0}function L(i,e){let a=[...i.values()].sort((t,s)=>b(t.refName,s.refName)||t.start-s.start||b(t.id,s.id)),r=[...e.keys()].sort((t,s)=>b(t,s));return["H VN:Z:1.0",...a.map(t=>z(t)),...r.map(t=>J(e.get(t)))].join(`
2
2
  `)}function D(i){return i.filter(e=>e.rank>0)}var V=1e3,C=class extends B{static{this.capabilities=["getFeatures","getRefNames"]}constructor(e,a,r){super(e,a,r),this.fine=this.openIndex([])}openIndex(e){let a=R(this,[...e,"segmentsLocation"],[...e,"segmentsIndex"]),r=this.getConf("walksLocation"),t=e.length===0&&(!("uri"in r)||r.uri!==""),s=R(this,[...e,"linksLocation"],[...e,"linksIndex"]);return{segments:a,links:s,walks:t?new O({walks:R(this,["walksLocation"],["walksIndex"]),nodes:a,links:s},this.getConf("walkChunk")):void 0,refNames:new v(a,this)}}async getHaplotypeNames(e={}){let a=await this.fine.walks?.header(e);return a?.haplotypes.length?a.haplotypes:void 0}index(e="fine"){return e==="fine"?this.fine:(this.coarse??=this.openIndex(["coarse"]),this.coarse)}async getRefNames(e={}){return this.fine.refNames.assemblyRefNames(e)}async hasDataForRefName(){return!0}getFeatures(e,a={}){let{signal:r,statusCallback:t}=a;return I(async s=>{let n=await this.fine.refNames.resolve(e,a);if(n!==void 0){let o=this.fine.walks?await this.fine.walks.queryStart(e.start,a):e.start;await A("Downloading segments",t,()=>u(this.fine.segments,n,o,e.end,{signal:r,lineCallback:c=>{let{segment:f,anchored:h}=y(c);if(h&&f.refName!==n)return;let l=G(f);s.next(new $({uniqueId:f.id,refName:e.refName,start:f.start,end:f.end,name:f.id,type:"segment",rank:f.rank,stableName:f.refName,...l&&{samples:l,sampleCount:l.length}}))}}))}s.complete()},r)}async getSubgraph(e,a={}){let{hops:r=0,signal:t,tier:s}=a,n=this.index(s),o=new Map,c=new Map,f=await n.refNames.resolve(e,{signal:t}),h=async(p,m,g)=>{let d=[];return await u(n.links,p,m,g,{signal:t,lineCallback:E=>{let k=w(E);c.set(S(k),k);for(let N of[k.sourceSegment,k.targetSegment])o.has(N.id)||(o.set(N.id,N),d.push(N))}}),d};if(f===void 0)throw new Error(`${e.assemblyName} ${e.refName} is not in this graph's index; a graph with PanSN names (GRCh38#0#chr1) needs ${e.assemblyName} mapped to its prefix in assemblyNameToPanSN`);if(n.walks)return this.walkSubgraph(n.walks,f,e,a);let l={anchored:!1};if(await u(n.segments,f,e.start,e.end,{signal:t,lineCallback:p=>{let m=y(p);l.anchored||=m.anchored,o.set(m.segment.id,m.segment)}}),l.anchored){let p=[];await u(n.links,f,e.start,e.end,{signal:t,lineCallback:g=>{p.push(w(g))}});let m=Z(o,p,{refName:f,start:e.start,end:e.end});return L(m.segments,m.links)}let x=D(await h(f,e.start,e.end));for(let p=0;p<r;p++){let m=await Promise.all(x.map(g=>h(g.refName,g.start,g.end)));x=D(m.flat())}if(r>0){let p=H([...o.values()],new Set(x.map(g=>g.id)),{refName:f,start:e.start,end:e.end}),m=[];await Promise.all(p.map(g=>u(n.links,g.refName,g.start,g.end,{signal:t,lineCallback:d=>{m.push(w(d))}})));for(let g of _(m,o,p)){c.set(S(g),g);for(let d of[g.sourceSegment,g.targetSegment])o.has(d.id)||o.set(d.id,d)}}return L(o,c)}async walkSubgraph(e,a,r,t){let{graph:s,kept:n,fragments:o}=await e.cut(a,r,{signal:t.signal,keep:P(t.haplotypes?.map(c=>M(this,c)),F(a)),stepBudget:t.walkRows?1/0:this.getConf("walkStepBudget"),byteBudget:this.getConf("walkByteBudget"),context:V});return T(s.tables(n,o),r,t.walkRows)}};export{C as default};
3
- //# sourceMappingURL=RgfaTabixAdapter-QCQRXP4Z.js.map
3
+ //# sourceMappingURL=RgfaTabixAdapter-Q2URYHKT.js.map
@@ -1,2 +1,2 @@
1
- import{b as O,c as D}from"./chunk-PNHULAAZ.js";import{a as _,b as q,d as j}from"./chunk-KX6CASVE.js";import{c as v,e as x,f as T}from"./chunk-ROD6PMOR.js";import{f as C,g as L,k as $,t as I}from"./chunk-BPN3IL3K.js";import"./chunk-WAGGHKBL.js";import"./chunk-D257CI4F.js";import"./chunk-OGQ6OQDN.js";import"./chunk-YBLNN5FU.js";import{a as S,c as P,d as F,e as A,f as N,g as W}from"./chunk-E2GK6JEL.js";import"./chunk-E7J6SB5P.js";import"./chunk-7WIBGKBU.js";import{o as R}from"./chunk-TENPGIPX.js";var Y=50;function Z(i){let e=[];for(let t=0;t<i.length;t++){let[r,s]=i[t],[a,n]=i[t+1]??[];s===n&&s<=Y&&(r==="I"&&a==="D"||r==="D"&&a==="I")?(e.push(["X",s]),t++):e.push([r,s])}return e}function ee(i){return i.map(([e,t])=>`${t}${e}`).join("")}function H(i){let e=new Map,t=a=>{let n=i.get(a),o=n===void 0?0:n.end-n.start,p=e.get(o);return p===void 0&&(p="N".repeat(o),e.set(o,p)),p},r=new Map,s=a=>{let n=r.get(a);return n===void 0&&(n=Array.from(a.ids,(o,p)=>2*o+a.rev[p]),r.set(a,n)),n};return(a,n)=>L({query:s(a),target:s(n),sequenceOf:t,bases:!1})}var te=100;function E(i,e,t){let r=i.at(-1);t>0&&(r?.[0]===e?r[1]+=t:i.push([e,t]))}function X(i){let e=s=>{let a=i.get(s>>1);return a===void 0?0:a.end-a.start},t=s=>{let a=new Float64Array(s.length+1);return s.forEach((n,o)=>{a[o+1]=a[o]+e(n)}),a},r=s=>Array.from(s.ids,(a,n)=>2*a+s.rev[n]);return(s,a)=>{let n=r(a),o=r(s),[p,g]=C(o,n,e),[f,l]=C(o.map(b=>b^1).reverse(),n,e),u=l>g,c=u?f:p,d=Math.max(g,l);if(d<te)return[];let h=t(n),m=t(o),y=b=>u?o.length-1-c[b][0]:c[b][0],w=[];c.forEach(([,b],k)=>{if(k>0){let[U,J]=[y(k-1),y(k)].sort((Q,V)=>Q-V);E(w,"I",m[J]-m[U+1]),E(w,"D",h[b]-h[c[k-1][1]+1])}E(w,"=",e(n[b]))});let[z,K]=[y(0),y(c.length-1)].sort((b,k)=>b-k);return[{queryStart:m[z],queryEnd:m[K+1],targetStart:h[c[0][1]],targetEnd:h[c.at(-1)[1]+1],strand:u?"-":"+",edits:w,sharedBases:d}]}}function M({chain:i,target:e,query:t,assemblyName:r,refName:s,mateAssemblyName:a}){let n=e.hapStart+i.targetStart,o=e.hapStart+i.targetEnd,p=t.hapStart+i.queryStart,g=t.hapStart+i.queryEnd,f=Z(i.edits),l=f.reduce((d,[h,m])=>d+(h==="="?m:0),0),u=f.reduce((d,[,h])=>d+h,0),c=`${e.name}:${n}-${o}|${t.name}:${p}-${g}`;return new _({uniqueId:c,assemblyName:r,refName:s,start:n,end:o,type:"match",strand:i.strand==="-"?-1:1,CIGAR:ee(f),syntenyId:c,identity:l/Math.max(u,1),numMatches:l,blockLen:u,mate:{refName:F(t.name),start:p,end:g,assemblyName:a}})}var ae=1e3;function G(i,e){return i[e]??i[S(e)]??e}var ne=i=>P(i.name)??i.name,B=class extends q{constructor(e,t,r){super(e,t,r);let s=x(this,["nodesLocation"],["nodesIndex"]);this.reader=new D({walks:x(this,["walksLocation"],["walksIndex"]),nodes:s,links:x(this,["linksLocation"],["linksIndex"])},this.getConf("walkChunk")),this.refNames=new T(s,this)}get anchor(){let e=this.getConf("assemblyNames")[0];if(e===void 0)throw new Error("WalkTabixSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");return e}async getHaplotypeNames(e={}){let{haplotypes:t}=await this.reader.header(e);return t.length>0?t:void 0}async getHeader(e={}){let{haplotypes:t,references:r}=await this.reader.header(e),{anchor:s}=this,a=N(this,s),n=W(this);return{hasCoarseTier:!1,anchorAssemblyName:s,referenceSamples:r,lanes:t.filter(o=>o!==a&&S(o)!==a).map(o=>({name:G(n,o),label:o,group:S(o)}))}}async getRefNames(e={}){let{assemblyName:t}=e;return t===void 0||t===this.anchor?this.refNames.assemblyRefNames({...e,assemblyName:this.anchor}):[]}budgets(e){return{stepBudget:e?1/0:this.getConf("walkStepBudget"),byteBudget:this.getConf("walkByteBudget"),context:ae}}async getSubgraph(e,t={}){let{signal:r,haplotypes:s,walkRows:a}=t,n=await this.refNames.resolve(e,{signal:r});if(n===void 0)throw new Error(`${e.assemblyName} ${e.refName} is not in this graph's index; the graph is cut on ${this.anchor}, mapped to its PanSN prefix in assemblyNameToPanSN`);let{graph:o,kept:p,fragments:g}=await this.reader.cut(n,e,{...this.budgets(a),signal:r,keep:O(s?.map(f=>N(this,f)),P(n))});return I(o.tables(p,g),e,a)}async laneWalks(e,t,r,s,a){return R(a,s.statusCallback,()=>this.reader.cut(e,t,{...this.budgets(),signal:s.signal,keep:O(r,P(e)),links:!1}).catch(n=>{throw n instanceof $&&(n.message=n.message.replace("to see the graph","to see lanes")),n}))}async anchorFeatures(e,t,r){let s=r.haplotypes?.length?r.haplotypes.map(m=>N(this,m)):void 0,a=N(this,r.targetAssemblyName),n=a===void 0?s:s===void 0||s.some(m=>A(a,m)||A(m,a))?[a]:[];if(n?.length===0)return[];let{start:o,end:p}=t,{graph:g,fragments:f}=await this.laneWalks(e,t,n,r,`Reading walks ${t.refName}:${o.toLocaleString()}-${p.toLocaleString()}`),l=X(g.nodes),u=W(this),c=f.filter(m=>m.name===e),d=m=>n===void 0?0:n.findIndex(y=>A(m.name,y));return f.filter(m=>m.name!==e&&d(m)>=0).sort((m,y)=>d(m)-d(y)).flatMap(m=>c.flatMap(y=>l(m,y).map(w=>M({chain:w,target:y,query:m,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:G(u,ne(m))}))))}async pairFeatures(e,t,r,s){let[a]=r,n=r.map(l=>({pair:l,featurePrefix:N(this,l.queryAssemblyName),matePrefix:N(this,l.targetAssemblyName)})),{graph:o,fragments:p}=await this.laneWalks(e,t,n.flatMap(l=>[l.featurePrefix,l.matePrefix]),s,r.length===1&&a?`Reading ${a.queryAssemblyName} against ${a.targetAssemblyName}`:`Reading ${r.length} lane pairs`),g=H(o.nodes),f=l=>p.filter(u=>A(u.name,l));return n.flatMap(({pair:l,featurePrefix:u,matePrefix:c})=>f(u).flatMap(d=>f(c).flatMap(h=>g(h,d).map(m=>M({chain:m,target:d,query:h,assemblyName:l.queryAssemblyName,refName:F(d.name),mateAssemblyName:l.targetAssemblyName})))))}getFeatures(e,t={}){return v(async r=>{let s=e.assemblyName===this.anchor?await this.refNames.resolve(e,t):void 0;if(s!==void 0){let a=j(t),n=a.length>0?await this.pairFeatures(s,e,a,t):await this.anchorFeatures(s,e,t);for(let o of n)r.next(o)}r.complete()},t.signal)}};export{B as default,G as laneOf};
2
- //# sourceMappingURL=WalkTabixSyntenyAdapter-H7MKUBJ6.js.map
1
+ import{b as O,c as D}from"./chunk-O5GO45MS.js";import{a as _,b as q,d as j}from"./chunk-W7UGHWWS.js";import{c as v,e as x,f as T}from"./chunk-AHE4Y2TX.js";import{f as C,g as L,k as $,t as I}from"./chunk-BPN3IL3K.js";import"./chunk-WAGGHKBL.js";import"./chunk-D257CI4F.js";import"./chunk-YBLNN5FU.js";import{a as S,c as P,d as F,e as A,f as N,g as W}from"./chunk-E2GK6JEL.js";import"./chunk-E7J6SB5P.js";import"./chunk-7WIBGKBU.js";import"./chunk-OGQ6OQDN.js";import{o as R}from"./chunk-TENPGIPX.js";var Y=50;function Z(i){let e=[];for(let t=0;t<i.length;t++){let[r,s]=i[t],[a,n]=i[t+1]??[];s===n&&s<=Y&&(r==="I"&&a==="D"||r==="D"&&a==="I")?(e.push(["X",s]),t++):e.push([r,s])}return e}function ee(i){return i.map(([e,t])=>`${t}${e}`).join("")}function H(i){let e=new Map,t=a=>{let n=i.get(a),o=n===void 0?0:n.end-n.start,p=e.get(o);return p===void 0&&(p="N".repeat(o),e.set(o,p)),p},r=new Map,s=a=>{let n=r.get(a);return n===void 0&&(n=Array.from(a.ids,(o,p)=>2*o+a.rev[p]),r.set(a,n)),n};return(a,n)=>L({query:s(a),target:s(n),sequenceOf:t,bases:!1})}var te=100;function E(i,e,t){let r=i.at(-1);t>0&&(r?.[0]===e?r[1]+=t:i.push([e,t]))}function X(i){let e=s=>{let a=i.get(s>>1);return a===void 0?0:a.end-a.start},t=s=>{let a=new Float64Array(s.length+1);return s.forEach((n,o)=>{a[o+1]=a[o]+e(n)}),a},r=s=>Array.from(s.ids,(a,n)=>2*a+s.rev[n]);return(s,a)=>{let n=r(a),o=r(s),[p,g]=C(o,n,e),[f,l]=C(o.map(b=>b^1).reverse(),n,e),u=l>g,c=u?f:p,d=Math.max(g,l);if(d<te)return[];let h=t(n),m=t(o),y=b=>u?o.length-1-c[b][0]:c[b][0],w=[];c.forEach(([,b],k)=>{if(k>0){let[U,J]=[y(k-1),y(k)].sort((Q,V)=>Q-V);E(w,"I",m[J]-m[U+1]),E(w,"D",h[b]-h[c[k-1][1]+1])}E(w,"=",e(n[b]))});let[z,K]=[y(0),y(c.length-1)].sort((b,k)=>b-k);return[{queryStart:m[z],queryEnd:m[K+1],targetStart:h[c[0][1]],targetEnd:h[c.at(-1)[1]+1],strand:u?"-":"+",edits:w,sharedBases:d}]}}function M({chain:i,target:e,query:t,assemblyName:r,refName:s,mateAssemblyName:a}){let n=e.hapStart+i.targetStart,o=e.hapStart+i.targetEnd,p=t.hapStart+i.queryStart,g=t.hapStart+i.queryEnd,f=Z(i.edits),l=f.reduce((d,[h,m])=>d+(h==="="?m:0),0),u=f.reduce((d,[,h])=>d+h,0),c=`${e.name}:${n}-${o}|${t.name}:${p}-${g}`;return new _({uniqueId:c,assemblyName:r,refName:s,start:n,end:o,type:"match",strand:i.strand==="-"?-1:1,CIGAR:ee(f),syntenyId:c,identity:l/Math.max(u,1),numMatches:l,blockLen:u,mate:{refName:F(t.name),start:p,end:g,assemblyName:a}})}var ae=1e3;function G(i,e){return i[e]??i[S(e)]??e}var ne=i=>P(i.name)??i.name,B=class extends q{constructor(e,t,r){super(e,t,r);let s=x(this,["nodesLocation"],["nodesIndex"]);this.reader=new D({walks:x(this,["walksLocation"],["walksIndex"]),nodes:s,links:x(this,["linksLocation"],["linksIndex"])},this.getConf("walkChunk")),this.refNames=new T(s,this)}get anchor(){let e=this.getConf("assemblyNames")[0];if(e===void 0)throw new Error("WalkTabixSyntenyAdapter needs assemblyNames: its first entry is the assembly the reference sample is loaded as");return e}async getHaplotypeNames(e={}){let{haplotypes:t}=await this.reader.header(e);return t.length>0?t:void 0}async getHeader(e={}){let{haplotypes:t,references:r}=await this.reader.header(e),{anchor:s}=this,a=N(this,s),n=W(this);return{hasCoarseTier:!1,anchorAssemblyName:s,referenceSamples:r,lanes:t.filter(o=>o!==a&&S(o)!==a).map(o=>({name:G(n,o),label:o,group:S(o)}))}}async getRefNames(e={}){let{assemblyName:t}=e;return t===void 0||t===this.anchor?this.refNames.assemblyRefNames({...e,assemblyName:this.anchor}):[]}budgets(e){return{stepBudget:e?1/0:this.getConf("walkStepBudget"),byteBudget:this.getConf("walkByteBudget"),context:ae}}async getSubgraph(e,t={}){let{signal:r,haplotypes:s,walkRows:a}=t,n=await this.refNames.resolve(e,{signal:r});if(n===void 0)throw new Error(`${e.assemblyName} ${e.refName} is not in this graph's index; the graph is cut on ${this.anchor}, mapped to its PanSN prefix in assemblyNameToPanSN`);let{graph:o,kept:p,fragments:g}=await this.reader.cut(n,e,{...this.budgets(a),signal:r,keep:O(s?.map(f=>N(this,f)),P(n))});return I(o.tables(p,g),e,a)}async laneWalks(e,t,r,s,a){return R(a,s.statusCallback,()=>this.reader.cut(e,t,{...this.budgets(),signal:s.signal,keep:O(r,P(e)),links:!1}).catch(n=>{throw n instanceof $&&(n.message=n.message.replace("to see the graph","to see lanes")),n}))}async anchorFeatures(e,t,r){let s=r.haplotypes?.length?r.haplotypes.map(m=>N(this,m)):void 0,a=N(this,r.targetAssemblyName),n=a===void 0?s:s===void 0||s.some(m=>A(a,m)||A(m,a))?[a]:[];if(n?.length===0)return[];let{start:o,end:p}=t,{graph:g,fragments:f}=await this.laneWalks(e,t,n,r,`Reading walks ${t.refName}:${o.toLocaleString()}-${p.toLocaleString()}`),l=X(g.nodes),u=W(this),c=f.filter(m=>m.name===e),d=m=>n===void 0?0:n.findIndex(y=>A(m.name,y));return f.filter(m=>m.name!==e&&d(m)>=0).sort((m,y)=>d(m)-d(y)).flatMap(m=>c.flatMap(y=>l(m,y).map(w=>M({chain:w,target:y,query:m,assemblyName:t.assemblyName,refName:t.refName,mateAssemblyName:G(u,ne(m))}))))}async pairFeatures(e,t,r,s){let[a]=r,n=r.map(l=>({pair:l,featurePrefix:N(this,l.queryAssemblyName),matePrefix:N(this,l.targetAssemblyName)})),{graph:o,fragments:p}=await this.laneWalks(e,t,n.flatMap(l=>[l.featurePrefix,l.matePrefix]),s,r.length===1&&a?`Reading ${a.queryAssemblyName} against ${a.targetAssemblyName}`:`Reading ${r.length} lane pairs`),g=H(o.nodes),f=l=>p.filter(u=>A(u.name,l));return n.flatMap(({pair:l,featurePrefix:u,matePrefix:c})=>f(u).flatMap(d=>f(c).flatMap(h=>g(h,d).map(m=>M({chain:m,target:d,query:h,assemblyName:l.queryAssemblyName,refName:F(d.name),mateAssemblyName:l.targetAssemblyName})))))}getFeatures(e,t={}){return v(async r=>{let s=e.assemblyName===this.anchor?await this.refNames.resolve(e,t):void 0;if(s!==void 0){let a=j(t),n=a.length>0?await this.pairFeatures(s,e,a,t):await this.anchorFeatures(s,e,t);for(let o of n)r.next(o)}r.complete()},t.signal)}};export{B as default,G as laneOf};
2
+ //# sourceMappingURL=WalkTabixSyntenyAdapter-RXTCCCDB.js.map
@@ -0,0 +1,2 @@
1
+ import{b as o,c as p,d as s}from"./chunk-R3TRNF7N.js";import{b as u}from"./chunk-7WIBGKBU.js";import{a as x}from"./chunk-OGQ6OQDN.js";var B=".segs.bed.gz",G=5e3;function L(e){return typeof e=="string"&&/^[\w+-][\w.+-]*$/.test(e)}function b(e){return e==null}function S(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function F(e){return S(e)&&L(e.prefix)&&typeof e.foldBelowBp=="number"&&Number.isFinite(e.foldBelowBp)&&e.foldBelowBp>0}function T(e){let n;try{n=JSON.parse(e)}catch{return}if(!S(n)||n.schema!==1)return;let{reference:i,tier:t,index:r,contig:a,bubbles:d,alleles:l}=n;if((b(i)||typeof i=="string"&&i.trim()!=="")&&(b(t)||F(t))&&[r,a,d,l].every(y=>b(y)||L(y)))return{...typeof i=="string"?{reference:i.trim()}:{},...F(t)?{tier:{prefix:t.prefix,foldBelowBp:t.foldBelowBp}}:{}}}function g(e,n){return s(e,i=>i.replace(/[^/\\]*$/,n))}function M(e){let n=o(e);return p(e)&&n.endsWith(B)?s(e,i=>`${i.slice(0,-B.length)}.graph.json`):void 0}async function D(e,n){let i=M(e);if(i)try{let t=await x(i,n).readFile({encoding:"utf8",signal:AbortSignal.timeout(G)});return T(t)}catch{return}}var H={RgfaTabixAdapter:"rGFA segments (tabix BED pair)",GbzBaseSyntenyAdapter:"GBZ database (.gbz.db)",MinigraphBubbleAdapter:"Minigraph bubbles (tabix BED)"},W={RgfaTabixAdapter:"Path to segments BED (.segs.bed.gz from gfa-to-tabix; the .links.bed.gz, its index and any .graph.json are read beside it)",GbzBaseSyntenyAdapter:"Path to the .gbz.db written by gbz-base construct",MinigraphBubbleAdapter:"Path to bubbles BED (.bed.gz from gfatools bubble)"},A="Path to tabix index (optional; the sibling .tbi is assumed, a .csi is recognised by name)",U={RgfaTabixAdapter:A,GbzBaseSyntenyAdapter:"Path to the haplotype index (optional; graph.haplotype-index.db beside the database is assumed)",MinigraphBubbleAdapter:A},c=".segs.bed.gz";function f(e,n){return s(e,i=>i+n)}function O(e){return p(e)&&o(e).endsWith(c)}function w(e){if(!o(e).endsWith(c))throw new Error(`Expected a segments BED ending in ${c}, got ${o(e)}`);return s(e,n=>`${n.slice(0,-c.length)}.links.bed.gz`)}function I(e,n){return n?{location:n,indexType:u(o(n),"CSI","TBI")}:{location:f(e,".tbi"),indexType:"TBI"}}function m(e,n){return n!==void 0&&u(o(n),"CSI","TBI")==="CSI"?{location:f(e,".csi"),indexType:"CSI"}:{location:f(e,".tbi"),indexType:"TBI"}}function h(e,n){let i=n.trim();return i?{assemblyNameToPanSN:{[e]:i}}:{}}function k(e,n,i){if(!i)return{};let t=g(e,`${i.prefix}${c}`),r=g(e,`${i.prefix}.links.bed.gz`);return{coarse:{foldBelowBp:i.foldBelowBp,segmentsLocation:t,segmentsIndex:m(t,n),linksLocation:r,linksIndex:m(r,n)}}}function E(e,n,i){let t=i===e?void 0:i;return h(e,n.trim()||t||"")}function z(e){return e?{readsLocation:e,...o(e).endsWith(".gz")&&p(e)?{readsIndex:{location:f(e,".tbi")}}:{}}:{}}function N({choice:e,loc:n,indexLoc:i,readsLoc:t,manifest:r,assembly:a,sample:d}){if(e==="GbzBaseSyntenyAdapter")return{type:"GbzBaseSyntenyAdapter",gbzDbLocation:n,...i?{haplotypeIndexLocation:i}:{},assemblyNames:[a],...z(t),...h(a,d)};if(e==="MinigraphBubbleAdapter")return{type:"MinigraphBubbleAdapter",bubblesLocation:n,index:I(n,i),...h(a,d)};let l=w(n);return{type:"RgfaTabixAdapter",segmentsLocation:n,segmentsIndex:I(n,i),linksLocation:l,linksIndex:m(l,i),...E(a,d,r?.reference),...k(n,i,r?.tier)}}function v(e){let{choice:n,assembly:i,trackId:t,name:r}=e;return{type:n==="MinigraphBubbleAdapter"?"FeatureTrack":"GraphTrack",trackId:t,name:r,assemblyNames:[i],adapter:N(e),...n==="RgfaTabixAdapter"?{displayDefaults:{showLabels:"none"}}:{}}}export{D as a,H as b,W as c,U as d,O as e,N as f,v as g};
2
+ //# sourceMappingURL=chunk-2I4VPDLZ.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/GraphAddTrackWorkflow/graphManifest.ts", "../../src/GraphAddTrackWorkflow/buildTrackConfig.ts"],
4
+ "sourcesContent": ["import { openLocation } from '@jbrowse/core/util/io'\n\nimport { locationName, readsSiblings, renamed } from '../locationName'\n\nimport type PluginManager from '@jbrowse/core/PluginManager'\nimport type { FileLocation } from '@jbrowse/core/util'\n\n// The part of `<prefix>.graph.json`, written by `gfa-to-tabix build`, that\n// Open track reads\nexport interface GraphManifest {\n reference?: string\n tier?: { prefix: string; foldBelowBp: number }\n}\n\nconst SEGMENTS_SUFFIX = '.segs.bed.gz'\nconst FETCH_TIMEOUT_MS = 5000\n\n// A bare file name beside the manifest: no directory, scheme or leading dot\nfunction isSiblingName(name: unknown): name is string {\n return typeof name === 'string' && /^[\\w+-][\\w.+-]*$/.test(name)\n}\n\nfunction isAbsent(value: unknown) {\n return value === undefined || value === null\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction isTier(tier: unknown): tier is NonNullable<GraphManifest['tier']> {\n return (\n isRecord(tier) &&\n isSiblingName(tier.prefix) &&\n typeof tier.foldBelowBp === 'number' &&\n Number.isFinite(tier.foldBelowBp) &&\n tier.foldBelowBp > 0\n )\n}\n\nexport function parseGraphManifest(text: string): GraphManifest | undefined {\n let json: unknown\n try {\n json = JSON.parse(text)\n } catch {\n return undefined\n }\n if (!isRecord(json) || json.schema !== 1) {\n return undefined\n }\n const { reference, tier, index, contig, bubbles, alleles } = json\n const valid =\n (isAbsent(reference) ||\n (typeof reference === 'string' && reference.trim() !== '')) &&\n (isAbsent(tier) || isTier(tier)) &&\n [index, contig, bubbles, alleles].every(\n f => isAbsent(f) || isSiblingName(f),\n )\n if (!valid) {\n return undefined\n }\n return {\n ...(typeof reference === 'string' ? { reference: reference.trim() } : {}),\n ...(isTier(tier)\n ? { tier: { prefix: tier.prefix, foldBelowBp: tier.foldBelowBp } }\n : {}),\n }\n}\n\n// A file the manifest names, in the directory of the segments file opened\nexport function besideSegments(segs: FileLocation, fileName: string) {\n return renamed(segs, name => name.replace(/[^/\\\\]*$/, fileName))\n}\n\nexport function manifestLocation(segs: FileLocation) {\n const name = locationName(segs)\n return readsSiblings(segs) && name.endsWith(SEGMENTS_SUFFIX)\n ? renamed(segs, n => `${n.slice(0, -SEGMENTS_SUFFIX.length)}.graph.json`)\n : undefined\n}\n\n// Undefined for a manifest that is missing, unreadable or not schema 1, so\n// Open track falls back to the files beside the segments alone\nexport async function readGraphManifest(\n segs: FileLocation,\n pluginManager?: PluginManager,\n) {\n const loc = manifestLocation(segs)\n if (!loc) {\n return undefined\n }\n try {\n const text = await openLocation(loc, pluginManager).readFile({\n encoding: 'utf8',\n signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),\n })\n return parseGraphManifest(text)\n } catch {\n return undefined\n }\n}\n", "import { makeIndexType } from '@jbrowse/core/util/tracks'\n\nimport { besideSegments } from './graphManifest'\nimport { locationName, readsSiblings, renamed } from '../locationName'\n\nimport type { GraphManifest } from './graphManifest'\nimport type { FileLocation } from '@jbrowse/core/util'\n\nexport type GraphFileChoice =\n 'RgfaTabixAdapter' | 'GbzBaseSyntenyAdapter' | 'MinigraphBubbleAdapter'\n\nexport const GRAPH_FILE_LABELS: Record<GraphFileChoice, string> = {\n RgfaTabixAdapter: 'rGFA segments (tabix BED pair)',\n GbzBaseSyntenyAdapter: 'GBZ database (.gbz.db)',\n MinigraphBubbleAdapter: 'Minigraph bubbles (tabix BED)',\n}\n\nexport const GRAPH_FILE_FIELDS: Record<GraphFileChoice, string> = {\n RgfaTabixAdapter:\n 'Path to segments BED (.segs.bed.gz from gfa-to-tabix; the .links.bed.gz, its index and any .graph.json are read beside it)',\n GbzBaseSyntenyAdapter: 'Path to the .gbz.db written by gbz-base construct',\n MinigraphBubbleAdapter: 'Path to bubbles BED (.bed.gz from gfatools bubble)',\n}\n\nconst TABIX_INDEX_FIELD =\n 'Path to tabix index (optional; the sibling .tbi is assumed, a .csi is recognised by name)'\n\nexport const GRAPH_INDEX_FIELDS: Record<GraphFileChoice, string> = {\n RgfaTabixAdapter: TABIX_INDEX_FIELD,\n GbzBaseSyntenyAdapter:\n 'Path to the haplotype index (optional; graph.haplotype-index.db beside the database is assumed)',\n MinigraphBubbleAdapter: TABIX_INDEX_FIELD,\n}\n\nconst SEGMENTS_SUFFIX = '.segs.bed.gz'\n\nfunction sibling(loc: FileLocation, suffix: string) {\n return renamed(loc, name => name + suffix)\n}\n\n// A segments BED the links BED can be found beside\nexport function isSegmentsLocation(loc: FileLocation) {\n return readsSiblings(loc) && locationName(loc).endsWith(SEGMENTS_SUFFIX)\n}\n\nfunction linksLocation(loc: FileLocation) {\n if (!locationName(loc).endsWith(SEGMENTS_SUFFIX)) {\n throw new Error(\n `Expected a segments BED ending in ${SEGMENTS_SUFFIX}, got ${locationName(loc)}`,\n )\n }\n return renamed(\n loc,\n name => `${name.slice(0, -SEGMENTS_SUFFIX.length)}.links.bed.gz`,\n )\n}\n\nfunction tabixIndex(loc: FileLocation, indexLoc: FileLocation | undefined) {\n return indexLoc\n ? {\n location: indexLoc,\n indexType: makeIndexType(locationName(indexLoc), 'CSI', 'TBI'),\n }\n : { location: sibling(loc, '.tbi'), indexType: 'TBI' }\n}\n\n// The links file's index is assumed beside it, of the kind the segments' is.\nfunction siblingIndex(loc: FileLocation, indexLoc: FileLocation | undefined) {\n const csi =\n indexLoc !== undefined &&\n makeIndexType(locationName(indexLoc), 'CSI', 'TBI') === 'CSI'\n return csi\n ? { location: sibling(loc, '.csi'), indexType: 'CSI' }\n : { location: sibling(loc, '.tbi'), indexType: 'TBI' }\n}\n\nfunction panSN(assembly: string, sample: string) {\n const name = sample.trim()\n return name ? { assemblyNameToPanSN: { [assembly]: name } } : {}\n}\n\nfunction coarseTier(\n loc: FileLocation,\n indexLoc: FileLocation | undefined,\n tier: GraphManifest['tier'],\n) {\n if (!tier) {\n return {}\n }\n const segs = besideSegments(loc, `${tier.prefix}${SEGMENTS_SUFFIX}`)\n const links = besideSegments(loc, `${tier.prefix}.links.bed.gz`)\n return {\n coarse: {\n foldBelowBp: tier.foldBelowBp,\n segmentsLocation: segs,\n segmentsIndex: siblingIndex(segs, indexLoc),\n linksLocation: links,\n linksIndex: siblingIndex(links, indexLoc),\n },\n }\n}\n\n// The user's sample wins; the manifest's reference stands in when blank\nfunction manifestPanSN(\n assembly: string,\n sample: string,\n reference: string | undefined,\n) {\n const fromManifest = reference === assembly ? undefined : reference\n return panSN(assembly, sample.trim() || fromManifest || '')\n}\n\n// a bgzipped GAF is read by its tabix index, a plain one whole\nfunction readsConfig(readsLoc: FileLocation | undefined) {\n return readsLoc\n ? {\n readsLocation: readsLoc,\n ...(locationName(readsLoc).endsWith('.gz') && readsSiblings(readsLoc)\n ? { readsIndex: { location: sibling(readsLoc, '.tbi') } }\n : {}),\n }\n : {}\n}\n\nexport function buildAdapterConfig({\n choice,\n loc,\n indexLoc,\n readsLoc,\n manifest,\n assembly,\n sample,\n}: {\n choice: GraphFileChoice\n loc: FileLocation\n indexLoc: FileLocation | undefined\n // a GBZ track's GAF reads, which no other choice takes\n readsLoc?: FileLocation\n // the `.graph.json` beside an rGFA segments file\n manifest?: GraphManifest\n assembly: string\n sample: string\n}) {\n if (choice === 'GbzBaseSyntenyAdapter') {\n return {\n type: 'GbzBaseSyntenyAdapter',\n gbzDbLocation: loc,\n ...(indexLoc ? { haplotypeIndexLocation: indexLoc } : {}),\n assemblyNames: [assembly],\n ...readsConfig(readsLoc),\n ...panSN(assembly, sample),\n }\n }\n if (choice === 'MinigraphBubbleAdapter') {\n return {\n type: 'MinigraphBubbleAdapter',\n bubblesLocation: loc,\n index: tabixIndex(loc, indexLoc),\n ...panSN(assembly, sample),\n }\n }\n const links = linksLocation(loc)\n return {\n type: 'RgfaTabixAdapter',\n segmentsLocation: loc,\n segmentsIndex: tabixIndex(loc, indexLoc),\n linksLocation: links,\n linksIndex: siblingIndex(links, indexLoc),\n ...manifestPanSN(assembly, sample, manifest?.reference),\n ...coarseTier(loc, indexLoc, manifest?.tier),\n }\n}\n\nexport function buildTrackConfig(args: {\n choice: GraphFileChoice\n loc: FileLocation\n indexLoc: FileLocation | undefined\n readsLoc?: FileLocation\n manifest?: GraphManifest\n assembly: string\n sample: string\n trackId: string\n name: string\n}) {\n const { choice, assembly, trackId, name } = args\n return {\n type: choice === 'MinigraphBubbleAdapter' ? 'FeatureTrack' : 'GraphTrack',\n trackId,\n name,\n assemblyNames: [assembly],\n adapter: buildAdapterConfig(args),\n ...(choice === 'RgfaTabixAdapter'\n ? { displayDefaults: { showLabels: 'none' } }\n : {}),\n }\n}\n"],
5
+ "mappings": "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",
6
+ "names": ["SEGMENTS_SUFFIX", "FETCH_TIMEOUT_MS", "isSiblingName", "name", "isAbsent", "value", "isRecord", "isTier", "tier", "parseGraphManifest", "text", "json", "reference", "index", "contig", "bubbles", "alleles", "f", "besideSegments", "segs", "fileName", "renamed", "manifestLocation", "locationName", "readsSiblings", "n", "readGraphManifest", "pluginManager", "loc", "openLocation", "GRAPH_FILE_LABELS", "GRAPH_FILE_FIELDS", "TABIX_INDEX_FIELD", "GRAPH_INDEX_FIELDS", "SEGMENTS_SUFFIX", "sibling", "loc", "suffix", "renamed", "name", "isSegmentsLocation", "readsSiblings", "locationName", "linksLocation", "tabixIndex", "indexLoc", "makeIndexType", "siblingIndex", "panSN", "assembly", "sample", "coarseTier", "tier", "segs", "besideSegments", "links", "manifestPanSN", "reference", "fromManifest", "readsConfig", "readsLoc", "buildAdapterConfig", "choice", "manifest", "buildTrackConfig", "args", "trackId"]
7
+ }