protected override void Context()
 {
     base.Context();
     _newAlias                     = "new_Name";
     _changedObject.Name           = "Name really old";
     _changedName                  = _changedObject.Name;
     _oldAlias                     = "Name_really_old";
     _theFormula                   = new ExplicitFormula(String.Format("k_{0}*{0}", _oldAlias));
     _formulaUsablePathNotToChange = new FormulaUsablePath(new[] { ObjectPath.PARENT_CONTAINER, "BLA", String.Format("k_{0}", _oldAlias) })
     {
         Alias = String.Format("k_{0}", _oldAlias)
     };
     _theFormula.AddObjectPath(_formulaUsablePathNotToChange);
     _formulaUsablePathToChange = new FormulaUsablePath(new[] { ObjectPath.PARENT_CONTAINER, _changedName })
     {
         Alias = _oldAlias
     };
     _theFormula.AddObjectPath(_formulaUsablePathToChange);
     _theFormula.Name = "F1";
     A.CallTo(() => _aliasCreator.CreateAliasFrom(_changedName)).Returns(_oldAlias);
     A.CallTo(() => _aliasCreator.CreateAliasFrom(_newName)).Returns(_newAlias);
     A.CallTo(() => _context.Get <IObjectBase>(A <string> ._)).Returns(_theFormula);
     _moleculeBuildingBlock = new MoleculeBuildingBlock().WithName("M").WithId("M");
     _moleculeBuildingBlock.AddFormula(_theFormula);
 }
Ejemplo n.º 2
0
        protected override void Context()
        {
            sut = new ExplicitFormula();

            sut.AddObjectPath(new FormulaUsablePath(new string[] { "X1", "Y1", "Z1" }));
            sut.AddObjectPath(new FormulaUsablePath(new string[] { "X2", "Y2", "Z2" }));
        }
Ejemplo n.º 3
0
        private void showWarningsFor(ExplicitFormula formula, IBuildingBlock buildingBlock, List <NotificationMessage> messages)
        {
            if (_formulaMapper.FormulaWasConverted(formula.FormulaString))
            {
                return;
            }

            if (formulaUsesOnlyOneDimension(formula))
            {
                return;
            }

            bool warningRequired =
                _dimensionMapper.NeededConversion(formula.Dimension) ||
                formula.ObjectPaths.Any(objectPath => _dimensionMapper.NeededConversion(objectPath.Dimension));

            if (!warningRequired)
            {
                return;
            }

            messages.Add(new NotificationMessage(formula, MessageOrigin.Formula, buildingBlock, NotificationType.Warning)
            {
                Message           = "Dimension check warning",
                BuildingBlockType = _objectTypeResolver.TypeFor(buildingBlock),
                ObjectType        = ObjectTypes.Formula
            });
        }
        protected override void Context()
        {
            _model      = new Model().WithName(_oldName);
            _model.Root = new Container().WithName(_oldName);
            var explicitFormula = new ExplicitFormula("A+B");

            _unchangedPath     = new FormulaUsablePath(new[] { "A", "B" });
            _changedObjectPath = new FormulaUsablePath(new[] { _oldName, "A" });
            var rhsFormula = new ExplicitFormula("-C");

            _rhsPath = new FormulaUsablePath(new [] { _oldName, "C" });
            rhsFormula.AddObjectPath(_rhsPath);
            explicitFormula.AddObjectPath(_changedObjectPath);
            explicitFormula.AddObjectPath(_unchangedPath);
            var parameter = new Parameter().WithName("P1").WithFormula(explicitFormula).WithRHS(rhsFormula);

            _model.Root.Add(parameter);
            _model.Neighborhoods = new Container().WithName(Constants.NEIGHBORHOODS);
            var neighborhood        = new Neighborhood().WithName("BLA");
            var neighborhoodFormula = new ExplicitFormula("u");

            _neighborhoodPath = new FormulaUsablePath(new[] { _oldName, _oldName, "u" });
            neighborhoodFormula.AddObjectPath(_neighborhoodPath);
            var neighborhoodParameter = new Parameter().WithFormula(neighborhoodFormula);

            neighborhood.Add(neighborhoodParameter);
            _model.Neighborhoods.Add(neighborhood);
            sut = new RenameModelCommand(_model, _newName);
        }
        protected override void Context()
        {
            base.Context();
            var sim1   = new Container().WithName("Sim1");
            var c1     = new Container().WithName("A").WithParentContainer(sim1);
            var p1     = new Parameter().WithName("B").WithParentContainer(c1);
            var param1 = new Parameter().WithName("C").WithParentContainer(c1);

            var sim2   = new Container().WithName("Sim2");
            var c2     = new Container().WithName("A").WithParentContainer(sim2);
            var p2     = new Parameter().WithName("B").WithParentContainer(c2);
            var param2 = new Parameter().WithName("C").WithParentContainer(c2);

            var formula1 = new ExplicitFormula("A+B");

            formula1.AddObjectPath(new FormulaUsablePath("Sim1", "A", "B").WithAlias("Same"));
            param1.Formula = formula1;
            formula1.ResolveObjectPathsFor(param1);

            var formula2 = new ExplicitFormula("A+B");

            formula2.AddObjectPath(new FormulaUsablePath("Sim2", "A", "B").WithAlias("Same"));
            param2.Formula = formula2;
            formula2.ResolveObjectPathsFor(param2);

            _object1 = param1;
            _object2 = param2;
        }
