예제 #1
0
        /// <summary>
        ///     Creates a MoBi Parameter from a given SBML Parameter.
        /// </summary>
        public IFormulaUsable CreateParameter(Parameter sbmlParameter)
        {
            var value = 0.0;

            if (sbmlParameter.isSetValue())
            {
                value = sbmlParameter.getValue();
            }
            IFormula formula = ObjectBaseFactory.Create <ConstantFormula>().WithValue(value);

            var parameter = ObjectBaseFactory.Create <IParameter>()
                            .WithName(sbmlParameter.getId())
                            .WithFormula(formula);

            if (!sbmlParameter.isSetUnits())
            {
                return(parameter);
            }

            if (_sbmlInformation.MobiDimension.ContainsKey(sbmlParameter.getUnits()))
            {
                parameter.Dimension = _sbmlInformation.MobiDimension[sbmlParameter.getUnits()];
            }
            return(parameter);
        }
        /// <summary>
        ///     Creates a MoBi Parameter from a given SBML Parameter.
        /// </summary>
        public IFormulaUsable CreateParameter(Parameter sbmlParameter)
        {
            var value = 0.0;

            if (sbmlParameter.isSetValue())
            {
                value = sbmlParameter.getValue();
            }
            if (!sbmlParameter.isSetUnits())
            {
                return(ObjectBaseFactory.Create <IParameter>()
                       .WithName(sbmlParameter.getId())
                       .WithFormula(ObjectBaseFactory.Create <ConstantFormula>().WithValue(value)));
            }

            var sbmlUnit  = sbmlParameter.getUnits();
            var baseValue = _unitDefinitionImporter.ToMobiBaseUnit(sbmlUnit, value);

            return(ObjectBaseFactory.Create <IParameter>()
                   .WithName(sbmlParameter.getId())
                   .WithFormula(_formulaFactory.ConstantFormula(baseValue.value, baseValue.dimension))
                   .WithDimension(baseValue.dimension));
        }