public class CommentRemarkConversionTest extends OboFormatTestBasics {
@Test
public void testConversion() throws Exception {
OBODoc obo = parseOBOFile("comment_remark_conversion.obo", true);
Frame headerFrame = obo.getHeaderFrame();
Collection<String> remarks = headerFrame.getTagValues(
OboFormatTag.TAG_REMARK, String.class);
OWLAPIObo2Owl obo2Owl = new OWLAPIObo2Owl(
OWLManager.createOWLOntologyManager());
OWLOntology owlOntology = obo2Owl.convert(obo);
Set<OWLAnnotation> annotations = owlOntology.getAnnotations();
Set<String> comments = new HashSet<>();
for (OWLAnnotation owlAnnotation : annotations) {
OWLAnnotationProperty property = owlAnnotation.getProperty();
if (property.isComment()) {
OWLAnnotationValue value = owlAnnotation.getValue();
if (value instanceof OWLLiteral) {
OWLLiteral literal = (OWLLiteral) value;
comments.add(literal.getLiteral());
}
}
}
// check that all remarks have been translated to rdfs:comment
assertEquals(remarks.size(), comments.size());
assertTrue(comments.containsAll(remarks));
assertTrue(remarks.containsAll(comments));
OWLAPIOwl2Obo owl2Obo = new OWLAPIOwl2Obo(
OWLManager.createOWLOntologyManager());
OBODoc oboRoundTrip = owl2Obo.convert(owlOntology);
Frame headerFrameRoundTrip = oboRoundTrip.getHeaderFrame();
Collection<String> remarksRoundTrip = headerFrameRoundTrip
.getTagValues(OboFormatTag.TAG_REMARK, String.class);
assertEquals(remarks.size(), remarksRoundTrip.size());
assertTrue(remarksRoundTrip.containsAll(remarks));
assertTrue(remarks.containsAll(remarksRoundTrip));
}