Ejemplo n.º 6
0
        protected override void Context()
        {
            base.Context();
            var displayUnitRetriever = IoC.Resolve <IDisplayUnitRetriever>();
            var f1 = new ExplicitFormula("CL*conc").WithName("formula");
            var r1 = new ReactionBuilder().WithName("Reaction").WithFormula(f1);

            r1.AddEduct(new ReactionPartnerBuilder("Drug", 1));
            r1.AddEduct(new ReactionPartnerBuilder("Metab", 1));
            r1.AddModifier("Cyp");
            var concentrationDimension = DomainHelperForSpecs.ConcentrationDimensionForSpecs();
            var p1Formula = new ConstantFormula(2).WithDimension(concentrationDimension);
            var p11       = new Parameter().WithName("P1").WithFormula(p1Formula).WithParentContainer(r1);

            var f2 = new ExplicitFormula("CL*conc").WithName("formula");
            var r2 = new ReactionBuilder().WithName("Reaction").WithFormula(f2);

            r2.AddEduct(new ReactionPartnerBuilder("Drug", 1));
            r2.AddEduct(new ReactionPartnerBuilder("Metab", 1));
            r2.AddModifier("Cyp");
            var p12Forumla = new ConstantFormula(3).WithDimension(concentrationDimension);
            var p12        = new Parameter().WithName("P1").WithFormula(p12Forumla).WithParentContainer(r2);

            _object1 = r1;
            _object2 = r2;

            _preferredUnit = concentrationDimension.Units.ElementAt(0);
            A.CallTo(() => displayUnitRetriever.PreferredUnitFor(p1Formula, null)).Returns(_preferredUnit);
            A.CallTo(() => displayUnitRetriever.PreferredUnitFor(p12Forumla, null)).Returns(_preferredUnit);
        }
