@jbrowse/cigar-utils 4.1.14
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 +201 -0
- package/README.md +167 -0
- package/esm/bamSeqDecoder.d.ts +3 -0
- package/esm/bamSeqDecoder.js +10 -0
- package/esm/bamSeqEncoder.d.ts +8 -0
- package/esm/bamSeqEncoder.js +33 -0
- package/esm/buildReadVsRefFeatures.d.ts +57 -0
- package/esm/buildReadVsRefFeatures.js +66 -0
- package/esm/cigarConstants.d.ts +11 -0
- package/esm/cigarConstants.js +15 -0
- package/esm/cigarRenderedSegments.d.ts +13 -0
- package/esm/cigarRenderedSegments.js +84 -0
- package/esm/cigarReorient.d.ts +2 -0
- package/esm/cigarReorient.js +29 -0
- package/esm/cigarToMismatches2.d.ts +2 -0
- package/esm/cigarToMismatches2.js +90 -0
- package/esm/cigarWalkStart.d.ts +4 -0
- package/esm/cigarWalkStart.js +54 -0
- package/esm/csOps.d.ts +47 -0
- package/esm/csOps.js +152 -0
- package/esm/csToCigar.d.ts +1 -0
- package/esm/csToCigar.js +43 -0
- package/esm/getNextRefPos.d.ts +31 -0
- package/esm/getNextRefPos.js +69 -0
- package/esm/index.d.ts +24 -0
- package/esm/index.js +24 -0
- package/esm/mdToMismatches2.d.ts +2 -0
- package/esm/mdToMismatches2.js +108 -0
- package/esm/mismatchCallback.d.ts +29 -0
- package/esm/mismatchCallback.js +20 -0
- package/esm/mismatchParser.d.ts +79 -0
- package/esm/mismatchParser.js +238 -0
- package/esm/mismatchTypes.d.ts +27 -0
- package/esm/mismatchTypes.js +1 -0
- package/esm/numericCigarHasSkip.d.ts +1 -0
- package/esm/numericCigarHasSkip.js +11 -0
- package/esm/numericCigarToString.d.ts +1 -0
- package/esm/numericCigarToString.js +13 -0
- package/esm/orientAlignment.d.ts +9 -0
- package/esm/orientAlignment.js +26 -0
- package/esm/pafIdentity.d.ts +20 -0
- package/esm/pafIdentity.js +31 -0
- package/esm/readEndpoints.d.ts +18 -0
- package/esm/readEndpoints.js +69 -0
- package/esm/samFlags.d.ts +50 -0
- package/esm/samFlags.js +89 -0
- package/package.json +42 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function readTrailingBp(strand: number, start: number, end: number): number;
|
|
2
|
+
export declare function readLeadingBp(strand: number, start: number, end: number): number;
|
|
3
|
+
export declare function readTrailingBodyDir(strand: number): -1 | 1;
|
|
4
|
+
export declare function readLeadingBodyDir(strand: number): -1 | 1;
|
|
5
|
+
export declare function connectionEndpointBps({ s1, start1, end1, s2, start2, end2, isSplit, }: {
|
|
6
|
+
s1: number;
|
|
7
|
+
start1: number;
|
|
8
|
+
end1: number;
|
|
9
|
+
s2: number;
|
|
10
|
+
start2: number;
|
|
11
|
+
end2: number;
|
|
12
|
+
isSplit: boolean;
|
|
13
|
+
}): {
|
|
14
|
+
bp1: number;
|
|
15
|
+
bp2: number;
|
|
16
|
+
dir1: number;
|
|
17
|
+
dir2: number;
|
|
18
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Split-read junction endpoints, in read (5'→3') coordinates. A read traversing
|
|
2
|
+
// segments in read order joins at the trailing (3') edge of one segment and the
|
|
3
|
+
// leading (5') edge of the next; on the reference, which genomic coordinate that
|
|
4
|
+
// maps to flips with strand. Shared by the alignments arc/linked-read renderers
|
|
5
|
+
// and breakpoint-split-view's AlignmentConnections, so the rule lives in one
|
|
6
|
+
// place.
|
|
7
|
+
// Trailing (3') edge of a segment in read coordinates. Also the mate 3' end for
|
|
8
|
+
// a paired read's endpoint.
|
|
9
|
+
export function readTrailingBp(strand, start, end) {
|
|
10
|
+
return strand === -1 ? start : end;
|
|
11
|
+
}
|
|
12
|
+
// Leading (5') edge of the next segment in read coordinates — the far side of a
|
|
13
|
+
// split junction from the previous segment's trailing edge.
|
|
14
|
+
export function readLeadingBp(strand, start, end) {
|
|
15
|
+
return strand === -1 ? end : start;
|
|
16
|
+
}
|
|
17
|
+
// Which way the segment's own aligned body lies from the edge above, as a
|
|
18
|
+
// genomic direction: +1 toward higher coordinates, -1 toward lower. This is the
|
|
19
|
+
// breakend orientation — "which side of this junction is kept" — and it is
|
|
20
|
+
// exactly the choice of edge said the other way round, which is why each of
|
|
21
|
+
// these mirrors its `…Bp` partner's ternary line for line rather than being
|
|
22
|
+
// written as `-strand` / `strand`. A strand of 0 (a feature with no strand at
|
|
23
|
+
// all) reads as forward in both, so the pair cannot disagree about it.
|
|
24
|
+
//
|
|
25
|
+
// The direction is a property of the JUNCTION, not of the read that crossed it:
|
|
26
|
+
// sequencing the same molecule from the other end swaps which segment is
|
|
27
|
+
// trailing and flips both strands, and the two flips cancel. That is what makes
|
|
28
|
+
// it safe for a mark drawn from arcs several reads were coalesced into.
|
|
29
|
+
//
|
|
30
|
+
// WHICH OF THE TWO A CALLER WANTS IS DECIDED BY ITS ANCHOR, not by its strand,
|
|
31
|
+
// and that is the thing to get right. A mark placed AT the junction takes the
|
|
32
|
+
// one that matches its edge, which is what `connectionEndpointBps` pairs up
|
|
33
|
+
// below. A mark placed at the fragment's outer edge — a mate-link arc, whose
|
|
34
|
+
// endpoints are the two reads' 5' ends rather than the junction between them —
|
|
35
|
+
// is a read length OUTSIDE the junction with the read's body pointing back at
|
|
36
|
+
// it, so it wants the OTHER one: `readTrailingBodyDir` beside a
|
|
37
|
+
// `readLeadingBp`. Pairing the mirrored names there instead drew an FR pair's
|
|
38
|
+
// feet inward, which the breakend grammar spells "duplication", while a split
|
|
39
|
+
// read over the identical junction drew them outward.
|
|
40
|
+
export function readTrailingBodyDir(strand) {
|
|
41
|
+
return strand === -1 ? 1 : -1;
|
|
42
|
+
}
|
|
43
|
+
export function readLeadingBodyDir(strand) {
|
|
44
|
+
return strand === -1 ? -1 : 1;
|
|
45
|
+
}
|
|
46
|
+
// The two absolute-bp endpoints of a resolved connection, given each segment's
|
|
47
|
+
// strand and genomic [start, end]. Endpoint 1 is always its segment's read-
|
|
48
|
+
// trailing (3') edge. Endpoint 2 is the next segment's read-leading (5') edge
|
|
49
|
+
// for a split junction (so a fwd→rev inversion lands on the breakpoint, not the
|
|
50
|
+
// far edge of the reverse segment), or the mate's read-trailing (3') edge for a
|
|
51
|
+
// pair. This is the single endpoint rule shared by every connector renderer —
|
|
52
|
+
// the alignments linked-read overlay + coverage arcs and breakpoint-split-view's
|
|
53
|
+
// AlignmentConnections — so it can't drift between them.
|
|
54
|
+
//
|
|
55
|
+
// It returns the two BODY DIRECTIONS with the two bps, and the name is older
|
|
56
|
+
// than that half. They ship together because they are one decision: `dir1` is
|
|
57
|
+
// trailing iff `bp1` is, so a second function asking `isSplit` again is the
|
|
58
|
+
// drift this file exists to prevent. A caller wanting only the coordinates
|
|
59
|
+
// ignores them.
|
|
60
|
+
export function connectionEndpointBps({ s1, start1, end1, s2, start2, end2, isSplit, }) {
|
|
61
|
+
return {
|
|
62
|
+
bp1: readTrailingBp(s1, start1, end1),
|
|
63
|
+
bp2: isSplit
|
|
64
|
+
? readLeadingBp(s2, start2, end2)
|
|
65
|
+
: readTrailingBp(s2, start2, end2),
|
|
66
|
+
dir1: readTrailingBodyDir(s1),
|
|
67
|
+
dir2: isSplit ? readLeadingBodyDir(s2) : readTrailingBodyDir(s2),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SAM flag bit constants for alignment records.
|
|
3
|
+
* See SAM specification: https://samtools.github.io/hts-specs/SAMv1.pdf
|
|
4
|
+
*/
|
|
5
|
+
/** Read is paired in sequencing */
|
|
6
|
+
export declare const SAM_FLAG_PAIRED = 1;
|
|
7
|
+
/** Read is mapped in a proper pair */
|
|
8
|
+
export declare const SAM_FLAG_PROPER_PAIR = 2;
|
|
9
|
+
/** Read is unmapped */
|
|
10
|
+
export declare const SAM_FLAG_UNMAPPED = 4;
|
|
11
|
+
/** Mate is unmapped */
|
|
12
|
+
export declare const SAM_FLAG_MATE_UNMAPPED = 8;
|
|
13
|
+
/** Read is on reverse strand */
|
|
14
|
+
export declare const SAM_FLAG_REVERSE = 16;
|
|
15
|
+
/** Mate is on reverse strand */
|
|
16
|
+
export declare const SAM_FLAG_MATE_REVERSE = 32;
|
|
17
|
+
/** Read is first in pair */
|
|
18
|
+
export declare const SAM_FLAG_FIRST_IN_PAIR = 64;
|
|
19
|
+
/** Read is second in pair */
|
|
20
|
+
export declare const SAM_FLAG_SECOND_IN_PAIR = 128;
|
|
21
|
+
/** Secondary alignment (not primary) */
|
|
22
|
+
export declare const SAM_FLAG_SECONDARY = 256;
|
|
23
|
+
/** Read fails platform/vendor quality checks */
|
|
24
|
+
export declare const SAM_FLAG_FAILS_QC = 512;
|
|
25
|
+
/** Read is PCR or optical duplicate */
|
|
26
|
+
export declare const SAM_FLAG_DUPLICATE = 1024;
|
|
27
|
+
/** Supplementary alignment (chimeric/split read) */
|
|
28
|
+
export declare const SAM_FLAG_SUPPLEMENTARY = 2048;
|
|
29
|
+
/**
|
|
30
|
+
* SAM flag bit labels in canonical order: index `i` is the label for bit
|
|
31
|
+
* `1 << i`. Shared by the feature-details flag list and the filter-by-tag
|
|
32
|
+
* dialog so the bit order can't drift between them.
|
|
33
|
+
*/
|
|
34
|
+
export declare const samFlagLabels: readonly ['read paired', 'read mapped in proper pair', 'read unmapped', 'mate unmapped', 'read reverse strand', 'mate reverse strand', 'first in pair', 'second in pair', 'not primary alignment', 'read fails quality checks', 'read is PCR or optical duplicate', 'supplementary alignment'];
|
|
35
|
+
/**
|
|
36
|
+
* Human-readable description for each SAM flag bit, in the same canonical order
|
|
37
|
+
* as `samFlagLabels` (index `i` describes bit `1 << i`). Surfaced as tooltips in
|
|
38
|
+
* the feature-details flag list so the terse labels are self-explanatory.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* The name samtools accepts for each SAM flag bit, in the same canonical order
|
|
42
|
+
* as `samFlagLabels` (index `i` names bit `1 << i`).
|
|
43
|
+
*
|
|
44
|
+
* These are `samtools view -f`/`-F`'s own spellings, so a mask written by hand
|
|
45
|
+
* reads the way the command line a reader already knows writes it. Separate
|
|
46
|
+
* from `samFlagLabels`, which is prose for a checkbox column and would make a
|
|
47
|
+
* poor token.
|
|
48
|
+
*/
|
|
49
|
+
export declare const samFlagNames: readonly ['PAIRED', 'PROPER_PAIR', 'UNMAP', 'MUNMAP', 'REVERSE', 'MREVERSE', 'READ1', 'READ2', 'SECONDARY', 'QCFAIL', 'DUP', 'SUPPLEMENTARY'];
|
|
50
|
+
export declare const samFlagDescriptions: readonly ['Template has multiple segments in sequencing (paired-end / mate-pair)', 'Each segment is properly aligned according to the aligner', 'This segment is unmapped', 'The mate / next segment in the template is unmapped', 'SEQ is reverse-complemented (read aligns to the reverse strand)', 'SEQ of the mate / next segment is reverse-complemented', 'This is the first segment in the template', 'This is the last segment in the template', 'Secondary alignment (not the primary linear representation of the read)', 'Read did not pass filters such as platform / vendor quality controls', 'PCR or optical duplicate', 'Supplementary alignment (part of a chimeric / split read)'];
|
package/esm/samFlags.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SAM flag bit constants for alignment records.
|
|
3
|
+
* See SAM specification: https://samtools.github.io/hts-specs/SAMv1.pdf
|
|
4
|
+
*/
|
|
5
|
+
/** Read is paired in sequencing */
|
|
6
|
+
export const SAM_FLAG_PAIRED = 1;
|
|
7
|
+
/** Read is mapped in a proper pair */
|
|
8
|
+
export const SAM_FLAG_PROPER_PAIR = 2;
|
|
9
|
+
/** Read is unmapped */
|
|
10
|
+
export const SAM_FLAG_UNMAPPED = 4;
|
|
11
|
+
/** Mate is unmapped */
|
|
12
|
+
export const SAM_FLAG_MATE_UNMAPPED = 8;
|
|
13
|
+
/** Read is on reverse strand */
|
|
14
|
+
export const SAM_FLAG_REVERSE = 16;
|
|
15
|
+
/** Mate is on reverse strand */
|
|
16
|
+
export const SAM_FLAG_MATE_REVERSE = 32;
|
|
17
|
+
/** Read is first in pair */
|
|
18
|
+
export const SAM_FLAG_FIRST_IN_PAIR = 64;
|
|
19
|
+
/** Read is second in pair */
|
|
20
|
+
export const SAM_FLAG_SECOND_IN_PAIR = 128;
|
|
21
|
+
/** Secondary alignment (not primary) */
|
|
22
|
+
export const SAM_FLAG_SECONDARY = 256;
|
|
23
|
+
/** Read fails platform/vendor quality checks */
|
|
24
|
+
export const SAM_FLAG_FAILS_QC = 512;
|
|
25
|
+
/** Read is PCR or optical duplicate */
|
|
26
|
+
export const SAM_FLAG_DUPLICATE = 1024;
|
|
27
|
+
/** Supplementary alignment (chimeric/split read) */
|
|
28
|
+
export const SAM_FLAG_SUPPLEMENTARY = 2048;
|
|
29
|
+
/**
|
|
30
|
+
* SAM flag bit labels in canonical order: index `i` is the label for bit
|
|
31
|
+
* `1 << i`. Shared by the feature-details flag list and the filter-by-tag
|
|
32
|
+
* dialog so the bit order can't drift between them.
|
|
33
|
+
*/
|
|
34
|
+
export const samFlagLabels = [
|
|
35
|
+
'read paired',
|
|
36
|
+
'read mapped in proper pair',
|
|
37
|
+
'read unmapped',
|
|
38
|
+
'mate unmapped',
|
|
39
|
+
'read reverse strand',
|
|
40
|
+
'mate reverse strand',
|
|
41
|
+
'first in pair',
|
|
42
|
+
'second in pair',
|
|
43
|
+
'not primary alignment',
|
|
44
|
+
'read fails quality checks',
|
|
45
|
+
'read is PCR or optical duplicate',
|
|
46
|
+
'supplementary alignment',
|
|
47
|
+
];
|
|
48
|
+
/**
|
|
49
|
+
* Human-readable description for each SAM flag bit, in the same canonical order
|
|
50
|
+
* as `samFlagLabels` (index `i` describes bit `1 << i`). Surfaced as tooltips in
|
|
51
|
+
* the feature-details flag list so the terse labels are self-explanatory.
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* The name samtools accepts for each SAM flag bit, in the same canonical order
|
|
55
|
+
* as `samFlagLabels` (index `i` names bit `1 << i`).
|
|
56
|
+
*
|
|
57
|
+
* These are `samtools view -f`/`-F`'s own spellings, so a mask written by hand
|
|
58
|
+
* reads the way the command line a reader already knows writes it. Separate
|
|
59
|
+
* from `samFlagLabels`, which is prose for a checkbox column and would make a
|
|
60
|
+
* poor token.
|
|
61
|
+
*/
|
|
62
|
+
export const samFlagNames = [
|
|
63
|
+
'PAIRED',
|
|
64
|
+
'PROPER_PAIR',
|
|
65
|
+
'UNMAP',
|
|
66
|
+
'MUNMAP',
|
|
67
|
+
'REVERSE',
|
|
68
|
+
'MREVERSE',
|
|
69
|
+
'READ1',
|
|
70
|
+
'READ2',
|
|
71
|
+
'SECONDARY',
|
|
72
|
+
'QCFAIL',
|
|
73
|
+
'DUP',
|
|
74
|
+
'SUPPLEMENTARY',
|
|
75
|
+
];
|
|
76
|
+
export const samFlagDescriptions = [
|
|
77
|
+
'Template has multiple segments in sequencing (paired-end / mate-pair)',
|
|
78
|
+
'Each segment is properly aligned according to the aligner',
|
|
79
|
+
'This segment is unmapped',
|
|
80
|
+
'The mate / next segment in the template is unmapped',
|
|
81
|
+
'SEQ is reverse-complemented (read aligns to the reverse strand)',
|
|
82
|
+
'SEQ of the mate / next segment is reverse-complemented',
|
|
83
|
+
'This is the first segment in the template',
|
|
84
|
+
'This is the last segment in the template',
|
|
85
|
+
'Secondary alignment (not the primary linear representation of the read)',
|
|
86
|
+
'Read did not pass filters such as platform / vendor quality controls',
|
|
87
|
+
'PCR or optical duplicate',
|
|
88
|
+
'Supplementary alignment (part of a chimeric / split read)',
|
|
89
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jbrowse/cigar-utils",
|
|
3
|
+
"version": "4.1.14",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Pure CIGAR / MD / mismatch parsers and types — no rendering or framework deps",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"jbrowse",
|
|
8
|
+
"jbrowse2",
|
|
9
|
+
"cigar",
|
|
10
|
+
"sam",
|
|
11
|
+
"bam"
|
|
12
|
+
],
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"homepage": "https://jbrowse.org",
|
|
15
|
+
"bugs": "https://github.com/GMOD/jbrowse-components/issues",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/GMOD/jbrowse-components.git",
|
|
19
|
+
"directory": "packages/cigar-utils"
|
|
20
|
+
},
|
|
21
|
+
"author": "JBrowse Team",
|
|
22
|
+
"main": "esm/index.js",
|
|
23
|
+
"files": [
|
|
24
|
+
"esm"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build:esm": "node ../../node_modules/typescript7/bin/tsc --build tsconfig.build.esm.json",
|
|
33
|
+
"build": "pnpm build:esm",
|
|
34
|
+
"test": "cd ../..; jest --passWithNoTests packages/cigar-utils",
|
|
35
|
+
"clean": "rimraf esm *.tsbuildinfo",
|
|
36
|
+
"prebuild": "pnpm clean"
|
|
37
|
+
},
|
|
38
|
+
"types": "esm/index.d.ts",
|
|
39
|
+
"exports": {
|
|
40
|
+
".": "./esm/index.js"
|
|
41
|
+
}
|
|
42
|
+
}
|