-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2364 export expression profile domain object (#2461)
* initial try * temp nuget update * adjusting mapper * Fixes #2344 Implement "Parameter Value Export" for Expression Profiles BB in PK-Sim (#2442) * use GetAllChildren of Individual (#2445) * 2438 outptu mappings not cleared (#2444) * waiting for Core PR to be accepted * nugets updated * updating nuget * temp nuget update * working export * spacing * updating packages * do not map object path for 'ROOT' * do not repeat formulae in the formula cache * adding tests * fixing test * correction * consolidate assets * correcting nugets * code review changes * code review * PR feedback * update core version * Appveyor builds turned on * PR feedback * pr feedback Co-authored-by: Robert McIntosh <261477+rwmcintosh@users.noreply.github.com>
- Loading branch information
1 parent
6ad7c98
commit 608c162
Showing
53 changed files
with
439 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
src/PKSim.Core/Mappers/ExpressionProfileToExpressionProfileBuildingBlockMapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using OSPSuite.Core; | ||
using OSPSuite.Core.Domain; | ||
using OSPSuite.Core.Domain.Builder; | ||
using OSPSuite.Core.Domain.Formulas; | ||
using OSPSuite.Core.Domain.Services; | ||
using OSPSuite.Utility; | ||
using PKSim.Assets; | ||
using PKSim.Core.Model; | ||
using IFormulaFactory = PKSim.Core.Model.IFormulaFactory; | ||
|
||
namespace PKSim.Core.Mappers | ||
{ | ||
public interface IExpressionProfileToExpressionProfileBuildingBlockMapper : IMapper<ExpressionProfile, ExpressionProfileBuildingBlock> | ||
{ | ||
} | ||
|
||
public class ExpressionProfileToExpressionProfileBuildingBlockMapper : IExpressionProfileToExpressionProfileBuildingBlockMapper | ||
{ | ||
private readonly IObjectBaseFactory _objectBaseFactory; | ||
private readonly IEntityPathResolver _entityPathResolver; | ||
private readonly IFormulaFactory _formulaFactory; | ||
private readonly IApplicationConfiguration _applicationConfiguration; | ||
|
||
public ExpressionProfileToExpressionProfileBuildingBlockMapper(IObjectBaseFactory objectBaseFactory, IEntityPathResolver entityPathResolver, IFormulaFactory formulaFactory, IApplicationConfiguration applicationConfiguration) | ||
{ | ||
_objectBaseFactory = objectBaseFactory; | ||
_entityPathResolver = entityPathResolver; | ||
_formulaFactory = formulaFactory; | ||
_applicationConfiguration = applicationConfiguration; | ||
} | ||
|
||
public ExpressionProfileBuildingBlock MapFrom(ExpressionProfile expressionProfile) | ||
{ | ||
var expressionProfileBuildingBlock = _objectBaseFactory.Create<ExpressionProfileBuildingBlock>(); | ||
|
||
expressionProfileBuildingBlock.Name = expressionProfile.Name; | ||
expressionProfileBuildingBlock.PKSimVersion = _applicationConfiguration.Version; | ||
expressionProfileBuildingBlock.Description = expressionProfile.Description; | ||
|
||
expressionProfileBuildingBlock.Type = mapExpressionType(expressionProfile.Molecule.MoleculeType); | ||
|
||
var allParameters = expressionProfile.GetAllChildren<IParameter>(); | ||
|
||
foreach (var parameter in allParameters) | ||
{ | ||
var expressionParameter = mapExpressionParameterFromExpressionProfile(parameter, expressionProfileBuildingBlock); | ||
expressionProfileBuildingBlock.Add(expressionParameter); | ||
} | ||
|
||
return expressionProfileBuildingBlock; | ||
} | ||
|
||
private ExpressionType mapExpressionType(QuantityType moleculeType) | ||
{ | ||
switch (moleculeType) | ||
{ | ||
case QuantityType.Enzyme: | ||
return ExpressionTypes.MetabolizingEnzyme; | ||
case QuantityType.Transporter: | ||
return ExpressionTypes.TransportProtein; | ||
case QuantityType.OtherProtein: | ||
return ExpressionTypes.ProteinBindingPartner; | ||
} | ||
|
||
throw new PKSimException(PKSimConstants.Error.CouldNotFindMoleculeType(moleculeType.ToString())); | ||
} | ||
|
||
private ExpressionParameter mapExpressionParameterFromExpressionProfile(IParameter parameter, | ||
ExpressionProfileBuildingBlock expressionProfileBuildingBlock) | ||
{ | ||
var expressionParameter = _objectBaseFactory.Create<ExpressionParameter>(); | ||
|
||
if (parameter.Formula != null && parameter.Formula.IsCachable()) | ||
{ | ||
var formula = _formulaFactory.RateFor(CoreConstants.CalculationMethod.EXPRESSION_PARAMETERS, parameter.Formula.Name, | ||
expressionProfileBuildingBlock.FormulaCache); | ||
expressionParameter.Formula = formula; | ||
} | ||
else | ||
{ | ||
(expressionParameter.StartValue, _) = parameter.TryGetValue(); | ||
} | ||
|
||
expressionParameter.Name = parameter.Name; | ||
|
||
expressionParameter.Path = _entityPathResolver.ObjectPathFor(parameter); | ||
expressionParameter.Dimension = parameter.Dimension; | ||
expressionParameter.DisplayUnit = parameter.DisplayUnit; | ||
return expressionParameter; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.