Ejemplo n.º 7
0
        protected override void Because()
        {
            _model = new Model();
            var root = new Container().WithName("ROOT");

            _model.Root = root;
            var subContainer = new Container().WithName("SUB").WithParentContainer(root);
            var p1Formula    = new ExplicitFormula("P3").WithName("p1Formula");

            p1Formula.AddObjectPath(new FormulaUsablePath(ObjectPath.PARENT_CONTAINER, ObjectPath.PARENT_CONTAINER, "P3").WithAlias("P3"));

            var p2Formula = new ExplicitFormula("P3").WithName("p2Formula");

            p2Formula.AddObjectPath(new FormulaUsablePath(ObjectPath.PARENT_CONTAINER, ObjectPath.PARENT_CONTAINER, "P3").WithAlias("P3"));
            var p3RHSFormula = new ExplicitFormula("P2").WithName("p3RHSFormula");

            p3RHSFormula.AddObjectPath(new FormulaUsablePath(ObjectPath.PARENT_CONTAINER, "SUB", "P2").WithAlias("P2"));

            _parameter1 = new Parameter().WithName("P1").WithFormula(p1Formula);
            _parameter2 = new Parameter().WithName("P2").WithFormula(p2Formula);
            _parameter3 = new Parameter().WithName("P3").WithFormula(new ExplicitFormula("1+2"));
            _parameter3.WithRHS(p3RHSFormula);

            root.Add(_parameter3);
            subContainer.Add(_parameter1);
            subContainer.Add(_parameter2);

            p1Formula.ResolveObjectPathsFor(_parameter1);
            p2Formula.ResolveObjectPathsFor(_parameter2);
            p3RHSFormula.ResolveObjectPathsFor(_parameter3);
        }
        protected override void Context()
        {
            base.Context();
            _commandCollector  = A.Fake <ICommandCollector>();
            _formula           = new ExplicitFormula();
            _formulaUsablePath = new FormulaUsablePath("path")
            {
                Alias = "alias", Dimension = DimensionFactoryForSpecs.MassDimension
            };
            _formula.AddObjectPath(_formulaUsablePath);

            var formulaUsablePath = new FormulaUsablePath("path")
            {
                Alias = "alias"
            };

            _formulaUsablePathDTO = new FormulaUsablePathDTO(formulaUsablePath, _formula);
            _dto = new ExplicitFormulaBuilderDTO {
                ObjectPaths = new List <FormulaUsablePathDTO> {
                    _formulaUsablePathDTO
                }
            };
            A.CallTo(() => _explicitFormulaMapper.MapFrom(_formula, A <IUsingFormula> ._)).Returns(_dto);
            sut.Edit(_formula);
            sut.InitializeWith(_commandCollector);

            A.CallTo(() => _moBiFormulaTask.AddFormulaUsablePath(_formula, A <IFormulaUsablePath> ._, A <IBuildingBlock> ._))
            .Invokes(x => _newFormulaPath = x.GetArgument <IFormulaUsablePath>(1));
        }
        public void TestSerializationQuantityWithExplicitFormula()
        {
            Observer x1 = CreateObject <Observer>().WithName("Quentin").WithDimension(DimensionLength);

            x1.ParentContainer = C1;
            x1.IsFixedValue    = false;
            x1.Persistable     = false;
            x1.Formula         = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4);

            ExplicitFormula f1 = CreateObject <ExplicitFormula>().WithName("Fortunato").WithDimension(DimensionLength);

            f1.AddObjectPath(ObjectPathFactory.CreateAbsoluteFormulaUsablePath(P1));
            f1.AddObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P0));
            f1.AddObjectPath(ObjectPathFactory.CreateRelativeFormulaUsablePath(P, P2).WithAlias("Pitter"));
            f1.ResolveObjectPathsFor(P);
            f1.FormulaString = "Paul + Peter + Pitter";

            P1.Value = 1.0;
            P0.Value = 10.0;
            P2.Value = 2.0;

            x1.Formula = f1;

            IQuantity x2 = SerializeAndDeserialize(x1);

            x2.ParentContainer = C1;
            x2.Formula.ResolveObjectPathsFor(x2);

            AssertForSpecs.AreEqualQuantity(x2, x1);
        }
Ejemplo n.º 10
0
 protected override void Context()
 {
     base.Context();
     _concentrationFormula = new ExplicitFormula("A+B");
     A.CallTo(_cloneManagerForModel).WithReturnType <ExplicitFormula>().Returns(_concentrationFormula);
     A.CallTo(_formulaTask).WithReturnType <string>().Returns("V1");
 }
        protected override void Context()
        {
            base.Context();

            _root = new Container().WithName("Root");
            var length = new Dimension(new BaseDimensionRepresentation {
                LengthExponent = 1
            }, "Length", "cm");
            var molWeight = new Dimension(new BaseDimensionRepresentation {
                AmountExponent = 1, MassExponent = -1
            }, "MW", "mol/g");

            var explicitFormula = new ExplicitFormula().WithFormulaString("exp(MW)").WithDimension(length);

            explicitFormula.AddObjectPath(new FormulaUsablePath(new[] { "Root", "MW" }).WithAlias("MW").WithDimension(molWeight));


            var pksimPara = new Parameter()
                            .WithName(AppConstants.Parameters.RADIUS_SOLUTE)
                            .WithParentContainer(_root)
                            .WithFormula(explicitFormula)
                            .WithDimension(length);

            new Parameter().WithName("MW").WithParentContainer(_root).WithDimension(molWeight).WithFormula(new ConstantFormula(1));
            explicitFormula.ResolveObjectPathsFor(pksimPara);
        }
