コード例 #1
0
        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);
            }
        }
コード例 #2
0
 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());
     }
 }
コード例 #3
0
        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));
        }
コード例 #4
0
        private IParameter create(PKSimBuildingBlockType buildingBlockType)
        {
            var parameter = A.Fake <IParameter>();

            parameter.CanBeVaried             = false;
            parameter.CanBeVariedInPopulation = false;
            A.CallTo(() => parameter.BuildingBlockType).Returns(buildingBlockType);
            return(parameter);
        }
コード例 #5
0
ファイル: BuildingBlockTask.cs プロジェクト: valdiman/PK-Sim
        private TemplateType typeFrom(PKSimBuildingBlockType buildingBlockType)
        {
            if (buildingBlockType == PKSimBuildingBlockType.SimulationSubject)
            {
                return(TemplateType.Individual | TemplateType.Population);
            }

            return(EnumHelper.ParseValue <TemplateType>(buildingBlockType.ToString()));
        }
コード例 #6
0
ファイル: BuildingBlockTask.cs プロジェクト: yvkashyap/PK-Sim
        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());
            }
        }
コード例 #7
0
ファイル: SimulationMapper.cs プロジェクト: devhliu/PK-Sim
 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));
 }
コード例 #8
0
 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;
 }
コード例 #9
0
ファイル: CompoundTask.cs プロジェクト: valdiman/PK-Sim
        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);
        }
コード例 #10
0
        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");
            }
        }
コード例 #11
0
ファイル: BuildingBlockTask.cs プロジェクト: valdiman/PK-Sim
        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);
            }
        }
コード例 #12
0
ファイル: ParameterFactory.cs プロジェクト: yvkashyap/PK-Sim
 public IParameter CreateFor(string parameterName, double defaultValue, PKSimBuildingBlockType buildingBlockType)
 {
     return(CreateFor(parameterName, defaultValue, Constants.Dimension.DIMENSIONLESS, buildingBlockType));
 }
コード例 #13
0
ファイル: ParameterFactory.cs プロジェクト: yvkashyap/PK-Sim
 public IParameter CreateFor(string parameterName, PKSimBuildingBlockType buildingBlockType)
 {
     return(CreateFor(parameterName, double.NaN, buildingBlockType));
 }
コード例 #14
0
ファイル: UsedBuildingBlock.cs プロジェクト: yvkashyap/PK-Sim
 public UsedBuildingBlock(string templateId, PKSimBuildingBlockType buildingBlockType)
 {
     TemplateId        = templateId;
     BuildingBlockType = buildingBlockType;
 }
コード例 #15
0
 public static bool IsOneOf(this PKSimBuildingBlockType buildingBlockType, params PKSimBuildingBlockType[] typesToCompare)
 {
     return(typesToCompare.Any(b => buildingBlockType.Is(b)));
 }
コード例 #16
0
        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);
        }
コード例 #17
0
ファイル: PKSimBuildingBlock.cs プロジェクト: valdiman/PK-Sim
 protected PKSimBuildingBlock(PKSimBuildingBlockType buildingBlockType) : this()
 {
     _buildingBlockType = buildingBlockType;
     Icon = buildingBlockType.ToString();
 }
コード例 #18
0
        /// <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));
        }
コード例 #19
0
 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);
     }
 }
コード例 #20
0
 private bool templateBuildingBlockCanBeUpdatedAsSingle(PKSimBuildingBlockType buildingBlockType)
 {
     return(buildingBlockType.IsOneOf(PKSimBuildingBlockType.Individual, PKSimBuildingBlockType.Population));
 }
コード例 #21
0
 public static bool IsOfType(this IParameter parameter, PKSimBuildingBlockType buildingBlockType)
 {
     return(parameter.BuildingBlockType.Is(buildingBlockType));
 }
コード例 #22
0
 /// <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)));
 }
コード例 #23
0
ファイル: Simulation.cs プロジェクト: valdiman/PK-Sim
 /// <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());
 }
コード例 #24
0
        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));
        }
コード例 #25
0
ファイル: ParameterFactory.cs プロジェクト: yvkashyap/PK-Sim
        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));
        }
コード例 #26
0
 public IBuildingBlockSnapshot BuildingBlockByTypeAndName(PKSimBuildingBlockType buildingBlockType, string name) =>
 BuildingBlocksByType(buildingBlockType)?.FindByName(name);
コード例 #27
0
ファイル: Simulation.cs プロジェクト: valdiman/PK-Sim
        public virtual string BuildingBlockName(PKSimBuildingBlockType buildingBlockType)
        {
            var usedBuildingBlock = UsedBuildingBlockInSimulation(buildingBlockType);

            return(usedBuildingBlock == null ? string.Empty : usedBuildingBlock.Name);
        }
コード例 #28
0
 private bool templateBuildingBlockCanBeUpdatedAsMultiple(PKSimBuildingBlockType buildingBlockType)
 {
     return(!templateBuildingBlockCanBeUpdatedAsSingle(buildingBlockType));
 }
コード例 #29
0
        /// <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);
        }
コード例 #30
0
ファイル: Simulation.cs プロジェクト: valdiman/PK-Sim
 /// <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);
 }