From d70667fa4aa410f8b2ade3d8549f42141bfab69b Mon Sep 17 00:00:00 2001 From: IgorRodchenkov Date: Sun, 12 May 2024 17:28:34 -0400 Subject: [PATCH] Followed #54 - polished tests and added more comments. --- .../io/jsonld/JsonldBiopaxConverterTest.java | 35 +- .../src/test/resources/demo-pathway-xsd.owl | 515 ------------------ ...emo-pathway-noxsd.owl => demo-pathway.owl} | 8 +- 3 files changed, 16 insertions(+), 542 deletions(-) delete mode 100644 json-converter/src/test/resources/demo-pathway-xsd.owl rename json-converter/src/test/resources/{demo-pathway-noxsd.owl => demo-pathway.owl} (98%) diff --git a/json-converter/src/test/java/org/biopax/paxtools/io/jsonld/JsonldBiopaxConverterTest.java b/json-converter/src/test/java/org/biopax/paxtools/io/jsonld/JsonldBiopaxConverterTest.java index 75332a41..51f96e97 100644 --- a/json-converter/src/test/java/org/biopax/paxtools/io/jsonld/JsonldBiopaxConverterTest.java +++ b/json-converter/src/test/java/org/biopax/paxtools/io/jsonld/JsonldBiopaxConverterTest.java @@ -10,7 +10,7 @@ public class JsonldBiopaxConverterTest { @Test - final void test() throws IOException { + final void testPc5BmpSignalingPathway() throws IOException { File jsonldTestFileName = File.createTempFile("test", ".jsonld"); File rdfTestFileName = File.createTempFile("test", ".rdf"); @@ -26,10 +26,16 @@ final void test() throws IOException { } @Test - final void test2() throws IOException { + final void testSomePc14DemoPathway() throws IOException { JsonldConverter converter = new JsonldBiopaxConverter(); + // convert owl test file in resource directory to jsonld format - InputStream in = getClass().getResourceAsStream("/demo-pathway-xsd.owl"); + InputStream in = getClass().getResourceAsStream("/demo-pathway.owl"); + //- there is no rdf:datatype=... anymore; should be fine as the datatypes are defined in the biopax-level3.owl spec! + //todo: for some reason, Jena libs v4 or v5 fail at e.g. rdf:about="TEST_CHEBI:cs_26d67131a0608673ae6a683d1dad18f7", + //but jena v3 just prints warnings, e.g.: org.apache.jena.riot - [line: 155, col: 82] {W107} Bad URI: Code: 0/ILLEGAL_CHARACTER in SCHEME: The character violates the grammar rules for URIs/IRIs. + //howver, removing the underscore from TEST_CHEBI - makes those warning/errors go away... + ByteArrayOutputStream baos = new ByteArrayOutputStream(); converter.convertToJsonld(in, baos); String res = baos.toString("UTF-8"); @@ -40,27 +46,10 @@ final void test2() throws IOException { () -> Assertions.assertDoesNotThrow(() -> URI.create("http://bioregistry.io/chebi:20")), //good valid absolute URI () -> Assertions.assertTrue(res.contains("@id\" : \"http://bioregistry.io/chebi:20")), () -> Assertions.assertTrue(res.contains("@id\" : \"http://bioregistry.io/mi:0361")),//as long as it has 'http://' (valid abs. uri w/o schema would fail here due Jena bug) - () -> Assertions.assertTrue(res.contains("@id\" : \"chebi:20")), //unchanged - () -> Assertions.assertTrue(res.contains("\"@id\" : \"http://www.biopax.org/release/biopax-level3.owl#displayName\"")) - ); - } - - @Test - final void test3() throws IOException { - JsonldConverter converter = new JsonldBiopaxConverter(); - // convert owl test file in resource directory to jsonld format - InputStream in = getClass().getResourceAsStream("/demo-pathway-noxsd.owl"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - converter.convertToJsonld(in, baos); - String res = baos.toString("UTF-8"); - Assertions.assertAll( - () -> Assertions.assertThrows(IllegalArgumentException.class, () -> URI.create("http://")), - () -> Assertions.assertDoesNotThrow(() -> URI.create("bioregistry.io/chebi:20")), - () -> Assertions.assertDoesNotThrow(() -> URI.create("chebi:20")), - () -> Assertions.assertDoesNotThrow(() -> URI.create("http://bioregistry.io/chebi:28")), - () -> Assertions.assertTrue(res.contains("@id\" : \"http://bioregistry.io/chebi:28")), + () -> Assertions.assertTrue(res.contains("@id\" : \"chebi:20")), //CURIE of a standard/normalized SMR's UnificationXref () -> Assertions.assertTrue(res.contains("\"@id\" : \"http://www.biopax.org/release/biopax-level3.owl#displayName\"")), - () -> Assertions.assertTrue(res.contains("@id\" : \"chebi:28")) + () -> Assertions.assertTrue(res.contains("\"displayName\" : \"(+)-camphene\"")), //chebi:20 + () -> Assertions.assertTrue(res.contains("\"id\" : \"CHEBI:20\"")) //with jena v3 (e.g. 3.2.0 or 3.17.0) ); } diff --git a/json-converter/src/test/resources/demo-pathway-xsd.owl b/json-converter/src/test/resources/demo-pathway-xsd.owl deleted file mode 100644 index 0bfd9eec..00000000 --- a/json-converter/src/test/resources/demo-pathway-xsd.owl +++ /dev/null @@ -1,515 +0,0 @@ - - - - - - - - 562 - ncbitaxon - - - - CHEBI:20 - chebi - - - - - CHEBI:16651 - chebi - - - - - see-also - - - - - This example is meant to provide an illustration of how various BioPAX slots should be filled; it is not intended to provide useful (or even accurate) biological information - cytoplasm - - - - a-D-glu-6-p - beta-D-glucose 6-phosphate - - - b-D-glucose-6-phoshate - D-glucose-6-P - beeta-D-glucose-6-p - glucose-6-P - - - - - - - LEFT_TO_RIGHT - - - - - PMID: 9847135 - R01786 - kegg.reaction - - - - - CHEBI:98 - chebi - - - - - H2a/x - - - Histone H2A.x - Reactome DB_ID: 56151 - - - - - b-D-glu => b-D-glu-6-p - - beta-D-glu + ATP => beta-D-glu-6-p + ADP - - - true - 2.7.1.2 - 2.7.1.1 - - - ATP:D-glucose 6-phosphotransferase - glucose ATP phosphotransferase - - REVERSIBLE - - - - Müller (utf-8 issue #298) - 2549346 - pubmed - - - - - identity - - - - MI:0356 - mi - - - - - CHEBI:20 - chebi - - - - - CHEBI:89 - chebi - - - - - multiple parent reference - - - - ATP - Adenosine 5'-triphosphate - - - adenosine triphosphate - - - - - MI:0829 - mi - - - - - H2AX - hgnc.symbol - - - - InChI - InChI=1S/C10H18O/c1-5-10(4,11)8-6-7-9(2)3/h5,7,11H,1,6,8H2,2-4H3/t10-/m0/s1 - - - - - 10203 - ncbigene - - - - InChI - InChI=1S/C10H16/c1-7-8-4-5-9(6-8)10(7,2)3/h8-9H,1,4-6H2,2-3H3/t8-,9+/m0/s1 - - - - b-D-glu - beta-D-glucose - - - <FONT FACE="Symbol">a</FONT>-D-glucose - - - - - Reactome - Reactome - test - Source type: BIOPAX, Foo - - - - 0.4 - - - - MI:0361 - mi - - - - Q16602 - uniprot - - - - P16104 - uniprot - - - - - CHEBI:28 - chebi - - - - Histone H2AX - - - - - H2AX_HUMAN - H2AFX - Histone H2A.X - H2a/x - H2AX - H2AX_HUMAN Reviewed; 143 AA. - - - - - PGI -> (b-d-glu-6-p <=> b-D-fru-6p) - catalysis of (beta-D-glu-6-p <=> beta-D-fruc-6-p) - - ACTIVATION - LEFT_TO_RIGHT - The source of this data did not store catalyses of reactions as separate objects, so there are no unification x-refs pointing to the source of these BioPAX instances. - - - - - - - - - - glycolysis - - - Glycolysis Pathway - glucose degradation - Embden-Meyerhof pathway - This example is meant to provide an illustration of how various BioPAX slots should be filled; it is not intended to provide useful (or even accurate) biological information - see http://www.amaze.ulb.ac.be/ - All data within the pathway has the same availability - - - - - - Escherichia coliü - - - - PMID: 9847135 - R02740 - kegg.reaction - - - - PGI - phosphoglucose isomerase - - - - PHI - GPI - glucose-6-phosphate isomerase - phosphohexose isomerase - - - - - - CHEBI:422 - chebi - - - - ADP - - C10H15N5O10P2 - Adenosine 5'-diphosphate - adenosine diphosphate - 427.2 - - - - - PMID: 11483584 - GO:0005737 - go - - - - Calcitonin gene-related peptide type 1 receptor - - - - - CALRL_HUMAN - CGRPR - Calcitonin receptor-like receptor - CGRP type 1 receptor - CALCRL - CALRL_HUMAN Reviewed; 461 AA. - - - - (2S)-2-hydroxypropanoic acid - - - - - C3H6O3 - (S)-lactic acid - (+)-lactic acid - L-(+)-lactic acid - L-(+)-alpha-hydroxypropionic acid - C3H6O3 - L-Lactic acid - CHEBI:422 - (S)-(+)-lactic acid - L-Milchsaeure - (S)-2-hydroxypropanoic acid - C[C@H](O)C(O)=O - (S)-2-hydroxypropionic acid - is_enantiomer_of 42111 - is_conjugate_acid_of 16651 - An optically active form of lactic acid having (S)-configuration. - - - - - - GLK -> (a-D-glu <=> a-D-glu-6-p) - catalysis of (alpha-D-glu <=> alpha-D-glu-6-p) - - ACTIVATION - LEFT_TO_RIGHT - The source of this data did not store catalyses of reactions as separate objects, so there are no unification x-refs pointing to the source of these BioPAX instances. - - - - - - CALCRL - hgnc.symbol - - - - b-D-fru-6-p - beta-D-fructose-6-phosphate - - - <FONT FACE="Symbol">b</FONT>-D-fructose-6-phosphate - - - - - Homo sapiens - - Homo sapiens - - - - - - - - - CHEBI:42111 - chebi - - - - CHEBI:422 - chebi - - - - PMID: 9847135 - 14438 - pubchem.compound - - - - SMILES - ADP - c12(n(cnc(c(N)ncn1)2)[CH]3(O[CH]([CH](O)[CH](O)3)COP(=O)(O)OP(O)(=O)O)) - - - - 1 - REACT_3939 - reactome - - - - - LEFT_TO_RIGHT - - - - - - CHEBI:422 - chebi - - - - ADP - Adenosine 5'-diphosphate - - - adenosine diphosphate - - - - - b-D-glu-6-p <=> b-D-fru-6-p - - beta-D-glu-6-p <=> beta-D-fru-6-p - - - 5.3.1.9 - - beta-D-Glucose 6-phosphate => beta-D-Fructose 6-phosphate - beta-D-Glucose 6-phosphate ketol-isomerase - - REVERSIBLE - - - - (3R)-3,7-dimethylocta-1,6-dien-3-ol - - - - - - C10H18O - (R)-linalool - C10H18O - (-)-Linalool - (-)-3,7-dimethyl-1,6-octadien-3-ol - CC(C)=CCC[C@@](C)(O)C=C - (R)-(-)-Linalool - (3R)-3,7-dimethyl-1,6-octadien-3-ol - (R)-3,7-dimethyl-1,6-octadien-3-ol - has_part 20 - A linalool that has formula C10H18O. - is_conjugate_acid_of 422 - is_enantiomer_of 98 - - - - - - CHEBI:17580 - chebi - - - - 9606 - ncbitaxon - - - - - 3014 - ncbigene - - - - (1R,4S)-2,2-dimethyl-3-methylidenebicyclo[2.2.1]heptane - - - - C10H16 - (+)-camphene - (1R,4S)-camphene - (1R)-2,2-dimethyl-3-methylenebicyclo[2.2.1]heptane - C10H16 - (+)-Comphene - d-camphene - (1R,4S)-(+)-camphene - (1R,4S)-2,2-dimethyl-3-methylenebicyclo[2.2.1]heptane - (+)-Camphene - CC1(C)[C@@H]2CC[C@@H](C2)C1=C - is_enantiomer_of 89 - A camphene that has formula C10H16. - - - - - MOD:00046 - protein modification ontology - - - - - O-phospho-L-serine - - - - CHEBI:28 - chebi - - - - InChI - InChI=1S/C3H6O3/c1-2(4)3(5)6/h2,4H,1H3,(H,5,6)/t2-/m0/s1 - - \ No newline at end of file diff --git a/json-converter/src/test/resources/demo-pathway-noxsd.owl b/json-converter/src/test/resources/demo-pathway.owl similarity index 98% rename from json-converter/src/test/resources/demo-pathway-noxsd.owl rename to json-converter/src/test/resources/demo-pathway.owl index 1aa86efc..d4ebf8db 100644 --- a/json-converter/src/test/resources/demo-pathway-noxsd.owl +++ b/json-converter/src/test/resources/demo-pathway.owl @@ -158,7 +158,7 @@ ncbigene - + InChI InChI=1S/C10H16/c1-7-8-4-5-9(6-8)10(7,2)3/h8-9H,1,4-6H2,2-3H3/t8-,9+/m0/s1 @@ -329,7 +329,7 @@ is_enantiomer_of 42111 is_conjugate_acid_of 16651 An optically active form of lactic acid having (S)-configuration. - + @@ -490,7 +490,7 @@ CC1(C)[C@@H]2CC[C@@H](C2)C1=C is_enantiomer_of 89 A camphene that has formula C10H16. - + @@ -508,7 +508,7 @@ chebi - + InChI InChI=1S/C3H6O3/c1-2(4)3(5)6/h2,4H,1H3,(H,5,6)/t2-/m0/s1