Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --input-format option #1056

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Checking for empty strings in addition to missing ones in `missing_label.rq` [#1017]
- Add new global option: `--input-format` [#1056]

## [1.9.0] - 2022-06-16

Expand Down Expand Up @@ -320,6 +321,7 @@ First official release of ROBOT!
[`template`]: http://robot.obolibrary.org/template
[`validate`]: http://robot.obolibrary.org/validate

[#1056]: https://github.com/ontodev/robot/issues/1056
[#1009]: https://github.com/ontodev/robot/issues/1009
[#979]: https://github.com/ontodev/robot/pull/979
[#978]: https://github.com/ontodev/robot/pull/978
Expand Down
11 changes: 1 addition & 10 deletions docs/examples/ro-base-reasoned.owl
Original file line number Diff line number Diff line change
Expand Up @@ -3687,15 +3687,6 @@ For example, protein A (transcription factor) indirectly increases by expression



<!-- http://xmlns.com/foaf/0.1/image -->

<owl:Class rdf:about="http://xmlns.com/foaf/0.1/image"/>
<rdf:Description>
<rdfs:seeAlso rdf:resource="https://github.com/oborel/obo-relations/issues/259"/>
</rdf:Description>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -3878,5 +3869,5 @@ For example, protein A (transcription factor) indirectly increases by expression



<!-- Generated by the OWL API (version 1.8.4) https://github.com/owlcs/owlapi -->
<!-- Generated by the OWL API (version 4.5.6) https://github.com/owlcs/owlapi -->

9 changes: 0 additions & 9 deletions docs/examples/ro-base.owl
Original file line number Diff line number Diff line change
Expand Up @@ -3553,15 +3553,6 @@ For example, protein A (transcription factor) indirectly increases by expression



<!-- http://xmlns.com/foaf/0.1/image -->

<owl:Class rdf:about="http://xmlns.com/foaf/0.1/image"/>
<rdf:Description>
<rdfs:seeAlso rdf:resource="https://github.com/oborel/obo-relations/issues/259"/>
</rdf:Description>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
Expand Down
17 changes: 17 additions & 0 deletions docs/global.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
4. [Logging (`-v`, `-vv`, `-vvv`)](#logging)
5. [XML Entities (`--xml-entities`)](#xml-entities)
6. [Strict Parsing (`--strict`)](#strict-parsing)
7. [Input Format (`--input-format`)](#input-format)

## Java Options

Expand Down Expand Up @@ -131,6 +132,22 @@ _:blank rdf:type rdf:Statement .
_:blank rdf:type owl:Axiom .
```

## Input Format

When loading an ontology, OWLAPI will attempt to load with a variety of ontology format parsers. When all parsers fail, many error logs are printed (when using verbose mode). Finding the cause of the error based on parser can be difficult due to number of messages. For debugging purposes, you can specify the `--input-format` of the ontology as one of:

| Format | Specification |
| ------ | --------------------------------------------------------------------------------- |
| owl | [RDF/XML](https://www.w3.org/TR/rdf-syntax-grammar/) |
| obo | [OBO Flat File](https://owlcollab.github.io/oboformat/doc/GO.format.obo-1_4.html) |
| owx | [OWL/XML](https://www.w3.org/TR/owl-xmlsyntax/) |
| ofn | [OWL Functional](https://www.w3.org/TR/owl2-syntax/) |
| omn | [OWL Manchester](https://www.w3.org/TR/owl2-manchester-syntax/) |
| ttl | [Turtle](https://www.w3.org/TR/turtle/) |
| json | [OBO Graphs JSON](https://github.com/geneontology/obographs/) |

Be aware that the suffix of the ontology file does not always correspond to the format; OBO ontologies will often use the suffix `.owl` for both RDF/XML and functional syntax. Check the contents of the file using the format specifications for reference to be sure.

---

## Error Messages
Expand Down
24 changes: 12 additions & 12 deletions docs/reason.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ If the input module contains at least one import, axioms in the debug module wil

## Equivalent Class Axioms

By default, ROBOT ignores one-to-one equivalent classes (e.g. `A EquivalentTo B`). But, in many cases, inferring equivalence between two classes is usually a sign that something has gone wrong.
By default, ROBOT ignores one-to-one equivalent classes (e.g. `A EquivalentTo B`). But, in many cases, inferring equivalence between two classes is usually a sign that something has gone wrong.

Sometimes we want to avoid equivalence between named classes at all (in the case of OBO, where we strive for orthogonality). This can be done through `--equivalent-classes-allowed <arg>` (shorthand `-e`).
Sometimes we want to avoid equivalence between named classes at all (in the case of OBO, where we strive for orthogonality). This can be done through `--equivalent-classes-allowed <arg>` (shorthand `-e`).

The `<arg>` options are:

Expand All @@ -77,16 +77,16 @@ The `<arg>` options are:

## Excluding tautologies

A **tautology** is an axiom that would be true in any ontology, i.e., it's just a given due to the semantics of OWL. For example, every class is a subclass
of `owl:Thing`; it is not generally useful for an ontology to explicitly state this. Some reasoners may however include these kinds of statements as part
A **tautology** is an axiom that would be true in any ontology, i.e., it's just a given due to the semantics of OWL. For example, every class is a subclass
of `owl:Thing`; it is not generally useful for an ontology to explicitly state this. Some reasoners may however include these kinds of statements as part
of their output. The ROBOT `reason` command provides an option for filtering out tautologies generated by the reasoning process: `--exclude-tautologies <arg>`.

The options for `<arg>` are:

* `false` (default): allow any generated tautologies in the output.
* `all` (recommended): use the HermiT reasoner to exclude any inferred axioms that would be entailed by an empty ontology.
* `structural` (fast): exclude axioms matching a hard-coded set of tautological patterns (e.g., `X SubClassOf owl:Thing`, `owl:Nothing SubClassOf X`, `X SubClassOf X`). Much faster than `all`.

## Generated Axioms

By default, the `reason` operation will only assert inferred subclass axioms. This can be configured with the `--axiom-generators` option. OWLAPI provides the following inferred axiom generators:
Expand All @@ -113,27 +113,27 @@ By default, the `reason` operation will only assert inferred subclass axioms. Th
One or more of these axiom generators can be passed into the option (separated by spaces). For example, to generate both subclass and disjoint class axioms:

```
robot reason --input unreasoned.owl
--axiom-generators "SubClass DisjointClasses"
robot reason --input unreasoned.owl \
--axiom-generators "SubClass DisjointClasses" \
--output reasoned.owl
```

Note that for some of the axiom generators you may need the Hermit reasoner
to get meaningful results:


robot reason --input ro-base.owl --reasoner hermit
--axiom-generators "ObjectPropertyRange ObjectPropertyDomain"
robot reason --input ro-base.owl --reasoner hermit \
--axiom-generators "ObjectPropertyRange ObjectPropertyDomain" \
--output ro-base-reasoned.owl


If you are only passing one axiom generator, it does not need to be surrounded by double quotes.

The axioms that are generated for subclasses, class assertions, and sub-object properties can be either direct or indirect. By default, the operation will only generate direct axioms (`--include-indirect false`). It is recommended to pipe to `reduce` after to remove any redundant axioms. For example, to generate all direct and indirect superclass expressions:
```
robot reason --input unreasoned.owl
--reasoner emr
--include-indirect true
robot reason --input unreasoned.owl \
--reasoner emr \
--include-indirect true \
reduce --output reasoned.owl
```

Expand Down
6 changes: 3 additions & 3 deletions docs/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ If the `TYPE` is a defined class, `owl:Individual`, or `owl:NamedIndividual`, an

#### Example of Individual Template Strings

| Label | Entity Type | Individual Role | Property Assertions | Different Individuals |
| Label | Entity Type | Individual Role | Property Assertions | Different Individuals |
| ------------ | ----------- | -------------------- | ------------------- | --------------------- |
| LABEL | TYPE | TI 'has role' some % | I part_of | DI % |
| Individual 1 | Class 1 | Role Class 1 | Individual 2 | |
Expand Down Expand Up @@ -188,7 +188,7 @@ If the command includes `--ancestors`, the result ontology will include the ance
Create an output ontology that includes the input ontology and the terms defined in the template:

robot template --merge-before --input edit.owl \
--template part_of_template.csv --output part_of_uberon.owl
--template part_of_template.csv --output results/part_of_uberon.owl


Create two outputs -- the templated terms ([`uberon_template.owl`](/examples/uberon_template.owl)) and the input ontology merged with the output ontology with an annotation ([`uberon_v2.owl`](/examples/uberon_v2)):
Expand Down Expand Up @@ -311,7 +311,7 @@ AL rdfs:label@en

The provided value cannot be parsed and may not be in proper Manchester syntax. See [Manchester Syntax](http://www.w3.org/2007/OWL/wiki/ManchesterSyntax) for more details. If you are using labels, make sure the labels are defined in the `--input` ontology or using the `LABEL` column. Also ensure that all properties use a label instead of a CURIE or IRI.

When using a restriction (`some`, `only`, `min`, `max`, `exactly`, or `value`) the term that preceeds the restriction must be a property.
When using a restriction (`some`, `only`, `min`, `max`, `exactly`, or `value`) the term that preceeds the restriction must be a property.

Terms joined using `and` or `or` must be of the same entity type, e.g., you cannot join an object property and a class in an expression.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.geneontology.reasoner.ExpressionMaterializingReasonerFactory;
import org.geneontology.whelk.owlapi.WhelkOWLReasonerFactory;
import org.semanticweb.elk.owlapi.ElkReasonerFactory;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.io.OWLParserFactory;
import org.semanticweb.owlapi.model.*;
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -66,7 +68,12 @@ public class CommandLineHelper {

/** Error message when more than one --input is specified, excluding merge and unmerge. */
private static final String multipleInputsError =
NS + "MULITPLE INPUTS ERROR only one --input is allowed";
NS + "MULTIPLE INPUTS ERROR only one --input is allowed";

/** Error message when --input-format is invalid. */
private static final String unknownInputFormatError =
NS
+ "UNKNOWN INPUT FORMAT ERROR --input-format must be one of: owl, ofn, owx, omn, obo, ttl, or json";

/** Error message when the --inputs pattern does not include * or ?, or is not quoted */
private static final String wildcardError =
Expand Down Expand Up @@ -462,7 +469,7 @@ public static OWLOntology getInputOntology(IOHelper ioHelper, CommandLine line)
* @param line the command line to use
* @param catalogPath the catalog to use to load imports
* @return the input ontology
* @throws IllegalArgumentException if requires options are missing
* @throws IllegalArgumentException if required options are missing
* @throws IOException if the ontology cannot be loaded
*/
public static OWLOntology getInputOntology(
Expand All @@ -476,17 +483,29 @@ public static OWLOntology getInputOntology(
throw new IllegalArgumentException(multipleInputsError);
}

// Create a manager to load ontology and maybe set parsers
// Otherwise, all parsers will be tried
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
String inputFormat = getOptionalValue(line, "input-format");
if (inputFormat != null) {
Set<OWLParserFactory> parsers = IOHelper.getParsersByFormat(inputFormat);
if (parsers == null) {
throw new IllegalArgumentException(unknownInputFormatError);
}
manager.setOntologyParsers(parsers);
}

if (!inputOntologyPaths.isEmpty()) {
if (catalogPath != null) {
return ioHelper.loadOntology(inputOntologyPaths.get(0), catalogPath);
return ioHelper.loadOntology(manager, inputOntologyPaths.get(0), catalogPath);
} else {
return ioHelper.loadOntology(inputOntologyPaths.get(0));
return ioHelper.loadOntology(manager, inputOntologyPaths.get(0));
}
} else if (!inputOntologyIRIs.isEmpty()) {
if (catalogPath != null) {
return ioHelper.loadOntology(IRI.create(inputOntologyIRIs.get(0)), catalogPath);
return ioHelper.loadOntology(manager, IRI.create(inputOntologyIRIs.get(0)), catalogPath);
} else {
return ioHelper.loadOntology(IRI.create(inputOntologyIRIs.get(0)));
return ioHelper.loadOntology(manager, IRI.create(inputOntologyIRIs.get(0)));
}
} else {
// Both input options are empty
Expand Down Expand Up @@ -908,6 +927,11 @@ public static Options getCommonOptions() {
o.addOption("v", "verbose", false, "increased logging");
o.addOption("vv", "very-verbose", false, "high logging");
o.addOption("vvv", "very-very-verbose", false, "maximum logging, including stack traces");
o.addOption(
null,
"input-format",
true,
"format of the input ontology: obo, owl, ttl, owx, omn, ofn, json");
o.addOption(null, "catalog", true, "use catalog from provided file");
o.addOption("p", "prefix", true, "add a prefix 'foo: http://bar'");
o.addOption("P", "prefixes", true, "use prefixes from JSON-LD file");
Expand Down
Loading