Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/MoBi.Core/Domain/Model/MoBiProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public override void AddParameterIdentification(ParameterIdentification paramete
parameterIdentification.IsLoaded = true;
}

/// <summary>
/// Returns all simulations or building blocks matching <typeparamref name="T"/>
/// </summary>
public override IReadOnlyCollection<T> All<T>() => get<T>();

public IEnumerable<CurveChart> Charts => _charts;
Expand All @@ -57,7 +60,7 @@ public void RemoveModule(Module module)

public IReadOnlyList<IMoBiSimulation> Simulations => _allSimulations;

private IReadOnlyList<T> get<T>() => _buildingBlocks.OfType<T>().ToList();
private IReadOnlyList<T> get<T>() => _buildingBlocks.OfType<T>().Concat(_allSimulations.OfType<T>()).ToList();

public IReadOnlyList<ExpressionProfileBuildingBlock> ExpressionProfileCollection => get<ExpressionProfileBuildingBlock>();

Expand Down Expand Up @@ -104,7 +107,7 @@ public override void AcceptVisitor(IVisitor visitor)

public IReadOnlyList<IMoBiSimulation> SimulationsUsing(IBuildingBlock templateBuildingBlock) => Simulations.Where(simulation => simulation.Uses(templateBuildingBlock)).ToList();

public IEnumerable<IObjectBase> All() => All<IObjectBase>().Union(Simulations);
public IEnumerable<IObjectBase> All() => All<IObjectBase>();

/// <summary>
/// Returns a list of simulations that have a module where the name matches <paramref name="module" />
Expand Down
6 changes: 3 additions & 3 deletions src/MoBi.Core/Snapshots/Mappers/ProjectMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ private async Task<ModelProject> mapToModel(SnapshotProject projectSnapshot, Pro
var observedData = await ObservedDataFrom(projectSnapshot.ObservedData, snapshotContext);
observedData?.Each(repository => AddObservedDataToProject(project, repository));

var parameterIdentifications = await AllParameterIdentificationsFrom(projectSnapshot.ParameterIdentifications, snapshotContext);
parameterIdentifications?.Each(pi => AddParameterIdentificationToProject(project, pi));

var simulationContext = new SimulationContext(context.RunSimulations, snapshotContext)
{
NumberOfSimulationsToLoad = projectSnapshot.Simulations?.Length ?? 0,
Expand All @@ -142,6 +139,9 @@ private async Task<ModelProject> mapToModel(SnapshotProject projectSnapshot, Pro
}
}

var parameterIdentifications = await AllParameterIdentificationsFrom(projectSnapshot.ParameterIdentifications, snapshotContext);
parameterIdentifications?.Each(pi => AddParameterIdentificationToProject(project, pi));

if (simulationContext.Run && project.Simulations.Any())
{
await runParallelSimulations(project);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System.Linq;
using FakeItEasy;
using MoBi.Core.Domain.Model;
using OSPSuite.BDDHelper;
using OSPSuite.BDDHelper.Extensions;
using OSPSuite.Core.Domain.Services;
using OSPSuite.Utility.Container;

namespace MoBi.IntegrationTests.Snapshots
{
public class When_loading_a_snapshot_with_a_parameter_identification_referencing_a_simulation : ContextWithLoadedSnapshot
{
public override void GlobalContext()
{
base.GlobalContext();

var validationTask = IoC.Resolve<IEntityValidationTask>();
A.CallTo(() => validationTask.Validate(A<MoBiSimulation>._)).Returns(true);

LoadSnapshot("snapshot_no_pksim_modules");
}

[Observation]
public void the_simulation_is_loaded()
{
_project.Simulations.Count.ShouldBeEqualTo(1);
_project.Simulations[0].Name.ShouldBeEqualTo("test");
}

[Observation]
public void the_parameter_identification_retains_its_simulation()
{
var parameterIdentification = _project.AllParameterIdentifications.Single();
parameterIdentification.AllSimulations.Select(x => x.Name).ShouldContain("test");
}

[Observation]
public void the_identification_parameter_is_linked_to_the_simulation_parameter()
{
var parameterIdentification = _project.AllParameterIdentifications.Single();
parameterIdentification.AllIdentificationParameters.Count.ShouldBeEqualTo(1);
}
}
}
37 changes: 36 additions & 1 deletion tests/MoBi.Tests/TestFiles/snapshot_no_pksim_modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,42 @@
"ParameterIdentifications": [
{
"Name": "Parameter Identification 1",
"Simulations": [],
"Simulations": [
"test"
],
"OutputMappings": [
{
"Scaling": "Log",
"Path": "test|Organism|PeripheralVenousBlood|Theophylline|Plasma (Peripheral Venous Blood)",
"ObservedData": "Human.Plasma.IV.Subj 1.Human.Plasma.IV.Subj 1"
}
],
"IdentificationParameters": [
{
"Name": "Fraction vascular",
"Scaling": "Linear",
"LinkedParameters": [
"test|Organism|ArterialBlood|Fraction vascular"
],
"Parameters": [
{
"Name": "Start value",
"Value": 1.0,
"ValueOrigin": {}
},
{
"Name": "MinValue",
"Value": 0.0,
"ValueOrigin": {}
},
{
"Name": "MaxValue",
"Value": 1.0,
"ValueOrigin": {}
}
]
}
],
"Configuration": {
"LLOQMode": "SimulationOutputAsObservedDataLLOQ",
"RemoveLLOQMode": "Never",
Expand Down