Skip to content

Commit

Permalink
Fixes #2140 fraction basolateral not set properly (#2144)
Browse files Browse the repository at this point in the history
  • Loading branch information
msevestre authored Mar 28, 2022
1 parent 61c5946 commit bc79201
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
8 changes: 6 additions & 2 deletions src/PKSim.Core/Services/TransportContainerUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ public void SetDefaultSettingsForTransporter(ISimulationSubject simulationSubjec
foreach (var transporterContainer in simulationSubject.AllMoleculeContainersFor<TransporterExpressionContainer>(transporter))
{
updateTransporterContainerFromTemplate(transporterContainer, null, transportType);
updateFractionExpressedEpithelial(transporterContainer, transportType);
updateFractionExpressedApical(transporterContainer, transportType);
}
}

private void updateFractionExpressedEpithelial(TransporterExpressionContainer transporterContainer, TransportType transportType)
private void updateFractionExpressedApical(TransporterExpressionContainer transporterContainer, TransportType transportType)
{
if (!transportType.IsOneOf(TransportType.Efflux, TransportType.Influx, TransportType.PgpLike))
return;
Expand All @@ -73,6 +73,10 @@ private void updateFractionExpressedEpithelial(TransporterExpressionContainer tr
if (fractionExpressedApical == null)
return;

//Parameter is a hidden parameter. This is used for consistency purpose only and should not be updated
if (!fractionExpressedApical.Visible)
return;

//value was set by the user.
if (fractionExpressedApical.Value != 0 && fractionExpressedApical.Value != 1)
return;
Expand Down
29 changes: 24 additions & 5 deletions tests/PKSim.Tests/Core/TransportContainerUpdaterSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public abstract class concern_for_TransportContainerUpdater : ContextSpecificati
protected IEventPublisher _eventPublisher;
protected ITransportDirectionRepository _transportDirectionRepository;
protected IParameter _fractionExpressedApical;
protected IParameter _fractionExpressedApicalBone;
protected IParameter _fractionExpressedApicalMucosa;
protected ISimulationSubject _individual;
protected TransporterExpressionContainer _transporterWithTemplate;
Expand All @@ -26,6 +27,7 @@ public abstract class concern_for_TransportContainerUpdater : ContextSpecificati
protected TransporterContainerTemplate _transporterContainerTemplate;
protected IndividualTransporter _transporter;
private TransporterExpressionContainer _transporterInMucosa;
private TransporterExpressionContainer _transporterInBone;

protected override void Context()
{
Expand All @@ -35,6 +37,9 @@ protected override void Context()
sut = new TransportContainerUpdater(_repository, _eventPublisher);
_fractionExpressedApical = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName(CoreConstants.Parameters.FRACTION_EXPRESSED_APICAL);
_fractionExpressedApicalMucosa = DomainHelperForSpecs.ConstantParameterWithValue(0).WithName(CoreConstants.Parameters.FRACTION_EXPRESSED_APICAL);
_fractionExpressedApicalBone = DomainHelperForSpecs.ConstantParameterWithValue(1).WithName(CoreConstants.Parameters.FRACTION_EXPRESSED_APICAL);
//Indicates that this parameter should not be visible to the user and therefore remains unchanged
_fractionExpressedApicalBone.Visible = false;
_individual = A.Fake<ISimulationSubject>();
_individual.Species.Name = _species;
_transporter = new IndividualTransporter {TransportType = TransportType.Efflux, Name = "toto"};
Expand All @@ -44,6 +49,8 @@ protected override void Context()
var liverCell = new Container().WithName(CoreConstants.Compartment.INTRACELLULAR).WithParentContainer(liver);
var kidney = new Container().WithName(CoreConstants.Organ.KIDNEY).WithParentContainer(organism);
var kidneyCell = new Container().WithName(CoreConstants.Compartment.INTRACELLULAR).WithParentContainer(kidney);
var bone = new Container().WithName(CoreConstants.Organ.BONE).WithParentContainer(organism);
var boneInterstitial = new Container().WithName(CoreConstants.Compartment.INTERSTITIAL).WithParentContainer(bone);
_transporterWithTemplate = new TransporterExpressionContainer {TransportDirection = TransportDirectionId.InfluxInterstitialToIntracellular}
.WithParentContainer(liverCell);
_transporterWithoutTemplate = new TransporterExpressionContainer
Expand All @@ -52,11 +59,16 @@ protected override void Context()

_transporterInMucosa = new TransporterExpressionContainer {TransportDirection = TransportDirectionId.InfluxInterstitialToIntracellular}
.WithParentContainer(mucosa);

_transporterInBone = new TransporterExpressionContainer { TransportDirection = TransportDirectionId.InfluxInterstitialToIntracellular }
.WithParentContainer(boneInterstitial);

_transporterInMucosa.Add(_fractionExpressedApicalMucosa);
_transporterWithoutTemplate.Add(_fractionExpressedApical);
_transporterInBone.Add(_fractionExpressedApicalBone);

A.CallTo(() => _individual.AllMoleculeContainersFor<TransporterExpressionContainer>(_transporter))
.Returns(new[] {_transporterWithTemplate, _transporterWithoutTemplate, _transporterInMucosa });
.Returns(new[] {_transporterWithTemplate, _transporterWithoutTemplate, _transporterInMucosa, _transporterInBone });

_transporterContainerTemplate = new TransporterContainerTemplate {TransportType = TransportType.Influx};
_allTransporterTemplates.Add(_transporterContainerTemplate);
Expand Down Expand Up @@ -139,7 +151,7 @@ protected override void Because()
}

[Observation]
public void should_set_the_value_of_the_fraction_expressed_epithelial_to_one()
public void should_set_the_value_of_the_fraction_expressed_apical_to_one()
{
_fractionExpressedApical.Value.ShouldBeEqualTo(1);
}
Expand All @@ -153,19 +165,26 @@ protected override void Because()
}

[Observation]
public void should_set_the_value_of_the_fraction_expressed_epithelial_to_zero_in_all_non_mucosa_compartment()
public void should_set_the_value_of_the_fraction_expressed_apical_to_zero_in_all_non_mucosa_compartment()
{
_fractionExpressedApical.Value.ShouldBeEqualTo(0);
}


[Observation]
public void should_not_change_the_value_of_fraction_expressed_apical_for_organ_that_only_have_this_parameter_for_consistency_purpose_such_as_bone()
{
_fractionExpressedApicalBone.Value.ShouldBeEqualTo(1);
}

[Observation]
public void should_set_the_value_of_the_fraction_expressed_epithelial_to_one_in_all_mucosa_compartment()
public void should_set_the_value_of_the_fraction_expressed_apical_to_one_in_all_mucosa_compartment()
{
_fractionExpressedApicalMucosa.Value.ShouldBeEqualTo(1);
}
}

public class When_updating_the_transport_type_from_efflux_to_influx_and_the_fraction_expressed_epithelial_was_changed_by_the_user : concern_for_TransportContainerUpdater
public class When_updating_the_transport_type_from_efflux_to_influx_and_the_fraction_expressed_apical_was_changed_by_the_user : concern_for_TransportContainerUpdater
{
protected override void Context()
{
Expand Down

0 comments on commit bc79201

Please sign in to comment.