Ejemplo n.º 12
0
 protected override void Context()
 {
     base.Context();
     _explicitFormula   = new ExplicitFormula("4+3");
     _parameter.Formula = _explicitFormula;
     _parameter.Value   = 10;
 }
        protected override void Context()
        {
            base.Context();
            _kinetic  = new ExplicitFormula().WithFormulaString("a+b");
            _reaction = new Reaction().WithName("Ralf Reaction")
                        .WithParentContainer(_root)
                        .WithFormula(_kinetic)
                        .WithId("1")
                        .WithDimension(_reactionDimension);

            _spA = new MoleculeAmount().WithName("SpA").WithParentContainer(_root)
                   .WithId("2")
                   .WithFormula(new ExplicitFormula().WithFormulaString("1"))
                   .WithScaleFactor(1);


            _spB = new MoleculeAmount().WithName("SpB").WithParentContainer(_root)
                   .WithId("3")
                   .WithFormula(new ExplicitFormula().WithFormulaString("0"))
                   .WithScaleFactor(2);

            _reaction.AddEduct(new ReactionPartner(1, _spA));
            _reaction.AddProduct(new ReactionPartner(2, _spB));

            _volume = new Parameter().WithFormula(new ConstantFormula(10)).WithId("4").WithName(Constants.Parameters.VOLUME);
        }
Ejemplo n.º 14
0
        private void updateEHCKinetic(ExplicitFormula kinetic, string moleculeName)
        {
            kinetic.FormulaString = GallbladderEmptyingNewFormula;
            var amount      = _context.DimensionFactory.Dimension(Constants.Dimension.AMOUNT);
            var noDimension = _context.DimensionFactory.NoDimension;
            var time        = _context.DimensionFactory.Dimension(Constants.Dimension.TIME);

            kinetic.ClearObjectPaths();
            kinetic.AddObjectPath(
                _context.ObjectPathFactory.CreateFormulaUsablePathFrom(Constants.ORGANISM, Gallbladder,
                                                                       moleculeName)
                .WithAlias("M")
                .WithDimension(amount));
            kinetic.AddObjectPath(
                _context.ObjectPathFactory.CreateFormulaUsablePathFrom(Constants.ORGANISM, Gallbladder,
                                                                       GallbladderEmptyingActive)
                .WithAlias(GallbladderEmptyingActiveAlias)
                .WithDimension(noDimension));
            kinetic.AddObjectPath(
                _context.ObjectPathFactory.CreateFormulaUsablePathFrom(Constants.ORGANISM, Gallbladder,
                                                                       GallbladderEjectionFraction)
                .WithAlias(GallbladderEjectionFractionAlias)
                .WithDimension(amount));
            kinetic.AddObjectPath(
                _context.ObjectPathFactory.CreateFormulaUsablePathFrom(Constants.ORGANISM, Gallbladder,
                                                                       GallbladderEjectionHalfTime)
                .WithAlias(GallbladderEjectionHalfTimeAlias)
                .WithDimension(time));
        }
        public void TestSerializationFormulaWithoutObjectPaths()
        {
            ExplicitFormula x1 = CreateObject <ExplicitFormula>().WithName("Fortunato").WithDimension(DimensionLength);
            IFormula        x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualFormula(x2, x1);
        }
