Beispiel #1
0
        public void test_XMLToken_namespace_set_clear()
        {
            XMLTriple     triple = new  XMLTriple("test", "", "");
            XMLAttributes attr   = new  XMLAttributes();
            XMLToken      token  = new  XMLToken(triple, attr);
            XMLNamespaces ns     = new  XMLNamespaces();

            assertTrue(token.getNamespacesLength() == 0);
            assertTrue(token.isNamespacesEmpty() == true);
            ns.add("http://test1.org/", "test1");
            ns.add("http://test2.org/", "test2");
            ns.add("http://test3.org/", "test3");
            ns.add("http://test4.org/", "test4");
            ns.add("http://test5.org/", "test5");
            token.setNamespaces(ns);
            assertTrue(token.getNamespacesLength() == 5);
            assertTrue(token.isNamespacesEmpty() == false);
            assertTrue(("test1" != token.getNamespacePrefix(0)) == false);
            assertTrue(("test2" != token.getNamespacePrefix(1)) == false);
            assertTrue(("test3" != token.getNamespacePrefix(2)) == false);
            assertTrue(("test4" != token.getNamespacePrefix(3)) == false);
            assertTrue(("test5" != token.getNamespacePrefix(4)) == false);
            assertTrue(("http://test1.org/" != token.getNamespaceURI(0)) == false);
            assertTrue(("http://test2.org/" != token.getNamespaceURI(1)) == false);
            assertTrue(("http://test3.org/" != token.getNamespaceURI(2)) == false);
            assertTrue(("http://test4.org/" != token.getNamespaceURI(3)) == false);
            assertTrue(("http://test5.org/" != token.getNamespaceURI(4)) == false);
            token.clearNamespaces();
            assertTrue(token.getNamespacesLength() == 0);
            ns     = null;
            token  = null;
            triple = null;
            attr   = null;
        }
Beispiel #2
0
        public void test_L3_SpeciesReference_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(3, 1);

            sbmlns.addNamespaces(xmlns);
            SpeciesReference sr = new  SpeciesReference(sbmlns);

            assertTrue(sr.getTypeCode() == libsbml.SBML_SPECIES_REFERENCE);
            assertTrue(sr.getMetaId() == "");
            assertTrue(sr.getNotes() == null);
            assertTrue(sr.getAnnotation() == null);
            assertTrue(sr.getLevel() == 3);
            assertTrue(sr.getVersion() == 1);
            assertTrue(sr.getNamespaces() != null);
            assertTrue(sr.getNamespaces().getLength() == 2);
            assertTrue(sr.getId() == "");
            assertTrue(sr.getName() == "");
            assertTrue(sr.getSpecies() == "");
            assertEquals(true, isnan(sr.getStoichiometry()));
            assertTrue(sr.getConstant() == false);
            assertEquals(false, sr.isSetId());
            assertEquals(false, sr.isSetName());
            assertEquals(false, sr.isSetSpecies());
            assertEquals(false, sr.isSetStoichiometry());
            assertEquals(false, sr.isSetConstant());
            sr = null;
        }
        public void test_L3_Event_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(3, 1);

            sbmlns.addNamespaces(xmlns);
            Event e = new  Event(sbmlns);

            assertTrue(e.getTypeCode() == libsbml.SBML_EVENT);
            assertTrue(e.getMetaId() == "");
            assertTrue(e.getNotes() == null);
            assertTrue(e.getAnnotation() == null);
            assertTrue(e.getLevel() == 3);
            assertTrue(e.getVersion() == 1);
            assertTrue(e.getNamespaces() != null);
            assertTrue(e.getNamespaces().getLength() == 2);
            assertTrue(e.getId() == "");
            assertTrue(e.getName() == "");
            assertTrue(e.getUseValuesFromTriggerTime() == true);
            assertEquals(false, e.isSetId());
            assertEquals(false, e.isSetName());
            assertEquals(false, e.isSetUseValuesFromTriggerTime());
            e = null;
        }
