@sjcrh/proteinpaint-server 2.189.0 → 2.190.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 +9 -12
- package/routes/aiProjectAdmin.js +2 -28
- package/routes/aiProjectSelectedWSImages.js +2 -16
- package/routes/brainImaging.js +1 -15
- package/routes/brainImagingSamples.js +1 -15
- package/routes/burden.js +1 -15
- package/routes/correlationVolcano.js +1 -15
- package/routes/dataset.js +1 -16
- package/routes/deleteWSITileSelection.js +2 -12
- package/routes/dsdata.js +1 -19
- package/routes/gdc.grin2.list.js +1 -15
- package/routes/gdc.grin2.run.js +1 -15
- package/routes/gdc.maf.js +1 -15
- package/routes/gdc.mafBuild.js +1 -15
- package/routes/genesetEnrichment.js +129 -97
- package/routes/grin2.js +110 -79
- package/routes/saveWSIAnnotation.js +2 -13
- package/routes/termdb.DE.js +137 -54
- package/routes/termdb.categories.js +2 -16
- package/routes/termdb.chat.js +169 -1076
- package/routes/termdb.cluster.js +5 -16
- package/routes/termdb.config.js +12 -17
- package/routes/termdb.descrstats.js +2 -16
- package/routes/termdb.diffMeth.js +100 -21
- package/routes/termdb.geneRanking.js +139 -0
- package/routes/termdb.proteome.js +1 -15
- package/routes/termdb.runChart.js +16 -30
- package/routes/termdb.sampleScatter.js +7 -97
- package/routes/termdb.singleCellPlots.js +159 -0
- package/routes/termdb.singlecellSamples.js +6 -16
- package/routes/termdb.violinBox.js +1 -15
- package/routes/wsimages.js +1 -16
- package/src/app.js +3984 -4103
- package/routes/_template_.js +0 -33
- package/routes/aiProjectTrainModel.js +0 -68
- package/routes/alphaGenome.js +0 -41
- package/routes/alphaGenomeTypes.js +0 -36
- package/routes/dzimages.js +0 -55
- package/routes/gene2canonicalisoform.js +0 -37
- package/routes/genelookup.js +0 -32
- package/routes/genesetOverrepresentation.js +0 -49
- package/routes/genomes.js +0 -150
- package/routes/healthcheck.js +0 -35
- package/routes/hicdata.js +0 -74
- package/routes/hicgenome.js +0 -75
- package/routes/hicstat.js +0 -35
- package/routes/img.js +0 -46
- package/routes/isoformlst.js +0 -48
- package/routes/ntseq.js +0 -36
- package/routes/pdomain.js +0 -53
- package/routes/profile.barchart2.js +0 -114
- package/routes/profile.forms2.js +0 -107
- package/routes/profile.polar2.js +0 -101
- package/routes/profile.radar2.js +0 -112
- package/routes/profile.radarFacility2.js +0 -148
- package/routes/sampledzimages.js +0 -48
- package/routes/samplewsimages.js +0 -60
- package/routes/snp.js +0 -98
- package/routes/termdb.chat2.js +0 -217
- package/routes/termdb.chat3.js +0 -209
- package/routes/termdb.cohort.summary.js +0 -37
- package/routes/termdb.cohorts.js +0 -41
- package/routes/termdb.dapVolcano.js +0 -80
- package/routes/termdb.dmr.js +0 -93
- package/routes/termdb.filterTermValues.js +0 -89
- package/routes/termdb.isoformAvailability.js +0 -35
- package/routes/termdb.numericcategories.js +0 -46
- package/routes/termdb.percentile.js +0 -66
- package/routes/termdb.profileFormScores.js +0 -92
- package/routes/termdb.profileScores.js +0 -113
- package/routes/termdb.rootterm.js +0 -39
- package/routes/termdb.sampleImages.js +0 -63
- package/routes/termdb.singleSampleMutation.js +0 -75
- package/routes/termdb.singlecellDEgenes.js +0 -55
- package/routes/termdb.singlecellData.js +0 -39
- package/routes/termdb.termchildren.js +0 -42
- package/routes/termdb.termsbyids.js +0 -50
- package/routes/termdb.topMutatedGenes.js +0 -127
- package/routes/termdb.topTermsByType.js +0 -96
- package/routes/termdb.topVariablyExpressedGenes.js +0 -132
- package/routes/tileserver.js +0 -68
- package/routes/wsisamples.js +0 -71
package/routes/_template_.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { snpPayload } from "#types/checkers";
|
|
2
|
-
const api = {
|
|
3
|
-
// route endpoint
|
|
4
|
-
// - no need for trailing slash
|
|
5
|
-
// - should be a noun
|
|
6
|
-
// - don't add 'Data' as response is assumed to be data
|
|
7
|
-
// - don't prefix with `get`, such as `/getmyroute`, the method is already indicated via HTTP GET
|
|
8
|
-
endpoint: "/myroute",
|
|
9
|
-
methods: {
|
|
10
|
-
get: {
|
|
11
|
-
...snpPayload,
|
|
12
|
-
// this would "spread"/copy-over payload key-values from snpPayload, such as {request: {typeId}, examples: []}
|
|
13
|
-
init
|
|
14
|
-
},
|
|
15
|
-
post: {
|
|
16
|
-
...snpPayload,
|
|
17
|
-
// repeat for post method, since PP routes are mostly read-only and POST can handle bigger payloads
|
|
18
|
-
init
|
|
19
|
-
}
|
|
20
|
-
// !!! DO NOT USE expressjs 'all' method shortcut !!!
|
|
21
|
-
// it will initialize 20+ methods includng HEAD which can break expected HTTP response
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
function init({ genomes }) {
|
|
25
|
-
return async function(req, res) {
|
|
26
|
-
const q = req.query;
|
|
27
|
-
console.log(genomes[q.genome]);
|
|
28
|
-
res.send({});
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export {
|
|
32
|
-
api
|
|
33
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { aiProjectTrainModelPayload } from "#types/checkers";
|
|
2
|
-
import { TileServerSessionsHandler } from "#src/wsisessions/TileServerSessionsHandler.ts";
|
|
3
|
-
import SessionManager from "#src/wsisessions/SessionManager.ts";
|
|
4
|
-
import { getDbConnection } from "#src/aiHistoDBConnection.js";
|
|
5
|
-
import { getImages } from "#routes/aiProjectAdmin.js";
|
|
6
|
-
const api = {
|
|
7
|
-
endpoint: "aiProjectTrainModel",
|
|
8
|
-
methods: {
|
|
9
|
-
get: {
|
|
10
|
-
...aiProjectTrainModelPayload,
|
|
11
|
-
init
|
|
12
|
-
},
|
|
13
|
-
post: {
|
|
14
|
-
...aiProjectTrainModelPayload,
|
|
15
|
-
init
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
function init({ genomes }) {
|
|
20
|
-
return async function(req, res) {
|
|
21
|
-
try {
|
|
22
|
-
const query = req.query;
|
|
23
|
-
const g = genomes[query.genome];
|
|
24
|
-
if (!g) throw "invalid genome name";
|
|
25
|
-
const ds = g.datasets[query.dslabel];
|
|
26
|
-
if (!ds) throw "invalid dataset name";
|
|
27
|
-
if (typeof ds.queries.WSImages.retrainModel == "function") {
|
|
28
|
-
const connection = getDbConnection(ds);
|
|
29
|
-
const project = {
|
|
30
|
-
id: query.projectId
|
|
31
|
-
};
|
|
32
|
-
const wsimages = getImages(connection, project);
|
|
33
|
-
await ds.queries.WSImages.retrainModel(query.projectId, wsimages);
|
|
34
|
-
try {
|
|
35
|
-
const handler = new TileServerSessionsHandler();
|
|
36
|
-
const sessionMgr = SessionManager.getInstance();
|
|
37
|
-
const keySessions = await sessionMgr.getAllKeyValues();
|
|
38
|
-
const sessions = keySessions.map((kv) => kv?.sessionData).filter(Boolean);
|
|
39
|
-
if (sessions && sessions.length) {
|
|
40
|
-
await handler.resetSessions(sessions);
|
|
41
|
-
await Promise.all(keySessions.map((kv) => sessionMgr.deleteSession(kv.key)));
|
|
42
|
-
}
|
|
43
|
-
} catch (err) {
|
|
44
|
-
console.warn("TileServerSessionsHandler error:", err);
|
|
45
|
-
}
|
|
46
|
-
} else {
|
|
47
|
-
res.status(500).send({
|
|
48
|
-
status: "error",
|
|
49
|
-
error: "No retraining script defined"
|
|
50
|
-
});
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
res.status(200).send({
|
|
54
|
-
status: "ok",
|
|
55
|
-
message: `Retraining model completed`
|
|
56
|
-
});
|
|
57
|
-
} catch (e) {
|
|
58
|
-
console.warn(e);
|
|
59
|
-
res.status(500).send({
|
|
60
|
-
status: "error",
|
|
61
|
-
error: e.message || e
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
export {
|
|
67
|
-
api
|
|
68
|
-
};
|
package/routes/alphaGenome.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { alphaGenomePayload } from "#types/checkers";
|
|
2
|
-
import { run_python } from "@sjcrh/proteinpaint-python";
|
|
3
|
-
import serverconfig from "#src/serverconfig.js";
|
|
4
|
-
const api = {
|
|
5
|
-
endpoint: "alphaGenome",
|
|
6
|
-
methods: {
|
|
7
|
-
get: {
|
|
8
|
-
...alphaGenomePayload,
|
|
9
|
-
init
|
|
10
|
-
},
|
|
11
|
-
post: {
|
|
12
|
-
...alphaGenomePayload,
|
|
13
|
-
init
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
function init() {
|
|
18
|
-
return async (req, res) => {
|
|
19
|
-
try {
|
|
20
|
-
const query = req.query;
|
|
21
|
-
const params = {
|
|
22
|
-
API_KEY: serverconfig.alphaGenome.API_KEY,
|
|
23
|
-
chromosome: query.chromosome,
|
|
24
|
-
position: query.position,
|
|
25
|
-
reference: query.reference,
|
|
26
|
-
alternate: query.alternate,
|
|
27
|
-
interval: query.interval
|
|
28
|
-
};
|
|
29
|
-
if (query.ontologyTerms) params["ontologyTerms"] = query.ontologyTerms;
|
|
30
|
-
if (query.outputType) params["outputType"] = Number(query.outputType);
|
|
31
|
-
const url = await run_python("alphaGenome.py", JSON.stringify(params));
|
|
32
|
-
res.send({ plotImage: url });
|
|
33
|
-
} catch (e) {
|
|
34
|
-
console.log(e);
|
|
35
|
-
res.status(404).send({ error: e });
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export {
|
|
40
|
-
api
|
|
41
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { alphaGenomeTypesPayload } from "#types/checkers";
|
|
2
|
-
import { run_python } from "@sjcrh/proteinpaint-python";
|
|
3
|
-
import serverconfig from "#src/serverconfig.js";
|
|
4
|
-
const api = {
|
|
5
|
-
endpoint: "AlphaGenomeTypes",
|
|
6
|
-
methods: {
|
|
7
|
-
get: {
|
|
8
|
-
...alphaGenomeTypesPayload,
|
|
9
|
-
init
|
|
10
|
-
},
|
|
11
|
-
post: {
|
|
12
|
-
...alphaGenomeTypesPayload,
|
|
13
|
-
init
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
function init() {
|
|
18
|
-
return async (req, res) => {
|
|
19
|
-
try {
|
|
20
|
-
const params = { API_KEY: serverconfig.alphaGenome.API_KEY };
|
|
21
|
-
const result = await run_python("AlphaGenomeTypes.py", JSON.stringify(params));
|
|
22
|
-
const { ontologyTerms, outputTypes, intervals } = JSON.parse(result);
|
|
23
|
-
res.send({
|
|
24
|
-
ontologyTerms: ontologyTerms.sort((a, b) => a.label.localeCompare(b.label)),
|
|
25
|
-
outputTypes,
|
|
26
|
-
intervals
|
|
27
|
-
});
|
|
28
|
-
} catch (e) {
|
|
29
|
-
console.log(e);
|
|
30
|
-
res.status(404).send({ error: e });
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
export {
|
|
35
|
-
api
|
|
36
|
-
};
|
package/routes/dzimages.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import serverconfig from "#src/serverconfig.js";
|
|
3
|
-
import { illegalpath } from "#src/utils.js";
|
|
4
|
-
import { dzImagesPayload } from "#types/checkers";
|
|
5
|
-
const api = {
|
|
6
|
-
endpoint: `dzimages/:sampleId`,
|
|
7
|
-
methods: {
|
|
8
|
-
get: {
|
|
9
|
-
...dzImagesPayload,
|
|
10
|
-
init
|
|
11
|
-
},
|
|
12
|
-
post: {
|
|
13
|
-
...dzImagesPayload,
|
|
14
|
-
init
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
function init({ genomes }) {
|
|
19
|
-
return async (req, res) => {
|
|
20
|
-
try {
|
|
21
|
-
const q = req.query;
|
|
22
|
-
const g = genomes[q.genome];
|
|
23
|
-
if (!g) throw "invalid genome name";
|
|
24
|
-
const ds = g.datasets[q.dslabel];
|
|
25
|
-
if (!ds) throw "invalid dataset name";
|
|
26
|
-
const sampleId = q.sampleId;
|
|
27
|
-
if (!sampleId) throw "invalid sampleId";
|
|
28
|
-
if (illegalpath(req.query.file)) throw `illegalpath filepath`;
|
|
29
|
-
const filename = path.basename(q.file);
|
|
30
|
-
const allowedExtensions = [".dzi", ".jpeg", ".png"];
|
|
31
|
-
const extension = path.extname(filename);
|
|
32
|
-
if (!allowedExtensions.includes(extension)) {
|
|
33
|
-
throw `Invalid file extension. Allowed extensions are ${allowedExtensions.join(", ")}`;
|
|
34
|
-
}
|
|
35
|
-
const imagePath = path.join(
|
|
36
|
-
`${serverconfig.tpmasterdir}/${ds.queries.DZImages.imageBySampleFolder}`,
|
|
37
|
-
`${sampleId}/${req.query.file}`
|
|
38
|
-
);
|
|
39
|
-
res.sendFile(imagePath, (err) => {
|
|
40
|
-
if (err) {
|
|
41
|
-
res.status(404).send("Image not found");
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
} catch (e) {
|
|
45
|
-
console.log(e);
|
|
46
|
-
res.send({
|
|
47
|
-
status: "error",
|
|
48
|
-
error: e.error || e
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
export {
|
|
54
|
-
api
|
|
55
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const api = {
|
|
2
|
-
endpoint: "gene2canonicalisoform",
|
|
3
|
-
// should rename to simply 'canonicalIsoform' or 'isoform', gene and type: 'canonical' can be part of payload
|
|
4
|
-
methods: {
|
|
5
|
-
get: {
|
|
6
|
-
init,
|
|
7
|
-
request: {
|
|
8
|
-
typeId: "any"
|
|
9
|
-
},
|
|
10
|
-
response: {
|
|
11
|
-
typeId: "any"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
post: {
|
|
15
|
-
alternativeFor: "get",
|
|
16
|
-
init
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
function init({ genomes }) {
|
|
21
|
-
return function(req, res) {
|
|
22
|
-
try {
|
|
23
|
-
if (!req.query.gene) throw ".gene missing";
|
|
24
|
-
const genome = genomes[req.query.genome];
|
|
25
|
-
if (!genome) throw "unknown genome";
|
|
26
|
-
if (!genome.genedb.get_gene2canonicalisoform) throw "gene2canonicalisoform not supported on this genome";
|
|
27
|
-
const data = genome.genedb.get_gene2canonicalisoform.get(req.query.gene);
|
|
28
|
-
res.send(data);
|
|
29
|
-
} catch (e) {
|
|
30
|
-
res.send({ error: e.message || e });
|
|
31
|
-
if (e.stack) console.log(e.stack);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export {
|
|
36
|
-
api
|
|
37
|
-
};
|
package/routes/genelookup.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { getResult } from "#src/gene.js";
|
|
2
|
-
import { geneLookupPayload } from "#types/checkers";
|
|
3
|
-
const api = {
|
|
4
|
-
endpoint: "genelookup",
|
|
5
|
-
methods: {
|
|
6
|
-
get: {
|
|
7
|
-
init,
|
|
8
|
-
...geneLookupPayload
|
|
9
|
-
},
|
|
10
|
-
post: {
|
|
11
|
-
init,
|
|
12
|
-
...geneLookupPayload
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
function init({ genomes }) {
|
|
17
|
-
return (req, res) => {
|
|
18
|
-
try {
|
|
19
|
-
const q = req.query;
|
|
20
|
-
const g = genomes[q.genome];
|
|
21
|
-
if (!g) throw "invalid genome name";
|
|
22
|
-
const result = getResult(g, q);
|
|
23
|
-
res.send(result);
|
|
24
|
-
} catch (e) {
|
|
25
|
-
res.send({ error: e.message || e });
|
|
26
|
-
if (e.stack) console.log(e.stack);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
export {
|
|
31
|
-
api
|
|
32
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { genesetOverrepresentationPayload } from "#types/checkers";
|
|
2
|
-
import { run_rust } from "@sjcrh/proteinpaint-rust";
|
|
3
|
-
import serverconfig from "#src/serverconfig.js";
|
|
4
|
-
import path from "path";
|
|
5
|
-
const api = {
|
|
6
|
-
endpoint: "genesetOverrepresentation",
|
|
7
|
-
methods: {
|
|
8
|
-
get: {
|
|
9
|
-
...genesetOverrepresentationPayload,
|
|
10
|
-
init
|
|
11
|
-
},
|
|
12
|
-
post: {
|
|
13
|
-
...genesetOverrepresentationPayload,
|
|
14
|
-
init
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
function init({ genomes }) {
|
|
19
|
-
return async (req, res) => {
|
|
20
|
-
try {
|
|
21
|
-
const results = await run_genesetOverrepresentation_analysis(req.query, genomes);
|
|
22
|
-
res.send(results);
|
|
23
|
-
} catch (e) {
|
|
24
|
-
res.send({ status: "error", error: e.message || e });
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
async function run_genesetOverrepresentation_analysis(q, genomes) {
|
|
29
|
-
if (!genomes[q.genome].termdbs) throw "termdb database is not available for " + q.genome;
|
|
30
|
-
const gene_overrepresentation_input_type = {
|
|
31
|
-
sample_genes: q.sample_genes,
|
|
32
|
-
msigdb: genomes[q.genome].termdbs.msigdb.cohort.db.connection.name,
|
|
33
|
-
gene_set_group: q.geneSetGroup,
|
|
34
|
-
filter_non_coding_genes: q.filter_non_coding_genes,
|
|
35
|
-
genedb: path.join(serverconfig.tpmasterdir, genomes[q.genome].genedb.dbfile)
|
|
36
|
-
};
|
|
37
|
-
if (q.background_genes) {
|
|
38
|
-
gene_overrepresentation_input_type.background_genes = q.background_genes;
|
|
39
|
-
}
|
|
40
|
-
const time1 = (/* @__PURE__ */ new Date()).valueOf();
|
|
41
|
-
const rust_output = await run_rust("genesetORA", JSON.stringify(gene_overrepresentation_input_type));
|
|
42
|
-
const time2 = (/* @__PURE__ */ new Date()).valueOf();
|
|
43
|
-
console.log("Time taken to run rust gene over representation pipeline:", time2 - time1, "ms");
|
|
44
|
-
const result = JSON.parse(rust_output);
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
|
-
export {
|
|
48
|
-
api
|
|
49
|
-
};
|
package/routes/genomes.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import serverconfig from "#src/serverconfig.js";
|
|
3
|
-
import { authApi } from "#src/auth.js";
|
|
4
|
-
import { versionInfo } from "#src/health.ts";
|
|
5
|
-
const api = {
|
|
6
|
-
endpoint: "genomes",
|
|
7
|
-
methods: {
|
|
8
|
-
get: {
|
|
9
|
-
init,
|
|
10
|
-
request: {
|
|
11
|
-
typeId: "any"
|
|
12
|
-
},
|
|
13
|
-
response: {
|
|
14
|
-
typeId: "any"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
post: {
|
|
18
|
-
alternativeFor: "get",
|
|
19
|
-
init
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
function init({ genomes }) {
|
|
24
|
-
return async function handle_genomes(req, res) {
|
|
25
|
-
try {
|
|
26
|
-
await fs.promises.stat(serverconfig.tpmasterdir);
|
|
27
|
-
} catch (e) {
|
|
28
|
-
let message = "Error with TP directory (" + e.code + ")";
|
|
29
|
-
const m = serverconfig.maintenance || {};
|
|
30
|
-
if ("start" in m && "stop" in m && m.tpMessage) {
|
|
31
|
-
const start = +new Date(m.start);
|
|
32
|
-
const stop = +new Date(m.stop);
|
|
33
|
-
const currTime = +/* @__PURE__ */ new Date();
|
|
34
|
-
if (start <= currTime && currTime <= stop) {
|
|
35
|
-
message = m.tpMessage;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
res.send({ error: message });
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const hash = {};
|
|
42
|
-
if (req.query && req.query.genome) {
|
|
43
|
-
hash[req.query.genome] = clientcopy_genome(req.query.genome, genomes);
|
|
44
|
-
} else {
|
|
45
|
-
for (const genomename in genomes) {
|
|
46
|
-
hash[genomename] = clientcopy_genome(genomename, genomes);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
let hasblat = false;
|
|
50
|
-
for (const n in genomes) {
|
|
51
|
-
if (genomes[n].blat) hasblat = true;
|
|
52
|
-
}
|
|
53
|
-
res.send({
|
|
54
|
-
genomes: hash,
|
|
55
|
-
debugmode: serverconfig.debugmode,
|
|
56
|
-
headermessage: serverconfig.headermessage,
|
|
57
|
-
base_zindex: serverconfig.base_zindex,
|
|
58
|
-
pkgver: versionInfo.pkgver,
|
|
59
|
-
codedate: versionInfo.codedate,
|
|
60
|
-
// still useful to know the package build/publish date in the response payload, even if it's not displayed
|
|
61
|
-
launchdate: versionInfo.launchdate,
|
|
62
|
-
hasblat,
|
|
63
|
-
features: serverconfig.features,
|
|
64
|
-
dsAuth: authApi.getDsAuth(req),
|
|
65
|
-
commonOverrides: serverconfig.commonOverrides,
|
|
66
|
-
targetPortal: serverconfig.targetPortal,
|
|
67
|
-
//sending target portal to the client
|
|
68
|
-
cardsPath: serverconfig.cards?.path
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function clientcopy_genome(genomename, genomes) {
|
|
73
|
-
const g = genomes[genomename];
|
|
74
|
-
const g2 = {
|
|
75
|
-
species: g.species,
|
|
76
|
-
name: genomename,
|
|
77
|
-
hasSNP: g.snp ? true : false,
|
|
78
|
-
hasIdeogram: g.genedb.hasIdeogram,
|
|
79
|
-
fimo_motif: g.fimo_motif ? true : false,
|
|
80
|
-
blat: g.blat ? true : false,
|
|
81
|
-
geneset: g.geneset,
|
|
82
|
-
defaultcoord: g.defaultcoord,
|
|
83
|
-
isdefault: g.isdefault,
|
|
84
|
-
majorchr: g.majorchr,
|
|
85
|
-
majorchrorder: g.majorchrorder,
|
|
86
|
-
minorchr: g.minorchr,
|
|
87
|
-
tracks: g.tracks,
|
|
88
|
-
hicenzymefragment: g.hicenzymefragment,
|
|
89
|
-
datasets: {},
|
|
90
|
-
hideOnClient: g.hideOnClient
|
|
91
|
-
};
|
|
92
|
-
if (g.termdbs) {
|
|
93
|
-
g2.termdbs = {};
|
|
94
|
-
for (const k in g.termdbs) {
|
|
95
|
-
g2.termdbs[k] = {
|
|
96
|
-
label: g.termdbs[k].label,
|
|
97
|
-
analysisGenesetGroups: g.termdbs[k].analysisGenesetGroups,
|
|
98
|
-
geneORAparam: g.termdbs[k].geneORAparam
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
for (const dsname in g.datasets) {
|
|
103
|
-
const ds = g.datasets[dsname];
|
|
104
|
-
if (ds.isMds3) {
|
|
105
|
-
g2.datasets[ds.label] = {
|
|
106
|
-
isMds3: true,
|
|
107
|
-
noHandleOnClient: ds.noHandleOnClient,
|
|
108
|
-
label: ds.label
|
|
109
|
-
};
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
if (ds.isMds) {
|
|
113
|
-
g2.datasets[ds.label] = {
|
|
114
|
-
isMds: true,
|
|
115
|
-
mdsIsUninitiated: true,
|
|
116
|
-
noHandleOnClient: ds.noHandleOnClient,
|
|
117
|
-
label: ds.label
|
|
118
|
-
};
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
g2.datasets[ds.label] = {
|
|
122
|
-
isofficial: true,
|
|
123
|
-
legacyDsIsUninitiated: true,
|
|
124
|
-
// so client only gets copy_legacyDataset once
|
|
125
|
-
noHandleOnClient: ds.noHandleOnClient,
|
|
126
|
-
label: ds.label
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
if (g.hicdomain) {
|
|
130
|
-
g2.hicdomain = { groups: {} };
|
|
131
|
-
for (const s1 in g.hicdomain.groups) {
|
|
132
|
-
const tt = g.hicdomain.groups[s1];
|
|
133
|
-
g2.hicdomain.groups[s1] = {
|
|
134
|
-
name: tt.name,
|
|
135
|
-
reference: tt.reference,
|
|
136
|
-
sets: {}
|
|
137
|
-
};
|
|
138
|
-
for (const s2 in tt.sets) {
|
|
139
|
-
g2.hicdomain.groups[s1].sets[s2] = {
|
|
140
|
-
name: tt.sets[s2].name,
|
|
141
|
-
longname: tt.sets[s2].longname
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return g2;
|
|
147
|
-
}
|
|
148
|
-
export {
|
|
149
|
-
api
|
|
150
|
-
};
|
package/routes/healthcheck.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { getStat } from "#src/health.ts";
|
|
2
|
-
import { healthcheckPayload } from "#types/checkers";
|
|
3
|
-
const api = {
|
|
4
|
-
endpoint: "healthcheck",
|
|
5
|
-
methods: {
|
|
6
|
-
get: {
|
|
7
|
-
...healthcheckPayload,
|
|
8
|
-
init
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
function init(arg) {
|
|
13
|
-
const genomes = arg.genomes;
|
|
14
|
-
return async (req, res) => {
|
|
15
|
-
try {
|
|
16
|
-
const q = req.query;
|
|
17
|
-
const health = await getStat(genomes);
|
|
18
|
-
if (q.dslabel) {
|
|
19
|
-
for (const gn in genomes) {
|
|
20
|
-
const ds = genomes[gn]?.datasets?.[q.dslabel];
|
|
21
|
-
if (!ds?.getHealth) continue;
|
|
22
|
-
if (!health.byDataset) health.byDataset = {};
|
|
23
|
-
if (!health.byDataset[q.dslabel]) health.byDataset[q.dslabel] = {};
|
|
24
|
-
health.byDataset[q.dslabel][gn] = ds.getHealth(ds);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
res.send(health);
|
|
28
|
-
} catch (e) {
|
|
29
|
-
res.send({ status: "error", error: e.message || e });
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export {
|
|
34
|
-
api
|
|
35
|
-
};
|
package/routes/hicdata.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { hicdataPayload } from "#types/checkers";
|
|
2
|
-
import { fileurl } from "#src/utils.js";
|
|
3
|
-
import { spawn } from "child_process";
|
|
4
|
-
import readline from "readline";
|
|
5
|
-
import serverconfig from "#src/serverconfig.js";
|
|
6
|
-
const api = {
|
|
7
|
-
endpoint: "hicdata",
|
|
8
|
-
methods: {
|
|
9
|
-
get: {
|
|
10
|
-
...hicdataPayload,
|
|
11
|
-
init
|
|
12
|
-
},
|
|
13
|
-
post: {
|
|
14
|
-
...hicdataPayload,
|
|
15
|
-
init
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
function init() {
|
|
20
|
-
return async (req, res) => {
|
|
21
|
-
try {
|
|
22
|
-
const q = req.query;
|
|
23
|
-
const payload = await handle_hicdata(q);
|
|
24
|
-
res.send(payload);
|
|
25
|
-
} catch (e) {
|
|
26
|
-
res.send({ error: e?.message || e });
|
|
27
|
-
if (e instanceof Error && e.stack) console.log(e);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function handle_hicdata(q) {
|
|
32
|
-
return new Promise((resolve, reject) => {
|
|
33
|
-
const [e, file] = fileurl({ query: q });
|
|
34
|
-
if (e) reject({ error: "illegal file name" });
|
|
35
|
-
const matrixType = q.matrixType == "log(oe)" ? "oe" : q.matrixType ? q.matrixType : "observed";
|
|
36
|
-
const par = [matrixType, q.nmeth || "NONE", file, q.pos1, q.pos2, q.isfrag ? "FRAG" : "BP", q.resolution];
|
|
37
|
-
const ps = spawn(serverconfig.hicstraw, par);
|
|
38
|
-
const rl = readline.createInterface({ input: ps.stdout });
|
|
39
|
-
const items = [];
|
|
40
|
-
const erroutput = [];
|
|
41
|
-
let linenot3fields = 0;
|
|
42
|
-
let fieldnotnumerical = 0;
|
|
43
|
-
rl.on("line", (line) => {
|
|
44
|
-
const l = line.split(" ");
|
|
45
|
-
if (l.length != 3) {
|
|
46
|
-
linenot3fields++;
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const n1 = Number.parseInt(l[0]);
|
|
50
|
-
const n2 = Number.parseInt(l[1]);
|
|
51
|
-
const v = q.matrixType == "log(oe)" ? Math.log(Number.parseFloat(l[2])) : Number.parseFloat(l[2]);
|
|
52
|
-
if (Number.isNaN(n1) || Number.isNaN(n2) || Number.isNaN(v)) {
|
|
53
|
-
fieldnotnumerical++;
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (q.mincutoff != void 0 && v <= q.mincutoff) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
items.push([n1, n2, v]);
|
|
60
|
-
});
|
|
61
|
-
ps.stderr.on("data", (i) => erroutput.push(i));
|
|
62
|
-
ps.on("close", () => {
|
|
63
|
-
const err = erroutput.join("");
|
|
64
|
-
if (err) reject({ error: err });
|
|
65
|
-
if (linenot3fields) reject({ error: linenot3fields + " lines have other than 3 fields" });
|
|
66
|
-
if (fieldnotnumerical)
|
|
67
|
-
reject({ error: fieldnotnumerical + " lines have non-numerical values in any of the 3 fields" });
|
|
68
|
-
resolve({ items });
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
export {
|
|
73
|
-
api
|
|
74
|
-
};
|
package/routes/hicgenome.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { hicGenomePayload } from "#types/checkers";
|
|
2
|
-
import { fileurl } from "#src/utils.js";
|
|
3
|
-
import { spawn } from "child_process";
|
|
4
|
-
import readline from "readline";
|
|
5
|
-
import serverconfig from "#src/serverconfig.js";
|
|
6
|
-
const api = {
|
|
7
|
-
endpoint: "hicgenome",
|
|
8
|
-
methods: {
|
|
9
|
-
get: {
|
|
10
|
-
...hicGenomePayload,
|
|
11
|
-
init
|
|
12
|
-
},
|
|
13
|
-
post: {
|
|
14
|
-
...hicGenomePayload,
|
|
15
|
-
init
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
function init() {
|
|
20
|
-
return async (req, res) => {
|
|
21
|
-
const query = req.query;
|
|
22
|
-
const data = [];
|
|
23
|
-
const erroutput = [];
|
|
24
|
-
const [e, file] = fileurl({ query });
|
|
25
|
-
if (e) res.send({ error: "illegal file name" });
|
|
26
|
-
const matrixType = req.query.matrixType == "log(oe)" ? "oe" : req.query.matrixType ? req.query.matrixType : "observed";
|
|
27
|
-
const promises = req.query.chrlst.map((lead, i) => {
|
|
28
|
-
return req.query.chrlst.slice(0, i + 1).map((follow, j) => {
|
|
29
|
-
if (j <= i) {
|
|
30
|
-
return new Promise((resolve, reject) => {
|
|
31
|
-
const pos1 = req.query.nochr ? lead.replace("chr", "") : lead;
|
|
32
|
-
const pos2 = req.query.nochr ? follow.replace("chr", "") : follow;
|
|
33
|
-
const par = [matrixType, req.query.nmeth || "NONE", file, pos1, pos2, "BP", req.query.resolution];
|
|
34
|
-
const ps = spawn(serverconfig.hicstraw, par);
|
|
35
|
-
const rl = readline.createInterface({ input: ps.stdout });
|
|
36
|
-
const items = [];
|
|
37
|
-
let linenot3fields = 0;
|
|
38
|
-
let fieldnotnumerical = 0;
|
|
39
|
-
rl.on("line", (line) => {
|
|
40
|
-
const l = line.split(" ");
|
|
41
|
-
if (l.length != 3) {
|
|
42
|
-
linenot3fields++;
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const n1 = Number.parseInt(l[0]);
|
|
46
|
-
const n2 = Number.parseInt(l[1]);
|
|
47
|
-
const v = req.query.matrixType == "log(oe)" ? Math.log(Number.parseFloat(l[2])) : Number.parseFloat(l[2]);
|
|
48
|
-
if (Number.isNaN(n1) || Number.isNaN(n2) || Number.isNaN(v)) {
|
|
49
|
-
fieldnotnumerical++;
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
items.push([n1, n2, v]);
|
|
53
|
-
});
|
|
54
|
-
data.push({ items, lead, follow });
|
|
55
|
-
ps.stderr.on("data", (i2) => erroutput.push(`${lead} - ${follow}: `, i2));
|
|
56
|
-
ps.on("close", () => {
|
|
57
|
-
if (erroutput.length) reject({ error: erroutput.join("") });
|
|
58
|
-
if (linenot3fields) reject({ error: `${linenot3fields} lines have other than 3 fields` });
|
|
59
|
-
if (fieldnotnumerical)
|
|
60
|
-
reject(`${fieldnotnumerical} lines have non-numerical values in any of the 3 fields`);
|
|
61
|
-
resolve();
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}).flat();
|
|
67
|
-
Promise.allSettled(promises).then(() => res.send({ data, error: erroutput.join("") })).catch((e2) => {
|
|
68
|
-
res.send({ error: e2?.message || e2 });
|
|
69
|
-
if (e2 instanceof Error && e2.stack) console.log(e2);
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
export {
|
|
74
|
-
api
|
|
75
|
-
};
|