Esempio n. 1
0
    static void Main(string[] args)
    {
        SBMLNamespaces sbmlns   = new SBMLNamespaces(3, 1, "distrib", 1);
        SBMLDocument   document = new SBMLDocument(sbmlns);

        // set the required attribute to true
        DistribSBMLDocumentPlugin docPlug = (DistribSBMLDocumentPlugin)
                                            (document->getPlugin("distrib"));

        docPlug.setRequired(true);

        // create the Model

        Model model = document.createModel();

        // create the FunctionDefintion

        FunctionDefinition fd = model.createFunctionDefinition();

        fd.setId("mynormal");

        ASTNode math = libsbml.parseFormula("lambda(param1, param2, 0)");

        fd.setMath(math);

        //
        // Get a DistribFunctionDefinitionPlugin object plugged in the fd object.
        //
        // The type of the returned value of SBase::getPlugin() function is SBasePlugin, and
        // thus the value needs to be casted for the corresponding derived class.
        //
        DistribFunctionDefinitionPlugin fdPlugin =
            (DistribFunctionDefinitionPlugin)(fd.getPlugin("distrib"));

        // create a DrawFromDistribution object
        DrawFromDistribution draw = fdPlugin.createDrawFromDistribution();

        // create the distribInputs
        DistribInput input1 = draw.createDistribInput();

        input1.setId("mu");
        input1.setIndex(0);

        DistribInput input2 = draw.createDistribInput();

        input2.setId("sigma");
        input2.setIndex(1);

        // create the UncertMLNode object
        UncertMLNode uncert = libsbml.createDistributionNode
                                  ("NormalDistribution", "mean, variance", "mu,sigma");

        draw.setUncertML(uncert);

        libsbml.writeSBMLToFile(document, "distrib_example1.xml");
    }
    static void Main(string[] args)
    {
        SBMLNamespaces sbmlns   = new SBMLNamespaces(3, 1, "distrib", 1);
        SBMLDocument   document = new SBMLDocument(sbmlns);

        // set the required attribute to true
        DistribSBMLDocumentPlugin docPlug = (DistribSBMLDocumentPlugin)
                                            (document->getPlugin("distrib"));

        docPlug.setRequired(true);

        // create the Model

        Model model = document.createModel();

        // create the Parameter

        Parameter p = model.createParameter();

        p.setId("V");
        p.setConstant(true);

        //
        // Get a DistribSBasePlugin object plugged in the parameter object.
        //
        DistribSBasePlugin pPlugin =
            (DistribSBasePlugin)(p.getPlugin("distrib"));

        // create a Uncertainty object
        Uncertainty uncert = pPlugin.createUncertainty();

        // create the UncertMLNode object
        UncertMLNode uncertML = libsbml.createDistributionNode
                                    ("Statistics", "Mean, Variance", "V_pop, V_omega");

        uncert.setUncertML(uncertML);

        libsbml.writeSBMLToFile(document, "distrib_example2.xml");
    }