Beispiel #4
0
        public void test_L3_Unit_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(3, 1);

            sbmlns.addNamespaces(xmlns);
            Unit u = new  Unit(sbmlns);

            assertTrue(u.getTypeCode() == libsbml.SBML_UNIT);
            assertTrue(u.getMetaId() == "");
            assertTrue(u.getNotes() == null);
            assertTrue(u.getAnnotation() == null);
            assertTrue(u.getLevel() == 3);
            assertTrue(u.getVersion() == 1);
            assertTrue(u.getNamespaces() != null);
            assertTrue(u.getNamespaces().getLength() == 2);
            assertTrue(u.getKind() == libsbml.UNIT_KIND_INVALID);
            assertEquals(true, isnan(u.getExponentAsDouble()));
            assertEquals(true, isnan(u.getMultiplier()));
            assertEquals(false, u.isSetKind());
            assertEquals(false, u.isSetExponent());
            assertEquals(false, u.isSetMultiplier());
            assertEquals(false, u.isSetScale());
            u = null;
        }
        public void test_Constraint_setMessage2()
        {
            XMLNode       text   = XMLNode.convertStringToXMLNode(" Some text ", null);
            XMLTriple     triple = new  XMLTriple("p", "http://www.w3.org/1999/xhtml", "");
            XMLAttributes att    = new  XMLAttributes();
            XMLNamespaces xmlns  = new  XMLNamespaces();

            xmlns.add("http://www.w3.org/1999/xhtml", "");
            XMLNode p = new XMLNode(triple, att, xmlns);

            p.addChild(text);
            XMLTriple     triple1 = new  XMLTriple("message", "", "");
            XMLAttributes att1    = new  XMLAttributes();
            XMLNode       node    = new XMLNode(triple1, att1);

            node.addChild(p);
            int i = C.setMessage(node);

            assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS);
            assertTrue(C.isSetMessage() == true);
            i = C.unsetMessage();
            assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS);
            assertEquals(false, C.isSetMessage());
            if (C.getMessage() != null)
            {
                ;
            }
            {
            }
            node = null;
        }
Beispiel #6
0
        public void test_L3_Reaction_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(3, 1);

            sbmlns.addNamespaces(xmlns);
            Reaction r = new  Reaction(sbmlns);

            assertTrue(r.getTypeCode() == libsbml.SBML_REACTION);
            assertTrue(r.getMetaId() == "");
            assertTrue(r.getNotes() == null);
            assertTrue(r.getAnnotation() == null);
            assertTrue(r.getLevel() == 3);
            assertTrue(r.getVersion() == 1);
            assertTrue(r.getNamespaces() != null);
            assertTrue(r.getNamespaces().getLength() == 2);
            assertTrue(r.getId() == "");
            assertTrue(r.getName() == "");
            assertTrue(r.getCompartment() == "");
            assertTrue(r.getFast() == false);
            assertTrue(r.getReversible() == true);
            assertEquals(false, r.isSetId());
            assertEquals(false, r.isSetName());
            assertEquals(false, r.isSetCompartment());
            assertEquals(false, r.isSetFast());
            assertEquals(false, r.isSetReversible());
            r = null;
        }
        public void test_L3_Compartment_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(3, 1);

            sbmlns.addNamespaces(xmlns);
            Compartment c = new  Compartment(sbmlns);

            assertTrue(c.getTypeCode() == libsbml.SBML_COMPARTMENT);
            assertTrue(c.getMetaId() == "");
            assertTrue(c.getNotes() == null);
            assertTrue(c.getAnnotation() == null);
            assertTrue(c.getLevel() == 3);
            assertTrue(c.getVersion() == 1);
            assertTrue(c.getNamespaces() != null);
            assertTrue(c.getNamespaces().getLength() == 2);
            assertTrue(c.getId() == "");
            assertTrue(c.getName() == "");
            assertTrue(c.getUnits() == "");
            assertTrue(c.getOutside() == "");
            assertEquals(true, isnan(c.getSpatialDimensionsAsDouble()));
            assertEquals(true, isnan(c.getVolume()));
            assertTrue(c.getConstant() == true);
            assertEquals(false, c.isSetId());
            assertEquals(false, c.isSetSpatialDimensions());
            assertEquals(false, c.isSetName());
            assertEquals(false, c.isSetSize());
            assertEquals(false, c.isSetVolume());
            assertEquals(false, c.isSetUnits());
            assertEquals(false, c.isSetOutside());
            assertEquals(false, c.isSetConstant());
            c = null;
        }
        public void test_L3_Parameter_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(3, 1);

            sbmlns.addNamespaces(xmlns);
            Parameter p = new  Parameter(sbmlns);

            assertTrue(p.getTypeCode() == libsbml.SBML_PARAMETER);
            assertTrue(p.getMetaId() == "");
            assertTrue(p.getNotes() == null);
            assertTrue(p.getAnnotation() == null);
            assertTrue(p.getLevel() == 3);
            assertTrue(p.getVersion() == 1);
            assertTrue(p.getNamespaces() != null);
            assertTrue(p.getNamespaces().getLength() == 2);
            assertTrue(p.getId() == "");
            assertTrue(p.getName() == "");
            assertTrue(p.getUnits() == "");
            assertEquals(true, isnan(p.getValue()));
            assertTrue(p.getConstant() == true);
            assertEquals(false, p.isSetId());
            assertEquals(false, p.isSetName());
            assertEquals(false, p.isSetValue());
            assertEquals(false, p.isSetUnits());
            assertEquals(false, p.isSetConstant());
            p = null;
        }
        public void test_SyntaxChecker_validXHTML()
        {
            SBMLNamespaces NS24 = new  SBMLNamespaces(2, 4);
            SBMLNamespaces NS31 = new  SBMLNamespaces(3, 1);
            XMLToken       toptoken;
            XMLNode        topnode;
            XMLTriple      toptriple = new  XMLTriple("notes", "", "");
            XMLToken       token;
            XMLNode        node;
            XMLTriple      triple = new  XMLTriple("p", "", "");
            XMLAttributes  att    = new  XMLAttributes();
            XMLNamespaces  ns     = new  XMLNamespaces();

            ns.add("http://www.w3.org/1999/xhtml", "");
            XMLToken tt = new  XMLToken("This is my text");
            XMLNode  n1 = new XMLNode(tt);

            toptoken = new  XMLToken(toptriple, att);
            topnode  = new XMLNode(toptoken);
            token    = new  XMLToken(triple, att, ns);
            node     = new XMLNode(token);
            node.addChild(n1);
            topnode.addChild(node);
            assertTrue(SyntaxChecker.hasExpectedXHTMLSyntax(topnode, null) == true);
            assertTrue(SyntaxChecker.hasExpectedXHTMLSyntax(topnode, NS24) == true);
            assertTrue(SyntaxChecker.hasExpectedXHTMLSyntax(topnode, NS31) == true);
            triple = new  XMLTriple("html", "", "");
            token  = new  XMLToken(triple, att, ns);
            node   = new XMLNode(token);
            node.addChild(n1);
            topnode.removeChild(0);
            topnode.addChild(node);
            assertTrue(SyntaxChecker.hasExpectedXHTMLSyntax(topnode, null) == true);
            assertTrue(SyntaxChecker.hasExpectedXHTMLSyntax(topnode, NS24) == false);
            assertTrue(SyntaxChecker.hasExpectedXHTMLSyntax(topnode, NS31) == true);
            triple = new  XMLTriple("html", "", "");
            ns.clear();
            token = new  XMLToken(triple, att, ns);
            node  = new XMLNode(token);
            node.addChild(n1);
            topnode.removeChild(0);
            topnode.addChild(node);
            assertTrue(SyntaxChecker.hasExpectedXHTMLSyntax(topnode, null) == false);
            assertTrue(SyntaxChecker.hasExpectedXHTMLSyntax(topnode, NS24) == false);
            assertTrue(SyntaxChecker.hasExpectedXHTMLSyntax(topnode, NS31) == false);
        }
