Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2525 creating individual from MoBi (PK-Sim code changes) #2526

Merged
merged 19 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from 17 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
4 changes: 2 additions & 2 deletions src/PKSim.Assets.Images/PKSim.Assets.Images.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OSPSuite.Assets" Version="12.0.111" />
<PackageReference Include="OSPSuite.Assets.Images" Version="12.0.111" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.114" />
<PackageReference Include="OSPSuite.Assets.Images" Version="12.0.114" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/PKSim.Assets/PKSim.Assets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OSPSuite.Assets" Version="12.0.111" />
<PackageReference Include="OSPSuite.Assets.Images" Version="12.0.111" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.114" />
<PackageReference Include="OSPSuite.Assets.Images" Version="12.0.114" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/PKSim.BatchTool/BatchRegister.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public override void RegisterInContainer(IContainer container)
scan.WithDefaultConvention();
});

container.Register<IUserSettings, ICoreUserSettings, OSPSuite.Core.ICoreUserSettings, IPresentationUserSettings, BatchUserSettings>(LifeStyle.Singleton);
container.Register<IUserSettings, ICoreUserSettings, OSPSuite.Core.ICoreUserSettings, OSPSuite.Presentation.IPresentationUserSettings, BatchUserSettings>(LifeStyle.Singleton);
container.Register<IDiagramModelToXmlMapper, CLIDiagramModelToXmlMapper>();
container.Register<IDiagramModel, CLIDiagramModel>();
container.Register<IJournalDiagramManagerFactory, CLIJournalDiagramManagerFactory>();
Expand Down
4 changes: 2 additions & 2 deletions src/PKSim.BatchTool/PKSim.BatchTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OSPSuite.Core" Version="12.0.111" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.111" />
<PackageReference Include="OSPSuite.Core" Version="12.0.114" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.114" />
<PackageReference Include="OSPSuite.DevExpress" Version="21.2.3" />
<PackageReference Include="OSPSuite.FuncParser" Version="4.0.0.54" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModel" Version="4.0.0.53" GeneratePathProperty="true" />
Expand Down
4 changes: 2 additions & 2 deletions src/PKSim.CLI.Core/PKSim.CLI.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OSPSuite.Assets" Version="12.0.111" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.114" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Core" Version="12.0.111" />
<PackageReference Include="OSPSuite.Core" Version="12.0.114" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/PKSim.CLI/PKSim.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.0" />
<PackageReference Include="OSPSuite.Core" Version="12.0.111" />
<PackageReference Include="OSPSuite.Presentation" Version="12.0.111" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.111" />
<PackageReference Include="OSPSuite.Core" Version="12.0.114" />
<PackageReference Include="OSPSuite.Presentation" Version="12.0.114" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.114" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.FuncParser" Version="4.0.0.54" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModel" Version="4.0.0.53" GeneratePathProperty="true" />
Expand Down
4 changes: 2 additions & 2 deletions src/PKSim.Core/Model/CompoundProcessParameterMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public interface ICompoundProcessParameterMapping
/// <summary>
/// Path to the mapped parameter (e.g. ORGANISM/Liver/Volume)
/// </summary>
IObjectPath MappedParameterPath { get; set; }
ObjectPath MappedParameterPath { get; set; }
}

public class CompoundProcessParameterMapping : ICompoundProcessParameterMapping
{
public string ProcessName { get; set; }
public string ParameterName { get; set; }
public IObjectPath MappedParameterPath { get; set; }
public ObjectPath MappedParameterPath { get; set; }
}
}
8 changes: 4 additions & 4 deletions src/PKSim.Core/Model/FormulaFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public IFormula DoseFromDosePerBodySurfaceAreaFor(IFormulaCache formulaCache)
return RateFor(CoreConstants.CalculationMethod.APPLICATION_PARAMETER_HUMAN, CoreConstants.Rate.APPLICATION_DOSE_FROM_DOSE_PER_BODY_SURFACE_AREA, formulaCache);
}

