@SuppressWarnings("null")
protected boolean tr(OWLAnnotationProperty prop,
@Nonnull OWLAnnotationValue annVal,
@Nonnull Set<OWLAnnotation> qualifiers, @Nonnull Frame frame) {
String tagString = owlObjectToTag(prop);
OboFormatTag tag = null;
if (tagString != null) {
tag = OBOFormatConstants.getTag(tagString);
}
if (tag == null) {
if (annVal instanceof IRI && FrameType.TERM.equals(frame.getType())
&& isMetadataTag(prop)) {
String propId = this.getIdentifier(prop);
if (propId != null) {
Clause clause = new Clause(OboFormatTag.TAG_RELATIONSHIP);
clause.addValue(propId);
clause.addValue(getIdentifier((IRI) annVal));
addQualifiers(clause, qualifiers);
frame.addClause(clause);
return true;
}
}
// annotation property does not correspond to a mapping to a tag in
// the OBO syntax -
// use the property_value tag
return trGenericPropertyValue(prop, annVal, qualifiers, frame);
}
String value = getValue(annVal, tagString);
if (!value.trim().isEmpty()) {
if (tag == OboFormatTag.TAG_ID) {
if (!frame.getId().equals(value)) {
warn("Conflicting id definitions: 1) " + frame.getId()
+ " 2)" + value);
return false;
}
return true;
}
Clause clause = new Clause(tag);
if (tag == OboFormatTag.TAG_DATE) {
try {
clause.addValue(OBOFormatConstants.headerDateFormat()
.parseObject(value));
} catch (ParseException e) {
error("Could not parse date string: " + value, true);
return false;
}
} else {
clause.addValue(value);
}
Set<OWLAnnotation> unprocessedQualifiers = new HashSet<>(qualifiers);
if (tag == OboFormatTag.TAG_DEF) {
for (OWLAnnotation aan : qualifiers) {
String propId = owlObjectToTag(aan.getProperty());
if ("xref".equals(propId)) {
OWLAnnotationValue v = aan.getValue();
String xrefValue;
if (v instanceof IRI) {
xrefValue = v.toString();
} else {
xrefValue = ((OWLLiteral) v).getLiteral();
}
Xref xref = new Xref(xrefValue);
clause.addXref(xref);
unprocessedQualifiers.remove(aan);
}
}
} else if (tag == OboFormatTag.TAG_XREF) {
Xref xref = new Xref(value);
for (OWLAnnotation annotation : qualifiers) {
if (fac.getRDFSLabel().equals(annotation.getProperty())) {
OWLAnnotationValue owlAnnotationValue = annotation
.getValue();
if (owlAnnotationValue instanceof OWLLiteral) {
unprocessedQualifiers.remove(annotation);
String xrefAnnotation = ((OWLLiteral) owlAnnotationValue)
.getLiteral();
xrefAnnotation = xrefAnnotation.trim();
if (!xrefAnnotation.isEmpty()) {
xref.setAnnotation(xrefAnnotation);
}
}
}
}
clause.setValue(xref);
} else if (tag == OboFormatTag.TAG_EXACT
|| tag == OboFormatTag.TAG_NARROW
|| tag == OboFormatTag.TAG_BROAD
|| tag == OboFormatTag.TAG_RELATED) {
handleSynonym(qualifiers, tag.getTag(), clause,
unprocessedQualifiers);
} else if (tag == OboFormatTag.TAG_SYNONYM) {
// This should never happen.
// All synonyms need to be qualified with a type.
String synonymType = null;