Ejemplo n.º 16
0
        protected override void Context()
        {
            _formulaUsablePathMapper = new FormulaUsablePathToFormulaUsablePathDTOMapper();
            _objectPathFactory       = new ObjectPathFactory(new AliasCreator());
            _entityPathResolver      = new EntityPathResolver(_objectPathFactory);
            sut = new ExplicitFormulaToExplicitFormulaDTOMapper(_formulaUsablePathMapper, _objectPathFactory, _entityPathResolver);

            _explicitFormula = new ExplicitFormula();
            _explicitFormula.AddObjectPath(
                new FormulaUsablePath(ObjectPath.PARENT_CONTAINER, "P2")
                .WithDimension(DimensionFactoryForSpecs.MassDimension)
                .WithAlias(AppConstants.Param)
                );


            _explicitFormula.FormulaString = "Param*2";

            _topContainer    = new Container().WithName("TOP");
            _parentContainer = new Container().WithName("Parent");
            _topContainer.Add(_parentContainer);
            _parameter  = new Parameter().WithName("P").WithFormula(_explicitFormula);
            _parameter2 = new Parameter().WithName("P2").WithFormula(new ConstantFormula(2));
            _parentContainer.Add(_parameter);
            _parentContainer.Add(_parameter2);
        }
Ejemplo n.º 17
0
 private void updateFormulaOrigin(ExplicitFormula sourceFormula, ExplicitFormula targetFormula)
 {
     if (sourceFormula == null || targetFormula == null)
     {
         return;
     }
     targetFormula.OriginId = sourceFormula.Id;
 }
 protected override void Context()
 {
     base.Context();
     _explicitFormula = new ExplicitFormula("A+B");
     A.CallTo(() => _reactionDimensionRetriever.SelectedDimensionMode).Returns(ReactionDimensionMode.ConcentrationBased);
     _reactionBuilder = new ReactionBuilder {
         Formula = _explicitFormula, Dimension = DomainHelperForSpecs.AmountPerTimeDimension
     };
 }
Ejemplo n.º 19
0
 protected override void Context()
 {
     base.Context();
     _project          = A.Fake <IMoBiProject>();
     _kinetic          = new ExplicitFormula("GallbladderEmptyingRate");
     _transportBuilder = new TransportBuilder().WithName("GallbladderEmptying").WithKinetic(_kinetic);
     _buildingBlock    = new PassiveTransportBuildingBlock();
     _buildingBlock.Add(_transportBuilder);
 }
        public ExplicitFormulaBuilderDTO MapFrom(ExplicitFormula explicitFormula, IUsingFormula usingFormula)
        {
            var dto = Map <ExplicitFormulaBuilderDTO>(explicitFormula);

            dto.FormulaString = explicitFormula.FormulaString;
            dto.Dimension     = explicitFormula.Dimension;
            dto.ObjectPaths   = _formulaUsablePathDTOMapper.MapFrom(updateObjectPaths(explicitFormula, usingFormula), explicitFormula);
            return(dto);
        }
        protected override void Context()
        {
            base.Context();

            var forumula1 = new ExplicitFormula("PAR1");

            forumula1.AddObjectPath(_objectPathFactory.CreateFormulaUsablePathFrom("ROOT", "C", "PARA1").WithAlias("PAR1"));
            _parameter1.RHSFormula = forumula1;
        }
 protected override void Context()
 {
     base.Context();
     _explicitFormula = new ExplicitFormula("A+B");
     A.CallTo(() => _reactionDimensionRetriever.SelectedDimensionMode).Returns(ReactionDimensionMode.ConcentrationBased);
     _moleculeBuilder = new MoleculeBuilder {
         DefaultStartFormula = _explicitFormula, Dimension = DomainHelperForSpecs.AmountDimension
     };
     A.CallTo(() => _amoutToConcentrationFormulaMapper.HasMappingFor(_explicitFormula)).Returns(false);
 }
Ejemplo n.º 23
0
 protected override void Context()
 {
     base.Context();
     _formula                     = new ExplicitFormula().WithName("F1").WithId("F11");
     _templateFormula             = new ExplicitFormula().WithName("F1").WithId("F12");
     _moleculeStartValues         = new MoleculeStartValuesBuildingBlock().WithName("MSV");
     _moleculeStartValuesTemplate = new MoleculeStartValuesBuildingBlock().WithName("MSV");
     _moleculeStartValuesTemplate.AddFormula(_templateFormula);
     _allBuildingBlocks.Add(_moleculeStartValuesTemplate);
 }
