ROBOT

- - - - - - - - - -
view on github
getting started
common errors
chaining commands
global options
makefile
- - - - - - - - - -
annotate
convert
diff
explain
extract
filter
materialize
merge
mirror
query
reason
reduce
relax
remove
rename
repair
report
template
unmerge
validate
verify
- - - - - - - - - -
ROBOT is licensed under the
BSD 3-Clause License.
Theme by orderedlist

Remove

The remove command allows you to remove selected axioms from an ontology. The filter command is the opposite of remove, allowing you to keep only selected axioms. To use these powerful commands effectively, some familiarity with OWL and OWLAPI is helpful.

remove works in four steps:

  1. specify an initial target set of objects to remove
  2. use selectors to broaden or narrow the target set of objects
  3. specify the types of axioms to consider
  4. check each axiom of specified type against the target set of objects

Here is how each step works in more detail:

  1. The --term and --term-file options let you specify the initial target set. You can specify zero or more --term options (one term each), and zero or more --term-file options (with one term per line). You can specify terms by IRI or CURIE. If no terms are specified, then the initial target set consists of all the objects in the ontology.

  2. The --select option lets you specify “selectors” that broaden or narrow the target set of objects. Some selectors such as classes take the target set and return a subset, i.e. all the classes in the target set. Other selectors such as parents return a new target set of related objects. The parents selector gets the parents of each object in the target set. Note that the parents set does not include the original target set, just the parents. Use the self selector to return the same target set. You can use multiple selectors together to get their union, so --select "self parents" will return the target set (self) and all the parents. You can use --select multiple times to modify the target set in several stages, so --select parents --select children will get the parents and then all their children, effectively returning the target set objects and all their siblings.

  3. The --axioms option lets you specify which axiom types to consider. By default, all axioms are considered, but this can be restricted to annotation axioms, logical axioms, more specific subtypes, or any combination.

  4. The final step is to take each axiom of the specified types, and compare it to the target set. Two options are important for this step. When --signature true is used, the named objects for the axiom (aka the “signature” of the axiom) are compared to the target set. When --signature false is used (the default), all named and anonymous objects for the axiom are compared to the target set. Named objects, such as classes, have IRIs, while anonymous objects, such as class expressions, do not have IRIs. When using remove --trim true (the default), if any object for the axiom is in the target set then that axiom is removed. When using remove --trim false, if all objects for the axiom are in the target set, then that axiom is removed.

Consider an example with this small ontology:

ax1: A subClassOf B
ax2: A subClassOf R some C
ax3: D subClassOf E

Then remove --term A --term R --term C --select "self parents" --axioms all --signature true --trim true works as follows:

  1. The initial target set includes all the specified --terms: {A, R, C}
  2. For self we get just the initial target set {A, R, C}; for parents we get {B, R some C}; so the new target set is the union {A, B, R, C, R some C}
  3. --axioms all means that we consider all axioms
  4. For each axiom we compare the objects for the axiom to the target set. With --signature true we only consider the named objects, i.e. objects that have IRIs, not anonymous objects such as R some C. With --trim true we are checking that any object for the axiom is in the target set.
    • the objects for ax1 are {A, B}, and at least one of these is in the target set, so ax1 is matched and removed
    • the objects for ax2 are {A, R, C} (with R some C excluded), and at least one of these is in the target set, so ax2 is matched and removed
    • the objects for ax3 are {D, E}, and none of these are in the target set, so ax3 is not matched and is not removed

The remove and filter operations maintains structural integrity by default: lineage is maintained, and gaps will be filled where classes have been removed. If you wish to not preserve the hierarchy, include --preserve-structure false.

Selectors

You can use the --select option zero or more times, providing one or more “selectors” each time. These can be provided in quotes in one select statement (--select "x y z"), or in multiple statements (--select x --select y --select z). When selects are provided in multiple statements, the output of the first will be passed to the second and so on. If multiple options are provided in one statement, all options will be processed at the same time, resulting in a union target set.

Subset Selectors

These selectors take a target set and return a subset:

Relation Selectors

These selectors consider each object in the target set, and return all the objects that have some relation

Pattern Subset Selectors

Terms can also be selected from the set based on their annotations. This can be helpful if you want to remove only terms with a specific annotation. When selecting with axioms, the --select option must always be quoted.

It is also possible to select terms based on parts of their IRI. You may include an IRI pattern using one or more wildcard characters (* and/or ?) enclosed in angle brackets. This MUST be enclosed in quotes to work on the command line.

If you wish to match a more complicated pattern, you may also use a regex pattern here by preceding the pattern with a tilde (~):

Axioms

The --axioms option allows you to specify the type of OWLAxiom to remove. More than one type can be provided and the order is not significant. For each axiom in the ontology (not including its imports closure), if the axiom implements one of the specified axiom types AND any of the selected terms are in the axiom’s signature, then the axiom is removed from the ontology.

Examples

Remove a class (‘organ’), all its descendants, and any axioms using these classes:

robot remove --input uberon_module.owl \
  --term UBERON:0000062 \
  --select "self descendants" \
  --signature true \
  --output results/remove_class.owl

Remove all axioms containing an entity in the BFO namespace from the UBERON module:

robot remove --input uberon_module.owl \
  --select "<http://purl.obolibrary.org/obo/BFO_*>" \
  --signature true \
  --output results/remove_bfo.owl

Remove all anonymous entities from the UBERON module:

robot remove --input uberon_module.owl \
  --select anonymous \
  --signature false \
  --output results/remove_anonymous.owl

Remove all individuals from OBI:

robot remove --input obi.owl --select individuals

Remove all deprecated classes from OBI:

robot remove --input obi.owl \
  --select "owl:deprecated='true'^^xsd:boolean"

Filter for only desired annotation properties (in this case, label and ID). This works by actually removing the opposite set of annotation properties (complement annotation-properties) from the ontology:

robot remove --input uberon_module.owl \
  --term rdfs:label --term oboInOwl:id  \
  --select complement --select annotation-properties \
  --signature true \
  --output results/filter_annotations.owl