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.
Files changed (134) hide show
  1. package/README.md +220 -39
  2. package/dist/alignmentQuality.d.ts +5 -5
  3. package/dist/alphaFoldModels.d.ts +4 -4
  4. package/dist/alphaFoldModels.js +4 -4
  5. package/dist/chooseMappedEntity.d.ts +11 -13
  6. package/dist/chooseMappedEntity.js +9 -12
  7. package/dist/chooseMappedEntity.js.map +1 -1
  8. package/dist/coordinates.d.ts +19 -19
  9. package/dist/coordinates.js.map +1 -1
  10. package/dist/dbIds.d.ts +1 -2
  11. package/dist/extractPerResidueConfidence.d.ts +1 -2
  12. package/dist/extractStructureSequences.d.ts +26 -34
  13. package/dist/extractStructureSequences.js +2 -2
  14. package/dist/extractStructureSequences.js.map +1 -1
  15. package/dist/fetchUtils.d.ts +7 -7
  16. package/dist/fetchUtils.js +26 -8
  17. package/dist/fetchUtils.js.map +1 -1
  18. package/dist/index.d.ts +1 -3
  19. package/dist/index.js +2 -4
  20. package/dist/index.js.map +1 -1
  21. package/dist/isoformRanking.d.ts +4 -1
  22. package/dist/mappings.d.ts +9 -12
  23. package/dist/mappings.js +4 -5
  24. package/dist/mappings.js.map +1 -1
  25. package/dist/pairwiseAlignment.d.ts +5 -4
  26. package/dist/pairwiseAlignment.js +9 -7
  27. package/dist/pairwiseAlignment.js.map +1 -1
  28. package/dist/pdbEntry.d.ts +32 -0
  29. package/dist/pdbEntry.js +182 -0
  30. package/dist/pdbEntry.js.map +1 -0
  31. package/dist/pdbUniProtMapping.d.ts +14 -39
  32. package/dist/pdbUniProtMapping.js +22 -140
  33. package/dist/pdbUniProtMapping.js.map +1 -1
  34. package/dist/structureFormat.d.ts +11 -18
  35. package/dist/structureFormat.js +4 -6
  36. package/dist/structureFormat.js.map +1 -1
  37. package/dist/structureSources.d.ts +37 -13
  38. package/dist/structureSources.js +144 -57
  39. package/dist/structureSources.js.map +1 -1
  40. package/dist/structureUrls.d.ts +13 -16
  41. package/dist/structureUrls.js +25 -23
  42. package/dist/structureUrls.js.map +1 -1
  43. package/dist/types.d.ts +2 -5
  44. package/dist/types.js +2 -5
  45. package/dist/types.js.map +1 -1
  46. package/dist/uniProtSearch.js +3 -8
  47. package/dist/uniProtSearch.js.map +1 -1
  48. package/esm/alignmentQuality.d.ts +5 -5
  49. package/esm/alphaFoldModels.d.ts +4 -4
  50. package/esm/alphaFoldModels.js +4 -4
  51. package/esm/chooseMappedEntity.d.ts +11 -13
  52. package/esm/chooseMappedEntity.js +9 -12
  53. package/esm/chooseMappedEntity.js.map +1 -1
  54. package/esm/coordinates.d.ts +19 -19
  55. package/esm/coordinates.js.map +1 -1
  56. package/esm/dbIds.d.ts +1 -2
  57. package/esm/extractPerResidueConfidence.d.ts +1 -2
  58. package/esm/extractStructureSequences.d.ts +26 -34
  59. package/esm/extractStructureSequences.js +2 -2
  60. package/esm/extractStructureSequences.js.map +1 -1
  61. package/esm/fetchUtils.d.ts +7 -7
  62. package/esm/fetchUtils.js +26 -8
  63. package/esm/fetchUtils.js.map +1 -1
  64. package/esm/index.d.ts +1 -3
  65. package/esm/index.js +2 -4
  66. package/esm/index.js.map +1 -1
  67. package/esm/isoformRanking.d.ts +4 -1
  68. package/esm/mappings.d.ts +9 -12
  69. package/esm/mappings.js +4 -5
  70. package/esm/mappings.js.map +1 -1
  71. package/esm/pairwiseAlignment.d.ts +5 -4
  72. package/esm/pairwiseAlignment.js +7 -5
  73. package/esm/pairwiseAlignment.js.map +1 -1
  74. package/esm/pdbEntry.d.ts +32 -0
  75. package/esm/pdbEntry.js +174 -0
  76. package/esm/pdbEntry.js.map +1 -0
  77. package/esm/pdbUniProtMapping.d.ts +14 -39
  78. package/esm/pdbUniProtMapping.js +22 -137
  79. package/esm/pdbUniProtMapping.js.map +1 -1
  80. package/esm/structureFormat.d.ts +11 -18
  81. package/esm/structureFormat.js +4 -6
  82. package/esm/structureFormat.js.map +1 -1
  83. package/esm/structureSources.d.ts +37 -13
  84. package/esm/structureSources.js +139 -55
  85. package/esm/structureSources.js.map +1 -1
  86. package/esm/structureUrls.d.ts +13 -16
  87. package/esm/structureUrls.js +23 -23
  88. package/esm/structureUrls.js.map +1 -1
  89. package/esm/types.d.ts +2 -5
  90. package/esm/types.js +2 -5
  91. package/esm/types.js.map +1 -1
  92. package/esm/uniProtSearch.js +3 -8
  93. package/esm/uniProtSearch.js.map +1 -1
  94. package/package.json +3 -2
  95. package/src/alignmentQuality.ts +5 -5
  96. package/src/alphaFoldModels.ts +4 -4
  97. package/src/chooseMappedEntity.ts +12 -15
  98. package/src/coordinates.ts +14 -17
  99. package/src/dbIds.ts +1 -1
  100. package/src/extractPerResidueConfidence.ts +1 -1
  101. package/src/extractStructureSequences.ts +26 -33
  102. package/src/fetchUtils.ts +30 -8
  103. package/src/index.ts +2 -4
  104. package/src/isoformRanking.ts +4 -4
  105. package/src/mappings.ts +9 -12
  106. package/src/pairwiseAlignment.ts +12 -9
  107. package/src/pdbEntry.ts +240 -0
  108. package/src/pdbUniProtMapping.ts +25 -164
  109. package/src/structureFormat.ts +11 -18
  110. package/src/structureSources.ts +194 -70
  111. package/src/structureUrls.ts +25 -23
  112. package/src/types.ts +2 -5
  113. package/src/uniProtSearch.ts +3 -8
  114. package/dist/pdbeBestStructures.d.ts +0 -23
  115. package/dist/pdbeBestStructures.js +0 -79
  116. package/dist/pdbeBestStructures.js.map +0 -1
  117. package/dist/pdbeEntryMolecules.d.ts +0 -7
  118. package/dist/pdbeEntryMolecules.js +0 -39
  119. package/dist/pdbeEntryMolecules.js.map +0 -1
  120. package/dist/siftsNumbering.d.ts +0 -23
  121. package/dist/siftsNumbering.js +0 -44
  122. package/dist/siftsNumbering.js.map +0 -1
  123. package/esm/pdbeBestStructures.d.ts +0 -23
  124. package/esm/pdbeBestStructures.js +0 -73
  125. package/esm/pdbeBestStructures.js.map +0 -1
  126. package/esm/pdbeEntryMolecules.d.ts +0 -7
  127. package/esm/pdbeEntryMolecules.js +0 -35
  128. package/esm/pdbeEntryMolecules.js.map +0 -1
  129. package/esm/siftsNumbering.d.ts +0 -23
  130. package/esm/siftsNumbering.js +0 -40
  131. package/esm/siftsNumbering.js.map +0 -1
  132. package/src/pdbeBestStructures.ts +0 -94
  133. package/src/pdbeEntryMolecules.ts +0 -37
  134. package/src/siftsNumbering.ts +0 -61
