Skip to content

Commit

Permalink
Merge pull request #466 from monarch-initiative/enhancement/obg-reader
Browse files Browse the repository at this point in the history
Moving to obg-reader
  • Loading branch information
ielis authored Jul 10, 2024
2 parents 279a757 + bf3489a commit 96dde40
Show file tree
Hide file tree
Showing 7 changed files with 11,284 additions and 4,531 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@
/**
* Loads an ontology using the obograph library.
*
* @deprecated use {@link org.geneontology.obographs.core.io.OgJsonReader} instead of <code>OboGraphDocumentLoader</code>.
* {@code OboGraphDocumentLoader} will be removed in <em>3.0.0</em>.
* @author Jules Jacobsen <j.jacobsen@qmul.ac.uk>
*/
// REMOVE(3.0.0)
// Removing this class will remove the last use of `com.fasterxml.jackson` package in `phenol-io`.
@Deprecated(forRemoval = true, since = "2.1.2")
public class OboGraphDocumentLoader {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.monarchinitiative.phenol.io.utils;

import org.geneontology.obographs.core.io.OgJsonReader;
import org.geneontology.obographs.core.model.GraphDocument;
import org.monarchinitiative.phenol.base.PhenolRuntimeException;
import org.monarchinitiative.phenol.io.MinimalOntologyLoader;
import org.monarchinitiative.phenol.io.OntologyLoader;
import org.monarchinitiative.phenol.io.obographs.OboGraphDocumentLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -41,7 +41,7 @@ public static GraphDocument loadGraphDocument(InputStream inputStream) {
logger.debug("Looks like a JSON file...");
try {
bufferedStream.reset();
return OboGraphDocumentLoader.loadJson(bufferedStream);
return OgJsonReader.readInputStream(bufferedStream);
} catch (Exception e) {
throw new PhenolRuntimeException("Error loading JSON", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public class LoadHpo {
@Test
public void metaInfoIsCorrect() {
Map<String, String> metaInfo = hpo.getMetaInfo();
assertThat(metaInfo, hasEntry("release", "2021-06-08"));
assertThat(metaInfo, hasEntry("data-version", "http://purl.obolibrary.org/obo/hp/releases/2021-06-08/hp.json"));
assertThat(metaInfo, hasEntry("release", "2024-06-25"));
assertThat(metaInfo, hasEntry("data-version", "http://purl.obolibrary.org/obo/hp/releases/2024-06-25/hp.json"));
}

@Test
public void versionIsParsed() {
Optional<String> version = hpo.version();
assertThat(version.isPresent(), equalTo(true));
assertThat(version.get(), equalTo("2021-06-08"));
assertThat(version.get(), equalTo("2024-06-25"));
}

@Test
Expand All @@ -48,9 +48,9 @@ public void rootTerm() {

@Test
public void testTheNumberOfParsedTermIds() {
assertThat(hpo.allTermIdsStream().count(), equalTo(381L));
assertThat(hpo.nonObsoleteTermIdsStream().count(), equalTo(280L));
assertThat(hpo.obsoleteTermIdsStream().count(), equalTo(381L - 280L));
assertThat(hpo.allTermIdsStream().count(), equalTo(637L));
assertThat(hpo.nonObsoleteTermIdsStream().count(), equalTo(533L));
assertThat(hpo.obsoleteTermIdsStream().count(), equalTo(637L - 533L));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public void testParseHpoToy() {
@Test
public void testMetadata() {
Map<String, String> metaInfo = hpo.getMetaInfo();
assertThat(metaInfo, hasEntry("release", "2021-06-08"));
assertThat(metaInfo, hasEntry("data-version", "http://purl.obolibrary.org/obo/hp/releases/2021-06-08/hp.json"));
assertThat(metaInfo, hasEntry("release", "2024-06-25"));
assertThat(metaInfo, hasEntry("data-version", "http://purl.obolibrary.org/obo/hp/releases/2024-06-25/hp.json"));
}

@Test
public void testGetRightNumberOfTerms() {
assertEquals(280, hpo.nonObsoleteTermIdCount());
assertEquals(533, hpo.nonObsoleteTermIdCount());
}

@Test
Expand Down Expand Up @@ -123,6 +123,6 @@ public void testArachnodactyly() {
public void ontologyHasVersion() {
Optional<String> version = hpo.version();
assertThat(version.isPresent(), equalTo(true));
assertThat(version.get(), equalTo("2021-06-08"));
assertThat(version.get(), equalTo("2024-06-25"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
import org.jgrapht.graph.DefaultDirectedGraph;
import org.junit.jupiter.api.Test;

/**
* A testcase that tests the codes of loading a dummy ontology built from ncit.owl.
*
* @author <a href="mailto:HyeongSikKim@lbl.gov">HyeongSik Kim</a>
*/
public class OntologyLoaderTest {

@Test
Expand Down
24 changes: 22 additions & 2 deletions phenol-io/src/test/resources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ etc.).
```shell
module load robot/1.8.3

HPO=https://github.com/obophenotype/human-phenotype-ontology/releases/download/v2022-10-05/hp.obo
HPO=https://github.com/obophenotype/human-phenotype-ontology/releases/download/v2024-06-25/hp.obo
wget $HPO
robot extract --input hp.obo --method BOT --term HP:0001166 convert --output arachnodactyly.hp.obo
robot extract --input hp.obo --method TOP --term HP:0012823 convert --output clinical-modifier.hp.obo
Expand Down Expand Up @@ -43,4 +43,24 @@ robot merge --input arachnodactyly.hp.obo \
rm *.obo
```

This was followed by replacing the top-level `meta` element with the value we see in the file.
This was followed by few extra steps:

- replace the top-level `meta` element with the value we see in the full HP JSON file
- insert the following node as the 1st position of the `nodes` list:
```json
{
"id" : "http://purl.obolibrary.org/obo/HP_0034334",
"lbl" : "allelic_requirement",
"type" : "PROPERTY",
"propertyType" : "ANNOTATION",
"meta" : {
"basicPropertyValues" : [ {
"pred" : "http://purl.org/dc/elements/1.1/date",
"val" : "2022-09-04T11:14:13Z"
}, {
"pred" : "http://purl.org/dc/terms/creator",
"val" : "https://orcid.org/0000-0002-0736-9199"
} ]
}
}
```
Loading

0 comments on commit 96dde40

Please sign in to comment.