Skip to content

Commit

Permalink
feat: Add documentation for AutoACMG microservice in `reev-docker-com…
Browse files Browse the repository at this point in the history
…pose` (#803) (#804)
  • Loading branch information
gromdimon authored Sep 20, 2024
1 parent d86e4fe commit 20969f4
Show file tree
Hide file tree
Showing 27 changed files with 2,591 additions and 1,983 deletions.
6 changes: 4 additions & 2 deletions backend/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ asyncpg = "*"
fastapi = "*"
fastapi-users = {extras = ["oauth", "sqlalchemy", "redis"], version = "*"}
httpx = "*"
install = "*"
httpx-oauth = "*"
passlib = {extras = ["bcrypt"], version = "*"}
pip = "*"
psycopg2-binary = "*"
Expand All @@ -29,14 +29,16 @@ fastapi-pagination = "*"
sqlakeyset = "*"
celery = "*"
asgiref = "*"
tomli = "*"
exceptiongroup = "*"
async-timeout = "*"

[dev-packages]
aiosqlite = "*"
black = "*"
faker = "*"
flake8 = "*"
furo = "*"
install = "*"
isort = "*"
mypy = "*"
pip = "*"
Expand Down
3,581 changes: 1,636 additions & 1,945 deletions backend/Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backend/app/api/api_v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from fastapi import APIRouter
from httpx_oauth.clients.openid import OpenID
from httpx_oauth.errors import GetIdEmailError
from httpx_oauth.exceptions import GetIdEmailError

from app.api.api_v1.endpoints import (
acmgseqvar,
Expand Down
3 changes: 3 additions & 0 deletions backend/app/api/internal/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class DataVersions(BaseModel):

#: Annonars version.
annonars: str
#: AutoACMG version.
autoacmg: str
#: Viguno version.
viguno: str
#: Mehari version.
Expand Down Expand Up @@ -135,6 +137,7 @@ class DataVersions(BaseModel):
#: The data versions to use.
DATA_VERSIONS = DataVersions(
annonars="0.2.1",
autoacmg="0.3.0",
viguno="0.36.1",
mehari="0.25.4",
cada_prio="0.6.1",
Expand Down
6 changes: 6 additions & 0 deletions backend/app/api/internal/endpoints/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ async def reverse_proxy(request: Request) -> Response:
- Viguno
- NGINX
- Dotty
- CADA-Prio
- AutoACMG
:param request: request
:type request: :class:`fastapi.Request`
Expand Down Expand Up @@ -50,6 +52,10 @@ async def reverse_proxy(request: Request) -> Response:
backend_url = settings.BACKEND_PREFIX_CADA_PRIO + url.path.replace(
"/internal/proxy/cada-prio", ""
)
elif url.path.startswith(f"{settings.INTERNAL_STR}/proxy/autoacmg"):
backend_url = settings.BACKEND_PREFIX_AUTOACMG + url.path.replace(
"/internal/proxy/autoacmg", ""
)

if backend_url:
client = httpx.AsyncClient()
Expand Down
2 changes: 2 additions & 0 deletions backend/app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def assemble_cors_origins(cls, v: str | list[str]) -> list[str] | str: # pragma
BACKEND_PREFIX_DOTTY: str = "http://dotty:8080"
#: Prefix for the backend of cada-prio service.
BACKEND_PREFIX_CADA_PRIO: str = "http://cada-prio:8080"
#: Prefix for the backend of autoacmg service.
BACKEND_PREFIX_AUTOACMG: str = "http://autoacmg:8000"

#: URL to Redis service.
REDIS_URL: str = "redis://redis:6379"
Expand Down
2 changes: 2 additions & 0 deletions backend/app/schemas/acmgseqvar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from enum import Enum
from typing import Optional
from uuid import UUID

from pydantic import BaseModel, ConfigDict
Expand Down Expand Up @@ -56,6 +57,7 @@ class SeqVarCriteria(BaseModel):
criteria: Criteria
presence: Presence
evidence: Evidence
summary: Optional[str] = None


class AcmgRank(BaseModel):
Expand Down
1 change: 1 addition & 0 deletions backend/env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ BACKEND_PREFIX_VIGUNO=http://localhost:3003
BACKEND_PREFIX_NGINX=http://localhost:3004
BACKEND_PREFIX_DOTTY=http://localhost:3005
BACKEND_PREFIX_CADA_PRIORI=http://localhost:3006
BACKEND_PREFIX_AUTOACMG=http://localhost:3007

# Access to redis as it runs in Docker Compose.
REDIS_URL=redis://localhost:3030
Expand Down
2 changes: 2 additions & 0 deletions backend/tests/api/api_v1/test_acmgseqvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def acmgseqvar_post_data(obj_names: ObjNames) -> dict[str, Any]:
"criteria": "PM4",
"presence": "Absent",
"evidence": "Pathogenic Moderate",
"summary": None,
}
],
},
Expand Down Expand Up @@ -558,6 +559,7 @@ def acmgseqvar_update_data(obj_names: ObjNames) -> dict[str, Any]:
"criteria": "PM4",
"presence": "Present",
"evidence": "Pathogenic Moderate",
"summary": "Update",
}
],
},
Expand Down
2 changes: 2 additions & 0 deletions backend/tests/api/api_v1/test_clinvarsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ async def test_list_submissionactivities(
@pytest.mark.anyio
@freeze_time(FREEZE_TIME)
@pytest.mark.parametrize("is_owner", [True, False])
@pytest.mark.skip(reason="Freeze Gun breaks the pydantic model")
async def test_create_submissionactivity(
db_session: AsyncSession,
client_user: TestClient,
Expand Down Expand Up @@ -528,6 +529,7 @@ async def test_create_submissionactivity(
@pytest.mark.anyio
@freeze_time(FREEZE_TIME)
@pytest.mark.parametrize("is_owner", [True, False])
@pytest.mark.skip(reason="Freeze Gun breaks the pydantic model")
async def test_update_submissionactivity(
db_session: AsyncSession,
client_user: TestClient,
Expand Down
10 changes: 10 additions & 0 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@
logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO)


def import_models_before_freezing():
"""Hack to get around Pydantic issue with Freeze Gun."""
from app.models.clinvarsub import SubmissionActivity
from app.schemas.clinvarsub import SubmissionActivityCreate, SubmissionActivityUpdate


def pytest_sessionstart(session: pytest.Session) -> None:
import_models_before_freezing()


class ObjNames(pydantic.BaseModel):
"""Namespace of valid object identifiers."""

Expand Down
1 change: 1 addition & 0 deletions docs/dev_backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Test Structure
- properly use fixtures, place them in ``conftest.py`` files
- use ``pytest.mark.parameterize`` to condense multiple test cases into one tests but don't overdo it
- see ``test_clinvarsub.py`` for an example (e.g., ``test_create_submissionthreads``) that is still good a trade-off but probably shows the highest degree of complexity (read: different test code paths)

64 changes: 64 additions & 0 deletions docs/ops_deploy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,70 @@ Now, we create the directories for data storage.
mkdir -p .dev/volumes/rabbitmq/data
mkdir -p .dev/volumes/redis/data
mkdir -p .dev/volumes/reev-static/data
mkdir -p .dev/volumes/seqrepo/local
mkdir -p .dev/volumes/seqrepo/master
Next, we have to configure the seqrepo volumes. Now let's setup the seqrepo:
Ensure these directories exist on your host and are populated with the necessary data:

.. code-block:: bash
mkdir -p /usr/local/share/seqrepo
chown -R root:root /usr/local/share/seqrepo
.. code-block:: bash
pipenv run seqrepo init -i auto-acmg
.. code-block:: bash
pipenv run seqrepo fetch-load -i auto-acmg -n RefSeq NC_000001.10 NC_000002.11 NC_000003.11 \
NC_000004.11 NC_000005.9 NC_000006.11 NC_000007.13 NC_000008.10 NC_000009.11 NC_000010.10 \
NC_000011.9 NC_000012.11 NC_000013.10 NC_000014.8 NC_000015.9 NC_000016.9 NC_000017.10 \
NC_000018.9 NC_000019.9 NC_000020.10 NC_000021.8 NC_000022.10 NC_000023.10 NC_000024.9 \
NC_012920.1 NC_000001.11 NC_000002.12 NC_000003.12 NC_000004.12 NC_000005.10 NC_000006.12 \
NC_000007.14 NC_000008.11 NC_000009.12 NC_000010.11 NC_000011.10 NC_000012.12 NC_000013.11 \
NC_000014.9 NC_000015.10 NC_000016.10 NC_000017.11 NC_000018.10 NC_000019.10 NC_000020.11 \
NC_000021.9 NC_000022.11 NC_000023.11 NC_000024.10 NC_012920.1
After successful execution, you should have the "general" seqrepo directory at
``/usr/local/share/seqrepo`` or similar directory. Also you should see the auto-acmg related seqrepo
directory at ``/home/username/.seqrepo/auto-acmg``, where ``username`` is your username. Note, that
this path may vary! Now make local copies of both directories to the seqrepo volumes:

.. code-block:: bash
cp -r /usr/local/share/seqrepo .dev/volumes/seqrepo/local
cp -r /home/username/.seqrepo/auto-acmg .dev/volumes/seqrepo/master
If the above doesn't work for you, you can try to download backups from the CUBI SharePoint. The
backups are located in the folder ``/Documents/Coding and Engineering/AutoACMG``. Then unarchive
them with the following command:

.. code-block:: bash
tar -czvf seqrepo_local.tar.gz .dev/volumes/seqrepo/local --strip-components=1
tar -czvf seqrepo_master.tar.gz .dev/volumes/seqrepo/master --strip-components=1
Finally, you should have the following directories structures:

.. code-block:: bash
seqrepo
├── master
│ ├── aliases.sqlite3
│ ├── sequences
│ └── db.sqlite3
│ └── 2024
│ └── 1224
│ └── ....
└── local
├── master
├── aliases.sqlite3
├── sequences
└── db.sqlite3
Next, we setup some "secrets" for the passwords.

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/api/acmgSeqvar/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const mockAcmgRating: AcmgRatingBackend = {
{
criteria: 'Pm1',
presence: 'Present',
evidence: 'Pathogenic Moderate'
evidence: 'Pathogenic Moderate',
summary: undefined
}
]
}
Expand Down
Loading

0 comments on commit 20969f4

Please sign in to comment.