p2s_mapper 1.4.0 → 2.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/README.md +220 -39
- package/dist/alignmentQuality.d.ts +5 -5
- package/dist/alphaFoldModels.d.ts +4 -4
- package/dist/alphaFoldModels.js +4 -4
- package/dist/chooseMappedEntity.d.ts +11 -13
- package/dist/chooseMappedEntity.js +9 -12
- package/dist/chooseMappedEntity.js.map +1 -1
- package/dist/coordinates.d.ts +19 -19
- package/dist/coordinates.js.map +1 -1
- package/dist/dbIds.d.ts +1 -2
- package/dist/extractPerResidueConfidence.d.ts +1 -2
- package/dist/extractStructureSequences.d.ts +26 -34
- package/dist/extractStructureSequences.js +2 -2
- package/dist/extractStructureSequences.js.map +1 -1
- package/dist/fetchUtils.d.ts +7 -7
- package/dist/fetchUtils.js +26 -8
- package/dist/fetchUtils.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/isoformRanking.d.ts +4 -1
- package/dist/mappings.d.ts +9 -12
- package/dist/mappings.js +4 -5
- package/dist/mappings.js.map +1 -1
- package/dist/pairwiseAlignment.d.ts +5 -4
- package/dist/pairwiseAlignment.js +9 -7
- package/dist/pairwiseAlignment.js.map +1 -1
- package/dist/pdbEntry.d.ts +32 -0
- package/dist/pdbEntry.js +182 -0
- package/dist/pdbEntry.js.map +1 -0
- package/dist/pdbUniProtMapping.d.ts +14 -39
- package/dist/pdbUniProtMapping.js +22 -140
- package/dist/pdbUniProtMapping.js.map +1 -1
- package/dist/structureFormat.d.ts +11 -18
- package/dist/structureFormat.js +4 -6
- package/dist/structureFormat.js.map +1 -1
- package/dist/structureSources.d.ts +37 -13
- package/dist/structureSources.js +144 -57
- package/dist/structureSources.js.map +1 -1
- package/dist/structureUrls.d.ts +13 -16
- package/dist/structureUrls.js +25 -23
- package/dist/structureUrls.js.map +1 -1
- package/dist/types.d.ts +2 -5
- package/dist/types.js +2 -5
- package/dist/types.js.map +1 -1
- package/dist/uniProtSearch.js +3 -8
- package/dist/uniProtSearch.js.map +1 -1
- package/esm/alignmentQuality.d.ts +5 -5
- package/esm/alphaFoldModels.d.ts +4 -4
- package/esm/alphaFoldModels.js +4 -4
- package/esm/chooseMappedEntity.d.ts +11 -13
- package/esm/chooseMappedEntity.js +9 -12
- package/esm/chooseMappedEntity.js.map +1 -1
- package/esm/coordinates.d.ts +19 -19
- package/esm/coordinates.js.map +1 -1
- package/esm/dbIds.d.ts +1 -2
- package/esm/extractPerResidueConfidence.d.ts +1 -2
- package/esm/extractStructureSequences.d.ts +26 -34
- package/esm/extractStructureSequences.js +2 -2
- package/esm/extractStructureSequences.js.map +1 -1
- package/esm/fetchUtils.d.ts +7 -7
- package/esm/fetchUtils.js +26 -8
- package/esm/fetchUtils.js.map +1 -1
- package/esm/index.d.ts +1 -3
- package/esm/index.js +2 -4
- package/esm/index.js.map +1 -1
- package/esm/isoformRanking.d.ts +4 -1
- package/esm/mappings.d.ts +9 -12
- package/esm/mappings.js +4 -5
- package/esm/mappings.js.map +1 -1
- package/esm/pairwiseAlignment.d.ts +5 -4
- package/esm/pairwiseAlignment.js +7 -5
- package/esm/pairwiseAlignment.js.map +1 -1
- package/esm/pdbEntry.d.ts +32 -0
- package/esm/pdbEntry.js +174 -0
- package/esm/pdbEntry.js.map +1 -0
- package/esm/pdbUniProtMapping.d.ts +14 -39
- package/esm/pdbUniProtMapping.js +22 -137
- package/esm/pdbUniProtMapping.js.map +1 -1
- package/esm/structureFormat.d.ts +11 -18
- package/esm/structureFormat.js +4 -6
- package/esm/structureFormat.js.map +1 -1
- package/esm/structureSources.d.ts +37 -13
- package/esm/structureSources.js +139 -55
- package/esm/structureSources.js.map +1 -1
- package/esm/structureUrls.d.ts +13 -16
- package/esm/structureUrls.js +23 -23
- package/esm/structureUrls.js.map +1 -1
- package/esm/types.d.ts +2 -5
- package/esm/types.js +2 -5
- package/esm/types.js.map +1 -1
- package/esm/uniProtSearch.js +3 -8
- package/esm/uniProtSearch.js.map +1 -1
- package/package.json +3 -2
- package/src/alignmentQuality.ts +5 -5
- package/src/alphaFoldModels.ts +4 -4
- package/src/chooseMappedEntity.ts +12 -15
- package/src/coordinates.ts +14 -17
- package/src/dbIds.ts +1 -1
- package/src/extractPerResidueConfidence.ts +1 -1
- package/src/extractStructureSequences.ts +26 -33
- package/src/fetchUtils.ts +30 -8
- package/src/index.ts +2 -4
- package/src/isoformRanking.ts +4 -4
- package/src/mappings.ts +9 -12
- package/src/pairwiseAlignment.ts +12 -9
- package/src/pdbEntry.ts +240 -0
- package/src/pdbUniProtMapping.ts +25 -164
- package/src/structureFormat.ts +11 -18
- package/src/structureSources.ts +194 -70
- package/src/structureUrls.ts +25 -23
- package/src/types.ts +2 -5
- package/src/uniProtSearch.ts +3 -8
- package/dist/pdbeBestStructures.d.ts +0 -23
- package/dist/pdbeBestStructures.js +0 -79
- package/dist/pdbeBestStructures.js.map +0 -1
- package/dist/pdbeEntryMolecules.d.ts +0 -7
- package/dist/pdbeEntryMolecules.js +0 -39
- package/dist/pdbeEntryMolecules.js.map +0 -1
- package/dist/siftsNumbering.d.ts +0 -23
- package/dist/siftsNumbering.js +0 -44
- package/dist/siftsNumbering.js.map +0 -1
- package/esm/pdbeBestStructures.d.ts +0 -23
- package/esm/pdbeBestStructures.js +0 -73
- package/esm/pdbeBestStructures.js.map +0 -1
- package/esm/pdbeEntryMolecules.d.ts +0 -7
- package/esm/pdbeEntryMolecules.js +0 -35
- package/esm/pdbeEntryMolecules.js.map +0 -1
- package/esm/siftsNumbering.d.ts +0 -23
- package/esm/siftsNumbering.js +0 -40
- package/esm/siftsNumbering.js.map +0 -1
- package/src/pdbeBestStructures.ts +0 -94
- package/src/pdbeEntryMolecules.ts +0 -37
- package/src/siftsNumbering.ts +0 -61
package/esm/structureUrls.d.ts
CHANGED
|
@@ -9,21 +9,18 @@ export declare function uniprotEntryUrl(uniprotId: string): string;
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function getAlphaFoldStructureUrl(uniprotId: string, version?: string): string;
|
|
11
11
|
export declare function getPdbStructureUrl(pdbId: string): string;
|
|
12
|
+
export declare function isPdbId(value: string): boolean;
|
|
13
|
+
export declare function rcsbEntryUrl(pdbId: string): string;
|
|
12
14
|
/**
|
|
13
|
-
* Resolve the `{ pdbId }` shorthand to a
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* Resolve the `{ pdbId }` shorthand to a structure URL, so a hand-written config
|
|
16
|
+
* or a short launch URL needs no RCSB filename. An explicit `url` (or inline
|
|
17
|
+
* `data`) always wins, and resolving an already-resolved spec returns the same
|
|
18
|
+
* url.
|
|
17
19
|
*
|
|
18
|
-
* `uniprotId`
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* file to open.
|
|
23
|
-
*
|
|
24
|
-
* Shared by the Structure model's snapshot preprocessor and the
|
|
25
|
-
* LaunchView-ProteinView extension point, which would otherwise each carry
|
|
26
|
-
* their own copy of the same precedence rule.
|
|
20
|
+
* `uniprotId` resolves to no url and still outranks a `pdbId`. AlphaFold DB's
|
|
21
|
+
* files for an accession change (an isoform model, several fragments, a new
|
|
22
|
+
* model version), so the caller keeps the accession and asks
|
|
23
|
+
* `fetchAlphaFoldModels` which file to open.
|
|
27
24
|
*/
|
|
28
25
|
export declare function resolveStructureUrl({ url, data, uniprotId, pdbId, }: {
|
|
29
26
|
url?: string;
|
|
@@ -43,9 +40,9 @@ export declare function getUniprotIdFromAlphaFoldTarget(target: string): string
|
|
|
43
40
|
export declare function getStructureUrlFromTarget(target: string, db: string): string | undefined;
|
|
44
41
|
export declare function getConfidenceUrlFromTarget(target: string): string | undefined;
|
|
45
42
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
43
|
+
* The name to show for a structure: its PDB id, its AlphaFold accession, else
|
|
44
|
+
* the file's name. Use it wherever a structure is named, so each place shows
|
|
45
|
+
* the same name.
|
|
49
46
|
*/
|
|
50
47
|
export declare function structureDisplayLabel({ url, data, uniprotId, }: {
|
|
51
48
|
url?: string;
|
package/esm/structureUrls.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
//
|
|
2
|
-
// the launch flow and the ProteinView model (e.g. resolving a `uniprotId`/`pdbId`
|
|
3
|
-
// shorthand at hydration) can import them without pulling in heavy launch code.
|
|
1
|
+
// Structure URL builders and target parsers, with no dependencies.
|
|
4
2
|
const ALPHAFOLD_VERSION = 'v6';
|
|
5
|
-
// UniProt endpoints. rest.* is the machine API
|
|
6
|
-
// the
|
|
7
|
-
// assembly is built from); www.*/entry is the human-facing entry page the UI
|
|
8
|
-
// links to. Centralized so a path change is one edit rather than a grep.
|
|
3
|
+
// UniProt endpoints. rest.* is the machine API, serving the features as GFF
|
|
4
|
+
// and the sequence as FASTA; www.*/entry is the entry page for people.
|
|
9
5
|
export function uniprotGffUrl(uniprotId) {
|
|
10
6
|
return `https://rest.uniprot.org/uniprotkb/${uniprotId}.gff`;
|
|
11
7
|
}
|
|
@@ -27,21 +23,25 @@ export function getAlphaFoldStructureUrl(uniprotId, version = ALPHAFOLD_VERSION)
|
|
|
27
23
|
export function getPdbStructureUrl(pdbId) {
|
|
28
24
|
return `https://files.rcsb.org/download/${pdbId}.cif`;
|
|
29
25
|
}
|
|
26
|
+
// A PDB id is four characters, the first a digit: 1TUP, 6ZIO. Checked before
|
|
27
|
+
// a typed one reaches a fetch, so three characters on the way to four are not
|
|
28
|
+
// a 404 apiece.
|
|
29
|
+
export function isPdbId(value) {
|
|
30
|
+
return /^[1-9][A-Za-z0-9]{3}$/.test(value);
|
|
31
|
+
}
|
|
32
|
+
export function rcsbEntryUrl(pdbId) {
|
|
33
|
+
return `https://www.rcsb.org/structure/${pdbId.toUpperCase()}`;
|
|
34
|
+
}
|
|
30
35
|
/**
|
|
31
|
-
* Resolve the `{ pdbId }` shorthand to a
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* `uniprotId` deliberately resolves to no url here, and still outranks a
|
|
37
|
-
* `pdbId`. An accession's files are whatever AlphaFold DB currently holds — an
|
|
38
|
-
* isoform model, several fragments, a new model version — so the structure
|
|
39
|
-
* keeps the accession and the structure loader asks the prediction API which
|
|
40
|
-
* file to open.
|
|
36
|
+
* Resolve the `{ pdbId }` shorthand to a structure URL, so a hand-written config
|
|
37
|
+
* or a short launch URL needs no RCSB filename. An explicit `url` (or inline
|
|
38
|
+
* `data`) always wins, and resolving an already-resolved spec returns the same
|
|
39
|
+
* url.
|
|
41
40
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
41
|
+
* `uniprotId` resolves to no url and still outranks a `pdbId`. AlphaFold DB's
|
|
42
|
+
* files for an accession change (an isoform model, several fragments, a new
|
|
43
|
+
* model version), so the caller keeps the accession and asks
|
|
44
|
+
* `fetchAlphaFoldModels` which file to open.
|
|
45
45
|
*/
|
|
46
46
|
export function resolveStructureUrl({ url, data, uniprotId, pdbId, }) {
|
|
47
47
|
if (url !== undefined || data !== undefined) {
|
|
@@ -108,9 +108,9 @@ export function getConfidenceUrlFromTarget(target) {
|
|
|
108
108
|
return undefined;
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
111
|
+
* The name to show for a structure: its PDB id, its AlphaFold accession, else
|
|
112
|
+
* the file's name. Use it wherever a structure is named, so each place shows
|
|
113
|
+
* the same name.
|
|
114
114
|
*/
|
|
115
115
|
export function structureDisplayLabel({ url, data, uniprotId, }) {
|
|
116
116
|
if (url === undefined) {
|
package/esm/structureUrls.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structureUrls.js","sourceRoot":"","sources":["../src/structureUrls.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"structureUrls.js","sourceRoot":"","sources":["../src/structureUrls.ts"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ACD,MAAM,YAAY,GAAG,+BAA+B,CAAC,GAAG,CAAC,CAAA;IACzD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,aAAa,YAAY,EAAE,CAAA;IACpC,CAAC;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAChD,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAA;AACvD,CAAC"}
|
package/esm/types.d.ts
CHANGED
|
@@ -5,10 +5,7 @@ export declare const ALIGNMENT_ALGORITHMS: {
|
|
|
5
5
|
};
|
|
6
6
|
export declare const DEFAULT_ALIGNMENT_ALGORITHM: AlignmentAlgorithm;
|
|
7
7
|
export declare const ALIGNMENT_ALGORITHM_VALUES: AlignmentAlgorithm[];
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* The only place a coercion is needed: the model property is an enumeration, so
|
|
11
|
-
* everything downstream of hydration is already typed.
|
|
12
|
-
*/
|
|
8
|
+
/** Parses an untrusted algorithm name, such as a URL parameter, falling back
|
|
9
|
+
* to Smith-Waterman. */
|
|
13
10
|
export declare function coerceAlignmentAlgorithm(value: string): AlignmentAlgorithm;
|
|
14
11
|
export declare const ALIGNMENT_ALGORITHM_LABELS: Record<AlignmentAlgorithm, string>;
|
package/esm/types.js
CHANGED
|
@@ -7,11 +7,8 @@ export const ALIGNMENT_ALGORITHM_VALUES = [
|
|
|
7
7
|
'needleman_wunsch',
|
|
8
8
|
'smith_waterman',
|
|
9
9
|
];
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* The only place a coercion is needed: the model property is an enumeration, so
|
|
13
|
-
* everything downstream of hydration is already typed.
|
|
14
|
-
*/
|
|
10
|
+
/** Parses an untrusted algorithm name, such as a URL parameter, falling back
|
|
11
|
+
* to Smith-Waterman. */
|
|
15
12
|
export function coerceAlignmentAlgorithm(value) {
|
|
16
13
|
return (ALIGNMENT_ALGORITHM_VALUES.find(v => v === value) ??
|
|
17
14
|
DEFAULT_ALIGNMENT_ALGORITHM);
|
package/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,gBAAgB,EAAE,kBAAkB;IACpC,cAAc,EAAE,gBAAgB;CACxB,CAAA;AAEV,MAAM,CAAC,MAAM,2BAA2B,GAAuB,gBAAgB,CAAA;AAE/E,MAAM,CAAC,MAAM,0BAA0B,GAAyB;IAC9D,kBAAkB;IAClB,gBAAgB;CACjB,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,gBAAgB,EAAE,kBAAkB;IACpC,cAAc,EAAE,gBAAgB;CACxB,CAAA;AAEV,MAAM,CAAC,MAAM,2BAA2B,GAAuB,gBAAgB,CAAA;AAE/E,MAAM,CAAC,MAAM,0BAA0B,GAAyB;IAC9D,kBAAkB;IAClB,gBAAgB;CACjB,CAAA;AAED;wBACwB;AACxB,MAAM,UAAU,wBAAwB,CAAC,KAAa;IACpD,OAAO,CACL,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC;QACjD,2BAA2B,CAC5B,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAuC;IAC5E,gBAAgB,EAAE,kBAAkB;IACpC,cAAc,EAAE,gBAAgB;CACjC,CAAA"}
|
package/esm/uniProtSearch.js
CHANGED
|
@@ -47,7 +47,6 @@ async function searchByXref(id, opts) {
|
|
|
47
47
|
return { entries: await searchUniProt(query, 10, opts), error: undefined };
|
|
48
48
|
}
|
|
49
49
|
catch (e) {
|
|
50
|
-
console.error(`xref search failed for ${id}:`, e);
|
|
51
50
|
return { entries: [], error: e };
|
|
52
51
|
}
|
|
53
52
|
}
|
|
@@ -59,18 +58,14 @@ async function searchByGeneName(geneName, organismId, opts) {
|
|
|
59
58
|
// are 284812. The descendants are asked only on a miss, because for a
|
|
60
59
|
// species with reviewed subspecies entries (human and Neanderthal) they
|
|
61
60
|
// turn one answer into two.
|
|
62
|
-
//
|
|
63
|
-
//
|
|
61
|
+
// When the descendant search fails, the taxon's own empty result stands
|
|
62
|
+
// rather than becoming an error.
|
|
64
63
|
const entries = exact.length === 0 && organismId
|
|
65
|
-
? await searchUniProt(buildGeneNameQuery(geneName, organismId, 'taxonomy_id'), 5, opts).catch((
|
|
66
|
-
console.error(`descendant-taxon search failed for ${geneName}:`, e);
|
|
67
|
-
return exact;
|
|
68
|
-
})
|
|
64
|
+
? await searchUniProt(buildGeneNameQuery(geneName, organismId, 'taxonomy_id'), 5, opts).catch(() => exact)
|
|
69
65
|
: exact;
|
|
70
66
|
return { entries, error: undefined };
|
|
71
67
|
}
|
|
72
68
|
catch (e) {
|
|
73
|
-
console.error(`gene name search failed for ${geneName}:`, e);
|
|
74
69
|
return { entries: [], error: e };
|
|
75
70
|
}
|
|
76
71
|
}
|
package/esm/uniProtSearch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniProtSearch.js","sourceRoot":"","sources":["../src/uniProtSearch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,YAAY,CAAA;AAsCnB,MAAM,cAAc,GAClB,6DAA6D,CAAA;AAE/D,SAAS,mBAAmB,CAC1B,MAAsC;IAEtC,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,gBAAgB;QAClC,EAAE,EAAE,MAAM,CAAC,WAAW;QAC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C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAEpD,4EAA4E;IAC5E,6EAA6E;IAC7E,IACE,OAAO,CAAC,MAAM,KAAK,CAAC;QACpB,cAAc,GAAG,CAAC;QAClB,cAAc,KAAK,WAAW,EAC9B,CAAC;QACD,MAAM,CACJ,mBAAmB,EAAE,KAAK;YAC1B,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,EAAE,KAAK,CACpD,CAAA;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,QAAQ,CACvB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CACtD;QACD,cAAc;QACd,WAAW;KACZ,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "p2s_mapper",
|
|
3
|
-
"description": "Map a transcript's translation onto a protein structure: alignment, coordinates, chain choice,
|
|
4
|
-
"version": "1.
|
|
3
|
+
"description": "Map a transcript's translation onto a protein structure: alignment, coordinates, chain choice, UniProt mapping, and the AlphaFold and RCSB lookups that find the structure",
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"packageManager": "pnpm@11.15.1",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"clean": "rimraf dist esm",
|
|
26
26
|
"format": "prettier --write .",
|
|
27
27
|
"format:check": "prettier --check .",
|
|
28
|
+
"docs:api": "node scripts/api-doc.ts",
|
|
28
29
|
"lint": "eslint --report-unused-disable-directives --max-warnings 0",
|
|
29
30
|
"typecheck": "tsc --noEmit -p tsconfig.lint.json",
|
|
30
31
|
"prebuild": "pnpm clean",
|
package/src/alignmentQuality.ts
CHANGED
|
@@ -7,21 +7,21 @@ import {
|
|
|
7
7
|
import type { PairwiseAlignment } from './mappings.ts'
|
|
8
8
|
|
|
9
9
|
export interface AlignmentQuality {
|
|
10
|
-
/** columns
|
|
10
|
+
/** columns with a residue in both rows, i.e. mapped positions */
|
|
11
11
|
aligned: number
|
|
12
12
|
identical: number
|
|
13
13
|
transcriptLength: number
|
|
14
14
|
structureLength: number
|
|
15
15
|
/** identical over aligned; 0 when nothing aligned */
|
|
16
16
|
identity: number
|
|
17
|
-
/** identical over the shorter of the two sequences
|
|
18
|
-
*
|
|
17
|
+
/** identical over the shorter of the two sequences, which separates a
|
|
18
|
+
* real match from a chance local alignment (see LOW_IDENTITY_OVER_SHORTER) */
|
|
19
19
|
identityOverShorter: number
|
|
20
20
|
/** aligned over the structure's length */
|
|
21
21
|
structureCoverage: number
|
|
22
22
|
/** first and last transcript residue the alignment covers, 1-based
|
|
23
|
-
* inclusive; 0 when nothing aligned. A structure is usually a fragment,
|
|
24
|
-
* which part of the protein it
|
|
23
|
+
* inclusive; 0 when nothing aligned. A structure is usually a fragment, so
|
|
24
|
+
* these show which part of the protein it contains. */
|
|
25
25
|
transcriptStart: number
|
|
26
26
|
transcriptEnd: number
|
|
27
27
|
}
|
package/src/alphaFoldModels.ts
CHANGED
|
@@ -78,11 +78,11 @@ export async function fetchAlphaFoldModels(
|
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
80
|
* The model to open for a gene's transcripts: one folded from exactly a
|
|
81
|
-
* transcript's translation, canonical first, so
|
|
82
|
-
*
|
|
81
|
+
* transcript's translation, canonical first, so every residue maps to itself;
|
|
82
|
+
* else the canonical model; else the longest isoform model.
|
|
83
83
|
*
|
|
84
|
-
* Takes any record of sequences, since
|
|
85
|
-
*
|
|
84
|
+
* Takes any record of sequences, since a caller may know one translation rather
|
|
85
|
+
* than a gene's isoforms.
|
|
86
86
|
*/
|
|
87
87
|
export function pickAlphaFoldModel(
|
|
88
88
|
models: AlphaFoldModel[],
|
|
@@ -24,13 +24,13 @@ export function interactionMatchesMappedEntity(
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface EntitySelection extends ScoredAlignment {
|
|
27
|
-
/** index
|
|
27
|
+
/** index of the chosen entity in the candidate array */
|
|
28
28
|
index: number
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface ScoredAlignment {
|
|
32
|
-
/** alignment of the transcript against the entity
|
|
33
|
-
*
|
|
32
|
+
/** alignment of the transcript against the entity, with stop codons
|
|
33
|
+
* stripped from both */
|
|
34
34
|
alignment: PairwiseAlignment
|
|
35
35
|
/** identical aligned residues */
|
|
36
36
|
matches: number
|
|
@@ -56,8 +56,7 @@ export interface EntityCandidate {
|
|
|
56
56
|
* usually is: on 1H26 the 11-residue p53 peptide matches 11 while CDK2 accrues
|
|
57
57
|
* 58 scattered identities, and on 4ZZJ SIRT1 beats the 7-residue p53 peptide
|
|
58
58
|
* 63 to 6. The Smith-Waterman score is no better there (56 vs 58). Dividing
|
|
59
|
-
* by length
|
|
60
|
-
* gene's product: the peptide scores 0.69 and 0.50, the partners 0.19 and
|
|
59
|
+
* by the shorter length identifies the chain that *is* this gene's product: the peptide scores 0.69 and 0.50, the partners 0.19 and
|
|
61
60
|
* 0.17, and across a ribosome's 55 chains no decoy passes 0.29.
|
|
62
61
|
*
|
|
63
62
|
* Dividing by the *entity's* length alone penalised a fusion construct: a
|
|
@@ -136,18 +135,16 @@ export function alignTranscriptToEntity(
|
|
|
136
135
|
}
|
|
137
136
|
|
|
138
137
|
/**
|
|
139
|
-
* Pick
|
|
138
|
+
* Pick the polymer entity of a structure that is the transcript's protein.
|
|
140
139
|
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* sequence (see `explainedFraction`). Nucleic-acid entities are never
|
|
147
|
-
* candidates.
|
|
140
|
+
* Taking entity `[0]` mis-maps every heteromeric, protein-DNA or
|
|
141
|
+
* processed-peptide structure where the protein is another chain. An exact
|
|
142
|
+
* sequence match wins outright; otherwise the entity with the highest identity
|
|
143
|
+
* over the shorter sequence wins (see `explainedFraction`). Nucleic-acid
|
|
144
|
+
* entities are never candidates.
|
|
148
145
|
*
|
|
149
|
-
* Returns `undefined` only when there is nothing to map
|
|
150
|
-
* protein
|
|
146
|
+
* Returns `undefined` only when there is nothing to map: no transcript, or no
|
|
147
|
+
* protein entity. It never falls back to another entity.
|
|
151
148
|
*/
|
|
152
149
|
export function chooseMappedEntity(
|
|
153
150
|
transcript: string,
|
package/src/coordinates.ts
CHANGED
|
@@ -8,21 +8,19 @@ import { invertMap } from './invertMap.ts'
|
|
|
8
8
|
import type { PairwiseAlignment } from './mappings.ts'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Branded coordinate spaces. Every position
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* the
|
|
15
|
-
*
|
|
16
|
-
* boundaries where raw numbers enter (molstar picks, hover events, features).
|
|
11
|
+
* Branded coordinate spaces. Every position is a plain `number` at runtime, but
|
|
12
|
+
* a structure residue index, a transcript residue index and an alignment column
|
|
13
|
+
* mean different things, and mixing them causes off-by-one bugs. The brands
|
|
14
|
+
* make the compiler reject mixing; wrap a raw number with the helpers below
|
|
15
|
+
* where it enters, such as a molstar pick, a hover event or a feature.
|
|
17
16
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* All are 0-based. StructurePos indexes the ungapped structure sequence,
|
|
18
|
+
* TranscriptPos the ungapped transcript sequence, and AlignmentCol a column of
|
|
19
|
+
* the pairwise alignment, gaps included.
|
|
21
20
|
*/
|
|
22
|
-
type
|
|
23
|
-
export type
|
|
24
|
-
export type
|
|
25
|
-
export type AlignmentCol = Branded<'AlignmentCol'>
|
|
21
|
+
export type StructurePos = number & { readonly __brand: 'StructurePos' }
|
|
22
|
+
export type TranscriptPos = number & { readonly __brand: 'TranscriptPos' }
|
|
23
|
+
export type AlignmentCol = number & { readonly __brand: 'AlignmentCol' }
|
|
26
24
|
|
|
27
25
|
export const structurePos = (n: number) => n as StructurePos
|
|
28
26
|
export const transcriptPos = (n: number) => n as TranscriptPos
|
|
@@ -45,10 +43,9 @@ export interface CoordinateMapper {
|
|
|
45
43
|
transcriptToAlignment: (p: TranscriptPos) => AlignmentCol | undefined
|
|
46
44
|
alignmentToTranscript: (c: AlignmentCol) => TranscriptPos | undefined
|
|
47
45
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* point conversions.
|
|
46
|
+
* The lookup tables as plain numbers, for code that iterates a whole map,
|
|
47
|
+
* such as drawing a per-residue track or selecting every aligned residue.
|
|
48
|
+
* Use the typed methods above to convert one position.
|
|
52
49
|
*/
|
|
53
50
|
readonly maps: CoordinateMaps
|
|
54
51
|
}
|
package/src/dbIds.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// keyword, the regex (Ensembl patterns cover human ENS, mouse ENSMUS, zebrafish
|
|
4
4
|
// ENSDAR, etc.), and a human-readable label. Recognition, label rendering, and
|
|
5
5
|
// xref-query building all derive from this list, so a new ID type is one entry.
|
|
6
|
-
type DbType = 'ensembl' | 'refseq' | 'ccds' | 'hgnc' | 'geneid'
|
|
6
|
+
export type DbType = 'ensembl' | 'refseq' | 'ccds' | 'hgnc' | 'geneid'
|
|
7
7
|
|
|
8
8
|
const DB_ID_PATTERNS: { db: DbType; pattern: RegExp; label: string }[] = [
|
|
9
9
|
{ db: 'ensembl', pattern: /^ENS[A-Z]*G\d+/i, label: 'Ensembl gene' },
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// store the per-residue pLDDT in the B-factor column (B_iso_or_equiv), so the
|
|
3
3
|
// first atom of each residue yields pLDDT for a predicted model and the
|
|
4
4
|
// crystallographic B-factor for an experimental one.
|
|
5
|
-
interface ConfidenceModel {
|
|
5
|
+
export interface ConfidenceModel {
|
|
6
6
|
obj?: {
|
|
7
7
|
data: {
|
|
8
8
|
atomicConformation: {
|
|
@@ -1,51 +1,44 @@
|
|
|
1
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
|
|
2
|
+
* sequence, and the molstar `label_seq_id` of each residue.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Structure positions are 0-based indices into `seq`, and molstar selects
|
|
5
|
+
* residues by `label_seq_id`. The two differ by 1 only when the entity's
|
|
6
|
+
* sequence covers every residue from 1, which holds for any mmCIF with an
|
|
7
|
+
* `entity_poly_seq` category (all of RCSB and AlphaFold) and for a PDB file
|
|
8
|
+
* with SEQRES records, from which molstar builds that category.
|
|
6
9
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* residues
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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.
|
|
10
|
+
* For a PDB file without SEQRES, molstar falls back to
|
|
11
|
+
* `StructureSequence.fromHierarchy` and takes `label_seq_id` from the observed
|
|
12
|
+
* residues' author numbering: a chain whose coordinates start at residue 94 has
|
|
13
|
+
* seqIds 94.., and an unobserved loop leaves a gap. Adding 1 there is off by the
|
|
14
|
+
* whole offset, in both directions, so convert through `seqIds`.
|
|
21
15
|
*/
|
|
22
16
|
export interface Entity {
|
|
17
|
+
/** mmCIF entity id */
|
|
23
18
|
entityId: string
|
|
19
|
+
/** one letter per residue, observed or not */
|
|
24
20
|
seq: string
|
|
21
|
+
/** molstar `label_seq_id` per position of `seq` */
|
|
25
22
|
seqIds: number[]
|
|
26
|
-
/** author chain ids
|
|
27
|
-
*
|
|
28
|
-
* molstar's own bookkeeping */
|
|
23
|
+
/** author chain ids of this entity, e.g. ['A', 'B'] for a homodimer, as
|
|
24
|
+
* the PDB entry page lists them */
|
|
29
25
|
chains: string[]
|
|
30
|
-
/** DNA, RNA or a hybrid, by molstar's entity subtype.
|
|
31
|
-
*
|
|
32
|
-
* out of the transcript alignment rather than merely scoring low. */
|
|
26
|
+
/** DNA, RNA or a hybrid, by molstar's entity subtype. A, C, G, T and U
|
|
27
|
+
* are amino-acid letters too, so chooseMappedEntity skips these. */
|
|
33
28
|
nucleicAcid?: boolean
|
|
34
|
-
/** `auth_seq_id` per position: the
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* is addressed through `seqIds`. Absent when the model has no atomic
|
|
39
|
-
* hierarchy to read it from. See `residueNumber`. */
|
|
29
|
+
/** `auth_seq_id` per position: the depositors' numbering, which papers cite
|
|
30
|
+
* (1TUP's position 154 is R248) and Mol*'s hover shows. For display only;
|
|
31
|
+
* use `seqIds` to select residues in Mol*. Absent when the model has no
|
|
32
|
+
* atomic hierarchy. See `residueNumber`. */
|
|
40
33
|
authSeqIds?: number[]
|
|
41
34
|
}
|
|
42
35
|
|
|
43
|
-
interface Column<T> {
|
|
36
|
+
export interface Column<T> {
|
|
44
37
|
rowCount: number
|
|
45
38
|
value(row: number): T
|
|
46
39
|
}
|
|
47
40
|
|
|
48
|
-
interface StructureModel {
|
|
41
|
+
export interface StructureModel {
|
|
49
42
|
obj?: {
|
|
50
43
|
data: {
|
|
51
44
|
entities?: {
|
|
@@ -284,8 +277,8 @@ export function entityLabel(entity: Entity) {
|
|
|
284
277
|
return `${chains} (${entity.seq.length} ${entity.nucleicAcid ? 'nt' : 'aa'})`
|
|
285
278
|
}
|
|
286
279
|
|
|
287
|
-
/** The protein chains' sequences, for
|
|
288
|
-
*
|
|
280
|
+
/** The protein chains' sequences, for ranking isoforms against a structure.
|
|
281
|
+
* DNA chains are left out, because their letters align as amino acids. */
|
|
289
282
|
export function extractStructureSequences(
|
|
290
283
|
model: StructureModel,
|
|
291
284
|
): string[] | undefined {
|
package/src/fetchUtils.ts
CHANGED
|
@@ -36,9 +36,9 @@ export function isDefinitiveFailure(e: unknown) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* The error a failed response
|
|
40
|
-
*
|
|
41
|
-
*
|
|
39
|
+
* The error for a failed response: status and host, plus at most the first line
|
|
40
|
+
* of the body. A whole body is an HTML error page or a megabyte of JSON, which
|
|
41
|
+
* hides the line that says what went wrong.
|
|
42
42
|
*/
|
|
43
43
|
export async function httpError(response: Response, url: string) {
|
|
44
44
|
const detail = firstLine(await response.text().catch(() => ''))
|
|
@@ -75,10 +75,32 @@ export interface FetchOptions extends RequestInit {
|
|
|
75
75
|
fetch?: typeof globalThis.fetch
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
const USER_AGENT = 'p2s_mapper (+https://github.com/GMOD/p2s_mapper)'
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* AlphaFold's prediction API answers 403 to `node`, the user agent Node's fetch
|
|
82
|
+
* sends (measured 2026-10-11), so outside a browser every request names this
|
|
83
|
+
* package unless the caller named something else. A browser sends its own, and
|
|
84
|
+
* a script-set one would cost a CORS preflight on every call.
|
|
85
|
+
*/
|
|
86
|
+
function withUserAgent(init: RequestInit) {
|
|
87
|
+
if (
|
|
88
|
+
typeof navigator !== 'undefined' &&
|
|
89
|
+
navigator.userAgent.startsWith('Mozilla')
|
|
90
|
+
) {
|
|
91
|
+
return init
|
|
92
|
+
}
|
|
93
|
+
const headers = new Headers(init.headers)
|
|
94
|
+
if (!headers.has('user-agent')) {
|
|
95
|
+
headers.set('user-agent', USER_AGENT)
|
|
96
|
+
}
|
|
97
|
+
return { ...init, headers }
|
|
98
|
+
}
|
|
99
|
+
|
|
78
100
|
export async function rawfetch(url: string, args?: FetchOptions) {
|
|
79
101
|
const { fetch: f = globalThis.fetch, ...init } = args ?? {}
|
|
80
102
|
try {
|
|
81
|
-
return await f(url, init)
|
|
103
|
+
return await f(url, withUserAgent(init))
|
|
82
104
|
} catch (e) {
|
|
83
105
|
throw networkError(url, e)
|
|
84
106
|
}
|
|
@@ -105,10 +127,10 @@ export async function jsonfetch<T = unknown>(
|
|
|
105
127
|
}
|
|
106
128
|
|
|
107
129
|
/**
|
|
108
|
-
* An AbortSignal's reason as a real Error. `signal.reason` is `any
|
|
109
|
-
* DOMException, but a caller can abort with
|
|
110
|
-
*
|
|
111
|
-
*
|
|
130
|
+
* An AbortSignal's reason as a real Error. `signal.reason` is `any`, usually a
|
|
131
|
+
* DOMException, but a caller can abort with any value, and throwing a non-Error
|
|
132
|
+
* loses the stack and breaks `instanceof Error` checks. Use it at every throw
|
|
133
|
+
* site.
|
|
112
134
|
*/
|
|
113
135
|
export function abortError(signal: AbortSignal) {
|
|
114
136
|
return signal.reason instanceof Error
|
package/src/index.ts
CHANGED
|
@@ -16,14 +16,12 @@ export * from './extractStructureSequences.ts'
|
|
|
16
16
|
export * from './extractPerResidueConfidence.ts'
|
|
17
17
|
export * from './isoformRanking.ts'
|
|
18
18
|
|
|
19
|
-
//
|
|
19
|
+
// UniProt mapping
|
|
20
20
|
export * from './pdbUniProtMapping.ts'
|
|
21
|
-
export * from './
|
|
21
|
+
export * from './pdbEntry.ts'
|
|
22
22
|
|
|
23
23
|
// Structure sources
|
|
24
24
|
export * from './alphaFoldModels.ts'
|
|
25
|
-
export * from './pdbeBestStructures.ts'
|
|
26
|
-
export * from './pdbeEntryMolecules.ts'
|
|
27
25
|
export * from './structureSources.ts'
|
|
28
26
|
export * from './uniProtSearch.ts'
|
|
29
27
|
export * from './dbIds.ts'
|
package/src/isoformRanking.ts
CHANGED
|
@@ -17,16 +17,16 @@ export interface RankedIsoform {
|
|
|
17
17
|
/** identical residues against the structure, for an isoform that does not
|
|
18
18
|
* match it exactly; undefined with no structure to compare to */
|
|
19
19
|
identical?: number
|
|
20
|
-
/** that alignment's score, which
|
|
20
|
+
/** that alignment's score, which ranks the non-matching isoforms */
|
|
21
21
|
score?: number
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface ClassifiedIsoforms {
|
|
25
|
-
|
|
25
|
+
/** translates to exactly the structure's sequence, longest first */
|
|
26
26
|
matches: RankedIsoform[]
|
|
27
|
-
|
|
27
|
+
/** translates to something else, best-aligning first */
|
|
28
28
|
nonMatches: RankedIsoform[]
|
|
29
|
-
|
|
29
|
+
/** ids of the isoforms with no translation */
|
|
30
30
|
noData: string[]
|
|
31
31
|
}
|
|
32
32
|
|