react-mutation-mapper 0.8.28 → 0.8.33

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
@@ -1867,17 +1867,11 @@ var OncoKB = /** @class */ (function (_super) {
1867
1867
  ].map(function (dataType) { return (React.createElement(AnnotationIcon, { type: dataType, tooltipOverlay: _this.tooltipContent(dataType), indicator: _this.props.indicator, availableDataTypes: _this.props.availableDataTypes })); })));
1868
1868
  }
1869
1869
  else {
1870
- // TODO This doesn't always work, in some cases it adds unnecessary empty icons, we need a better solution.
1871
- // we still need to draw empty icons even if there is no indicator data.
1872
- // this is to keep the icon alignment consistent with the rest of the column
1873
- // return (
1874
- // <>
1875
- // {this.props.availableDataTypes?.map(() => (
1876
- // <AnnotationIconWithTooltip icon={<i />} />
1877
- // ))}
1878
- // </>
1879
- // );
1880
- return null;
1870
+ // workaround: use content padding value to draw an empty icon when there is no indicator data.
1871
+ // this is to keep the icon alignment consistent with the rest of the column.
1872
+ // ideally we should implement grouped columns to avoid these kind of workarounds
1873
+ // (see https://github.com/cBioPortal/cbioportal/issues/8723)
1874
+ return React.createElement("i", { style: { paddingRight: this.props.contentPadding } });
1881
1875
  }
1882
1876
  }
1883
1877
  });
@@ -2305,9 +2299,9 @@ function sortValue$4(annotation) {
2305
2299
  ]);
2306
2300
  }
