|
a |
|
b/tests/tools/nlp/test_medcat.py |
|
|
1 |
from pathlib import Path |
|
|
2 |
|
|
|
3 |
import pandas as pd |
|
|
4 |
|
|
|
5 |
import ehrapy as ep |
|
|
6 |
from tests.conftest import TEST_DATA_PATH |
|
|
7 |
|
|
|
8 |
CURRENT_DIR = Path(__file__).parent |
|
|
9 |
_TEST_PATH = f"{CURRENT_DIR}/test_data_nlp" |
|
|
10 |
|
|
|
11 |
|
|
|
12 |
class TestMedCAT: |
|
|
13 |
def test_add_medcat_annotation_to_obs(self): |
|
|
14 |
# created manually a small dataset with annotations to use here |
|
|
15 |
adata = ep.io.read_csv(f"{TEST_DATA_PATH}/dataset1.csv") |
|
|
16 |
adata.uns["medcat_annotations"] = pd.read_csv(f"{_TEST_PATH}/medcat_annotations1.csv") |
|
|
17 |
|
|
|
18 |
ep.tl.add_medcat_annotation_to_obs(adata, name="Diabetes") |
|
|
19 |
assert "Diabetes" in adata.obs.columns |