Skip to content

Commit

Permalink
isse #121 test #20
Browse files Browse the repository at this point in the history
  • Loading branch information
Schmoho committed Aug 2, 2022
1 parent 2e1e7c6 commit 62b6b21
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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());
}

}

0 comments on commit 62b6b21

Please sign in to comment.