OPL Plugin

OPL support has been superceded by OPPL and its P4 plugin

The OPL (Ontology Processing Language) transformation language has been designed by Mikel Egaña Aranguren as part of the GONG project.
It has been adapted to work within P4 to test what further requirements are needed for ontology transforms.

Actions are currently limited to classes, and matching annotation properties is simple, but we can expand on this.

Download the plugin

From CO-ODE plugin downloads on Google Code.

Unzip into plugins directory

Run

Start Protege and load your favourite ontology

Go to Tools | OPL.... This creates a view at the bottom of your screen
(alternatively you can find the view in the View | Misc Views | OPL menu)

IMPORTANT - subclassOf and equivalentClass conditions rely on the reasoner, so the ontology must be classified.

Set the namespace prefixes

The plugin should do this for you if the ontologies exist when you start it up.

Importantly, you must make sure that the top one matches the ontology you wish all new axioms to be added to.

ORG http://www.gong.manchester.ac.uk/organism.owl
FD http://www.gong.manchester.ac.uk/food.owl

and then do things ...

Note that all actions are currently atomic - that is transforms results affect the state of the ontology as they go.
This has 2 effects; firstly, multiple undos are required to get state back, secondly, the results of earlier transforms effect later ones.

SELECT ORG:?x WHERE ORG:?x subClassOf ORG:Animal;
ADD FD:?x subClassOf ORG:produces all (FD:Milk or FD:Meat);

Meaning: "Select anything that is a subclass of animal from ORG ontology and add produces only union of Milk and Meat from FD ontology". Note that we are combining elements from different ontologies.

The statements can be of arbitrary complexity:

SELECT ORG:?x WHERE ORG:?x subClassOf ORG:eats some (ORG:Cow or ORG:Pig);
ADD ORG:?x subClassOf ORG:eats some ((ORG:develops_from all ORG:Organism) or (ORG:develops_from some ORG:Organism));

We can remove axioms as well:

SELECT ORG:?x WHERE ORG:?x equivalentTo (ORG:Animal or ORG:Plant);
REMOVE OPL:?x equivalentTo (ORG:Animal or ORG:Plant);

Labels can be used to select classes "label" or to point to classes "<LABEL>", and more than one action
(in this case, two ADD statements) can be performed in the selected class:

SELECT ORG:?x WHERE ORG:?x label Leon;ADD ORG:?x subClassOf ORG:eats some (ORG:human and ORG:<LABEL>Vaca);
ADD ORG:?x subClassOf ORG:develops_from all ORG:Lion;
SELECT ORG:?x WHERE ORG:?x label (.+?) (sapiens);
ADD ORG:?x subClassOf ORG:<LABEL><RG1>;
ADD ORG:?x equivalentTo ORG:belongs_to_taxon all ORG:<RG2>;

Here we are selecting classes using the regular expression (.+?) (sapiens) as a matching condition for their labels; in the first action statement we are telling the parser to add a subclass axiom, being the superclass the class with the label with the same content as the group one of the regexp matching result, thus (.+?) (in this case it will be "Homo"). The second action statement does the same but instead of using the label, searches directly for the class name (sapiens).

Finally...

When you are happy with your transformation, press Process and your ontology should now reflect the changes you have requested.

Source

Source code is also available from subversion.