@gmod/gfa-tabix 0.0.0-stage → 10.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.
- package/LICENSE +21 -0
- package/README.md +82 -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 +28 -0
- package/esm/index.js +15 -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 +49 -0
- package/esm/walkDepartures.js +272 -0
- package/esm/walkFile.d.ts +240 -0
- package/esm/walkFile.js +1389 -0
- package/esm/walkGaps.d.ts +56 -0
- package/esm/walkGaps.js +345 -0
- package/esm/walkRows.d.ts +305 -0
- package/esm/walkRows.js +1600 -0
- package/package.json +61 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Tabix-indexed file as the node and link index is read: @gmod/tabix's
|
|
3
|
+
* TabixIndexedFile is one. `bytesForRegions` estimates the compressed bytes a
|
|
4
|
+
* read fetches.
|
|
5
|
+
*/
|
|
6
|
+
export interface TabixSource {
|
|
7
|
+
getHeaderLines(opts?: {
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}): Promise<string[]>;
|
|
10
|
+
getLines(refName: string, start: number, end: number, opts: {
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
lineCallback: (line: string) => void;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
getReferenceSequenceNames(opts?: {
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}): Promise<string[]>;
|
|
17
|
+
bytesForRegions?(regions: {
|
|
18
|
+
refName: string;
|
|
19
|
+
start: number;
|
|
20
|
+
end: number;
|
|
21
|
+
}[], opts?: {
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
}): Promise<number>;
|
|
24
|
+
}
|
|
25
|
+
export declare function checkRange(refName: string, start: number, end: number): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @gmod/tabix loops forever on a NaN end and reads nothing for a NaN start
|
|
2
|
+
// (GMOD/tabix-js#157), so every query refuses a range that is not finite first
|
|
3
|
+
export function checkRange(refName, start, end) {
|
|
4
|
+
if (!Number.isFinite(start) || !Number.isFinite(end)) {
|
|
5
|
+
throw new Error(`${refName}:${start}-${end} is not a finite range to query the graph's index for`);
|
|
6
|
+
}
|
|
7
|
+
}
|
package/esm/util.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export interface GraphTables {
|
|
2
|
+
nodes: {
|
|
3
|
+
names: string[];
|
|
4
|
+
lengths: Int32Array;
|
|
5
|
+
refs: Int32Array;
|
|
6
|
+
starts: Float64Array;
|
|
7
|
+
ranks: Int32Array;
|
|
8
|
+
refNames: string[];
|
|
9
|
+
passes?: Int32Array;
|
|
10
|
+
reversed?: Uint8Array;
|
|
11
|
+
placeholders?: Uint8Array;
|
|
12
|
+
};
|
|
13
|
+
links: {
|
|
14
|
+
from: Int32Array;
|
|
15
|
+
to: Int32Array;
|
|
16
|
+
strands: Uint8Array;
|
|
17
|
+
};
|
|
18
|
+
walks: {
|
|
19
|
+
names: string[];
|
|
20
|
+
starts: Float64Array;
|
|
21
|
+
ends: Float64Array;
|
|
22
|
+
offsets: Int32Array;
|
|
23
|
+
steps: Int32Array;
|
|
24
|
+
reversed: Uint8Array;
|
|
25
|
+
refStarts?: Float64Array;
|
|
26
|
+
trimmedBefore?: Float64Array;
|
|
27
|
+
trimmedAfter?: Float64Array;
|
|
28
|
+
abridgedSteps?: Float64Array;
|
|
29
|
+
};
|
|
30
|
+
departures: DepartureTable;
|
|
31
|
+
revisited: number;
|
|
32
|
+
gaps?: GapTable;
|
|
33
|
+
}
|
|
34
|
+
export interface GapTable {
|
|
35
|
+
names: string[];
|
|
36
|
+
walks: Int32Array;
|
|
37
|
+
edges: Uint8Array;
|
|
38
|
+
starts: Float64Array;
|
|
39
|
+
ends: Float64Array;
|
|
40
|
+
segmentOffsets: Int32Array;
|
|
41
|
+
segments: {
|
|
42
|
+
kinds: Uint8Array;
|
|
43
|
+
bp: Float64Array;
|
|
44
|
+
missingBp: Float64Array;
|
|
45
|
+
before: Float64Array;
|
|
46
|
+
after: Float64Array;
|
|
47
|
+
stepOffsets: Int32Array;
|
|
48
|
+
steps: Int32Array;
|
|
49
|
+
reversed: Uint8Array;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export interface DepartureTable {
|
|
53
|
+
names: string[];
|
|
54
|
+
hapStarts: Float64Array;
|
|
55
|
+
ownBp: Float64Array;
|
|
56
|
+
missingBp: Float64Array;
|
|
57
|
+
leavePos: Float64Array;
|
|
58
|
+
leaveReversed: Uint8Array;
|
|
59
|
+
leavePasses: Int32Array;
|
|
60
|
+
rejoinPos: Float64Array;
|
|
61
|
+
rejoinReversed: Uint8Array;
|
|
62
|
+
rejoinPasses: Int32Array;
|
|
63
|
+
fromSteps: Uint8Array;
|
|
64
|
+
offsets: Int32Array;
|
|
65
|
+
steps: Int32Array;
|
|
66
|
+
reversed: Uint8Array;
|
|
67
|
+
abridgedSteps?: Float64Array;
|
|
68
|
+
breakAt?: Int32Array;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A window too large to cut. `regionTooLarge` and the name are what JBrowse
|
|
72
|
+
* and @jbrowse/bandage-core read a zoom-in notice by; `fitsBp` is about how
|
|
73
|
+
* wide a window would fit. `zoomHelps` is false where no narrower window
|
|
74
|
+
* fits. Over a byte budget, `bytes` is what the window's read would fetch,
|
|
75
|
+
* the byte budget that would load it.
|
|
76
|
+
*/
|
|
77
|
+
export declare class RegionTooLargeError extends Error {
|
|
78
|
+
readonly regionTooLarge = true;
|
|
79
|
+
name: string;
|
|
80
|
+
readonly limit: number;
|
|
81
|
+
readonly windowBp: number;
|
|
82
|
+
readonly fitsBp: number;
|
|
83
|
+
readonly zoomHelps: boolean;
|
|
84
|
+
readonly bytes?: number;
|
|
85
|
+
constructor(message: string, limit: number, windowBp: number, fitsBp: number, overBytes?: {
|
|
86
|
+
bytes: number;
|
|
87
|
+
zoomHelps?: boolean;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
export declare function panSNSample(refName: string): string;
|
|
91
|
+
export declare function panSNContig(refName: string): string;
|
|
92
|
+
export declare function panSNHaplotype(refName: string): string | undefined;
|
|
93
|
+
export declare function panSNHaplotypeOrSample(refName: string): string;
|
|
94
|
+
export declare function panSNMatchesPrefix(refName: string, prefix: string | undefined): boolean;
|
|
95
|
+
export declare function bpString(bp: number): string;
|
package/esm/util.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A window too large to cut. `regionTooLarge` and the name are what JBrowse
|
|
3
|
+
* and @jbrowse/bandage-core read a zoom-in notice by; `fitsBp` is about how
|
|
4
|
+
* wide a window would fit. `zoomHelps` is false where no narrower window
|
|
5
|
+
* fits. Over a byte budget, `bytes` is what the window's read would fetch,
|
|
6
|
+
* the byte budget that would load it.
|
|
7
|
+
*/
|
|
8
|
+
export class RegionTooLargeError extends Error {
|
|
9
|
+
constructor(message, limit, windowBp, fitsBp, overBytes) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.regionTooLarge = true;
|
|
12
|
+
this.name = 'NodeLimitError';
|
|
13
|
+
this.limit = limit;
|
|
14
|
+
this.windowBp = windowBp;
|
|
15
|
+
this.fitsBp = fitsBp;
|
|
16
|
+
this.zoomHelps = overBytes === undefined || overBytes.zoomHelps === true;
|
|
17
|
+
if (overBytes) {
|
|
18
|
+
this.bytes = overBytes.bytes;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const SEP = '#';
|
|
23
|
+
// `grape#1#chr1` -> `grape`
|
|
24
|
+
export function panSNSample(refName) {
|
|
25
|
+
return refName.split(SEP)[0];
|
|
26
|
+
}
|
|
27
|
+
// `grape#1#chr1` and `grape#chr1` -> `chr1`
|
|
28
|
+
export function panSNContig(refName) {
|
|
29
|
+
const parts = refName.split(SEP);
|
|
30
|
+
return parts.length >= 3
|
|
31
|
+
? parts.slice(2).join(SEP)
|
|
32
|
+
: parts.length === 2
|
|
33
|
+
? parts[1]
|
|
34
|
+
: refName;
|
|
35
|
+
}
|
|
36
|
+
export function panSNHaplotype(refName) {
|
|
37
|
+
const parts = refName.split(SEP);
|
|
38
|
+
return parts.length >= 3 ? `${parts[0]}${SEP}${parts[1]}` : undefined;
|
|
39
|
+
}
|
|
40
|
+
// What a walk file's header lists a path under: `grape#1#chr1` -> `grape#1`,
|
|
41
|
+
// and `grape#chr1`, which has no haplotype field, -> `grape`
|
|
42
|
+
export function panSNHaplotypeOrSample(refName) {
|
|
43
|
+
var _a;
|
|
44
|
+
return (_a = panSNHaplotype(refName)) !== null && _a !== void 0 ? _a : panSNSample(refName);
|
|
45
|
+
}
|
|
46
|
+
export function panSNMatchesPrefix(refName, prefix) {
|
|
47
|
+
return (prefix !== undefined &&
|
|
48
|
+
(refName === prefix || refName.startsWith(prefix + SEP)));
|
|
49
|
+
}
|
|
50
|
+
const precise = (n) => Number.parseFloat(n.toPrecision(3));
|
|
51
|
+
// `1.5Kbp`, `12Mbp`, `850bp`, as JBrowse writes a span
|
|
52
|
+
export function bpString(bp) {
|
|
53
|
+
const mb = precise(bp / 1000000);
|
|
54
|
+
return mb >= 1
|
|
55
|
+
? `${mb.toLocaleString('en-US')}Mbp`
|
|
56
|
+
: bp >= 1000
|
|
57
|
+
? `${precise(bp / 1000).toLocaleString('en-US')}Kbp`
|
|
58
|
+
: `${Math.floor(bp)}bp`;
|
|
59
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import type { Abridged, WalkRow } from './walkRows.ts';
|
|
2
|
+
export declare const NONE = -1;
|
|
3
|
+
export interface Route {
|
|
4
|
+
entry: number;
|
|
5
|
+
interior: number[];
|
|
6
|
+
exit: number;
|
|
7
|
+
}
|
|
8
|
+
export interface PlacedNode {
|
|
9
|
+
refName: string;
|
|
10
|
+
start: number;
|
|
11
|
+
end: number;
|
|
12
|
+
rank: number;
|
|
13
|
+
passes: number;
|
|
14
|
+
reversed?: boolean;
|
|
15
|
+
placeholder?: true;
|
|
16
|
+
}
|
|
17
|
+
export declare const idOf: (handle: number) => number;
|
|
18
|
+
export declare function checkedId(id: number): number;
|
|
19
|
+
export declare function tokens(field: string, previous: {
|
|
20
|
+
id: number;
|
|
21
|
+
}, out: number[]): number[];
|
|
22
|
+
export declare function numbers(field: string): number[];
|
|
23
|
+
export declare function passCounts(cols: string[], n: number): number[];
|
|
24
|
+
export declare function canonicalLink(a: number, b: number): [number, number];
|
|
25
|
+
export declare function parseCopy(token: string): [number, number];
|
|
26
|
+
export declare class RefPath {
|
|
27
|
+
readonly handles: number[];
|
|
28
|
+
readonly before: number[];
|
|
29
|
+
readonly starts: number[];
|
|
30
|
+
readonly occurrences: Map<number, number[]>;
|
|
31
|
+
private held?;
|
|
32
|
+
private typed;
|
|
33
|
+
columns(): {
|
|
34
|
+
ids: Int32Array<ArrayBuffer>;
|
|
35
|
+
rev: Uint8Array<ArrayBuffer>;
|
|
36
|
+
bp: Int32Array<ArrayBuffer>;
|
|
37
|
+
starts: Float64Array<ArrayBuffer>;
|
|
38
|
+
};
|
|
39
|
+
add(handles: number[], lengths: number[], start: number): void;
|
|
40
|
+
bp(i: number): number;
|
|
41
|
+
first(handle: number): number | undefined;
|
|
42
|
+
copy(handle: number, k: number): number | undefined;
|
|
43
|
+
nearest(handle: number, i: number): number | undefined;
|
|
44
|
+
reach(i: number, h: number, target: number): number | undefined;
|
|
45
|
+
handleAt(i: number, forward: boolean): number;
|
|
46
|
+
startingAt(start: number): number | undefined;
|
|
47
|
+
endingAt(end: number): number | undefined;
|
|
48
|
+
past(i: number, bp: number): number | undefined;
|
|
49
|
+
end(i: number): number;
|
|
50
|
+
hull(span: {
|
|
51
|
+
start: number;
|
|
52
|
+
end: number;
|
|
53
|
+
}): {
|
|
54
|
+
start: number;
|
|
55
|
+
end: number;
|
|
56
|
+
} | undefined;
|
|
57
|
+
}
|
|
58
|
+
interface Visitor {
|
|
59
|
+
step(handle: number, i: number): void;
|
|
60
|
+
stretch(from: number, to: number, forward: boolean): void;
|
|
61
|
+
route(index: number, flip: boolean): boolean;
|
|
62
|
+
}
|
|
63
|
+
export declare class WalkRowError extends Error {
|
|
64
|
+
}
|
|
65
|
+
export declare const interiorAt: (route: Route, flip: boolean, k: number) => number;
|
|
66
|
+
export declare function parseChoices(field: string): number[];
|
|
67
|
+
export declare function traverse(path: RefPath, routes: Route[], start: number, startCopy: number, choices: number[], n: number, visit: Visitor): void;
|
|
68
|
+
export interface DecodedChunk {
|
|
69
|
+
sequences: Map<number, string>;
|
|
70
|
+
rows: WalkRow[];
|
|
71
|
+
abridged: AbridgedPiece[];
|
|
72
|
+
nodes: Map<number, PlacedNode>;
|
|
73
|
+
revisits: (PlacedNode & {
|
|
74
|
+
id: number;
|
|
75
|
+
})[];
|
|
76
|
+
path: RefPath;
|
|
77
|
+
}
|
|
78
|
+
export declare function abridgedPiece(cols: string[], tileStart: number): {
|
|
79
|
+
chunkStart: number;
|
|
80
|
+
name: string;
|
|
81
|
+
fragStart: number;
|
|
82
|
+
hapOffset: number;
|
|
83
|
+
piece: number;
|
|
84
|
+
hapBp: number;
|
|
85
|
+
span: {
|
|
86
|
+
start: number;
|
|
87
|
+
end: number;
|
|
88
|
+
};
|
|
89
|
+
abridged: Abridged;
|
|
90
|
+
};
|
|
91
|
+
export type AbridgedPiece = ReturnType<typeof abridgedPiece>;
|
|
92
|
+
export declare const SKIPPED: number;
|
|
93
|
+
export declare function parseBlocks(cols: string[]): {
|
|
94
|
+
before: number;
|
|
95
|
+
after: number;
|
|
96
|
+
begins: number[];
|
|
97
|
+
lengths: number[];
|
|
98
|
+
against: boolean[];
|
|
99
|
+
off: number[];
|
|
100
|
+
end: number;
|
|
101
|
+
bp: number;
|
|
102
|
+
};
|
|
103
|
+
export type PieceBlocks = ReturnType<typeof parseBlocks>;
|
|
104
|
+
export interface OwnRun {
|
|
105
|
+
key: string;
|
|
106
|
+
start: number;
|
|
107
|
+
end: number;
|
|
108
|
+
trailing: boolean;
|
|
109
|
+
pos: number;
|
|
110
|
+
reversed: boolean;
|
|
111
|
+
}
|
|
112
|
+
export declare function ownStretch(piece: Pick<AbridgedPiece, 'name' | 'piece' | 'hapOffset' | 'hapBp'>, record: {
|
|
113
|
+
hapStart: number;
|
|
114
|
+
ownBp: number;
|
|
115
|
+
}): {
|
|
116
|
+
start: number;
|
|
117
|
+
end: number;
|
|
118
|
+
trailing: boolean;
|
|
119
|
+
} | undefined;
|
|
120
|
+
export declare const bpRow: (piece: AbridgedPiece) => {
|
|
121
|
+
chunkStart: number;
|
|
122
|
+
name: string;
|
|
123
|
+
fragStart: number;
|
|
124
|
+
hapOffset: number;
|
|
125
|
+
piece: number;
|
|
126
|
+
n: number;
|
|
127
|
+
steps: {
|
|
128
|
+
ids: Int32Array<ArrayBuffer>;
|
|
129
|
+
rev: Uint8Array<ArrayBuffer>;
|
|
130
|
+
refStarts: Float64Array<ArrayBuffer>;
|
|
131
|
+
against: Uint8Array<ArrayBuffer>;
|
|
132
|
+
bp: Int32Array<ArrayBuffer>;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
export declare function ownRunsRow(piece: AbridgedPiece, runs: OwnRun[], path: RefPath, placeholder: (start: number, end: number) => number): {
|
|
136
|
+
row: WalkRow;
|
|
137
|
+
nodes: Map<number, PlacedNode>;
|
|
138
|
+
};
|
|
139
|
+
export declare function blocksOver(blocks: PieceBlocks, span: {
|
|
140
|
+
start: number;
|
|
141
|
+
end: number;
|
|
142
|
+
}): {
|
|
143
|
+
first: number;
|
|
144
|
+
last: number;
|
|
145
|
+
};
|
|
146
|
+
export declare function blockPositions(piece: AbridgedPiece, blocks: PieceBlocks, path: RefPath): {
|
|
147
|
+
from: Int32Array<ArrayBuffer>;
|
|
148
|
+
to: Int32Array<ArrayBuffer>;
|
|
149
|
+
};
|
|
150
|
+
export interface PieceEnds {
|
|
151
|
+
name: string;
|
|
152
|
+
fragStart: number;
|
|
153
|
+
piece: number;
|
|
154
|
+
first: number;
|
|
155
|
+
last: number;
|
|
156
|
+
}
|
|
157
|
+
export declare function blockLinks(cols: string[], path: RefPath, rowStarts: number[]): {
|
|
158
|
+
links: number[];
|
|
159
|
+
ends: PieceEnds;
|
|
160
|
+
};
|
|
161
|
+
export declare function tileLinks(rows: string[][], path: RefPath): {
|
|
162
|
+
links: number[];
|
|
163
|
+
ends: PieceEnds[];
|
|
164
|
+
rowStarts: number[];
|
|
165
|
+
};
|
|
166
|
+
export declare function unloadedRow(piece: AbridgedPiece, blocks: PieceBlocks, path: RefPath, over: {
|
|
167
|
+
start: number;
|
|
168
|
+
end: number;
|
|
169
|
+
}, core: [number, number] | undefined, placeholder: (start: number, end: number) => number): {
|
|
170
|
+
row: WalkRow;
|
|
171
|
+
nodes: Map<number, PlacedNode>;
|
|
172
|
+
};
|
|
173
|
+
export declare const refRows: (rows: string[][]) => string[][];
|
|
174
|
+
/**
|
|
175
|
+
* What a cut's decode of a tile reads, and what it surely keeps of the tile
|
|
176
|
+
* where its extent lies strictly inside the stretch the cut draws, from the
|
|
177
|
+
* tile's lines before any is decoded; undefined where the decode would
|
|
178
|
+
* refuse a row of a walk `keep` takes.
|
|
179
|
+
*
|
|
180
|
+
* `kept` is the steps of each `ref` and `walk` row of a walk `keep` takes,
|
|
181
|
+
* less the steps off R before a walk row's first step on R and after its
|
|
182
|
+
* last. Every step a row places on R lies within its tile's extent, so a cut
|
|
183
|
+
* over the extent keeps each row from its first step on R to its last, and
|
|
184
|
+
* every step between, as one stretch of a fragment, whether it is contained
|
|
185
|
+
* or not. The steps off R at a row's ends are kept only if a neighbouring
|
|
186
|
+
* piece reaches the window, so they are not counted. An `abridged` row
|
|
187
|
+
* counts nothing here, since a cut builds the piece from its blocks row with
|
|
188
|
+
* a placeholder for each run off R, in fewer steps than its `nsteps`
|
|
189
|
+
* (blocksSteps counts those from the blocks row), and a departure's own
|
|
190
|
+
* steps are not counted either. So `kept` never exceeds the steps of the
|
|
191
|
+
* cut's fragments, which its step budget counts with the departures' own
|
|
192
|
+
* steps.
|
|
193
|
+
*
|
|
194
|
+
* `n` and `interior` bound the steps the decode's rows give the read budget,
|
|
195
|
+
* and those of them off R: each `ref` and `walk` row's own, and an abridged
|
|
196
|
+
* piece's `nsteps`, all off R where `expand` reads it from its detail
|
|
197
|
+
* record, and else as many on R, no fewer than the row built from its blocks
|
|
198
|
+
* row or its bp holds. `blocks` says the cut reads a blocks row for one of
|
|
199
|
+
* the tile's pieces, and `expanded` a detail record.
|
|
200
|
+
*/
|
|
201
|
+
export declare function tileSteps(lines: string[], keep: ((name: string) => boolean) | undefined, expand: ((name: string) => boolean) | undefined): {
|
|
202
|
+
kept: number;
|
|
203
|
+
n: number;
|
|
204
|
+
interior: number;
|
|
205
|
+
blocks: boolean;
|
|
206
|
+
expanded: boolean;
|
|
207
|
+
} | undefined;
|
|
208
|
+
export declare function statedAbridgedSteps(lines: string[], keep: ((name: string) => boolean) | undefined, expand: ((name: string) => boolean) | undefined): number;
|
|
209
|
+
/**
|
|
210
|
+
* The steps a cut over `drawn` surely keeps of the pieces a tile abridges
|
|
211
|
+
* and the cut builds from their blocks rows, from the tile's lines and its
|
|
212
|
+
* blocks unit's before any is decoded; undefined where a piece has no
|
|
213
|
+
* blocks row, or one the cut refuses.
|
|
214
|
+
*
|
|
215
|
+
* A cut builds whole each block of such a piece that lies over the stretch
|
|
216
|
+
* it draws, a step for each step of R under the block, and a placeholder
|
|
217
|
+
* for the run off R between two blocks it builds whole. It keeps every step
|
|
218
|
+
* a row places on that stretch, and every step between two of them with no
|
|
219
|
+
* step onto R off the stretch between, contained or not. So the count is
|
|
220
|
+
* the steps of R under each block wholly inside `drawn`, and one for each
|
|
221
|
+
* run off R between two such blocks, one after the other. A run off R at a
|
|
222
|
+
* piece's end is kept only where a neighbouring piece reaches the window,
|
|
223
|
+
* so it is not counted.
|
|
224
|
+
*/
|
|
225
|
+
export declare function blocksSteps(lines: string[], blocksLines: string[], drawn: {
|
|
226
|
+
start: number;
|
|
227
|
+
end: number;
|
|
228
|
+
}, keep: ((name: string) => boolean) | undefined, expand: ((name: string) => boolean) | undefined): number | undefined;
|
|
229
|
+
export declare function tileNodeIds(lines: string[], into: Set<number>): Set<number>;
|
|
230
|
+
export interface ChunkRef {
|
|
231
|
+
path: RefPath;
|
|
232
|
+
lengths: Map<number, number>;
|
|
233
|
+
}
|
|
234
|
+
export declare function chunkRef(rows: string[][]): ChunkRef;
|
|
235
|
+
/**
|
|
236
|
+
* Decodes one tile's rows, each split on tabs, the tile starting at
|
|
237
|
+
* `tileStart` nominally. `keep` names the walk rows whose steps a cut wants,
|
|
238
|
+
* undefined for every one. Given `ref`, the rows are a detail record decoded
|
|
239
|
+
* against that tile's R, and the result leaves out R's rows, nodes, ends and
|
|
240
|
+
* bases, which the tile's own decode gave.
|
|
241
|
+
*/
|
|
242
|
+
export declare function decodeChunk(rows: string[][], tileStart: number, keep: ((name: string) => boolean) | undefined, withSequences?: boolean, ref?: ChunkRef): DecodedChunk;
|
|
243
|
+
export declare function referenceNodes(rows: string[][]): (PlacedNode & {
|
|
244
|
+
id: number;
|
|
245
|
+
})[];
|
|
246
|
+
export {};
|