@gmod/gfa-tabix 0.0.0-stage → 10.1.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.
- package/LICENSE +21 -0
- package/README.md +85 -2
- package/esm/abridgedWalks.d.ts +7 -0
- package/esm/abridgedWalks.js +34 -0
- package/esm/formsCheck.d.ts +50 -0
- package/esm/formsCheck.js +251 -0
- package/esm/gfaTabixFile.d.ts +27 -0
- package/esm/gfaTabixFile.js +168 -0
- package/esm/index.d.ts +30 -0
- package/esm/index.js +16 -0
- package/esm/refNames.d.ts +25 -0
- package/esm/refNames.js +65 -0
- package/esm/rgfaBed.d.ts +67 -0
- package/esm/rgfaBed.js +301 -0
- package/esm/structuralForms.d.ts +225 -0
- package/esm/structuralForms.js +813 -0
- package/esm/tabixSource.d.ts +25 -0
- package/esm/tabixSource.js +7 -0
- package/esm/util.d.ts +95 -0
- package/esm/util.js +59 -0
- package/esm/walkChunk.d.ts +246 -0
- package/esm/walkChunk.js +1314 -0
- package/esm/walkContainer.d.ts +54 -0
- package/esm/walkContainer.js +358 -0
- package/esm/walkCounts.d.ts +158 -0
- package/esm/walkCounts.js +580 -0
- package/esm/walkDeparture.d.ts +58 -0
- package/esm/walkDeparture.js +122 -0
- package/esm/walkDepartures.d.ts +80 -0
- package/esm/walkDepartures.js +301 -0
- package/esm/walkFile.d.ts +259 -0
- package/esm/walkFile.js +1534 -0
- package/esm/walkGaps.d.ts +56 -0
- package/esm/walkGaps.js +345 -0
- package/esm/walkRows.d.ts +315 -0
- package/esm/walkRows.js +1607 -0
- package/esm/walkRuns.d.ts +229 -0
- package/esm/walkRuns.js +989 -0
- package/package.json +63 -3
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { RefPath } from './walkChunk.ts';
|
|
2
|
+
import type { GraphTables } from './util.ts';
|
|
3
|
+
import type { AbridgedPiece } from './walkChunk.ts';
|
|
4
|
+
import type { Hole, WalkDeparture } from './walkDeparture.ts';
|
|
5
|
+
import type { ChainEvent } from './walkDepartures.ts';
|
|
6
|
+
/**
|
|
7
|
+
* What a walk does past one end of a fragment, read from the departure that
|
|
8
|
+
* leaves its last step on the reference, or rejoins its first: `beyond`, it
|
|
9
|
+
* is next on the reference past the drawn stretch on that side, the same way
|
|
10
|
+
* round; `elsewhere`, any other departure, reversed, back on the other side
|
|
11
|
+
* or with its far end inside the drawn stretch; `edge`, no departure, and the
|
|
12
|
+
* end lies on the drawn stretch's edge, so whatever the walk does next lies
|
|
13
|
+
* off it; `nowhere`, no departure and the end lies inside the drawn stretch:
|
|
14
|
+
* the walk has no step on the reference sequence past it.
|
|
15
|
+
*/
|
|
16
|
+
export declare const END_KINDS: readonly ["beyond", "elsewhere", "edge", "nowhere"];
|
|
17
|
+
export type EndKind = (typeof END_KINDS)[number];
|
|
18
|
+
/**
|
|
19
|
+
* One end of each fragment, by END_KINDS index in `kinds`. For `beyond` and
|
|
20
|
+
* `elsewhere`: `pos`, the departure's breakpoint off the fragment, its leave
|
|
21
|
+
* for a `before` end and its rejoin for an `after` one, `reversed` 1 where
|
|
22
|
+
* that step runs against the reference, `ownBp` the walk's bp between the
|
|
23
|
+
* fragment's stretch and that step, a lead or tail included, and
|
|
24
|
+
* `missingBp` the part between the contig's W lines. For `nowhere`, `ownBp`
|
|
25
|
+
* is the rest of the run the read holds past the stretch, all of it off the
|
|
26
|
+
* reference; for `edge` it is NaN. For both, `pos` is NaN and `reversed` and
|
|
27
|
+
* `missingBp` are 0.
|
|
28
|
+
*/
|
|
29
|
+
export interface WalkEnds {
|
|
30
|
+
kinds: Uint8Array;
|
|
31
|
+
pos: Float64Array;
|
|
32
|
+
reversed: Uint8Array;
|
|
33
|
+
ownBp: Float64Array;
|
|
34
|
+
missingBp: Float64Array;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A window's walks as runs, a fragment per walk-table walk of the cut, in
|
|
38
|
+
* its order: the reference's fragments first, then by name and contig
|
|
39
|
+
* position. A stretch is consecutive steps on the reference, each starting on
|
|
40
|
+
* the base the last ended on, all one way; it never spans a hole. A run is
|
|
41
|
+
* what lies between two stretches of a fragment. A fragment's stretches lie
|
|
42
|
+
* at `offsets[p]` up to `offsets[p + 1]`, each over `[starts, starts + bp)`
|
|
43
|
+
* of the reference, `against` 1 where the walk takes it against the
|
|
44
|
+
* reference, `offBefore` the bp of the walk's own run before it, 0 for a
|
|
45
|
+
* fragment's first, and `loaded` 0 where that run holds a placeholder: the
|
|
46
|
+
* file abridged its piece, so it reports the file's abridging, not which
|
|
47
|
+
* nodes a host loaded. Stretches either side of a hole follow on with
|
|
48
|
+
* `offBefore` 0, so a consumer takes `holes` out before calling the gap a
|
|
49
|
+
* deletion. In a plain cut a fragment's stretches can lie off the drawn
|
|
50
|
+
* stretch and off the reference's nodes, where the walk goes away and comes
|
|
51
|
+
* back; a contained cut keeps them on it. `leadBp` and `tailBp` are the bp
|
|
52
|
+
* off the reference before a fragment's first stretch and after its last, a
|
|
53
|
+
* contained cut's context. The reference's nodes are those of its fragments,
|
|
54
|
+
* and the drawn stretch spans them, NaN where the reference has no node over
|
|
55
|
+
* the window. `departing` leaves out a walk with a fragment, even where it
|
|
56
|
+
* also jumps the window elsewhere.
|
|
57
|
+
*/
|
|
58
|
+
export interface WalkRuns {
|
|
59
|
+
refName: string;
|
|
60
|
+
drawn: {
|
|
61
|
+
refName: string;
|
|
62
|
+
start: number;
|
|
63
|
+
end: number;
|
|
64
|
+
};
|
|
65
|
+
revisited: number;
|
|
66
|
+
holes: {
|
|
67
|
+
start: number;
|
|
68
|
+
end: number;
|
|
69
|
+
}[];
|
|
70
|
+
reference: {
|
|
71
|
+
names: string[];
|
|
72
|
+
starts: Float64Array;
|
|
73
|
+
lengths: Int32Array;
|
|
74
|
+
};
|
|
75
|
+
walks: {
|
|
76
|
+
names: string[];
|
|
77
|
+
starts: Float64Array;
|
|
78
|
+
ends: Float64Array;
|
|
79
|
+
trimmedBefore: Float64Array;
|
|
80
|
+
trimmedAfter: Float64Array;
|
|
81
|
+
offsets: Int32Array;
|
|
82
|
+
leadBp: Float64Array;
|
|
83
|
+
leadLoaded: Uint8Array;
|
|
84
|
+
tailBp: Float64Array;
|
|
85
|
+
tailLoaded: Uint8Array;
|
|
86
|
+
before: WalkEnds;
|
|
87
|
+
after: WalkEnds;
|
|
88
|
+
};
|
|
89
|
+
stretches: {
|
|
90
|
+
starts: Float64Array;
|
|
91
|
+
bp: Float64Array;
|
|
92
|
+
against: Uint8Array;
|
|
93
|
+
offBefore: Float64Array;
|
|
94
|
+
loaded: Uint8Array;
|
|
95
|
+
};
|
|
96
|
+
departing: {
|
|
97
|
+
names: string[];
|
|
98
|
+
hapStarts: Float64Array;
|
|
99
|
+
ownBp: Float64Array;
|
|
100
|
+
missingBp: Float64Array;
|
|
101
|
+
leavePos: Float64Array;
|
|
102
|
+
leaveReversed: Uint8Array;
|
|
103
|
+
rejoinPos: Float64Array;
|
|
104
|
+
rejoinReversed: Uint8Array;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A file whose header does not state revisited:i:0: a run off the reference
|
|
109
|
+
* may hold a node the reference passes elsewhere, so the runs would not say
|
|
110
|
+
* what the steps do. A host cuts the window instead.
|
|
111
|
+
*/
|
|
112
|
+
export declare class RunsRefusedError extends Error {
|
|
113
|
+
name: string;
|
|
114
|
+
}
|
|
115
|
+
export declare const refuseRevisited: (revisited: number | undefined) => RunsRefusedError | undefined;
|
|
116
|
+
interface OnItem {
|
|
117
|
+
kind: 'on';
|
|
118
|
+
piece: number;
|
|
119
|
+
path: RefPath;
|
|
120
|
+
a: number;
|
|
121
|
+
b: number;
|
|
122
|
+
against: boolean;
|
|
123
|
+
}
|
|
124
|
+
interface OffItem {
|
|
125
|
+
kind: 'off';
|
|
126
|
+
piece: number;
|
|
127
|
+
bp: number[];
|
|
128
|
+
loaded: boolean;
|
|
129
|
+
}
|
|
130
|
+
interface SkipItem {
|
|
131
|
+
kind: 'skip';
|
|
132
|
+
piece: number;
|
|
133
|
+
bp: number;
|
|
134
|
+
}
|
|
135
|
+
type Item = OnItem | OffItem | SkipItem;
|
|
136
|
+
export interface RunsPiece {
|
|
137
|
+
name: string;
|
|
138
|
+
fragStart: number;
|
|
139
|
+
piece: number;
|
|
140
|
+
hapOffset: number;
|
|
141
|
+
items: Item[];
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* A tile's R, its routes and its node lengths, its kept pieces as runs
|
|
145
|
+
* items, the `ref` and `walk` rows decoded and the `abridged` rows listed
|
|
146
|
+
* for blocksPiece, each walk row's span
|
|
147
|
+
*/
|
|
148
|
+
export declare function runsTile(rows: string[][], tileStart: number, keep: ((name: string) => boolean) | undefined): {
|
|
149
|
+
path: RefPath;
|
|
150
|
+
pieces: (RunsPiece & {
|
|
151
|
+
span?: {
|
|
152
|
+
start: number;
|
|
153
|
+
end: number;
|
|
154
|
+
};
|
|
155
|
+
})[];
|
|
156
|
+
abridged: {
|
|
157
|
+
chunkStart: number;
|
|
158
|
+
name: string;
|
|
159
|
+
fragStart: number;
|
|
160
|
+
hapOffset: number;
|
|
161
|
+
piece: number;
|
|
162
|
+
hapBp: number;
|
|
163
|
+
span: {
|
|
164
|
+
start: number;
|
|
165
|
+
end: number;
|
|
166
|
+
};
|
|
167
|
+
abridged: import("./walkRows.ts").Abridged;
|
|
168
|
+
}[];
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* An abridged piece as runs items from its `blocks` row: each block a
|
|
172
|
+
* stretch of the tile's R and each run off R one placeholder
|
|
173
|
+
*/
|
|
174
|
+
export declare function blocksPiece(piece: AbridgedPiece, cols: string[], path: RefPath): RunsPiece;
|
|
175
|
+
export declare const skippedPiece: (piece: AbridgedPiece) => RunsPiece;
|
|
176
|
+
export interface RunsInput {
|
|
177
|
+
refName: string;
|
|
178
|
+
pieces: RunsPiece[];
|
|
179
|
+
records: WalkDeparture[];
|
|
180
|
+
window: {
|
|
181
|
+
start: number;
|
|
182
|
+
end: number;
|
|
183
|
+
};
|
|
184
|
+
contained: boolean;
|
|
185
|
+
context: number;
|
|
186
|
+
holes: Hole[];
|
|
187
|
+
revisited: number;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The runs of a window's pieces, as a cut over the same window keeps them:
|
|
191
|
+
* each line's pieces in a row of piece numbers joined, each kept from its
|
|
192
|
+
* first step on `window` to its last, split where a contained cut splits
|
|
193
|
+
* it, and each fragment's ends from the departure at its first and last
|
|
194
|
+
* steps on the reference, computed in their piece or read from `records`
|
|
195
|
+
*/
|
|
196
|
+
export declare function windowRuns({ refName, pieces, records, window, contained, context, holes, revisited, }: RunsInput): WalkRuns;
|
|
197
|
+
/**
|
|
198
|
+
* A cut's tables read back as runs: each walk-table walk a fragment, its
|
|
199
|
+
* steps on the reference grouped into stretches and those off it into runs,
|
|
200
|
+
* and its ends from the departure table's departure leaving its last step on
|
|
201
|
+
* the reference, or rejoining its first. `holes` are the walk file's
|
|
202
|
+
* header's, which the tables do not state. It does not refuse: it copies the
|
|
203
|
+
* tables' `revisited`, which a caller checks is 0. It is what
|
|
204
|
+
* WalkFile.getRunsForRange returns for a cut that expands nothing.
|
|
205
|
+
*/
|
|
206
|
+
export declare function fragmentRuns({ nodes, walks, departures, revisited }: GraphTables, refName: string, holes: Hole[]): WalkRuns;
|
|
207
|
+
/**
|
|
208
|
+
* A fragment's stretches and runs as the events walkDepartures reads, two
|
|
209
|
+
* stretches with no own bp between them that follow on, holes removed, as
|
|
210
|
+
* one; with `ends`, a departure at either end that rejoins the reference
|
|
211
|
+
* too, as a cut lists it
|
|
212
|
+
*/
|
|
213
|
+
export declare function runEvents(runs: WalkRuns, p: number, ends?: boolean): ChainEvent[];
|
|
214
|
+
export interface RunDeparture {
|
|
215
|
+
leavePos: number;
|
|
216
|
+
rejoinPos: number;
|
|
217
|
+
ownBp: number;
|
|
218
|
+
invertedBp: number;
|
|
219
|
+
loaded: boolean;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* A fragment's departures in its own order, as walkDepartures reads a chain:
|
|
223
|
+
* where it leaves a stretch along its way and rejoins the next, with the bp
|
|
224
|
+
* of its own runs between and of the stretches it takes the other way,
|
|
225
|
+
* `loaded` false where a run between holds a placeholder. Its way is the
|
|
226
|
+
* one walkDepartures reads it in.
|
|
227
|
+
*/
|
|
228
|
+
export declare function runDepartures(runs: WalkRuns, p: number): RunDeparture[];
|
|
229
|
+
export {};
|