protvista-uniprot 4.4.0 → 4.4.1

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.
@@ -1,5 +1,7 @@
1
1
  import { PTM } from '../adapters/ptm-exchange-adapter';
2
2
  export declare const phosphorylate: (aa: string) => string;
3
3
  export declare const sumoylate: (aa: string) => string;
4
+ export declare const ubiquitinate: (aa: string) => string;
5
+ export declare const acetylate: (aa: string) => string;
4
6
  declare const formatTooltip: (title: string, ptms: PTM[], aa: string, confidenceScore: string) => string;
5
7
  export default formatTooltip;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "protvista-uniprot",
3
3
  "description": "ProtVista tool for the UniProt website",
4
- "version": "4.4.0",
4
+ "version": "4.4.1",
5
5
  "files": [
6
6
  "dist",
7
7
  "src"
@@ -36,7 +36,7 @@
36
36
  "@nightingale-elements/nightingale-manager": "5.6.0",
37
37
  "@nightingale-elements/nightingale-navigation": "5.6.0",
38
38
  "@nightingale-elements/nightingale-sequence": "5.6.0",
39
- "@nightingale-elements/nightingale-sequence-heatmap": "5.6.0",
39
+ "@nightingale-elements/nightingale-sequence-heatmap": "5.6.2",
40
40
  "@nightingale-elements/nightingale-structure": "5.7.0",
41
41
  "@nightingale-elements/nightingale-track-canvas": "5.6.0",
42
42
  "@nightingale-elements/nightingale-variation": "5.6.0",
@@ -1,15 +1,38 @@
1
1
  import { AlphafoldPayload } from './types/alphafold';
2
2
 
3
- // from example data
4
- // benign: [0.0448,0.3397]: x < 0.34
5
- // ambiguous: [0.34,0.564]: 0.34 <= x <= 0.564
6
- // pathogenic: [0.5646,0.9999]: 0.564 < x
7
- const benign = 0.34;
8
- const pathogenic = 0.564;
3
+ // from color scale B:0,H:0.1132,V:0.2264,L:0.3395,A:0.4527,l:0.5895,h:0.7264,p:0.8632,P:1
4
+ const certainlyBenign = 0;
5
+ const benign = 0.1132;
6
+ const veryLikelyBenign = 0.2264;
7
+ const likelyBenign = 0.3395;
8
+ const ambiguous = 0.4527;
9
+ const likelyAmbiguous = 0.5895;
10
+ const likelyPathogenic = 0.7264;
11
+ const pathogenic = 0.8632;
12
+ const certainlyPathogenic = 1;
9
13
 
10
14
  export const rowSplitter = /\s*\n\s*/;
11
15
  export const cellSplitter = /^(.)(\d+)(.),(.+),(\w+)$/;
12
16
 
17
+ const pathogenicityCategories = [
18
+ { min: certainlyBenign, max: benign, code: 'H' },
19
+ { min: benign, max: veryLikelyBenign, code: 'V' },
20
+ { min: veryLikelyBenign, max: likelyBenign, code: 'L' },
21
+ { min: likelyBenign, max: ambiguous, code: 'A' },
22
+ { min: ambiguous, max: likelyAmbiguous, code: 'l' },
23
+ { min: likelyAmbiguous, max: likelyPathogenic, code: 'h' },
24
+ { min: likelyPathogenic, max: pathogenic, code: 'p' },
25
+ { min: pathogenic, max: certainlyPathogenic, code: 'P' },
26
+ ];
27
+
28
+ const getPathogenicityCode = (score) => {
29
+ for (const { min, max, code } of pathogenicityCategories) {
30
+ if (score >= min && score < max) {
31
+ return code;
32
+ }
33
+ }
34
+ };
35
+
13
36
  type Row = {
14
37
  wildType: string;
15
38
  position: number;
@@ -48,7 +71,6 @@ const parseCSV = (rawText: string): string => {
48
71
 
49
72
  const out = [];
50
73
  for (const position of positions) {
51
- let letter = 'A';
52
74
  // maximum
53
75
  // const value = Math.max(
54
76
  // ...position.map((variation) => variation.pathogenicityScore)
@@ -59,11 +81,7 @@ const parseCSV = (rawText: string): string => {
59
81
  (acc, variation) => acc + +variation.pathogenicityScore,
60
82
  0
61
83
  ) / position.length;
62
- if (value > pathogenic) {
63
- letter = 'P';
64
- } else if (value < benign) {
65
- letter = 'B';
66
- }
84
+ const letter = getPathogenicityCode(value);
67
85
  out.push(letter);
68
86
  }
69
87
 
@@ -13,64 +13,19 @@ const transformData = (data) => {
13
13
  let adaptedData = [];
14
14
 
15
15
  if (data && data.length !== 0) {
16
- /* Important: The PTM map is a temporary patch until multiple modifications are shown in the peptide. At this point, only 'phospho' sites are of interest.
17
- Once they are available in the data, there is no need for the below merging */
18
-
19
- // To merge PTM data present in same residue in a same length peptide, have a map [key: start-end-phospho site 1-... phosphosite n, value: corresponding feature elements]
20
- const ptmMap: Record<string, any> = {};
21
- data.features.forEach((feature) => {
22
- let ft = `${feature.begin}-${feature.end}`;
23
- if (feature.ptms) {
24
- feature.ptms.forEach((ptm) => {
25
- ft += `-${ptm.position}`;
26
- });
27
- ptmMap[ft] = ft in ptmMap ? [...ptmMap[ft], feature] : [feature];
28
- }
16
+ adaptedData = data.features.map((feature) => {
17
+ feature.residuesToHighlight = feature.ptms?.map((ptm) => ({
18
+ name: ptm.name,
19
+ position: ptm.position,
20
+ sources: ptm.sources,
21
+ dbReferences: ptm.dbReferences,
22
+ }));
23
+ return Object.assign(
24
+ feature,
25
+ proteomicsTrackProperties(feature, data.taxid)
26
+ );
29
27
  });
30
28
 
31
- // The else part alone is enough if the PTM information need not be merged.
32
- if (Object.keys(ptmMap).length) {
33
- adaptedData = Object.values(ptmMap).map((features) => {
34
- // Only the dbReferences have to be merged as the rest is all the same
35
- const mergedDbReferences = [];
36
- features.forEach((feature) => {
37
- feature.ptms.forEach((ptm) => {
38
- ptm.dbReferences.forEach((dbReference) => {
39
- mergedDbReferences.push(dbReference);
40
- });
41
- });
42
- });
43
-
44
- const mergedFeatures = {
45
- type: features[0].type,
46
- begin: features[0].begin,
47
- end: features[0].end,
48
- xrefs: features[0].xrefs,
49
- evidences: features[0].evidences,
50
- peptide: features[0].peptide,
51
- unique: features[0].unique,
52
- residuesToHighlight: features[0].ptms.map((ptm) => ({
53
- name: ptm.name,
54
- position: ptm.position,
55
- sources: ptm.sources,
56
- dbReferences: mergedDbReferences,
57
- })),
58
- };
59
-
60
- return Object.assign(
61
- mergedFeatures,
62
- proteomicsTrackProperties(mergedFeatures, data.taxid)
63
- );
64
- }, []);
65
- } else {
66
- adaptedData = data.features.map((feature) => {
67
- return Object.assign(
68
- feature,
69
- proteomicsTrackProperties(feature, data.taxid)
70
- );
71
- });
72
- }
73
-
74
29
  adaptedData = renameProperties(adaptedData);
75
30
  }
76
31
  return adaptedData;
@@ -59,38 +59,50 @@ const convertPtmExchangePtms = (
59
59
  aa: string,
60
60
  absolutePosition: number
61
61
  ) => {
62
- const confidenceScores = new Set(
63
- ptms.flatMap(({ dbReferences }) =>
64
- dbReferences?.map(({ properties }) => properties['Confidence score'])
65
- )
66
- );
67
- let confidenceScore: string | null = null;
68
-
69
- if (!confidenceScores.size) {
70
- console.log('PTM has no confidence score');
71
- } else if (confidenceScores.size > 1) {
72
- console.error(
73
- `PTM has a mixture of confidence scores: ${Array.from(confidenceScores)}`
74
- );
75
- } else {
76
- [confidenceScore] = confidenceScores;
62
+ const groupPtmsByModification: Record<string, PTM[]> = {};
63
+ for (const ptm of ptms) {
64
+ if (groupPtmsByModification[ptm.name]) {
65
+ groupPtmsByModification[ptm.name].push(ptm);
66
+ } else {
67
+ groupPtmsByModification[ptm.name] = [ptm];
68
+ }
77
69
  }
78
70
 
79
- return {
80
- source: 'PTMeXchange',
81
- type: 'MOD_RES_LS',
82
- start: absolutePosition,
83
- end: absolutePosition,
84
- shape: 'triangle',
85
- tooltipContent: formatTooltip(
86
- `MOD_RES_LS ${absolutePosition}-${absolutePosition}`,
87
- ptms,
88
- aa,
89
- confidenceScore
90
- ),
91
- color:
92
- (confidenceScore && ConfidenceScoreColors[confidenceScore]) || 'black',
93
- };
71
+ return Object.values(groupPtmsByModification).map((groupedPtms) => {
72
+ const confidenceScores = new Set(
73
+ groupedPtms.flatMap(({ dbReferences }) =>
74
+ dbReferences?.map(({ properties }) => properties['Confidence score'])
75
+ )
76
+ );
77
+ let confidenceScore: string | null = null;
78
+ if (confidenceScores.size) {
79
+ if (confidenceScores.size > 1) {
80
+ console.error(
81
+ `PTMeXchange PTM has a mixture of confidence scores: ${Array.from(
82
+ confidenceScores
83
+ )}`
84
+ );
85
+ } else {
86
+ [confidenceScore] = confidenceScores;
87
+ }
88
+ }
89
+
90
+ return {
91
+ source: 'PTMeXchange',
92
+ type: 'MOD_RES_LS',
93
+ start: absolutePosition,
94
+ end: absolutePosition,
95
+ shape: 'triangle',
96
+ tooltipContent: formatTooltip(
97
+ `MOD_RES_LS ${absolutePosition}-${absolutePosition}`,
98
+ groupedPtms,
99
+ aa,
100
+ confidenceScore
101
+ ),
102
+ color:
103
+ (confidenceScore && ConfidenceScoreColors[confidenceScore]) || 'black',
104
+ };
105
+ });
94
106
  };
95
107
 
96
108
  const transformData = (data: ProteomicsPtm) => {
@@ -130,7 +142,7 @@ const transformData = (data: ProteomicsPtm) => {
130
142
  return Object.entries(absolutePositionToPtms).map(
131
143
  ([absolutePosition, { ptms, aa }]) =>
132
144
  convertPtmExchangePtms(ptms, aa, +absolutePosition)
133
- );
145
+ ).flat();
134
146
  }
135
147
  }
136
148
  return [];
package/src/config.ts CHANGED
@@ -815,8 +815,8 @@ const config: ProtvistaConfig = {
815
815
  name: 'ALPHAMISSENSE_PATHOGENICITY',
816
816
  label: 'AlphaMissense',
817
817
  trackType: 'nightingale-colored-sequence',
818
- scale: 'P:100,A:50,B:0',
819
- 'color-range': '#9a131a:100,#a8a9ad:50,#3d5493:0',
818
+ scale: 'B:0,H:0.1132,V:0.2264,L:0.3395,A:0.4527,l:0.5895,h:0.7264,p:0.8632,P:1',
819
+ 'color-range': '#2166ac:0,#4290bf:0.1132,#8cbcd4:0.2264,#c3d6e0:0.3395,#e2e2e2:0.4527,#edcdba:0.5895,#e99e7c:0.7264,#d15e4b:0.8632,#b2182b:1',
820
820
  tracks: [
821
821
  {
822
822
  name: 'alphamissense_pathogenicity',
@@ -16,6 +16,7 @@ import NightingaleSequenceHeatmap from '@nightingale-elements/nightingale-sequen
16
16
  import NightingaleFilter, {
17
17
  Filter,
18
18
  } from '@nightingale-elements/nightingale-filter';
19
+ import { amColorScale } from '@nightingale-elements/nightingale-structure';
19
20
 
20
21
  // adapters
21
22
  import featureAdapter from './adapters/feature-adapter';
@@ -294,6 +295,11 @@ class ProtvistaUniprot extends LitElement {
294
295
  ...new Set(heatmapData.map((hotMapItem) => hotMapItem.yValue)),
295
296
  ] as string[];
296
297
  heatmapComponent.setHeatmapData(xDomain, yDomain, heatmapData);
298
+ heatmapComponent.updateComplete.then(() => {
299
+ heatmapComponent.heatmapInstance.setColor((d) =>
300
+ amColorScale(d.score)
301
+ );
302
+ });
297
303
  }
298
304
  }
299
305
  }
@@ -1,5 +1,10 @@
1
1
  import ecoMap from '../adapters/config/evidence';
2
- import { phosphorylate, sumoylate } from './ptm-tooltip';
2
+ import {
3
+ acetylate,
4
+ phosphorylate,
5
+ sumoylate,
6
+ ubiquitinate,
7
+ } from './ptm-tooltip';
3
8
 
4
9
  const taxIdToPeptideAtlasBuildData = {
5
10
  '36329': { build: '542', organism: 'Plasmodium' },
@@ -101,12 +106,18 @@ const findModifiedResidueName = (feature, ptm) => {
101
106
  const { peptide, begin: peptideStart } = feature;
102
107
  const proteinLocation = Number(peptideStart) + ptm.position - 1;
103
108
  const modifiedResidue = peptide.charAt(ptm.position - 1); // CharAt index starts from 0
104
- if (ptm.name === 'Phosphorylation') {
105
- return `${proteinLocation} ${phosphorylate(modifiedResidue)}`;
106
- } else if (ptm.name === 'SUMOylation') {
107
- return `${proteinLocation} ${sumoylate(modifiedResidue)}`;
109
+ switch (ptm.name) {
110
+ case 'Phosphorylation':
111
+ return `${proteinLocation} ${phosphorylate(modifiedResidue)}`;
112
+ case 'SUMOylation':
113
+ return `${proteinLocation} ${sumoylate(modifiedResidue)}`;
114
+ case 'Ubiquitinylation':
115
+ return `${proteinLocation} ${ubiquitinate(modifiedResidue)}`;
116
+ case 'Acetylation':
117
+ return `${proteinLocation} ${acetylate(modifiedResidue)}`;
118
+ default:
119
+ return '';
108
120
  }
109
- return '';
110
121
  };
111
122
 
112
123
  const formatTooltip = (feature, taxId?: string) => {
@@ -234,8 +245,10 @@ const formatTooltip = (feature, taxId?: string) => {
234
245
  }
235
246
  ${
236
247
  ref.properties['Universal Spectrum Id']
237
- ? `<li class="text-indent-2 nowrap">Universal Spectrum Id:
238
- <a href="http://proteomecentral.proteomexchange.org/usi/?usi=${ref.properties['Universal Spectrum Id']}" target="_blank">View on ProteomeXchange</a>
248
+ ? `<li class="text-indent-2 nowrap margin-bottom">Universal Spectrum Id:
249
+ <a href="http://proteomecentral.proteomexchange.org/usi/?usi=${encodeURIComponent(
250
+ ref.properties['Universal Spectrum Id']
251
+ )}" target="_blank">View on ProteomeXchange</a>
239
252
  </li>`
240
253
  : ``
241
254
  }
@@ -1,6 +1,10 @@
1
1
  import { PTM } from '../adapters/ptm-exchange-adapter';
2
2
 
3
- type Modification = 'Phosphorylation' | 'SUMOylation';
3
+ type Modification =
4
+ | 'Phosphorylation'
5
+ | 'SUMOylation'
6
+ | 'Ubiquitinylation'
7
+ | 'Acetylation';
4
8
 
5
9
  const aaToPhosphorylated = {
6
10
  R: 'Phosphoarginine',
@@ -15,6 +19,31 @@ const aaToSumoylated = {
15
19
  K: 'Sumoylated lysine',
16
20
  };
17
21
 
22
+ const aaToUbiquitinated = {
23
+ K: 'Ubiquitinated lysine',
24
+ S: 'Ubiquitinated serine',
25
+ T: 'Ubiquitinated threonine',
26
+ C: 'Ubiquitinated cysteine',
27
+ };
28
+
29
+ const aaToAcetylated = {
30
+ S: 'Acetylserine',
31
+ A: 'Acetylalanine',
32
+ G: 'Acetylglycine',
33
+ T: 'Acetylthreonine',
34
+ V: 'Acetylvaline',
35
+ C: 'Acetylcysteine',
36
+ E: 'Acetylglutamin acid',
37
+ D: 'Acetylaspartic acid',
38
+ N: 'Acetylasparagine',
39
+ Q: 'Acetylglutamine',
40
+ L: 'Acetyllucine',
41
+ I: 'Acetlyisolucine',
42
+ W: 'Acetyltryptophan',
43
+ F: 'Acetylphenylalanine',
44
+ K: 'Acetyllysine',
45
+ };
46
+
18
47
  export const phosphorylate = (aa: string) => {
19
48
  const AA = aa.toUpperCase();
20
49
  if (AA in aaToPhosphorylated) {
@@ -33,6 +62,39 @@ export const sumoylate = (aa: string) => {
33
62
  return '';
34
63
  };
35
64
 
65
+ export const ubiquitinate = (aa: string) => {
66
+ const AA = aa.toUpperCase();
67
+ if (AA in aaToUbiquitinated) {
68
+ return aaToUbiquitinated[AA as keyof typeof aaToUbiquitinated];
69
+ }
70
+ console.error(`${AA} not a valid amino acid for Ubiquitinylation`);
71
+ return '';
72
+ };
73
+
74
+ export const acetylate = (aa: string) => {
75
+ const AA = aa.toUpperCase();
76
+ if (AA in aaToAcetylated) {
77
+ return aaToAcetylated[AA as keyof typeof aaToAcetylated];
78
+ }
79
+ console.error(`${AA} not a valid amino acid for Acetylation`);
80
+ return '';
81
+ };
82
+
83
+ const getDescription = (modification: Modification, aa: string) => {
84
+ switch (modification) {
85
+ case 'Phosphorylation':
86
+ return phosphorylate(aa);
87
+ case 'SUMOylation':
88
+ return sumoylate(aa);
89
+ case 'Ubiquitinylation':
90
+ return ubiquitinate(aa);
91
+ case 'Acetylation':
92
+ return acetylate(aa);
93
+ default:
94
+ return '';
95
+ }
96
+ };
97
+
36
98
  const formatTooltip = (
37
99
  title: string,
38
100
  ptms: PTM[],
@@ -52,7 +114,7 @@ const formatTooltip = (
52
114
  if (modifications.size) {
53
115
  if (modifications.size > 1) {
54
116
  console.error(
55
- `PTMeXchange PTM has a mixture of modifications: ${Array.from(
117
+ `The ptms are grouped by modification, but more than one type detected: ${Array.from(
56
118
  modifications
57
119
  )}`
58
120
  );
@@ -63,9 +125,7 @@ const formatTooltip = (
63
125
 
64
126
  return `
65
127
  ${title ? `<h4>${title}</h4><hr />` : ''}
66
- <h5>Description</h5><p>${
67
- modification === 'Phosphorylation' ? phosphorylate(aa) : sumoylate(aa)
68
- }</p>
128
+ <h5>Description</h5><p>${getDescription(modification, aa)}</p>
69
129
  ${
70
130
  confidenceScore
71
131
  ? `<h5 data-article-id="mod_res_large_scale#confidence-score">Confidence Score</h5><p>${confidenceScore}</p>`