Skip to content

Commit dc5c981

Browse files
committed
Test and fix for BioJava #836 to parse and save all OBO synonyms
1 parent 0e86964 commit dc5c981

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

biojava-ontology/src/main/java/org/biojava/nbio/ontology/Synonym.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,7 @@ public String toString(){
4848
public final static Comparator<Synonym> COMPARATOR = new Comparator<Synonym>() {
4949
@Override
5050
public int compare(Synonym a, Synonym b) {
51-
if (a == null && b == null)
52-
return 0;
53-
else if (a == null)
54-
return -1;
55-
else if (b == null)
56-
return 1;
57-
else {
58-
if ((a.getCategory() == null) && (b.getCategory() == null))
59-
return 0;
60-
else if ( a.getCategory()==null)
61-
return -1;
62-
else if ( b.getCategory()==null)
63-
return 1;
64-
65-
return a.getCategory().compareToIgnoreCase(
66-
b.getCategory());
67-
}
51+
return String.CASE_INSENSITIVE_ORDER.compare(a.toString(), b.toString());
6852
}
6953
};
7054

biojava-ontology/src/test/java/org/biojava/nbio/ontology/TestOboFileParsing.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ public void testParsingHPOOBO() throws Exception {
8080
Assert.assertTrue(anno.containsProperty("replaced_by"));
8181
Assert.assertEquals("HP:0008665", anno.getProperty("replaced_by"));
8282
}
83+
if(term.getName().equals("HP:0000006")) {
84+
Assert.assertEquals("Autosomal dominant inheritance", term.getDescription());
85+
Object[] syns = term.getSynonyms();
86+
Assert.assertEquals(3, syns.length);
87+
Assert.assertEquals("Autosomal dominant", ((Synonym) syns[0]).getName());
88+
Assert.assertEquals("Autosomal dominant form", ((Synonym) syns[1]).getName());
89+
Assert.assertEquals("Autosomal dominant type", ((Synonym) syns[2]).getName());
90+
}
8391
}
8492
}
8593

0 commit comments

Comments
 (0)