Skip to content

Commit

Permalink
chore: work on fixing server img + prod deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Jan 11, 2024
1 parent a6c4c36 commit 0c0bf2b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
7 changes: 7 additions & 0 deletions epivar-prod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ Genes and gene-peak pairs:
docker compose exec -iT epivar-node-1-server node ./scripts/import-genes.mjs < /opt/epivar/input-files/flu-infection-gene-peaks.csv
docker compose exec -iT epivar-node-2-server node ./scripts/import-genes.mjs < TODO
```

Peaks:

```bash
docker compose exec epivar-node-1-server node ./scripts/import-peaks.js
docker compose exec epivar-node-2-server node ./scripts/import-peaks.js
```
5 changes: 2 additions & 3 deletions epivar-prod/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
# Node 1: hg19 data --------------------------------------------------------------------------------------------------

epivar-node-1-server:
user: $EPIVAR_UID:$EPIVAR_UID
# user: $EPIVAR_UID:$EPIVAR_UID
image: ghcr.io/c3g/epivar-server:pr-13
networks:
- epivar-node-1-server-net
Expand Down Expand Up @@ -82,7 +82,7 @@ services:
# Node 2: hg38 data (lifted over) ------------------------------------------------------------------------------------

# epivar-node-2-server:
# user: $USER:$USER
# # user: $USER:$USER
# image: ghcr.io/c3g/epivar-server:latest
# networks:
# - epivar-node-2-server-net
Expand Down Expand Up @@ -143,7 +143,6 @@ services:
networks:
epivar-node-1-server-net:
driver: bridge
internal: true
epivar-node-1-redis-net:
driver: bridge
internal: true
Expand Down
14 changes: 13 additions & 1 deletion models/genes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
* genes.js
*/

export const normalizeGeneName = name => name.replace(/[^a-zA-Z\d]/g, '-');
const GENE_RENAMES = {
CCDC132: "VPS50",
CCDC109B: "MCUB",
FAM214B: "ATOSB",
BZRAP1: "TSPOAP1",
C19orf60: "REX1BD",
};

export const normalizeGeneName = name => {
const nameNorm = name.replace(/[^a-zA-Z\d]/g, '-');
if (nameNorm in GENE_RENAMES) return GENE_RENAMES[nameNorm];
return nameNorm;
}

export default {
normalizeGeneName,
Expand Down
14 changes: 8 additions & 6 deletions scripts/import-peaks.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ console.log("Loading peaks");
// --------------------------------------------------------------------------

(async () => {
const {ASSAYS, loadingPrecomputedPoints, precomputedPoints} = await import('./_common.mjs');
const {loadingPrecomputedPoints, precomputedPoints} = await import('./_common.mjs');

const db = await import("../models/db.mjs");
const Gene = await import('../models/genes.mjs');

const datasetPaths = ASSAYS.map(assay => envConfig.QTLS_TEMPLATE.replace(/\$ASSAY/g, assay));
const client = await db.connect();

const assays = Object.fromEntries(
(await client.query("SELECT * FROM assays")).rows.map(r => [r.name, r]));

const datasetPaths = Object.keys(assays).map(assay => envConfig.QTLS_TEMPLATE.replace(/\$ASSAY/g, assay));
console.log(`Found paths:`, datasetPaths);

// Clear relevant tables of existing data
await db.run("TRUNCATE TABLE snps RESTART IDENTITY CASCADE");
Expand All @@ -26,11 +32,7 @@ console.log("Loading peaks");
const featureCache = Object.fromEntries(
(await db.findAll("SELECT * FROM features")).map(row => [row.nat_id, row.id]));

const client = await db.connect();
try {
const assays = Object.fromEntries(
(await client.query("SELECT * FROM assays")).rows.map(r => [r.name, r]));

// Preload all gene features
process.stdout.write("Preloading gene features...");
const geneCache = Object.fromEntries(
Expand Down
5 changes: 1 addition & 4 deletions spec/run_server.bash
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash

export HOME=/app

npm install -g pm2
pipx ensurepath
source $HOME/.profile
source /root/.profile
pm2-runtime /app/bin/www --name epivar -i 0
5 changes: 5 additions & 0 deletions spec/server.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ COPY spec/run_server.bash /

RUN mkdir -p /tracks; \
mkdir -p /mergedTracks

HOME=/app
WORKDIR /app

# Copy source code + file directories
Expand All @@ -42,6 +44,9 @@ RUN wget https://hgdownload.soe.ucsc.edu/admin/exe/linux.x86_64/bigWigSummary -O
# Uninstall compilation dependencies + wget since we don't need them anymore
RUN apt-get purge -y build-essential python3-dev wget

# Install PM2 to manage multiple processes
RUN npm install -g pm2

# Install Node dependencies
RUN npm ci

Expand Down

0 comments on commit 0c0bf2b

Please sign in to comment.