@sjcrh/proteinpaint-shared 2.79.3 → 2.83.0
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/package.json +1 -1
- package/src/helpers.js +19 -0
- package/src/termdb.usecase.js +10 -0
- package/src/terms.js +4 -2
package/package.json
CHANGED
package/src/helpers.js
CHANGED
|
@@ -29,3 +29,22 @@ export function convertUnits(v, fromUnit, toUnit, scaleFactor, compact) {
|
|
|
29
29
|
if (compact) return `${toUnitV}${toUnit.charAt(0)}${fromUnitV}${fromUnit.charAt(0)}`
|
|
30
30
|
return `${toUnitV} ${toUnitV > 1 ? toUnit + 's' : toUnit} ${fromUnitV} ${fromUnitV > 1 ? fromUnit + 's' : fromUnit}`
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
export function deepEqual(x, y) {
|
|
34
|
+
if (x === y) {
|
|
35
|
+
return true
|
|
36
|
+
} else if (typeof x == 'object' && x != null && typeof y == 'object' && y != null) {
|
|
37
|
+
if (Object.keys(x).length != Object.keys(y).length) {
|
|
38
|
+
return false
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
for (var prop in x) {
|
|
42
|
+
if (y.hasOwnProperty(prop)) {
|
|
43
|
+
if (!deepEqual(x[prop], y[prop])) return false
|
|
44
|
+
} else {
|
|
45
|
+
return false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return true
|
|
49
|
+
} else return false
|
|
50
|
+
}
|
package/src/termdb.usecase.js
CHANGED
|
@@ -97,6 +97,16 @@ export function isUsableTerm(term, _usecase, termdbConfig, ds) {
|
|
|
97
97
|
if (!term.isleaf) uses.add('branch')
|
|
98
98
|
}
|
|
99
99
|
return uses
|
|
100
|
+
case 'numericDictTermCluster':
|
|
101
|
+
if (!usecase.detail?.exclude?.includes(term.id)) {
|
|
102
|
+
if (isNumericTerm(term)) {
|
|
103
|
+
uses.add('plot')
|
|
104
|
+
}
|
|
105
|
+
if (hasNumericChild(child_types)) {
|
|
106
|
+
uses.add('branch')
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return uses
|
|
100
110
|
|
|
101
111
|
case 'profile':
|
|
102
112
|
if (!term.isleaf) {
|
package/src/terms.js
CHANGED
|
@@ -39,6 +39,8 @@ export const TermTypes = {
|
|
|
39
39
|
SINGLECELL_CELLTYPE: 'singleCellCellType'
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
export const NUMERIC_DICTIONARY_TERM = 'numericDictTerm'
|
|
43
|
+
|
|
42
44
|
export const TermTypes2Dt = {
|
|
43
45
|
[TermTypes.GENE_EXPRESSION]: dtgeneexpression,
|
|
44
46
|
[TermTypes.METABOLITE_INTENSITY]: dtmetaboliteintensity
|
|
@@ -163,11 +165,11 @@ export function getSampleType(term, ds) {
|
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
export function getParentType(types, ds) {
|
|
166
|
-
if (ds.cohort.termdb.sampleTypes.
|
|
168
|
+
if (Object.keys(ds.cohort.termdb.sampleTypes).length == 0) return null //dataset only has one type of sample
|
|
167
169
|
const ids = Array.from(types)
|
|
168
170
|
if (!ids || ids.length == 0) return null
|
|
169
171
|
for (const id of ids) {
|
|
170
|
-
const typeObj = ds.cohort.termdb.sampleTypes
|
|
172
|
+
const typeObj = ds.cohort.termdb.sampleTypes[id]
|
|
171
173
|
if (typeObj.parent_id == null) return id //this is the root type
|
|
172
174
|
//if my parent is in the list, then I am not the parent
|
|
173
175
|
if (ids.includes(typeObj.parent_id)) continue
|