Open-Systems-Pharmacology / OSPSuite.Core

Core functionalities of the Open Systems Pharmacology Suite
Other
5 stars 8 forks source link

Simulation named as top container #700

Closed Yuri05 closed 4 years ago

Yuri05 commented 4 years ago

If I try to create a simulation named e.g. "Organism" or "Neighborhoods" an Object reference not set is thrown. An explicit message would be better.

Also it's possible to give a simulation one of the existing enzyme names (e.g. "CYP1A2"). Such a simulation can be created in PK-Sim. If exported to MoBi, it then crashes when configuring etc.

Application:
PK-Sim® 8.0.22

Object reference not set to an instance of an object.

Stack trace:

at OSPSuite.Core.Domain.ObjectPathFactory.addPathEntry(IEntity entity, ObjectPath objectPath)
   at OSPSuite.Core.Domain.ObjectPathFactory.CreateAbsoluteObjectPath(IEntity entity)
   at OSPSuite.Core.Domain.Services.KeywordReplacerTask.addCommonNeighborhoodReplacersTo(IKeywordReplacerCollection keywordReplacer, INeighborhood neighborhood)
   at OSPSuite.Core.Domain.Services.KeywordReplacerTask.ReplaceIn(INeighborhood neighborhood, IContainer rootContainer)
   at OSPSuite.Core.Domain.Services.CalculationMethodTask.replaceKeyWordsIn(IParameter parameter, String moleculeName)
   at OSPSuite.Core.Domain.Services.CalculationMethodTask.createFormulaForBlackBoxParameters(ICoreCalculationMethod calculationMethod, IList`1 allMoleculesUsingMethod)
   at OSPSuite.Core.Domain.Services.CalculationMethodTask.MergeCalculationMethodInModel(IModel model, IBuildConfiguration buildConfiguration)
   at OSPSuite.Core.Domain.Services.ModelConstructor.createMoleculeCalculationMethodsFormula(IModel model, IBuildConfiguration buildConfiguration)
   at OSPSuite.Core.Domain.Services.ModelConstructor.createModelStructure(IModel model, IBuildConfiguration buildConfiguration)
   at OSPSuite.Core.Domain.Services.ModelConstructor.buildProcess(IModel model, IBuildConfiguration buildConfiguration, Func`3[] steps)
   at OSPSuite.Core.Domain.Services.ModelConstructor.CreateModelFrom(IBuildConfiguration buildConfiguration, String modelName)
   at PKSim.Core.Services.SimulationModelCreator.CreateModelFor(Simulation simulation, Boolean shouldValidate, Boolean shouldShowProgress)
   at PKSim.Presentation.Presenters.Simulations.CreateSimulationPresenter.UpdateSimulationProperties()
   at OSPSuite.Presentation.Services.HeavyWorkManager.doWork()
   at OSPSuite.Presentation.Services.HeavyWorkManager.<.ctor>b__9_1(Object o, DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
msevestre commented 4 years ago

this is actually something that should be forbidden upon model construction. I will throw an error from Core

Reason is

if the Model is named Organism and the first container is called Organism, our keyword replaced are trying to avoid creating duplicated path. They always add the name only if it's not alread there at the root of the path. This gets tricky with neighborhood referencing path etc..

There is probably a way to make this happen but because it's such a weird case, I am going to prevent it from happening at the first place

msevestre commented 4 years ago

This will be the message

The simulation name cannot be one of the following reserved terms:
    'Organism', 'Neighborhoods', 'A', 'B', 'D', 'C', 'E', 'F'.
Please rename your simulation.