Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bacpop 186 v9 db #84

Merged
merged 31 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5f30d32
fix: update content property in CytoscapeCanvas.vue for correct data …
absternator Nov 19, 2024
3a9c6ed
fix: update API_BRANCH to bacpop-202-fallback-to-refs in common script
absternator Nov 21, 2024
217dd8b
{commit_message}
absternator Dec 16, 2024
9337a8d
Merge branch 'main' of https://github.com/bacpop/beebop into bacpop-1…
absternator Dec 16, 2024
39281d3
fix: update node selectors and styles in CytoscapeCanvas; add info me…
absternator Dec 19, 2024
f047471
fix: swap info messages in NetworkTab for clarity on graph viewing op…
absternator Dec 19, 2024
3791a81
fix: adjust content formatting in CytoscapeCanvas and improve info me…
absternator Dec 19, 2024
0e844d4
fix: increase test timeout in jest configuration from 120s to 240s
absternator Dec 19, 2024
5c889f5
fix: increase Playwright test timeout from 120s to 180s
absternator Dec 19, 2024
6084605
fix: remove --refs option from database download script to download a…
absternator Dec 19, 2024
4a8cff6
Revert "fix: remove --refs option from database download script to do…
absternator Dec 20, 2024
a15a1e5
fix: decrease Playwright test timeout from 180s to 120s
absternator Jan 6, 2025
6fddd66
fix: decrease test timeout in jest configuration from 240s to 120s
absternator Jan 7, 2025
2d70de3
fix: update node data attributes in CytoscapeCanvas component
absternator Jan 10, 2025
188680b
fix: increase test timeouts in Playwright and Jest configurations
absternator Jan 10, 2025
7a032bb
{commit_message}
absternator Jan 10, 2025
e39b05f
{commit_message}
absternator Jan 14, 2025
d5afdc8
update docs for dev setup
absternator Jan 14, 2025
1d37e56
fix: update GitHub Actions to use Ubuntu 22.04 for Playwright CI
absternator Jan 14, 2025
80d1bad
fix: update GitHub Actions to use Ubuntu 22.04 for Playwright CI
absternator Jan 14, 2025
28ce92e
update playwright
absternator Jan 14, 2025
4c0d559
chore: reduce timeout values in Playwright and Jest configurations
absternator Jan 15, 2025
4e8aa56
{commit_message}
absternator Jan 15, 2025
7274f6b
fix: update API_IMAGE for database support
absternator Jan 15, 2025
9e3dada
feat: get working & cleaned up version
absternator Jan 16, 2025
df9fc93
fix: update API_IMAGE for development environment
absternator Jan 16, 2025
5090d19
Merge branch 'bacpop-186-v9-db' of https://github.com/bacpop/beebop i…
absternator Jan 16, 2025
858cc09
unit + integration tests
absternator Jan 16, 2025
3044dce
fix: remove debug log from handleWorkerResponse
absternator Jan 16, 2025
ad01292
Merge pull request #87 from bacpop/bacpop-209-amr-microreact
absternator Jan 21, 2025
f074057
fix: update API_IMAGE to use main for consistency
absternator Jan 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 10 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,10 @@
# beebop

## Docker Quick Start

Run the dockerised app along with proxy and all dependencies:

```
./scripts/run_docker_decrypt
```

