@sjcrh/proteinpaint-shared 2.98.0 → 2.99.1
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 +2 -2
- package/src/common.js +2 -2
- package/src/doc.js +4 -8
- package/src/joinUrl.js +7 -0
- package/src/termdb.usecase.js +12 -0
- package/src/terms.js +22 -0
- package/src/urljson.js +28 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sjcrh/proteinpaint-shared",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.99.1",
|
|
4
4
|
"description": "ProteinPaint code that is shared between server and client-side workspaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"./*": "./src/*"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "esbuild src/*.ts --platform=node --outdir=src/ --format=esm",
|
|
12
|
+
"build": "esbuild src/*.ts --platform=node --outdir=src/ --format=esm && prettier --no-semi --use-tabs --write src/urljson.js src/joinUrl.js src/doc.js",
|
|
13
13
|
"prepack": "npm run build",
|
|
14
14
|
"test": "ls src/test/*.spec* | xargs node"
|
|
15
15
|
},
|
package/src/common.js
CHANGED
|
@@ -307,7 +307,7 @@ mclass[mclasscnvloss] = {
|
|
|
307
307
|
export const mclasscnvAmp = 'CNV_amplification'
|
|
308
308
|
mclass[mclasscnvAmp] = {
|
|
309
309
|
label: 'Copy number amplification',
|
|
310
|
-
color: '#
|
|
310
|
+
color: '#ff0000',
|
|
311
311
|
dt: dtcnv,
|
|
312
312
|
desc: 'Copy number amplification',
|
|
313
313
|
key: mclasscnvAmp
|
|
@@ -316,7 +316,7 @@ mclass[mclasscnvAmp] = {
|
|
|
316
316
|
export const mclasscnvHomozygousDel = 'CNV_homozygous_deletion'
|
|
317
317
|
mclass[mclasscnvHomozygousDel] = {
|
|
318
318
|
label: 'Copy number homozygous deletion',
|
|
319
|
-
color: '#
|
|
319
|
+
color: '#0000ff',
|
|
320
320
|
dt: dtcnv,
|
|
321
321
|
desc: 'Copy number homozygous deletion',
|
|
322
322
|
key: mclasscnvHomozygousDel
|
package/src/doc.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
const test = {}
|
|
1
|
+
const test = {}
|
|
2
2
|
function doc(opts) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
test[opts.type] = opts.test;
|
|
3
|
+
if (opts.type in test) throw `test['${opts.type}'] already exists`
|
|
4
|
+
test[opts.type] = opts.test
|
|
6
5
|
}
|
|
7
|
-
export {
|
|
8
|
-
doc,
|
|
9
|
-
test
|
|
10
|
-
};
|
|
6
|
+
export { doc, test }
|
package/src/joinUrl.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
function joinUrl(p1, p2) {
|
|
2
|
+
if (typeof p1 != 'string' || typeof p2 != 'string') throw `both arguments must be string type`
|
|
3
|
+
if (!p1 || !p2) throw 'blank string not allowed'
|
|
4
|
+
if (p1.indexOf('?') != -1) throw 'search string not allowed'
|
|
5
|
+
return (p1.endsWith('/') ? p1 : p1 + '/') + (p2.startsWith('/') ? p2.substring(1) : p2)
|
|
6
|
+
}
|
|
7
|
+
export { joinUrl }
|
package/src/termdb.usecase.js
CHANGED
|
@@ -181,6 +181,18 @@ export function isUsableTerm(term, _usecase, termdbConfig, ds) {
|
|
|
181
181
|
}
|
|
182
182
|
// no specific rule for filter. pass and use default rules
|
|
183
183
|
|
|
184
|
+
case 'correlationVolcano':
|
|
185
|
+
if (usecase.detail == 'numeric') {
|
|
186
|
+
if (isNumericTerm(term)) {
|
|
187
|
+
uses.add('plot')
|
|
188
|
+
}
|
|
189
|
+
if (hasNumericChild(child_types)) uses.add('branch')
|
|
190
|
+
} else {
|
|
191
|
+
if (graphableTypes.has(term.type)) uses.add('plot')
|
|
192
|
+
if (!term.isleaf) uses.add('branch')
|
|
193
|
+
}
|
|
194
|
+
return uses
|
|
195
|
+
|
|
184
196
|
default:
|
|
185
197
|
if (graphableTypes.has(term.type)) uses.add('plot')
|
|
186
198
|
if (!term.isleaf) uses.add('branch')
|
package/src/terms.js
CHANGED
|
@@ -184,3 +184,25 @@ export function getParentType(types, ds) {
|
|
|
184
184
|
}
|
|
185
185
|
return null //no parent found
|
|
186
186
|
}
|
|
187
|
+
|
|
188
|
+
//Returns human readable type (nice label) for the given type
|
|
189
|
+
export function getReadableType(type) {
|
|
190
|
+
const typeMap = {
|
|
191
|
+
categorical: 'Categorical',
|
|
192
|
+
condition: 'Condition',
|
|
193
|
+
float: 'Numeric',
|
|
194
|
+
integer: 'Numeric',
|
|
195
|
+
geneExpression: 'Gene Expression',
|
|
196
|
+
geneVariant: 'Gene Variant',
|
|
197
|
+
metaboliteIntensity: 'Metabolite Intensity',
|
|
198
|
+
multiValue: 'Multi Value',
|
|
199
|
+
samplelst: 'Sample List',
|
|
200
|
+
singleCellGeneExpression: 'Single Cell, Gene Expression',
|
|
201
|
+
singleCellCellType: 'Single Cell, Cell Type',
|
|
202
|
+
snplocus: 'SNP Locus',
|
|
203
|
+
snp: 'SNP',
|
|
204
|
+
snplst: 'SNP List'
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return typeMap[type] || 'Unknown type [shared/utils/src/terms.js getReadableType()]'
|
|
208
|
+
}
|
package/src/urljson.js
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import { isNumeric } from
|
|
2
|
-
const reserved = [
|
|
3
|
-
const delimiters = ['"',
|
|
1
|
+
import { isNumeric } from './helpers.js'
|
|
2
|
+
const reserved = ['false', 'true', 'null', 'undefined']
|
|
3
|
+
const delimiters = ['"', '{', '[']
|
|
4
4
|
function encode(rawObject) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
const params = []
|
|
6
|
+
for (const [key, value] of Object.entries(rawObject)) {
|
|
7
|
+
if (typeof value == 'string' && !isNumeric(value) && !reserved.includes(value) && !delimiters.includes(value[0])) {
|
|
8
|
+
params.push(`${key}=${encodeURIComponent(value)}`)
|
|
9
|
+
} else if (value !== void 0) {
|
|
10
|
+
params.push(`${key}=${encodeURIComponent(JSON.stringify(value))}`)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return params.join('&')
|
|
14
14
|
}
|
|
15
15
|
function decode(query) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
const encoding = query.encoding
|
|
17
|
+
for (const [key, value] of Object.entries(query)) {
|
|
18
|
+
if (
|
|
19
|
+
encoding == 'json' ||
|
|
20
|
+
value == 'null' || // not new, always been
|
|
21
|
+
value == 'true' || // NEED TO FIND-REPLACE CODE THAT USES value == 'true'
|
|
22
|
+
value == 'false' || // NEED TO FIND-REPLACE CODE THAT USES value == 'false'
|
|
23
|
+
isNumeric(value) || // NEED TO check
|
|
24
|
+
(value.startsWith('"') && value.endsWith('"')) ||
|
|
25
|
+
(value.startsWith('{') && value.endsWith('}')) ||
|
|
26
|
+
(value.startsWith('[') && value.endsWith(']'))
|
|
27
|
+
)
|
|
28
|
+
query[key] = JSON.parse(value)
|
|
29
|
+
}
|
|
30
|
+
return query
|
|
26
31
|
}
|
|
27
|
-
export {
|
|
28
|
-
decode,
|
|
29
|
-
encode
|
|
30
|
-
};
|
|
32
|
+
export { decode, encode }
|