protected override void Context() { base.Context(); _formulaCache = new FormulaCache(); _compoundFactory = IoC.Resolve <ICompoundFactory>(); _parameterAlternativeFactory = IoC.Resolve <IParameterAlternativeFactory>(); _compound = _compoundFactory.Create().WithName("Comp"); _compound.Parameter(Constants.Parameters.MOL_WEIGHT).Value = 250; //Two simple parameters without alternatives //one parameter defined as a constant for which an alternative was also specififed var lipoGroup = _compound.ParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_LIPOPHILICITY); _alternativeLipo1 = _parameterAlternativeFactory.CreateAlternativeFor(lipoGroup).WithName("ALT_LIPO1").WithId("ALT_LIPO1"); _alternativeLipo1.Parameter(CoreConstants.Parameters.LIPOPHILICITY).Value = 2; _alternativeLipo2 = _parameterAlternativeFactory.CreateAlternativeFor(lipoGroup).WithName("ALT_LIPO2").WithId("ALT_LIPO2"); _alternativeLipo2.Parameter(CoreConstants.Parameters.LIPOPHILICITY).Value = 5; lipoGroup.AddAlternative(_alternativeLipo1); lipoGroup.AddAlternative(_alternativeLipo2); //one parameter defined as a formula with a default calculated alternative var permAlternativeGroup = _compound.ParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_PERMEABILITY); //value cannot be changed by user _alternativePerm1 = _parameterAlternativeFactory.CreateDefaultAlternativeFor(permAlternativeGroup).WithName("ALT_PERM1").WithId("ALT_PERM1"); _alternativePerm2 = _parameterAlternativeFactory.CreateAlternativeFor(permAlternativeGroup).WithName("ALT_PERM2").WithId("ALT_PERM2"); _alternativePerm2.Parameter(CoreConstants.Parameters.PERMEABILITY).Value = 10; permAlternativeGroup.AddAlternative(_alternativePerm1); permAlternativeGroup.AddAlternative(_alternativePerm2); }
public override async Task <ParameterAlternative> MapToModel(Alternative snapshot, ParameterAlternativeGroup parameterAlternativeGroup) { var alternative = _parameterAlternativeFactory.CreateAlternativeFor(parameterAlternativeGroup); alternative.IsDefault = ModelValueFor(snapshot.IsDefault, DEFAULT_IS_DEFAULT); MapSnapshotPropertiesToModel(snapshot, alternative); await UpdateParametersFromSnapshot(snapshot, alternative, parameterAlternativeGroup.Name); if (parameterAlternativeGroup.IsNamed(CoreConstants.Groups.COMPOUND_SOLUBILITY)) { updateSolubilityAlternative(alternative); } var alternativeWithSpecies = alternative as ParameterAlternativeWithSpecies; if (alternativeWithSpecies == null) { return(alternative); } alternativeWithSpecies.Species = _speciesRepository.FindByName(snapshot.Species); if (alternativeWithSpecies.Species == null) { throw new SnapshotOutdatedException(PKSimConstants.Error.CouldNotFindSpecies(snapshot.Species, _speciesRepository.AllNames())); } return(alternativeWithSpecies); }
public ParameterAlternative CreateCompoundAlternative(Compound compound, string group, string alternativeName, double value, string parameterName, bool setDefault = true) { var alternativeGroup = compound.ParameterAlternativeGroup(group); var alternative = _parameterAlternativeFactory.CreateAlternativeFor(alternativeGroup).WithName(alternativeName); AddCommand(_compoundAlternativeTask.AddParameterGroupAlternativeTo(alternativeGroup, alternative)); AddCommand(_compoundAlternativeTask.SetAlternativeParameterValue(alternative.Parameter(parameterName), value)); if (setDefault) { AddCommand(_compoundAlternativeTask.SetDefaultAlternativeFor(alternativeGroup, alternative)); } return(alternative); }
public ICommand AddParameterGroupAlternativeTo(ParameterAlternativeGroup compoundParameterGroup) { var newParamGroupAlternative = _parameterAlternativeFactory.CreateAlternativeFor(compoundParameterGroup); using (var presenter = _applicationController.Start <IParameterAlternativeNamePresenter>()) { //canceled by user - nothing to do if (!presenter.Edit(compoundParameterGroup)) { return(new PKSimEmptyCommand()); } newParamGroupAlternative.Name = presenter.Name; newParamGroupAlternative.Description = presenter.Description; return(AddParameterGroupAlternativeTo(compoundParameterGroup, newParamGroupAlternative)); } }
public ParameterAlternative CreateAlternative(ParameterAlternativeGroup compoundParameterGroup, string name) => _parameterAlternativeFactory.CreateAlternativeFor(compoundParameterGroup).WithName(name);