Beispiel #10
0
        public void test_XMLToken_newSetters_setNamespaces2()
        {
            int           i;
            XMLTriple     triple = new  XMLTriple("test", "", "");
            XMLToken      token  = new  XMLToken(triple);
            XMLNamespaces ns     = new  XMLNamespaces();

            assertTrue(token.getNamespacesLength() == 0);
            assertTrue(token.isNamespacesEmpty() == true);
            ns.add("http://test1.org/", "test1");
            i = token.setNamespaces(ns);
            assertTrue(i == libsbml.LIBSBML_INVALID_XML_OPERATION);
            assertTrue(token.getNamespacesLength() == 0);
            assertTrue(token.isNamespacesEmpty() == true);
            triple = null;
            token  = null;
            ns     = null;
        }
        public void test_NS_copyConstructor()
        {
            XMLNamespaces ns = new XMLNamespaces();

            ns.add("http://test1.org/", "test1");
            assertTrue(ns.getLength() == 1);
            assertTrue(ns.isEmpty() == false);
            assertTrue(ns.getPrefix(0) == "test1");
            assertTrue(ns.getURI("test1") == "http://test1.org/");
            XMLNamespaces ns2 = new XMLNamespaces(ns);

            assertTrue(ns2.getLength() == 1);
            assertTrue(ns2.isEmpty() == false);
            assertTrue(ns2.getPrefix(0) == "test1");
            assertTrue(ns2.getURI("test1") == "http://test1.org/");
            ns2 = null;
            ns  = null;
        }
