Skip to content

Commit 096d8a5

Browse files
committed
Update HPO test resource.
1 parent 5551bd7 commit 096d8a5

4 files changed

Lines changed: 25 additions & 13 deletions

File tree

phenopacket-tools-validator-core/src/test/java/org/phenopackets/phenopackettools/validator/core/TestData.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,25 @@
33
import org.monarchinitiative.phenol.io.MinimalOntologyLoader;
44
import org.monarchinitiative.phenol.ontology.data.MinimalOntology;
55

6-
import java.nio.file.Path;
6+
import java.io.BufferedInputStream;
7+
import java.io.IOException;
8+
import java.util.Objects;
9+
import java.util.zip.GZIPInputStream;
710

811
public class TestData {
912

10-
public static final Path TEST_BASE_DIR = Path.of("src/test/resources/org/phenopackets/phenopackettools/validator/core");
11-
private static final Path HPO_MODULE_PATH = TEST_BASE_DIR.resolve("hp.module.json");
13+
public static final MinimalOntology HPO;
1214

13-
public static final MinimalOntology HPO = MinimalOntologyLoader.loadOntology(HPO_MODULE_PATH.toFile());
15+
static {
16+
try {
17+
HPO = MinimalOntologyLoader.loadOntology(new GZIPInputStream(
18+
new BufferedInputStream(
19+
Objects.requireNonNull(TestData.class.getResourceAsStream("hp.v2026-01-08.json.gz"))
20+
)
21+
));
22+
} catch (IOException e) {
23+
throw new RuntimeException(e);
24+
}
25+
}
1426

1527
}

phenopacket-tools-validator-core/src/test/java/org/phenopackets/phenopackettools/validator/core/phenotype/AncestryHpoValidatorTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void testValidInput() {
4949
public void testFailsIfTermAndAncestorIsObserved() {
5050
// Has some Abnormality of finger and Arachnodactyly. Only Arachnodactyly should be present.
5151
Phenopacket pp = createPhenopacket(
52-
"example-phenopacket", "example-subject", createPhenotypicFeature("HP:0001167", "Abnormality of finger", false),
52+
"example-phenopacket", "example-subject", createPhenotypicFeature("HP:0001167", "Abnormal finger morphology", false),
5353
createPhenotypicFeature("HP:0001166", "Arachnodactyly", false)
5454
).build();
5555

@@ -60,14 +60,14 @@ public void testFailsIfTermAndAncestorIsObserved() {
6060
assertThat(result.validatorInfo(), equalTo(validator.validatorInfo()));
6161
assertThat(result.level(), equalTo(ValidationLevel.ERROR));
6262
assertThat(result.category(), equalTo("Violation of the annotation propagation rule"));
63-
assertThat(result.message(), equalTo("Phenotypic features of example-phenopacket must not contain both an observed term (Arachnodactyly, HP:0001166) and an observed ancestor (Abnormality of finger, HP:0001167)"));
63+
assertThat(result.message(), equalTo("Phenotypic features of example-phenopacket must not contain both an observed term (Arachnodactyly, HP:0001166) and an observed ancestor (Abnormal finger morphology, HP:0001167)"));
6464
}
6565

6666
@Test
6767
public void testFailsIfTermAndAncestorIsExcluded() {
6868
// Has neither Abnormality of finger nor Arachnodactyly. Only Abnormality of finger should be present.
6969
Phenopacket pp = createPhenopacket(
70-
"example-phenopacket", "example-subject", createPhenotypicFeature("HP:0001167", "Abnormality of finger", true),
70+
"example-phenopacket", "example-subject", createPhenotypicFeature("HP:0001167", "Abnormal finger morphology", true),
7171
createPhenotypicFeature("HP:0001166", "Arachnodactyly", true)
7272
).build();
7373

@@ -77,14 +77,14 @@ public void testFailsIfTermAndAncestorIsExcluded() {
7777
ValidationResult result = results.get(0);
7878
assertThat(result.level(), equalTo(ValidationLevel.ERROR));
7979
assertThat(result.category(), equalTo("Violation of the annotation propagation rule"));
80-
assertThat(result.message(), equalTo("Phenotypic features of example-phenopacket must not contain both an excluded term (Abnormality of finger, HP:0001167) and an excluded child (Arachnodactyly, HP:0001166)"));
80+
assertThat(result.message(), equalTo("Phenotypic features of example-phenopacket must not contain both an excluded term (Abnormal finger morphology, HP:0001167) and an excluded child (Arachnodactyly, HP:0001166)"));
8181
}
8282

8383
@Test
8484
public void testFailsIfTermIsPresentAndAncestorIsExcluded() {
8585
// Has neither Abnormality of finger nor Arachnodactyly. Only Abnormality of finger should be present.
8686
Phenopacket pp = createPhenopacket(
87-
"example-phenopacket", "example-subject", createPhenotypicFeature("HP:0001167", "Abnormality of finger", true),
87+
"example-phenopacket", "example-subject", createPhenotypicFeature("HP:0001167", "Abnormal finger morphology", true),
8888
createPhenotypicFeature("HP:0001166", "Arachnodactyly", false)
8989
).build();
9090

@@ -94,7 +94,7 @@ public void testFailsIfTermIsPresentAndAncestorIsExcluded() {
9494
ValidationResult result = results.get(0);
9595
assertThat(result.level(), equalTo(ValidationLevel.ERROR));
9696
assertThat(result.category(), equalTo("Violation of the annotation propagation rule"));
97-
assertThat(result.message(), equalTo("Phenotypic features of example-phenopacket must not contain both an observed term (Arachnodactyly, HP:0001166) and an excluded ancestor (Abnormality of finger, HP:0001167)"));
97+
assertThat(result.message(), equalTo("Phenotypic features of example-phenopacket must not contain both an observed term (Arachnodactyly, HP:0001166) and an excluded ancestor (Abnormal finger morphology, HP:0001167)"));
9898
}
9999
}
100100

phenopacket-tools-validator-core/src/test/java/org/phenopackets/phenopackettools/validator/core/phenotype/PrimaryHpoPhenotypeValidatorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public void testMissingTermId() throws Exception {
6767
},
6868
"phenotypicFeatures": [{
6969
"type": {
70-
"id": "HP:0001182",
71-
"label": "Tapered finger"
70+
"id": "HP:0000000",
71+
"label": "Nonexistent term"
7272
}
7373
}, {
7474
"type": {
@@ -85,7 +85,7 @@ public void testMissingTermId() throws Exception {
8585
ValidationResult result = results.get(0);
8686
assertThat(result.level(), equalTo(ValidationLevel.ERROR));
8787
assertThat(result.category(), equalTo("Invalid TermId"));
88-
assertThat(result.message(), equalTo("HP:0001182 in proband A not found in 2021-06-08"));
88+
assertThat(result.message(), equalTo("HP:0000000 in proband A not found in 2026-01-08"));
8989
}
9090

9191
@Test

0 commit comments

Comments
 (0)