OOP in Bioinformatics
OOP in Bioinformatics
OOP in Bioinformatics
Ontology-oriented programming
for biomedical informatics
Jean-Baptiste Lamy
Jean-baptiste.lamy @ univ-paris13 . fr
Ontology
Universal statements
knowledge :
Ticagrelor is contraindicated Terminological statements
with Hemorrhagic disorders translations :
EN = Hemorrhagic disorders
FR = Maladies hmorragiques
Assertional statements
data :
Ticagrelor has for daily cost 2.48
2
Working with ontologies
Many tools have been developped for working with ontologies :
Ontology language : OWL
Ontology editor : Protg
Ontology API : OWLAPI
However, these tools does not integrate well with usual tools :
Object-oriented programming
Database... Ontologies
Data
base
OOP3
Working with ontologies : example
Java source code for computing the total cost of a drug order :
(considering a single box for each drug)
class Order {
[...]
publicfloatgetCost(){
floatcost=0.0;
Iteratordrug_iterator=this.getDrugs().iterator();
while(drug_iterator.hasNext()){
Drugdrug=(Drug)drug_iterator.next();
cost=cost+drug.getPrice();
}
returncost;
}
}
4
Working with ontologies : example
Same example using an ontology :
publicstaticfloatgetOrderCost(OWLIndividualorder){
OWLModelmodel=order.getOWLModel();
OWLPropertydrugProperty=model.getOWLObjectProperty("drug");
OWLPropertypriceProperty=model.getOWLDadatypeProperty("price");
floatcost=0.0;
Iteratordrugs=order.listPropertyValues(drugProperty);
while(purchases.hasNext()){
OWLIndividualdrug=(OWLIndividual)drugs.next();
Floatprice=(Float)drug.getPropertyValue(priceProperty);
cost=cost+price.floatValue();
}
returncost;
}
3) produce inferences
with a reasoner
Drug
database
1) populate 3) generate
the ontology a website
Refe-
rence Ontology
texts
Website
Expert
6
Ontology programming interface
Tools for manipulating ontologies in programming languages are
known as ontology programming interface
A problem identified by A. Rector in 2008
Use Cases for Building OWL Ontologies as Modules: Localizing,
Ontology and Programming Interfaces & Extensions
How to access, manipulate and populate an ontology from a computer
programming language?
E.g. how to write a program for populating the ontology from a database
and then for generating an HTML website from the inferences produced
by the ontology?
7
Difficulties encountered with
ontologies in the biomedical domain
Many medical concepts cannot be represented by individuals but
need classes to represent them
Disorders and drugs can be described at various levels of granularity
NSAID (Non Steroid Anti-Inflammatory Drugs)
Aspirin
Aspirin 100mg tablet in the antiplatelet indication
=> Disorders and drugs must be classes in ontologies
Disorders and drugs properties are often defined at mid-granularity
level
E.g. aspirin is contraindicated with hemorrhagic disorders
But OWL does not allow direct relation between two classes
All kinds of aspirin are contraindicated with all kind of hemorrhagic
disorders
a, d, Aspirin(a) HemorrhagicDisorder(d) => contraindication(a, d)
8
Difficulties encountered with
ontologies in the biomedical domain
The open-world assumption is not always appropriate for medical
reasoning
Open-world assumption is interesting when reasoning on patient
It allows the reasoner to perform hypothesis about unknown patient
conditions
But it is not desirable on drug or disorder knowledge
Physicians usually consider that all properties of a given drug are known
and described in official reference documents
This can lead to stupid alerts :
the patient has renal failure; the drug you are prescribing is not
contraindicated with renal failure but the drug might have a
yet-unknown contraindication with renal failure.
9
Two approaches for ontology
programming interface
Traditional API (e.g. OWLAPI in Java)
Classes and functions for manipulating OWL constructs
An OWL class is an instance of OWLClass
Ontology-oriented programming
Many similarities between ontologies and the object-oriented
programming paradigm
Classes, properties and individuals in ontologies
= Classes, attributes and instances in object models
Try to unify the ontological model with the object model of the
programming language
An OWL class is a class in the programming language
=> shorter source code, faster development and thus fewer errors
10
Object and ontology paradigm
Object Ontology
Closed-world assumption: Open-world assumption:
Implicit disjoints between classes: Explicit disjoints between classes:
two classes are disjoint if they have no two classes can be disjoint or not
common child
11
Static vs dynamic
Static ontology-oriented programming :
Automatic generation of classes source code from an OWL ontology
Java [Kalyanpur], Sapphire [Stevenson], C# [Goldman]
Dynamic ontology-oriented programming :
A dynamic translator between the ontology paradigm and the object
paradigm
Limited to dynamic programming languages
Common Lisp [Koide], Python [Babik]
Allows automatic classification at run time
Mix Open-world (ontology) and closed-world (object) assumption
=> Dynamic ontology-oriented programming seems the best way for
accessing ontology in biomedical informatics
12
OwlReady
A module for dynamic ontology-oriented programming in Python 3
https://pypi.python.org/pypi/Owlready (Free Software, GNU LGPL)
Dynamic class creation
Automatic classification of classes and instances with the Hermit reasoner
Addition of Python methods to OWL classes
OWL/XML 2 file format
Properties Properties
Individuals Individuals
13
OwlReady vs traditional API
publicstaticfloatgetOrderCost(OWLIndividualorder){ Java + API
OWLModelmodel=order.getOWLModel();
OWLPropertydrugProperty=model.getOWLObjectProperty("drug");
OWLPropertypriceProperty=model.getOWLDadatypeProperty("price");
floatcost=0.0;
Iteratordrugs=order.listPropertyValues(drugProperty);
while(purchases.hasNext()){
OWLIndividualdrug=(OWLIndividual)drugs.next();
Floatprice=(Float)drug.getPropertyValue(priceProperty);
cost=cost+price.floatValue();
}
returncost;
} Python + OwlReady
A Python / OWL class
classOrder(Thing): with a Python method
defget_cost(order):
cost=0.0
fordruginorder.drugs:cost=cost+drug.price
returncost 14
Using OwlReady in VIIIP
Architecture of the VIIIP platform with OwlReady
Include an ontology of drug contraindications
HermiT VIIIP
Reasoner Ontology
(OWL)
Drug OwlReady
database
SQL request VIIIP
Ontology Website
Manual data entry (Python)
Clinical
trial field value
reports field value
OwlReady
Dialog boxes 15
Automatic dialog boxes
generation from the ontology
OwlReady can generate dialog boxes for editing instances
Using the EditObj3 dialog box generator
http://www.lesfleursdunormal.fr/static/informatique/editobj/index_en.html
And the
definition
in the
ontology
16
Comparison with literature
Goldman Kalyanpur Koide Babik Stevenson Lamy
2003 2004 2005 2006 2011 2016
Classification no no ? ? no yes
of classes
18
Conclusion
Dynamic ontology-oriented programming is an interesting approach
for integrating ontologies in computer software
Simpler and shorter source code
While computer programs manipulating biomedical ontologies tend to be
more and more complex
Especially in the biomedical domain
because disorders and drugs must be represented using classes
because a mix of open- and closed-world assumption is often
needed
19
Reference
Rector A, Horridge M, Iannone L, Drummond N. Use Cases for Building OWL Ontologies as
Modules: Localizing, Ontology and Programming Interfaces & Extensions. In: 4th Int Workshop
on Semantic Web enabled software engineering (SWESE-08); 2008.
Knublauch H, Oberle D, Tetlow P, Wallace E. A Semantic Web Primer for Object-Oriented
Software Developers. W3C Working Group Note. 2006.
Koide S, Aasman J, Haflich S. OWL vs. Object Oriented Programming. In: the 4th International
Semantic Web Conference (ISWC 2005), Workshop on Semantic Web Enabled Software
Engineering (SWESE); 2005. p. 115.
Kalyanpur A, Pastor D, Battle S, Padget J. Automatic mapping of OWL ontologies into Java. In:
Proceedings of the Sixteenth International Conference on Software Engineering & Knowledge
Engineering (SEKE2004); 2004. p. 98103.
Goldman NM. Ontology-oriented programming: static typing for the inconsistent programmer.
In: Lecture notes in computer science: the SemanticWeb, ISWC. vol. 2870; 2003. p. 850865.
Stevenson G, Dobson S. Sapphire: Generating Java Runtime Artefacts from OWL Ontologies.
In: Lecture Notes in Business Information Processing, Advanced Information Systems
Engineering Workshops. vol.83; 2011. p. 425436.
Babik M, Hluchy L. Deep Integration of Python with Web Ontology Language. In: Proceedings
of the 2nd workshop on scripting for the semantic web. Budva,
Montenegro; 2006. p. 15. 20