@SuppressWarnings("null")
@Nonnull
protected OWLOntology tr(@Nonnull OWLOntology in)
throws OWLOntologyCreationException {
setOwlOntology(in);
Frame hf = obodoc.getHeaderFrame();
Clause ontClause = hf.getClause(OboFormatTag.TAG_ONTOLOGY);
if (ontClause != null) {
String ontOboId = (String) ontClause.getValue();
defaultIDSpace = ontOboId;
IRI ontIRI;
if (ontOboId.contains(":")) {
ontIRI = IRI.create(ontOboId);
} else {
ontIRI = IRI.create(DEFAULT_IRI_PREFIX + ontOboId + ".owl");
}
Clause dvclause = hf.getClause(OboFormatTag.TAG_DATA_VERSION);
if (dvclause != null) {
String dv = dvclause.getValue().toString();
IRI vIRI = IRI.create(DEFAULT_IRI_PREFIX + ontOboId + '/' + dv
+ '/' + ontOboId + ".owl");
OWLOntologyID oid = new OWLOntologyID(Optional.of(ontIRI),
Optional.of(vIRI));
// if the ontology being read has a differet id from the one
// that was passed in, update it
// when parsing, the original ontology is likely an anonymous,
// empty one
if (!oid.equals(in.getOntologyID())) {
manager.applyChange(new SetOntologyID(in, oid));
}
} else {
// if the ontology being read has a differet id from the one
// that was passed in, update it
// when parsing, the original ontology is likely an anonymous,
// empty one
if (!ontIRI
.equals(in.getOntologyID().getOntologyIRI().orNull())) {
manager.applyChange(new SetOntologyID(in,
new OWLOntologyID(Optional.of(ontIRI), Optional
.<IRI> absent())));
}
}
} else {
defaultIDSpace = "TEMP";
manager.applyChange(new SetOntologyID(in,
new OWLOntologyID(Optional.of(IRI.create(DEFAULT_IRI_PREFIX
+ defaultIDSpace)), Optional.<IRI> absent())));
// TODO - warn
}
trHeaderFrame(hf);
for (Frame f : obodoc.getTypedefFrames()) {
trTypedefToAnnotationProperty(f);
}
for (Frame f : obodoc.getTypedefFrames()) {
trTypedefFrame(f);
}
for (Frame f : obodoc.getTermFrames()) {
trTermFrame(f);
}
// TODO - individuals
for (Clause cl : hf.getClauses(OboFormatTag.TAG_IMPORT)) {
String path = getURI(cl.getValue().toString());
IRI importIRI = IRI.create(path);
manager.loadOntology(importIRI);
AddImport ai = new AddImport(in,
fac.getOWLImportsDeclaration(importIRI));