public override void Execute(IExecutionContext context) { Add(new SetSpeciesInSpeciesDependentEntityCommand(_process, _species, context)); var defaultIndividualRetriever = context.Resolve <IDefaultIndividualRetriever>(); var defaultIndividual = defaultIndividualRetriever.DefaultIndividualFor(_species); var compoundProcessParameterMappingRepository = context.Resolve <ICompoundProcessParameterMappingRepository>(); var allProcessParametersWithDefaultValueInIndividual = _process.AllParameters() .Where(p => compoundProcessParameterMappingRepository.HasMappedParameterFor(_process.InternalName, p.Name)).ToList(); foreach (var parameter in allProcessParametersWithDefaultValueInIndividual) { var objectPath = compoundProcessParameterMappingRepository.MappedParameterPathFor(_process.InternalName, parameter.Name); var individualParameter = objectPath.Resolve <IParameter>(defaultIndividual); Add(new SetParameterValueCommand(parameter, individualParameter.Value) { Visible = false }); //Parameter updated from default individual should have the default value origin Add(new UpdateParameterValueOriginCommand(parameter, individualParameter.ValueOrigin) { Visible = false }); } base.Execute(context); _process = null; _species = null; }
private void bindProcessParameters(CompoundProcess process) { using (new BatchUpdate(_parametersPresenter)) { _parametersPresenter.EditParameters(process.AllParameters()); View.AdjustParametersHeight(_parametersPresenter.OptimalHeight); } }
public CompoundProcessDTO MapFrom(CompoundProcess compoundProcess) { var compoundProcessDTO = new CompoundProcessDTO(compoundProcess); SetProperties(compoundProcess, compoundProcessDTO); return(compoundProcessDTO); }
public IPKSimCommand SetSpeciesForProcess(CompoundProcess compoundProcess, Species species) { if (species == null) { return(new PKSimEmptyCommand()); } return(new SetSpeciesInCompoundProcessCommand(compoundProcess, species).Run(_executionContext)); }
private TProcess createProcessFromTemplate(CompoundProcess templateProcess) { var createdProcess = _compoundProcessTask.CreateProcessFromTemplate(templateProcess, _compound).DowncastTo <TProcess>(); _view.SpeciesVisible = createdProcess.IsAnImplementationOf <ISpeciesDependentCompoundProcess>(); _view.TemplateDescription = templateProcess.Description; return(createdProcess); }
private IReactionBuilder createReactionFromProcess(CompoundProcess process, string reactionName, IReadOnlyCollection <string> forbiddenNames) { //retrieve process for the simulation and create a clone var reaction = createReactionFromProcess(process, _simulationActiveProcessRepository.ProcessFor <PKSimReaction>(process.InternalName), reactionName, forbiddenNames); //make sure formula name is unique as it can be shared among processes reaction.Formula.Name = CoreConstants.CompositeNameFor(reaction.Name, reaction.Formula.Name); return(reaction); }
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 RenameDataSourceCommand(CompoundProcess compoundProcess, string newDataSource, IExecutionContext context) { _processId = compoundProcess.Id; BuildingBlockId = context.BuildingBlockIdContaining(compoundProcess); _newDataSource = newDataSource; _compoundProcess = compoundProcess; ObjectType = context.TypeFor(compoundProcess); CommandType = PKSimConstants.Command.CommandTypeEdit; context.UpdateBuildingBlockPropertiesInCommand(this, context.BuildingBlockContaining(compoundProcess)); }
public void RemoveProcess(CompoundProcess compoundProcess) { var question = _dialogCreator.MessageBoxYesNo(PKSimConstants.UI.ReallyDeleteProcess(_entityTask.TypeFor(compoundProcess), compoundProcess.Name)); if (question == ViewResult.No) { return; } AddCommand(_compoundProcessTask.RemoveProcess(_compound, compoundProcess)); }
private void updateSpeciesDependentParameter(Model.CompoundProcess process, CompoundProcess batchCompoundProcess) { if (string.IsNullOrEmpty(batchCompoundProcess.Species)) { return; } var species = _speciesRepository.FindById(batchCompoundProcess.Species); _compoundProcessTask.SetSpeciesForProcess(process, species); }
public override void GlobalContext() { base.GlobalContext(); LoadProject("IsDefaultConversion_722"); _compound = First <Compound>(); _formulation = First <Formulation>(); _event = First <PKSimEvent>(); _simpleProtocol = First <SimpleProtocol>(); _advancedProtocol = First <AdvancedProtocol>(); _tubularSecretionProcess = _compound.AllProcesses().FirstOrDefault(); }
public ChangeCompoundProcessInternalNameCommand(CompoundProcess compoundProcess, string internalName, IExecutionContext context) { _compoundProcess = compoundProcess; _internalName = internalName; _processId = compoundProcess.Id; _oldInternalName = _compoundProcess.InternalName; BuildingBlockId = context.BuildingBlockIdContaining(_compoundProcess); //This command is necessary to insure consitency but does not need to be seen context.UpdateBuildinBlockPropertiesInCommand(this, context.BuildingBlockContaining(_compoundProcess)); Visible = false; }
private ITransportBuilder activeTransportFrom(CompoundProcess process, string individualProcessName, IFormulaCache formulaCache) { //retrieve process for the simulation and create a clone var activeTransport = _cloner.Clone(_simulationActiveProcessRepository.TransportFor(individualProcessName, process.InternalName)); updateTransporterFormulaFromCache(activeTransport, formulaCache); //remove all parameters defined in the builder var allParameters = activeTransport.Parameters.ToList(); allParameters.Each(activeTransport.RemoveParameter); return(activeTransport); }
public IPKSimCommand RenameDataSource(CompoundProcess compoundProcess) { using (var renameDataSourcePresenter = _applicationController.Start <IRenameDataSourcePresenter>()) { if (!renameDataSourcePresenter.Edit(compoundProcess)) { return(new PKSimEmptyCommand()); } return(new RenameDataSourceCommand(compoundProcess, renameDataSourcePresenter.DataSource, _executionContext).Run(_executionContext)); } }
public ITransportBuilder PassiveTransportProcessFrom(CompoundProcess compoundProcess, string compoundName, IFormulaCache formulaCache) { var passiveProcess = _cloner.Clone(_simulationActiveProcessRepository.ProcessFor <PKSimTransport>(compoundProcess.InternalName)); passiveProcess.Name = compoundProcess.Name; passiveProcess.ForAll = false; passiveProcess.AddMoleculeName(compoundName); updateTransporterFormulaFromCache(passiveProcess, formulaCache); passiveProcess.Parameters.Where(x => !x.Formula.IsConstant()).Each(p => formulaCache.Add(p.Formula)); _parameterSetUpdater.UpdateValuesByName(compoundProcess.AllParameters(), passiveProcess.Parameters); return(passiveProcess); }
protected override void Context() { base.Context(); _formulaCache = A.Fake <IFormulaCache>(); _pkSimTransport = new PKSimTransport { Formula = A.Fake <IFormula>() }; _process = new SystemicProcess { InternalName = "Proc", Name = "BLA BLA" }; A.CallTo(() => _simulationActiveProcessRepository.ProcessFor <PKSimTransport>(_process.InternalName)).Returns(_pkSimTransport); A.CallTo(() => _cloneManager.Clone(_pkSimTransport)).Returns(_pkSimTransport); }
private void updateProcessParameters(Model.CompoundProcess compoundProcess, CompoundProcess batchCompoundProcess) { foreach (var parameterValue in batchCompoundProcess.ParameterValues) { var parameter = compoundProcess.Parameter(parameterValue.Key); if (parameter == null) { _batchLogger.AddWarning($"Parameter '{parameterValue.Key}' not found in process '{compoundProcess.InternalName}'"); continue; } parameter.Value = parameterValue.Value; _batchLogger.AddParameterValueToDebug(parameter); } }
public IReactionBuilder ComplexReactionFrom(CompoundProcess process, IMoleculeBuilder compoundBuilder, IMoleculeBuilder complex, string enzymeName, IReadOnlyCollection <string> forbiddenNames, IFormulaCache formulaCache) { //retrieve process for the simulation and create a clone var reaction = createReactionFromProcess(compoundBuilder, process, forbiddenNames); //replace keywords replaceKeywordsInProcess(reaction, new[] { CoreConstants.KeyWords.Molecule, CoreConstants.KeyWords.Protein, CoreConstants.KeyWords.Complex, CoreConstants.KeyWords.Reaction }, new[] { compoundBuilder.Name, enzymeName, complex.Name, reaction.Name }); reaction.AddEduct(new ReactionPartnerBuilder(compoundBuilder.Name, 1)); reaction.AddEduct(new ReactionPartnerBuilder(enzymeName, 1)); reaction.AddProduct(new ReactionPartnerBuilder(complex.Name, 1)); formulaCache.Add(reaction.Formula); return(reaction); }
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 ITransportBuilder activeTransportFrom(CompoundProcess process, InducedProcess inducedProcess, IFormulaCache formulaCache) { //retrieve process for the simulation and create a clone var simulationProcess = _simulationActiveProcessRepository.TransportFor(inducedProcess.Name, process.InternalName); if (simulationProcess == null) { throw new PKSimException(PKSimConstants.Error.CannotCreateTransportProcessWithKinetic(inducedProcess.Name, process.Name)); } var activeTransport = _cloner.Clone(simulationProcess); updateTransporterFormulaFromCache(activeTransport, formulaCache); //remove all parameters defined in the builder var allParameters = activeTransport.Parameters.ToList(); allParameters.Each(activeTransport.RemoveParameter); return(activeTransport); }
protected override void Context() { _executionContext = A.Fake <IExecutionContext>(); _project = new PKSimProject(); A.CallTo(() => _executionContext.CurrentProject).Returns(_project); _compound = new Compound().WithId("Tralala").WithName("Tralala"); _project.AddBuildingBlock(_compound); _proc = new EnzymaticProcess().WithName("ActProc1"); var serializedStream = new byte[1]; A.CallTo(() => _executionContext.Serialize(_proc)).Returns(serializedStream); A.CallTo(() => _executionContext.Deserialize <CompoundProcess>(serializedStream)).Returns(_proc); A.CallTo(() => _executionContext.Get <Compound>(_compound.Id)).Returns(_compound); A.CallTo(() => _executionContext.Get <CompoundProcess>(_proc.Id)).Returns(_proc); sut = new AddProcessToCompoundCommand(_proc, _compound, _executionContext); }
public TransporterMoleculeContainer ActiveTransportFrom(CompoundProcess compoundProcess, IndividualTransporter transporter, IFormulaCache formulaCache) { var transporterMoleculeContainer = _objectBaseFactory.Create <TransporterMoleculeContainer>().WithName(compoundProcess.InternalName); transporterMoleculeContainer.Icon = compoundProcess.Icon; transporterMoleculeContainer.TransportName = compoundProcess.Name; foreach (var inducedProcess in transporter.AllInducedProcesses()) { var activeTransporterBuilder = activeTransportFrom(compoundProcess, inducedProcess, formulaCache); transporterMoleculeContainer.Icon = activeTransporterBuilder.Icon; activeTransporterBuilder.TransportType = transporter.TransportType; transporterMoleculeContainer.AddActiveTransportRealization(activeTransporterBuilder); updateTransporterTagsFor(transporter, activeTransporterBuilder, inducedProcess); } _parameterContainerTask.AddProcessBuilderParametersTo(transporterMoleculeContainer); _parameterSetUpdater.UpdateValuesByName(compoundProcess.AllParameters(), transporterMoleculeContainer.Parameters); transporterMoleculeContainer.Name = transporter.Name; return(transporterMoleculeContainer); }
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); }
protected override void Context() { base.Context(); _process = new EnzymaticProcess().WithName("tralala"); _process.InternalName = "internalNAme"; _drug = new MoleculeBuilder().WithName("drug"); _metabolite = new MoleculeBuilder().WithName("metabolite"); _enzymeName = "enzyme"; _formulaCache = new FormulaCache(); _kinetic = new ExplicitFormula().WithId("trala").WithName("KINETIC"); _kinetic.AddObjectPath(new FormulaUsablePath(new[] { "Organism", CoreConstants.KeyWords.Molecule })); _kinetic.AddObjectPath(new FormulaUsablePath(new[] { "Organism", CoreConstants.KeyWords.Protein })); _parameterFormula = new ExplicitFormula(); _parameterFormula.AddObjectPath(new FormulaUsablePath(new[] { "Liver", CoreConstants.KeyWords.Molecule })); _parameterInReaction = new PKSimParameter().WithName("p").WithFormula(_parameterFormula); var pkSimReaction = new PKSimReaction().WithName("template"); pkSimReaction.AddParameter(_parameterInReaction); A.CallTo(() => _simulationActiveProcessRepository.ProcessFor <PKSimReaction>(_process.InternalName)).Returns(pkSimReaction); pkSimReaction.Formula = _kinetic; A.CallTo(() => _cloneManager.Clone <IReactionBuilder>(pkSimReaction)).Returns(pkSimReaction); }
protected override void Because() { _result = sut.CreateProcessFromTemplate(_template, _compound); }
public override void RestoreExecutionData(IExecutionContext context) { base.RestoreExecutionData(context); _compoundProcess = context.Get <PartialProcess>(_processId); }
protected override void ClearReferences() { _compoundProcess = null; }
public SystemicProcessDTO(CompoundProcess process) : base(process) { Rules.AddRange(SystemicProcessRules.All()); }
public void AddActiveProcessParametersTo(CompoundProcess process) { addParametersTo(process, null, CoreConstants.CalculationMethod.ForProcesses); }