diff --git a/README.md b/README.md index 3664bde..baf3062 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,33 @@ The Dictionary Project's goal is to create a unified process for enabling the fi of a query. It needs to work across our current projects, and, in anticipation of our push to productize PIC-SURE, it needs to be workable for new PIC-SURE installations. +## Usage + +### Create Env File + +```shell +cp env.example .env +vi .env +``` + +### Start DB + +```shell +docker compose up -d --build dictionary-db +``` + +Once up, do some sanity checks in the database: + +```shell +docker exec -ti dictionary-db psql -U picsure dictionary +``` + +### Start API + +```shell +docker compose up -d --build +``` + ## Solution ### UI diff --git a/docker-compose.yml b/docker-compose.yml index e13adbb..02c0feb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: image: postgres:16-alpine volumes: - picsure-search:/var/lib/postgresql/data - - ./db/schema.sql:/docker-entrypoint-initdb.d/schema.sql:ro + - ./src/test/resources/seed.sql:/docker-entrypoint-initdb.d/schema.sql:ro env_file: .env networks: - dictionary diff --git a/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepositoryTest.java b/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepositoryTest.java index 7ea3b5a..8e1494b 100644 --- a/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepositoryTest.java +++ b/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepositoryTest.java @@ -47,33 +47,16 @@ static void mySQLProperties(DynamicPropertyRegistry registry) { @Test void shouldListAllConcepts() { List actual = subject.getConcepts(new Filter(List.of(), ""), Pageable.unpaged()); - List expected = List.of( - new CategoricalConcept("\\\\\\\\A\\\\\\\\", "a", "A", "invalid.invalid", null, List.of("0", "1"), null, null), - new CategoricalConcept("\\\\\\\\A\\\\\\\\1\\\\\\\\", "1", "1", "invalid.invalid", null, List.of("X", "Z"), null, null), - new CategoricalConcept("\\\\\\\\A\\\\\\\\0\\\\\\\\", "0", "0", "invalid.invalid", null, List.of("X", "Y"), null, null), - new CategoricalConcept("\\\\\\\\A\\\\\\\\0\\\\\\\\X\\\\\\\\", "x", "X", "invalid.invalid", null, List.of("foo", "bar"), null, null), - new CategoricalConcept("\\\\\\\\A\\\\\\\\0\\\\\\\\Y\\\\\\\\", "y", "Y", "invalid.invalid", null, List.of("foo", "bar", "baz"), null, null), - new ContinuousConcept("\\\\\\\\A\\\\\\\\1\\\\\\\\X\\\\\\\\", "x", "X", "invalid.invalid", null, 0, 0, null), - new ContinuousConcept("\\\\\\\\A\\\\\\\\1\\\\\\\\Z\\\\\\\\", "z", "Z", "invalid.invalid", null, 0, 0, null), - new CategoricalConcept("\\\\\\\\B\\\\\\\\", "b", "B", "invalid.invalid", null, List.of("0", "2"), null, null), - new CategoricalConcept("\\\\\\\\B\\\\\\\\0\\\\\\\\", "0", "0", "invalid.invalid", null, List.of("X", "Y", "Z"), null, null), - new CategoricalConcept("\\\\\\\\B\\\\\\\\2\\\\\\\\", "2", "2", "invalid.invalid", null, List.of("Y", "Z"), null, null), - new CategoricalConcept("\\\\\\\\B\\\\\\\\0\\\\\\\\X\\\\\\\\", "x", "X", "invalid.invalid", null, List.of("bar", "baz"), null, null), - new CategoricalConcept("\\\\\\\\B\\\\\\\\0\\\\\\\\Y\\\\\\\\", "y", "Y", "invalid.invalid", null, List.of("bar", "baz", "qux"), null, null), - new CategoricalConcept("\\\\\\\\B\\\\\\\\0\\\\\\\\Z\\\\\\\\", "z", "Z", "invalid.invalid", null, List.of("foo", "bar", "baz", "qux"), null, null), - new ContinuousConcept("\\\\\\\\B\\\\\\\\2\\\\\\\\Y\\\\\\\\", "y", "Y", "invalid.invalid", null, 0, 0, null), - new ContinuousConcept("\\\\\\\\B\\\\\\\\2\\\\\\\\Z\\\\\\\\", "z", "Z", "invalid.invalid", null, 0, 0, null) - ); - Assertions.assertEquals(expected, actual); + Assertions.assertEquals(29, actual.size()); } @Test void shouldListFirstTwoConcepts() { List actual = subject.getConcepts(new Filter(List.of(), ""), Pageable.ofSize(2).first()); List expected = List.of( - new CategoricalConcept("\\\\\\\\A\\\\\\\\", "a", "A", "invalid.invalid", null, List.of("0", "1"), null, null), - new CategoricalConcept("\\\\\\\\A\\\\\\\\1\\\\\\\\", "1", "1", "invalid.invalid", null, List.of("X", "Z"), null, null) + new ContinuousConcept("\\phs000007\\pht000021\\phv00003844\\FL200\\", "phv00003844", "FL200", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", 0, 3, null), + new CategoricalConcept("\\Variant Data Type\\Low coverage WGS\\", "Low coverage WGS", "Low coverage WGS", "1", "Low coverage WGS", List.of("TRUE"), null, null) ); Assertions.assertEquals(expected, actual); @@ -83,8 +66,8 @@ void shouldListFirstTwoConcepts() { void shouldListNextTwoConcepts() { List actual = subject.getConcepts(new Filter(List.of(), ""), Pageable.ofSize(2).first().next()); List expected = List.of( - new CategoricalConcept("\\\\\\\\A\\\\\\\\0\\\\\\\\", "0", "0", "invalid.invalid", null, List.of("X", "Y"), null, null), - new CategoricalConcept("\\\\\\\\A\\\\\\\\0\\\\\\\\X\\\\\\\\", "x", "X", "invalid.invalid", null, List.of("foo", "bar"), null, null) + new CategoricalConcept("\\phs002385\\RACEG\\", "RACEG", "RACEG", "phs002385", "Race (regrouped)", List.of("Not Reported"), null, null), + new CategoricalConcept("\\Variant Data Type\\Low coverage WGS\\", "Low coverage WGS", "Low coverage WGS", "1", "Low coverage WGS", List.of("TRUE"), null, null) ); Assertions.assertEquals(expected, actual); @@ -109,11 +92,11 @@ void shouldFilterConceptsByFacet() { @Test void shouldFilterBySearch() { - List actual = subject.getConcepts(new Filter(List.of(), "X"), Pageable.unpaged()); + List actual = subject.getConcepts(new Filter(List.of(), "COLA"), Pageable.unpaged()); List expected = List.of( - new CategoricalConcept("\\\\\\\\A\\\\\\\\0\\\\\\\\X\\\\\\\\", "x", "X", "invalid.invalid", null, List.of("foo", "bar"), null, null), - new ContinuousConcept("\\\\\\\\A\\\\\\\\1\\\\\\\\X\\\\\\\\", "x", "X", "invalid.invalid", null, 0, 0, null), - new CategoricalConcept("\\\\\\\\B\\\\\\\\0\\\\\\\\X\\\\\\\\", "x", "X", "invalid.invalid", null, List.of("bar", "baz"), null, null) + new ContinuousConcept("\\phs000007\\pht000022\\phv00004260\\FM219\\", "phv00004260", "FM219", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", 0, 1, null), + new ContinuousConcept("\\phs000007\\pht000021\\phv00003844\\FL200\\", "phv00003844", "FL200", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", 0, 3, null), + new ContinuousConcept("\\phs000007\\pht000033\\phv00008849\\D080\\", "phv00008849", "D080", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA/DAY", 0, 5, null) ); Assertions.assertEquals(expected, actual); @@ -122,10 +105,10 @@ void shouldFilterBySearch() { @Test void shouldFilterByBothSearchAndFacet() { List actual = - subject.getConcepts(new Filter(List.of(new Facet("bch", "", "", 1, null, "site", null)), "X"), Pageable.unpaged()); + subject.getConcepts(new Filter(List.of(new Facet("phs002715", "", "", 1, null, "study_ids_dataset_ids", null)), "phs002715"), Pageable.unpaged()); List expected = List.of( - new CategoricalConcept("\\\\\\\\A\\\\\\\\0\\\\\\\\X\\\\\\\\", "x", "X", "invalid.invalid", null, List.of("foo", "bar"), null, null), - new ContinuousConcept("\\\\\\\\A\\\\\\\\1\\\\\\\\X\\\\\\\\", "x", "X", "invalid.invalid", null, 0, 0, null) + new CategoricalConcept("\\phs002715\\age\\", "AGE_CATEGORY", "age", "phs002715", "Participant's age (category)", List.of("21"), null, null), + new CategoricalConcept("\\phs002715\\nsrr_ever_smoker\\", "nsrr_ever_smoker", "nsrr_ever_smoker", "phs002715", "Smoker status", List.of("yes"), null, null) ); Assertions.assertEquals(expected, actual); @@ -135,12 +118,12 @@ void shouldFilterByBothSearchAndFacet() { void shouldGetCount() { long actual = subject.countConcepts(new Filter(List.of(), "")); - Assertions.assertEquals(15L, actual); + Assertions.assertEquals(29L, actual); } @Test void shouldGetCountWithFilter() { - Long actual = subject.countConcepts(new Filter(List.of(new Facet("bch", "", "", 1, null, "site", null)), "X")); + Long actual = subject.countConcepts(new Filter(List.of(new Facet("phs002715", "", "", 1, null, "study_ids_dataset_ids", null)), "")); Assertions.assertEquals(2L, actual); } @@ -148,15 +131,15 @@ void shouldGetCountWithFilter() { void shouldGetDetailForConcept() { ContinuousConcept expected = new ContinuousConcept("\\\\\\\\B\\\\\\\\2\\\\\\\\Z\\\\\\\\", "z", "Z", "invalid.invalid", null, 0, 0, null); - Optional actual = subject.getConcept(expected.dataset(), expected.conceptPath()); + Optional actual = subject.getConcept("AGE_CATEGORY", "\\phs002715\\age\\"); Assertions.assertEquals(Optional.of(expected), actual); } @Test void shouldGetMetaForConcept() { - Map actual = subject.getConceptMeta("invalid.invalid", "\\\\\\\\B\\\\\\\\2\\\\\\\\Z\\\\\\\\"); - Map expected = Map.of("MIN", "0", "MAX", "0"); + Map actual = subject.getConceptMeta("AGE_CATEGORY", "\\phs002715\\age\\"); + Map expected = Map.of(); Assertions.assertEquals(expected, actual); }