Ejemplo n.º 1
0
        private void createFormulaForBlackBoxParameters(ICoreCalculationMethod calculationMethod, IList <IMoleculeBuilder> allMoleculesUsingMethod)
        {
            foreach (var formula in calculationMethod.AllOutputFormulas())
            {
                var parameterDescriptor = calculationMethod.DescriptorFor(formula);
                foreach (var molecule in allMoleculesUsingMethod)
                {
                    foreach (var parameter in allMoleculeParameterForFormula(parameterDescriptor, molecule))
                    {
                        //not a black box parameter. Should not be overridden by cm
                        if (parameterIsNotBlackBoxParameter(parameter))
                        {
                            continue;
                        }

                        //parmeter formula was not set yet
                        if (parameter.Formula.IsBlackBox())
                        {
                            parameter.Formula = _formulaMapper.MapFrom(formula, _buildConfiguration);
                            replaceKeyWordsIn(parameter, molecule.Name);
                        }
                        else
                        {
                            if (!formulasAreTheSameForParameter(parameter, formula, molecule.Name))
                            {
                                throw new OSPSuiteException(Error.TwoDiffentFormulaForSameParameter(parameter.Name, _objectPathFactory.CreateAbsoluteObjectPath(parameter).ToPathString()));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void addHelpParametersFor(ICoreCalculationMethod calculationMethod, IList <IMoleculeBuilder> allMoleculesUsingMethod)
 {
     foreach (var helpParameter in calculationMethod.AllHelpParameters())
     {
         var containerDescriptor = calculationMethod.DescriptorFor(helpParameter);
         foreach (var molecule in allMoleculesUsingMethod)
         {
             foreach (var container in allMoleculeContainersFor(containerDescriptor, molecule))
             {
                 var exisitingParameter = container.GetSingleChildByName <IParameter>(helpParameter.Name);
                 //does not exist yet
                 if (exisitingParameter == null)
                 {
                     var parameter = _parameterMapper.MapFrom(helpParameter, _buildConfiguration);
                     container.Add(parameter);
                     replaceKeyWordsIn(parameter, molecule.Name);
                 }
                 else if (!formulasAreTheSameForParameter(exisitingParameter, helpParameter.Formula, molecule.Name))
                 {
                     throw new OSPSuiteException(Error.HelpParameterAlreadyDefinedWithAnotherFormula(calculationMethod.Name, _objectPathFactory.CreateAbsoluteObjectPath(helpParameter).ToString()));
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 private IEnumerable <IMoleculeBuilder> allMoleculesUsing(ICoreCalculationMethod calculationMethod, IMoleculeBuildingBlock moleculeBuildingBlock)
 {
     return(from molecule in moleculeBuildingBlock
            where molecule.IsFloatingXenobiotic
            from usedCalculationMethod in molecule.UsedCalculationMethods
            where usedCalculationMethod.CalculationMethod == calculationMethod.Name
            select molecule);
 }
 protected override void Context()
 {
     _spatialStructureFactory      = A.Fake <IPKSimSpatialStructureFactory>();
     _modelObserverQuery           = A.Fake <IModelObserverQuery>();
     _modelPassiveTransportQuery   = A.Fake <IModelPassiveTransportQuery>();
     _parameterStartValueCreator   = A.Fake <IPKSimParameterStartValuesCreator>();
     _moleculesAndReactionsCreator = A.Fake <IMoleculesAndReactionsCreator>();
     _eventBuildingBlockCreator    = A.Fake <IEventBuildingBlockCreator>();
     _moleculeStartValueCreator    = A.Fake <IPKSimMoleculeStartValuesCreator>();
     _moleculeCalculationRetriever = A.Fake <IMoleculeCalculationRetriever>();
     _distributedTableConverter    = A.Fake <IDistributedParameterToTableParameterConverter>();
     _parameterDefaultStateUpdater = A.Fake <IParameterDefaultStateUpdater>();
     _cm1        = new CoreCalculationMethod();
     _cm2        = new CoreCalculationMethod();
     _simulation = new IndividualSimulation {
         Properties = new SimulationProperties()
     };
     _simulation.SimulationSettings = new SimulationSettings();
     _simulation.ModelConfiguration = new ModelConfiguration();
     _individual                      = new Individual().WithName("MyIndividuyal");
     _compound                        = A.Fake <Compound>().WithName("MyCompound");
     _protocol                        = new SimpleProtocol().WithName("MyProtocol");
     _spatialStructure                = A.Fake <ISpatialStructure>();
     _passiveTransportBuilingBlock    = A.Fake <IPassiveTransportBuildingBlock>();
     _observerBuildingBlock           = A.Fake <IObserverBuildingBlock>();
     _eventBuildingBlock              = A.Fake <IEventGroupBuildingBlock>();
     _parameterValuesBuildingBlock    = A.Fake <IParameterStartValuesBuildingBlock>();
     _moleculeStartValueBuildingBlock = A.Fake <IMoleculeStartValuesBuildingBlock>();
     _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("Individual", PKSimBuildingBlockType.Individual)
     {
         BuildingBlock = _individual
     });
     _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("Compound", PKSimBuildingBlockType.Compound)
     {
         BuildingBlock = _compound
     });
     _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("Protocol", PKSimBuildingBlockType.Protocol)
     {
         BuildingBlock = _protocol
     });
     A.CallTo(() => _moleculeCalculationRetriever.AllMoleculeCalculationMethodsUsedBy(_simulation)).Returns(new[] { _cm1, _cm2 });
     A.CallTo(() => _spatialStructureFactory.CreateFor(_individual, _simulation)).Returns(_spatialStructure);
     A.CallTo(() => _modelPassiveTransportQuery.AllPassiveTransportsFor(_simulation)).Returns(_passiveTransportBuilingBlock);
     A.CallTo(() => _modelObserverQuery.AllObserversFor(A <IMoleculeBuildingBlock> .Ignored, _simulation)).Returns(_observerBuildingBlock);
     A.CallTo(() => _eventBuildingBlockCreator.CreateFor(_simulation)).Returns(_eventBuildingBlock);
     A.CallTo(() => _parameterStartValueCreator.CreateFor(A <IBuildConfiguration> .Ignored, A <Simulation> .Ignored)).Returns(_parameterValuesBuildingBlock);
     A.CallTo(() => _moleculeStartValueCreator.CreateFor(A <IBuildConfiguration> .Ignored, A <Simulation> .Ignored)).Returns(_moleculeStartValueBuildingBlock);
     sut = new BuildConfigurationTask(_spatialStructureFactory, _modelObserverQuery, _modelPassiveTransportQuery, _parameterStartValueCreator,
                                      _moleculesAndReactionsCreator, _eventBuildingBlockCreator, _moleculeStartValueCreator, _moleculeCalculationRetriever,
                                      _distributedTableConverter, _parameterDefaultStateUpdater);
 }
Ejemplo n.º 5
0
 public void AddUsedCalculationMethod(ICoreCalculationMethod calculationMethod)
 {
     AddUsedCalculationMethod(new UsedCalculationMethod(calculationMethod.Category, calculationMethod.Name));
 }
 public virtual void AddCalculationMethod(ICoreCalculationMethod calculationMethodToAdd)
 {
     _allCalculationMethods.Add(calculationMethodToAdd);
 }
 public void AddCalculationMethod(ICoreCalculationMethod calculationMethod)
 {
     _allMethods.Add(calculationMethod);
 }
Ejemplo n.º 8
0
        protected override void Context()
        {
            base.Context();
            _allCoreCalculationMethods = new List <ICoreCalculationMethod>();
            _simulation = new IndividualSimulation {
                Properties = new SimulationProperties()
            };
            var compound1 = new Compound().WithName("C1");
            var compound2 = new Compound().WithName("C2");

            _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("C1", PKSimBuildingBlockType.Compound)
            {
                BuildingBlock = compound1
            });
            _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("C2", PKSimBuildingBlockType.Compound)
            {
                BuildingBlock = compound2
            });

            var cm1 = new CalculationMethod {
                Category = "MOLECULE"
            }.WithName("CM1");
            var cm2 = new CalculationMethod {
                Category = "MOLECULE"
            }.WithName("CM2");
            var cm3 = new CalculationMethod {
                Category = "MOLECULE"
            }.WithName("CM3");
            var cm5 = new CalculationMethod {
                Category = "NOT MOLECULE"
            }.WithName("CM5");

            A.CallTo(() => _calculationMethodCategoryRepository.FindBy("MOLECULE")).Returns(new CalculationMethodCategory {
                CategoryType = CategoryType.Molecule
            });
            A.CallTo(() => _calculationMethodCategoryRepository.FindBy("NOT MOLECULE")).Returns(new CalculationMethodCategory {
                CategoryType = CategoryType.Individual
            });

            var cp1 = new CompoundProperties {
                Compound = compound1
            };
            var cp2 = new CompoundProperties {
                Compound = compound2
            };

            _simulation.Properties.AddCompoundProperties(cp1);
            _simulation.Properties.AddCompoundProperties(cp2);

            cp1.AddCalculationMethod(cm1);
            cp1.AddCalculationMethod(cm2);

            cp2.AddCalculationMethod(cm2);
            cp2.AddCalculationMethod(cm3);
            cp2.AddCalculationMethod(cm5);

            _coreCM1 = new CoreCalculationMethod {
                Name = cm1.Name
            };
            _coreCM2 = new CoreCalculationMethod {
                Name = cm2.Name
            };
            _coreCM3 = new CoreCalculationMethod {
                Name = cm3.Name
            };
            _coreCM4 = new CoreCalculationMethod {
                Name = "TOTO"
            };
            _coreCM5 = new CoreCalculationMethod {
                Name = cm5.Name
            };

            _allCoreCalculationMethods.Add(_coreCM1);
            _allCoreCalculationMethods.Add(_coreCM2);
            _allCoreCalculationMethods.Add(_coreCM3);
            _allCoreCalculationMethods.Add(_coreCM4);
            _allCoreCalculationMethods.Add(_coreCM5);
            A.CallTo(() => _coreCalculationMethodRepository.All()).Returns(_allCoreCalculationMethods);
        }