예제 #1
0
        public ModelCompound MapFrom(BatchCompound batchCompound)
        {
            var compound = _compoundFactory.Create();

            compound.Name = batchCompound.Name;
            setValue(compound, CoreConstants.Groups.COMPOUND_LIPOPHILICITY,
                     CoreConstants.Parameter.LIPOPHILICITY, batchCompound.Lipophilicity);

            setValue(compound, CoreConstants.Groups.COMPOUND_FRACTION_UNBOUND,
                     CoreConstants.Parameter.FractionUnbound, batchCompound.FractionUnbound);

            setValue(compound, Constants.Parameters.MOL_WEIGHT, batchCompound.MolWeight);

            setValue(compound, CoreConstants.Parameter.CL, batchCompound.Cl);

            setValue(compound, CoreConstants.Parameter.F, batchCompound.F);

            setValue(compound, CoreConstants.Parameter.BR, batchCompound.Br);

            setValue(compound, CoreConstants.Parameter.I, batchCompound.I);

            setValue(compound, CoreConstants.Parameter.IS_SMALL_MOLECULE, batchCompound.IsSmallMolecule ? 1 : 0);

            setValue(compound, CoreConstants.Groups.COMPOUND_SOLUBILITY,
                     CoreConstants.Parameter.SolubilityAtRefpH, batchCompound.SolubilityAtRefpH);

            setValue(compound, CoreConstants.Groups.COMPOUND_SOLUBILITY,
                     CoreConstants.Parameter.RefpH, batchCompound.RefpH);

            for (int i = 0; i < batchCompound.PkaTypes.Count; i++)
            {
                setPka(compound, batchCompound.PkaTypes[i], i);
            }

            foreach (var batchSystemicProcess in batchCompound.SystemicProcesses)
            {
                var systemicProcess = retrieveProcessFrom <Model.SystemicProcess>(batchSystemicProcess);
                if (systemicProcess == null)
                {
                    continue;
                }

                systemicProcess.SystemicProcessType = SystemicProcessTypes.ById(batchSystemicProcess.SystemicProcessType);
                systemicProcess.RefreshName();
                compound.AddProcess(systemicProcess);
            }

            foreach (var batchPartialProcess in batchCompound.PartialProcesses)
            {
                var partialProcess = retrieveProcessFrom <Model.PartialProcess>(batchPartialProcess);
                if (partialProcess == null)
                {
                    continue;
                }

                partialProcess.MoleculeName = batchPartialProcess.MoleculeName;
                partialProcess.RefreshName();
                compound.AddProcess(partialProcess);
            }

            //Update default with available CM in configuration
            foreach (var calculationMethodName in batchCompound.CalculationMethods)
            {
                var calculationMethod = _calculationMethodRepository.FindByName(calculationMethodName);
                if (calculationMethod == null)
                {
                    _batchLogger.AddWarning($"Calculation method '{calculationMethodName}' not found");
                    continue;
                }

                var category = _calculationMethodCategoryRepository.FindByName(calculationMethod.Category);
                if (category == null)
                {
                    _batchLogger.AddWarning($"Could not find compound category '{calculationMethod.Category}' for calculation method '{calculationMethodName}.");
                    continue;
                }

                //this is a compound calculationmethod. Swap them out
                var existingCalculationMethod = compound.CalculationMethodFor(category);
                compound.RemoveCalculationMethod(existingCalculationMethod);
                compound.AddCalculationMethod(calculationMethod);

                _batchLogger.AddDebug($"Using calculation method '{calculationMethod.Name}' instead of '{existingCalculationMethod.Name}' for category '{calculationMethod.Category}'");
            }

            return(compound);
        }
예제 #2
0
 protected CalculationMethodCategory CalculationMethodCategory(string category)
 {
     return(_compoundCalculationMethodCategoryRepository.FindByName(category));
 }