Skip to content

Commit

Permalink
Fixes #2256 snapshot initial concentration issue
Browse files Browse the repository at this point in the history
  • Loading branch information
msevestre committed Jul 29, 2022
1 parent 27d6496 commit acda375
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/PKSim.Core/Snapshots/Mappers/ParameterMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ public override async Task<IParameter> MapToModel(SnapshotParameter snapshot, Pa
parameter.DisplayUnit = parameter.Dimension.UnitOrDefault(displayUnit);

//This needs to come AFTER formula update so that the base value is accurate
var baseValue = parameter.Value;
var snapshotValueInBaseUnit = parameter.ConvertToBaseUnit(snapshot.Value);

if (!ValueComparer.AreValuesEqual(baseValue, snapshotValueInBaseUnit))
var (value, success) = parameter.TryGetValue();

//Value could not be parsed (e.g. Initial concentration was overwritten) or the value are indeed different
if (!success || !ValueComparer.AreValuesEqual(value, snapshotValueInBaseUnit))
{
parameter.Value = snapshotValueInBaseUnit;
parameter.IsDefault = false;
Expand Down
154 changes: 154 additions & 0 deletions tests/PKSim.Tests/Data/ind_expression_with_modified_initial_conc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"Version": 79,
"ExpressionProfiles": [
{
"Type": "Enzyme",
"Species": "Human",
"Molecule": "CYP3A4",
"Category": "European (P-gp modified, CYP3A4 REFINED 36 h)",
"Parameters": [
{
"Path": "CYP3A4|Reference concentration",
"Value": 4.32,
"Unit": "µmol/l"
},
{
"Path": "CYP3A4|t1/2 (intestine)",
"Value": 23.0,
"Unit": "h"
},
{
"Path": "CYP3A4|t1/2 (liver)",
"Value": 36.0,
"Unit": "h",
"ValueOrigin": {
"Source": "Unknown"
}
},
{
"Path": "Organism|Brain|Intracellular|CYP3A4|Relative expression",
"Value": 0.0,
"ValueOrigin": {
"Source": "Unknown"
}
},
{
"Path": "Organism|Gonads|Intracellular|CYP3A4|Relative expression",
"Value": 0.0,
"ValueOrigin": {
"Source": "Unknown"
}
},
{
"Path": "Organism|Kidney|Intracellular|CYP3A4|Relative expression",
"Value": 0.0,
"ValueOrigin": {
"Source": "Unknown"
}
},
{
"Path": "Organism|Liver|Pericentral|Intracellular|CYP3A4|Initial concentration",
"Value": 3.414,
"Unit": "µmol/l"
},
{
"Path": "Organism|Liver|Pericentral|Intracellular|CYP3A4|Relative expression",
"Value": 0.0,
"ValueOrigin": {
"Source": "Unknown"
}
},
{
"Path": "Organism|Liver|Periportal|Intracellular|CYP3A4|Initial concentration",
"Value": 3.414,
"Unit": "µmol/l"
},
{
"Path": "Organism|Liver|Periportal|Intracellular|CYP3A4|Relative expression",
"Value": 0.0,
"ValueOrigin": {
"Source": "Unknown"
}
},
{
"Path": "Organism|Lung|Intracellular|CYP3A4|Relative expression",
"Value": 0.0,
"ValueOrigin": {
"Source": "Unknown"
}
},
{
"Path": "Organism|SmallIntestine|Intracellular|CYP3A4|Relative expression",
"Value": 0.0,
"ValueOrigin": {
"Source": "Unknown"
}
},
{
"Path": "Organism|SmallIntestine|Mucosa|Duodenum|Intracellular|CYP3A4|Initial concentration",
"Value": 0.516,
"Unit": "µmol/l"
},
{
"Path": "Organism|SmallIntestine|Mucosa|Duodenum|Intracellular|CYP3A4|Relative expression",
"Value": 0.0,
"ValueOrigin": {
"Source": "Unknown"
}
},
{
"Path": "Organism|SmallIntestine|Mucosa|LowerIleum|Intracellular|CYP3A4|Initial concentration",
"Value": 0.138,
"Unit": "µmol/l"
},
{
"Path": "Organism|SmallIntestine|Mucosa|LowerIleum|Intracellular|CYP3A4|Relative expression",
"Value": 0.0,
"ValueOrigin": {
"Source": "Unknown"
}
},
{
"Path": "Organism|SmallIntestine|Mucosa|LowerJejunum|Intracellular|CYP3A4|Initial concentration",
"Value": 0.268,
"Unit": "µmol/l"
},
{
"Path": "Organism|SmallIntestine|Mucosa|LowerJejunum|Intracellular|CYP3A4|Relative expression",
"Value": 0.0,
"ValueOrigin": {
"Source": "Unknown"
}
},
{
"Path": "Organism|SmallIntestine|Mucosa|UpperIleum|Intracellular|CYP3A4|Initial concentration",
"Value": 0.136,
"Unit": "µmol/l"
},
{
"Path": "Organism|SmallIntestine|Mucosa|UpperIleum|Intracellular|CYP3A4|Relative expression",
"Value": 0.0,
"ValueOrigin": {
"Source": "Unknown"
}
},
{
"Path": "Organism|SmallIntestine|Mucosa|UpperJejunum|Intracellular|CYP3A4|Initial concentration",
"Value": 0.283,
"Unit": "µmol/l"
},
{
"Path": "Organism|SmallIntestine|Mucosa|UpperJejunum|Intracellular|CYP3A4|Relative expression",
"Value": 0.0,
"ValueOrigin": {
"Source": "Unknown"
}
}
],
"Localization": "Intracellular, BloodCellsIntracellular, VascEndosome",
"Ontogeny": {
"Name": "CYP3A4"
}
}
]
}
17 changes: 17 additions & 0 deletions tests/PKSim.Tests/IntegrationTests/IndividualMapperSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,21 @@ public void should_have_set_the_value_of_the_global_molecule_parameters_as_expec
}
}

public class When_loading_a_snapshot_with_an_expression_profile_where_the_initial_concentration_was_overwritten : ContextWithLoadedSnapshot
{
private ExpressionProfile _expressionProfile;

public override void GlobalContext()
{
base.GlobalContext();
LoadSnapshot("ind_expression_with_modified_initial_conc");
_expressionProfile = First<ExpressionProfile>();
}

[Observation]
public void should_have_been_able_to_load_the_profile()
{
_expressionProfile.ShouldNotBeNull();
}
}
}

0 comments on commit acda375

Please sign in to comment.