Example #1
0
        private void moveMoleculeCalculationMethod(ModelProperties modelProperties, CompoundProperties compoundProperties, string category)
        {
            var cm = modelProperties.CalculationMethodFor(category);

            if (cm == null)
            {
                return;
            }
            modelProperties.RemoveCalculationMethod(cm);
            compoundProperties.AddCalculationMethod(cm);
        }
Example #2
0
        public CompoundProperties MapFrom(Compound compound)
        {
            var compoundProperties = new CompoundProperties {
                Compound = compound
            };

            foreach (var category in _categoryRepository.All())
            {
                var compoundCalculationMethod = compound.CalculationMethodFor(category) ?? category.DefaultItem;
                compoundProperties.AddCalculationMethod(compoundCalculationMethod);
            }

            //update default mapping for alternatives in compound
            foreach (var alternativeGroup in compound.AllParameterAlternativeGroups())
            {
                var compoundGroupSelection = new CompoundGroupSelection {
                    AlternativeName = alternativeGroup.DefaultAlternative.Name, GroupName = alternativeGroup.Name
                };
                compoundProperties.AddCompoundGroupSelection(compoundGroupSelection);
            }

            return(compoundProperties);
        }
Example #3
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);
        }