-
Notifications
You must be signed in to change notification settings - Fork 50
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
2586 parameters not common for all species #2587
Changes from 4 commits
4586b4c
5b45a3a
82fff03
b1c2f0c
809ba9b
864ad1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
UPDATE tab_container_parameter_values SET default_value=124000.0 WHERE parameter_value_version='InVitroClearance_PKSim' AND species='Cattle' AND container_id=159 AND container_type='ORGAN' AND container_name='Liver' AND parameter_name='Number of cells/g tissue'; | ||
|
||
Original file line number | Diff line number | Diff line change | |||||
---|---|---|---|---|---|---|---|
|
@@ -91937,4 +91937,62 @@ CREATE VIEW VIEW_KNOWN_TRANSPORTER_CONTAINERS AS SELECT | ||||||
t.CONTAINER_NAME AS ContainerName, | |||||||
t.MEMBRANE AS MembraneLocation | |||||||
FROM tab_known_transporters_containers t; | |||||||
CREATE VIEW [ContainerParameters_Species] | |||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This view is database internal (not used by PK-Sim) |
|||||||
AS | |||||||
SELECT DISTINCT | |||||||
[cpc].[container_id], | |||||||
[cpc].[container_type], | |||||||
[cpc].[container_name], | |||||||
[cpc].[parameter_name], | |||||||
[species] | |||||||
FROM [tab_container_parameter_curves] AS [cpc], | |||||||
[tab_container_parameters] AS [cp] | |||||||
WHERE [cpc].[container_id] = [cp].[container_id] | |||||||
AND [cpc].[parameter_name] = [cp].[parameter_name] | |||||||
AND [building_block_type] = "INDIVIDUAL" | |||||||
UNION | |||||||
SELECT DISTINCT | |||||||
[cpv].[container_id], | |||||||
[cpv].[container_type], | |||||||
[cpv].[container_name], | |||||||
[cpv].[parameter_name], | |||||||
[species] | |||||||
FROM [tab_container_parameter_values] AS [cpv], | |||||||
[tab_container_parameters] AS [cp] | |||||||
WHERE [cpv].[container_id] = [cp].[container_id] | |||||||
AND [cpv].[parameter_name] = [cp].[parameter_name] | |||||||
AND [building_block_type] = "INDIVIDUAL" | |||||||
UNION | |||||||
SELECT DISTINCT | |||||||
[cpr].[container_id], | |||||||
[cpr].[container_type], | |||||||
[cpr].[container_name], | |||||||
[cpr].[parameter_name], | |||||||
[species] | |||||||
FROM [tab_container_parameter_rates] AS [cpr], | |||||||
[tab_species_calculation_methods] AS [scm], | |||||||
[tab_container_parameters] AS [cp] | |||||||
WHERE [cpr].[calculation_method] = [scm].[calculation_method] | |||||||
AND [cpr].[container_id] = [cp].[container_id] | |||||||
AND [cpr].[parameter_name] = [cp].[parameter_name] | |||||||
AND [building_block_type] = "INDIVIDUAL"; | |||||||
CREATE VIEW [VIEW_CONTAINER_PARAMETER_NOT_FOR_ALL_SPECIES] | |||||||
AS | |||||||
SELECT DISTINCT | |||||||
[ContainerParameters_Species].[container_id] AS [ContainerId], | |||||||
[ContainerParameters_Species].[container_type] AS [ContainerType], | |||||||
[ContainerParameters_Species].[container_name] AS [ContainerName], | |||||||
[ContainerParameters_Species].[parameter_name] AS [ParameterName], | |||||||
COUNT ([ContainerParameters_Species].[species]) AS [SpeciesCount] | |||||||
FROM [ContainerParameters_Species] | |||||||
GROUP BY | |||||||
[container_id], | |||||||
[container_type], | |||||||
[container_name], | |||||||
[parameter_name] | |||||||
HAVING COUNT ([species]) < (SELECT COUNT ([species]) | |||||||
FROM [tab_species]) | |||||||
ORDER BY | |||||||
[container_id], | |||||||
[parameter_name]; | |||||||
Comment on lines
+91979
to
+91997
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the view used by PK-Sim. It retrieves the table
Species count tells in how many species the parameter is defined (currently this info is not used by PK-Sim) |
|||||||
COMMIT; | |||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
using OSPSuite.Utility.Collections; | ||
|
||
namespace PKSim.Core.Repositories | ||
{ | ||
public interface IContainerParametersNotCommonForAllSpeciesRepository : IStartableRepository<(string ContainerPath, string ParameterName, int SpeciesCount)> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the repo which retrieves the info, if a parameter is used by all species or not. I did not defined a new type for the repo objects, because they are probably not of interest So I just defined a named tuple instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hum....this is not what we do normally and just for consistency sake, I would use a type here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, can change it, np |
||
{ | ||
bool UsedForAllSpecies(string containerPath, string parameterName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the function, which returns if a parameter in a container is used for all species or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need one for the parmaeter path completely as well probably. but I can add if required. Looks good |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace PKSim.Infrastructure.ORM.FlatObjects | ||
{ | ||
public class FlatContainerParametersNotCommonForAllSpecies | ||
{ | ||
public int ContainerId { get; set; } | ||
public string ContainerType { get; set; } | ||
public string ContainerName { get; set; } | ||
public string ParameterName { get; set; } | ||
public int SpeciesCount { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using OSPSuite.Utility.Collections; | ||
using PKSim.Core.Repositories; | ||
|
||
namespace PKSim.Infrastructure.ORM.Repositories | ||
{ | ||
public class ContainerParametersNotCommonForAllSpeciesRepository: StartableRepository<(string ContainerPath, string ParameterName, int SpeciesCount)>, IContainerParametersNotCommonForAllSpeciesRepository | ||
{ | ||
private readonly IFlatContainerRepository _flatContainerRepository; | ||
private readonly IFlatContainerParametersNotCommonForAllSpeciesRepository _flatContainerParametersNotCommonForAllSpeciesRepository; | ||
|
||
private readonly List<(string ContainerPath, string ParameterName, int SpeciesCount)> _containerParametersNotCommonForAllSpecies; | ||
private readonly ICache<string, List<string>> _parametersNotCommonForAllSpeciesByContainer; | ||
|
||
public ContainerParametersNotCommonForAllSpeciesRepository( | ||
IFlatContainerRepository flatContainerRepository, | ||
IFlatContainerParametersNotCommonForAllSpeciesRepository flatContainerParametersNotCommonForAllSpeciesRepository) | ||
{ | ||
_flatContainerRepository = flatContainerRepository; | ||
_flatContainerParametersNotCommonForAllSpeciesRepository = flatContainerParametersNotCommonForAllSpeciesRepository; | ||
|
||
_containerParametersNotCommonForAllSpecies = new List<(string ContainerPath, string ParameterName, int SpeciesCount)>(); | ||
_parametersNotCommonForAllSpeciesByContainer = new Cache<string, List<string>>(); | ||
} | ||
|
||
protected override void DoStart() | ||
{ | ||
var flatContainerParametersNotCommonForAllSpecies = _flatContainerParametersNotCommonForAllSpeciesRepository.All().ToList(); | ||
|
||
foreach(var containerParameter in flatContainerParametersNotCommonForAllSpecies) | ||
{ | ||
var containerPath = _flatContainerRepository.ContainerPathFrom(containerParameter.ContainerId).ToString(); | ||
_containerParametersNotCommonForAllSpecies.Add((containerPath, containerParameter.ParameterName, containerParameter.SpeciesCount)); | ||
} | ||
|
||
//cache the parameters by container path | ||
foreach (var containerParametersInContainer in _containerParametersNotCommonForAllSpecies.GroupBy(x => x.ContainerPath)) | ||
{ | ||
_parametersNotCommonForAllSpeciesByContainer.Add(containerParametersInContainer.Key, containerParametersInContainer.Select(cp=>cp.ParameterName).ToList()); | ||
} | ||
} | ||
|
||
public override IEnumerable<(string ContainerPath, string ParameterName, int SpeciesCount)> All() | ||
{ | ||
Start(); | ||
return _containerParametersNotCommonForAllSpecies; | ||
} | ||
|
||
public bool UsedForAllSpecies(string containerPath, string parameterName) | ||
{ | ||
Start(); | ||
var parametersUsedNotForAllSpeciesInContainer = _parametersNotCommonForAllSpeciesByContainer[containerPath]; | ||
|
||
return parametersUsedNotForAllSpeciesInContainer == null || !parametersUsedNotForAllSpeciesInContainer.Contains(parameterName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the combination There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means, that if a container or parameter path is invalid - the function would also return true |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using PKSim.Core; | ||
using PKSim.Infrastructure.ORM.Core; | ||
using PKSim.Infrastructure.ORM.FlatObjects; | ||
using PKSim.Infrastructure.ORM.Mappers; | ||
|
||
namespace PKSim.Infrastructure.ORM.Repositories | ||
{ | ||
public interface IFlatContainerParametersNotCommonForAllSpeciesRepository : IMetaDataRepository<FlatContainerParametersNotCommonForAllSpecies> | ||
{ | ||
} | ||
|
||
public class FlatContainerParametersNotCommonForAllSpeciesRepository : MetaDataRepository<FlatContainerParametersNotCommonForAllSpecies>, IFlatContainerParametersNotCommonForAllSpeciesRepository | ||
{ | ||
public FlatContainerParametersNotCommonForAllSpeciesRepository(IDbGateway dbGateway, IDataTableToMetaDataMapper<FlatContainerParametersNotCommonForAllSpecies> mapper) | ||
: base(dbGateway, mapper, CoreConstants.ORM.VIEW_CONTAINER_PARAMETER_NOT_FOR_ALL_SPECIES) | ||
{ | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using FluentNHibernate.Utils; | ||
using OSPSuite.BDDHelper; | ||
using OSPSuite.BDDHelper.Extensions; | ||
using PKSim.Core.Repositories; | ||
|
||
namespace PKSim.IntegrationTests | ||
{ | ||
public abstract class concern_for_ContainerParametersNotCommonForAllSpeciesRepository : ContextForIntegration<IContainerParametersNotCommonForAllSpeciesRepository> | ||
{ | ||
} | ||
|
||
public class When_retrieving_parameters_not_common_for_all_species_from_the_repository : concern_for_ContainerParametersNotCommonForAllSpeciesRepository | ||
{ | ||
private IEnumerable<(string ContainerPath, string ParameterName, int SpeciesCount)> _result; | ||
|
||
protected override void Because() | ||
{ | ||
_result = sut.All(); | ||
} | ||
|
||
[Observation] | ||
public void should_return_at_least_one_parameter() | ||
{ | ||
_result.Count().ShouldBeGreaterThan(0); | ||
} | ||
|
||
[Observation] | ||
public void all_parameter_paths_should_start_with_organism_or_neighborhoods() | ||
{ | ||
//because we deal here with individual parameters only: only parameters with path "Organism|..." or "Neighborhoods|..." may appear in the list | ||
_result.Each(p=> | ||
{ | ||
var containerPath = p.ContainerPath; | ||
(containerPath.StartsWith("Organism")|| containerPath.StartsWith("Neighborhoods")).ShouldBeTrue($"{p.ContainerPath}|{p.ParameterName}"); | ||
}); | ||
} | ||
} | ||
|
||
public class When_testing_if_a_parameter_is_common_for_all_species : concern_for_ContainerParametersNotCommonForAllSpeciesRepository | ||
{ | ||
[Observation] | ||
public void age_parameter_should_be_defined_not_for_all_species() | ||
{ | ||
sut.UsedForAllSpecies("Organism","Age").ShouldBeFalse(); | ||
} | ||
|
||
[Observation] | ||
public void weight_parameter_should_be_defined_for_all_species() | ||
{ | ||
sut.UsedForAllSpecies("Organism", "Weight").ShouldBeTrue(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using OSPSuite.BDDHelper; | ||
using OSPSuite.BDDHelper.Extensions; | ||
using PKSim.Infrastructure.ORM.FlatObjects; | ||
using PKSim.Infrastructure.ORM.Repositories; | ||
|
||
namespace PKSim.IntegrationTests | ||
{ | ||
public abstract class concern_for_FlatContainerParametersNotCommonForAllSpeciesRepository : ContextForIntegration<IFlatContainerParametersNotCommonForAllSpeciesRepository> | ||
{ | ||
} | ||
|
||
public class When_resolving_all_parameters_not_common_for_all_species_as_a_flat_table : concern_for_FlatContainerParametersNotCommonForAllSpeciesRepository | ||
{ | ||
private IEnumerable<FlatContainerParametersNotCommonForAllSpecies> _result; | ||
|
||
protected override void Because() | ||
{ | ||
_result = sut.All(); | ||
} | ||
|
||
[Observation] | ||
public void should_retrieve_some_object_from_the_underlying_database() | ||
{ | ||
_result.Count().ShouldBeGreaterThan(0); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for whatever reason the changes are not included into the diff file - so you can see them only in dump