Beispiel #12
0
        public void test_Constraint_assignmentOperator()
        {
            Constraint o1 = new Constraint(2, 4);

            o1.setMetaId("c");
            assertTrue(o1.getMetaId() == "c");
            XMLNode       text   = XMLNode.convertStringToXMLNode(" Some text ");
            XMLTriple     triple = new XMLTriple("p", "http://www.w3.org/1999/xhtml", "");
            XMLAttributes att    = new XMLAttributes();
            XMLNamespaces xmlns  = new XMLNamespaces();

            xmlns.add("http://www.w3.org/1999/xhtml");
            XMLNode p = new XMLNode(triple, att, xmlns);

            p.addChild(text);
            XMLTriple     triple1 = new XMLTriple("message", "", "");
            XMLAttributes att1    = new XMLAttributes();
            XMLNode       message = new XMLNode(triple1, att1);

            message.addChild(p);
            ASTNode math = new ASTNode(libsbml.AST_CONSTANT_PI);

            o1.setMath(math);
            o1.setMessage(message);
            math    = null;
            message = null;
            XMLNode msg;

            assertTrue(o1.getMath() != null);
            msg = o1.getMessage();
            assertTrue(msg != null);
            Constraint o2 = new Constraint(2, 4);

            o2 = o1;
            assertTrue(o2.getMetaId() == "c");
            assertTrue(o2.getMath() != null);
            msg = o2.getMessage();
            assertTrue(msg != null);
            assertTrue(o2.getParentSBMLObject() == o1.getParentSBMLObject());
            o2 = null;
            o1 = null;
        }
        public void test_EventAssignment_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(2, 1);

            sbmlns.addNamespaces(xmlns);
            EventAssignment object1 = new  EventAssignment(sbmlns);

            assertTrue(object1.getTypeCode() == libsbml.SBML_EVENT_ASSIGNMENT);
            assertTrue(object1.getMetaId() == "");
            assertTrue(object1.getNotes() == null);
            assertTrue(object1.getAnnotation() == null);
            assertTrue(object1.getLevel() == 2);
            assertTrue(object1.getVersion() == 1);
            assertTrue(object1.getNamespaces() != null);
            assertTrue(object1.getNamespaces().getLength() == 2);
            object1 = null;
        }
Beispiel #14
0
        public void test_Constraint_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(2, 2);

            sbmlns.addNamespaces(xmlns);
            Constraint object1 = new  Constraint(sbmlns);

            assertTrue(object1.getTypeCode() == libsbml.SBML_CONSTRAINT);
            assertTrue(object1.getMetaId() == "");
            assertTrue(object1.getNotes() == null);
            assertTrue(object1.getAnnotation() == null);
            assertTrue(object1.getLevel() == 2);
            assertTrue(object1.getVersion() == 2);
            assertTrue(object1.getNamespaces() != null);
            assertTrue(object1.getNamespaces().getLength() == 2);
            object1 = null;
        }
        public void test_StoichiometryMath_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(2, 1);

            sbmlns.addNamespaces(xmlns);
            StoichiometryMath object1 = new  StoichiometryMath(sbmlns);

            assertTrue(object1.getTypeCode() == libsbml.SBML_STOICHIOMETRY_MATH);
            assertTrue(object1.getMetaId() == "");
            assertTrue(object1.getNotes() == null);
            assertTrue(object1.getAnnotation() == null);
            assertTrue(object1.getLevel() == 2);
            assertTrue(object1.getVersion() == 1);
            assertTrue(object1.getNamespaces() != null);
            assertTrue(object1.getNamespaces().getLength() == 2);
            object1 = null;
        }
        public void test_UnitDefinition_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(2, 1);

            sbmlns.addNamespaces(xmlns);
            UnitDefinition object1 = new  UnitDefinition(sbmlns);

            assertTrue(object1.getTypeCode() == libsbml.SBML_UNIT_DEFINITION);
            assertTrue(object1.getMetaId() == "");
            assertTrue(object1.getNotes() == null);
            assertTrue(object1.getAnnotation() == null);
            assertTrue(object1.getLevel() == 2);
            assertTrue(object1.getVersion() == 1);
            assertTrue(object1.getNamespaces() != null);
            assertTrue(object1.getNamespaces().getLength() == 2);
            object1 = null;
        }
