Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import org.monarchinitiative.phenol.io.MinimalOntologyLoader;
import org.monarchinitiative.phenol.ontology.data.MinimalOntology;

import java.nio.file.Path;
import java.io.File;
import java.net.URL;
import java.util.Objects;

public class TestData {

public static final Path TEST_BASE_DIR = Path.of("src/test/resources/org/phenopackets/phenopackettools/validator/core");
private static final Path HPO_MODULE_PATH = TEST_BASE_DIR.resolve("hp.module.json");
public class TestData {

public static final MinimalOntology HPO = MinimalOntologyLoader.loadOntology(HPO_MODULE_PATH.toFile());
private static final URL HP_MODULE_URL = TestData.class.getResource("hp.module.json");
public static final MinimalOntology HPO = MinimalOntologyLoader.loadOntology(new File(Objects.requireNonNull(HP_MODULE_URL.getPath())));

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void testValidInput() {
// Has some Abnormality of finger but no Arachnodactyly.
Phenopacket pp = createPhenopacket(
"example-phenopacket", "example-subject",
createPhenotypicFeature("HP:0001167", "Abnormality of finger", false),
createPhenotypicFeature("HP:0001167", "Abnormal finger morphology", false),
createPhenotypicFeature("HP:0001166", "Arachnodactyly", true)
).build();

Expand All @@ -49,7 +49,7 @@ public void testValidInput() {
public void testFailsIfTermAndAncestorIsObserved() {
// Has some Abnormality of finger and Arachnodactyly. Only Arachnodactyly should be present.
Phenopacket pp = createPhenopacket(
"example-phenopacket", "example-subject", createPhenotypicFeature("HP:0001167", "Abnormality of finger", false),
"example-phenopacket", "example-subject", createPhenotypicFeature("HP:0001167", "Abnormal finger morphology", false),
createPhenotypicFeature("HP:0001166", "Arachnodactyly", false)
).build();

Expand All @@ -60,14 +60,14 @@ public void testFailsIfTermAndAncestorIsObserved() {
assertThat(result.validatorInfo(), equalTo(validator.validatorInfo()));
assertThat(result.level(), equalTo(ValidationLevel.ERROR));
assertThat(result.category(), equalTo("Violation of the annotation propagation rule"));
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)"));
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)"));
}

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

Expand All @@ -77,14 +77,14 @@ public void testFailsIfTermAndAncestorIsExcluded() {
ValidationResult result = results.get(0);
assertThat(result.level(), equalTo(ValidationLevel.ERROR));
assertThat(result.category(), equalTo("Violation of the annotation propagation rule"));
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)"));
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)"));
}

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

Expand All @@ -94,7 +94,7 @@ public void testFailsIfTermIsPresentAndAncestorIsExcluded() {
ValidationResult result = results.get(0);
assertThat(result.level(), equalTo(ValidationLevel.ERROR));
assertThat(result.category(), equalTo("Violation of the annotation propagation rule"));
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)"));
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)"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void testMissingTermId() throws Exception {
ValidationResult result = results.get(0);
assertThat(result.level(), equalTo(ValidationLevel.ERROR));
assertThat(result.category(), equalTo("Invalid TermId"));
assertThat(result.message(), equalTo("HP:0001182 in proband A not found in 2021-06-08"));
assertThat(result.message(), equalTo("HP:0001182 in proband A not found in 2026-06-06"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,71 @@ The folder contains test resources.

## HPO
The `hp.module.json` contains Human Phenotype Ontology module in Obographs format. For the *Phenotypic abnormality*
subhierarchy, the module contains *Arachnodactyly* (`HP:0001166`) and the ancestors. The module contains all other HPO
subhierarchies.
subhierarchy, the module contains *Arachnodactyly* (`HP:0001166`), *Focal clonic seizure* (`HP:0002266`),
and their ancestors. The module contains all other HPO subhierarchies.

Run the following to prepare the module:

```shell
module load robot/1.9.8

HPO=https://github.com/obophenotype/human-phenotype-ontology/releases/download/v2026-06-06/hp.obo

wget $HPO

# Arachnodactyly HP:0001166
robot extract --input hp.obo --method BOT --term HP:0001166 \
convert --output arachnodactyly.hp.obo

# Focal clonic seizure HP:0002266
robot extract --input hp.obo --method BOT --term HP:0002266 \
convert --output fcs.hp.obo

# We use a kind of a hack to include both
# Clinical modifier HP:0012823
robot extract --input hp.obo --method BOT --term HP:0012823 \
convert --output cm.bot.hp.obo
robot extract --input hp.obo --method TOP --term HP:0012823 \
convert --output cm.top.hp.obo

# Frequency HP:0040279
robot extract --input hp.obo --method BOT --term HP:0040279 \
convert --output freq.bot.hp.obo
robot extract --input hp.obo --method TOP --term HP:0040279 \
convert --output freq.top.hp.obo

# Mode of inheritance HP:0000005
robot extract --input hp.obo --method BOT --term HP:0000005 \
convert --output moi.bot.hp.obo
robot extract --input hp.obo --method TOP --term HP:0000005 \
convert --output moi.top.hp.obo

# Past medical history HP:0032443
robot extract --input hp.obo --method BOT --term HP:0032443 \
convert --output pmh.bot.hp.obo
robot extract --input hp.obo --method TOP --term HP:0032443 \
convert --output pmh.top.hp.obo

# Blood group HP:0032223
robot extract --input hp.obo --method BOT --term HP:0032223 \
convert --output bg.bot.hp.obo
robot extract --input hp.obo --method TOP --term HP:0032223 \
convert --output bg.top.hp.obo

# Merge into one file
robot merge --input arachnodactyly.hp.obo \
--input fcs.hp.obo \
--input cm.bot.hp.obo \
--input cm.top.hp.obo \
--input freq.bot.hp.obo \
--input freq.top.hp.obo \
--input moi.bot.hp.obo \
--input moi.top.hp.obo \
--input pmh.bot.hp.obo \
--input pmh.top.hp.obo \
--input bg.bot.hp.obo \
--input bg.top.hp.obo \
--output hp.module.json

rm *.obo
```
Loading
Loading