Skip to content

Commit

Permalink
Expression profile in core (#1814)
Browse files Browse the repository at this point in the history
* temp

* fixing build

* changing the namespace naming

* adding the serializer initial implementation

* trying to update expression profile

* updating the serializer

* temporarily hard coding the icon name

* expanding ExpressionParameter

* ExpressionParameter serializer test

* second try

* third try

* fourth try

* fifth try

* sixth try

* removing abstract identifier

* adding ExpressionParameter empty constructor

* skipping formulas with value only

* Create OSMOSES branch

* remove older nupkg files for each deploy

* update build-scripts

* automatically update applications with -m -p arguments

* add batch files for rake tasks

* working import/export

* resharper

* building

* building

* building

* adding tests for ExpressionProfileBuildingBlock

* corecting appveyor.yml

* adding serialization test

* adding tests for expressionParameter

* correcting appveyor

* Serialize expression type.

* moved constants to Core location

* consolidating assets in Core

* comparison of expression profile building block properties

* adding objectType

* code review changes

* adding name

* changing PKSimVersion type

* correcting build

* PR comments

Co-authored-by: Robert McIntosh <[email protected]>
  • Loading branch information
georgeDaskalakis and rwmcintosh authored Dec 8, 2022
1 parent a2f2ec5 commit 148c260
Show file tree
Hide file tree
Showing 19 changed files with 692 additions and 15 deletions.
3 changes: 3 additions & 0 deletions src/OSPSuite.Assets/IconNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,8 @@ public static class IconNames
public const string MOBI = "MoBi";
public const string PARAMETER_IDENTIFICATION = "ParameterIdentification";
public const string SENSITIVITY_ANALYSIS = "SensitivityAnalysis";
public static string Transporter = "Transporter";
public static string Protein = "Protein";
public static string Enzyme = "Enzyme";
}
}
6 changes: 6 additions & 0 deletions src/OSPSuite.Assets/UIConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public static class SizeAndLocation

public static class Captions
{
public static readonly string Transporter = "Transporter";
public static readonly string Protein = "Protein";
public static readonly string Enzyme = "Enzyme";
public static readonly string Species = "Species";
public static readonly string Category = "Category";
public static readonly string ConfirmationDialog = "Confirmation";
public static readonly string Excel = "Excel®";
public static readonly string EmptyColumn = " ";
Expand Down Expand Up @@ -2294,6 +2299,7 @@ public static class ObjectTypes
public static readonly string Formulation = "Formulation";
public static readonly string SensitivityParameter = "Sensitivity Parameter";
public static readonly string SensitivityAnalysis = "Sensitivity Analysis";
public static readonly string ExpressionProfileBuildingBlock = "Expression Profile Building Block";
}

