public void test_FunctionDefinition_createWith()
 {
     ASTNode math = libsbml.parseFormula("lambda(x, x^3)");
       FunctionDefinition fd = new  FunctionDefinition(2,4);
       fd.setId( "pow3");
       fd.setMath(math);
       ASTNode math1;
       string formula;
       assertTrue( fd.getTypeCode() == libsbml.SBML_FUNCTION_DEFINITION );
       assertTrue( fd.getMetaId() == "" );
       assertTrue( fd.getNotes() == null );
       assertTrue( fd.getAnnotation() == null );
       assertTrue( fd.getName() == "" );
       math1 = fd.getMath();
       assertTrue( math1 != null );
       formula = libsbml.formulaToString(math1);
       assertTrue( formula != null );
       assertTrue((  "lambda(x, x^3)" == formula ));
       assertTrue( fd.getMath() != math );
       assertEquals( true, fd.isSetMath() );
       assertTrue((  "pow3" == fd.getId() ));
       assertEquals( true, fd.isSetId() );
       math = null;
       fd = null;
 }
 public void setUp()
 {
     E = new  FunctionDefinition(2,4);
       if (E == null);
       {
       }
 }
Ejemplo n.º 3
0
 public void test_Model_getFunctionDefinitionById()
 {
     FunctionDefinition fd1 = new  FunctionDefinition(2,4);
       FunctionDefinition fd2 = new  FunctionDefinition(2,4);
       fd1.setId( "sin" );
       fd2.setId( "cos" );
       fd1.setMath(libsbml.parseFormula("2"));
       fd2.setMath(libsbml.parseFormula("2"));
       M.addFunctionDefinition(fd1);
       M.addFunctionDefinition(fd2);
       assertTrue( M.getNumFunctionDefinitions() == 2 );
       assertNotEquals(M.getFunctionDefinition( "sin" ),fd1);
       assertNotEquals(M.getFunctionDefinition( "cos" ),fd2);
       assertEquals(M.getFunctionDefinition( "tan" ),null);
 }
 public void test_FunctionDefinition()
 {
     FunctionDefinition fd = new FunctionDefinition(2,4);
       assertEquals( false, (fd.hasRequiredElements()) );
       fd.setMath(libsbml.parseFormula("fd"));
       assertEquals( true, fd.hasRequiredElements() );
       fd = null;
 }
 FunctionDefinition get(long n) {
    IntPtr cPtr = libsbmlPINVOKE.ListOfFunctionDefinitions_get__SWIG_0(swigCPtr, n);
    FunctionDefinition ret = (cPtr == IntPtr.Zero) ? null : new FunctionDefinition(cPtr, false);
    return ret;
  }
 FunctionDefinition remove(string sid) {
    IntPtr cPtr = libsbmlPINVOKE.ListOfFunctionDefinitions_remove__SWIG_1(swigCPtr, sid);
    FunctionDefinition ret = (cPtr == IntPtr.Zero) ? null : new FunctionDefinition(cPtr, true);
    if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }
