Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into refact/scopeable-m…
Browse files Browse the repository at this point in the history
…odel-base-class

# Conflicts:
#	chord_metadata_service/phenopackets/api_views.py
#	chord_metadata_service/phenopackets/tests/test_api.py
#	chord_metadata_service/restapi/api_renderers.py
#	chord_metadata_service/restapi/tests/test_fhir.py
  • Loading branch information
davidlougheed committed Dec 13, 2024
2 parents e04f552 + 9f12712 commit 91044a7
Show file tree
Hide file tree
Showing 62 changed files with 665 additions and 18,076 deletions.
25 changes: 1 addition & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ CANARIE funded initial development of the Katsu Metadata service under the CHORD
Katsu Metadata Service is a service to store epigenomic metadata.

1. Patients service handles anonymized individual’s data (individual id, sex, age or date of birth)
* Data model: aggregated profile from GA4GH Phenopackets Individual, and FHIR Patient.
* Data model: extended from GA4GH Phenopackets Individual.

2. Phenopackets service handles phenotypic and clinical data
* Data model: [GA4GH Phenopackets schema](https://github.com/phenopackets/phenopacket-schema)
Expand Down Expand Up @@ -81,11 +81,6 @@ To retrieved data in json compliant with phenopackets that uses camelCase append

* Data can be ingested and retrieved in snake_case or camelCase.

* Other available renderers:
Phenopackets model is mapped to [FHIR](https://www.hl7.org/fhir/) using
[Phenopackets on FHIR](https://aehrc.github.io/fhir-phenopackets-ig/) implementation guide.
To retrieve data in fhir append `?format=fhir` .

* Ingest endpoint: `/private/ingest`.


Expand Down Expand Up @@ -378,24 +373,6 @@ Ingested data successfully.
accepted by the Phenopackets workflow or the Experiments workflow, depending
on the data type of the table)

#### Patient Commands

```
$ ./manage.py patients_build_index
...
```

Builds an ElasticSearch index for patients in the database.

#### Phenopacket Commands

```
$ ./manage.py phenopackets_build_index
...
```

Builds an ElasticSearch index for Phenopackets in the database.

### Accessing the Django Shell from inside a Bento Container

#### When running Katsu with `bentoV2`:
Expand Down
4 changes: 0 additions & 4 deletions chord_metadata_service/chord/ingest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from chord_metadata_service.chord.workflows import metadata as wm

from .experiments import ingest_experiments_workflow
from .fhir import ingest_fhir_workflow
from .phenopackets import ingest_phenopacket_workflow
from .readsets import ingest_readset_workflow

from typing import Callable

Expand All @@ -14,6 +12,4 @@
WORKFLOW_INGEST_FUNCTION_MAP: dict[str, Callable] = {
wm.WORKFLOW_EXPERIMENTS_JSON: ingest_experiments_workflow,
wm.WORKFLOW_PHENOPACKETS_JSON: ingest_phenopacket_workflow,
wm.WORKFLOW_FHIR_JSON: ingest_fhir_workflow,
wm.WORKFLOW_READSET: ingest_readset_workflow,
}
46 changes: 0 additions & 46 deletions chord_metadata_service/chord/ingest/fhir.py

This file was deleted.

13 changes: 0 additions & 13 deletions chord_metadata_service/chord/ingest/readsets.py

This file was deleted.

2 changes: 0 additions & 2 deletions chord_metadata_service/chord/tests/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"TEST_SEARCH_QUERY_8",
"TEST_SEARCH_QUERY_9",
"TEST_SEARCH_QUERY_10",
"TEST_FHIR_SEARCH_QUERY",
]

VALID_DATA_USE_1 = {
Expand Down Expand Up @@ -253,4 +252,3 @@ def valid_phenotypic_feature(biosample=None, phenopacket=None):
TEST_SEARCH_QUERY_9 = ["#eq", ["#resolve", "subject", "id"], "patient:1"]
TEST_SEARCH_QUERY_10 = ["#in", ["#resolve", "biosamples", "[item]", "id"],
["#list", "biosample_id:1", "biosample_id:2"]]
TEST_FHIR_SEARCH_QUERY = {"query": {"match": {"gender": "FEMALE"}}}
56 changes: 0 additions & 56 deletions chord_metadata_service/chord/tests/es_mocks.py

This file was deleted.

67 changes: 6 additions & 61 deletions chord_metadata_service/chord/tests/test_api_search.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import json

from unittest.mock import patch

from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase
Expand All @@ -19,7 +17,6 @@
valid_experiment, valid_experiment_result, valid_instrument
)

from chord_metadata_service.chord.tests.es_mocks import SEARCH_SUCCESS
from .constants import (
VALID_PROJECT_1,
valid_dataset_1,
Expand All @@ -34,7 +31,6 @@
TEST_SEARCH_QUERY_8,
TEST_SEARCH_QUERY_9,
TEST_SEARCH_QUERY_10,
TEST_FHIR_SEARCH_QUERY,
)
from ..models import Project, Dataset
from ..data_types import (
Expand Down Expand Up @@ -105,25 +101,25 @@ def _search_call(self, endpoint, args=None, data=None, method="GET"):
def test_common_search_1(self):
# No body
for method in POST_GET:
r = self._search_call("search", method=method)
r = self._search_call("private-search", method=method)
self.assertEqual(r.status_code, status.HTTP_400_BAD_REQUEST)

def test_common_search_2(self):
# No data type
for method in POST_GET:
r = self._search_call("search", data={"query": TEST_SEARCH_QUERY_1}, method=method)
r = self._search_call("private-search", data={"query": TEST_SEARCH_QUERY_1}, method=method)
self.assertEqual(r.status_code, status.HTTP_400_BAD_REQUEST)

def test_common_search_3(self):
# No query
for method in POST_GET:
r = self._search_call("search", data={"data_type": DATA_TYPE_PHENOPACKET}, method=method)
r = self._search_call("private-search", data={"data_type": DATA_TYPE_PHENOPACKET}, method=method)
self.assertEqual(r.status_code, status.HTTP_400_BAD_REQUEST)

def test_common_search_4(self):
# Bad data type
for method in POST_GET:
r = self._search_call("search", data={
r = self._search_call("private-search", data={
"data_type": "bad_data_type",
"query": TEST_SEARCH_QUERY_1,
}, method=method)
Expand All @@ -132,33 +128,16 @@ def test_common_search_4(self):
def test_common_search_5(self):
# Bad syntax for query
for method in POST_GET:
r = self._search_call("search", data={
r = self._search_call("private-search", data={
"data_type": DATA_TYPE_PHENOPACKET,
"query": ["hello", "world"]
}, method=method)
self.assertEqual(r.status_code, status.HTTP_400_BAD_REQUEST)

def test_search_with_result(self):
# Valid search with result
for method in POST_GET:
r = self._search_call("search", data={
"data_type": DATA_TYPE_PHENOPACKET,
"query": TEST_SEARCH_QUERY_1
}, method=method)
self.assertEqual(r.status_code, status.HTTP_200_OK)

c = r.json()

self.assertEqual(len(c["results"]), 1)
self.assertDictEqual(c["results"][0], {
"id": str(self.dataset.identifier),
"data_type": DATA_TYPE_PHENOPACKET
})

def test_search_without_result(self):
# Valid search without result
for method in POST_GET:
r = self._search_call("search", data={
r = self._search_call("private-search", data={
"data_type": DATA_TYPE_PHENOPACKET,
"query": TEST_SEARCH_QUERY_2
}, method=method)
Expand Down Expand Up @@ -499,37 +478,3 @@ def test_private_search_values_list(self):
dataset_id = list(c["results"].keys())[0]
matches = c["results"][dataset_id]["matches"]
self.assertEqual(len(matches), 2) # 2 biosamples in list

@patch('chord_metadata_service.chord.views_search.es')
def test_fhir_search(self, mocked_es):
mocked_es.search.return_value = SEARCH_SUCCESS
# Valid search with result
for method in POST_GET:
r = self._search_call("fhir-search", data={
"query": TEST_FHIR_SEARCH_QUERY
}, method=method)

self.assertEqual(r.status_code, status.HTTP_200_OK)
c = r.json()

self.assertEqual(len(c["results"]), 1)
self.assertDictEqual(c["results"][0], {
"id": str(self.dataset.identifier),
"data_type": DATA_TYPE_PHENOPACKET
})

@patch('chord_metadata_service.chord.views_search.es')
def test_private_fhir_search(self, mocked_es):
mocked_es.search.return_value = SEARCH_SUCCESS
# Valid search with result
for method in POST_GET:
r = self._search_call("fhir-private-search", data={
"query": TEST_FHIR_SEARCH_QUERY
}, method=method)

self.assertEqual(r.status_code, status.HTTP_200_OK)
c = r.json()

self.assertIn(str(self.dataset.identifier), c["results"])
self.assertEqual(c["results"][str(self.dataset.identifier)]["data_type"], DATA_TYPE_PHENOPACKET)
self.assertEqual(self.phenopacket.id, c["results"][str(self.dataset.identifier)]["matches"][0]["id"])
3 changes: 0 additions & 3 deletions chord_metadata_service/chord/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
path('data-types/<str:data_type>/metadata_schema', views_data_types.data_type_metadata_schema,
name="data-type-metadata-schema"),

path('search', views_search.chord_search, name="search"),
path('fhir-search', views_search.fhir_public_search, name="fhir-search"),
path('private/fhir-search', views_search.fhir_private_search, name="fhir-private-search"),
path('private/search', views_search.chord_private_search, name="private-search"),

path('datasets', DatasetViewSet.as_view({'get': 'list'}), name="chord-dataset-list"),
Expand Down
Loading

0 comments on commit 91044a7

Please sign in to comment.