public static void Main(string[] args) { ArraysPkgNamespaces arraysNs = new ArraysPkgNamespaces(); SBMLDocument doc = new SBMLDocument(arraysNs); doc.setPackageRequired("arrays", true); Model model = doc.createModel(); // create compartment Compartment comp = model.createCompartment(); comp.setMetaId("dd"); comp.setId("s"); comp.setConstant(true); // set dimensions ArraysSBasePlugin compPlugin = (ArraysSBasePlugin)comp.getPlugin("arrays"); Dimension dim = compPlugin.createDimension(); dim.setId("i"); dim.setSize("n"); // create species Species species = model.createSpecies(); species.setId("A"); species.setCompartment("s"); species.setHasOnlySubstanceUnits(false); species.setBoundaryCondition(false); species.setConstant(false); ArraysSBasePlugin splugin = (ArraysSBasePlugin)species.getPlugin("arrays"); dim = splugin.createDimension(); dim.setId("i"); dim.setSize("n"); species = model.createSpecies(); species.setId("B"); species.setCompartment("s"); species.setHasOnlySubstanceUnits(false); species.setBoundaryCondition(false); species.setConstant(false); splugin = (ArraysSBasePlugin)species.getPlugin("arrays"); dim = splugin.createDimension(); dim.setId("i"); dim.setSize("n"); species = model.createSpecies(); species.setId("C"); species.setCompartment("s"); species.setHasOnlySubstanceUnits(false); species.setBoundaryCondition(false); species.setConstant(false); splugin = (ArraysSBasePlugin)species.getPlugin("arrays"); dim = splugin.createDimension(); dim.setId("i"); dim.setSize("n"); // create parameter Parameter param = model.createParameter(); param.setId("n"); param.setValue(100); param.setConstant(true); // create reaction Reaction reaction = model.createReaction(); reaction.setId("reaction1"); reaction.setReversible(false); reaction.setFast(false); ArraysSBasePlugin reactionPlugin = (ArraysSBasePlugin)reaction.getPlugin("arrays"); dim = reactionPlugin.createDimension(); dim.setId("i"); dim.setSize("n"); SpeciesReference speciesRef = reaction.createReactant(); speciesRef.setSpecies("A"); speciesRef.setConstant(false); ArraysSBasePlugin refPlugin = (ArraysSBasePlugin)speciesRef.getPlugin("arrays"); Index index = refPlugin.createIndex(); ASTNode ast = new ASTNode(libsbml.AST_LINEAR_ALGEBRA_SELECTOR); ASTNode ci = new ASTNode(libsbml.AST_NAME); ci.setName("A"); ast.addChild(ci); ci = new ASTNode(libsbml.AST_NAME); ci.setName("i"); ast.addChild(ci); index.setMath(ast); speciesRef = reaction.createProduct(); speciesRef.setSpecies("C"); speciesRef.setConstant(false); refPlugin = (ArraysSBasePlugin)speciesRef.getPlugin("arrays"); index = refPlugin.createIndex(); ast = new ASTNode(libsbml.AST_LINEAR_ALGEBRA_SELECTOR); ci = new ASTNode(libsbml.AST_NAME); ci.setName("C"); ast.addChild(ci); ci = new ASTNode(libsbml.AST_NAME); ci.setName("i"); ast.addChild(ci); index.setMath(ast); libsbml.writeSBMLToFile(doc, "arrays1.xml"); }
public void test_RDFAnnotation_parseCVTerms() { XMLNode node = RDFAnnotationParser.parseCVTerms(m.getCompartment(0)); assertTrue(node.getNumChildren() == 1); XMLNode rdf = node.getChild(0); assertTrue(("RDF" == rdf.getName())); assertTrue(("rdf" == rdf.getPrefix())); assertTrue(("http://www.w3.org/1999/02/22-rdf-syntax-ns#" == rdf.getURI())); assertTrue(rdf.getNumChildren() == 1); XMLNode desc = rdf.getChild(0); assertTrue(("Description" == desc.getName())); assertTrue(("rdf" == desc.getPrefix())); assertTrue(("http://www.w3.org/1999/02/22-rdf-syntax-ns#" == desc.getURI())); assertTrue(desc.getNumChildren() == 1); XMLNode is1 = desc.getChild(0); assertTrue(("is" == is1.getName())); assertTrue(("bqbiol" == is1.getPrefix())); assertTrue(is1.getNumChildren() == 1); XMLNode Bag = is1.getChild(0); assertTrue(("Bag" == Bag.getName())); assertTrue(("rdf" == Bag.getPrefix())); assertTrue(("http://www.w3.org/1999/02/22-rdf-syntax-ns#" == Bag.getURI())); assertTrue(Bag.getNumChildren() == 4); XMLNode li = Bag.getChild(0); assertTrue(("li" == li.getName())); assertTrue(("rdf" == li.getPrefix())); assertTrue(("http://www.w3.org/1999/02/22-rdf-syntax-ns#" == li.getURI())); assertTrue(li.getNumChildren() == 0); XMLNode li1 = Bag.getChild(1); assertTrue(("li" == li1.getName())); assertTrue(("rdf" == li1.getPrefix())); assertTrue(("http://www.w3.org/1999/02/22-rdf-syntax-ns#" == li1.getURI())); assertTrue(li1.getNumChildren() == 0); XMLNode li2 = Bag.getChild(2); assertTrue(("li" == li2.getName())); assertTrue(("rdf" == li2.getPrefix())); assertTrue(("http://www.w3.org/1999/02/22-rdf-syntax-ns#" == li2.getURI())); assertTrue(li2.getNumChildren() == 0); XMLNode li3 = Bag.getChild(3); assertTrue(("li" == li3.getName())); assertTrue(("rdf" == li3.getPrefix())); assertTrue(("http://www.w3.org/1999/02/22-rdf-syntax-ns#" == li3.getURI())); assertTrue(li3.getNumChildren() == 0); node = null; XMLNode node1 = RDFAnnotationParser.parseCVTerms(null); assertTrue(node1 == null); node1 = RDFAnnotationParser.createCVTerms(null); assertTrue(node1 == null); node1 = RDFAnnotationParser.parseCVTerms(m.getCompartment(2)); assertTrue(node1 == null); node1 = RDFAnnotationParser.createCVTerms(m.getCompartment(2)); assertTrue(node1 == null); node1 = RDFAnnotationParser.parseCVTerms(m); assertTrue(node1 == null); node1 = RDFAnnotationParser.createCVTerms(m); assertTrue(node1 == null); Compartment c = new Compartment(3, 1); c.setMetaId("_002"); node1 = RDFAnnotationParser.parseCVTerms(c); assertTrue(node1 == null); node1 = RDFAnnotationParser.createCVTerms(c); assertTrue(node1 == null); CVTerm cv = new CVTerm(libsbml.BIOLOGICAL_QUALIFIER); cv.setBiologicalQualifierType(23); cv.addResource("http://myres"); c.addCVTerm(cv); node1 = RDFAnnotationParser.createCVTerms(c); assertTrue(node1 == null); c = null; Model m1 = new Model(3, 1); m1.setMetaId("_002"); cv = new CVTerm(libsbml.MODEL_QUALIFIER); cv.setModelQualifierType(23); cv.addResource("http://myres"); m1.addCVTerm(cv); node1 = RDFAnnotationParser.createCVTerms(m1); assertTrue(node1 == null); }