Example #1
0
        protected override void Context()
        {
            var obf = IoC.Resolve <IObjectBaseFactory>();
            var opf = IoC.Resolve <IObjectPathFactory>();
            var mdf = IoC.Resolve <IMoBiDimensionFactory>();
            var ac  = IoC.Resolve <IAliasCreator>();
            var sI  = new SBMLInformation();

            sut = new ASTHandler(obf, opf, ac, mdf);
        }
Example #2
0
        protected override void Context()
        {
            base.Context();
            _sbmlModel       = new Model(3, 1);
            _sbmlInformation = new SBMLInformation();

            //one compartment reaction
            _reaction = _sbmlModel.createReaction();
            _reaction.setId("r1");

            //reaction partner
            var s1 = _sbmlModel.createSpecies();

            s1.setId("s1");
            s1.setCompartment("default");

            var s2 = _sbmlModel.createSpecies();

            s2.setId("s2");
            s2.setCompartment("default");

            var m  = new MoleculeInformation(s1);
            var m2 = new MoleculeInformation(s2);

            _sbmlInformation.MoleculeInformation.Add(m);
            _sbmlInformation.MoleculeInformation.Add(m2);

            //SRef
            var s1Ref = _reaction.createReactant();

            s1Ref.setSpecies("s1");
            s1Ref.setStoichiometry(1);

            var s2Ref = _reaction.createProduct();

            s2Ref.setSpecies("s2");
            s2Ref.setStoichiometry(2);
            _reaction.addProduct(s2Ref);

            //Modifier
            var mod = _reaction.createModifier();

            mod.setId("mod");
            mod.setName("mod");
            mod.setSpecies("s1");

            //Kinetic Law
            var kl = _reaction.createKineticLaw();

            kl.setId("kl");
            kl.setMath(libsbml.parseFormula("2*3"));
        }
Example #3
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;
     }
 }
Example #4
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;
            }
        }
Example #5
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;
            }
        }
Example #6
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();
                _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;
            }
        }
Example #7
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);
 }