monarch-initiative / phenol

phenol: Phenotype ontology library
https://phenol.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
23 stars 4 forks source link

Allow dropping non-propagating relationships during ontology loading #422

Closed ielis closed 1 year ago

ielis commented 1 year ago

For specific applications, it is desirable to only keep the propagating relationships in the ontology graph. However, the current code includes relationships of all types by default.

This PR adds an option for dropping non-propagating relationships during the ontology parsing. An OntologyLoaderOptions class is added to phenol-io that can be used in OntologyLoader.loadOntology(...):

public static Ontology loadOntology(InputStream inputStream,
                                    CurieUtil curieUtil,
                                    OntologyLoaderOptions options,
                                    String... termIdPrefixes) {
  ...
}

This is a non-breaking change and the default loading is unaffected. However, if desired, the user can choose to drop the unwanted non-propagating relationships from the ontology graph.

As a second item, the PR addresses an inconsistency, where OntologyAlgorithm.getParentTerms() considered relationship propagation when fetching parent term IDs, but the symmetric function OntologyAlgorithm.getChildTerms() did not consider the propagation aspect. Now, both functions consider the propagation.