@@ -53,20 +53,7 @@ function getBucketKey(entry: KbMatchedStatementType, delimiter = '||') {
53
53
const variantName = getVariantName ( kbMatch ?. variant , kbMatch ?. variantType ) ;
54
54
const { relevance, disease } = entry ;
55
55
const commonSuffix = `${ context } ${ delimiter } ${ variantName } ${ delimiter } ${ relevance } ${ delimiter } ${ disease } ` ;
56
- if ( kbMatch ?. variantType === 'sv' ) {
57
- const {
58
- variant : { gene1 : { name : gene1Name } , gene2 : { name : gene2Name } } ,
59
- } = kbMatch as KbMatchType < 'sv' > ;
60
- bucketKey += `${ gene1Name || '?' } ${ delimiter } ${ gene2Name || '?' } ${ delimiter } ${ commonSuffix } ` ;
61
- } else if ( kbMatch ?. variantType === 'msi' || kbMatch ?. variantType === 'tmb' ) {
62
- const { kbCategory } = kbMatch . variant as KbMatchType < 'tmb' | 'msi' > [ 'variant' ] ;
63
- bucketKey += `${ kbCategory } ${ delimiter } ${ commonSuffix } ` ;
64
- } else {
65
- const {
66
- variant : { gene : { name : geneName } } ,
67
- } = kbMatch as KbMatchType < 'cnv' | 'exp' | 'mut' > ;
68
- bucketKey += `${ geneName } ${ delimiter } ${ commonSuffix } ` ;
69
- }
56
+ bucketKey += commonSuffix ;
70
57
}
71
58
return bucketKey ;
72
59
}
@@ -78,7 +65,6 @@ function getBucketKey(entry: KbMatchedStatementType, delimiter = '||') {
78
65
const commonSuffix = `${ context } ${ delimiter } ${ variantName } ${ delimiter } ${ relevance } ${ delimiter } ${ disease } ` ;
79
66
return commonSuffix ;
80
67
}
81
-
82
68
return null ;
83
69
}
84
70
@@ -114,7 +100,13 @@ const coalesceEntries = <T extends KbMatchedStatementType[]>(entries: T): Coales
114
100
} else {
115
101
Object . entries ( entry ) . forEach ( ( [ key , value ] ) => {
116
102
if ( Array . isArray ( buckets [ bucketKey ] [ key ] ) ) {
117
- if ( ! buckets [ bucketKey ] [ key ] . includes ( value ) ) {
103
+ if ( key === 'kbMatches' && Array . isArray ( value ) ) {
104
+ const kbMatchesIdents = buckets [ bucketKey ] [ key ] . map ( ( kbM ) => kbM . ident ) . join ( ) ;
105
+ const coalescedKbMatchesIdents = value . map ( ( kbM ) => kbM . ident ) . join ( ) ;
106
+ if ( kbMatchesIdents !== coalescedKbMatchesIdents ) {
107
+ buckets [ bucketKey ] [ key ] = buckets [ bucketKey ] [ key ] . concat ( value ) ;
108
+ }
109
+ } else if ( ! buckets [ bucketKey ] [ key ] . includes ( value ) ) {
118
110
buckets [ bucketKey ] [ key ] . push ( value ) ;
119
111
}
120
112
} else if ( typeof buckets [ bucketKey ] [ key ] !== 'object' && buckets [ bucketKey ] [ key ] !== value ) {
0 commit comments