Skip to content

Command Line Examples

Daniel Himmelstein edited this page Jul 12, 2015 · 2 revisions

Some simple examples

Introduction

Here are some examples of how to use owltools

Command Line Help

You can list all owltools commands like this:

owltools -h

to get help on a specific command:

owltools COMMAND -h

Each command has its own sub-options and grammar

to get help on a command-specific option:

owltools COMMAND OPTION -h

Things to remember

ORDER IS IMPORTANT! Command line options are processed in order. This is quite unusual, but it allows for powerful sequential chaining of commands.

A detailed understanding of the OWLTools model is not required. However, some understanding of the central OWLGraphWrapper class helps. An instance of this class holds a pointer to a single source OWLOntology and zero to many support OWLOntologies. Each OWLOntology can itself wrap multiple OWL ontologies via an imports closure. However, support ontologies are not formally connected in any way.

When the command line is processed, if an argument is not recognized as a command, then it is treated as an ontology. The first ontology encountered is loaded as the source ontology. Subsequent ones are added to the list of support ontologies. These can be mashed and merged via various commands.

Examples

Finding ancestor edges of a class

owltools cl.obo --ancestors neuron

Same thing, over the web:

owltools http://purl.obolibrary.org/obo/cl.owl --ancestors neuron

Same thing, using ID:

owltools cl.obo --ancestors CL:0000540

Same thing, using official obo-foundry URI:

owltools cl.obo --ancestors http://purl.obolibrary.org/obo/CL_0000540

For an explanation of what is meant by ancestor, see owltools.graph

Example output:

...
CL:0000540 "neuron" [CL:0000393 "electrically responsive cell"
CL:0000540 "neuron" [SUBCLASS_OF](SUBCLASS_OF]/1)/1 CL:0002319 "neural cell"
CL:0000540 "neuron" ["develops_from" SOME](RO:0002202)/5 ObjectSomeValuesFrom(BFO:0000050 "part_of" UBERON:0001017 "central nervous system")
...

i.e. their is a path of length 5 between "neuron" and CNS, and the relationship is that every neuron is a develops_from some part_of some CNS

Use for Chado

owltools go.obo --save-closure-for-chado go.inf

Merging Ontologies

This merges multiple ontologies into cl:

owltools cl.obo pro.obo go.obo --merge-support-ontologies  -o cl-merged.owl

Caching and reading the save graph closure

Save it:

owltools uberon.owl --save-closure -c uberon.closure

Use the cached closure:

owltools uberon.owl --read-closure uberon.closure -a digit

(note the closure must be read AFTER the ontology is loaded)

Using reasoners

Basic report:

owltools uberon.owl --reasoner hermit --run-reasoner

Assert implied links:

owltools uberon.owl --reasoner hermit --run-reasoner --assert-implied

Attempt to check asserted links, see if we can re-infer them (ADVANCED):

owltools go.obo go_xp_chebi.obo chebi.obo  --stash-subclasses --merge-support-ontologies --reasoner hermit --run-reasoner --assert-implied

Note the stashing has to be done before merging - only the source ontology axioms are stashed

Query using a reasoner

All brain parts:

owltools uberon.owl --reasoner-query -r elk 'BFO_0000050 some UBERON_0000955'

Note that Elk does not allow reasoner queries over class expressions. If the reasoner is Elk, then a temp query class is created equivalent to the query class expression prior to reasoning. This can be explicitly set by the "-m" option. See Queries for more details.

MORE EXAMPLES TO FOLLOW...