Beispiel #17
0
        public void test_Priority_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(3, 1);

            sbmlns.addNamespaces(xmlns);
            Priority object1 = new  Priority(sbmlns);

            assertTrue(object1.getTypeCode() == libsbml.SBML_PRIORITY);
            assertTrue(object1.getMetaId() == "");
            assertTrue(object1.getNotes() == null);
            assertTrue(object1.getAnnotation() == null);
            assertTrue(object1.getLevel() == 3);
            assertTrue(object1.getVersion() == 1);
            assertTrue(object1.getNamespaces() != null);
            assertTrue(object1.getNamespaces().getLength() == 2);
            object1 = null;
        }
Beispiel #18
0
        public void test_RateRule_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(2, 1);

            sbmlns.addNamespaces(xmlns);
            Rule object1 = new  RateRule(sbmlns);

            assertTrue(object1.getTypeCode() == libsbml.SBML_RATE_RULE);
            assertTrue(object1.getMetaId() == "");
            assertTrue(object1.getNotes() == null);
            assertTrue(object1.getAnnotation() == null);
            assertTrue(object1.getLevel() == 2);
            assertTrue(object1.getVersion() == 1);
            assertTrue(object1.getNamespaces() != null);
            assertTrue(object1.getNamespaces().getLength() == 2);
            object1 = null;
        }
        public void test_Parameter_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(2, 1);

            sbmlns.addNamespaces(xmlns);
            Parameter object1 = new  Parameter(sbmlns);

            assertTrue(object1.getTypeCode() == libsbml.SBML_PARAMETER);
            assertTrue(object1.getMetaId() == "");
            assertTrue(object1.getNotes() == null);
            assertTrue(object1.getAnnotation() == null);
            assertTrue(object1.getLevel() == 2);
            assertTrue(object1.getVersion() == 1);
            assertTrue(object1.getNamespaces() != null);
            assertTrue(object1.getNamespaces().getLength() == 2);
            object1 = null;
        }
Beispiel #20
0
        public void test_AlgebraicRule_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(2, 3);

            sbmlns.addNamespaces(xmlns);
            Rule r = new  AlgebraicRule(sbmlns);

            assertTrue(r.getTypeCode() == libsbml.SBML_ALGEBRAIC_RULE);
            assertTrue(r.getMetaId() == "");
            assertTrue(r.getNotes() == null);
            assertTrue(r.getAnnotation() == null);
            assertTrue(r.getLevel() == 2);
            assertTrue(r.getVersion() == 3);
            assertTrue(r.getNamespaces() != null);
            assertTrue(r.getNamespaces().getLength() == 2);
            r = null;
        }
        public void test_SpeciesType_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(2, 2);

            sbmlns.addNamespaces(xmlns);
            SpeciesType object1 = new  SpeciesType(sbmlns);

            assertTrue(object1.getTypeCode() == libsbml.SBML_SPECIES_TYPE);
            assertTrue(object1.getMetaId() == "");
            assertTrue(object1.getNotes() == null);
            assertTrue(object1.getAnnotation() == null);
            assertTrue(object1.getLevel() == 2);
            assertTrue(object1.getVersion() == 2);
            assertTrue(object1.getNamespaces() != null);
            assertTrue(object1.getNamespaces().getLength() == 2);
            object1 = null;
        }
        public void test_KineticLaw_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(2, 1);

            sbmlns.addNamespaces(xmlns);
            KineticLaw object1 = new  KineticLaw(sbmlns);

            assertTrue(object1.getTypeCode() == libsbml.SBML_KINETIC_LAW);
            assertTrue(object1.getMetaId() == "");
            assertTrue(object1.getNotes() == null);
            assertTrue(object1.getAnnotation() == null);
            assertTrue(object1.getLevel() == 2);
            assertTrue(object1.getVersion() == 1);
            assertTrue(object1.getNamespaces() != null);
            assertTrue(object1.getNamespaces().getLength() == 2);
            object1 = null;
        }
Beispiel #23
0
        public void test_XMLToken_newSetters_setNamespaces1()
        {
            XMLTriple     triple = new  XMLTriple("test", "", "");
            XMLAttributes attr   = new  XMLAttributes();
            XMLToken      token  = new  XMLToken(triple, attr);
            XMLNamespaces ns     = new  XMLNamespaces();

            assertTrue(token.getNamespacesLength() == 0);
            assertTrue(token.isNamespacesEmpty() == true);
            ns.add("http://test1.org/", "test1");
            int i = token.setNamespaces(ns);

            assertTrue(i == libsbml.LIBSBML_OPERATION_SUCCESS);
            assertTrue(token.getNamespacesLength() == 1);
            assertTrue(token.isNamespacesEmpty() == false);
            attr   = null;
            triple = null;
            token  = null;
            ns     = null;
        }
