@@ -135,6 +135,25 @@ function badgeLabelFormat(
135
135
}
136
136
}
137
137
138
+ function isExcludedProteinImpactType (
139
+ type : ProteinImpactType ,
140
+ excludedProteinTypes ?: string [ ] ,
141
+ counts ?: { [ proteinImpactType : string ] : number }
142
+ ) {
143
+ return ! (
144
+ excludedProteinTypes ?. includes (
145
+ type . split ( '_' ) [ 0 ] // get protein type without driver/vus suffix
146
+ ) ||
147
+ ( ( type === ProteinImpactType . OTHER_PUTATIVE_DRIVER ||
148
+ type === ProteinImpactType . OTHER_UNKNOWN_SIGNIFICANCE ||
149
+ type === ProteinImpactType . OTHER ) &&
150
+ counts &&
151
+ counts [ ProteinImpactType . OTHER_PUTATIVE_DRIVER ] +
152
+ counts [ ProteinImpactType . OTHER_UNKNOWN_SIGNIFICANCE ] ===
153
+ 0 )
154
+ ) ;
155
+ }
156
+
138
157
@observer
139
158
export default class DriverAnnotationProteinImpactTypeBadgeSelector extends ProteinImpactTypeBadgeSelector <
140
159
IDriverAnnotationProteinImpactTypeBadgeSelectorProps
@@ -146,29 +165,20 @@ export default class DriverAnnotationProteinImpactTypeBadgeSelector extends Prot
146
165
super ( props ) ;
147
166
makeObservable ( this ) ;
148
167
149
- this . putativeDriverTypes = PUTATIVE_DRIVER_TYPE . filter (
150
- t =>
151
- ! (
152
- this . props . excludedProteinTypes ?. includes (
153
- t . slice ( 0 , t . indexOf ( '_' ) )
154
- ) ||
155
- ( t === ProteinImpactType . OTHER_PUTATIVE_DRIVER &&
156
- this . props . counts ?. [
157
- ProteinImpactType . OTHER_PUTATIVE_DRIVER
158
- ] === 0 )
159
- )
168
+ // filter out driver/vus types prefixed by protein types in excludedProteinTypes
169
+ this . putativeDriverTypes = PUTATIVE_DRIVER_TYPE . filter ( t =>
170
+ isExcludedProteinImpactType (
171
+ t ,
172
+ this . props . excludedProteinTypes ,
173
+ this . props . counts
174
+ )
160
175
) ;
161
- this . unknownSignificanceTypes = UNKNOWN_SIGNIFICANCE_TYPE . filter (
162
- t =>
163
- ! (
164
- this . props . excludedProteinTypes ?. includes (
165
- t . slice ( 0 , t . indexOf ( '_' ) )
166
- ) ||
167
- ( t === ProteinImpactType . OTHER_UNKNOWN_SIGNIFICANCE &&
168
- this . props . counts ?. [
169
- ProteinImpactType . OTHER_UNKNOWN_SIGNIFICANCE
170
- ] === 0 )
171
- )
176
+ this . unknownSignificanceTypes = UNKNOWN_SIGNIFICANCE_TYPE . filter ( t =>
177
+ isExcludedProteinImpactType (
178
+ t ,
179
+ this . props . excludedProteinTypes ,
180
+ this . props . counts
181
+ )
172
182
) ;
173
183
}
174
184
@@ -252,27 +262,12 @@ export default class DriverAnnotationProteinImpactTypeBadgeSelector extends Prot
252
262
253
263
protected get options ( ) {
254
264
// get options, hide "Other" if it's 0
255
- let excludedProteinTypes = this . props . excludedProteinTypes || [ ] ;
256
- if (
257
- this . props . counts &&
258
- this . props . counts [ ProteinImpactType . OTHER_PUTATIVE_DRIVER ] +
259
- this . props . counts [
260
- ProteinImpactType . OTHER_UNKNOWN_SIGNIFICANCE
261
- ] ===
262
- 0
263
- ) {
264
- excludedProteinTypes = excludedProteinTypes . concat ( [
265
- ProteinImpactWithoutVusMutationType . OTHER ,
266
- ] ) ;
267
- }
268
- return SELECTOR_VALUE_WITH_VUS . filter (
269
- type =>
270
- ! (
271
- excludedProteinTypes . includes ( type ) ||
272
- excludedProteinTypes . includes (
273
- type . slice ( 0 , type . indexOf ( '_' ) )
274
- )
275
- )
265
+ return SELECTOR_VALUE_WITH_VUS . filter ( type =>
266
+ isExcludedProteinImpactType (
267
+ type ,
268
+ this . props . excludedProteinTypes ,
269
+ this . props . counts
270
+ )
276
271
) . map ( value => ( {
277
272
value,
278
273
label : this . optionDisplayValueMap [ value ] ,
0 commit comments