public IReadOnlyList <IBuildingBlockSnapshot> BuildingBlocksByType(PKSimBuildingBlockType buildingBlockType) { switch (buildingBlockType) { case PKSimBuildingBlockType.ExpressionProfile: return(ExpressionProfiles); case PKSimBuildingBlockType.Compound: return(Compounds); case PKSimBuildingBlockType.Formulation: return(Formulations); case PKSimBuildingBlockType.Protocol: return(Protocols); case PKSimBuildingBlockType.Individual: return(Individuals); case PKSimBuildingBlockType.Population: return(Populations); case PKSimBuildingBlockType.Event: return(Events); case PKSimBuildingBlockType.Simulation: return(Simulations); case PKSimBuildingBlockType.ObserverSet: return(ObserverSets); default: return(null); } }
public IReadOnlyList <TBuildingBlock> LoadFromSnapshot <TBuildingBlock>(PKSimBuildingBlockType buildingBlockType) where TBuildingBlock : class, IPKSimBuildingBlock { using (var presenter = _applicationController.Start <ILoadFromSnapshotPresenter <TBuildingBlock> >()) { var buildingBlocks = presenter.LoadModelFromSnapshot(); return(addBuildingBlocksToProject(buildingBlocks).ToList()); } }
public async Task <T> LoadModelFromProjectFileAsync <T>(string fileName, PKSimBuildingBlockType buildingBlockType, string buildingBlockName) { var projectSnapshot = await LoadSnapshotFromFileAsync <Project>(fileName); var snapshot = projectSnapshot.BuildingBlockByTypeAndName(buildingBlockType, buildingBlockName); return(await loadModelFromSnapshot <T>(snapshot)); }
private IParameter create(PKSimBuildingBlockType buildingBlockType) { var parameter = A.Fake <IParameter>(); parameter.CanBeVaried = false; parameter.CanBeVariedInPopulation = false; A.CallTo(() => parameter.BuildingBlockType).Returns(buildingBlockType); return(parameter); }
private TemplateType typeFrom(PKSimBuildingBlockType buildingBlockType) { if (buildingBlockType == PKSimBuildingBlockType.SimulationSubject) { return(TemplateType.Individual | TemplateType.Population); } return(EnumHelper.ParseValue <TemplateType>(buildingBlockType.ToString())); }
public IReadOnlyList <TBuildingBlock> LoadFromTemplate <TBuildingBlock>(PKSimBuildingBlockType buildingBlockType) where TBuildingBlock : class, IPKSimBuildingBlock { using (var presenter = _applicationController.Start <ITemplatePresenter>()) { var buildingBlocks = presenter.LoadFromTemplate <TBuildingBlock>(typeFrom(buildingBlockType)); return(addBuildingBlocksToProject(buildingBlocks).ToList()); } }
private static bool canFilterUnchangedParameters(PKSimBuildingBlockType buildingBlockType) { //Exclude Protocol for now because of the 1to n relationship between building block parameters and simulation parameters return(buildingBlockType.IsOneOf( PKSimBuildingBlockType.Compound, PKSimBuildingBlockType.Formulation, PKSimBuildingBlockType.Individual, PKSimBuildingBlockType.Event, PKSimBuildingBlockType.Population)); }
public ParameterInfo() { //Min value and Max value should be initialized to null to avoid serialization issues CanBeVaried = true; MinValue = null; MinIsAllowed = false; MaxValue = null; MaxIsAllowed = false; Visible = true; GroupName = Constants.Groups.UNDEFINED; Sequence = 1; ReferenceId = 0; BuildingBlockType = PKSimBuildingBlockType.Simulation; }
protected override IReadOnlyList <Compound> LoadFromTemplate(PKSimBuildingBlockType buildingBlockType) { var loadedCompounds = base.LoadFromTemplate(buildingBlockType); if (loadedCompounds.Count <= 1) { return(loadedCompounds); } //one compound and one or more metabolites warnUserIfMetabolitesDoNotMatch(loadedCompounds); return(loadedCompounds); }
private string getContainerPathToRename(PKSimBuildingBlockType buildingBlockType) { switch (buildingBlockType) { case PKSimBuildingBlockType.Formulation: case PKSimBuildingBlockType.Protocol: return(Constants.APPLICATIONS); case PKSimBuildingBlockType.Event: return(Constants.EVENTS); default: throw new ArgumentOutOfRangeException("buildingBlockType"); } }
public IReadOnlyList <TBuildingBlock> LoadFromTemplate <TBuildingBlock>(PKSimBuildingBlockType buildingBlockType) where TBuildingBlock : class, IPKSimBuildingBlock { var loadedBuildingBlocks = new List <TBuildingBlock>(); using (var presenter = _applicationController.Start <ITemplatePresenter>()) { var buildingBlocks = presenter.LoadFromTemplate <TBuildingBlock>(typeFrom(buildingBlockType)); buildingBlocks.Each(bb => { var command = AddToProject(bb, editBuildingBlock: false); if (!command.IsEmpty()) { loadedBuildingBlocks.Add(bb); } }); return(loadedBuildingBlocks); } }
public IParameter CreateFor(string parameterName, double defaultValue, PKSimBuildingBlockType buildingBlockType) { return(CreateFor(parameterName, defaultValue, Constants.Dimension.DIMENSIONLESS, buildingBlockType)); }
public IParameter CreateFor(string parameterName, PKSimBuildingBlockType buildingBlockType) { return(CreateFor(parameterName, double.NaN, buildingBlockType)); }
public UsedBuildingBlock(string templateId, PKSimBuildingBlockType buildingBlockType) { TemplateId = templateId; BuildingBlockType = buildingBlockType; }
public static bool IsOneOf(this PKSimBuildingBlockType buildingBlockType, params PKSimBuildingBlockType[] typesToCompare) { return(typesToCompare.Any(b => buildingBlockType.Is(b))); }
public void UpdateUsedBuildingBlockInSimulationFromTemplate(Simulation simulation, IPKSimBuildingBlock templateBuildingBlock, PKSimBuildingBlockType buildingBlockType) { if (!templateBuildingBlockCanBeUpdatedAsSingle(buildingBlockType)) { throw new ArgumentException($"Should not call this function with a building block of type '{buildingBlockType}'"); } var previousUsedBuildingBlock = simulation.UsedBuildingBlockInSimulation(buildingBlockType); var newUsedBuildingBlock = _buildingBlockMapper.MapFrom(templateBuildingBlock, previousUsedBuildingBlock); simulation.RemoveUsedBuildingBlock(previousUsedBuildingBlock); simulation.AddUsedBuildingBlock(newUsedBuildingBlock); }
protected PKSimBuildingBlock(PKSimBuildingBlockType buildingBlockType) : this() { _buildingBlockType = buildingBlockType; Icon = buildingBlockType.ToString(); }
/// <summary> /// Update parameter values from the used building block into the simulationm /// </summary> /// <param name="usedBuildingBlockParameters">All used building blocks parameters</param> /// <param name="simulation">simulation for which parameters should be updated</param> /// <param name="buildingBlockType">Type of parameters to update</param> private IEnumerable <ICommand> updateParameterValues(IEnumerable <IParameter> usedBuildingBlockParameters, Simulation simulation, PKSimBuildingBlockType buildingBlockType) { var simulationParameterCache = new Cache <string, List <IParameter> >(onMissingKey: x => new List <IParameter>()); foreach (var parameter in simulation.ParametersOfType(buildingBlockType)) { var originParameterId = parameter.Origin.ParameterId; if (!simulationParameterCache.Contains(originParameterId)) { simulationParameterCache[originParameterId] = new List <IParameter>(); } simulationParameterCache[originParameterId].Add(parameter); } return(from parameter in usedBuildingBlockParameters.OrderBy(x => x.IsDistributed()) let simParams = simulationParameterCache[parameter.Id] from simParam in simParams select _parameterSetUpdater.UpdateValue(parameter, simParam)); }
private void addUsedBuildingBlock(Simulation simulation, ITreeNode simulationNode, PKSimBuildingBlockType buildingBlockType) { foreach (var usedBuildingBlock in simulation.UsedBuildingBlocksInSimulation(buildingBlockType)) { _treeNodeFactory.CreateFor(simulation, usedBuildingBlock) .WithIcon(_buildingBlockIconRetriever.IconFor(usedBuildingBlock)) .WithText(usedBuildingBlock.Name) .Under(simulationNode); } }
private bool templateBuildingBlockCanBeUpdatedAsSingle(PKSimBuildingBlockType buildingBlockType) { return(buildingBlockType.IsOneOf(PKSimBuildingBlockType.Individual, PKSimBuildingBlockType.Population)); }
public static bool IsOfType(this IParameter parameter, PKSimBuildingBlockType buildingBlockType) { return(parameter.BuildingBlockType.Is(buildingBlockType)); }
/// <summary> /// return all parameters defined with the given building block type /// </summary> public virtual IEnumerable <IParameter> ParametersOfType(PKSimBuildingBlockType buildingBlockType) { //Do not need neighborhood parameters, since neighborhood is defined a a child of root return(All <IParameter>().Where(p => p.IsOfType(buildingBlockType))); }
/// <summary> /// Returns the building block used in the simulation with the given building block type /// </summary> public virtual UsedBuildingBlock UsedBuildingBlockInSimulation(PKSimBuildingBlockType buildingBlockType) { return(UsedBuildingBlocksInSimulation(buildingBlockType).SingleOrDefault()); }
public void UpdateMultipleUsedBuildingBlockInSimulationFromTemplate(Simulation simulation, IEnumerable <IPKSimBuildingBlock> templateBuildingBlocks, PKSimBuildingBlockType buildingBlockType) { var allTemplates = templateBuildingBlocks.ToList(); if (!allTemplates.Any()) { simulation.RemoveAllBuildingBlockOfType(buildingBlockType); } if (!templateBuildingBlockCanBeUpdatedAsMultiple(buildingBlockType)) { throw new ArgumentException($"Should not call this function with a building block of type '{buildingBlockType}'"); } //templateBuildingBlocks contains all the building block that have been selected //remove the one that are not used anymore . Used to list to remove while looping foreach (var usedBuildingBlock in simulation.UsedBuildingBlocksInSimulation(buildingBlockType).ToList()) { //template is used, continue if (allTemplates.ExistsById(usedBuildingBlock.TemplateId)) { continue; } //user defined building block reused? if (allTemplates.ExistsById(usedBuildingBlock.Id)) { continue; } simulation.RemoveUsedBuildingBlock(usedBuildingBlock); } allTemplates.Each(bb => addUsedBuildingBlockToSimulation(simulation, bb)); }
public IParameter CreateFor(string parameterName, double defaultValue, string dimensionName, PKSimBuildingBlockType buildingBlockType) { var parameterValueDefinition = new ParameterValueMetaData { ParameterName = parameterName, DefaultValue = defaultValue, Dimension = dimensionName, BuildingBlockType = buildingBlockType, }; return(CreateFor(parameterValueDefinition)); }
public IBuildingBlockSnapshot BuildingBlockByTypeAndName(PKSimBuildingBlockType buildingBlockType, string name) => BuildingBlocksByType(buildingBlockType)?.FindByName(name);
public virtual string BuildingBlockName(PKSimBuildingBlockType buildingBlockType) { var usedBuildingBlock = UsedBuildingBlockInSimulation(buildingBlockType); return(usedBuildingBlock == null ? string.Empty : usedBuildingBlock.Name); }
private bool templateBuildingBlockCanBeUpdatedAsMultiple(PKSimBuildingBlockType buildingBlockType) { return(!templateBuildingBlockCanBeUpdatedAsSingle(buildingBlockType)); }
/// <summary> /// Remove the building blocks as used in the simulation by type /// </summary> public virtual void RemoveAllBuildingBlockOfType(PKSimBuildingBlockType buildingBlockType) { var allBuildingBlocksOfType = _usedBuildingBlocks.Where(x => x.BuildingBlockType.Is(buildingBlockType)).ToList(); allBuildingBlocksOfType.Each(RemoveUsedBuildingBlock); }
/// <summary> /// Returns all the buildng block with the given type used in the simulation /// </summary> public virtual IEnumerable <UsedBuildingBlock> UsedBuildingBlocksInSimulation(PKSimBuildingBlockType buildingBlockType) { return(from usedBuildingBlock in UsedBuildingBlocks where usedBuildingBlock.BuildingBlockType.Is(buildingBlockType) select usedBuildingBlock); }