Beispiel #24
0
        public void test_XMLNode_getters()
        {
            XMLToken      token;
            XMLNode       node;
            XMLTriple     triple;
            XMLAttributes attr;
            XMLNamespaces NS;

            NS = new  XMLNamespaces();
            NS.add("http://test1.org/", "test1");
            token = new  XMLToken("This is a test");
            node  = new XMLNode(token);
            assertTrue(node != null);
            assertTrue(node.getNumChildren() == 0);
            assertTrue(("This is a test" != node.getCharacters()) == false);
            assertTrue(node.getChild(1) != null);
            attr = new  XMLAttributes();
            assertTrue(attr != null);
            attr.add("attr2", "value");
            triple = new  XMLTriple("attr", "uri", "prefix");
            token  = new  XMLToken(triple, attr);
            assertTrue(token != null);
            node = new XMLNode(token);
            assertTrue(("attr" != node.getName()) == false);
            assertTrue(("uri" != node.getURI()) == false);
            assertTrue(("prefix" != node.getPrefix()) == false);
            XMLAttributes returnattr = node.getAttributes();

            assertTrue(("attr2" != returnattr.getName(0)) == false);
            assertTrue(("value" != returnattr.getValue(0)) == false);
            token = new  XMLToken(triple, attr, NS);
            node  = new XMLNode(token);
            XMLNamespaces returnNS = node.getNamespaces();

            assertTrue(returnNS.getLength() == 1);
            assertTrue(returnNS.isEmpty() == false);
            triple = null;
            token  = null;
            node   = null;
        }
        public void test_L3_Species_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(3, 1);

            sbmlns.addNamespaces(xmlns);
            Species s = new  Species(sbmlns);

            assertTrue(s.getTypeCode() == libsbml.SBML_SPECIES);
            assertTrue(s.getMetaId() == "");
            assertTrue(s.getNotes() == null);
            assertTrue(s.getAnnotation() == null);
            assertTrue(s.getLevel() == 3);
            assertTrue(s.getVersion() == 1);
            assertTrue(s.getNamespaces() != null);
            assertTrue(s.getNamespaces().getLength() == 2);
            assertTrue(s.getId() == "");
            assertTrue(s.getName() == "");
            assertTrue(s.getCompartment() == "");
            assertEquals(true, isnan(s.getInitialAmount()));
            assertEquals(true, isnan(s.getInitialConcentration()));
            assertTrue(s.getSubstanceUnits() == "");
            assertTrue(s.getHasOnlySubstanceUnits() == false);
            assertTrue(s.getBoundaryCondition() == false);
            assertTrue(s.getConstant() == false);
            assertTrue(s.getConversionFactor() == "");
            assertEquals(false, s.isSetId());
            assertEquals(false, s.isSetName());
            assertEquals(false, s.isSetCompartment());
            assertEquals(false, s.isSetInitialAmount());
            assertEquals(false, s.isSetInitialConcentration());
            assertEquals(false, s.isSetSubstanceUnits());
            assertEquals(false, s.isSetHasOnlySubstanceUnits());
            assertEquals(false, s.isSetBoundaryCondition());
            assertEquals(false, s.isSetConstant());
            assertEquals(false, s.isSetConversionFactor());
            s = null;
        }
Beispiel #26
0
        public void test_ModifierSpeciesReference_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(2, 1);

            sbmlns.addNamespaces(xmlns);
            SBase object1 = new  ModifierSpeciesReference(sbmlns);

            assertTrue(object1.getTypeCode() == libsbml.SBML_MODIFIER_SPECIES_REFERENCE);
            assertTrue(object1.getMetaId() == "");
            assertTrue(object1.getNotes() == null);
            assertTrue(object1.getAnnotation() == null);
            assertTrue(object1.getLevel() == 2);
            assertTrue(object1.getVersion() == 1);
            assertTrue(object1.getNamespaces() != null);
            XMLNamespaces n = object1.getNamespaces();

            assertTrue(n.getLength() == 2);
            object1 = null;
        }
Beispiel #27
0
        public void test_Compartment_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(2, 1);

            sbmlns.addNamespaces(xmlns);
            Compartment c = new  Compartment(sbmlns);

            assertTrue(c.getTypeCode() == libsbml.SBML_COMPARTMENT);
            assertTrue(c.getMetaId() == "");
            assertTrue(c.getNotes() == null);
            assertTrue(c.getAnnotation() == null);
            assertTrue(c.getLevel() == 2);
            assertTrue(c.getVersion() == 1);
            assertTrue(c.getNamespaces() != null);
            assertTrue(c.getNamespaces().getLength() == 2);
            assertTrue(c.getName() == "");
            assertTrue(c.getSpatialDimensions() == 3);
            assertTrue(c.getConstant() == true);
            c = null;
        }