Ejemplo n.º 24
0
 protected override void Context()
 {
     base.Context();
     _formula = new ExplicitFormula {
         Id = "id"
     };
     _formulaUsablePath = new FormulaUsablePath("A", "B").WithAlias("OLD");
     _formula.AddObjectPath(_formulaUsablePath);
     A.CallTo(() => _context.Get <IFormula>(_formula.Id)).Returns(_formula);
 }
Ejemplo n.º 25
0
        protected override void Context()
        {
            _buildingBlock    = A.Fake <IBuildingBlock>();
            _newFormulaString = "newFormulaString";
            _oldFormulaString = "oldFormulaString";
            _formula          = new ExplicitFormula(_oldFormulaString);
            _context          = A.Fake <IMoBiContext>();
            A.CallTo(() => _context.Get <ExplicitFormula>(_formula.Id)).Returns(_formula);

            sut = new EditFormulaStringCommand(_newFormulaString, _oldFormulaString, _formula, _buildingBlock);
        }
Ejemplo n.º 26
0
 protected override void Context()
 {
     base.Context();
     _buildingBlockToAddTo = A.Fake <IBuildingBlock>();
     _formulaCache         = new FormulaCache();
     A.CallTo(() => _buildingBlockToAddTo.FormulaCache).Returns(_formulaCache);
     _totalyNewObject        = new MoleculeBuilder().WithName("New");
     _newFormula             = A.Fake <ExplicitFormula>().WithName("New Formula").WithDimension(A.Fake <IDimension>()).WithFormulaString("1+1").WithId("1");
     _newFormula.ObjectPaths = new IFormulaUsablePath[0];
     _totalyNewObject.DefaultStartFormula = _newFormula;
 }
Ejemplo n.º 27
0
        protected override void Context()
        {
            base.Context();
            var monitor  = new ExplicitFormula("TotalDrugMass");
            var observer = new ContainerObserverBuilder().WithName("Tralala").WithFormula(monitor);

            _totalDrugMassReference = new FormulaUsablePath(new[] { "Applications", "TotalDrugMass" }).WithAlias("TotalDrugMass");
            monitor.AddObjectPath(_totalDrugMassReference);
            _observerBuildingBlock = new ObserverBuildingBlock();
            _observerBuildingBlock.Add(observer);
        }
 protected override void Context()
 {
     base.Context();
     _formula = new ExplicitFormula();
     sut.Edit(_formula, null);
     sut.InitializeWith(A.Fake <ICommandCollector>());
     _formula.AddObjectPath(new FormulaUsablePath());
     A.CallTo(() => _dimensionFactory.Dimension(_userSettings.ParameterDefaultDimension)).Returns(DomainHelperForSpecs.AmountDimension);
     A.CallTo(() => _moBiFormulaTask.AddFormulaUsablePath(_formula, A <IFormulaUsablePath> ._, A <IBuildingBlock> ._))
     .Invokes(x => _newFormulaPath = x.GetArgument <IFormulaUsablePath>(1));
 }
        private IEnumerable <IFormulaUsablePath> updateObjectPaths(ExplicitFormula explicitFormula, IUsingFormula usingFormula)
        {
            if (shouldUseExistingObjectPaths(explicitFormula, usingFormula))
            {
                return(explicitFormula.ObjectPaths);
            }

            return(from objectPath in explicitFormula.ObjectPaths
                   let referencedObject = objectPath.TryResolve <IFormulaUsable>(usingFormula)
                                          select objectPathFor(referencedObject, objectPath));
        }
Ejemplo n.º 30
0
 protected override void Context()
 {
     base.Context();
     _buildingBlockToAddTo = A.Fake <IBuildingBlock>();
     _formulaCache         = new FormulaCache();
     A.CallTo(() => _buildingBlockToAddTo.FormulaCache).Returns(_formulaCache);
     _totalyNewObject         = new Parameter().WithName("New");
     _newFormula              = A.Fake <ExplicitFormula>().WithName("New Formula").WithDimension(A.Fake <IDimension>()).WithFormulaString("1+1").WithId("1");
     _newFormula.ObjectPaths  = new IFormulaUsablePath[0];
     _totalyNewObject.Formula = _newFormula;
     A.CallTo(() => _objectBaseRepository.ContainsObjectWithId(A <string> ._)).Returns(false);
 }