p2s_mapper 1.4.0 → 2.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/README.md +214 -32
- package/dist/coordinates.d.ts +8 -6
- 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 +14 -15
- package/dist/fetchUtils.js +19 -1
- 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 +3 -0
- package/dist/pairwiseAlignment.d.ts +1 -2
- 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 +9 -33
- package/dist/pdbUniProtMapping.js +17 -134
- package/dist/pdbUniProtMapping.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 +2 -0
- package/dist/structureUrls.js +11 -0
- package/dist/structureUrls.js.map +1 -1
- package/esm/coordinates.d.ts +8 -6
- 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 +14 -15
- package/esm/fetchUtils.js +19 -1
- 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 +3 -0
- package/esm/pairwiseAlignment.d.ts +1 -2
- 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 +9 -33
- package/esm/pdbUniProtMapping.js +17 -131
- package/esm/pdbUniProtMapping.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 +2 -0
- package/esm/structureUrls.js +9 -0
- package/esm/structureUrls.js.map +1 -1
- package/package.json +3 -2
- package/src/coordinates.ts +3 -4
- package/src/dbIds.ts +1 -1
- package/src/extractPerResidueConfidence.ts +1 -1
- package/src/extractStructureSequences.ts +14 -14
- package/src/fetchUtils.ts +23 -1
- package/src/index.ts +2 -4
- package/src/isoformRanking.ts +3 -3
- package/src/pairwiseAlignment.ts +1 -1
- package/src/pdbEntry.ts +240 -0
- package/src/pdbUniProtMapping.ts +20 -158
- package/src/structureSources.ts +194 -70
- package/src/structureUrls.ts +11 -0
- 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/pdbEntry.js
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// What RCSB knows about one PDB entry that a mapping needs, in one GraphQL
|
|
2
|
+
// call: each polymer entity's sequence, its author chains, and its alignment
|
|
3
|
+
// to UniProt. The alignment is what SIFTS publishes per chain, numbered the
|
|
4
|
+
// same way (`entity_beg_seq_id` is label_seq_id, 1-based into the SEQRES),
|
|
5
|
+
// and agreed with PDBe's SIFTS on every residue of 23 entries checked
|
|
6
|
+
// (2026-10-11, 1TUP, 2RH1, 4HHB, 7K00 among them), in a tenth of the time.
|
|
7
|
+
import { HttpError, isDefinitiveFailure, jsonfetch, timeout, } from "./fetchUtils.js";
|
|
8
|
+
export const RCSB_DATA_GRAPHQL_URL = 'https://data.rcsb.org/graphql';
|
|
9
|
+
export function pdbEntryQuery(pdbId) {
|
|
10
|
+
return `{ entry(entry_id: "${pdbId.toUpperCase()}") { polymer_entities {
|
|
11
|
+
rcsb_id
|
|
12
|
+
entity_poly { type pdbx_seq_one_letter_code_can }
|
|
13
|
+
rcsb_polymer_entity_container_identifiers { auth_asym_ids }
|
|
14
|
+
rcsb_polymer_entity_align {
|
|
15
|
+
reference_database_name reference_database_accession
|
|
16
|
+
aligned_regions { entity_beg_seq_id ref_beg_seq_id length }
|
|
17
|
+
}
|
|
18
|
+
uniprots { rcsb_id rcsb_uniprot_entry_name }
|
|
19
|
+
} } }`;
|
|
20
|
+
}
|
|
21
|
+
const RETRY_DELAYS_MS = [1000, 3000];
|
|
22
|
+
// bounded, since a view reports itself loading until the entry answers
|
|
23
|
+
const TIMEOUT_MS = 20_000;
|
|
24
|
+
/**
|
|
25
|
+
* A GraphQL request. The server answers 200 whatever happened, so a failure
|
|
26
|
+
* is read from the body's `errors`, and counts as a 400: the server
|
|
27
|
+
* understood the query and declined it, so asking again gets the same answer.
|
|
28
|
+
*/
|
|
29
|
+
export async function graphqlFetch(url, query, variables, opts) {
|
|
30
|
+
const json = await jsonfetch(url, {
|
|
31
|
+
...opts,
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: { 'Content-Type': 'application/json' },
|
|
34
|
+
body: JSON.stringify({ query, variables }),
|
|
35
|
+
});
|
|
36
|
+
const errors = isRecord(json) ? json.errors : undefined;
|
|
37
|
+
if (Array.isArray(errors) && errors.length > 0) {
|
|
38
|
+
const first = errors[0];
|
|
39
|
+
const message = isRecord(first) && typeof first.message === 'string'
|
|
40
|
+
? first.message
|
|
41
|
+
: 'unknown error';
|
|
42
|
+
throw new HttpError(`${new URL(url).host}: ${message}`, 400);
|
|
43
|
+
}
|
|
44
|
+
return isRecord(json) ? json.data : undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The entry, retried twice: one failed request would otherwise leave a fusion
|
|
48
|
+
* construct mapped onto its partner for the whole session. An id RCSB has no
|
|
49
|
+
* entry for is a 404, which is not retried, since that answer cannot change.
|
|
50
|
+
*/
|
|
51
|
+
export async function fetchPdbEntry(pdbId, opts) {
|
|
52
|
+
const { signal: caller, ...rest } = opts ?? {};
|
|
53
|
+
const signal = caller ?? undefined;
|
|
54
|
+
const deadline = () => signal
|
|
55
|
+
? AbortSignal.any([signal, AbortSignal.timeout(TIMEOUT_MS)])
|
|
56
|
+
: AbortSignal.timeout(TIMEOUT_MS);
|
|
57
|
+
for (let attempt = 0;; attempt++) {
|
|
58
|
+
try {
|
|
59
|
+
const entry = parsePdbEntry(await graphqlFetch(RCSB_DATA_GRAPHQL_URL, pdbEntryQuery(pdbId), undefined, { ...rest, signal: deadline() }));
|
|
60
|
+
if (!entry) {
|
|
61
|
+
throw new HttpError(`RCSB has no entry ${pdbId.toUpperCase()}`, 404);
|
|
62
|
+
}
|
|
63
|
+
return entry;
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
const delay = RETRY_DELAYS_MS[attempt];
|
|
67
|
+
// the caller's own abort is not a failure to retry either
|
|
68
|
+
if (delay === undefined || isDefinitiveFailure(e) || signal?.aborted) {
|
|
69
|
+
throw e;
|
|
70
|
+
}
|
|
71
|
+
await timeout(delay, signal);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** The entry's UniProt alignment alone. */
|
|
76
|
+
export async function fetchUniProtStructureMappings(pdbId, opts) {
|
|
77
|
+
return (await fetchPdbEntry(pdbId, opts)).mappings;
|
|
78
|
+
}
|
|
79
|
+
function isRecord(value) {
|
|
80
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
81
|
+
}
|
|
82
|
+
function finiteNumber(value) {
|
|
83
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
84
|
+
}
|
|
85
|
+
function strings(value) {
|
|
86
|
+
return Array.isArray(value)
|
|
87
|
+
? value.filter((v) => typeof v === 'string')
|
|
88
|
+
: [];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Parses the `data` of `pdbEntryQuery`. Undefined when RCSB has no such
|
|
92
|
+
* entry; an entry nothing aligns to UniProt (DNA alone, say) parses to no
|
|
93
|
+
* mappings. An unparseable alignment is skipped rather than failing the
|
|
94
|
+
* entry, so a chimera with one malformed region still maps its other chains.
|
|
95
|
+
*/
|
|
96
|
+
export function parsePdbEntry(data) {
|
|
97
|
+
const entry = isRecord(data) ? data.entry : undefined;
|
|
98
|
+
if (!isRecord(entry)) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
const entities = Array.isArray(entry.polymer_entities)
|
|
102
|
+
? entry.polymer_entities.filter(isRecord)
|
|
103
|
+
: [];
|
|
104
|
+
const byAccession = new Map();
|
|
105
|
+
const proteinSequences = [];
|
|
106
|
+
for (const entity of entities.toSorted((a, b) => entityNumber(a.rcsb_id) - entityNumber(b.rcsb_id))) {
|
|
107
|
+
const entityId = String(entityNumber(entity.rcsb_id));
|
|
108
|
+
const poly = isRecord(entity.entity_poly) ? entity.entity_poly : undefined;
|
|
109
|
+
const sequence = poly?.pdbx_seq_one_letter_code_can;
|
|
110
|
+
if (typeof poly?.type === 'string' &&
|
|
111
|
+
poly.type.startsWith('polypeptide') &&
|
|
112
|
+
typeof sequence === 'string' &&
|
|
113
|
+
sequence.length > 0) {
|
|
114
|
+
proteinSequences.push(sequence);
|
|
115
|
+
}
|
|
116
|
+
const ids = entity.rcsb_polymer_entity_container_identifiers;
|
|
117
|
+
const chains = strings(isRecord(ids) ? ids.auth_asym_ids : undefined);
|
|
118
|
+
const names = new Map((Array.isArray(entity.uniprots) ? entity.uniprots : [])
|
|
119
|
+
.filter(isRecord)
|
|
120
|
+
.map(u => [u.rcsb_id, strings(u.rcsb_uniprot_entry_name)[0]]));
|
|
121
|
+
for (const align of Array.isArray(entity.rcsb_polymer_entity_align)
|
|
122
|
+
? entity.rcsb_polymer_entity_align.filter(isRecord)
|
|
123
|
+
: []) {
|
|
124
|
+
const accession = align.reference_database_accession;
|
|
125
|
+
if (align.reference_database_name !== 'UniProt' ||
|
|
126
|
+
typeof accession !== 'string') {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const segments = (Array.isArray(align.aligned_regions) ? align.aligned_regions : []).flatMap(region => parseSegments(region, entityId, chains));
|
|
130
|
+
if (segments.length === 0) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const mapping = byAccession.get(accession) ?? {
|
|
134
|
+
accession,
|
|
135
|
+
name: names.get(accession),
|
|
136
|
+
segments: [],
|
|
137
|
+
};
|
|
138
|
+
mapping.segments.push(...segments);
|
|
139
|
+
byAccession.set(accession, mapping);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return { mappings: [...byAccession.values()], proteinSequences };
|
|
143
|
+
}
|
|
144
|
+
function entityNumber(rcsbId) {
|
|
145
|
+
return typeof rcsbId === 'string' ? Number(rcsbId.split('_')[1]) : NaN;
|
|
146
|
+
}
|
|
147
|
+
/** One segment per chain carrying the entity, so a PDB-format file, whose
|
|
148
|
+
* entities Mol* numbers per chain, still matches by chain. */
|
|
149
|
+
function parseSegments(region, entityId, chains) {
|
|
150
|
+
if (!isRecord(region)) {
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
const entityBeg = finiteNumber(region.entity_beg_seq_id);
|
|
154
|
+
const refBeg = finiteNumber(region.ref_beg_seq_id);
|
|
155
|
+
const length = finiteNumber(region.length);
|
|
156
|
+
if (entityBeg === undefined ||
|
|
157
|
+
refBeg === undefined ||
|
|
158
|
+
length === undefined ||
|
|
159
|
+
length < 1) {
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
const segment = {
|
|
163
|
+
entityId,
|
|
164
|
+
unpStart: refBeg,
|
|
165
|
+
unpEnd: refBeg + length - 1,
|
|
166
|
+
// SEQRES/label_seq_id is 1-based, structure positions are 0-based
|
|
167
|
+
structStart: entityBeg - 1,
|
|
168
|
+
structEnd: entityBeg + length - 2,
|
|
169
|
+
};
|
|
170
|
+
return chains.length === 0
|
|
171
|
+
? [segment]
|
|
172
|
+
: chains.map(chainId => ({ ...segment, chainId }));
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=pdbEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdbEntry.js","sourceRoot":"","sources":["../src/pdbEntry.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAC3E,sEAAsE;AACtE,2EAA2E;AAE3E,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,SAAS,EACT,OAAO,GACR,MAAM,iBAAiB,CAAA;AAQxB,MAAM,CAAC,MAAM,qBAAqB,GAAG,+BAA+B,CAAA;AAUpE,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,sBAAsB,KAAK,CAAC,WAAW,EAAE;;;;;;;;;MAS5C,CAAA;AACN,CAAC;AAED,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AACpC,uEAAuE;AACvE,MAAM,UAAU,GAAG,MAAM,CAAA;AAEzB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAW,EACX,KAAa,EACb,SAA8C,EAC9C,IAAmB;IAEnB,MAAM,IAAI,GAAY,MAAM,SAAS,CAAC,GAAG,EAAE;QACzC,GAAG,IAAI;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YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC1C,IACE,SAAS,KAAK,SAAS;QACvB,MAAM,KAAK,SAAS;QACpB,MAAM,KAAK,SAAS;QACpB,MAAM,GAAG,CAAC,EACV,CAAC;QACD,OAAO,EAAE,CAAA;IACX,CAAC;IACD,MAAM,OAAO,GAAG;QACd,QAAQ;QACR,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC;QAC3B,kEAAkE;QAClE,WAAW,EAAE,SAAS,GAAG,CAAC;QAC1B,SAAS,EAAE,SAAS,GAAG,MAAM,GAAG,CAAC;KAClC,CAAA;IACD,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC;QACxB,CAAC,CAAC,CAAC,OAAO,CAAC;QACX,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;AACtD,CAAC"}
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import type { FetchOptions } from './fetchUtils.ts';
|
|
2
1
|
/** One contiguous UniProt <-> structure correspondence for a single entity.
|
|
3
2
|
* `unp*` are 1-based UniProt positions; `struct*` are 0-based inclusive
|
|
4
|
-
* structure-sequence positions, this
|
|
3
|
+
* structure-sequence positions, this package's native coordinate. */
|
|
5
4
|
export interface UniProtStructureSegment {
|
|
6
5
|
entityId: string;
|
|
7
|
-
/** author chain id, when the
|
|
6
|
+
/** author chain id, when the source names it */
|
|
8
7
|
chainId?: string;
|
|
9
8
|
unpStart: number;
|
|
10
9
|
unpEnd: number;
|
|
11
10
|
structStart: number;
|
|
12
11
|
structEnd: number;
|
|
13
|
-
/** the endpoints' author residue numbers, the numbering a paper cites and a
|
|
14
|
-
* Mol* hover shows; absent when the response omits them */
|
|
15
|
-
authorStart?: number;
|
|
16
|
-
authorEnd?: number;
|
|
17
12
|
}
|
|
18
13
|
export interface UniProtStructureMapping {
|
|
19
14
|
accession: string;
|
|
@@ -27,27 +22,7 @@ export interface UniProtStructureMapping {
|
|
|
27
22
|
* the feature instead of drawing it somewhere misleading.
|
|
28
23
|
*/
|
|
29
24
|
export type MapUniProtPosition = (uniprotPos: number) => number | undefined;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* SIFTS for an entry, retried twice: one failed request would otherwise leave a
|
|
33
|
-
* fusion construct mapped onto its partner for the whole session.
|
|
34
|
-
*
|
|
35
|
-
* A 4xx is not retried. PDBe answers 404 for an entry it has no UniProt
|
|
36
|
-
* mapping for at all — a DNA-only or obsolete entry — and that answer cannot
|
|
37
|
-
* change, so the retries only postponed it: measured 2026-09-16, `1hhb` and
|
|
38
|
-
* `1bna` each took three requests and ~4.8s to say so, which a caller shows as
|
|
39
|
-
* four and a half seconds of "resolving" for a structure that will never
|
|
40
|
-
* resolve.
|
|
41
|
-
*/
|
|
42
|
-
export declare function fetchUniProtStructureMappings(pdbId: string, opts?: FetchOptions): Promise<UniProtStructureMapping[]>;
|
|
43
|
-
/**
|
|
44
|
-
* Parses a PDBe `mappings/uniprot/{pdbId}` response into one entry per UniProt
|
|
45
|
-
* accession. Unparseable segments are skipped rather than failing the whole
|
|
46
|
-
* response — a chimera with one malformed segment still maps its other chains.
|
|
47
|
-
* The response is keyed by pdb id, so the single entry is taken whatever its key.
|
|
48
|
-
*/
|
|
49
|
-
export declare function parseUniProtStructureMappings(json: unknown): UniProtStructureMapping[];
|
|
50
|
-
/** The entity a SIFTS segment is matched against: its mmCIF id and the author
|
|
25
|
+
/** The entity a segment is matched against: its mmCIF id and the author
|
|
51
26
|
* chains carrying it. */
|
|
52
27
|
export interface SegmentEntity {
|
|
53
28
|
entityId: string;
|
|
@@ -63,10 +38,11 @@ export interface SegmentEntity {
|
|
|
63
38
|
*/
|
|
64
39
|
export declare function chooseUniProtMappingForEntity(mappings: UniProtStructureMapping[], entity: SegmentEntity | undefined): UniProtStructureMapping | undefined;
|
|
65
40
|
/**
|
|
66
|
-
* Mapped structure positions
|
|
67
|
-
* transcript's, on a chain that fuses two. Local
|
|
68
|
-
* boundary, and on every GPCR fusion construct
|
|
69
|
-
* residues onto the partner, 33 of them onto T4
|
|
41
|
+
* Mapped structure positions the entry's UniProt alignment assigns to a
|
|
42
|
+
* protein other than the transcript's, on a chain that fuses two. Local
|
|
43
|
+
* alignment bridges a fusion boundary, and on every GPCR fusion construct
|
|
44
|
+
* checked it scattered receptor residues onto the partner, 33 of them onto T4
|
|
45
|
+
* lysozyme in 2RH1.
|
|
70
46
|
*
|
|
71
47
|
* `mapped` is each mapped structure position and whether its pair is
|
|
72
48
|
* identical. The transcript's own accession is the one whose covered positions
|
|
@@ -75,7 +51,7 @@ export declare function chooseUniProtMappingForEntity(mappings: UniProtStructure
|
|
|
75
51
|
* fused to CDK2 covers 11 positions against 224 chance hits on the kinase, and
|
|
76
52
|
* counting unmapped the peptide. Unless that accession reaches half identity
|
|
77
53
|
* the transcript is taken to be neither protein, and nothing is unmapped.
|
|
78
|
-
* Residues
|
|
54
|
+
* Residues assigned to no accession, such as tags, stay mapped.
|
|
79
55
|
*/
|
|
80
56
|
export declare function fusionPartnerPositions(mappings: UniProtStructureMapping[], entity: SegmentEntity | undefined, mapped: ReadonlyMap<number, boolean>): Set<number>;
|
|
81
57
|
/** 1-based UniProt position -> 0-based structure position, for an AlphaFold
|
package/esm/pdbUniProtMapping.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// UniProt <-> PDB residue mapping.
|
|
2
2
|
//
|
|
3
3
|
// UniProt feature coordinates are positions in the UniProt canonical sequence.
|
|
4
4
|
// For an AlphaFold model that *is* the structure's own sequence, so a feature at
|
|
@@ -6,134 +6,19 @@
|
|
|
6
6
|
// entry it is not: the deposited construct is usually a fragment, often with
|
|
7
7
|
// tags or engineered residues, so the two numberings differ by a per-segment
|
|
8
8
|
// offset (1TUP's p53 chain starts at UniProt 94; 6VXX's spike SEQRES 33 is
|
|
9
|
-
// UniProt 14).
|
|
10
|
-
//
|
|
9
|
+
// UniProt 14). The entry's own UniProt alignment, which `fetchPdbEntry` reads
|
|
10
|
+
// from RCSB, is the authority on that correspondence.
|
|
11
11
|
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
// position + 1 (see applyLociInteractivity.ts for the other place that boundary
|
|
15
|
-
// is crossed).
|
|
16
|
-
import { isDefinitiveFailure, jsonfetch, timeout } from "./fetchUtils.js";
|
|
17
|
-
export function pdbeSiftsUrl(pdbId) {
|
|
18
|
-
return `https://www.ebi.ac.uk/pdbe/api/mappings/uniprot/${pdbId.toLowerCase()}`;
|
|
19
|
-
}
|
|
20
|
-
const SIFTS_RETRY_DELAYS_MS = [1000, 3000];
|
|
21
|
-
// bounded, since a view reports itself loading until SIFTS answers
|
|
22
|
-
const SIFTS_TIMEOUT_MS = 20_000;
|
|
23
|
-
/**
|
|
24
|
-
* SIFTS for an entry, retried twice: one failed request would otherwise leave a
|
|
25
|
-
* fusion construct mapped onto its partner for the whole session.
|
|
26
|
-
*
|
|
27
|
-
* A 4xx is not retried. PDBe answers 404 for an entry it has no UniProt
|
|
28
|
-
* mapping for at all — a DNA-only or obsolete entry — and that answer cannot
|
|
29
|
-
* change, so the retries only postponed it: measured 2026-09-16, `1hhb` and
|
|
30
|
-
* `1bna` each took three requests and ~4.8s to say so, which a caller shows as
|
|
31
|
-
* four and a half seconds of "resolving" for a structure that will never
|
|
32
|
-
* resolve.
|
|
33
|
-
*/
|
|
34
|
-
export async function fetchUniProtStructureMappings(pdbId, opts) {
|
|
35
|
-
const { signal: caller, ...rest } = opts ?? {};
|
|
36
|
-
const signal = caller ?? undefined;
|
|
37
|
-
const deadline = () => signal
|
|
38
|
-
? AbortSignal.any([signal, AbortSignal.timeout(SIFTS_TIMEOUT_MS)])
|
|
39
|
-
: AbortSignal.timeout(SIFTS_TIMEOUT_MS);
|
|
40
|
-
for (let attempt = 0;; attempt++) {
|
|
41
|
-
try {
|
|
42
|
-
return parseUniProtStructureMappings(await jsonfetch(pdbeSiftsUrl(pdbId), { ...rest, signal: deadline() }));
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
const delay = SIFTS_RETRY_DELAYS_MS[attempt];
|
|
46
|
-
// the caller's own abort is not a failure to retry either
|
|
47
|
-
if (delay === undefined || isDefinitiveFailure(e) || signal?.aborted) {
|
|
48
|
-
throw e;
|
|
49
|
-
}
|
|
50
|
-
await timeout(delay, signal);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function isRecord(value) {
|
|
55
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
56
|
-
}
|
|
57
|
-
function finiteNumber(value) {
|
|
58
|
-
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
59
|
-
}
|
|
60
|
-
function residueNumber(endpoint) {
|
|
61
|
-
return isRecord(endpoint) ? finiteNumber(endpoint.residue_number) : undefined;
|
|
62
|
-
}
|
|
63
|
-
function authorResidueNumber(endpoint) {
|
|
64
|
-
return isRecord(endpoint)
|
|
65
|
-
? finiteNumber(endpoint.author_residue_number)
|
|
66
|
-
: undefined;
|
|
67
|
-
}
|
|
68
|
-
function parseSegment(mapping) {
|
|
69
|
-
if (!isRecord(mapping)) {
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
const entityId = finiteNumber(mapping.entity_id);
|
|
73
|
-
const unpStart = finiteNumber(mapping.unp_start);
|
|
74
|
-
const unpEnd = finiteNumber(mapping.unp_end);
|
|
75
|
-
const structStart = residueNumber(mapping.start);
|
|
76
|
-
const structEnd = residueNumber(mapping.end);
|
|
77
|
-
const authorStart = authorResidueNumber(mapping.start);
|
|
78
|
-
const authorEnd = authorResidueNumber(mapping.end);
|
|
79
|
-
return entityId === undefined ||
|
|
80
|
-
unpStart === undefined ||
|
|
81
|
-
unpEnd === undefined ||
|
|
82
|
-
structStart === undefined ||
|
|
83
|
-
structEnd === undefined
|
|
84
|
-
? undefined
|
|
85
|
-
: {
|
|
86
|
-
entityId: String(entityId),
|
|
87
|
-
...(typeof mapping.chain_id === 'string'
|
|
88
|
-
? { chainId: mapping.chain_id }
|
|
89
|
-
: {}),
|
|
90
|
-
unpStart,
|
|
91
|
-
unpEnd,
|
|
92
|
-
// SEQRES/label_seq_id is 1-based, structure positions are 0-based
|
|
93
|
-
structStart: structStart - 1,
|
|
94
|
-
structEnd: structEnd - 1,
|
|
95
|
-
...(authorStart === undefined ? {} : { authorStart }),
|
|
96
|
-
...(authorEnd === undefined ? {} : { authorEnd }),
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Parses a PDBe `mappings/uniprot/{pdbId}` response into one entry per UniProt
|
|
101
|
-
* accession. Unparseable segments are skipped rather than failing the whole
|
|
102
|
-
* response — a chimera with one malformed segment still maps its other chains.
|
|
103
|
-
* The response is keyed by pdb id, so the single entry is taken whatever its key.
|
|
104
|
-
*/
|
|
105
|
-
export function parseUniProtStructureMappings(json) {
|
|
106
|
-
const entry = isRecord(json) ? Object.values(json)[0] : undefined;
|
|
107
|
-
const uniprot = isRecord(entry) ? entry.UniProt : undefined;
|
|
108
|
-
if (!isRecord(uniprot)) {
|
|
109
|
-
return [];
|
|
110
|
-
}
|
|
111
|
-
const result = [];
|
|
112
|
-
for (const [accession, value] of Object.entries(uniprot)) {
|
|
113
|
-
const mappings = isRecord(value) ? value.mappings : undefined;
|
|
114
|
-
const segments = Array.isArray(mappings)
|
|
115
|
-
? mappings.map(parseSegment).filter(s => s !== undefined)
|
|
116
|
-
: [];
|
|
117
|
-
if (segments.length > 0) {
|
|
118
|
-
result.push({
|
|
119
|
-
accession,
|
|
120
|
-
name: isRecord(value) && typeof value.name === 'string'
|
|
121
|
-
? value.name
|
|
122
|
-
: undefined,
|
|
123
|
-
segments,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return result;
|
|
128
|
-
}
|
|
12
|
+
// Structure positions here index the entity's SEQRES from 0, i.e.
|
|
13
|
+
// label_seq_id - 1, which is this package's structure-sequence position.
|
|
129
14
|
function coveredResidues(segments) {
|
|
130
15
|
return segments.reduce((a, s) => a + (s.structEnd - s.structStart + 1), 0);
|
|
131
16
|
}
|
|
132
17
|
/**
|
|
133
|
-
* The segments of one accession that describe this entity.
|
|
134
|
-
* entities as the mmCIF does, and a PDB-format file loaded through
|
|
135
|
-
* them per chain (1H26.pdb's chain C is entity 2, which in
|
|
136
|
-
* so a segment naming its chain is matched by chain.
|
|
18
|
+
* The segments of one accession that describe this entity. The mapping
|
|
19
|
+
* numbers entities as the mmCIF does, and a PDB-format file loaded through
|
|
20
|
+
* Mol* numbers them per chain (1H26.pdb's chain C is entity 2, which in the
|
|
21
|
+
* mmCIF is cyclin A), so a segment naming its chain is matched by chain.
|
|
137
22
|
*/
|
|
138
23
|
function segmentsForEntity(mapping, entity) {
|
|
139
24
|
return dedupeSegments(mapping.segments.filter(s => s.chainId === undefined
|
|
@@ -165,10 +50,11 @@ export function chooseUniProtMappingForEntity(mappings, entity) {
|
|
|
165
50
|
const OWN_PSEUDOCOUNT = 5;
|
|
166
51
|
const MIN_OWN_IDENTITY = 0.5;
|
|
167
52
|
/**
|
|
168
|
-
* Mapped structure positions
|
|
169
|
-
* transcript's, on a chain that fuses two. Local
|
|
170
|
-
* boundary, and on every GPCR fusion construct
|
|
171
|
-
* residues onto the partner, 33 of them onto T4
|
|
53
|
+
* Mapped structure positions the entry's UniProt alignment assigns to a
|
|
54
|
+
* protein other than the transcript's, on a chain that fuses two. Local
|
|
55
|
+
* alignment bridges a fusion boundary, and on every GPCR fusion construct
|
|
56
|
+
* checked it scattered receptor residues onto the partner, 33 of them onto T4
|
|
57
|
+
* lysozyme in 2RH1.
|
|
172
58
|
*
|
|
173
59
|
* `mapped` is each mapped structure position and whether its pair is
|
|
174
60
|
* identical. The transcript's own accession is the one whose covered positions
|
|
@@ -177,7 +63,7 @@ const MIN_OWN_IDENTITY = 0.5;
|
|
|
177
63
|
* fused to CDK2 covers 11 positions against 224 chance hits on the kinase, and
|
|
178
64
|
* counting unmapped the peptide. Unless that accession reaches half identity
|
|
179
65
|
* the transcript is taken to be neither protein, and nothing is unmapped.
|
|
180
|
-
* Residues
|
|
66
|
+
* Residues assigned to no accession, such as tags, stay mapped.
|
|
181
67
|
*/
|
|
182
68
|
export function fusionPartnerPositions(mappings, entity, mapped) {
|
|
183
69
|
const partners = new Set();
|
|
@@ -214,8 +100,8 @@ export function fusionPartnerPositions(mappings, entity, mapped) {
|
|
|
214
100
|
}
|
|
215
101
|
return partners;
|
|
216
102
|
}
|
|
217
|
-
//
|
|
218
|
-
// repeat the same entity-level correspondence. They collapse to one
|
|
103
|
+
// The mapping lists one segment per *chain*, so the several chains of a
|
|
104
|
+
// homodimer repeat the same entity-level correspondence. They collapse to one.
|
|
219
105
|
function dedupeSegments(segments) {
|
|
220
106
|
const seen = new Set();
|
|
221
107
|
return segments.filter(s => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdbUniProtMapping.js","sourceRoot":"","sources":["../src/pdbUniProtMapping.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"pdbUniProtMapping.js","sourceRoot":"","sources":["../src/pdbUniProtMapping.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,EAAE;AACF,+EAA+E;AAC/E,iFAAiF;AACjF,+EAA+E;AAC/E,6EAA6E;AAC7E,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,sDAAsD;AACtD,EAAE;AACF,kEAAkE;AAClE,yEAAyE;AA6BzE,SAAS,eAAe,CAAC,QAAmC;IAC1D,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAC5E,CAAC;A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AG,OAAO,CAAC,QAAQ,CAAC,CAAA;QACjE,OAAO,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAA;IACnD,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { FetchOptions } from './fetchUtils.ts';
|
|
2
|
+
export declare const RCSB_SEQUENCE_COORDINATES_URL = "https://sequence-coordinates.rcsb.org/graphql";
|
|
2
3
|
export interface ExperimentalStructure {
|
|
3
4
|
pdbId: string;
|
|
5
|
+
/** RCSB's name for it: 'X-ray', 'EM', 'NMR', ... */
|
|
4
6
|
method: string;
|
|
5
7
|
/** Å; absent for NMR and some EM entries */
|
|
6
8
|
resolution?: number;
|
|
@@ -9,20 +11,42 @@ export interface ExperimentalStructure {
|
|
|
9
11
|
end: number;
|
|
10
12
|
/** fraction of the UniProt sequence the entry covers, 0..1 */
|
|
11
13
|
coverage: number;
|
|
14
|
+
/** author chain ids carrying the protein */
|
|
15
|
+
chains: string[];
|
|
12
16
|
}
|
|
13
|
-
|
|
17
|
+
/** One polymer entity aligned to the accession. */
|
|
18
|
+
export interface EntityAlignment {
|
|
19
|
+
/** RCSB's id, "1TUP_3" */
|
|
20
|
+
entityId: string;
|
|
21
|
+
pdbId: string;
|
|
22
|
+
start: number;
|
|
23
|
+
end: number;
|
|
24
|
+
coverage: number;
|
|
25
|
+
}
|
|
26
|
+
export interface EntityDetails {
|
|
27
|
+
method: string;
|
|
28
|
+
resolution?: number;
|
|
29
|
+
chains: string[];
|
|
30
|
+
}
|
|
31
|
+
export declare function entityAlignmentsQuery(uniprotId: string): string;
|
|
32
|
+
export declare const ENTITY_DETAILS_QUERY = "query($ids: [String!]!) { polymer_entities(entity_ids: $ids) {\n rcsb_id\n rcsb_polymer_entity_container_identifiers { auth_asym_ids }\n entry { rcsb_entry_info { experimental_method resolution_combined } }\n} }";
|
|
33
|
+
/**
|
|
34
|
+
* PDB entities only: the same list carries RCSB's computed models
|
|
35
|
+
* (`AF_AFP04637F1_1`), which a residue mapping does not exist for. The range
|
|
36
|
+
* spans every aligned region, as 3D-Beacons reported it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseEntityAlignments(data: unknown): EntityAlignment[];
|
|
39
|
+
export declare function parseEntityDetails(data: unknown): Map<string, EntityDetails>;
|
|
40
|
+
/**
|
|
41
|
+
* One row per entry, best coverage first and sharpest within a tie. An entry
|
|
42
|
+
* with several entities of the protein (a construct crystallised beside a
|
|
43
|
+
* different fragment of itself) takes the best-covering entity's range and
|
|
44
|
+
* every entity's chains.
|
|
45
|
+
*/
|
|
46
|
+
export declare function experimentalStructures(alignments: EntityAlignment[], details: ReadonlyMap<string, EntityDetails>): ExperimentalStructure[];
|
|
14
47
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* prediction comes from AlphaFold's own API, which answers per model. And
|
|
19
|
-
* 3D-Beacons files SASBDB's small-angle-scattering fits under "experimentally
|
|
20
|
-
* determined" too, with numeric ids and near-full coverage — dystrophin's best
|
|
21
|
-
* "structure" by coverage was SASBDB 436 — which are not entries a residue
|
|
22
|
-
* mapping exists for. Hence the `provider === 'PDBe'` gate rather than the
|
|
23
|
-
* category alone.
|
|
48
|
+
* Every PDB entry aligned to the accession. An accession with none, or one
|
|
49
|
+
* RCSB does not know, is `[]`; an isoform accession is asked as its entry,
|
|
50
|
+
* which is what the alignment is numbered on.
|
|
24
51
|
*/
|
|
25
|
-
export declare function parseExperimentalStructures(json: unknown): ExperimentalStructure[];
|
|
26
|
-
/** Best-effort: an unreachable API reads as "no entries", which costs a
|
|
27
|
-
* structure suggestion and nothing else. */
|
|
28
52
|
export declare function fetchExperimentalStructures(uniprotId: string, opts?: FetchOptions): Promise<ExperimentalStructure[]>;
|