Beispiel #28
0
        public void test_L3_Model_createWithNS()
        {
            XMLNamespaces xmlns = new  XMLNamespaces();

            xmlns.add("http://www.sbml.org", "testsbml");
            SBMLNamespaces sbmlns = new  SBMLNamespaces(3, 1);

            sbmlns.addNamespaces(xmlns);
            Model m = new  Model(sbmlns);

            assertTrue(m.getTypeCode() == libsbml.SBML_MODEL);
            assertTrue(m.getMetaId() == "");
            assertTrue(m.getNotes() == null);
            assertTrue(m.getAnnotation() == null);
            assertTrue(m.getLevel() == 3);
            assertTrue(m.getVersion() == 1);
            assertTrue(m.getNamespaces() != null);
            assertTrue(m.getNamespaces().getLength() == 2);
            assertTrue(m.getId() == "");
            assertTrue(m.getName() == "");
            assertTrue(m.getSubstanceUnits() == "");
            assertTrue(m.getTimeUnits() == "");
            assertTrue(m.getVolumeUnits() == "");
            assertTrue(m.getAreaUnits() == "");
            assertTrue(m.getLengthUnits() == "");
            assertTrue(m.getConversionFactor() == "");
            assertEquals(false, m.isSetId());
            assertEquals(false, m.isSetName());
            assertEquals(false, m.isSetSubstanceUnits());
            assertEquals(false, m.isSetTimeUnits());
            assertEquals(false, m.isSetVolumeUnits());
            assertEquals(false, m.isSetAreaUnits());
            assertEquals(false, m.isSetLengthUnits());
            assertEquals(false, m.isSetConversionFactor());
            m = null;
        }
