react-mutation-mapper 0.8.32 → 0.8.35

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/dist/index.js CHANGED
@@ -24,7 +24,8 @@ var Select = require('react-select');
24
24
  var Select__default = _interopDefault(Select);
25
25
  var $ = _interopDefault(require('jquery'));
26
26
  var Slider = _interopDefault(require('react-rangeslider'));
27
- var request = _interopDefault(require('superagent'));
27
+ var request = require('superagent');
28
+ var request__default = _interopDefault(request);
28
29
  var memoize = _interopDefault(require('memoize-weak-decorator'));
29
30
  var mobxpromise = require('mobxpromise');
30
31
 
@@ -3160,8 +3161,9 @@ var ProteinChange = /** @class */ (function (_super) {
3160
3161
  return ProteinChange;
3161
3162
  }(React.Component));
3162
3163
 
3163
- function getSignalData(mutation, indexedVariantAnnotations) {
3164
- var signalData = {};
3164
+ function getSignalData(mutation, indexedVariantAnnotations, mutationType // mutationType could be "germline", "somatic", or "undefined" which means both
3165
+ ) {
3166
+ var signalData = [];
3165
3167
  var variantAnnotation = indexedVariantAnnotations
3166
3168
  ? cbioportalUtils.getVariantAnnotation(mutation, indexedVariantAnnotations.result)
3167
3169
  : undefined;
@@ -3169,12 +3171,37 @@ function getSignalData(mutation, indexedVariantAnnotations) {
3169
3171
  variantAnnotation.signalAnnotation &&
3170
3172
  variantAnnotation.signalAnnotation.annotation &&
3171
3173
  variantAnnotation.signalAnnotation.annotation.length > 0) {
3172
- variantAnnotation.signalAnnotation.annotation.forEach(function (annotation) {
3173
- // only have one germline annotation
3174
- if (annotation.mutationStatus.includes('germline')) {
3175
- signalData = cbioportalUtils.extendMutations([annotation])[0];
3174
+ // if mutation is somatic OR germline, get annotation depending on mutationType
3175
+ if (variantAnnotation.signalAnnotation.annotation.length === 1) {
3176
+ if ((mutationType === cbioportalUtils.Pathogenicity.GERMLINE &&
3177
+ variantAnnotation.signalAnnotation.annotation[0].mutationStatus.includes('germline')) ||
3178
+ (mutationType === cbioportalUtils.Pathogenicity.SOMATIC &&
3179
+ variantAnnotation.signalAnnotation.annotation[0].mutationStatus.includes('somatic'))) {
3180
+ signalData = cbioportalUtils.extendMutations([
3181
+ variantAnnotation.signalAnnotation.annotation[0],
3182
+ ]);
3183
+ }
3184
+ }
3185
+ // if mutation is both somatic AND germline, get annotation for both or get one of them depending on mutationType
3186
+ else {
3187
+ // if mutationType is undefined, get annotation for both somatic and germline
3188
+ if (mutationType === undefined) {
3189
+ signalData = cbioportalUtils.extendMutations(variantAnnotation.signalAnnotation.annotation);
3176
3190
  }
3177
- });
3191
+ // if mutationType is defined, get annotation depending on mutationType
3192
+ else {
3193
+ variantAnnotation.signalAnnotation.annotation.forEach(function (annotation) {
3194
+ if (mutationType === cbioportalUtils.Pathogenicity.GERMLINE &&
3195
+ annotation.mutationStatus.includes('germline')) {
3196
+ signalData = cbioportalUtils.extendMutations([annotation]);
3197
+ }
3198
+ else if (mutationType === cbioportalUtils.Pathogenicity.SOMATIC &&
3199
+ annotation.mutationStatus.includes('somatic')) {
3200
+ signalData = cbioportalUtils.extendMutations([annotation]);
3201
+ }
3202
+ });
3203
+ }
3204
+ }
3178
3205
  }
3179
3206
  return signalData;
3180
3207
  }
@@ -3182,25 +3209,29 @@ function signalSortMethod(a, b) {
3182
3209
  return cbioportalUtils.defaultSortMethod(getSortValue(a), getSortValue(b));
3183
3210
  }
3184
3211
  function getSortValue(signalData) {
3185
- return signalData.germlineFrequency || null;
3212
+ return signalData ? signalData.germlineFrequency || null : null;
3186
3213
  }
3187
- function download$7(signalData) {
3188
- return signalData.germlineFrequency != null
3214
+ function download$7(signalData, mutationType) {
3215
+ return signalData && signalData.germlineFrequency !== null
3189
3216
  ? "" + cbioportalUtils.formatNumberValueInSignificantDigits(signalData.germlineFrequency, 2)
3190
3217
  : '';
3191
3218
  }
3192
- function getSignalValue(mutation, indexedVariantAnnotations, significantDigits) {
3193
- var signalData = getSignalData(mutation, indexedVariantAnnotations);
3194
- if (signalData.tumorTypeDecomposition) {
3195
- return cbioportalUtils.formatNumberValueInSignificantDigits(signalData.germlineFrequency, significantDigits || 2);
3219
+ // Get germline OR somatic frequency value
3220
+ function getSingleSignalValue(mutation, mutationType, indexedVariantAnnotations, significantDigits) {
3221
+ var signalData = getSignalData(mutation, indexedVariantAnnotations, mutationType);
3222
+ if (signalData &&
3223
+ signalData.length === 1 &&
3224
+ signalData[0].tumorTypeDecomposition) {
3225
+ return cbioportalUtils.formatNumberValueInSignificantDigits(signalData[0].germlineFrequency || signalData[0].somaticFrequency, significantDigits || 2);
3196
3226
  }
3197
3227
  else {
3198
3228
  return null;
3199
3229
  }
3200
3230
  }
3201
3231
  var SignalTable = function (props) {
3202
- var signalData = getSignalData(props.mutation, props.indexedVariantAnnotations);
3203
- if (getSignalValue(props.mutation, props.indexedVariantAnnotations) !== null) {
3232
+ // signal data should be either germline or somatic, so should be only one element
3233
+ var signalData = getSignalData(props.mutation, props.indexedVariantAnnotations, props.mutationType)[0];
3234
+ if (getSingleSignalValue(props.mutation, props.mutationType || cbioportalUtils.Pathogenicity.GERMLINE, props.indexedVariantAnnotations) !== null) {
3204
3235
  return (React.createElement(cbioportalFrontendCommons.MutationTumorTypeFrequencyTable, { data: cbioportalUtils.generateTumorTypeDecomposition(signalData, signalData.countsByTumorType, signalData.biallelicCountsByTumorType, signalData.qcPassCountsByTumorType, signalData.statsByTumorType), columns: [
3205
3236
  cbioportalFrontendCommons.FREQUENCY_COLUMNS_DEFINITION[cbioportalFrontendCommons.FrequencyTableColumnEnum.TUMOR_TYPE],
3206
3237
  cbioportalFrontendCommons.FREQUENCY_COLUMNS_DEFINITION[cbioportalFrontendCommons.FrequencyTableColumnEnum.MUTATION_STATUS],
@@ -3241,11 +3272,11 @@ var Signal = /** @class */ (function (_super) {
3241
3272
  }
3242
3273
  else {
3243
3274
  content = React.createElement("div", null);
3244
- var signalValue = getSignalValue(this.props.mutation, this.props.indexedVariantAnnotations);
3275
+ var signalValue = getSingleSignalValue(this.props.mutation, this.props.mutationType || cbioportalUtils.Pathogenicity.GERMLINE, this.props.indexedVariantAnnotations);
3245
3276
  if (signalValue !== null) {
3246
3277
  content = (React.createElement(cbioportalFrontendCommons.DefaultTooltip, { placement: "top", overlayStyle: {
3247
3278
  width: 800,
3248
- }, overlay: React.createElement(SignalTable, { mutation: this.props.mutation, indexedVariantAnnotations: this.props.indexedVariantAnnotations }) },
3279
+ }, overlay: React.createElement(SignalTable, { mutation: this.props.mutation, indexedVariantAnnotations: this.props.indexedVariantAnnotations, mutationType: this.props.mutationType }) },
3249
3280
  React.createElement("span", null, signalValue)));
3250
3281
  }
3251
3282
  }
@@ -5189,7 +5220,7 @@ var DefaultMutationTable = /** @class */ (function (_super) {
5189
5220
  return this.indexedVariantAnnotationDataStatus === 'pending'
5190
5221
  ? function () { return undefined; }
5191
5222
  : function (mutation) {
5192
- return getSignalData(mutation, _this.props.indexedVariantAnnotations);
5223
+ return getSignalData(mutation, _this.props.indexedVariantAnnotations, cbioportalUtils.Pathogenicity.GERMLINE)[0];
5193
5224
  };
5194
5225
  },
5195
5226
  enumerable: false,
@@ -5259,7 +5290,7 @@ var DefaultMutationTable = /** @class */ (function (_super) {
5259
5290
  case exports.MutationColumn.DBSNP:
5260
5291
  return function (column) { return (React.createElement(Dbsnp, { mutation: column.original, indexedMyVariantInfoAnnotations: _this.props.indexedMyVariantInfoAnnotations })); };
5261
5292
  case exports.MutationColumn.SIGNAL:
5262
- return function (column) { return (React.createElement(Signal, { mutation: column.original, indexedVariantAnnotations: _this.props.indexedVariantAnnotations })); };
5293
+ return function (column) { return (React.createElement(Signal, { mutation: column.original, indexedVariantAnnotations: _this.props.indexedVariantAnnotations, mutationType: cbioportalUtils.Pathogenicity.GERMLINE })); };
5263
5294
  default:
5264
5295
  return undefined;
5265
5296
  }
@@ -8440,8 +8471,24 @@ var ExonTrack = /** @class */ (function (_super) {
8440
8471
  enumerable: false,
8441
8472
  configurable: true
8442
8473
  });
8474
+ Object.defineProperty(ExonTrack.prototype, "chromosome", {
8475
+ get: function () {
8476
+ var _a, _b;
8477
+ return (_b = (_a = this.props.store.ensemblTranscriptLookUp.result) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.seq_region_name;
8478
+ },
8479
+ enumerable: false,
8480
+ configurable: true
8481
+ });
8482
+ Object.defineProperty(ExonTrack.prototype, "genomeBuild", {
8483
+ get: function () {
8484
+ return this.props.store.genomeBuild;
8485
+ },
8486
+ enumerable: false,
8487
+ configurable: true
8488
+ });
8443
8489
  Object.defineProperty(ExonTrack.prototype, "exonSpecs", {
8444
8490
  get: function () {
8491
+ var _this = this;
8445
8492
  if (!this.transcriptId || !this.transcript) {
8446
8493
  return [];
8447
8494
  }
@@ -8455,10 +8502,15 @@ var ExonTrack = /** @class */ (function (_super) {
8455
8502
  ? exonInfo.map(function (exon, index) {
8456
8503
  var startCodon = exon.start;
8457
8504
  var endCodon = exon.start + exon.length;
8458
- var exonLength = exon.length;
8459
- var stringStart = cbioportalUtils.formatExonLocation(startCodon);
8460
- var stringEnd = cbioportalUtils.formatExonLocation(endCodon);
8461
- var stringLength = cbioportalUtils.formatExonLocation(exonLength);
8505
+ var exonStartLocation = cbioportalUtils.formatExonLocation(startCodon, index);
8506
+ var exonEndLocation = cbioportalUtils.formatExonLocation(endCodon);
8507
+ var exonLength = cbioportalUtils.formatExonLength(exon.length);
8508
+ var link = _this.chromosome
8509
+ ? "https://igv.org/app/?locus=chr" + _this.chromosome + ":" + exon.genomicLocationStart + "-" + exon.genomicLocationEnd + "&genome=" + _this.genomeBuild
8510
+ : 'https://igv.org';
8511
+ var linkText = _this.chromosome
8512
+ ? _this.genomeBuild + ":chr" + _this.chromosome + ":" + exon.genomicLocationStart + " - " + exon.genomicLocationEnd
8513
+ : exon.genomicLocationStart + " - " + exon.genomicLocationEnd;
8462
8514
  return {
8463
8515
  color: altColors[index % 2],
8464
8516
  startCodon: startCodon,
@@ -8470,14 +8522,41 @@ var ExonTrack = /** @class */ (function (_super) {
8470
8522
  " Exon ",
8471
8523
  exon.rank,
8472
8524
  " "),
8473
- "Start: ",
8474
- stringStart,
8525
+ "Start: Nucleotide",
8526
+ ' ',
8527
+ React.createElement("strong", null, exonStartLocation.nucleotideLocation),
8528
+ ' ',
8529
+ "of amino acid",
8530
+ ' ',
8531
+ React.createElement("strong", null, exonStartLocation.aminoAcidLocation),
8475
8532
  React.createElement("br", null),
8476
- "End: ",
8477
- stringEnd,
8533
+ "End: Nucleotide",
8534
+ ' ',
8535
+ React.createElement("strong", null, exonEndLocation.nucleotideLocation),
8536
+ ' ',
8537
+ "of amino acid",
8538
+ ' ',
8539
+ React.createElement("strong", null, exonEndLocation.aminoAcidLocation),
8478
8540
  React.createElement("br", null),
8479
- "Length: ",
8480
- stringLength)),
8541
+ "Length:",
8542
+ ' ',
8543
+ React.createElement("strong", null, exonLength.aminoAcidLength),
8544
+ ' ',
8545
+ "amino acids",
8546
+ ' ',
8547
+ exonLength.nucleotideLength && (React.createElement(React.Fragment, null,
8548
+ ' ',
8549
+ "and",
8550
+ ' ',
8551
+ React.createElement("strong", null, exonLength.nucleotideLength),
8552
+ ' ',
8553
+ "nucleotides")),
8554
+ React.createElement("br", null),
8555
+ "Genomic location:", " ",
8556
+ React.createElement("a", { target: "_blank", href: link, rel: "noopener noreferrer" },
8557
+ React.createElement(React.Fragment, null,
8558
+ linkText, " ",
8559
+ React.createElement("i", { className: "fa fa-external-link" }))))),
8481
8560
  };
8482
8561
  })
8483
8562
  : [];
@@ -8508,6 +8587,12 @@ var ExonTrack = /** @class */ (function (_super) {
8508
8587
  __decorate([
8509
8588
  mobx.computed
8510
8589
  ], ExonTrack.prototype, "transcript", null);
8590
+ __decorate([
8591
+ mobx.computed
8592
+ ], ExonTrack.prototype, "chromosome", null);
8593
+ __decorate([
8594
+ mobx.computed
8595
+ ], ExonTrack.prototype, "genomeBuild", null);
8511
8596
  __decorate([
8512
8597
  mobx.computed
8513
8598
  ], ExonTrack.prototype, "exonSpecs", null);
@@ -10128,7 +10213,7 @@ var DefaultPubMedCache = /** @class */ (function (_super) {
10128
10213
  switch (_a.label) {
10129
10214
  case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
10130
10215
  // TODO duplicate code from cbioportal-frontend
10131
- request
10216
+ request__default
10132
10217
  .post('https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&retmode=json')
10133
10218
  .type('form')
10134
10219
  .send({ id: query })
@@ -10162,7 +10247,7 @@ var DefaultPubMedCache = /** @class */ (function (_super) {
10162
10247
 
10163
10248
  function fetchMutationAlignerLink(pfamDomainId, mutationAlignerUrlTemplate) {
10164
10249
  if (mutationAlignerUrlTemplate === void 0) { mutationAlignerUrlTemplate = DEFAULT_MUTATION_ALIGNER_PROXY_URL_TEMPLATE; }
10165
- return request
10250
+ return request__default
10166
10251
  .get(getUrl(mutationAlignerUrlTemplate, { pfamDomainId: pfamDomainId }))
10167
10252
  .accept('application/json');
10168
10253
  }
@@ -10538,7 +10623,7 @@ var DefaultMutationMapperDataFetcher = /** @class */ (function () {
10538
10623
  var myGeneData;
10539
10624
  return __generator(this, function (_a) {
10540
10625
  switch (_a.label) {
10541
- case 0: return [4 /*yield*/, request.get(getUrl(this.config.myGeneUrlTemplate || DEFAULT_MY_GENE_URL_TEMPLATE, { entrezGeneId: entrezGeneId }))];
10626
+ case 0: return [4 /*yield*/, request__default.get(getUrl(this.config.myGeneUrlTemplate || DEFAULT_MY_GENE_URL_TEMPLATE, { entrezGeneId: entrezGeneId }))];
10542
10627
  case 1:
10543
10628
  myGeneData = _a.sent();
10544
10629
  return [2 /*return*/, JSON.parse(myGeneData.text).uniprot['Swiss-Prot']];
@@ -10556,7 +10641,7 @@ var DefaultMutationMapperDataFetcher = /** @class */ (function () {
10556
10641
  var uniprotData;
10557
10642
  return __generator(this, function (_a) {
10558
10643
  switch (_a.label) {
10559
- case 0: return [4 /*yield*/, request.get(getUrl(this.config.uniprotIdUrlTemplate ||
10644
+ case 0: return [4 /*yield*/, request__default.get(getUrl(this.config.uniprotIdUrlTemplate ||
10560
10645
  DEFAULT_UNIPROT_ID_URL_TEMPLATE, { swissProtAccession: swissProtAccession }))];
10561
10646
  case 1:
10562
10647
  uniprotData = _a.sent();
@@ -10714,7 +10799,7 @@ var DefaultMutationMapperDataFetcher = /** @class */ (function () {
10714
10799
  switch (_a.label) {
10715
10800
  case 0:
10716
10801
  if (!swissProtId) return [3 /*break*/, 2];
10717
- return [4 /*yield*/, request.get(getUrl("https://www.ebi.ac.uk/proteins/api/features/<%= uniprotAccession %>?categories=" + category.join(','), { uniprotAccession: swissProtId }))];
10802
+ return [4 /*yield*/, request__default.get(getUrl("https://www.ebi.ac.uk/proteins/api/features/<%= uniprotAccession %>?categories=" + category.join(','), { uniprotAccession: swissProtId }))];
10718
10803
  case 1:
10719
10804
  uniprotData = _a.sent();
10720
10805
  featureList = JSON.parse(uniprotData.text);
@@ -11697,6 +11782,28 @@ var DefaultMutationMapperStore = /** @class */ (function () {
11697
11782
  },
11698
11783
  })
11699
11784
  });
11785
+ Object.defineProperty(this, "ensemblTranscriptLookUp", {
11786
+ enumerable: true,
11787
+ configurable: true,
11788
+ writable: true,
11789
+ value: cbioportalFrontendCommons.remoteData({
11790
+ await: function () { return [_this.activeTranscript]; },
11791
+ invoke: function () { return __awaiter(_this, void 0, void 0, function () {
11792
+ var ensemblTranscriptLookUpLink;
11793
+ return __generator(this, function (_a) {
11794
+ ensemblTranscriptLookUpLink = this.genomeBuild === 'hg19'
11795
+ ? "https://grch37.rest.ensembl.org/lookup/id/" + this.activeTranscript.result + "?content-type=application/json"
11796
+ : "https://rest.ensembl.org/lookup/id/" + this.activeTranscript.result + "?content-type=application/json";
11797
+ return [2 /*return*/, this.activeTranscript.result
11798
+ ? request.get(ensemblTranscriptLookUpLink)
11799
+ : undefined];
11800
+ });
11801
+ }); },
11802
+ onError: function () {
11803
+ // fail silently, leave the error handling responsibility to the data consumer
11804
+ },
11805
+ })
11806
+ });
11700
11807
  mobx.makeObservable(this);
11701
11808
  }
11702
11809
  Object.defineProperty(DefaultMutationMapperStore.prototype, "selectedTranscript", {
@@ -12006,6 +12113,13 @@ var DefaultMutationMapperStore = /** @class */ (function () {
12006
12113
  0);
12007
12114
  }
12008
12115
  });
12116
+ Object.defineProperty(DefaultMutationMapperStore.prototype, "genomeBuild", {
12117
+ get: function () {
12118
+ return this.config.genomeBuild || 'hg19';
12119
+ },
12120
+ enumerable: false,
12121
+ configurable: true
12122
+ });
12009
12123
  __decorate([
12010
12124
  mobx.observable
12011
12125
  ], DefaultMutationMapperStore.prototype, "_selectedTranscript", void 0);
@@ -12076,6 +12190,9 @@ var DefaultMutationMapperStore = /** @class */ (function () {
12076
12190
  __decorate([
12077
12191
  autobind
12078
12192
  ], DefaultMutationMapperStore.prototype, "getDefaultEntrezGeneId", null);
12193
+ __decorate([
12194
+ mobx.computed
12195
+ ], DefaultMutationMapperStore.prototype, "genomeBuild", null);
12079
12196
  return DefaultMutationMapperStore;
12080
12197
  }());
12081
12198
 
@@ -12889,7 +13006,7 @@ exports.getProteinImpactTypeBadgeLabel = getProteinImpactTypeBadgeLabel;
12889
13006
  exports.getProteinImpactTypeOptionLabel = getProteinImpactTypeOptionLabel;
12890
13007
  exports.getSelectedOptionValues = getSelectedOptionValues;
12891
13008
  exports.getSignalData = getSignalData;
12892
- exports.getSignalValue = getSignalValue;
13009
+ exports.getSingleSignalValue = getSingleSignalValue;
12893
13010
  exports.getUrl = getUrl;
12894
13011
  exports.gnomadDownload = download$5;
12895
13012
  exports.gnomadSortValue = sortValue$7;