From 62b6b210c2b0b643799121de5a78cbb11991dac4 Mon Sep 17 00:00:00 2001 From: Schmoho Date: Tue, 2 Aug 2022 14:10:24 +0200 Subject: [PATCH] isse #121 test #20 --- .../annotation/ReactionAnnotationTest.java | 79 +++++++++++++++++++ .../annotation/SpeciesAnnotationTest.java | 40 +++++++++- 2 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 src/test/java/edu/ucsd/sbrg/bigg/annotation/ReactionAnnotationTest.java diff --git a/src/test/java/edu/ucsd/sbrg/bigg/annotation/ReactionAnnotationTest.java b/src/test/java/edu/ucsd/sbrg/bigg/annotation/ReactionAnnotationTest.java new file mode 100644 index 00000000..b761a7f9 --- /dev/null +++ b/src/test/java/edu/ucsd/sbrg/bigg/annotation/ReactionAnnotationTest.java @@ -0,0 +1,79 @@ +package edu.ucsd.sbrg.bigg.annotation; + +import org.junit.jupiter.api.Test; +import org.sbml.jsbml.CVTerm; +import org.sbml.jsbml.Model; +import org.sbml.jsbml.ext.fbc.FBCConstants; +import org.sbml.jsbml.ext.fbc.FBCReactionPlugin; +import org.sbml.jsbml.ext.fbc.GeneProductRef; +import org.sbml.jsbml.ext.groups.GroupsConstants; +import org.sbml.jsbml.ext.groups.GroupsModelPlugin; +import org.sbml.jsbml.ext.groups.Member; + +import java.util.Set; +import java.util.stream.Collectors; + +import static edu.ucsd.sbrg.TestUtils.initParameters; +import static org.junit.jupiter.api.Assertions.*; + +public class ReactionAnnotationTest extends BiGGDBTest { + + @Test + public void getBiGGIdFromResourcesTest() { + initParameters(); + var m = new Model("iJO1366", 3, 2); + var r1 = m.createReaction("some_name"); + var r2 = m.createReaction("some_other_name"); + var r3 = m.createReaction("some_third_name"); + + r1.addCVTerm(new CVTerm( + CVTerm.Type.BIOLOGICAL_QUALIFIER, + CVTerm.Qualifier.BQB_IS, + "http://identifiers.org/biocyc/META:ACETATEKIN-RXN")); + + r2.addCVTerm(new CVTerm( + CVTerm.Type.BIOLOGICAL_QUALIFIER, + CVTerm.Qualifier.BQB_IS, + "http://identifiers.org/metanetx.reaction/MNXR103371")); + + r3.addCVTerm(new CVTerm( + CVTerm.Type.BIOLOGICAL_QUALIFIER, + CVTerm.Qualifier.BQB_IS, + "http://identifiers.org/kegg.reaction/R00299")); + + var gPlugin = (GroupsModelPlugin) m.getPlugin(GroupsConstants.shortLabel); + assertEquals(0, gPlugin.getGroupCount()); + + new ReactionAnnotation(r1).annotate(); + new ReactionAnnotation(r2).annotate(); + new ReactionAnnotation(r3).annotate(); + + var r1FbcPlugin = (FBCReactionPlugin) r1.getPlugin(FBCConstants.shortLabel); + var gpa1 = r1FbcPlugin.getGeneProductAssociation(); + assertNull(gpa1); + assertEquals(false, r1.isSetCompartment()); + assertEquals("", r1.getName()); + assertEquals(1, r1.getCVTermCount()); + assertEquals(1, r1.getCVTerm(0).getNumResources()); + + assertEquals(1, r2.getCVTermCount()); + assertEquals(1, r2.getCVTerm(0).getNumResources()); + + var r3FbcPlugin = (FBCReactionPlugin) r3.getPlugin(FBCConstants.shortLabel); + var gpa3 = r3FbcPlugin.getGeneProductAssociation(); + assertNotNull(gpa3); + assertEquals("G_b2388", ((GeneProductRef) gpa3.getAssociation()).getGeneProduct()); + assertEquals(false, r1.isSetCompartment()); + assertEquals("", r1.getName()); + assertEquals(1, r3.getCVTermCount()); + assertEquals(11, r3.getCVTerm(0).getNumResources()); + + assertEquals(1, gPlugin.getGroupCount()); + assertEquals("glycolysis/gluconeogenesis", gPlugin.getGroup(0).getName()); + assertEquals(Set.of("some_third_name"), gPlugin.getGroup(0) + .getListOfMembers().stream().map(Member::getIdRef).collect(Collectors.toSet())); + + assertFalse(r3.isSetListOfReactants()); + assertFalse(r3.isSetListOfProducts()); + } +} diff --git a/src/test/java/edu/ucsd/sbrg/bigg/annotation/SpeciesAnnotationTest.java b/src/test/java/edu/ucsd/sbrg/bigg/annotation/SpeciesAnnotationTest.java index f48ee29d..5af9192c 100644 --- a/src/test/java/edu/ucsd/sbrg/bigg/annotation/SpeciesAnnotationTest.java +++ b/src/test/java/edu/ucsd/sbrg/bigg/annotation/SpeciesAnnotationTest.java @@ -1,17 +1,19 @@ package edu.ucsd.sbrg.bigg.annotation; import edu.ucsd.sbrg.TestUtils; +import edu.ucsd.sbrg.bigg.ModelPolisherOptions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.sbml.jsbml.CVTerm; import org.sbml.jsbml.Model; +import org.sbml.jsbml.SBMLDocument; import org.sbml.jsbml.ext.fbc.FBCConstants; import org.sbml.jsbml.ext.fbc.FBCSpeciesPlugin; +import java.util.Map; import java.util.Set; -import static edu.ucsd.sbrg.TestUtils.assertCVTermIsPresent; -import static edu.ucsd.sbrg.TestUtils.assertCVTermsArePresent; +import static edu.ucsd.sbrg.TestUtils.*; import static org.junit.jupiter.api.Assertions.assertEquals; public class SpeciesAnnotationTest extends BiGGDBTest { @@ -195,5 +197,39 @@ public void H2OAnnotationTest() { } + /** + * Same principle as above, just testing for kegg and biocyc too. + */ + @Test + public void getBiGGIdFromResourcesTest() { + initParameters(Map.of( + ModelPolisherOptions.ANNOTATE_WITH_BIGG.getOptionName(), + "true", + ModelPolisherOptions.INCLUDE_ANY_URI.getOptionName(), + "true")); + var sbml = new SBMLDocument(3, 2); + var m = new Model("iJO1366", 3, 2); + sbml.setModel(m); + var s1 = m.createSpecies("some_name"); + var s2 = m.createSpecies("some_other_name"); + + s1.addCVTerm(new CVTerm( + CVTerm.Type.BIOLOGICAL_QUALIFIER, + CVTerm.Qualifier.BQB_IS, + "https://identifiers.org/kegg.compound/C00001")); + + s2.addCVTerm(new CVTerm( + CVTerm.Type.BIOLOGICAL_QUALIFIER, + CVTerm.Qualifier.BQB_IS, + "https://identifiers.org/biocyc/META:ATP")); + + var annotater = new BiGGAnnotation(); + annotater.annotate(sbml); + + assertEquals(1, s2.getCVTermCount()); + assertEquals(29, s1.getCVTerm(0).getNumResources()); + assertEquals(1, s2.getCVTermCount()); + assertEquals(30, s2.getCVTerm(0).getNumResources()); + } } \ No newline at end of file