Skip to content

Commit

Permalink
Fixes #1904 and Fixes #1905 (#1907)
Browse files Browse the repository at this point in the history
* Fixes #1904 and Fixes #1905

* Add also fix for global parameters
  • Loading branch information
msevestre authored Oct 21, 2021
1 parent 96b2ad5 commit a4455e1
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace PKSim.Core.Services
public class CompetitiveInhibitionsKineticUpdaterSpecification : InteractionKineticUpdaterSpecificationBase
{
public CompetitiveInhibitionsKineticUpdaterSpecification(IObjectPathFactory objectPathFactory, IDimensionRepository dimensionRepository, IInteractionTask interactionTask) :
\ base(objectPathFactory, dimensionRepository, interactionTask, InteractionType.CompetitiveInhibition,
= kiNumeratorAlias: CoreConstants.Alias.COMPETITIVE_INHIBITION_KI,
base(objectPathFactory, dimensionRepository, interactionTask, InteractionType.CompetitiveInhibition,
kiNumeratorAlias: CoreConstants.Alias.COMPETITIVE_INHIBITION_KI,
kiNumeratorParameter: CoreConstants.Parameters.KI,
kiDenominatorAlias: CoreConstants.Alias.COMPETITIVE_INHIBITION_KI,
kiDenominatorParameter: CoreConstants.Parameters.KI,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public static class Parameters
public static readonly string RESIDUAL_FRACTION = "Residual fraction";
public static readonly string ScalingExponentForFluidRecircFlowRate = "Scaling exponent for fluid recirculation flow rate";
public static readonly string TabletTimeDelayFactor = "Tablet time delay factor";
public static readonly string REL_EXP_NORM = NormParameterFor(CoreConstants.Parameters.REL_EXP);
public static readonly string FRACTION_ENDOSOMAL = "Fraction endosomal";
public static readonly string NORM_SUFFIX = " (normalized)";

Expand All @@ -45,6 +44,10 @@ public static string NormParameterFor(string parameter)
return $"{parameter}{NORM_SUFFIX}";
}

public static readonly string REL_EXP_NORM = NormParameterFor(CoreConstants.Parameters.REL_EXP);
public static readonly string REL_EXP_BLOOD_CELLS_NORM = NormParameterFor(CoreConstants.Parameters.REL_EXP_BLOOD_CELLS);
public static readonly string REL_EXP_PLASMA_NORM = NormParameterFor(CoreConstants.Parameters.REL_EXP_PLASMA);
public static readonly string REL_EXP_VASCULAR_ENDOTHELIUM_NORM = NormParameterFor(CoreConstants.Parameters.REL_EXP_VASCULAR_ENDOTHELIUM);

public static IList<string> DistributedParametersWithOnlyOneSupportingPoint => new List<string>
{
Expand Down
30 changes: 28 additions & 2 deletions src/PKSim.Infrastructure/ProjectConverter/v10/Converter9To10.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using PKSim.Core.Services;
using PKSim.Core.Snapshots.Services;
using PKSim.Presentation;
using static PKSim.Infrastructure.ProjectConverter.ConverterConstants.Parameters;

namespace PKSim.Infrastructure.ProjectConverter.v10
{
Expand Down Expand Up @@ -108,7 +109,32 @@ private void convertIndividualTransporterNode(XElement transporterNode)

public void Visit(Population population) => convertIndividual(population.FirstIndividual);

public void Visit(Simulation simulation) => convertIndividual(simulation.BuildingBlock<Individual>());
public void Visit(Simulation simulation)
{
convertIndividual(simulation.BuildingBlock<Individual>());

var root = simulation.Model?.Root;
//This can be the case for instance for a MoBi simulation
if (root == null)
return;

//Also hide all relative expression normalized parameters (and we make sure they cannot be edited)
var allRelExpNormalized = root.GetAllChildren<IParameter>(x => x.IsNamed(REL_EXP_NORM)).ToList();
allRelExpNormalized.Each(hideNormalizedExpression);

var allGlobalRelExpNormalized = root.GetAllChildren<IParameter>(x => x.NameIsOneOf(
REL_EXP_BLOOD_CELLS_NORM,
REL_EXP_PLASMA_NORM,
REL_EXP_VASCULAR_ENDOTHELIUM_NORM
));
allGlobalRelExpNormalized.Each(hideNormalizedExpression);

void hideNormalizedExpression(IParameter x)
{
x.Visible = false;
x.Editable = false;
}
}

public void Visit(ParameterIdentification parameterIdentification)
{
Expand All @@ -131,7 +157,7 @@ private void addFractionEndosomalParametersTo(Individual individual)
{
var defaultHuman = _defaultIndividualRetriever.DefaultHuman();
var allFractionEndosomalParameters =
defaultHuman.GetAllChildren<IParameter>(x => x.IsNamed(ConverterConstants.Parameters.FRACTION_ENDOSOMAL));
defaultHuman.GetAllChildren<IParameter>(x => x.IsNamed(FRACTION_ENDOSOMAL));

allFractionEndosomalParameters.Each(x =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ public TExpressionParameterDTO MapFrom(IParameter parameter)

//Parameters are located in a molecule which is in a compartment => Parent.Parent
var compartment = parameter.ParentContainer.ParentContainer;

//Organ may be null for old simulations (v9.1 and below)
var organ = compartment.ParentContainer;

//Relative expression parameters not in lumen should be displayed directly under the organism
var compartmentName = parameter.IsExpression() && !parameter.IsInLumen() ? string.Empty : compartment.Name;
return createExpressionContainerParameterDTOFrom(organ.Name, compartmentName, groupName, parameter);
return createExpressionContainerParameterDTOFrom(organ?.Name, compartmentName, groupName, parameter);
}

private TExpressionParameterDTO createExpressionContainerParameterDTOFrom(string containerName, string compartmentName,
Expand Down
2 changes: 2 additions & 0 deletions src/PKSim.UI/Views/Core/BaseUserControlWithValueInGrid.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Windows.Forms;
using DevExpress.Utils;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Columns;
using OSPSuite.UI.Controls;
using OSPSuite.Utility.Extensions;

namespace PKSim.UI.Views.Core
{
Expand Down
Binary file added tests/PKSim.Tests/Data/9.1_P1.pksim5
Binary file not shown.
42 changes: 42 additions & 0 deletions tests/PKSim.Tests/ProjectConverter/v10/Converter9To10Specs.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,58 @@
using System.Collections.Generic;
using System.Linq;
using Castle.MicroKernel.SubSystems.Conversion;
using OSPSuite.BDDHelper;
using OSPSuite.BDDHelper.Extensions;
using OSPSuite.Core.Domain;
using OSPSuite.Utility.Extensions;
using PKSim.Core;
using PKSim.Core.Model;
using PKSim.Infrastructure.ProjectConverter;
using PKSim.Infrastructure.ProjectConverter.v10;
using PKSim.IntegrationTests;

namespace PKSim.ProjectConverter.v10
{
public class When_converting_the_9_1_P1_project_to_10 : ContextWithLoadedProject<Converter9To10>
{
private List<Simulation> _allSimulations;
private Simulation _simulation;

public override void GlobalContext()
{
base.GlobalContext();
LoadProject("9.1_P1");
_allSimulations = All<Simulation>().ToList();
_allSimulations.Each(Load);
_simulation = _allSimulations.First();
}

[Observation]
public void should_make_all_normalized_parameter_readonly_and_hidden()
{
var allRelExpNorms = _simulation.Model.Root.GetAllChildren<IParameter>(x => x.IsNamed(ConverterConstants.Parameters.REL_EXP_NORM));
allRelExpNorms.Any().ShouldBeTrue();
allRelExpNorms.Each(x=>x.Visible.ShouldBeFalse());
allRelExpNorms.Each(x => x.Editable.ShouldBeFalse());
}


[Observation]
public void should_make_all_global_normalized_parameter_readonly_and_hidden()
{
var allGlobalRelExpNorms = _simulation.Model.Root.GetAllChildren<IParameter>(x => x.NameIsOneOf(
ConverterConstants.Parameters.REL_EXP_BLOOD_CELLS_NORM,
ConverterConstants.Parameters.REL_EXP_PLASMA_NORM,
ConverterConstants.Parameters.REL_EXP_VASCULAR_ENDOTHELIUM_NORM
));
allGlobalRelExpNorms.Any().ShouldBeTrue();
allGlobalRelExpNorms.Each(x => x.Visible.ShouldBeFalse());
allGlobalRelExpNorms.Each(x => x.Editable.ShouldBeFalse());
}
}



public class When_converting_the_simple_project_730_project_to_10 : ContextWithLoadedProject<Converter9To10>
{
private List<PopulationSimulation> _allSimulations;
Expand Down

0 comments on commit a4455e1

Please sign in to comment.