public override void GlobalContext() { base.GlobalContext(); _compoundProcessRepository = IoC.Resolve <ICompoundProcessRepository>(); _cloneManager = IoC.Resolve <ICloneManager>(); _liverMicrosomeFirstOrder = _cloneManager.Clone(_compoundProcessRepository.ProcessByName(CoreConstantsForSpecs.Process.METABOLIZATION_LIVER_MICROSOME_FIRST_ORDER)); _liverMicrosomeFirstOrder.Name = "liverMicrosomeFirstOrder"; _liverMicrosomeRes = _cloneManager.Clone(_compoundProcessRepository.ProcessByName(CoreConstantsForSpecs.Process.LIVER_MICROSOME_RES)); _liverMicrosomeRes.Name = "liverMicrosomeRes"; }
public override void GlobalContext() { base.GlobalContext(); _compoundProcessRepository = IoC.Resolve <ICompoundProcessRepository>(); _cloneManager = IoC.Resolve <ICloneManager>(); _enzymeFactory = IoC.Resolve <IIndividualEnzymeFactory>(); _transporterFactory = IoC.Resolve <IIndividualTransporterFactory>(); _modelPropertiesTask = IoC.Resolve <IModelPropertiesTask>(); _modelConfigurationRepository = IoC.Resolve <IModelConfigurationRepository>(); _compound = DomainFactoryForSpecs.CreateStandardCompound(); _individual = DomainFactoryForSpecs.CreateStandardIndividual(); _protocol = DomainFactoryForSpecs.CreateStandardIVBolusProtocol(); _enzyme = _enzymeFactory.CreateFor(_individual).DowncastTo <IndividualEnzyme>().WithName("CYP"); _enzyme.GetRelativeExpressionNormParameterFor(CoreConstants.Compartment.Plasma).Value = _relExpNormPls; _enzyme.GetRelativeExpressionNormParameterFor(CoreConstants.Compartment.BloodCells).Value = _relExpNormBloodCells; _enzyme.GetRelativeExpressionNormParameterFor(CoreConstants.Compartment.VascularEndothelium).Value = _relExpVascEndo; _individual.AddMolecule(_enzyme); _hct = _individual.Organism.Parameter(CoreConstants.Parameters.HCT).Value; _metabolizationProcess = _cloneManager.Clone(_compoundProcessRepository.ProcessByName(CoreConstantsForSpecs.Process.METABOLIZATION_SPECIFIC_FIRST_ORDER).DowncastTo <PartialProcess>()); _metabolizationProcess.Name = "My Partial Process"; _metabolizationProcess.Parameter(ConverterConstants.Parameter.CLspec).Value = 15; _compound.AddProcess(_metabolizationProcess); _simulationRunOptions = new SimulationRunOptions { RaiseEvents = false }; }
public override void GlobalContext() { base.GlobalContext(); _compoundProcessRepo = IoC.Resolve <ICompoundProcessRepository>(); _interactionTask = IoC.Resolve <IInteractionTask>(); var cloner = IoC.Resolve <ICloneManager>(); var enzymeFactory = IoC.Resolve <IIndividualEnzymeFactory>(); var transporterFactory = IoC.Resolve <IIndividualTransporterFactory>(); var inhibitor = DomainFactoryForSpecs.CreateStandardCompound().WithName("Inhibitor"); var protocol2 = DomainFactoryForSpecs.CreateStandardIVBolusProtocol().WithName("IV2"); var allPartialProcesses = PartialProcesses.ToList(); foreach (var metaTemplate in allPartialProcesses) { var moleculeName = "Molecule_" + metaTemplate.Name; if (metaTemplate as EnzymaticProcess != null) { var individualProtein = enzymeFactory.CreateFor(_individual).WithName(moleculeName); _individual.AddMolecule(individualProtein.DowncastTo <IndividualEnzyme>().WithName(moleculeName)); } else { var individualProtein = transporterFactory.CreateFor(_individual).WithName(moleculeName); _individual.AddMolecule(individualProtein.DowncastTo <IndividualTransporter>().WithName(moleculeName)); } var process = cloner.Clone(metaTemplate).DowncastTo <PartialProcess>(); process.Name = "Process " + moleculeName; process.MoleculeName = moleculeName; _compound.AddProcess(process); var inhibitionTemplate = _compoundProcessRepo.ProcessByName <InteractionProcess>(InhibitionProcessName); var inhibitionProcess = cloner.Clone(inhibitionTemplate); inhibitionProcess.Name = "InhibitionProcess " + moleculeName; inhibitionProcess.MoleculeName = moleculeName; inhibitor.AddProcess(inhibitionProcess); } _simulation = DomainFactoryForSpecs.CreateModelLessSimulationWith( _individual, new[] { _compound, inhibitor }, new[] { _protocol, protocol2 }).DowncastTo <IndividualSimulation>(); foreach (var inhibitionProcess in inhibitor.AllProcesses <InteractionProcess>()) { var interactionSelection = new InteractionSelection { CompoundName = inhibitor.Name, MoleculeName = inhibitionProcess.MoleculeName, ProcessName = inhibitionProcess.Name }; _simulation.InteractionProperties.AddInteraction(interactionSelection); } DomainFactoryForSpecs.AddModelToSimulation(_simulation); }
private void convertCompound(Compound compound) { if (compound == null) { return; } var templateCompound = _compoundFactory.Create().WithName(compound.Name); var solubilityTable = templateCompound.Parameter(CoreConstants.Parameters.SOLUBILITY_TABLE); compound.Add(_cloner.Clone(solubilityTable)); var solubilityGroup = compound.ParameterAlternativeGroup(CoreConstants.Groups.COMPOUND_SOLUBILITY); solubilityGroup.AllAlternatives.Each(x => x.Add(_cloner.Clone(solubilityTable))); var templateParameterCache = _containerTask.CacheAllChildrenSatisfying <IParameter>(templateCompound, x => !x.IsDefault); var compoundParameterCache = _containerTask.CacheAllChildren <IParameter>(compound); foreach (var parameterPath in templateParameterCache.Keys) { setAsInput(compoundParameterCache[parameterPath]); } foreach (var templateAlternativeGroup in templateCompound.AllParameterAlternativeGroups()) { var templateAlternative = templateAlternativeGroup.AllAlternatives.First(); var compoundGroup = compound.ParameterAlternativeGroup(templateAlternativeGroup.Name); foreach (var alternative in compoundGroup.AllAlternatives) { updateIsInputStateByNameAndValue(alternative, templateAlternative); } } foreach (var process in compound.AllProcesses()) { var templateProcess = _compoundProcessRepository.ProcessByName(process.InternalName); updateIsInputStateByNameAndValue(process, templateProcess); } _converted = true; }
private TProcess retrieveProcessFrom <TProcess>(CompoundProcess batchCompoundProcess) where TProcess : Model.CompoundProcess { var template = _compoundProcessRepository.ProcessByName <TProcess>(batchCompoundProcess.InternalName); if (template == null) { _batchLogger.AddWarning($"Could not find process named '{batchCompoundProcess.InternalName}' in database"); return(null); } var process = _cloner.Clone(template); process.DataSource = batchCompoundProcess.DataSource; if (template.IsAnImplementationOf <ISpeciesDependentCompoundProcess>()) { updateSpeciesDependentParameter(process, batchCompoundProcess); } updateProcessParameters(process, batchCompoundProcess); return(process); }
private async Task <ModelCompoundProcess> retrieveProcessFrom(CompoundProcess snapshot, SnapshotContext snapshotContext) { var template = _compoundProcessRepository.ProcessByName(snapshot.InternalName); if (template == null) { _logger.AddError(PKSimConstants.Error.SnapshotProcessNameNotFound(snapshot.InternalName)); return(null); } var process = _cloner.Clone(template); process.DataSource = snapshot.DataSource; if (process.IsAnImplementationOf <ISpeciesDependentCompoundProcess>()) { updateSpeciesDependentParameter(process, snapshot); } await UpdateParametersFromSnapshot(snapshot, process, snapshotContext, process.InternalName); return(process); }