Skip to content

Commit

Permalink
2475 expression profile from pksim (#2476)
Browse files Browse the repository at this point in the history
* #784_expression_profile_from_pksim

* updating with mapper

* Fixes #2475 Create expression profile from PK-sim

* add dimensions as resource for tests

* Add pkparameters for test project

* add sqlite db

* PR feedback
  • Loading branch information
rwmcintosh committed Apr 3, 2023
1 parent da87629 commit d55d807
Show file tree
Hide file tree
Showing 42 changed files with 397 additions and 917 deletions.
12 changes: 6 additions & 6 deletions PKSim.sln
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PKSim.R", "src\PKSim.R\PKSi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PKSim.R.Tests", "tests\PKSim.R.Tests\PKSim.R.Tests.csproj", "{4E310F99-4604-4502-8F0B-A4E4F27B062B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PKSim.UI.Starter", "tests\PKSim.UI.Starter\PKSim.UI.Starter.csproj", "{795B1096-E236-4A0B-AB67-590F264F9F8E}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PKSim.UI.Starter", "src\PKSim.UI.Starter\PKSim.UI.Starter.csproj", "{35E511E9-0130-4E28-9DB3-EDCCB098D383}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -128,17 +128,17 @@ Global
{4E310F99-4604-4502-8F0B-A4E4F27B062B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E310F99-4604-4502-8F0B-A4E4F27B062B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E310F99-4604-4502-8F0B-A4E4F27B062B}.Release|Any CPU.Build.0 = Release|Any CPU
{795B1096-E236-4A0B-AB67-590F264F9F8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{795B1096-E236-4A0B-AB67-590F264F9F8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{795B1096-E236-4A0B-AB67-590F264F9F8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{795B1096-E236-4A0B-AB67-590F264F9F8E}.Release|Any CPU.Build.0 = Release|Any CPU
{35E511E9-0130-4E28-9DB3-EDCCB098D383}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35E511E9-0130-4E28-9DB3-EDCCB098D383}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35E511E9-0130-4E28-9DB3-EDCCB098D383}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35E511E9-0130-4E28-9DB3-EDCCB098D383}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
VisualSVNWorkingCopyRoot =
SolutionGuid = {13620E23-1993-42C6-A4AB-468E29DD24DE}
VisualSVNWorkingCopyRoot =
EndGlobalSection
GlobalSection(NDepend) = preSolution
Project = ".\PKSim.ndproj"
Expand Down
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.76" />
<PackageReference Include="OSPSuite.Assets.Images" Version="12.0.76" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.77" />
<PackageReference Include="OSPSuite.Assets.Images" Version="12.0.77" />
</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.76" />
<PackageReference Include="OSPSuite.Assets.Images" Version="12.0.76" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.77" />
<PackageReference Include="OSPSuite.Assets.Images" Version="12.0.77" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 0 additions & 2 deletions src/PKSim.Assets/PKSimConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,6 @@ public static class MenuNames
public static readonly string NewFormulation = "Add &Formulation...";
public static readonly string NewEvent = "Add &Event...";
public static readonly string NewObservers = "Add &Observers...";
public static readonly string NewExpressionProfile = "Add &Expression Profile";
public static readonly string AddObservedData = "Add &Observed Data...";
public static readonly string AddObservedDataFor = "Add Observed Data for";
public static readonly string SaveAs = "Save As...";
Expand Down Expand Up @@ -1886,7 +1885,6 @@ public static class UI
public static readonly string NewFormulationDescription = "Create a new formulation...";
public static readonly string NewEventDescription = "Create a new event...";
public static readonly string NewObserversDescription = "Create a new observer list...";
public static readonly string NewExpressionProfileDescription = "Create a new expression profile...";
public static readonly string NewCompoundDescription = "Create a new compound...";
public static readonly string OptionsDescription = "Manage the options for the application and the current user...";
public static readonly string ExitDescription = "Exit the application";
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.76" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.76" />
<PackageReference Include="OSPSuite.Core" Version="12.0.77" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.77" />
<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.76" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.77" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Core" Version="12.0.76" />
<PackageReference Include="OSPSuite.Core" Version="12.0.77" />
</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.76" />
<PackageReference Include="OSPSuite.Presentation" Version="12.0.76" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.76" />
<PackageReference Include="OSPSuite.Core" Version="12.0.77" />
<PackageReference Include="OSPSuite.Presentation" Version="12.0.77" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.77" />
<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
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.76" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.76" />
<PackageReference Include="OSPSuite.Assets.Images" Version="12.0.76" />
<PackageReference Include="OSPSuite.Infrastructure.Import" Version="12.0.76" />
<PackageReference Include="OSPSuite.Core" Version="12.0.77" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.77" />
<PackageReference Include="OSPSuite.Assets.Images" Version="12.0.77" />
<PackageReference Include="OSPSuite.Infrastructure.Import" Version="12.0.77" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
</ItemGroup>

Expand Down
18 changes: 9 additions & 9 deletions src/PKSim.Infrastructure/PKSim.Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.0" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.13" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.76" />
<PackageReference Include="OSPSuite.Core" Version="12.0.76" />
<PackageReference Include="OSPSuite.Infrastructure" Version="12.0.76" />
<PackageReference Include="OSPSuite.Infrastructure.Castle" Version="12.0.76" />
<PackageReference Include="OSPSuite.Infrastructure.Export" Version="12.0.76" />
<PackageReference Include="OSPSuite.Infrastructure.Import" Version="12.0.76" />
<PackageReference Include="OSPSuite.Infrastructure.Reporting" Version="12.0.76" />
<PackageReference Include="OSPSuite.Infrastructure.Serialization" Version="12.0.76" />
<PackageReference Include="OSPSuite.Presentation.Serialization" Version="12.0.76" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.77" />
<PackageReference Include="OSPSuite.Core" Version="12.0.77" />
<PackageReference Include="OSPSuite.Infrastructure" Version="12.0.77" />
<PackageReference Include="OSPSuite.Infrastructure.Castle" Version="12.0.77" />
<PackageReference Include="OSPSuite.Infrastructure.Export" Version="12.0.77" />
<PackageReference Include="OSPSuite.Infrastructure.Import" Version="12.0.77" />
<PackageReference Include="OSPSuite.Infrastructure.Reporting" Version="12.0.77" />
<PackageReference Include="OSPSuite.Infrastructure.Serialization" Version="12.0.77" />
<PackageReference Include="OSPSuite.Presentation.Serialization" Version="12.0.77" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
</ItemGroup>

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

<ItemGroup>
<PackageReference Include="OSPSuite.Assets" Version="12.0.76" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.77" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Core" Version="12.0.76" />
<PackageReference Include="OSPSuite.Core" Version="12.0.77" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/PKSim.Presentation/PKSim.Presentation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OSPSuite.Assets" Version="12.0.76" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.77" />
<PackageReference Include="OSPSuite.TeXReporting" Version="3.0.0.4" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Presentation" Version="12.0.76" />
<PackageReference Include="OSPSuite.Core" Version="12.0.76" />
<PackageReference Include="OSPSuite.Presentation" Version="12.0.77" />
<PackageReference Include="OSPSuite.Core" Version="12.0.77" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ public IPKSimCommand Create<TMolecule>() where TMolecule : IndividualMolecule
_view.Caption = PKSimConstants.UI.CreateExpressionProfile;
_view.BindTo(_dto);
_view.Display();

if (_view.Canceled)
{
return new PKSimEmptyCommand();
}

//we create a new one with all new features
ExpressionProfile = _expressionProfileFactory.Create<TMolecule>(_dto.Species, _dto.MoleculeName);
Expand Down
4 changes: 2 additions & 2 deletions src/PKSim.Presentation/Repositories/MenuBarItemRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ protected override IEnumerable<IMenuBarItem> AllMenuBarItems()
.WithCommand<LoadObserverSetCommand>()
.WithIcon(ApplicationIcons.LoadFromTemplate);

var newExpressionProfile = CreateSubMenu.WithCaption(PKSimConstants.MenuNames.NewExpressionProfile)
var newExpressionProfile = CreateSubMenu.WithCaption(MenuNames.NewExpressionProfile)
.WithIcon(ApplicationIcons.ExpressionProfile)
.WithDescription(PKSimConstants.UI.NewExpressionProfileDescription)
.WithDescription(MenuDescriptions.NewExpressionProfileDescription)
.WithId(MenuBarItemIds.NewExpressionProfile);

var newEnzyme = CreateMenuButton.WithCaption(PKSimConstants.UI.AddMetabolizingEnzyme)
Expand Down
4 changes: 2 additions & 2 deletions src/PKSim.R/PKSim.R.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@


<ItemGroup>
<PackageReference Include="OSPSuite.Assets" Version="12.0.76" />
<PackageReference Include="OSPSuite.Assets" Version="12.0.77" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Core" Version="12.0.76" />
<PackageReference Include="OSPSuite.Core" Version="12.0.77" />
<PackageReference Include="OSPSuite.FuncParser" Version="4.0.0.54" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModel" Version="4.0.0.53" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModelSolver_CVODES" Version="4.1.0.8" GeneratePathProperty="true" />
Expand Down
115 changes: 115 additions & 0 deletions src/PKSim.UI.Starter/ApplicationStartup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using System.Globalization;
using System.Threading;
using OSPSuite.Assets;
using OSPSuite.Core.Commands.Core;
using OSPSuite.Core.Journal;
using OSPSuite.Core.Services;
using OSPSuite.Infrastructure.Import.Services;
using OSPSuite.Presentation;
using OSPSuite.Presentation.Core;
using OSPSuite.Presentation.DTO;
using OSPSuite.Presentation.Services;
using OSPSuite.Presentation.Views;
using OSPSuite.UI.Mappers;
using OSPSuite.UI.Services;
using OSPSuite.Utility.Container;
using OSPSuite.Utility.Exceptions;
using PKSim.CLI.Core.MinimalImplementations;
using PKSim.Core;
using PKSim.Core.Services;
using PKSim.Infrastructure;
using PKSim.Presentation;
using PKSim.Presentation.DTO.Mappers;
using PKSim.Presentation.Presenters.ExpressionProfiles;
using PKSim.Presentation.Services;
using PKSim.Presentation.Views.ExpressionProfiles;
using PKSim.UI.Views.ExpressionProfiles;

namespace PKSim.UI.Starter
{
public static class ApplicationStartup
{
static IContainer _container;

public static IContainer Initialize(IShell shell)
{
if (_container != null)
return _container;

_container = initializeForStartup(shell);

return _container;
}

private static IContainer initializeForStartup(IShell shell)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en");
ApplicationIcons.DefaultIcon = ApplicationIcons.PKSim;


var container = InfrastructureRegister.Initialize(registerContainerAsStatic: false);
container.RegisterImplementationOf(SynchronizationContext.Current);

container.Register<IApplicationController, ApplicationController>(LifeStyle.Singleton);
container.Register<ICoreWorkspace, OSPSuite.Core.IWorkspace, IWorkspace, Workspace>(LifeStyle.Singleton);

// registerImplementationsFromCore(container);
registerMinimalImplementations(container);


using (container.OptimizeDependencyResolution())
{
container.RegisterImplementationOf(shell);
container.AddRegister(x => x.FromType<CoreRegister>());
container.AddRegister(x => x.FromType<InfrastructureRegister>());
container.Register<ICreateExpressionProfilePresenter, CreateExpressionProfilePresenter>();
container.Register<ICreateExpressionProfileView, CreateExpressionProfileView>();
container.Register<IExpressionProfileToExpressionProfileDTOMapper, ExpressionProfileToExpressionProfileDTOMapper>();
container.Register<IMoleculePropertiesMapper, MoleculePropertiesMapper>();
container.Register<ICoreUserSettings, IPresentationUserSettings, UIStarterUserSettings>(LifeStyle.Singleton);
container.Register<IOntogenyTask, OntogenyTask>();
container.Register<IEntityTask, EntityTask>();
container.Register<IRenameObjectDTOFactory, RenameObjectDTOFactory>();
container.Register<IHistoryManager, HistoryManager<IExecutionContext>>();
InfrastructureRegister.LoadSerializers(container);
}

return container;
}

// /// <summary>
// /// Use this method to register all dependencies in Core.UI and Core.Presentation
// /// </summary>
// private static void registerImplementationsFromCore(IContainer container)
// {
// container.Register<IExceptionManager, ExceptionManager>(LifeStyle.Singleton);
// container.AddRegister(x => x.FromType<UIRegister>());
// container.AddRegister(x => x.FromType<OSPSuite.Presentation.PresenterRegister>());
// }

/// <summary>
/// Use this method to register and refine the minimal implementations for dependencies
/// </summary>
private static void registerMinimalImplementations(IContainer container)
{
container.Register<IMRUProvider, MRUProvider>();
container.Register<IImageListRetriever, ImageListRetriever>();
container.Register<IApplicationIconsToImageCollectionMapper, ApplicationIconsToImageCollectionMapper>();
container.Register<IDisplayUnitRetriever, CLIDisplayUnitRetriever>();
container.Register<IExceptionManager, CLIExceptionManager>();
container.Register<IDialogCreator, CLIDialogCreator>();
container.Register<IDataImporter, CLIDataImporter>();
container.Register<IJournalDiagramManagerFactory, CLIJournalDiagramManagerFactory>();
}
}

internal class Workspace : CLIWorkspace, IWorkspace
{
public Workspace(IRegistrationTask registrationTask) : base(registrationTask)
{
}

public IWorkspaceLayout WorkspaceLayout { get; set; }
}
}
42 changes: 42 additions & 0 deletions src/PKSim.UI.Starter/ExpressionProfileCreator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using OSPSuite.Core.Commands.Core;
using OSPSuite.Presentation.Views;
using PKSim.Core.Mappers;
using PKSim.Core.Model;
using PKSim.Presentation;
using PKSim.Presentation.Presenters.ExpressionProfiles;

namespace PKSim.UI.Starter
{
public static class ExpressionProfileCreator
{
public static object CreateIndividualEnzymeExpressionProfile(IShell shell)
{
return createExpressionProfile<IndividualEnzyme>(shell);
}

public static object CreateTransporterExpressionProfile(IShell shell)
{
return createExpressionProfile<IndividualTransporter>(shell);
}

public static object CreateBindingPartnerExpressionProfile(IShell shell)
{
return createExpressionProfile<IndividualOtherProtein>(shell);
}

private static object createExpressionProfile<T>(IShell shell) where T : IndividualMolecule
{
var container = ApplicationStartup.Initialize(shell);

using (var presenter = container.Resolve<ICreateExpressionProfilePresenter>())
{
var workspace = container.Resolve<IWorkspace>();
workspace.Project = new PKSimProject();
var mapper = container.Resolve<IExpressionProfileToExpressionProfileBuildingBlockMapper>();


return presenter.Create<T>().IsEmpty() ? null : mapper.MapFrom(presenter.ExpressionProfile);
}
}
}
}
21 changes: 21 additions & 0 deletions src/PKSim.UI.Starter/PKSim.UI.Starter.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<Version>11.1.0</Version>
<AssemblyVersion>11.1.0</AssemblyVersion>
<FileVersion>11.1.0</FileVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\PKSim.CLI.Core\PKSim.CLI.Core.csproj">
<CopyLocalSatelliteAssemblies></CopyLocalSatelliteAssemblies>
<Private></Private>
</ProjectReference>
<ProjectReference Include="..\PKSim.UI\PKSim.UI.csproj">
<Private></Private>
<CopyLocalSatelliteAssemblies></CopyLocalSatelliteAssemblies>
</ProjectReference>
</ItemGroup>

</Project>
Loading

0 comments on commit d55d807

Please sign in to comment.