You may need to update your version of Docker and Docker Compose: see [here](https://docs.docker.com/engine/install/ubuntu/) for instructions on updating on Ubuntu.

By default this will configure the nginx proxy for host localhost. To deploy with a different hostname, pass it as an argument, e.g.
```
./scripts/run_docker_decrypt beebop.dide.ic.ac.uk
```

This will also populate app config with secrets from the vault. If you are not running the script for the first time,
or not for the first time since running the app outside docker, you can omit this step by running the `run_docker` script.

Bring down the app with
```
./scripts/stop_docker
```
# Beebop

Docker images are built on CI using `./proxy/docker/build`, `./app/server/docker/build`. If you want
to generate them from changed local sources you can run those same scripts locally to build images.

To target a branch of `beebop_py`, set `API_IMAGE` in `scripts/common`.

When running locally in docker, the backend is serving from `beebop_beebop-server_1`, and the front end from the proxy
container `beebop_proxy_1`.
To target a branch of `beebop_py`, set `API_IMAGE` in `scripts/common`. If there is a dev image available,
that can be targeting by adding `-dev` to the image name.

## Local development

Expand All @@ -47,7 +22,7 @@ docker --version


If you run the application for the first time (or for the first time after running in docker), you need to replace the
secrets in the config file in `app/server/src/resources` first.
secrets in the config file in `app/server/src/resources` first.
Login to the vault:
```
export VAULT_ADDR=https://vault.dide.ic.ac.uk:8200
Expand All @@ -64,6 +39,12 @@ To start all required components, run:
./scripts/run_test
```

To run dependencies and server only, run:
```
./scripts/run_test server-only
```
*Note: These scripts call `run_dependencies` which downloads ref databases only. To download full databases, remove `--refs` from the `./scripts/download_databases --refs` command in `run_dependencies`*

The website can be viewed at http://localhost:5173/ . You can stop the application with `./scripts/stop_test`.

The `run_test` script uses [pm2](https://github.com/Unitech/pm2) to manage running the client and server applications.
Expand Down
30 changes: 15 additions & 15 deletions app/client-v2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/client-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"devDependencies": {
"@pinia/testing": "^0.1.3",
"@playwright/test": "^1.42.0",
"@playwright/test": "^1.49.1",
"@rushstack/eslint-patch": "^1.3.3",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/user-event": "^14.5.2",
Expand Down
1 change: 0 additions & 1 deletion app/client-v2/src/__tests__/App.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { createTestingPinia } from "@pinia/testing";
import { render, screen } from "@testing-library/vue";
import { defineComponent } from "vue";
import { createRouter, createWebHistory } from "vue-router";
import PrimeVue from "primevue/config";

const mockedThemeValues = {
setInitialTheme: vitest.fn(),
Expand Down
28 changes: 27 additions & 1 deletion app/client-v2/src/__tests__/stores/projectStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,33 @@ describe("projectStore", () => {
[MOCK_PROJECT_SAMPLES[0].hash]: MOCK_PROJECT_SAMPLES[0].sketch,
[MOCK_PROJECT_SAMPLES[1].hash]: MOCK_PROJECT_SAMPLES[1].sketch,
[MOCK_PROJECT_SAMPLES[2].hash]: MOCK_PROJECT_SAMPLES[2].sketch
}
},
amrForMetadataCsv: [
{
"Chloramphenicol Resistance": "Probably",
"Cotrim Resistance": "Probably not",
"Erythromycin Resistance": "Probably not",
ID: "sample1-test-hash",
"Penicillin Resistance": "Unlikely",
"Tetracycline Resistance": "Highly unlikely"
},
{
"Chloramphenicol Resistance": "Probably",
"Cotrim Resistance": "Almost certainly",
"Erythromycin Resistance": "Almost certainly",
ID: "sample2-test-hash",
"Penicillin Resistance": "Highly unlikely",
"Tetracycline Resistance": "Highly unlikely"
},
{
"Chloramphenicol Resistance": "Probably",
"Cotrim Resistance": "Unlikely",
"Erythromycin Resistance": "Probably not",
ID: "sample3-test-hash",
"Penicillin Resistance": "Probably",
"Tetracycline Resistance": "Highly unlikely"
}
]
});
});
it("should get download url & download when downloadZip is called", async () => {
Expand Down
10 changes: 5 additions & 5 deletions app/client-v2/src/__tests__/utils/projectCsvUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ describe("projectCsvUtils", () => {
const result = convertAmrForCsv(amr);

expect(result).toEqual({
Penicillin: "word",
Chloramphenicol: "word",
Erythromycin: "word",
Tetracycline: "word",
Cotrim: "word"
"Penicillin Resistance": "word",
"Chloramphenicol Resistance": "word",
"Erythromycin Resistance": "word",
"Tetracycline Resistance": "word",
"Cotrim Resistance": "word"
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions app/client-v2/src/components/ProjectView/CytoscapeCanvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ onMounted(async () => {
style: {
width: "10px",
height: "10px",
content: "data(key0)",
content: "data(d1)",
"font-size": "7px",
color: "#00CC66",
"background-color": "rgba(45, 212, 191, 0.44)"
}
},
{
selector: 'node[ref_query = "query"]',
selector: 'node[d2 = "query"]',
style: {
"background-color": "crimson",
color: "crimson"
Expand Down
4 changes: 4 additions & 0 deletions app/client-v2/src/components/ProjectView/NetworkTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const { data, error, isFetching } = useFetch(`${apiUrl}/networkGraphs/${store.pr
<ProgressSpinner strokeWidth="8" class="w-4rem h-4rem" animationDuration=".5s" />
</div>
<div v-else-if="data?.data">
<InlineMessage severity="info" class="mb-2"
>These graphs are pruned versions of the full graphs. To view full graphs, download the zip file and view the
.graphml externally.</InlineMessage
>
<InlineMessage severity="info" class="mb-2"
>View in fullscreen, reset layout or use mouse, touchpad or touchscreen gestures on graphs to zoom in and out, or
move nodes around.</InlineMessage
Expand Down
13 changes: 12 additions & 1 deletion app/client-v2/src/stores/projectStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getApiUrl } from "@/config";
import {
AnalysisType,
COMPLETE_STATUS_TYPES,
type AMRMetadataCsv,
type AnalysisStatus,
type ApiResponse,
type ClusterInfo,
Expand All @@ -17,6 +18,7 @@ import { defineStore } from "pinia";
import { Md5 } from "ts-md5";
import { useSpeciesStore, type SketchKmerArguments } from "./speciesStore";
import { toRaw } from "vue";
import { convertAmrForCsv } from "@/utils/projectCsvUtils";

const baseApi = mande(getApiUrl(), { credentials: "include" });

Expand Down Expand Up @@ -304,17 +306,26 @@ export const useProjectStore = defineStore("project", {
buildRunAnalysisPostBody() {
const sketches: Record<string, unknown> = {};
const names: Record<string, unknown> = {};
const amrForMetadataCsv: AMRMetadataCsv[] = [];
let projectHashKey = "";
this.project.samples
.sort((a, b) => a.filename.localeCompare(b.filename))
.forEach((sample: ProjectSample) => {
projectHashKey += sample.hash + sample.filename;
sketches[sample.hash] = sample.sketch;
names[sample.hash] = sample.filename;
amrForMetadataCsv.push({ ID: sample.hash, ...convertAmrForCsv(sample.amr!!) });
}, "");
const projectHash = Md5.hashStr(projectHashKey);

return { projectHash, names, sketches, projectId: this.project.id, species: this.project.species };
return {
projectHash,
names,
sketches,
projectId: this.project.id,
species: this.project.species,
amrForMetadataCsv
};
},

async downloadZip(type: AnalysisType, cluster: string) {
Expand Down
11 changes: 11 additions & 0 deletions app/client-v2/src/types/projectTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ export interface AMR {
species: boolean;
}

export interface AMRForCsv {
"Penicillin Resistance": string;
"Chloramphenicol Resistance": string;
"Erythromycin Resistance": string;
"Tetracycline Resistance": string;
"Cotrim Resistance": string;
}

export interface AMRMetadataCsv extends AMRForCsv {
ID: string;
}
export interface ProjectSample {
hash: string;
filename: string;
Expand Down
14 changes: 7 additions & 7 deletions app/client-v2/src/utils/projectCsvUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AMR, ProjectSample } from "@/types/projectTypes";
import type { AMR, AMRForCsv, ProjectSample } from "@/types/projectTypes";
import { convertProbabilityToWord } from "./amrDisplayUtils";

export const downloadCsv = (samples: ProjectSample[], filename: string) => {
Expand All @@ -12,12 +12,12 @@ export const downloadCsv = (samples: ProjectSample[], filename: string) => {
triggerCsvDownload(csvContent, `${filename}.csv`);
};

export const convertAmrForCsv = (amr: AMR) => ({
Penicillin: convertProbabilityToWord(amr.Penicillin, "Penicillin"),
Chloramphenicol: convertProbabilityToWord(amr.Chloramphenicol, "Chloramphenicol"),
Erythromycin: convertProbabilityToWord(amr.Erythromycin, "Erythromycin"),
Tetracycline: convertProbabilityToWord(amr.Tetracycline, "Tetracycline"),
Cotrim: convertProbabilityToWord(amr.Trim_sulfa, "Cotrim")
export const convertAmrForCsv = (amr: AMR): AMRForCsv => ({
"Penicillin Resistance": convertProbabilityToWord(amr.Penicillin, "Penicillin"),
"Chloramphenicol Resistance": convertProbabilityToWord(amr.Chloramphenicol, "Chloramphenicol"),
"Erythromycin Resistance": convertProbabilityToWord(amr.Erythromycin, "Erythromycin"),
"Tetracycline Resistance": convertProbabilityToWord(amr.Tetracycline, "Tetracycline"),
"Cotrim Resistance": convertProbabilityToWord(amr.Trim_sulfa, "Cotrim")
});

export const generateCsvContent = (data: Record<string, string>[]) => {
Expand Down
4 changes: 2 additions & 2 deletions app/server/src/controllers/indexController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export default (config) => {
async runPoppunk(request, response, next) {
await asyncHandler(next, async () => {
const poppunkRequest = request.body as BeebopRunRequest;
const {projectHash, projectId, names, sketches, species } = poppunkRequest;
const { projectHash, projectId, names, sketches, species, amrForMetadataCsv } = poppunkRequest;
const {redis} = request.app.locals;
await userStore(redis).saveHashAndSamplesRun(request, projectId, projectHash, names);
const apiRequest = { names, projectHash, sketches, species } as PoppunkRequest;
const apiRequest = { names, projectHash, sketches, species, amrForMetadataCsv } as PoppunkRequest;
await axios
.post(`${config.api_url}/poppunk`, apiRequest, {
headers: {
Expand Down
12 changes: 12 additions & 0 deletions app/server/src/types/requestTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@ export interface PoppunkRequest {
projectHash: string,
sketches: Record<string, never>
species: string,
amrForMetadataCsv: AMRMetadataCsv[]
}

export interface AMRForCsv {
"Penicillin Resistance": string;
"Chloramphenicol Resistance": string;
"Erythromycin Resistance": string;
"Tetracycline Resistance": string;
"Cotrim Resistance": string;
}

export interface AMRMetadataCsv extends AMRForCsv {
ID: string;
}
export interface BeebopRunRequest extends PoppunkRequest {
projectId: string,
}
Expand Down
10 changes: 10 additions & 0 deletions app/server/tests/integration/testSample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13135,4 +13135,14 @@ export const testSample = (
},
},
names: { fd38a3bc7197390fd3734240a67fb515: "7622_5#78.fa" },
amrForMetadataCsv: [
{
ID: "fd38a3bc7197390fd3734240a67fb515",
"Penicillin Resistance": "Highly unlikely",
"Chloramphenicol Resistance": "Unsure",
"Erythromycin Resistance": "Highly unlikely",
"Tetracycline Resistance": "Almost certainly",
"Cotrim Resistance": "Highly likely",
},
],
});
4 changes: 2 additions & 2 deletions scripts/common
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
export API_IMAGE="main"
export API_IMAGE="main" # TODO revert back to main before merge into main

NETWORK=beebop_nw
VOLUME=beebop-storage
NAME_REDIS=beebop-redis
NAME_API=beebop-py-api
NAME_WORKER=beebop-py-worker
PORT=5000
PORT=5000
Loading