2307
2301
  function GenericAnnotation(props) {
2308
- var annotation = props.annotation, enableCivic = props.enableCivic, enableHotspot = props.enableHotspot, enableMyCancerGenome = props.enableMyCancerGenome, enableOncoKb = props.enableOncoKb, pubMedCache = props.pubMedCache, userEmailAddress = props.userEmailAddress, mergeOncoKbIcons = props.mergeOncoKbIcons;
2302
+ var annotation = props.annotation, enableCivic = props.enableCivic, enableHotspot = props.enableHotspot, enableMyCancerGenome = props.enableMyCancerGenome, enableOncoKb = props.enableOncoKb, pubMedCache = props.pubMedCache, userEmailAddress = props.userEmailAddress, mergeOncoKbIcons = props.mergeOncoKbIcons, oncoKbContentPadding = props.oncoKbContentPadding;
2309
2303
  return (React.createElement("span", { style: { display: 'flex', minWidth: 100 } },
2310
- enableOncoKb && (React.createElement(OncoKB, { usingPublicOncoKbInstance: annotation.usingPublicOncoKbInstance, hugoGeneSymbol: annotation.hugoGeneSymbol, geneNotExist: !annotation.oncoKbGeneExist, isCancerGene: annotation.isOncoKbCancerGene, status: annotation.oncoKbStatus, indicator: annotation.oncoKbIndicator, availableDataTypes: annotation.oncoKbAvailableDataTypes, mergeAnnotationIcons: mergeOncoKbIcons, pubMedCache: pubMedCache, userEmailAddress: userEmailAddress })),
2304
+ enableOncoKb && (React.createElement(OncoKB, { usingPublicOncoKbInstance: annotation.usingPublicOncoKbInstance, hugoGeneSymbol: annotation.hugoGeneSymbol, geneNotExist: !annotation.oncoKbGeneExist, isCancerGene: annotation.isOncoKbCancerGene, status: annotation.oncoKbStatus, indicator: annotation.oncoKbIndicator, availableDataTypes: annotation.oncoKbAvailableDataTypes, mergeAnnotationIcons: mergeOncoKbIcons, pubMedCache: pubMedCache, userEmailAddress: userEmailAddress, contentPadding: oncoKbContentPadding })),
2311
2305
  enableCivic && (React.createElement(Civic, { civicEntry: annotation.civicEntry, civicStatus: annotation.civicStatus, hasCivicVariants: annotation.hasCivicVariants })),
2312
2306
  enableMyCancerGenome && (React.createElement(MyCancerGenome, { linksHTML: annotation.myCancerGenomeLinks })),
2313
2307
  enableHotspot && (React.createElement(HotspotAnnotation, { isHotspot: annotation.isHotspot, is3dHotspot: annotation.is3dHotspot, status: annotation.hotspotStatus }))));
@@ -3166,8 +3160,9 @@ var ProteinChange = /** @class */ (function (_super) {
3166
3160
  return ProteinChange;
3167
3161
  }(React.Component));
3168
3162
 
3169
- function getSignalData(mutation, indexedVariantAnnotations) {
3170
- var signalData = {};
3163
+ function getSignalData(mutation, indexedVariantAnnotations, mutationType // mutationType could be "germline", "somatic", or "undefined" which means both
3164
+ ) {
3165
+ var signalData = [];
3171
3166
  var variantAnnotation = indexedVariantAnnotations
3172
3167
  ? cbioportalUtils.getVariantAnnotation(mutation, indexedVariantAnnotations.result)
3173
3168
  : undefined;
@@ -3175,12 +3170,37 @@ function getSignalData(mutation, indexedVariantAnnotations) {
3175
3170
  variantAnnotation.signalAnnotation &&
3176
3171
  variantAnnotation.signalAnnotation.annotation &&
3177
3172
  variantAnnotation.signalAnnotation.annotation.length > 0) {
3178
- variantAnnotation.signalAnnotation.annotation.forEach(function (annotation) {
3179
- // only have one germline annotation
3180
- if (annotation.mutationStatus.includes('germline')) {
3181
- signalData = cbioportalUtils.extendMutations([annotation])[0];
3173
+ // if mutation is somatic OR germline, get annotation depending on mutationType
3174
+ if (variantAnnotation.signalAnnotation.annotation.length === 1) {
3175
+ if ((mutationType === cbioportalUtils.Pathogenicity.GERMLINE &&
3176
+ variantAnnotation.signalAnnotation.annotation[0].mutationStatus.includes('germline')) ||
3177
+ (mutationType === cbioportalUtils.Pathogenicity.SOMATIC &&
3178
+ variantAnnotation.signalAnnotation.annotation[0].mutationStatus.includes('somatic'))) {
3179
+ signalData = cbioportalUtils.extendMutations([
3180
+ variantAnnotation.signalAnnotation.annotation[0],
3181
+ ]);
3182
+ }
3183
+ }
3184
+ // if mutation is both somatic AND germline, get annotation for both or get one of them depending on mutationType
3185
+ else {
3186
+ // if mutationType is undefined, get annotation for both somatic and germline
3187
+ if (mutationType === undefined) {
3188
+ signalData = cbioportalUtils.extendMutations(variantAnnotation.signalAnnotation.annotation);
3182
3189
  }
3183
- });
3190
+ // if mutationType is defined, get annotation depending on mutationType
3191
+ else {
3192
+ variantAnnotation.signalAnnotation.annotation.forEach(function (annotation) {
3193
+ if (mutationType === cbioportalUtils.Pathogenicity.GERMLINE &&
3194
+ annotation.mutationStatus.includes('germline')) {
3195
+ signalData = cbioportalUtils.extendMutations([annotation]);
3196
+ }
3197
+ else if (mutationType === cbioportalUtils.Pathogenicity.SOMATIC &&
3198
+ annotation.mutationStatus.includes('somatic')) {
3199
+ signalData = cbioportalUtils.extendMutations([annotation]);
3200
+ }
3201
+ });
3202
+ }
3203
+ }
3184
3204
  }
3185
3205
  return signalData;
3186
3206
  }
@@ -3188,25 +3208,29 @@ function signalSortMethod(a, b) {
3188
3208
  return cbioportalUtils.defaultSortMethod(getSortValue(a), getSortValue(b));
3189
3209
  }
3190
3210
  function getSortValue(signalData) {
3191
- return signalData.germlineFrequency || null;
3211
+ return signalData ? signalData.germlineFrequency || null : null;
3192
3212
  }
3193
- function download$7(signalData) {
3194
- return signalData.germlineFrequency != null
3213
+ function download$7(signalData, mutationType) {
3214
+ return signalData && signalData.germlineFrequency !== null
3195
3215
  ? "" + cbioportalUtils.formatNumberValueInSignificantDigits(signalData.germlineFrequency, 2)
3196
3216
  : '';
3197
3217
  }
3198
- function getSignalValue(mutation, indexedVariantAnnotations, significantDigits) {
3199
- var signalData = getSignalData(mutation, indexedVariantAnnotations);
3200
- if (signalData.tumorTypeDecomposition) {
3201
- return cbioportalUtils.formatNumberValueInSignificantDigits(signalData.germlineFrequency, significantDigits || 2);
3218
+ // Get germline OR somatic frequency value
3219
+ function getSingleSignalValue(mutation, mutationType, indexedVariantAnnotations, significantDigits) {
3220
+ var signalData = getSignalData(mutation, indexedVariantAnnotations, mutationType);
3221
+ if (signalData &&
3222
+ signalData.length === 1 &&
3223
+ signalData[0].tumorTypeDecomposition) {
3224
+ return cbioportalUtils.formatNumberValueInSignificantDigits(signalData[0].germlineFrequency || signalData[0].somaticFrequency, significantDigits || 2);
3202
3225
  }
3203
3226
  else {
3204
3227
  return null;
3205
3228
  }
3206
3229
  }
3207
3230
  var SignalTable = function (props) {
3208
- var signalData = getSignalData(props.mutation, props.indexedVariantAnnotations);
3209
- if (getSignalValue(props.mutation, props.indexedVariantAnnotations) !== null) {
3231
+ // signal data should be either germline or somatic, so should be only one element
3232
+ var signalData = getSignalData(props.mutation, props.indexedVariantAnnotations, props.mutationType)[0];
3233
+ if (getSingleSignalValue(props.mutation, props.mutationType || cbioportalUtils.Pathogenicity.GERMLINE, props.indexedVariantAnnotations) !== null) {
3210
3234
  return (React.createElement(cbioportalFrontendCommons.MutationTumorTypeFrequencyTable, { data: cbioportalUtils.generateTumorTypeDecomposition(signalData, signalData.countsByTumorType, signalData.biallelicCountsByTumorType, signalData.qcPassCountsByTumorType, signalData.statsByTumorType), columns: [
3211
3235
  cbioportalFrontendCommons.FREQUENCY_COLUMNS_DEFINITION[cbioportalFrontendCommons.FrequencyTableColumnEnum.TUMOR_TYPE],
3212
3236
  cbioportalFrontendCommons.FREQUENCY_COLUMNS_DEFINITION[cbioportalFrontendCommons.FrequencyTableColumnEnum.MUTATION_STATUS],
@@ -3247,11 +3271,11 @@ var Signal = /** @class */ (function (_super) {
3247
3271
  }
3248
3272
  else {
3249
3273
  content = React.createElement("div", null);
3250
- var signalValue = getSignalValue(this.props.mutation, this.props.indexedVariantAnnotations);
3274
+ var signalValue = getSingleSignalValue(this.props.mutation, this.props.mutationType || cbioportalUtils.Pathogenicity.GERMLINE, this.props.indexedVariantAnnotations);
3251
3275
  if (signalValue !== null) {
3252
3276
  content = (React.createElement(cbioportalFrontendCommons.DefaultTooltip, { placement: "top", overlayStyle: {
3253
3277
  width: 800,
3254
- }, overlay: React.createElement(SignalTable, { mutation: this.props.mutation, indexedVariantAnnotations: this.props.indexedVariantAnnotations }) },
3278
+ }, overlay: React.createElement(SignalTable, { mutation: this.props.mutation, indexedVariantAnnotations: this.props.indexedVariantAnnotations, mutationType: this.props.mutationType }) },
3255
3279
  React.createElement("span", null, signalValue)));
3256
3280
  }
3257
3281
  }
@@ -5195,7 +5219,7 @@ var DefaultMutationTable = /** @class */ (function (_super) {
5195
5219
  return this.indexedVariantAnnotationDataStatus === 'pending'
5196
5220
  ? function () { return undefined; }
5197
5221
  : function (mutation) {
5198
- return getSignalData(mutation, _this.props.indexedVariantAnnotations);
5222
+ return getSignalData(mutation, _this.props.indexedVariantAnnotations, cbioportalUtils.Pathogenicity.GERMLINE)[0];
5199
5223
  };
5200
5224
  },
5201
5225
  enumerable: false,
@@ -5265,7 +5289,7 @@ var DefaultMutationTable = /** @class */ (function (_super) {
5265
5289
  case exports.MutationColumn.DBSNP:
5266
5290
  return function (column) { return (React.createElement(Dbsnp, { mutation: column.original, indexedMyVariantInfoAnnotations: _this.props.indexedMyVariantInfoAnnotations })); };
5267
5291
  case exports.MutationColumn.SIGNAL:
5268
- return function (column) { return (React.createElement(Signal, { mutation: column.original, indexedVariantAnnotations: _this.props.indexedVariantAnnotations })); };
5292
+ return function (column) { return (React.createElement(Signal, { mutation: column.original, indexedVariantAnnotations: _this.props.indexedVariantAnnotations, mutationType: cbioportalUtils.Pathogenicity.GERMLINE })); };
5269
5293
  default:
5270
5294
  return undefined;
5271
5295
  }
@@ -8462,9 +8486,9 @@ var ExonTrack = /** @class */ (function (_super) {
8462
8486
  var startCodon = exon.start;
8463
8487
  var endCodon = exon.start + exon.length;
8464
8488
  var exonLength = exon.length;
8465
- var stringStart = cbioportalUtils.formatExonLocation(startCodon);
8489
+ var stringStart = cbioportalUtils.formatExonLocation(startCodon, index);
8466
8490
  var stringEnd = cbioportalUtils.formatExonLocation(endCodon);
8467
- var stringLength = cbioportalUtils.formatExonLocation(exonLength);
8491
+ var stringLength = cbioportalUtils.formatExonLength(exonLength);
8468
8492
  return {
8469
8493
  color: altColors[index % 2],
8470
8494
  startCodon: startCodon,
@@ -12895,7 +12919,7 @@ exports.getProteinImpactTypeBadgeLabel = getProteinImpactTypeBadgeLabel;
12895
12919
  exports.getProteinImpactTypeOptionLabel = getProteinImpactTypeOptionLabel;
12896
12920
  exports.getSelectedOptionValues = getSelectedOptionValues;
12897
12921
  exports.getSignalData = getSignalData;
12898
- exports.getSignalValue = getSignalValue;
12922
+ exports.getSingleSignalValue = getSingleSignalValue;
12899
12923
  exports.getUrl = getUrl;
12900
12924
  exports.gnomadDownload = download$5;
12901
12925
  exports.gnomadSortValue = sortValue$7;