|
23 | 23 | package org.biojava.nbio.ontology; |
24 | 24 |
|
25 | 25 | import org.biojava.nbio.ontology.io.OboParser; |
26 | | -import org.junit.Assert; |
| 26 | +import org.biojava.nbio.ontology.utils.Annotation; |
27 | 27 | import org.junit.Test; |
28 | 28 |
|
29 | 29 | import java.io.*; |
30 | 30 | import java.text.ParseException; |
| 31 | +import java.util.List; |
31 | 32 | import java.util.Set; |
32 | 33 |
|
33 | 34 | import static org.biojava.nbio.ontology.obo.OboFileHandler.NAMESPACE; |
| 35 | +import static org.biojava.nbio.ontology.obo.OboFileHandler.ALT_ID; |
| 36 | +import static org.junit.Assert.assertEquals; |
| 37 | +import static org.junit.Assert.assertNotNull; |
| 38 | +import static org.junit.Assert.assertTrue; |
34 | 39 |
|
35 | 40 | public class TestParseOBO { |
36 | 41 |
|
37 | 42 | @Test |
38 | 43 | public void testNamespace() throws IOException, ParseException { |
39 | 44 |
|
40 | | - String testTermEntry = "\n[Term]\n" + |
41 | | - "id: SO:0000691\n" + |
42 | | - "name: cleaved_initiator_methionine \n" + |
43 | | - "namespace: sequence\n" + |
44 | | - "alt_id: BS:00067\n" + |
45 | | - "def: \"The initiator methionine that has been cleaved from a mature polypeptide sequence.\" [EBIBS:GAR]\n" + |
46 | | - "subset: biosapiens\n" + |
47 | | - "synonym: \"cleaved initiator methionine\" EXACT []\n" + |
48 | | - "synonym: \"init_met\" RELATED [uniprot:feature_type]\n" + |
49 | | - "synonym: \"initiator methionine\" RELATED []\n" + |
50 | | - "is_a: SO:0100011 ! cleaved_peptide_region\n\n"; |
| 45 | + String testTermEntry = "\n[Term]\n" + "id: SO:0000691\n" |
| 46 | + + "name: cleaved_initiator_methionine \n" |
| 47 | + + "namespace: sequence\n" |
| 48 | + + "alt_id: BS:00067\n" |
| 49 | + + "def: \"The initiator methionine that has been cleaved from a mature polypeptide sequence.\" [EBIBS:GAR]\n" |
| 50 | + + "subset: biosapiens\n" + "synonym: \"cleaved initiator methionine\" EXACT []\n" |
| 51 | + + "synonym: \"init_met\" RELATED [uniprot:feature_type]\n" |
| 52 | + + "synonym: \"initiator methionine\" RELATED []\n" + "is_a: SO:0100011 ! cleaved_peptide_region\n\n"; |
51 | 53 |
|
52 | | - OboParser parser = new OboParser(); |
53 | | - InputStream inStream = new ByteArrayInputStream(testTermEntry.getBytes()); |
| 54 | + OboParser parser = new OboParser(); |
| 55 | + InputStream inStream = new ByteArrayInputStream(testTermEntry.getBytes()); |
54 | 56 |
|
55 | | - Assert.assertNotNull(inStream); |
| 57 | + assertNotNull(inStream); |
56 | 58 |
|
57 | | - BufferedReader oboFile = new BufferedReader ( new InputStreamReader ( inStream ) ); |
| 59 | + BufferedReader oboFile = new BufferedReader(new InputStreamReader(inStream)); |
58 | 60 | Ontology ontology = parser.parseOBO(oboFile, "so-xp/subsets/biosapiens", |
59 | | - "snippet from biosapiens protein feature ontology"); |
| 61 | + "snippet from biosapiens protein feature ontology"); |
| 62 | + |
60 | 63 | Set<Term> keys = ontology.getTerms(); |
61 | 64 |
|
62 | | - Assert.assertTrue(keys.size() > 1); |
63 | | - Assert.assertTrue(ontology.getTerm("SO:0000691").getAnnotation().containsProperty(NAMESPACE)); |
64 | | - Assert.assertEquals("sequence", ontology.getTerm("SO:0000691").getAnnotation().getProperty(NAMESPACE)); |
| 65 | + assertTrue(keys.size() > 1); |
| 66 | + assertTrue(getAnnotationForTerm(ontology).containsProperty(NAMESPACE)); |
| 67 | + assertEquals("sequence", getAnnotationForTerm(ontology).getProperty(NAMESPACE)); |
| 68 | + assertTrue( getAnnotationForTerm(ontology).getProperty(ALT_ID) instanceof List); |
| 69 | + |
| 70 | + } |
| 71 | + |
| 72 | + private Annotation getAnnotationForTerm(Ontology ontology) { |
| 73 | + return ontology.getTerm("SO:0000691").getAnnotation(); |
65 | 74 | } |
66 | 75 | } |
0 commit comments