Ejemplo n.º 7
0
 internal static HandleRef getCPtr(FunctionDefinition obj)
 {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
Ejemplo n.º 8
0
 public void test_Model_addFunctionDefinition4()
 {
     Model m = new  Model(2,2);
       FunctionDefinition fd = new  FunctionDefinition(2,2);
       fd.setId( "fd");
       fd.setMath(libsbml.parseFormula("fd"));
       FunctionDefinition fd1 = new  FunctionDefinition(2,2);
       fd1.setId( "fd");
       fd1.setMath(libsbml.parseFormula("fd"));
       int i = m.addFunctionDefinition(fd);
       assertTrue( i == libsbml.LIBSBML_OPERATION_SUCCESS );
       assertTrue( m.getNumFunctionDefinitions() == 1 );
       i = m.addFunctionDefinition(fd1);
       assertTrue( i == libsbml.LIBSBML_DUPLICATE_OBJECT_ID );
       assertTrue( m.getNumFunctionDefinitions() == 1 );
       fd = null;
       fd1 = null;
       m = null;
 }
 public void test_FunctionDefinition_parent_add()
 {
     FunctionDefinition fd = new FunctionDefinition(2,4);
       Model m = new Model(2,4);
       fd.setId("fd");
       fd.setMath(libsbml.parseFormula("l"));
       m.addFunctionDefinition(fd);
       fd = null;
       ListOf lo = m.getListOfFunctionDefinitions();
       assertTrue( lo == m.getFunctionDefinition(0).getParentSBMLObject() );
       assertTrue( m == lo.getParentSBMLObject() );
 }
 public void test_internal_consistency_check_99911_fd()
 {
     SBMLDocument d = new SBMLDocument(2,4);
       long errors;
       Model m = d.createModel();
       FunctionDefinition fd = new FunctionDefinition(2,4);
       d.setLevelAndVersion(2,1,false);
       fd.setId("fd");
       fd.setSBOTerm(2);
       m.addFunctionDefinition(fd);
       errors = d.checkInternalConsistency();
       assertTrue( errors == 0 );
       d = null;
 }
 public void test_internal_consistency_check_99912()
 {
     SBMLDocument d = new SBMLDocument(2,4);
       long errors;
       FunctionDefinition fd = new FunctionDefinition(2,4);
       Model m = d.createModel();
       d.setLevelAndVersion(1,2,false);
       Compartment c = m.createCompartment();
       c.setId("cc");
       c.setConstant(false);
       m.addFunctionDefinition(fd);
       errors = d.checkInternalConsistency();
       assertTrue( errors == 0 );
       d = null;
 }
Ejemplo n.º 12
0
 static void replaceFD(ASTNode math, FunctionDefinition fd, IdList idsToExclude)
 {
     libsbmlPINVOKE.SBMLTransforms_replaceFD__SWIG_0(ASTNode.getCPtr(math), FunctionDefinition.getCPtr(fd), IdList.getCPtr(idsToExclude));
 }
Ejemplo n.º 13
0
 static void replaceFD(ASTNode math, FunctionDefinition fd)
 {
     libsbmlPINVOKE.SBMLTransforms_replaceFD__SWIG_1(ASTNode.getCPtr(math), FunctionDefinition.getCPtr(fd));
 }
Ejemplo n.º 14
0
 FunctionDefinition(FunctionDefinition orig) : this(libsbmlPINVOKE.new_FunctionDefinition__SWIG_2(FunctionDefinition.getCPtr(orig)), true)
 {
     if (libsbmlPINVOKE.SWIGPendingException.Pending)
     {
         throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 15
0
 internal static HandleRef getCPtr(FunctionDefinition obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
 public void test_FunctionDefinition()
 {
     FunctionDefinition fd = new FunctionDefinition(2,4);
       assertEquals( false, (fd.hasRequiredAttributes()) );
       fd.setId("fd");
       assertEquals( true, fd.hasRequiredAttributes() );
       fd = null;
 }
Ejemplo n.º 17
0
 public void test_WriteSBML_FunctionDefinition_withSBO()
 {
     string expected = "<functionDefinition sboTerm=\"SBO:0000064\" id=\"pow3\">\n" +
     "  <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n" +
     "    <lambda>\n" +
     "      <bvar>\n" +
     "        <ci> x </ci>\n" +
     "      </bvar>\n" +
     "      <apply>\n" +
     "        <power/>\n" +
     "        <ci> x </ci>\n" +
     "        <cn type=\"integer\"> 3 </cn>\n" +
     "      </apply>\n" +
     "    </lambda>\n" +
     "  </math>\n" +
     "</functionDefinition>";
       FunctionDefinition fd = new FunctionDefinition ( 2,4 );
       fd.setId("pow3");
       fd.setMath(libsbml.parseFormula("lambda(x, x^3)"));
       fd.setSBOTerm(64);
       assertEquals( true, equals(expected,fd.toSBML()) );
 }
 public void tearDown()
 {
     FD = null;
 }
Ejemplo n.º 19
0
 public void test_Model_addFunctionDefinition2()
 {
     Model m = new  Model(2,2);
       FunctionDefinition fd = new  FunctionDefinition(2,1);
       fd.setId( "fd");
       fd.setMath(libsbml.parseFormula("fd"));
       int i = m.addFunctionDefinition(fd);
       assertTrue( i == libsbml.LIBSBML_VERSION_MISMATCH );
       assertTrue( m.getNumFunctionDefinitions() == 0 );
       fd = null;
       m = null;
 }
Ejemplo n.º 20
0
 /** */
 /* libsbml-internal */
 public static void replaceFD(ASTNode math, FunctionDefinition fd, IdList idsToExclude)
 {
     libsbmlPINVOKE.SBMLTransforms_replaceFD__SWIG_0(ASTNode.getCPtr(math), FunctionDefinition.getCPtr(fd), IdList.getCPtr(idsToExclude));
 }
Ejemplo n.º 21
0
 public void test_FunctionDefinition_ancestor_add()
 {
     FunctionDefinition fd = new FunctionDefinition(2,4);
       Model m = new Model(2,4);
       fd.setId("fd");
       fd.setMath(libsbml.parseFormula("l"));
       m.addFunctionDefinition(fd);
       fd = null;
       ListOf lo = m.getListOfFunctionDefinitions();
       FunctionDefinition obj = m.getFunctionDefinition(0);
       assertTrue( obj.getAncestorOfType(libsbml.SBML_MODEL) == m );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == null );
       assertTrue( obj.getAncestorOfType(libsbml.SBML_EVENT) == null );
 }
Ejemplo n.º 22
0
 /**
    * Adds a copy of the given FunctionDefinition object to this Model.
    *
    * @param fd the FunctionDefinition to add
    *
    *
  * @return integer value indicating success/failure of the
  * function.  @if clike The value is drawn from the
  * enumeration #OperationReturnValues_t. @endif The possible values
  * returned by this function are:
  * @li @link libsbml#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS@endlink
    * @li @link libsbml#LIBSBML_LEVEL_MISMATCH LIBSBML_LEVEL_MISMATCH@endlink
    * @li @link libsbml#LIBSBML_VERSION_MISMATCH LIBSBML_VERSION_MISMATCH@endlink
    * @li @link libsbml#LIBSBML_DUPLICATE_OBJECT_ID LIBSBML_DUPLICATE_OBJECT_ID@endlink
    * @li @link libsbml#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT@endlink
    * @li @link libsbml#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED@endlink
    *
    *
  * @note This method should be used with some caution.  The fact that this
  * method @em copies the object passed to it means that the caller will be
  * left holding a physically different object instance than the one contained
  * inside this object.  Changes made to the original object instance (such as
  * resetting attribute values) will <em>not affect the instance in this
  * object</em>.  In addition, the caller should make sure to free the
  * original object if it is no longer being used, or else a memory leak will
  * result.  Please see other methods on this class (particularly a
  * corresponding method whose name begins with the word <code>create</code>)
  * for alternatives that do not lead to these issues.
  *
  *
    *
    * @see createFunctionDefinition()
    */
 public int addFunctionDefinition(FunctionDefinition fd)
 {
     int ret = libsbmlPINVOKE.Model_addFunctionDefinition(swigCPtr, FunctionDefinition.getCPtr(fd));
     return ret;
 }
Ejemplo n.º 23
0
    private static void printFunctionDefinition(int n, FunctionDefinition fd)
    {
        ASTNode math;
        string formula;

        if (fd.isSetMath())
        {
            Console.Write("FunctionDefinition " + n + ", " + fd.getId());

            math = fd.getMath();

            /* Print function arguments. */
            if (math.getNumChildren() > 1)
            {
                Console.Write("(" + (math.getLeftChild()).getName());

                for (n = 1; n < math.getNumChildren() - 1; ++n)
                {
                    Console.Write(", " + (math.getChild(n)).getName());
                }
            }

            Console.Write(") := ");

            /* Print function body. */
            if (math.getNumChildren() == 0)
            {
                Console.Write("(no body defined)");
            }
            else
            {
                math = math.getChild(math.getNumChildren() - 1);
                formula = libsbml.formulaToString(math);
                Console.Write(formula + Environment.NewLine);

            }
        }
    }
 FunctionDefinition remove(long n) {
    IntPtr cPtr = libsbmlPINVOKE.ListOfFunctionDefinitions_remove__SWIG_0(swigCPtr, n);
    FunctionDefinition ret = (cPtr == IntPtr.Zero) ? null : new FunctionDefinition(cPtr, true);
    return ret;
  }
Ejemplo n.º 25
0
 /** */
 /* libsbml-internal */
 public static void replaceFD(ASTNode math, FunctionDefinition fd)
 {
     libsbmlPINVOKE.SBMLTransforms_replaceFD__SWIG_1(ASTNode.getCPtr(math), FunctionDefinition.getCPtr(fd));
 }
 public void test_FunctionDefinition_createWithNS()
 {
     XMLNamespaces xmlns = new  XMLNamespaces();
       xmlns.add( "http://www.sbml.org", "testsbml");
       SBMLNamespaces sbmlns = new  SBMLNamespaces(2,1);
       sbmlns.addNamespaces(xmlns);
       FunctionDefinition object1 = new  FunctionDefinition(sbmlns);
       assertTrue( object1.getTypeCode() == libsbml.SBML_FUNCTION_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;
 }
Ejemplo n.º 27
0
 /**
    * Copy constructor; creates a copy of this FunctionDefinition.
    *
    * @param orig the object to copy.
    *
    * @throws SBMLConstructorException
    * Thrown if the argument @p orig is @c null.
    */
 public FunctionDefinition(FunctionDefinition orig)
     : this(libsbmlPINVOKE.new_FunctionDefinition__SWIG_2(FunctionDefinition.getCPtr(orig)), true)
 {
     if (libsbmlPINVOKE.SWIGPendingException.Pending) throw libsbmlPINVOKE.SWIGPendingException.Retrieve();
 }
 public void tearDown()
 {
     E = null;
 }
Ejemplo n.º 29
0
        internal static HandleRef getCPtrAndDisown(FunctionDefinition obj)
        {
            HandleRef ptr = new HandleRef(null, IntPtr.Zero);

            if (obj != null)
            {
            ptr             = obj.swigCPtr;
            obj.swigCMemOwn = false;
            }

            return ptr;
        }
Ejemplo n.º 30
0
 public void test_Model_add_get_FunctionDefinitions()
 {
     FunctionDefinition fd1 = new  FunctionDefinition(2,4);
       FunctionDefinition fd2 = new  FunctionDefinition(2,4);
       fd1.setId( "fd1");
       fd2.setId( "fd2");
       fd1.setMath(libsbml.parseFormula("2"));
       fd2.setMath(libsbml.parseFormula("2"));
       M.addFunctionDefinition(fd1);
       M.addFunctionDefinition(fd2);
       assertTrue( M.getNumFunctionDefinitions() == 2 );
       assertNotEquals(M.getFunctionDefinition(0),fd1);
       assertNotEquals(M.getFunctionDefinition(1),fd2);
       assertEquals(M.getFunctionDefinition(2),null);
 }
        public void test_FunctionDefinition_constructor()
        {
            SBase s;

              try
              {
            s = new FunctionDefinition(2,1);
            s = new FunctionDefinition(2,2);
            s = new FunctionDefinition(2,3);
            s = new FunctionDefinition(2,4);
            s = new FunctionDefinition(3,1);
            s = new FunctionDefinition(SN21);
            s = new FunctionDefinition(SN22);
            s = new FunctionDefinition(SN23);
            s = new FunctionDefinition(SN24);
            s = new FunctionDefinition(SN31);
              }
              catch (SBMLConstructorException e)
              {
             s = null;
              }
              assertTrue(s != null);

              string msg = "";

              try
              {
            s = new FunctionDefinition(1,1);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);

              msg = "";
              try
              {
            s = new FunctionDefinition(1,2);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);

              msg = "";
              try
              {
            s = new FunctionDefinition(9,9);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);

              msg = "";
              try
              {
            s = new FunctionDefinition(SN11);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);

              msg = "";
              try
              {
            s = new FunctionDefinition(SN12);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);

              msg = "";
              try
              {
            s = new FunctionDefinition(SN99);
              }
              catch (SBMLConstructorException e)
              {
             msg = e.Message;
              }
              assertTrue(msg == ErrMsg);
        }
Ejemplo n.º 32
0
 public void test_FunctionDefinition_copyConstructor()
 {
     FunctionDefinition o1 = new FunctionDefinition(2,4);
       o1.setId("c");
       assertTrue( o1.getId() ==  "c" );
       ASTNode node = new ASTNode(libsbml.AST_CONSTANT_PI);
       o1.setMath(node);
       node = null;
       assertTrue( o1.getMath() != null );
       FunctionDefinition o2 = new FunctionDefinition(o1);
       assertTrue( o2.getId() ==  "c" );
       assertTrue( o2.getMath() != null );
       assertTrue( o2.getParentSBMLObject() == o1.getParentSBMLObject() );
       o2 = null;
       o1 = null;
 }