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);
        }
Ejemplo n.º 2
0
        public void should_have_added_the_gain_per_charge_to_all_solubility_alternatives()
        {
            var solGroup = _compound.ParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_SOLUBILITY);

            foreach (var alternative in solGroup.AllAlternatives)
            {
                alternative.Parameter(CoreConstants.Parameter.SolubilityGainPerCharge).Value.ShouldBeEqualTo(1000);
            }
        }
Ejemplo n.º 3
0
        private void checkAlternativeParameter(Compound compound, string groupName, string alternativeName,
                                               string parameterName, double expectedValue, string expectedUnit = "")
        {
            var alternative = compound.ParameterAlternativeGroup(groupName).AlternativeByName(alternativeName);

            checkParameter(alternative.Parameter(parameterName), expectedValue, expectedUnit);
        }
Ejemplo n.º 4
0
        private void checkIsDefaultFlagIn(Compound compound)
        {
            compound.Parameter(CoreConstants.Parameters.MOLECULAR_WEIGHT).IsDefault.ShouldBeFalse();
            var lipoGroup  = compound.ParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_LIPOPHILICITY);
            var parameters = lipoGroup.AllAlternatives.Select(x => x.Parameter(CoreConstants.Parameters.LIPOPHILICITY));

            parameters.Each(p => p.IsDefault.ShouldBeFalse());
        }
Ejemplo n.º 5
0
        private void updateFractionUnboundName(Compound compound)
        {
            var fuGroup = compound.ParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_FRACTION_UNBOUND);

            foreach (var alternative in fuGroup.AllAlternatives)
            {
                updateFractionUnboundParameterInContainer(alternative);
            }
        }
Ejemplo n.º 6
0
 private void checkDefaultAlternative(Compound compound, string groupName, string defaultAlternativeName)
 {
     foreach (var alternative in compound.ParameterAlternativeGroup(groupName).AllAlternatives)
     {
         if (alternative.Name.Equals(defaultAlternativeName))
         {
             alternative.IsDefault.ShouldBeTrue($"{alternative} must be default");
             continue;
         }
         alternative.IsDefault.ShouldBeFalse($"{alternative} may not be default");
     }
 }
Ejemplo n.º 7
0
        private IParameter getParameterForAlternative(Compound compound, CompoundProperties compoundProperties, CompoundGroupSelection alternativeSelection)
        {
            if (compound == null)
            {
                return(null);
            }

            var alternativeGroup = compound.ParameterAlternativeGroup(alternativeSelection.GroupName);

            if (alternativeGroup == null)
            {
                return(null);
            }

            var alternative = alternativeGroup.AlternativeByName(alternativeSelection.AlternativeName);

            if (alternative == null)
            {
                return(null);
            }

            var parameter = alternative.AllVisibleParameters().FirstOrDefault();

            if (parameter == null)
            {
                return(null);
            }

            if (!CoreConstants.Groups.GroupsWithCalculatedAlternative.Contains(alternativeSelection.GroupName))
            {
                return(parameter);
            }

            //this is a calculated alternative. We need to retrieve the value depending on the selected lipophilicity
            IEnumerable <IParameter> allParameters;

            if (alternativeGroup.Name == CoreConstants.Groups.COMPOUND_PERMEABILITY)
            {
                allParameters = _compoundAlternativeTask.PermeabilityValuesFor(compound);
            }
            else
            {
                allParameters = _compoundAlternativeTask.IntestinalPermeabilityValuesFor(compound);
            }

            var lipophilicityName = compoundProperties.CompoundGroupSelections
                                    .Where(x => x.GroupName == CoreConstants.Groups.COMPOUND_LIPOPHILICITY)
                                    .Select(x => x.AlternativeName).FirstOrDefault();

            return(allParameters.FirstOrDefault(x => x.IsNamed(lipophilicityName)));
        }
