当前位置: 首页>>代码示例>>C#>>正文


C# Model.getLevel方法代码示例

本文整理汇总了C#中libsbml.Model.getLevel方法的典型用法代码示例。如果您正苦于以下问题:C# Model.getLevel方法的具体用法?C# Model.getLevel怎么用?C# Model.getLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在libsbml.Model的用法示例。


在下文中一共展示了Model.getLevel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SBML_Model

        /// <summary>
        /// 
        /// </summary>
        /// <param name="aSBMLmodel"></param>
        public SBML_Model(Model aSBMLmodel)
        {
            this.CompartmentSize = new Dictionary<string,double>();
            this.CompartmentUnit = new Dictionary<string,string>();
            this.FunctionDefinition = new Dictionary<string, string>();

            this.Level = aSBMLmodel.getLevel();
            this.Version = aSBMLmodel.getVersion();

            this.CompartmentList = SbmlFunctions.getCompartment(aSBMLmodel);
            this.EventList = SbmlFunctions.getEvent(aSBMLmodel);
            this.FunctionDefinitionList = SbmlFunctions.getFunctionDefinition(aSBMLmodel);
            this.ParameterList = SbmlFunctions.getParameter(aSBMLmodel);
            this.ReactionList = SbmlFunctions.getReaction(aSBMLmodel);
            this.RuleList = SbmlFunctions.getRule(aSBMLmodel);
            this.SpeciesList = SbmlFunctions.getSpecies(aSBMLmodel);
            this.UnitDefinitionList = SbmlFunctions.getUnitDefinition(aSBMLmodel);
            this.InitialAssignmentList = SbmlFunctions.getInitialAssignments(aSBMLmodel);
            this.setFunctionDefinitionToDictionary();
        }
开发者ID:ecell,项目名称:ecell3-ide,代码行数:24,代码来源:SBML_Model.cs