private IFormulaUsablePath pathInParentContainerFor(IParameter parameter, string alias)
private FormulaUsablePath pathInParentContainerFor(IParameter parameter, string alias)
{
return _objectPathFactory.CreateFormulaUsablePathFrom(ObjectPath.PARENT_CONTAINER, parameter.Name)
.WithAlias(alias)
Expand Down Expand Up @@ -338,7 +338,7 @@ private IFormula createFormula(RateKey rateKey)

foreach (var rateObjectPath in _rateObjectPathsRepository.ObjectPathsFor(rateKey))
{
formula.AddObjectPath(rateObjectPath.Clone<IFormulaUsablePath>());
formula.AddObjectPath(rateObjectPath.Clone<FormulaUsablePath>());
}

addTimeReferenceIfNeeded(formula);
Expand Down Expand Up @@ -395,8 +395,8 @@ private IFormula createTableFormulaWithOffset(RateKey rateKey)
if (tableObjectPath == null || offsetObjectPath == null)
throw new ArgumentException(PKSimConstants.Error.TableFormulaWithOffsetMissingRefs(rateKey.ToString(), CoreConstants.Alias.TABLE, CoreConstants.Alias.OFFSET));

formula.AddTableObjectPath(tableObjectPath.Clone<IFormulaUsablePath>());
formula.AddOffsetObjectPath(offsetObjectPath.Clone<IFormulaUsablePath>());
formula.AddTableObjectPath(tableObjectPath.Clone<FormulaUsablePath>());
formula.AddOffsetObjectPath(offsetObjectPath.Clone<FormulaUsablePath>());

//Table formula with offest has the same dimension as its referenced table object
formula.Dimension = tableObjectPath.Dimension;
Expand Down
6 changes: 3 additions & 3 deletions src/PKSim.Core/Model/MoleculeStartFormula.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface IMoleculeStartFormula
/// <summary>
/// Database path to the molecule, e.g. "ORGANISM\Liver\Plasma\DRUG"
/// </summary>
IObjectPath MoleculePath { get; }
ObjectPath MoleculePath { get; }

/// <summary>
/// Calculation method and rate for given formula
Expand All @@ -20,13 +20,13 @@ public interface IMoleculeStartFormula

public class MoleculeStartFormula : IMoleculeStartFormula
{
public MoleculeStartFormula(IObjectPath moleculePath, string calculationMethod, string rate)
public MoleculeStartFormula(ObjectPath moleculePath, string calculationMethod, string rate)
{
MoleculePath = moleculePath;
RateKey = new RateKey(calculationMethod, rate);
}

public IObjectPath MoleculePath { get; private set; }
public ObjectPath MoleculePath { get; private set; }
public RateKey RateKey { get; private set; }
}
}
2 changes: 2 additions & 0 deletions src/PKSim.Core/Model/PKSimBuildingBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ public virtual ContainerMode Mode
}

public virtual IReadOnlyList<IEntity> Children => Root.Children;

public ObjectPath ParentPath { get; set; }

