private Model.CompoundProcess notSelectedProcessFrom(CompoundProcessSelection snapshotCompoundProcessSelection, ISimulationSubject simulationSubject) { //Partial process var moleculeName = snapshotCompoundProcessSelection.MoleculeName; var systemicProcessType = snapshotCompoundProcessSelection.SystemicProcessType; //this should be a specific process if (!string.IsNullOrEmpty(systemicProcessType)) { return new NotSelectedSystemicProcess { SystemicProcessType = SystemicProcessTypes.ById(systemicProcessType) } } ; if (string.IsNullOrEmpty(moleculeName)) { return(null); } var molecule = simulationSubject.MoleculeByName(moleculeName); if (molecule == null) { return(null); } switch (molecule) { case IndividualTransporter _: return(new TransportPartialProcess { MoleculeName = moleculeName }); case IndividualEnzyme _: return(new EnzymaticProcess { MoleculeName = moleculeName }); case IndividualOtherProtein _: return(new SpecificBindingPartialProcess { MoleculeName = moleculeName }); } return(null); }
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); }
public override object ConvertFrom(string attributeValue, SerializationContext context) { return(SystemicProcessTypes.ById(attributeValue)); }