p2s_mapper 1.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 +148 -0
- package/dist/alignmentQuality.d.ts +58 -0
- package/dist/alignmentQuality.js +108 -0
- package/dist/alignmentQuality.js.map +1 -0
- package/dist/alphaFoldModels.d.ts +29 -0
- package/dist/alphaFoldModels.js +60 -0
- package/dist/alphaFoldModels.js.map +1 -0
- package/dist/caCoordsToPdb.d.ts +18 -0
- package/dist/caCoordsToPdb.js +95 -0
- package/dist/caCoordsToPdb.js.map +1 -0
- package/dist/chooseMappedEntity.d.ts +55 -0
- package/dist/chooseMappedEntity.js +140 -0
- package/dist/chooseMappedEntity.js.map +1 -0
- package/dist/coordinates.d.ts +66 -0
- package/dist/coordinates.js +66 -0
- package/dist/coordinates.js.map +1 -0
- package/dist/dbIds.d.ts +16 -0
- package/dist/dbIds.js +42 -0
- package/dist/dbIds.js.map +1 -0
- package/dist/extractPerResidueConfidence.d.ts +49 -0
- package/dist/extractPerResidueConfidence.js +42 -0
- package/dist/extractPerResidueConfidence.js.map +1 -0
- package/dist/extractStructureSequences.d.ts +142 -0
- package/dist/extractStructureSequences.js +217 -0
- package/dist/extractStructureSequences.js.map +1 -0
- package/dist/fetchUtils.d.ts +34 -0
- package/dist/fetchUtils.js +91 -0
- package/dist/fetchUtils.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/invertMap.d.ts +2 -0
- package/dist/invertMap.js +8 -0
- package/dist/invertMap.js.map +1 -0
- package/dist/isoformRanking.d.ts +47 -0
- package/dist/isoformRanking.js +91 -0
- package/dist/isoformRanking.js.map +1 -0
- package/dist/mappings.d.ts +58 -0
- package/dist/mappings.js +193 -0
- package/dist/mappings.js.map +1 -0
- package/dist/package.json +1 -0
- package/dist/pairwiseAlignment.d.ts +35 -0
- package/dist/pairwiseAlignment.js +337 -0
- package/dist/pairwiseAlignment.js.map +1 -0
- package/dist/pdbUniProtMapping.d.ts +75 -0
- package/dist/pdbUniProtMapping.js +241 -0
- package/dist/pdbUniProtMapping.js.map +1 -0
- package/dist/pdbeBestStructures.d.ts +23 -0
- package/dist/pdbeBestStructures.js +79 -0
- package/dist/pdbeBestStructures.js.map +1 -0
- package/dist/pdbeEntryMolecules.d.ts +7 -0
- package/dist/pdbeEntryMolecules.js +39 -0
- package/dist/pdbeEntryMolecules.js.map +1 -0
- package/dist/siftsNumbering.d.ts +23 -0
- package/dist/siftsNumbering.js +44 -0
- package/dist/siftsNumbering.js.map +1 -0
- package/dist/stripStopCodon.d.ts +15 -0
- package/dist/stripStopCodon.js +24 -0
- package/dist/stripStopCodon.js.map +1 -0
- package/dist/structureFormat.d.ts +40 -0
- package/dist/structureFormat.js +54 -0
- package/dist/structureFormat.js.map +1 -0
- package/dist/structureSources.d.ts +28 -0
- package/dist/structureSources.js +76 -0
- package/dist/structureSources.js.map +1 -0
- package/dist/structureUrls.d.ts +54 -0
- package/dist/structureUrls.js +147 -0
- package/dist/structureUrls.js.map +1 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.js +27 -0
- package/dist/types.js.map +1 -0
- package/dist/uniProtSearch.d.ts +32 -0
- package/dist/uniProtSearch.js +114 -0
- package/dist/uniProtSearch.js.map +1 -0
- package/esm/alignmentQuality.d.ts +58 -0
- package/esm/alignmentQuality.js +100 -0
- package/esm/alignmentQuality.js.map +1 -0
- package/esm/alphaFoldModels.d.ts +29 -0
- package/esm/alphaFoldModels.js +55 -0
- package/esm/alphaFoldModels.js.map +1 -0
- package/esm/caCoordsToPdb.d.ts +18 -0
- package/esm/caCoordsToPdb.js +91 -0
- package/esm/caCoordsToPdb.js.map +1 -0
- package/esm/chooseMappedEntity.d.ts +55 -0
- package/esm/chooseMappedEntity.js +134 -0
- package/esm/chooseMappedEntity.js.map +1 -0
- package/esm/coordinates.d.ts +66 -0
- package/esm/coordinates.js +58 -0
- package/esm/coordinates.js.map +1 -0
- package/esm/dbIds.d.ts +16 -0
- package/esm/dbIds.js +35 -0
- package/esm/dbIds.js.map +1 -0
- package/esm/extractPerResidueConfidence.d.ts +49 -0
- package/esm/extractPerResidueConfidence.js +38 -0
- package/esm/extractPerResidueConfidence.js.map +1 -0
- package/esm/extractStructureSequences.d.ts +142 -0
- package/esm/extractStructureSequences.js +205 -0
- package/esm/extractStructureSequences.js.map +1 -0
- package/esm/fetchUtils.d.ts +34 -0
- package/esm/fetchUtils.js +82 -0
- package/esm/fetchUtils.js.map +1 -0
- package/esm/index.d.ts +23 -0
- package/esm/index.js +30 -0
- package/esm/index.js.map +1 -0
- package/esm/invertMap.d.ts +2 -0
- package/esm/invertMap.js +5 -0
- package/esm/invertMap.js.map +1 -0
- package/esm/isoformRanking.d.ts +47 -0
- package/esm/isoformRanking.js +86 -0
- package/esm/isoformRanking.js.map +1 -0
- package/esm/mappings.d.ts +58 -0
- package/esm/mappings.js +179 -0
- package/esm/mappings.js.map +1 -0
- package/esm/pairwiseAlignment.d.ts +35 -0
- package/esm/pairwiseAlignment.js +328 -0
- package/esm/pairwiseAlignment.js.map +1 -0
- package/esm/pdbUniProtMapping.d.ts +75 -0
- package/esm/pdbUniProtMapping.js +231 -0
- package/esm/pdbUniProtMapping.js.map +1 -0
- package/esm/pdbeBestStructures.d.ts +23 -0
- package/esm/pdbeBestStructures.js +73 -0
- package/esm/pdbeBestStructures.js.map +1 -0
- package/esm/pdbeEntryMolecules.d.ts +7 -0
- package/esm/pdbeEntryMolecules.js +35 -0
- package/esm/pdbeEntryMolecules.js.map +1 -0
- package/esm/siftsNumbering.d.ts +23 -0
- package/esm/siftsNumbering.js +40 -0
- package/esm/siftsNumbering.js.map +1 -0
- package/esm/stripStopCodon.d.ts +15 -0
- package/esm/stripStopCodon.js +20 -0
- package/esm/stripStopCodon.js.map +1 -0
- package/esm/structureFormat.d.ts +40 -0
- package/esm/structureFormat.js +48 -0
- package/esm/structureFormat.js.map +1 -0
- package/esm/structureSources.d.ts +28 -0
- package/esm/structureSources.js +71 -0
- package/esm/structureSources.js.map +1 -0
- package/esm/structureUrls.d.ts +54 -0
- package/esm/structureUrls.js +134 -0
- package/esm/structureUrls.js.map +1 -0
- package/esm/types.d.ts +14 -0
- package/esm/types.js +23 -0
- package/esm/types.js.map +1 -0
- package/esm/uniProtSearch.d.ts +32 -0
- package/esm/uniProtSearch.js +110 -0
- package/esm/uniProtSearch.js.map +1 -0
- package/package.json +63 -0
- package/src/alignmentQuality.ts +132 -0
- package/src/alphaFoldModels.ts +91 -0
- package/src/caCoordsToPdb.ts +111 -0
- package/src/chooseMappedEntity.ts +198 -0
- package/src/coordinates.ts +119 -0
- package/src/dbIds.ts +46 -0
- package/src/extractPerResidueConfidence.ts +88 -0
- package/src/extractStructureSequences.ts +342 -0
- package/src/fetchUtils.ts +110 -0
- package/src/index.ts +34 -0
- package/src/invertMap.ts +4 -0
- package/src/isoformRanking.ts +139 -0
- package/src/mappings.ts +230 -0
- package/src/pairwiseAlignment.ts +423 -0
- package/src/pdbUniProtMapping.ts +320 -0
- package/src/pdbeBestStructures.ts +94 -0
- package/src/pdbeEntryMolecules.ts +37 -0
- package/src/siftsNumbering.ts +61 -0
- package/src/stripStopCodon.ts +20 -0
- package/src/structureFormat.ts +70 -0
- package/src/structureSources.ts +101 -0
- package/src/structureUrls.ts +171 -0
- package/src/types.ts +30 -0
- package/src/uniProtSearch.ts +212 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { structurePositionToAlignmentMap, structureSeqVsTranscriptSeqMap, transcriptPositionToAlignmentMap, } from "./mappings.js";
|
|
2
|
+
import { invertMap } from "./invertMap.js";
|
|
3
|
+
export const structurePos = (n) => n;
|
|
4
|
+
export const transcriptPos = (n) => n;
|
|
5
|
+
export const alignmentCol = (n) => n;
|
|
6
|
+
/**
|
|
7
|
+
* Builds every coordinate conversion once from a pairwise alignment, replacing
|
|
8
|
+
* the scatter of per-getter map builds + repeated invertMap calls. The branded
|
|
9
|
+
* methods are the preferred API; `maps` stays unbranded for whole-map consumers.
|
|
10
|
+
*/
|
|
11
|
+
export function makeCoordinateMapper(pairwiseAlignment) {
|
|
12
|
+
const { structureSeqToTranscriptSeqPosition, transcriptSeqToStructureSeqPosition, } = structureSeqVsTranscriptSeqMap(pairwiseAlignment);
|
|
13
|
+
const s2aln = structurePositionToAlignmentMap(pairwiseAlignment);
|
|
14
|
+
const t2aln = transcriptPositionToAlignmentMap(pairwiseAlignment);
|
|
15
|
+
const aln2s = invertMap(s2aln);
|
|
16
|
+
const aln2t = invertMap(t2aln);
|
|
17
|
+
// The `as` casts below are the single brand-crossing point: indexing a
|
|
18
|
+
// Record<number,number> yields a plain number that we re-brand to its output
|
|
19
|
+
// space. Isolated here so the rest of the codebase stays brand-clean.
|
|
20
|
+
return {
|
|
21
|
+
structureToTranscript: p => structureSeqToTranscriptSeqPosition[p],
|
|
22
|
+
transcriptToStructure: p => transcriptSeqToStructureSeqPosition[p],
|
|
23
|
+
structureToAlignment: p => s2aln[p],
|
|
24
|
+
alignmentToStructure: c => aln2s[c],
|
|
25
|
+
transcriptToAlignment: p => t2aln[p],
|
|
26
|
+
alignmentToTranscript: c => aln2t[c],
|
|
27
|
+
maps: {
|
|
28
|
+
structureSeqToTranscriptSeqPosition,
|
|
29
|
+
transcriptSeqToStructureSeqPosition,
|
|
30
|
+
structurePositionToAlignmentMap: s2aln,
|
|
31
|
+
transcriptPositionToAlignmentMap: t2aln,
|
|
32
|
+
alignmentToStructurePosition: aln2s,
|
|
33
|
+
alignmentToTranscriptPosition: aln2t,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The 0-based half-open structure-position range covering an inclusive range
|
|
39
|
+
* of 1-based transcript residues, the numbering a UniProt feature or a domain
|
|
40
|
+
* map uses. Residues the structure lacks are skipped, so a range that runs
|
|
41
|
+
* past a fragment's end clamps to the last modeled residue; undefined when none
|
|
42
|
+
* of the range aligns to the structure.
|
|
43
|
+
*/
|
|
44
|
+
export function transcriptRangeToStructureRange(mapper, range) {
|
|
45
|
+
let first;
|
|
46
|
+
let last;
|
|
47
|
+
for (let residue = range.start; residue <= range.end; residue++) {
|
|
48
|
+
const pos = mapper.transcriptToStructure(transcriptPos(residue - 1));
|
|
49
|
+
if (pos !== undefined) {
|
|
50
|
+
first = first === undefined ? pos : Math.min(first, pos);
|
|
51
|
+
last = last === undefined ? pos : Math.max(last, pos);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return first === undefined || last === undefined
|
|
55
|
+
? undefined
|
|
56
|
+
: { start: first, end: last + 1 };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=coordinates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinates.js","sourceRoot":"","sources":["../src/coordinates.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,gCAAgC,GACjC,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAqB1C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAiB,CAAA;AAC5D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAkB,CAAA;AAC9D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAiB,CAAA;AA2B5D;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAClC,iBAAoC;IAEpC,MAAM,EACJ,mCAAmC,EACnC,mCAAmC,GACpC,GAAG,8BAA8B,CAAC,iBAAiB,CAAC,CAAA;IACrD,MAAM,KAAK,GAAG,+BAA+B,CAAC,iBAAiB,CAAC,CAAA;IAChE,MAAM,KAAK,GAAG,gCAAgC,CAAC,iBAAiB,CAAC,CAAA;IACjE,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CA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CAAA;YACxD,IAAI,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QACvD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS;QAC9C,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,GAAG,CAAC,EAAE,CAAA;AACrC,CAAC"}
|
package/esm/dbIds.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type DbType = 'ensembl' | 'refseq' | 'ccds' | 'hgnc';
|
|
2
|
+
export declare function matchDbIdPattern(id: string): {
|
|
3
|
+
db: DbType;
|
|
4
|
+
pattern: RegExp;
|
|
5
|
+
label: string;
|
|
6
|
+
} | undefined;
|
|
7
|
+
/** Whether an ID is a database identifier UniProt can map. */
|
|
8
|
+
export declare function isRecognizedDatabaseId(id: string): boolean;
|
|
9
|
+
/** Human-readable label for an ID, e.g. "ENST00000123 (Ensembl transcript)".
|
|
10
|
+
* Unrecognized IDs are returned unadorned. */
|
|
11
|
+
export declare function getDbIdLabel(id: string): string;
|
|
12
|
+
/** The UniProt xref query fragment for a recognized ID, e.g.
|
|
13
|
+
* "xref:ensembl-ENST00000123". HGNC strips its redundant "HGNC:" prefix. */
|
|
14
|
+
export declare function buildUniProtXrefQuery(id: string): string | undefined;
|
|
15
|
+
export declare function stripTrailingVersion(s?: string): string | undefined;
|
|
16
|
+
export {};
|
package/esm/dbIds.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const DB_ID_PATTERNS = [
|
|
2
|
+
{ db: 'ensembl', pattern: /^ENS[A-Z]*G\d+/i, label: 'Ensembl gene' },
|
|
3
|
+
{ db: 'ensembl', pattern: /^ENS[A-Z]*T\d+/i, label: 'Ensembl transcript' },
|
|
4
|
+
{ db: 'ensembl', pattern: /^ENS[A-Z]*P\d+/i, label: 'Ensembl protein' },
|
|
5
|
+
{ db: 'refseq', pattern: /^[NX]M_\d+/i, label: 'RefSeq mRNA' },
|
|
6
|
+
{ db: 'refseq', pattern: /^[NX]R_\d+/i, label: 'RefSeq ncRNA' },
|
|
7
|
+
{ db: 'refseq', pattern: /^[NX]P_\d+/i, label: 'RefSeq protein' },
|
|
8
|
+
{ db: 'ccds', pattern: /^CCDS\d+/i, label: 'CCDS' },
|
|
9
|
+
{ db: 'hgnc', pattern: /^HGNC:\d+/i, label: 'HGNC' },
|
|
10
|
+
];
|
|
11
|
+
export function matchDbIdPattern(id) {
|
|
12
|
+
return DB_ID_PATTERNS.find(p => p.pattern.test(id));
|
|
13
|
+
}
|
|
14
|
+
/** Whether an ID is a database identifier UniProt can map. */
|
|
15
|
+
export function isRecognizedDatabaseId(id) {
|
|
16
|
+
return matchDbIdPattern(id) !== undefined;
|
|
17
|
+
}
|
|
18
|
+
/** Human-readable label for an ID, e.g. "ENST00000123 (Ensembl transcript)".
|
|
19
|
+
* Unrecognized IDs are returned unadorned. */
|
|
20
|
+
export function getDbIdLabel(id) {
|
|
21
|
+
const match = matchDbIdPattern(id);
|
|
22
|
+
return match ? `${id} (${match.label})` : id;
|
|
23
|
+
}
|
|
24
|
+
/** The UniProt xref query fragment for a recognized ID, e.g.
|
|
25
|
+
* "xref:ensembl-ENST00000123". HGNC strips its redundant "HGNC:" prefix. */
|
|
26
|
+
export function buildUniProtXrefQuery(id) {
|
|
27
|
+
const match = matchDbIdPattern(id);
|
|
28
|
+
return match
|
|
29
|
+
? `xref:${match.db}-${match.db === 'hgnc' ? id.replace('HGNC:', '') : id}`
|
|
30
|
+
: undefined;
|
|
31
|
+
}
|
|
32
|
+
export function stripTrailingVersion(s) {
|
|
33
|
+
return s?.replace(/\.[^./]+$/, '');
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=dbIds.js.map
|
package/esm/dbIds.js.map
ADDED
|
@@ -0,0 +1 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,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;AAC9C,CAAC;AAED;4EAC4E;AAC5E,MAAM,UAAU,qBAAqB,CAAC,EAAU;IAC9C,MAAM,KAAK,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAA;IAClC,OAAO,KAAK;QACV,CAAC,CAAC,QAAQ,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;QAC1E,CAAC,CAAC,SAAS,CAAA;AACf,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,CAAU;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AACpC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
interface ConfidenceModel {
|
|
2
|
+
obj?: {
|
|
3
|
+
data: {
|
|
4
|
+
atomicConformation: {
|
|
5
|
+
B_iso_or_equiv: {
|
|
6
|
+
value: (row: number) => number;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
atomicHierarchy: {
|
|
10
|
+
residueAtomSegments: {
|
|
11
|
+
offsets: ArrayLike<number>;
|
|
12
|
+
count: number;
|
|
13
|
+
};
|
|
14
|
+
chainAtomSegments: {
|
|
15
|
+
index: ArrayLike<number>;
|
|
16
|
+
};
|
|
17
|
+
chains: {
|
|
18
|
+
label_entity_id: {
|
|
19
|
+
value: (row: number) => string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
residues: {
|
|
23
|
+
label_seq_id: {
|
|
24
|
+
value: (row: number) => number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Per-residue B-factor / pLDDT of one polymer entity, keyed by molstar's
|
|
33
|
+
* `label_seq_id`. Keyed by id rather than by residue order because the atomic
|
|
34
|
+
* hierarchy only holds *observed* residues: a chain with an unmodeled loop, or
|
|
35
|
+
* a chain that is not the first in the file, would otherwise plot every value
|
|
36
|
+
* against the wrong SEQRES position. Convert through `Entity.seqIds`.
|
|
37
|
+
*/
|
|
38
|
+
export interface EntityConfidence {
|
|
39
|
+
entityId: string;
|
|
40
|
+
byLabelSeqId: Map<number, number>;
|
|
41
|
+
}
|
|
42
|
+
export declare function extractPerResidueConfidence(model: ConfidenceModel): EntityConfidence[] | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* AlphaFold-style pLDDT lives in [0, 100] and varies across residues. A
|
|
45
|
+
* constant column (common when a PDB has no B-factors) or out-of-range values
|
|
46
|
+
* indicate the track wouldn't be meaningful as confidence.
|
|
47
|
+
*/
|
|
48
|
+
export declare function looksLikePlddt(values: number[] | undefined): values is number[];
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function extractPerResidueConfidence(model) {
|
|
2
|
+
const data = model.obj?.data;
|
|
3
|
+
if (!data) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
const { B_iso_or_equiv } = data.atomicConformation;
|
|
7
|
+
const { residueAtomSegments, chainAtomSegments, chains, residues } = data.atomicHierarchy;
|
|
8
|
+
const byEntity = new Map();
|
|
9
|
+
for (let residue = 0; residue < residueAtomSegments.count; residue++) {
|
|
10
|
+
const atom = residueAtomSegments.offsets[residue];
|
|
11
|
+
const entityId = chains.label_entity_id.value(chainAtomSegments.index[atom]);
|
|
12
|
+
let values = byEntity.get(entityId);
|
|
13
|
+
if (!values) {
|
|
14
|
+
values = new Map();
|
|
15
|
+
byEntity.set(entityId, values);
|
|
16
|
+
}
|
|
17
|
+
const seqId = residues.label_seq_id.value(residue);
|
|
18
|
+
if (!values.has(seqId)) {
|
|
19
|
+
values.set(seqId, B_iso_or_equiv.value(atom));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return [...byEntity].map(([entityId, byLabelSeqId]) => ({
|
|
23
|
+
entityId,
|
|
24
|
+
byLabelSeqId,
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* AlphaFold-style pLDDT lives in [0, 100] and varies across residues. A
|
|
29
|
+
* constant column (common when a PDB has no B-factors) or out-of-range values
|
|
30
|
+
* indicate the track wouldn't be meaningful as confidence.
|
|
31
|
+
*/
|
|
32
|
+
export function looksLikePlddt(values) {
|
|
33
|
+
return (!!values &&
|
|
34
|
+
values.length > 1 &&
|
|
35
|
+
values.every(v => v >= 0 && v <= 100) &&
|
|
36
|
+
new Set(values).size > 1);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=extractPerResidueConfidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractPerResidueConfidence.js","sourceRoot":"","sources":["../src/extractPerResidueConfidence.ts"],"names":[],"mappings":"AAyCA,MAAM,UAAU,2BAA2B,CACzC,KAAsB;IAEtB,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,CAAA;IAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,kBAAkB,CAAA;IAClD,MAAM,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE,GAChE,IAAI,CAAC,eAAe,CAAA;IACtB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA+B,CAAA;IACvD,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC;QACrE,MAAM,IAAI,GAAG,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAE,CAAA;QAClD,MAAM,QAAQ,GAAG,MAAM,CAAC,eAAe,CAAC,KAAK,CAC3C,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAE,CAC/B,CAAA;QACD,IAAI,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACnC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,IAAI,GAAG,EAAE,CAAA;YAClB,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAChC,CAAC;QACD,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAClD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QAC/C,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC;QACtD,QAAQ;QACR,YAAY;KACb,CAAC,CAAC,CAAA;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,MAA4B;IAE5B,OAAO,CACL,CAAC,CAAC,MAAM;QACR,MAAM,CAAC,MAAM,GAAG,CAAC;QACjB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;QACrC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC,CACzB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/** A polymer entity of a loaded structure: its mmCIF entity id, its one-letter
|
|
2
|
+
* sequence, and the molstar `label_seq_id` of each of those residues.
|
|
3
|
+
*
|
|
4
|
+
* The entity id is what lets every downstream step talk about "the gene's
|
|
5
|
+
* protein" by identity instead of by the fragile entity-[0] position.
|
|
6
|
+
*
|
|
7
|
+
* `seqIds` is what lets it talk about a *residue* by identity. Structure
|
|
8
|
+
* positions in this plugin are 0-based indices into `seq`; molstar addresses
|
|
9
|
+
* residues by `label_seq_id`. Those are related by `+1` only when the entity's
|
|
10
|
+
* sequence covers every residue from 1 — true for any mmCIF with an
|
|
11
|
+
* `entity_poly_seq` category (all of RCSB and AlphaFold) and for PDB files
|
|
12
|
+
* carrying SEQRES records, because molstar synthesizes the category from them.
|
|
13
|
+
*
|
|
14
|
+
* A PDB-format file with no SEQRES has no such category, so molstar falls back
|
|
15
|
+
* to `StructureSequence.fromHierarchy` and takes `label_seq_id` straight from
|
|
16
|
+
* the observed residues' author numbering: a chain whose coordinates start at
|
|
17
|
+
* residue 94 yields seqIds 94.., and an unobserved loop leaves a hole. Deriving
|
|
18
|
+
* the id arithmetically there is off by the whole offset, in both directions —
|
|
19
|
+
* every hover reads the wrong residue and every highlight paints the wrong one.
|
|
20
|
+
* So carry the real ids and convert through them.
|
|
21
|
+
*/
|
|
22
|
+
export interface Entity {
|
|
23
|
+
entityId: string;
|
|
24
|
+
seq: string;
|
|
25
|
+
seqIds: number[];
|
|
26
|
+
/** author chain ids carrying this entity, e.g. ['A', 'B'] for a homodimer;
|
|
27
|
+
* what a user recognises from the PDB entry page, where the entity id is
|
|
28
|
+
* molstar's own bookkeeping */
|
|
29
|
+
chains: string[];
|
|
30
|
+
/** DNA, RNA or a hybrid, by molstar's entity subtype. Its one-letter
|
|
31
|
+
* sequence spells amino acids too (A, C, G, T, U), so it has to be kept
|
|
32
|
+
* out of the transcript alignment rather than merely scoring low. */
|
|
33
|
+
nucleicAcid?: boolean;
|
|
34
|
+
/** `auth_seq_id` per position: the numbering the depositors chose, which
|
|
35
|
+
* for an RCSB entry is the one papers and UniProt cite (1TUP's position 154
|
|
36
|
+
* is R248) and what Mol*'s own hover label shows. Display only; every
|
|
37
|
+
* coordinate the plugin computes with stays a 0-based position, and molstar
|
|
38
|
+
* is addressed through `seqIds`. Absent when the model has no atomic
|
|
39
|
+
* hierarchy to read it from. See `residueNumber`. */
|
|
40
|
+
authSeqIds?: number[];
|
|
41
|
+
}
|
|
42
|
+
interface Column<T> {
|
|
43
|
+
rowCount: number;
|
|
44
|
+
value(row: number): T;
|
|
45
|
+
}
|
|
46
|
+
interface StructureModel {
|
|
47
|
+
obj?: {
|
|
48
|
+
data: {
|
|
49
|
+
entities?: {
|
|
50
|
+
subtype: Column<string>;
|
|
51
|
+
getEntityIndex(id: string): number;
|
|
52
|
+
};
|
|
53
|
+
sourceData?: {
|
|
54
|
+
data: unknown;
|
|
55
|
+
};
|
|
56
|
+
sequence: {
|
|
57
|
+
sequences: readonly {
|
|
58
|
+
entityId: string;
|
|
59
|
+
sequence: {
|
|
60
|
+
code: {
|
|
61
|
+
toArray(): ArrayLike<string>;
|
|
62
|
+
};
|
|
63
|
+
seqId: {
|
|
64
|
+
toArray(): ArrayLike<number>;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
}[];
|
|
68
|
+
};
|
|
69
|
+
atomicHierarchy?: {
|
|
70
|
+
chains: {
|
|
71
|
+
label_entity_id: Column<string>;
|
|
72
|
+
auth_asym_id: Column<string>;
|
|
73
|
+
};
|
|
74
|
+
residues?: {
|
|
75
|
+
label_seq_id: Column<number>;
|
|
76
|
+
auth_seq_id: Column<number>;
|
|
77
|
+
};
|
|
78
|
+
residueAtomSegments?: {
|
|
79
|
+
offsets: ArrayLike<number>;
|
|
80
|
+
count: number;
|
|
81
|
+
};
|
|
82
|
+
chainAtomSegments?: {
|
|
83
|
+
index: ArrayLike<number>;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Author numbering for every SEQRES position, observed or not. A residue with
|
|
91
|
+
* no atoms has no auth_seq_id of its own, so it takes the offset of the nearest
|
|
92
|
+
* observed residue before it (after it, at an unobserved N-terminus): a
|
|
93
|
+
* disordered loop keeps counting the way the paper does. With nothing observed
|
|
94
|
+
* the label numbering stands.
|
|
95
|
+
*/
|
|
96
|
+
export declare function fillAuthSeqIds(seqIds: number[], observed: Map<number, number> | undefined): number[];
|
|
97
|
+
/** The number a residue is called by: author numbering when the file carries
|
|
98
|
+
* it, else molstar's label_seq_id, which is the author numbering already for a
|
|
99
|
+
* SEQRES-less PDB and 1..N for everything else. */
|
|
100
|
+
export declare function residueNumber(entity: Entity | undefined, pos: number): number;
|
|
101
|
+
/**
|
|
102
|
+
* The 0-based half-open position range covering an inclusive range of author
|
|
103
|
+
* residue numbers, the form a paper or a spec names a site by ("R248",
|
|
104
|
+
* "residues 102-292"). Undefined when no residue of the entity carries a number
|
|
105
|
+
* in the range, so a typo selects nothing rather than something else.
|
|
106
|
+
*/
|
|
107
|
+
export declare function residueRangeToPositions(entity: Entity | undefined, range: {
|
|
108
|
+
start: number;
|
|
109
|
+
end: number;
|
|
110
|
+
}): {
|
|
111
|
+
start: number;
|
|
112
|
+
end: number;
|
|
113
|
+
} | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* One letter per position, so `seq[pos]` and `seqIds[pos]` name the same
|
|
116
|
+
* residue. Molstar's `label` column is not that: it spells a residue with no
|
|
117
|
+
* one-letter code by its component id (MSE, TPO, ACE) and an alternate site as
|
|
118
|
+
* "(S|P)", which shifted every later position. `code` writes X for those; the
|
|
119
|
+
* mmCIF canonical sequence then supplies the parent residue (MSE is M) when it
|
|
120
|
+
* has one letter per position, which a chromophore spelled "TYG" does not.
|
|
121
|
+
*/
|
|
122
|
+
export declare function oneLetterSequence(codes: ArrayLike<string>, canonical: string | undefined): string;
|
|
123
|
+
export declare function extractEntities(model: StructureModel): Entity[] | undefined;
|
|
124
|
+
/** A user-facing name for an entity: its chains when known, else its id. */
|
|
125
|
+
export declare function entityLabel(entity: Entity): string;
|
|
126
|
+
/** The protein chains' sequences, for the launch dialog's isoform matching,
|
|
127
|
+
* which has no use for a DNA strand that happens to align. */
|
|
128
|
+
export declare function extractStructureSequences(model: StructureModel): string[] | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* The molstar `label_seq_id`s for a set of 0-based structure positions. Unknown
|
|
131
|
+
* positions are dropped rather than guessed, so an out-of-range position paints
|
|
132
|
+
* nothing instead of painting something wrong.
|
|
133
|
+
*/
|
|
134
|
+
export declare function toLabelSeqIds(entity: Entity | undefined, positions: Iterable<number>): number[];
|
|
135
|
+
/** As toLabelSeqIds, for a half-open [start, end) structure-position range. */
|
|
136
|
+
export declare function rangeToLabelSeqIds(entity: Entity | undefined, range: {
|
|
137
|
+
start: number;
|
|
138
|
+
end: number;
|
|
139
|
+
} | undefined): number[];
|
|
140
|
+
/** Reverse of `seqIds`: molstar's label_seq_id -> 0-based structure position. */
|
|
141
|
+
export declare function makeLabelSeqIdIndex(entity: Entity | undefined): Map<number, number>;
|
|
142
|
+
export {};
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/** Observed residues' label_seq_id -> auth_seq_id, per entity. The first chain
|
|
2
|
+
* carrying an entity wins, so a homodimer's copies agree. */
|
|
3
|
+
function authSeqIdsByEntity(model) {
|
|
4
|
+
const hierarchy = model.obj?.data.atomicHierarchy;
|
|
5
|
+
const byEntity = new Map();
|
|
6
|
+
const { residues, residueAtomSegments, chainAtomSegments, chains } = hierarchy ?? {};
|
|
7
|
+
if (!residues || !residueAtomSegments || !chainAtomSegments || !chains) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
for (let residue = 0; residue < residueAtomSegments.count; residue++) {
|
|
11
|
+
const atom = residueAtomSegments.offsets[residue];
|
|
12
|
+
const entityId = chains.label_entity_id.value(chainAtomSegments.index[atom]);
|
|
13
|
+
let ids = byEntity.get(entityId);
|
|
14
|
+
if (!ids) {
|
|
15
|
+
ids = new Map();
|
|
16
|
+
byEntity.set(entityId, ids);
|
|
17
|
+
}
|
|
18
|
+
const labelSeqId = residues.label_seq_id.value(residue);
|
|
19
|
+
if (!ids.has(labelSeqId)) {
|
|
20
|
+
ids.set(labelSeqId, residues.auth_seq_id.value(residue));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return byEntity;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Author numbering for every SEQRES position, observed or not. A residue with
|
|
27
|
+
* no atoms has no auth_seq_id of its own, so it takes the offset of the nearest
|
|
28
|
+
* observed residue before it (after it, at an unobserved N-terminus): a
|
|
29
|
+
* disordered loop keeps counting the way the paper does. With nothing observed
|
|
30
|
+
* the label numbering stands.
|
|
31
|
+
*/
|
|
32
|
+
export function fillAuthSeqIds(seqIds, observed) {
|
|
33
|
+
const out = [];
|
|
34
|
+
let offset;
|
|
35
|
+
const firstObserved = seqIds.find(id => observed?.has(id));
|
|
36
|
+
if (firstObserved !== undefined) {
|
|
37
|
+
offset = observed.get(firstObserved) - firstObserved;
|
|
38
|
+
}
|
|
39
|
+
for (const id of seqIds) {
|
|
40
|
+
const auth = observed?.get(id);
|
|
41
|
+
if (auth !== undefined) {
|
|
42
|
+
offset = auth - id;
|
|
43
|
+
}
|
|
44
|
+
out.push(id + (offset ?? 0));
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/** The number a residue is called by: author numbering when the file carries
|
|
49
|
+
* it, else molstar's label_seq_id, which is the author numbering already for a
|
|
50
|
+
* SEQRES-less PDB and 1..N for everything else. */
|
|
51
|
+
export function residueNumber(entity, pos) {
|
|
52
|
+
return entity?.authSeqIds?.[pos] ?? entity?.seqIds[pos] ?? pos + 1;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The 0-based half-open position range covering an inclusive range of author
|
|
56
|
+
* residue numbers, the form a paper or a spec names a site by ("R248",
|
|
57
|
+
* "residues 102-292"). Undefined when no residue of the entity carries a number
|
|
58
|
+
* in the range, so a typo selects nothing rather than something else.
|
|
59
|
+
*/
|
|
60
|
+
export function residueRangeToPositions(entity, range) {
|
|
61
|
+
if (!entity) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
let first;
|
|
65
|
+
let last;
|
|
66
|
+
for (let pos = 0; pos < entity.seq.length; pos++) {
|
|
67
|
+
const n = residueNumber(entity, pos);
|
|
68
|
+
if (n >= range.start && n <= range.end) {
|
|
69
|
+
first ??= pos;
|
|
70
|
+
last = pos;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return first === undefined || last === undefined
|
|
74
|
+
? undefined
|
|
75
|
+
: { start: first, end: last + 1 };
|
|
76
|
+
}
|
|
77
|
+
function chainsByEntity(model) {
|
|
78
|
+
const chains = model.obj?.data.atomicHierarchy?.chains;
|
|
79
|
+
const byEntity = new Map();
|
|
80
|
+
if (chains) {
|
|
81
|
+
for (let i = 0; i < chains.label_entity_id.rowCount; i++) {
|
|
82
|
+
const entityId = chains.label_entity_id.value(i);
|
|
83
|
+
const chain = chains.auth_asym_id.value(i);
|
|
84
|
+
const list = byEntity.get(entityId) ?? [];
|
|
85
|
+
if (!list.includes(chain)) {
|
|
86
|
+
list.push(chain);
|
|
87
|
+
}
|
|
88
|
+
byEntity.set(entityId, list);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return byEntity;
|
|
92
|
+
}
|
|
93
|
+
// mmCIF entity_poly.type values for nucleic-acid polymers. Molstar derives the
|
|
94
|
+
// subtype from residue components when a file (PDB format) carries no
|
|
95
|
+
// entity_poly, so the flag is available for either format.
|
|
96
|
+
const NUCLEIC_ACID_SUBTYPES = new Set([
|
|
97
|
+
'polydeoxyribonucleotide',
|
|
98
|
+
'polyribonucleotide',
|
|
99
|
+
'polydeoxyribonucleotide/polyribonucleotide hybrid',
|
|
100
|
+
'peptide nucleic acid',
|
|
101
|
+
]);
|
|
102
|
+
function isNucleicAcid(model, entityId) {
|
|
103
|
+
const entities = model.obj?.data.entities;
|
|
104
|
+
if (!entities) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
const index = entities.getEntityIndex(entityId);
|
|
108
|
+
return index >= 0 && NUCLEIC_ACID_SUBTYPES.has(entities.subtype.value(index));
|
|
109
|
+
}
|
|
110
|
+
function canonicalSequencesByEntity(model) {
|
|
111
|
+
const source = model.obj?.data.sourceData?.data;
|
|
112
|
+
const entityPoly = source?.db?.entity_poly;
|
|
113
|
+
const byEntity = new Map();
|
|
114
|
+
if (entityPoly) {
|
|
115
|
+
for (let i = 0; i < entityPoly.entity_id.rowCount; i++) {
|
|
116
|
+
byEntity.set(entityPoly.entity_id.value(i), entityPoly.pdbx_seq_one_letter_code_can.value(i).replaceAll(/\s/g, ''));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return byEntity;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* One letter per position, so `seq[pos]` and `seqIds[pos]` name the same
|
|
123
|
+
* residue. Molstar's `label` column is not that: it spells a residue with no
|
|
124
|
+
* one-letter code by its component id (MSE, TPO, ACE) and an alternate site as
|
|
125
|
+
* "(S|P)", which shifted every later position. `code` writes X for those; the
|
|
126
|
+
* mmCIF canonical sequence then supplies the parent residue (MSE is M) when it
|
|
127
|
+
* has one letter per position, which a chromophore spelled "TYG" does not.
|
|
128
|
+
*/
|
|
129
|
+
export function oneLetterSequence(codes, canonical) {
|
|
130
|
+
const letters = Array.from(codes);
|
|
131
|
+
return letters
|
|
132
|
+
.map((c, i) => c === 'X' && canonical?.length === letters.length ? canonical[i] : c)
|
|
133
|
+
.join('');
|
|
134
|
+
}
|
|
135
|
+
export function extractEntities(model) {
|
|
136
|
+
const chains = chainsByEntity(model);
|
|
137
|
+
const authIds = authSeqIdsByEntity(model);
|
|
138
|
+
const canonical = canonicalSequencesByEntity(model);
|
|
139
|
+
return model.obj?.data.sequence.sequences.map(s => {
|
|
140
|
+
const seqIds = Array.from(s.sequence.seqId.toArray());
|
|
141
|
+
return {
|
|
142
|
+
entityId: s.entityId,
|
|
143
|
+
seq: oneLetterSequence(s.sequence.code.toArray(), canonical.get(s.entityId)),
|
|
144
|
+
seqIds,
|
|
145
|
+
chains: chains.get(s.entityId) ?? [],
|
|
146
|
+
...(isNucleicAcid(model, s.entityId) ? { nucleicAcid: true } : {}),
|
|
147
|
+
...(authIds
|
|
148
|
+
? { authSeqIds: fillAuthSeqIds(seqIds, authIds.get(s.entityId)) }
|
|
149
|
+
: {}),
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/** A user-facing name for an entity: its chains when known, else its id. */
|
|
154
|
+
export function entityLabel(entity) {
|
|
155
|
+
const chains = entity.chains.length > 0
|
|
156
|
+
? `Chain ${entity.chains.join('/')}`
|
|
157
|
+
: `Entity ${entity.entityId}`;
|
|
158
|
+
return `${chains} (${entity.seq.length} ${entity.nucleicAcid ? 'nt' : 'aa'})`;
|
|
159
|
+
}
|
|
160
|
+
/** The protein chains' sequences, for the launch dialog's isoform matching,
|
|
161
|
+
* which has no use for a DNA strand that happens to align. */
|
|
162
|
+
export function extractStructureSequences(model) {
|
|
163
|
+
return extractEntities(model)
|
|
164
|
+
?.filter(e => !e.nucleicAcid)
|
|
165
|
+
.map(e => e.seq);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The molstar `label_seq_id`s for a set of 0-based structure positions. Unknown
|
|
169
|
+
* positions are dropped rather than guessed, so an out-of-range position paints
|
|
170
|
+
* nothing instead of painting something wrong.
|
|
171
|
+
*/
|
|
172
|
+
export function toLabelSeqIds(entity, positions) {
|
|
173
|
+
if (!entity) {
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
const out = [];
|
|
177
|
+
for (const pos of positions) {
|
|
178
|
+
const id = entity.seqIds[pos];
|
|
179
|
+
if (id !== undefined) {
|
|
180
|
+
out.push(id);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
/** As toLabelSeqIds, for a half-open [start, end) structure-position range. */
|
|
186
|
+
export function rangeToLabelSeqIds(entity, range) {
|
|
187
|
+
if (!entity || !range) {
|
|
188
|
+
return [];
|
|
189
|
+
}
|
|
190
|
+
const start = Math.max(0, range.start);
|
|
191
|
+
const end = Math.min(entity.seqIds.length, range.end);
|
|
192
|
+
return end > start ? entity.seqIds.slice(start, end) : [];
|
|
193
|
+
}
|
|
194
|
+
/** Reverse of `seqIds`: molstar's label_seq_id -> 0-based structure position. */
|
|
195
|
+
export function makeLabelSeqIdIndex(entity) {
|
|
196
|
+
const index = new Map();
|
|
197
|
+
entity?.seqIds.forEach((id, pos) => {
|
|
198
|
+
// first wins: duplicate ids (micro-heterogeneity) collapse to one residue
|
|
199
|
+
if (!index.has(id)) {
|
|
200
|
+
index.set(id, pos);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
return index;
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=extractStructureSequences.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractStructureSequences.js","sourceRoot":"","sources":["../src/extractStructureSequences.ts"],"names":[],"mappings":"AAoFA;6DAC6D;AAC7D,SAAS,kBAAkB,CAAC,KAAqB;IAC/C,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,CAAA;IACjD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA+B,CAAA;IACvD,MAAM,EAAE,QAAQ,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,EAAE,GAChE,SAAS,IAAI,EAAE,CAAA;IACjB,IAAI,CAAC,QAAQ,IAAI,CAAC,mBAAmB,IAAI,CAAC,iBAAiB,IAAI,CAAC,MAAM,EAAE,CAAC;QACvE,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC;QACrE,MAAM,IAAI,GAAG,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAE,CAAA;QAClD,MAAM,QAAQ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B;IAC5D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAA;IACvC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE;QACjC,0EAA0E;QAC1E,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACnB,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;QACpB,CAAC;IACH,CAAC,CAAC,CAAA;IACF,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The error a failed response deserves: status and host, plus at most the first
|
|
3
|
+
* line of the body. A whole body is an HTML error page or a megabyte of JSON,
|
|
4
|
+
* and pasting it into the dialog buries the one line that says what went wrong.
|
|
5
|
+
*/
|
|
6
|
+
export declare function httpError(response: Response, url: string): Promise<Error>;
|
|
7
|
+
/**
|
|
8
|
+
* `fetch` rejects with a bare `TypeError: Failed to fetch` for a DNS failure,
|
|
9
|
+
* an offline browser and a refused cross-origin request alike, naming neither
|
|
10
|
+
* the host nor the cause. Anything else — an abort, most notably — passes
|
|
11
|
+
* through untouched.
|
|
12
|
+
*/
|
|
13
|
+
export declare function networkError(url: string, cause: unknown): unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Request options plus the `fetch` to make the request with. Every network
|
|
16
|
+
* function here takes them, so a caller can hand in a host's instrumented
|
|
17
|
+
* fetch, a test double, or nothing at all and get `globalThis.fetch`. Resolved
|
|
18
|
+
* per call rather than captured at import, so a page that installs its fetch
|
|
19
|
+
* late is still honored.
|
|
20
|
+
*/
|
|
21
|
+
export interface FetchOptions extends RequestInit {
|
|
22
|
+
fetch?: typeof globalThis.fetch;
|
|
23
|
+
}
|
|
24
|
+
export declare function rawfetch(url: string, args?: FetchOptions): Promise<Response>;
|
|
25
|
+
export declare function myfetch(url: string, args?: FetchOptions): Promise<Response>;
|
|
26
|
+
export declare function jsonfetch<T = unknown>(url: string, args?: FetchOptions): Promise<T>;
|
|
27
|
+
/**
|
|
28
|
+
* An AbortSignal's reason as a real Error. `signal.reason` is `any` — usually a
|
|
29
|
+
* DOMException, but a caller can abort with anything at all — and throwing a
|
|
30
|
+
* non-Error loses the stack and breaks `instanceof Error` checks in the UI's
|
|
31
|
+
* error rendering. Normalize at every throw site.
|
|
32
|
+
*/
|
|
33
|
+
export declare function abortError(signal: AbortSignal): Error;
|
|
34
|
+
export declare function timeout(time: number, signal?: AbortSignal): Promise<void>;
|