@@ -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 concrete structure URL, so a
14
- * hand-authored snapshot or a short launch URL doesn't have to know RCSB's
15
- * filename format. An explicit `url` (or inline `data`) always wins.
16
- * Idempotent: re-resolving an already-resolved spec returns the same url.
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` deliberately resolves to no url here, and still outranks a
19
- * `pdbId`. An accession's files are whatever AlphaFold DB currently holds — an
20
- * isoform model, several fragments, a new model version — so the structure
21
- * keeps the accession and the structure loader asks the prediction API which
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
- * What a structure is called in the UI: its PDB id, its AlphaFold accession,
47
- * else the file's name. Shared by the view title, the alignment panel heading
48
- * and the hover readout, so one structure reads the same everywhere.
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;
@@ -1,11 +1,7 @@
1
- // Pure structure-URL builders and target parsers. Kept dependency-free so both
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 (the GFF the feature tracks and
6
- // the alignment's annotation rows both read, the FASTA the temporary protein
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 concrete structure URL, so a
32
- * hand-authored snapshot or a short launch URL doesn't have to know RCSB's
33
- * filename format. An explicit `url` (or inline `data`) always wins.
34
- * Idempotent: re-resolving an already-resolved spec returns the same url.
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
- * Shared by the Structure model's snapshot preprocessor and the
43
- * LaunchView-ProteinView extension point, which would otherwise each carry
44
- * their own copy of the same precedence rule.
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
- * What a structure is called in the UI: its PDB id, its AlphaFold accession,
112
- * else the file's name. Shared by the view title, the alignment panel heading
113
- * and the hover readout, so one structure reads the same everywhere.
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) {
@@ -1 +1 @@
1
- {"version":3,"file":"structureUrls.js","sourceRoot":"","sources":["../src/structureUrls.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,kF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gBACT,CAAC,CAAC,aAAa,SAAS,EAAE;gBAC1B,CAAC,CAAC,EAAE,CAAA;IACV,CAAC;IACD,MAAM,KAAK,GAAG,eAAe,CAAC,GAAG,CAAC,CAAA;IAClC,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,KAAK,CAAC,WAAW,EAAE,CAAA;IAC5B,CAAC;IACD,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
- * Parses an untrusted algorithm name (a URL session-spec param) into the union.
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
- * Parses an untrusted algorithm name (a URL session-spec param) into the union.
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;;;;GAIG;AACH,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"}
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"}
@@ -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
- // The taxon itself has answered, so the wider question failing leaves
63
- // that answer standing rather than turning an empty result into an error.
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((e) => {
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
  }
@@ -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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C,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,MAAM;QACrD,CAAC,mBAAmB,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,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, SIFTS, and the AlphaFold and PDBe lookups that find the structure",
4
- "version": "1.4.0",
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",
@@ -7,21 +7,21 @@ import {
7
7
  import type { PairwiseAlignment } from './mappings.ts'
8
8
 
9
9
  export interface AlignmentQuality {
10
- /** columns carrying a residue on both rows, i.e. mapped positions */
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: the statistic that
18
- * separates a real match from a chance local alignment, see below */
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, and
24
- * which part of the protein it holds is the reader's first question. */
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
  }
@@ -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 the view maps it as an
82
- * identity; else the canonical model; else the longest isoform model.
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 the structure loader knows one
85
- * translation rather than a gene's isoforms.
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 into the candidate array of the entity that is the transcript's */
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 (stop codons stripped on
33
- * both sides, matching the rest of the mapping pipeline) */
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 asks the question the picker actually has, which chain *is* this
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 which polymer entity of a structure corresponds to the transcript.
138
+ * Pick the polymer entity of a structure that is the transcript's protein.
140
139
  *
141
- * The plugin historically hardcoded entity `[0]`, which silently mis-maps every
142
- * heteromeric / protein-DNA / processed-peptide structure where the protein of
143
- * interest is some other chain. Selecting by alignment makes the structure self-
144
- * describe which entity is the gene's protein: an exact sequence match wins
145
- * outright, otherwise the entity with the highest identity over the shorter
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 (no transcript or no
150
- * protein entities) — never a silent fallback to the wrong entity.
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,
@@ -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 in this plugin is a bare `number`,
12
- * but the *meaning* differs: a structure residue index is not interchangeable
13
- * with a transcript residue index or an alignment column, and mixing them is
14
- * the root cause of the off-by-one class of bugs. Branding makes the compiler
15
- * reject cross-space mixing; construct values with the helpers below at the
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
- * Conventions: all are 0-based. StructurePos indexes the ungapped structure
19
- * sequence; TranscriptPos the ungapped transcript sequence; AlignmentCol a
20
- * column of the pairwise alignment (gaps included).
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 Branded<B extends string> = number & { readonly __brand: B }
23
- export type StructurePos = Branded<'StructurePos'>
24
- export type TranscriptPos = Branded<'TranscriptPos'>
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
- * Raw lookup tables, for consumers that iterate the whole map rather than
49
- * convert a single position (e.g. per-residue track rendering, selection of
50
- * all aligned residues). Plain numbers — prefer the typed methods above for
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 of those residues.
2
+ * sequence, and the molstar `label_seq_id` of each residue.
3
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.
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
- * `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.
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 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 */
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. 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. */
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 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`. */
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 the launch dialog's isoform matching,
288
- * which has no use for a DNA strand that happens to align. */
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 deserves: status and host, plus at most the first
40
- * line of the body. A whole body is an HTML error page or a megabyte of JSON,
41
- * and pasting it into the dialog buries the one line that says what went wrong.
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` — usually a
109
- * DOMException, but a caller can abort with anything at all — and throwing a
110
- * non-Error loses the stack and breaks `instanceof Error` checks in the UI's
111
- * error rendering. Normalize at every throw site.
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
- // SIFTS
19
+ // UniProt mapping
20
20
  export * from './pdbUniProtMapping.ts'
21
- export * from './siftsNumbering.ts'
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'
@@ -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 is what ranks non-matching isoforms */
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
- // protein matches the structure residues, longest first
25
+ /** translates to exactly the structure's sequence, longest first */
26
26
  matches: RankedIsoform[]
27
- // has a protein sequence but doesn't match the structure, best-aligning first
27
+ /** translates to something else, best-aligning first */
28
28
  nonMatches: RankedIsoform[]
29
- // ids of the isoforms no protein sequence could be computed for
29
+ /** ids of the isoforms with no translation */
30
30
  noData: string[]
31
31
  }
32
32