Beispiel #29
0
    public static int Main(string[] args)
    {
        if (args.Length != 2)
        {
            Console.WriteLine("  usage: addingEvidenceCodes_2 <input-filename> <output-filename>");
            Console.WriteLine("  Adds controlled vocabulary term to a species");
            Console.WriteLine();
            return(2);
        }


        SBMLDocument d      = libsbml.readSBML(args[0]);
        long         errors = d.getNumErrors();

        if (errors > 0)
        {
            Console.WriteLine("Read Error(s):");
            d.printErrors();

            Console.WriteLine("Correct the above and re-run.");
        }
        else
        {
            long n = d.getModel().getNumSpecies();

            if (n <= 0)
            {
                Console.WriteLine("Model has no species.\n Cannot add CV terms\n");
            }
            else
            {
                Species s = d.getModel().getSpecies(0);

                /* check that the species has a metaid
                 * no CVTerms will be added if there is no metaid to reference
                 */
                if (!s.isSetMetaId())
                {
                    s.setMetaId("metaid_0000052");
                }

                CVTerm cv1 = new CVTerm(libsbml.BIOLOGICAL_QUALIFIER);
                cv1.setBiologicalQualifierType(libsbml.BQB_OCCURS_IN);
                cv1.addResource("urn:miriam:obo.go:GO%3A0005764");

                s.addCVTerm(cv1);

                // now create the additional annotation

                //<rdf:Statement>
                //  <rdf:subject rdf:resource="#metaid_0000052"/>
                //  <rdf:predicate rdf:resource="http://biomodels.net/biology-qualifiers/occursIn"/>
                //  <rdf:object rdf:resource="urn:miriam:obo.go:GO%3A0005764"/>
                //  <bqbiol:isDescribedBy>
                //    <rdf:Bag>
                //      <rdf:li rdf:resource="urn:miriam:obo.eco:ECO%3A0000004"/>
                //      <rdf:li rdf:resource="urn:miriam:pubmed:7017716"/>
                //    </rdf:Bag>
                //  </bqbiol:isDescribedBy>
                //</rdf:Statement>

                /* attributes */
                XMLAttributes blank_att = new XMLAttributes();

                XMLAttributes resource_att = new XMLAttributes();

                /* create the outer statement node */
                XMLTriple statement_triple = new XMLTriple("Statement",
                                                           "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                                                           "rdf");

                XMLToken statement_token = new XMLToken(statement_triple, blank_att);

                XMLNode statement = new XMLNode(statement_token);

                /*create the subject node */
                XMLTriple subject_triple = new XMLTriple("subject",
                                                         "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                                                         "rdf");

                resource_att.clear();
                resource_att.add("rdf:resource", "#" + s.getMetaId());

                XMLToken subject_token = new XMLToken(subject_triple, resource_att);

                XMLNode subject = new XMLNode(subject_token);


                /*create the predicate node */
                XMLTriple predicate_triple = new XMLTriple("predicate",
                                                           "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                                                           "rdf");

                resource_att.clear();
                resource_att.add("rdf:resource",
                                 "http://biomodels.net/biology-qualifiers/occursIn");

                XMLToken predicate_token = new XMLToken(predicate_triple, resource_att);

                XMLNode predicate = new XMLNode(predicate_token);

                /*create the object node */
                XMLTriple object_triple = new XMLTriple("object",
                                                        "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                                                        "rdf");

                resource_att.clear();
                resource_att.add("rdf:resource", "urn:miriam:obo.go:GO%3A0005764");

                XMLToken object_token = new XMLToken(object_triple, resource_att);

                XMLNode object_ = new XMLNode(object_token);

                /* create the bqbiol node */
                XMLTriple bqbiol_triple = new XMLTriple("isDescribedBy",
                                                        "http://biomodels.net/biology-qualifiers/",
                                                        "bqbiol");

                XMLToken bqbiol_token = new XMLToken(bqbiol_triple, blank_att);

                XMLNode bqbiol = new XMLNode(bqbiol_token);

                /* create the bag node */
                XMLTriple bag_triple = new XMLTriple("Bag",
                                                     "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                                                     "rdf");

                XMLToken bag_token = new XMLToken(bag_triple, blank_att);

                XMLNode bag = new XMLNode(bag_token);

                /* create each li node and add to the bag */
                XMLTriple li_triple = new XMLTriple("li",
                                                    "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                                                    "rdf");

                resource_att.clear();
                resource_att.add("rdf:resource", "urn:miriam:obo.eco:ECO%3A0000004");

                XMLToken li_token = new XMLToken(li_triple, resource_att);
                li_token.setEnd();

                XMLNode li = new XMLNode(li_token);

                bag.addChild(li);

                resource_att.clear();
                resource_att.add("rdf:resource", "urn:miriam:pubmed:7017716");
                li_token = new XMLToken(li_triple, resource_att);
                li_token.setEnd();
                li = new XMLNode(li_token);

                bag.addChild(li);

                /* add the bag to bqbiol */
                bqbiol.addChild(bag);

                /* add subject, predicate, object and bqbiol to statement */
                statement.addChild(subject);
                statement.addChild(predicate);
                statement.addChild(object_);
                statement.addChild(bqbiol);


                /* create a top-level RDF element
                 * this will ensure correct merging
                 */

                XMLNamespaces xmlns = new XMLNamespaces();
                xmlns.add("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf");
                xmlns.add("http://purl.org/dc/elements/1.1/", "dc");
                xmlns.add("http://purl.org/dc/terms/", "dcterms");
                xmlns.add("http://www.w3.org/2001/vcard-rdf/3.0#", "vCard");
                xmlns.add("http://biomodels.net/biology-qualifiers/", "bqbiol");
                xmlns.add("http://biomodels.net/model-qualifiers/", "bqmodel");

                XMLTriple RDF_triple = new XMLTriple("RDF",
                                                     "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                                                     "rdf");

                XMLToken RDF_token = new XMLToken(RDF_triple, blank_att, xmlns);

                XMLNode annotation = new XMLNode(RDF_token);

                /* add the staement node to the RDF node */
                annotation.addChild(statement);

                s.appendAnnotation(annotation);

                libsbml.writeSBML(d, args[1]);
            }
        }

        return((int)errors);
    }
 public void test_XMLNamespaces_add()
 {
     assertTrue(NS.getLength() == 0);
     assertTrue(NS.isEmpty() == true);
     NS.add("http://test1.org/", "test1");
     assertTrue(NS.getLength() == 1);
     assertTrue(NS.isEmpty() == false);
     NS.add("http://test2.org/", "test2");
     assertTrue(NS.getLength() == 2);
     assertTrue(NS.isEmpty() == false);
     NS.add("http://test1.org/", "test1a");
     assertTrue(NS.getLength() == 3);
     assertTrue(NS.isEmpty() == false);
     NS.add("http://test1.org/", "test1a");
     assertTrue(NS.getLength() == 3);
     assertTrue(NS.isEmpty() == false);
     assertTrue(!(NS.getIndex("http://test1.org/") == -1));
 }