Пример #1
0
 public void DoImport(Model sbmlModel, IMoBiProject moBiProject, SBMLInformation sbmlInformation, ICommandCollector command)
 {
     _sbmlProject     = moBiProject;
     _sbmlInformation = sbmlInformation;
     _command         = command;
     try
     {
         Import(sbmlModel);
     }
     finally
     {
         _sbmlProject     = null;
         _sbmlInformation = null;
         _command         = null;
     }
 }
Пример #2
0
        /// <summary>
        ///     Parses a SBML MathML expression into a MoBi Formula.
        /// </summary>
        /// <param name="rootNode"></param>
        /// <param name="rootObjectId"> The id of the parent object of the rootNode to set the name of </param>
        /// <param name="isRateRule"></param>
        /// <param name="sbmlProject"></param>
        /// <param name="sbmlInformation"></param>
        public IFormula Parse(ASTNode rootNode, string rootObjectId, bool isRateRule, IMoBiProject sbmlProject,
                              SBMLInformation sbmlInformation)
        {
            try
            {
                _sbmlProject     = sbmlProject;
                _sbmlInformation = sbmlInformation;
                _objectPaths.Clear();

                _counter++;
                var formulaString = Eval(rootNode);
                if (string.IsNullOrEmpty(formulaString))
                {
                    return(null);
                }

                var formula = _objectBaseFactory.Create <ExplicitFormula>()
                              .WithName(rootObjectId + _counter)
                              .WithFormulaString(formulaString);

                if (isRateRule)
                {
                    getObjectPathName(ObjectPath.PARENT_CONTAINER, rootObjectId);
                }

                foreach (var path in _objectPaths.Where(path => path != null))
                {
                    formula.AddObjectPath(path);
                }
                if (string.IsNullOrEmpty(formula?.FormulaString))
                {
                    createErrorMsg(rootNode);
                    return(null);
                }
                else
                {
                    return(formula);
                }
            }
            finally
            {
                _sbmlProject     = null;
                _sbmlInformation = null;
            }
        }
Пример #3
0
        /// <summary>
        ///     Parses a SBML MathML expression from a SBML Event Assignment into a MoBi Formula.
        /// </summary>
        /// <param name="rootNode"> The MathMl Expression of the SBML Event Assignment the assignmentVariable should be assigned with.</param>
        /// <param name="eventAssignmentBuilder"> The MoBi Event Assignment Builder the SBML Event Assigment should be build with. </param>
        /// <param name="assignmentVariable"> The Parameter, Molecule, Species or SpeciesReference that should be assigned when the Event is triggered. </param>
        /// <param name="sbmlProject"></param>
        /// <param name="sbmlInformation"></param>
        public IFormula Parse(ASTNode rootNode, IEventAssignmentBuilder eventAssignmentBuilder, string assignmentVariable,
                              IMoBiProject sbmlProject, SBMLInformation sbmlInformation)
        {
            try
            {
                _sbmlProject     = sbmlProject;
                _sbmlInformation = sbmlInformation;
                _counter++;
                var formulaString = Eval(rootNode);
                if (string.IsNullOrEmpty(formulaString))
                {
                    return(null);
                }

                var formula = _objectBaseFactory.Create <ExplicitFormula>()
                              .WithName(SBMLConstants.SBML_EVENT_ASSIGNMENT + assignmentVariable + _counter)
                              .WithFormulaString(formulaString);
                foreach (var opath in _objectPaths.Where(opath => opath != null))
                {
                    formula.AddObjectPath(opath);
                }

                var path = getObjectPathForAssignment(assignmentVariable);
                if (path != null)
                {
                    eventAssignmentBuilder.ObjectPath = path;
                }

                if (string.IsNullOrEmpty(formula?.FormulaString))
                {
                    createErrorMsg(rootNode);
                    return(null);
                }
                else
                {
                    return(formula);
                }
            }
            finally
            {
                _sbmlProject     = null;
                _sbmlInformation = null;
            }
        }
Пример #4
0
        /// <summary>
        ///     Parses a SBML MathML expression from a SBML Reaction into a MoBi Formula.
        /// </summary>
        /// <param name="rootNode"> The root of the MathMl expression. </param>
        /// <param name="reactionBuilder"> The MoBi reactionBuilder the SBML reaction should be build with. </param>
        /// <param name="sbmlProject"></param>
        /// <param name="sbmlInformation"></param>
        public IFormula Parse(ASTNode rootNode, IReactionBuilder reactionBuilder, IMoBiProject sbmlProject,
                              SBMLInformation sbmlInformation)
        {
            try
            {
                _objectPaths.Clear();
                _functionDefDictionary.Clear();
                _sbmlProject     = sbmlProject;
                _sbmlInformation = sbmlInformation;
                _reactionBuilder = reactionBuilder;

                var formulaString = Eval(rootNode);
                if (string.IsNullOrEmpty(formulaString))
                {
                    return(null);
                }

                var formula = _objectBaseFactory.Create <ExplicitFormula>()
                              .WithName(SBMLConstants.SBML_KINETIC_LAW + reactionBuilder.Name)
                              .WithFormulaString(formulaString);

                foreach (var path in _objectPaths.Where(path => path != null))
                {
                    formula.AddObjectPath(path);
                }

                if (string.IsNullOrEmpty(formula?.FormulaString))
                {
                    createErrorMsg(rootNode);
                    return(null);
                }
                else
                {
                    return(formula);
                }
            }
            finally
            {
                _reactionBuilder = null;
                _sbmlProject     = null;
                _sbmlInformation = null;
            }
        }
Пример #5
0
 /// <summary>
 ///    Saves additional Information and important Information that is necessary for the Import.
 /// </summary>
 public SBMLInformation SaveSBMLInformation(Model sbmlModel, SBMLDocument sbmlDoc)
 {
     SBMLInformation = new SBMLInformation();
     SBMLInformation.Initialize(sbmlModel, sbmlDoc);
     return(SBMLInformation);
 }