示例2: getReaction

        /// <summary>
        /// [ ReactionStruct ]
        /// [[ Id , Name , [ KineticLawStruct ] , Reversible , Fast , [ ReactantStruct ] , [ ProductStruct ] , [ ModifierSpecies ] ]]
        /// </summary>
        /// <param name="aSBMLmodel"></param>
        /// <returns></returns>
        public static List<ReactionStruct> getReaction(Model aSBMLmodel)
        {
            List<ReactionStruct> list = new List<ReactionStruct>();

            ListOfReactions reactions = aSBMLmodel.getListOfReactions();
            for (int i = 0; i < reactions.size(); i++ )
            {
                Reaction aReaction = aSBMLmodel.getReaction(i);

                string anId = aReaction.getId();
                string aName =aReaction.getName();

                //----------KineticLaw----------------------------------
                List<KineticLawStruct> ListOfKineticLaw = new List<KineticLawStruct>();
                if( aReaction.isSetKineticLaw())
                {
                    KineticLaw aKineticLaw = aReaction.getKineticLaw();
                    if( aKineticLaw != null)
                    {
                        string aFormula_KL;
                        if( aKineticLaw.isSetFormula())
                            aFormula_KL = aKineticLaw.getFormula();
                        else
                            aFormula_KL = "";

                        List<string> aString_KL = new List<string>();
                        if (aSBMLmodel.getLevel() == 1)
                        {
                            aString_KL.Add( "" );
                        }
                        else
                        {
                            if (aKineticLaw.isSetMath())
                            {
                                ASTNode anASTNode_KL = aKineticLaw.getMath();
                                aString_KL.Add( libsbml.libsbml.formulaToString( anASTNode_KL ) );
                            }
                            else
                                aString_KL.Add( "" );
                        }

                        string aTimeUnit_KL = aKineticLaw.getTimeUnits();
                        string aSubstanceUnit_KL = aKineticLaw.getSubstanceUnits();

                        List<ParameterStruct> listOfParameters = new List<ParameterStruct>();

                        ListOfParameters parameters = aKineticLaw.getListOfParameters();
                        for (int j = 0; j < parameters.size(); j++ )
                        {
                            Parameter aParameter = aKineticLaw.getParameter(j);
                            if (aParameter == null)
                                continue;
                            string anId_KL_P = aParameter.getId();
                            string aName_KL_P = aParameter.getName();
                            double aValue_KL_P = aParameter.getValue();
                            string aUnit_KL_P = aParameter.getUnits();
                            bool aConstant_KL_P = aParameter.getConstant();

                            ParameterStruct parameter = new ParameterStruct(
                                anId_KL_P,
                                aName_KL_P,
                                aValue_KL_P,
                                aUnit_KL_P,
                                aConstant_KL_P);

                            listOfParameters.Add( parameter );
                        }

                        XMLNode anExpressionAnnotation = aKineticLaw.getAnnotation();

                        KineticLawStruct kineticLaw = new KineticLawStruct(
                            aFormula_KL,
                            aString_KL,
                            aTimeUnit_KL,
                            aSubstanceUnit_KL,
                            listOfParameters,
                            anExpressionAnnotation );

                        ListOfKineticLaw.Add(kineticLaw);
                    }
                }

                bool aReversible = aReaction.getReversible();
                bool aFast = aReaction.getFast();

                //----------Reactants----------------------------------
                List<ReactantStruct> ListOfReactants = new List<ReactantStruct>();

                ListOfSpeciesReferences reactants = aReaction.getListOfReactants();
                for (int k = 0; k < reactants.size(); k++ )
                {
                    SpeciesReference aSpeciesReference = aReaction.getReactant(k);

                    string aSpecies_R = aSpeciesReference.getSpecies();
//.........这里部分代码省略.........
开发者ID:ecell,项目名称:ecell3-ide,代码行数:101,代码来源:SbmlFunctions.cs

示例3: test_Model_createWithNS

 public void test_Model_createWithNS()
 {
     XMLNamespaces xmlns = new  XMLNamespaces();
       xmlns.add( "http://www.sbml.org", "testsbml");
       SBMLNamespaces sbmlns = new  SBMLNamespaces(2,1);
       sbmlns.addNamespaces(xmlns);
       Model object1 = new  Model(sbmlns);
       assertTrue( object1.getTypeCode() == libsbml.SBML_MODEL );
       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;
 }
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:17,代码来源:TestModel.cs

示例4: test_L3_Model_createWithNS

 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;
 }
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:33,代码来源:TestL3Model.cs

示例5: setEssentialEntity

        private static void setEssentialEntity(Model aSBMLModel)
        {
            //
            //  set N_A Parameter
            //
            bool isAbogadroNumber = false;
            foreach (ParameterStruct aParameter in SbmlFunctions.getParameter(aSBMLModel))
            {
                if (aSBMLModel.getLevel() == 1 && aParameter.Name == "N_A")
                    isAbogadroNumber = true;
                else if (aSBMLModel.getLevel() == 2 && aParameter.ID == "N_A")
                    isAbogadroNumber = true;
            }
            if ( !isAbogadroNumber )
            {
                // create Parameter object
                Parameter aParameter = aSBMLModel.createParameter();
                // set Parameter Name
                if (aSBMLModel.getLevel() == 1)
                    aParameter.setName("N_A");
                else if (aSBMLModel.getLevel() == 2)
                    aParameter.setId("N_A");
                // set Parameter Value
                aParameter.setValue(6.0221367e+23);
                // set Parameter Constant
                aParameter.setConstant(true);
            }

            // ------------
            // set EmptySet
            // ------------
            //bool isEmptySet = false;
            //foreach (SpeciesStruct aSpecies in SbmlFunctions.getSpecies(aSBMLModel))
            //{
            //    if (aSBMLModel.getLevel() == 1 && aSpecies.Name == "EmptySet")
            //        isEmptySet = true;
            //    else if (aSBMLModel.getLevel() == 2 && aSpecies.ID == "EmptySet")
            //        isEmptySet = true;
            //}
            //if (!isEmptySet)
            //{
            //    // create Species object
            //    Species aSpecies = aSBMLModel.createSpecies();
            //    // set Species Name
            //    if (aSBMLModel.getLevel() == 1)
            //        aSpecies.setName("EmptySet");
            //    else if (aSBMLModel.getLevel() == 2)
            //        aSpecies.setId("EmptySet");
            //    // set Species Compartment
            //    aSpecies.setCompartment("default");
            //    // set Species Amount
            //    aSpecies.setInitialAmount(0);
            //    // set Species Constant
            //    aSpecies.setConstant(true);
            //}
        }
开发者ID:ecell,项目名称:ecell3-ide,代码行数:56,代码来源:EML2SBML.cs

示例6: createSystem

        private static void createSystem(EcellObject anEml, Model aSBMLModel)
        {
            if ( anEml.LocalID == "SBMLParameter" || anEml.LocalID == "SBMLRule" )
                return;

            // create Compartment object
            Compartment aCompartment = aSBMLModel.createCompartment();

            // set ID ROOT System and Other System
            string aCompartmentID = "";
            if (anEml.LocalID == "/")
                aCompartmentID = "default"; // Root system
            else
                aCompartmentID = anEml.LocalID;
            //  aCompartmentID = "default" + anEml.Key.Replace( "/", "__" );

            ID_Namespace.Add( aCompartmentID );

            if (aSBMLModel.getLevel() == 1)
                aCompartment.setName( aCompartmentID );
            else if (aSBMLModel.getLevel() == 2)
                aCompartment.setId( aCompartmentID );

            foreach(EcellObject child in anEml.Children)
            {
                if (!(child is EcellVariable))
                    continue;
                // set Size and constant of Compartment
                if( child.LocalID == "SIZE" )
                {
                    double size = ((EcellSystem)anEml).SizeInVolume;
                    aCompartment.setSize(size);

                    EcellValue value = anEml.GetEcellValue("Fixed");
                    if(value != null)
                        aCompartment.setConstant(System.Convert.ToBoolean((int)value));
                }
                // set Dimensions of Compartment
                else if( child.LocalID == "Dimensions" )
                {
                    int dimension = (int)child.GetEcellValue("Value");
                    aCompartment.setSpatialDimensions(dimension);
                }
            }
            // set Outside element of Compartment
            if( anEml.ParentSystemID == "/" && anEml.LocalID != "")
            {
                aCompartment.setOutside( "default" );
            }
            else if (!string.IsNullOrEmpty(anEml.ParentSystemID))
            {
                aCompartment.setOutside(
                    getCurrentCompartment( anEml.ParentSystemID ));
            }
        }
开发者ID:ecell,项目名称:ecell3-ide,代码行数:55,代码来源:EML2SBML.cs

示例7: createSpecies

        private static void createSpecies(EcellObject anEml, Model aSBMLModel)
        {
            string aCurrentCompartment = getCurrentCompartment( anEml.ParentSystemID );
            Compartment aCurrentCompartmentObj = aSBMLModel.getCompartment( aCurrentCompartment );

            if( aCurrentCompartment == "SBMLParameter" )
            {
                // ------------------------
                // create Parameter object
                // ------------------------
                Parameter aParameter = aSBMLModel.createParameter();

                string aParameterID;
                if ( ID_Namespace.Contains(anEml.LocalID) == false )
                    aParameterID = anEml.LocalID;
                else
                    aParameterID = "SBMLParamter__" + anEml.LocalID;

                // set Paramter ID to Id namespace
                ID_Namespace.Add( aParameterID );

                // set Parameter ID
                if (aSBMLModel.getLevel() == 1)
                    aParameter.setName( aParameterID );

                else if (aSBMLModel.getLevel() == 2)
                    aParameter.setId( aParameterID );

                // set Parameter Name, Value and Constant
                foreach(EcellData aProperty in anEml.Value)
                {
                    string aFullPN = anEml.FullID + ":" + aProperty.Name;

                    // set Parameter Name
                    if ( aProperty.Name == "Name" )
                    {
                        if (aSBMLModel.getLevel() == 1)
                        {
                        }
                        if (aSBMLModel.getLevel() == 2)
                        {
                            aParameter.setName( (string)aProperty.Value );
                        }
                    }

                    // set Parameter Value
                    else if ( aProperty.Name == "Value" )
                    {
                        aParameter.setValue( (double)aProperty.Value );
                    }
                    // set Constant
                    else if ( aProperty.Name == "Fixed" )
                    {
                        aParameter.setConstant(System.Convert.ToBoolean((int)aProperty.Value));
                    }
                    else
                    {
                        Trace.WriteLine("Unrepresentable property; " + aFullPN);
                        //throw new EcellException("Unrepresentable property; " + aFullPN);
                    }
                }
            }
            else
            {
                if( anEml.LocalID != "SIZE" && anEml.LocalID != "Dimensions" )
                {
                    // create Species object
                    Species aSpecies = aSBMLModel.createSpecies();

                    // set Species ID
                    string aSpeciesID;
                    if ( ID_Namespace.Contains( anEml.LocalID) == false )
                        aSpeciesID = anEml.LocalID;
                    else
                    {
                        if ( !anEml.ParentSystemID.Equals("/") )
                            aSpeciesID = anEml.LocalID;
                        else
                            aSpeciesID = anEml.LocalID;
                    }

                    ID_Namespace.Add( aSpeciesID );

                    if (aSBMLModel.getLevel() == 1)
                        aSpecies.setName( aSpeciesID );
                    if (aSBMLModel.getLevel() == 2)
                        aSpecies.setId( aSpeciesID );

                    // set Compartment of Species
                    if( aCurrentCompartment == "" )
                        aSpecies.setCompartment( "default" );
                    else
                        aSpecies.setCompartment( aCurrentCompartment );

                    // set Species Name, Value and Constant
                    foreach(EcellData aProperty in anEml.Value)
                    {
                        string aFullPN = anEml.FullID + ":" + aProperty.Name;

                        // set Species Name
//.........这里部分代码省略.........
开发者ID:ecell,项目名称:ecell3-ide,代码行数:101,代码来源:EML2SBML.cs

示例8: createReaction

        private static void createReaction(EcellObject anEml, Model aSBMLModel)
        {
            EcellProcess aProcess = (EcellProcess)anEml;
            List<EcellReference> aVariableReferenceList = aProcess.ReferenceList;
            string anExpression = aProcess.Expression;
            // ------------------
            //  make Rule object
            // ------------------
            if ( anEml.ParentSystemID == "/SBMLRule" )
            {
                // get Process Class

                anExpression = convertExpression(
                    anExpression,
                    aVariableReferenceList,
                    aProcess.ParentSystemID);

                if( aProcess.Classname == ProcessConstants.ExpressionAlgebraicProcess )
                {
                    // create AlgebraicRule object
                    AlgebraicRule anAlgebraicRule = aSBMLModel.createAlgebraicRule();

                    // set AlgebraicRule Formula
                    anAlgebraicRule.setFormula( anExpression );
                }
                else if( aProcess.Classname == ProcessConstants.ExpressionAssignmentProcess )
                {
                    foreach(EcellReference aVariableReference in aVariableReferenceList)
                    {
                        if ( aVariableReference.Coefficient != 0 )
                        {
                            // create AssignmentRule object
                            AssignmentRule anAssignmentRule =aSBMLModel.createAssignmentRule();
                            // set AssignmentRule Formula
                            anAssignmentRule.setFormula( aVariableReference.Coefficient.ToString() + "* ( " + anExpression + ")" );
                            string aVariableID = getVariableReferenceId( aVariableReference.FullID, aProcess.ParentSystemID );
                            anAssignmentRule.setVariable( aVariableID );
                        }
                    }
                }
                else if( aProcess.Classname == ProcessConstants.ExpressionFluxProcess )
                {
                    foreach(EcellReference aVariableReference in aVariableReferenceList)
                    {
                        if ( aVariableReference.Coefficient != 0 )
                        {
                            // create AssignmentRule object
                            RateRule aRateRule = aSBMLModel.createRateRule();

                            // set AssignmentRule Formula
                            aRateRule.setFormula( aVariableReference.Coefficient + "* ( " + anExpression + ")" );

                            string aVariableID = getVariableReferenceId( aVariableReference.FullID, aProcess.ParentSystemID );
                            aRateRule.setVariable( aVariableID );
                        }
                    }
                }
                else
                {
                    throw new EcellException("The type of Process must be Algebraic, Assignment, Flux Processes: " + aProcess.Key);
                }

            }
            // ----------------------
            //  make Reaction object
            // ----------------------
            else
            {
                // create Parameter object
                Reaction aReaction = aSBMLModel.createReaction();

                // create KineticLaw Object
                KineticLaw aKineticLaw = aSBMLModel.createKineticLaw();

                // set Reaction ID
                if (aSBMLModel.getLevel() == 1)
                    aReaction.setName( anEml.LocalID );
                if (aSBMLModel.getLevel() == 2)
                    aReaction.setId( anEml.LocalID );

                foreach(EcellData aProperty in anEml.Value)
                {
                    if (!aProperty.Loadable)
                        continue;

                    string aFullPN = aProcess.FullID + ":" + aProperty.Name;

                    // set Name property ( Name )
                    if ( aProperty.Name == "Name" )
                    {
                        // set Reaction Name
                        if (aSBMLModel.getLevel() == 1)
                        {
                        }
                        else if (aSBMLModel.getLevel() == 2)
                            aReaction.setName( (string)aProperty.Value );

                    }
                    // set Expression property ( KineticLaw Formula )
                    else if ( aProperty.Name == "Expression")
//.........这里部分代码省略.........
开发者ID:ecell,项目名称:ecell3-ide,代码行数:101,代码来源:EML2SBML.cs


注:本文中的libsbml.Model.getLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。