public IEnumerator<IEntity> GetEnumerator()
{
Expand Down
18 changes: 9 additions & 9 deletions src/PKSim.Core/Model/RateObjectPaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ public interface IRateObjectPaths
{
string Rate { get; }
string CalculationMethod { get; }
IEnumerable<IFormulaUsablePath> ObjectPaths { get; }
void AddObjectPath(IFormulaUsablePath objectPath);
IEnumerable<FormulaUsablePath> ObjectPaths { get; }
void AddObjectPath(FormulaUsablePath objectPath);
}

public class RateObjectPaths : IRateObjectPaths
{
private readonly IList<IFormulaUsablePath> _objectPaths;
private readonly IList<FormulaUsablePath> _objectPaths;
public string Rate { get; private set; }
public string CalculationMethod { get; private set; }

public RateObjectPaths(string calculationMethod, string rate)
{
CalculationMethod = calculationMethod;
Rate = rate;
_objectPaths = new List<IFormulaUsablePath>();
_objectPaths = new List<FormulaUsablePath>();
}

public IEnumerable<IFormulaUsablePath> ObjectPaths
public IEnumerable<FormulaUsablePath> ObjectPaths
{
get { return _objectPaths; }
}

public void AddObjectPath(IFormulaUsablePath objectPath)
public void AddObjectPath(FormulaUsablePath objectPath)
{
_objectPaths.Add(objectPath);
}
Expand All @@ -40,12 +40,12 @@ public class NullObjectPaths : IRateObjectPaths
public string Rate { get; private set; }
public string CalculationMethod { get; private set; }

public IEnumerable<IFormulaUsablePath> ObjectPaths
public IEnumerable<FormulaUsablePath> ObjectPaths
{
get { return new List<IFormulaUsablePath>(); }
get { return new List<FormulaUsablePath>(); }
}

public void AddObjectPath(IFormulaUsablePath objectPath)
public void AddObjectPath(FormulaUsablePath objectPath)
{
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/PKSim.Core/PKSim.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Core" Version="12.0.111" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.111" />
<PackageReference Include="OSPSuite.Assets.Images" Version="12.0.111" />
<PackageReference Include="OSPSuite.Infrastructure.Import" Version="12.0.111" />
<PackageReference Include="OSPSuite.Core" Version="12.0.114" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.114" />
<PackageReference Include="OSPSuite.Assets.Images" Version="12.0.114" />
<PackageReference Include="OSPSuite.Infrastructure.Import" Version="12.0.114" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
</ItemGroup>

Expand Down
51 changes: 51 additions & 0 deletions src/PKSim.Core/PKSimStarterRegistrationConvention.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using OSPSuite.Utility.Container;
using System.Collections.Generic;
using System.Linq;
using OSPSuite.Core;
using OSPSuite.Core.Commands.Core;
using OSPSuite.Utility;
using OSPSuite.Utility.Extensions;

namespace PKSim.Core
{
/// <summary>
/// Register components in the container that are relevant for the PKSimStarter
/// </summary>
public class PKSimStarterRegistrationConvention : PKSimRegistrationConvention
{
public override void Process(Type concreteType, IContainer container, LifeStyle lifeStyle)
{
if (!shouldRegisterType(concreteType))
return;

base.Process(concreteType, container, lifeStyle);
}

private bool shouldRegisterType(Type concreteType)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this done here and not in the register with the Include exclude. ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this => scan.Include(shouldRegisterType);?

{
if (concreteType.FullName == null)
return false;

if (concreteType.FullName.Contains("ExpressionProfile"))
return true;

if (concreteType.FullName.Contains("Individual"))
return true;

if (concreteType.FullName.Contains("Parameter"))
return true;

if (concreteType.FullName.Contains("Mapper"))
return true;

if (concreteType.FullName.Contains("Factory"))
return true;

if (concreteType.FullName.Contains("Tooltip"))
return true;

return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface ICompoundProcessParameterMappingRepository : IRepository<ICompo
/// </summary>
/// <param name="compoundProcessName">Internal name of the compound process</param>
/// <param name="processParameterName">Name of parameter</param>
IObjectPath MappedParameterPathFor(string compoundProcessName, string processParameterName);
ObjectPath MappedParameterPathFor(string compoundProcessName, string processParameterName);

/// <summary>
/// Returns true if a mapping is available for the give{Process, ParameterName} otherwise false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public interface IModelContainerMoleculeRepository : IStartableRepository<string
/// - for moleculeName = DRUG return true
/// - for moleculeName != DRUG return false
/// </summary>
bool IsPresent(string modelName, IObjectPath containerPath, string moleculeName);
bool IsPresent(string modelName, ObjectPath containerPath, string moleculeName);

/// <summary>
/// Checks if molecule is available in container (for given model).<para/>
/// Default behaviour for the case no entry for {model, container, molecule} is found: return false
/// </summary>
bool NegativeValuesAllowed(string modelName, IObjectPath containerPath, string moleculeName);
bool NegativeValuesAllowed(string modelName, ObjectPath containerPath, string moleculeName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public interface IMoleculeStartFormulaRepository : IStartableRepository<IMolecul
/// <paramref name="moleculePath" /> must be a database path to the molecule (e.g. "ORGANISM\Liver\Plasma\DRUG")
/// </summary>
/// <returns>Rate key if found, null if not found</returns>
RateKey RateKeyFor(IObjectPath moleculePath, ModelProperties modelProperties);
RateKey RateKeyFor(ObjectPath moleculePath, ModelProperties modelProperties);
}
}
6 changes: 3 additions & 3 deletions src/PKSim.Core/Repositories/IRateObjectPathsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ namespace PKSim.Core.Repositories
{
public interface IRateObjectPathsRepository : IStartableRepository<IRateObjectPaths>
{
IEnumerable<IFormulaUsablePath> ObjectPathsFor(string rate, string calculationMethod);
IEnumerable<IFormulaUsablePath> ObjectPathsFor(RateKey rateKey);
IEnumerable<FormulaUsablePath> ObjectPathsFor(string rate, string calculationMethod);
IEnumerable<FormulaUsablePath> ObjectPathsFor(RateKey rateKey);

/// <summary>
/// returns the first path defined for the ratekey with the given alias. If not path is found, returns null
/// </summary>
IFormulaUsablePath PathWithAlias(RateKey rateKey, string alias);
FormulaUsablePath PathWithAlias(RateKey rateKey, string alias);
}
}
4 changes: 2 additions & 2 deletions src/PKSim.Core/Services/DataRepositoryFromResultsCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ private bool columnIsSelected(DataColumn column, OutputSelections outputSelectio
/// <param name="simulation"></param>
/// <param name="path"></param>
/// <returns></returns>
private Tuple<IQuantity, IObjectPath> quantityAndPathFrom(Simulation simulation, IEnumerable<string> path)
private Tuple<IQuantity, ObjectPath> quantityAndPathFrom(Simulation simulation, IReadOnlyList<string> path)
{
var objectPath = _objectPathFactory.CreateObjectPathFrom(path).AndAddAtFront(simulation.Name);
var quantity = objectPath.TryResolve<IQuantity>(simulation.Model.Root);
return new Tuple<IQuantity, IObjectPath>(quantity, objectPath);
return new Tuple<IQuantity, ObjectPath>(quantity, objectPath);
}

private DataRepository createDataRepositoryWithBaseGrid(Simulation simulation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private void createPlasmaProteinOntogenyTable(IBuildConfiguration buildConfigura
private void createParameterValueVersionOntogenyTableParameter(
IParameter ontogenyFactorParameter,
IBuildConfiguration buildConfiguration,
IObjectPath ontogenyFactorPath,
ObjectPath ontogenyFactorPath,
IndividualMolecule molecule)
{
var psv = buildConfiguration.ParameterStartValues;
Expand Down Expand Up @@ -345,7 +345,7 @@ PopulationSimulation populationSimulation
}
}

private void createPopulationOntogenyTableParameter(IParameter ontogenyFactorParameter, IObjectPath ontogenyFactorPath, IndividualMolecule molecule, PopulationSimulation populationSimulation)
private void createPopulationOntogenyTableParameter(IParameter ontogenyFactorParameter, ObjectPath ontogenyFactorPath, IndividualMolecule molecule, PopulationSimulation populationSimulation)
{
addAgingDataToPopulationSimulation(populationSimulation, ontogenyFactorPath.ToString(), ontogenyFactorParameter,
p => createOntogenyTableFormulaFrom(p.Parameter, molecule.Ontogeny, p.OriginData, populationSimulation.RandomGenerator));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,24 @@ protected virtual IReadOnlyList<InteractionProcess> AllInteractionProcessesFor(s
return _interactionTask.AllInteractionProcessesFor(moleculeName, _interactionType, simulation, compoundName);
}

private IFormulaUsablePath kiPath(string kiParameter, Compound inhibitor, InteractionProcess process, string kiAlias)
private FormulaUsablePath kiPath(string kiParameter, Compound inhibitor, InteractionProcess process, string kiAlias)
{
return _objectPathFactory.CreateFormulaUsablePathFrom(inhibitor.Name, process.Name, kiParameter)
.WithAlias(kiAlias)
.WithDimension(_dimensionRepository.MolarConcentration);
}

private IFormulaUsablePath inhibitorConcentrationPath(Compound inhibitor, string inhibitorAlias, IContainer processParameterContainer)
private FormulaUsablePath inhibitorConcentrationPath(Compound inhibitor, string inhibitorAlias, IContainer processParameterContainer)
{
return localInhibitorParameterPath(inhibitor, Constants.Parameters.CONCENTRATION, inhibitorAlias, processParameterContainer, _dimensionRepository.MolarConcentration);
}

private IFormulaUsablePath kwaterPath(Compound inhibitor, string kwaterAlias, IContainer processParameterContainer)
private FormulaUsablePath kwaterPath(Compound inhibitor, string kwaterAlias, IContainer processParameterContainer)
{
return localInhibitorParameterPath(inhibitor, CoreConstants.Parameters.K_WATER, kwaterAlias, processParameterContainer, _dimensionRepository.NoDimension);
}

private IFormulaUsablePath localInhibitorParameterPath(Compound inhibitor, string parameterName, string parameterAlias, IContainer processParameterContainer, IDimension dimension)
private FormulaUsablePath localInhibitorParameterPath(Compound inhibitor, string parameterName, string parameterAlias, IContainer processParameterContainer, IDimension dimension)
{
var objectPath = _objectPathFactory.CreateFormulaUsablePathFrom(inhibitor.Name, parameterName)
.WithAlias(parameterAlias)
Expand Down
Loading