public static class ToolTips
Expand Down
28 changes: 14 additions & 14 deletions src/OSPSuite.Core/Comparison/BuildingBlockDiffBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace OSPSuite.Core.Comparison
{
public abstract class BuildingBlockDiffBuilder<T> : DiffBuilder<IBuildingBlock<T>> where T : class, IObjectBase
public abstract class BuildingBlockDiffBuilder<TBuildingBlock, TBuilder> : DiffBuilder<TBuildingBlock> where TBuildingBlock : class, IBuildingBlock<TBuilder> where TBuilder : class, IObjectBase
{
private readonly ObjectBaseDiffBuilder _objectBaseDiffBuilder;
private readonly EnumerableComparer _enumerableComparer;
private readonly Func<T, object> _equalityProperty;
protected Func<T, string> _presentObjectDetailsFunc;
private readonly Func<TBuilder, object> _equalityProperty;
protected Func<TBuilder, string> _presentObjectDetailsFunc;

protected BuildingBlockDiffBuilder(ObjectBaseDiffBuilder objectBaseDiffBuilder,
EnumerableComparer enumerableComparer, Func<T, object> equalityProperty)
EnumerableComparer enumerableComparer, Func<TBuilder, object> equalityProperty)
{
_objectBaseDiffBuilder = objectBaseDiffBuilder;
_equalityProperty = equalityProperty;
Expand All @@ -24,60 +24,60 @@ protected BuildingBlockDiffBuilder(ObjectBaseDiffBuilder objectBaseDiffBuilder,
{
}

public override void Compare(IComparison<IBuildingBlock<T>> comparison)
public override void Compare(IComparison<TBuildingBlock> comparison)
{
_objectBaseDiffBuilder.Compare(comparison);
_enumerableComparer.CompareEnumerables(comparison, x => x, _equalityProperty, _presentObjectDetailsFunc);
}
}

public class MoleculeBuildingBlockDiffBuilder : BuildingBlockDiffBuilder<IMoleculeBuilder>
public class MoleculeBuildingBlockDiffBuilder : BuildingBlockDiffBuilder<IMoleculeBuildingBlock, IMoleculeBuilder>
{
public MoleculeBuildingBlockDiffBuilder(ObjectBaseDiffBuilder objectBaseDiffBuilder, EnumerableComparer enumerableComparer) : base(objectBaseDiffBuilder, enumerableComparer)
{
}
}

public class SpatialStructureDiffBuilder : BuildingBlockDiffBuilder<IContainer>
public class SpatialStructureDiffBuilder : BuildingBlockDiffBuilder<ISpatialStructure, IContainer>
{
public SpatialStructureDiffBuilder(ObjectBaseDiffBuilder objectBaseDiffBuilder, EnumerableComparer enumerableComparer)
: base(objectBaseDiffBuilder, enumerableComparer)
{
}
}

public class ReactionBuildingBlockDiffBuilder : BuildingBlockDiffBuilder<IReactionBuilder>
public class ReactionBuildingBlockDiffBuilder : BuildingBlockDiffBuilder<IReactionBuildingBlock, IReactionBuilder>
{
public ReactionBuildingBlockDiffBuilder(ObjectBaseDiffBuilder objectBaseDiffBuilder, EnumerableComparer enumerableComparer) : base(objectBaseDiffBuilder, enumerableComparer)
{
}
}

public class PassiveTransportBuildingBlockDiffBuilder : BuildingBlockDiffBuilder<ITransportBuilder>
public class PassiveTransportBuildingBlockDiffBuilder : BuildingBlockDiffBuilder<IPassiveTransportBuildingBlock, ITransportBuilder>
{
public PassiveTransportBuildingBlockDiffBuilder(ObjectBaseDiffBuilder objectBaseDiffBuilder, EnumerableComparer enumerableComparer)
: base(objectBaseDiffBuilder, enumerableComparer)
{
}
}

public class EventGroupBuildingBlocksDiffBuilder : BuildingBlockDiffBuilder<IEventGroupBuilder>
public class EventGroupBuildingBlocksDiffBuilder : BuildingBlockDiffBuilder<IEventGroupBuildingBlock, IEventGroupBuilder>
{
public EventGroupBuildingBlocksDiffBuilder(ObjectBaseDiffBuilder objectBaseDiffBuilder, EnumerableComparer enumerableComparer)
: base(objectBaseDiffBuilder, enumerableComparer)
{
}
}

public class ObserverBuildingBlocksDiffBuilder : BuildingBlockDiffBuilder<IObserverBuilder>
public class ObserverBuildingBlocksDiffBuilder : BuildingBlockDiffBuilder<IObserverBuildingBlock, IObserverBuilder>
{
public ObserverBuildingBlocksDiffBuilder(ObjectBaseDiffBuilder objectBaseDiffBuilder, EnumerableComparer enumerableComparer)
: base(objectBaseDiffBuilder, enumerableComparer)
{
}
}

public abstract class StartValueBuildingBlockDiffBuilder<TStartValue> : BuildingBlockDiffBuilder<TStartValue> where TStartValue : class, IStartValue
public abstract class StartValueBuildingBlockDiffBuilder<TBuildingBlock, TStartValue> : BuildingBlockDiffBuilder<TBuildingBlock, TStartValue> where TStartValue : class, IStartValue where TBuildingBlock : class, IBuildingBlock<TStartValue>
{
private readonly UnitFormatter _unitFormatter = new UnitFormatter();

Expand All @@ -101,14 +101,14 @@ private string startValueDisplayFor(TStartValue startValue)
}
}

public class MoleculeStartValueBuildingBlockDiffBuilder : StartValueBuildingBlockDiffBuilder<IMoleculeStartValue>
public class MoleculeStartValueBuildingBlockDiffBuilder : StartValueBuildingBlockDiffBuilder<IMoleculeStartValuesBuildingBlock, IMoleculeStartValue>
{
public MoleculeStartValueBuildingBlockDiffBuilder(ObjectBaseDiffBuilder objectBaseDiffBuilder, EnumerableComparer enumerableComparer) : base(objectBaseDiffBuilder, enumerableComparer)
{
}
}

public class ParameterStartValueBuildingBlockDiffBuilder : StartValueBuildingBlockDiffBuilder<IParameterStartValue>
public class ParameterStartValueBuildingBlockDiffBuilder : StartValueBuildingBlockDiffBuilder<IParameterStartValuesBuildingBlock, IParameterStartValue>
{
public ParameterStartValueBuildingBlockDiffBuilder(ObjectBaseDiffBuilder objectBaseDiffBuilder, EnumerableComparer enumerableComparer) : base(objectBaseDiffBuilder, enumerableComparer)
{
Expand Down
27 changes: 27 additions & 0 deletions src/OSPSuite.Core/Comparison/ExpressionProfileDiffBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using OSPSuite.Core.Domain.Builder;

namespace OSPSuite.Core.Comparison
{
public class ExpressionProfileBuildingBlockDiffBuilder : BuildingBlockDiffBuilder<ExpressionProfileBuildingBlock, ExpressionParameter>
{
public ExpressionProfileBuildingBlockDiffBuilder(ObjectBaseDiffBuilder objectBaseDiffBuilder, EnumerableComparer enumerableComparer) : base(objectBaseDiffBuilder, enumerableComparer)
{

}

public override void Compare(IComparison<ExpressionProfileBuildingBlock> comparison)
{
base.Compare(comparison);
CompareValues(x => x.PKSimVersion, x => x.PKSimVersion, comparison);
CompareStringValues(x => x.Name, x => x.Name, comparison);
CompareValues(x => x.Type, x => x.Type, comparison);
}
}

internal class ExpressionParameterDiffBuilder : StartValueDiffBuilder<ExpressionParameter>
{
public ExpressionParameterDiffBuilder(IObjectComparer objectComparer, EntityDiffBuilder entityDiffBuilder, WithValueOriginComparison<ExpressionParameter> valueOriginComparison) : base(objectComparer, entityDiffBuilder, valueOriginComparison)
{
}
}
}
22 changes: 22 additions & 0 deletions src/OSPSuite.Core/Domain/Builder/ExpressionParameter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using OSPSuite.Core.Domain.Services;

namespace OSPSuite.Core.Domain.Builder
{
public class ExpressionParameter : PathAndValueEntity, IStartValue
{
/// <summary>
/// Do not use! When refactoring on promotion to core, this should be removed
/// </summary>
public double? StartValue { get; set; }

public override void UpdatePropertiesFrom(IUpdatable source, ICloneManager cloneManager)
{
base.UpdatePropertiesFrom(source, cloneManager);

if (!(source is ExpressionParameter sourceExpressionParameter))
return;

StartValue = sourceExpressionParameter.StartValue;
}
}
}
55 changes: 55 additions & 0 deletions src/OSPSuite.Core/Domain/Builder/ExpressionProfileBuildingBlock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using OSPSuite.Core.Domain.Services;
using static OSPSuite.Core.Domain.Constants.ContainerName;

namespace OSPSuite.Core.Domain.Builder
{
public class ExpressionProfileBuildingBlock : StartValueBuildingBlock<ExpressionParameter>
{
public override string Icon => Type.IconName;

public virtual string MoleculeName { get; private set; }

public string Species { get; private set; }

public ExpressionType Type { set; get; }

public string PKSimVersion { set; get; }

public virtual string Category { get; private set; }

public override string Name
{
get => ExpressionProfileName(MoleculeName, Species, Category);
set
{
if (string.Equals(Name, value))
{
return;
}

var (moleculeName, species, category) = NamesFromExpressionProfileName(value);
if (string.IsNullOrEmpty(moleculeName))
return;

Species = species;
Category = category;
MoleculeName = moleculeName;
OnPropertyChanged(() => Name);
}
}

public override void UpdatePropertiesFrom(IUpdatable source, ICloneManager cloneManager)
{
base.UpdatePropertiesFrom(source, cloneManager);
var sourceExpressionProfile = source as ExpressionProfileBuildingBlock;
if (sourceExpressionProfile == null) return;

Type = sourceExpressionProfile.Type;
PKSimVersion = sourceExpressionProfile.PKSimVersion;

// Name is required because our base objects will the private property
// But in this case the name is decomposed and stored in 3 other properties
Name = sourceExpressionProfile.Name;
}
}
}
50 changes: 50 additions & 0 deletions src/OSPSuite.Core/Domain/Builder/ExpressionTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using OSPSuite.Utility.Collections;

namespace OSPSuite.Core.Domain.Builder
{

public enum ExpressionTypesId
{
Transport,
Enzyme,
BindingPartner
}

public static class ExpressionTypes
{
public static ExpressionType TransportProtein = new ExpressionType(ExpressionTypesId.Transport, Assets.IconNames.Transporter, Assets.Captions.Transporter);
public static ExpressionType MetabolizingEnzyme = new ExpressionType(ExpressionTypesId.Enzyme, Assets.IconNames.Enzyme, Assets.Captions.Enzyme);
public static ExpressionType ProteinBindingPartner = new ExpressionType(ExpressionTypesId.BindingPartner, Assets.IconNames.Protein, Assets.Captions.Protein);

private static readonly ICache<ExpressionTypesId, ExpressionType> _typesCache = new Cache<ExpressionTypesId, ExpressionType>(x => x.Id)
{
TransportProtein,
MetabolizingEnzyme,
ProteinBindingPartner
};

public static ExpressionType ById(ExpressionTypesId expressionTypeId)
{
return _typesCache[expressionTypeId];
}
}

public class ExpressionType
{
public ExpressionTypesId Id { get; }
public string IconName { get; }
public string DisplayName { get; }
public ExpressionType(ExpressionTypesId expressionTypesId, string iconName, string displayName)
{
Id = expressionTypesId;
IconName = iconName;
DisplayName = displayName;
}

public override string ToString()
{
return DisplayName;
}

}
}
Loading

0 comments on commit 148c260

Please sign in to comment.