Ejemplo n.º 8
0
        private void updateProcessParameterFromDefaultAleternative(CompoundProcess newProcess, Compound compound, string processParameterName, string compoundParameterName, string groupName)
        {
            var processParameter = newProcess.Parameter(processParameterName);

            if (processParameter == null)
            {
                return;
            }
            var parameterAlternative = compound.ParameterAlternativeGroup(groupName).DefaultAlternative;

            if (parameterAlternative == null)
            {
                return;
            }
            processParameter.Value = parameterAlternative.Parameter(compoundParameterName).Value;
        }
        private IEnumerable <IParameter> permeabilityParametersFor(Compound compound, string permeabilityParameterName)
        {
            //create a temp compound from the compound factory
            //retrieve the lipophilicity alternatives
            var lipophilicityGroup = compound.ParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_LIPOPHILICITY);

            foreach (var alternative in lipophilicityGroup.AllAlternatives)
            {
                var tempCompound = _compoundFactory.Create();
                tempCompound.Parameter(Constants.Parameters.IS_SMALL_MOLECULE).Value = compound.Parameter(Constants.Parameters.IS_SMALL_MOLECULE).Value;
                tempCompound.Parameter(CoreConstants.Parameters.EFFECTIVE_MOLECULAR_WEIGHT).Value = compound.Parameter(CoreConstants.Parameters.EFFECTIVE_MOLECULAR_WEIGHT).Value;
                tempCompound.Parameter(CoreConstants.Parameters.LIPOPHILICITY).Value = alternative.Parameter(CoreConstants.Parameters.LIPOPHILICITY).Value;
                var permParameter = tempCompound.Parameter(permeabilityParameterName);
                permParameter.Editable = false;
                permParameter.Name     = alternative.Name;
                yield return(permParameter);
            }
        }
Ejemplo n.º 10
0
        public override void GlobalContext()
        {
            base.GlobalContext();

            _compound   = DomainFactoryForSpecs.CreateStandardCompound();
            _individual = DomainFactoryForSpecs.CreateStandardIndividual();
            _protocol   = DomainFactoryForSpecs.CreateStandardIVBolusProtocol();

            var cmRepo = IoC.Resolve <ICalculationMethodRepository>();
            var intestinalPermGroup     = _compound.ParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_INTESTINAL_PERMEABILITY);
            var paramAlternativeFactory = IoC.Resolve <IParameterAlternativeFactory>();
            var alternative             = paramAlternativeFactory.CreateAlternativeFor(intestinalPermGroup).WithName(_intestinalPermAlternativeName);

            intestinalPermGroup.AddAlternative(alternative);

            _intestinalPermeabilityCalcMethods = cmRepo.Where(cm => cm.Category.Equals(CoreConstants.Category.IntestinalPermeability)).ToList();
            _alternativeIntestinalPermParam    = alternative.Parameter(CoreConstants.Parameter.SpecificIntestinalPermeability);
            _simulationEngine = IoC.Resolve <ISimulationEngine <IndividualSimulation> >();
        }
Ejemplo n.º 11
0
        public void UpdateGainPerChargeInAlternatives(Compound compound, bool updateValues = true)
        {
            var gainPerCharge = compound.Parameter(CoreConstants.Parameter.SolubilityGainPerCharge);

            gainPerCharge.GroupName = CoreConstants.Groups.COMPOUND_SOLUBILITY;

            var solGroup = compound.ParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_SOLUBILITY);

            foreach (var alternative in solGroup.AllAlternatives)
            {
                var alternativeParameter = alternative.Parameter(CoreConstants.Parameter.SolubilityGainPerCharge);
                if (alternativeParameter != null)
                {
                    if (updateValues)
                    {
                        alternativeParameter.Value = gainPerCharge.Value;
                    }
                }
                else
                {
                    alternative.Add(_cloner.Clone(gainPerCharge));
                }
            }
        }
 public virtual void EditCompound(Compound compound)
 {
     _compound = compound;
     EditParameterGroup(compound.ParameterAlternativeGroup(_parameterGroupName));
 }
Ejemplo n.º 13
0
 private IEnumerable <ParameterAlternative> selectedAlternativesFor(Compound compound, CompoundProperties compoundProperties)
 {
     return(compoundProperties.CompoundGroupSelections.Select(groupSelection => compound.ParameterAlternativeGroup(groupSelection.GroupName)
                                                              .AlternativeByName(groupSelection.AlternativeName)));
 }