Exemple #1
0
        protected override void Context()
        {
            _project          = new PKSimProject();
            _projectRetriever = A.Fake <IProjectRetriever>();
            A.CallTo(() => _projectRetriever.CurrentProject).Returns(_project);

            _compound1          = A.Fake <Compound>();
            _compound1.IsLoaded = false;
            _compound2          = new Compound {
                IsLoaded = true
            };
            _compound2.AddProcess(new EnzymaticProcess {
                MoleculeName = "A", Name = "P1"
            });
            _compound2.AddProcess(new EnzymaticProcess {
                MoleculeName = "C", Name = "P2"
            });
            _compound2.AddProcess(new EnzymaticProcess {
                MoleculeName = "B", Name = "P3"
            });

            _individual1          = A.Fake <Individual>();
            _individual1.IsLoaded = false;
            _individual2          = new Individual {
                IsLoaded = true
            };
            _individual2.AddMolecule(new IndividualEnzyme().WithName("B"));
            _individual2.AddMolecule(new IndividualEnzyme().WithName("D"));

            _project.AddBuildingBlock(_compound1);
            _project.AddBuildingBlock(_compound2);
            _project.AddBuildingBlock(_individual1);
            _project.AddBuildingBlock(_individual2);
            sut = new UsedMoleculeRepository(_projectRetriever);
        }
Exemple #2
0
        protected override void Context()
        {
            _executionContext = A.Fake <IExecutionContext>();
            _project          = new PKSimProject();
            A.CallTo(() => _executionContext.CurrentProject).Returns(_project);

            _compound = new Compound().WithId("Tralala").WithName("Tralala");
            _project.AddBuildingBlock(_compound);

            _proc = new EnzymaticProcess().WithName("ActProc1");

            var serializedStream = new byte[1];

            A.CallTo(() => _executionContext.Serialize(_proc)).Returns(serializedStream);
            A.CallTo(() => _executionContext.Deserialize <PKSim.Core.Model.CompoundProcess>(serializedStream)).Returns(_proc);

            A.CallTo(() => _executionContext.Get <Compound>(_compound.Id)).Returns(_compound);
            A.CallTo(() => _executionContext.Get <PKSim.Core.Model.CompoundProcess>(_proc.Id)).Returns(_proc);

            sut = new AddProcessToCompoundCommand(_proc, _compound, _executionContext);
        }
        public override void GlobalContext()
        {
            base.GlobalContext();

            _sim1 = new IndividualSimulation
            {
                Id       = "Sim1",
                Name     = "Sim1",
                IsLoaded = true,
                Model    = new Model {
                    Root = new Container()
                }
            };
            _sim1.Model.Root.Add(new Container {
                new Parameter().WithName("P")
            }.WithName("Liver"));

            var objectBaseRepository = IoC.Resolve <IWithIdRepository>();
            var workspace            = IoC.Resolve <IWorkspace>();

            _project          = IoC.Resolve <IPKSimProject>();
            workspace.Project = _project;
            objectBaseRepository.Register(_sim1);
            _project.AddBuildingBlock(_sim1);

            _sensitivityAnalysis = new SensitivityAnalysis
            {
                Name       = "SA",
                Simulation = _sim1
            };
            _sensitivityParameter1 = DomainHelperForSpecs.SensitivityParameter(range: 0.5d, steps: 5);
            _parameterSelection1   = new ParameterSelection(_sim1, new QuantitySelection("Liver|P", QuantityType.Parameter));
            _sensitivityParameter1.ParameterSelection = _parameterSelection1;

            _sensitivityAnalysis.AddSensitivityParameter(_sensitivityParameter1);

            _deserializedSensitivityAnalysis = SerializeAndDeserialize(_sensitivityAnalysis);
        }
 public void should_add_the_new_simulation_to_the_project()
 {
     A.CallTo(() => _project.AddBuildingBlock(_newSimulation)).MustHaveHappened();
 }
Exemple #5
0
        public override void GlobalContext()
        {
            base.GlobalContext();
            _observedData = DomainHelperForSpecs.ObservedData();
            _sim1         = new IndividualSimulation
            {
                Id       = "Sim1",
                Name     = "Sim1",
                IsLoaded = true,
                Model    = new Model {
                    Root = new Container()
                }
            };
            _sim1.Model.Root.Add(new Container {
                new Parameter().WithName("P")
            }.WithName("Liver"));
            _sim2 = new IndividualSimulation
            {
                Id       = "Sim2",
                Name     = "Sim2",
                IsLoaded = true,
                Model    = new Model {
                    Root = new Container()
                }
            };
            _sim2.Model.Root.Add(new Container {
                new Parameter().WithName("P")
            }.WithName("Liver"));

            _objectBaseRepository = IoC.Resolve <IWithIdRepository>();
            var workspace = IoC.Resolve <IWorkspace>();

            _project          = IoC.Resolve <IPKSimProject>();
            workspace.Project = _project;
            _objectBaseRepository.Register(_sim1);
            _objectBaseRepository.Register(_sim2);
            _project.AddObservedData(_observedData);
            _project.AddBuildingBlock(_sim1);
            _project.AddBuildingBlock(_sim2);

            _parameterIdentification = new ParameterIdentification();
            _parameterIdentification.AddSimulation(_sim1);
            _parameterIdentification.AddSimulation(_sim2);

            _outputMapping = new OutputMapping
            {
                WeightedObservedData = new WeightedObservedData(_observedData),
                OutputSelection      = new SimulationQuantitySelection(_sim1, new QuantitySelection("A|B", QuantityType.Metabolite)),
                Weight  = 5,
                Scaling = Scalings.Log
            };

            _outputMapping.WeightedObservedData.Weights[1] = 10;
            _parameterIdentification.AddOutputMapping(_outputMapping);

            _identificationParameter = DomainHelperForSpecs.IdentificationParameter(min: 1, max: 10, startValue: 5);

            _parameterSelection1 = new ParameterSelection(_sim1, new QuantitySelection("Liver|P", QuantityType.Parameter));
            _parameterSelection2 = new ParameterSelection(_sim2, new QuantitySelection("Liver|P", QuantityType.Parameter));
            _identificationParameter.AddLinkedParameter(_parameterSelection1);
            _identificationParameter.AddLinkedParameter(_parameterSelection2);
            _parameterIdentification.AddIdentificationParameter(_identificationParameter);
            _identificationParameter.Scaling = Scalings.Linear;

            _parameterIdentification.Configuration.AlgorithmProperties = new OptimizationAlgorithmProperties("AA");
            _parameterIdentification.AlgorithmProperties.Add(new ExtendedProperty <double> {
                Name = "Toto", Value = 5
            });

            _runResult = new ParameterIdentificationRunResult();

            _parameterIdentification.AddResult(_runResult);

            _parameterIdentification.AddAnalysis(new ParameterIdentificationPredictedVsObservedChart());
            _parameterIdentification.AddAnalysis(new ParameterIdentificationTimeProfileChart());
            _parameterIdentification.AddAnalysis(new ParameterIdentificationResidualHistogram());
            _parameterIdentification.AddAnalysis(new ParameterIdentificationResidualVsTimeChart());

            GlobalBecause();
        }
        protected override void Context()
        {
            _view = A.Fake <IBuildingBlockExplorerView>();
            A.CallTo(() => _view.TreeView).Returns(A.Fake <IUxTreeView>());
            _regionResolver = A.Fake <IRegionResolver>();
            _region         = A.Fake <IRegion>();
            A.CallTo(() => _regionResolver.RegionWithName(RegionNames.BuildingBlockExplorer)).Returns(_region);
            _project = new PKSimProject();
            var compound = A.Fake <Compound>().WithName("compound");

            _individual = A.Fake <Individual>().WithName("individual");
            A.CallTo(() => _individual.BuildingBlockType).Returns(PKSimBuildingBlockType.Individual);
            A.CallTo(() => _individual.Species).Returns(new Species());
            _project.AddBuildingBlock(_individual);
            _project.AddBuildingBlock(compound);
            _observedDataInExplorerPresenter = A.Fake <IObservedDataInExplorerPresenter>();
            _buildingBlockIconRetriever      = A.Fake <IBuildingBlockIconRetriever>();
            _treeNodeFactory                    = A.Fake <ITreeNodeFactory>();
            _contextMenuFactory                 = A.Fake <ITreeNodeContextMenuFactory>();
            _buildingBlockTask                  = A.Fake <IBuildingBlockTask>();
            _toolTipCreator                     = A.Fake <IToolTipPartCreator>();
            _projectRetriever                   = A.Fake <IProjectRetriever>();
            _classificationPresenter            = A.Fake <IClassificationPresenter>();
            _multipleTreeNodeContextMenuFactory = A.Fake <IMultipleTreeNodeContextMenuFactory>();
            sut = new BuildingBlockExplorerPresenter(_view, _treeNodeFactory, _contextMenuFactory, _multipleTreeNodeContextMenuFactory, _buildingBlockIconRetriever, _regionResolver,
                                                     _buildingBlockTask, _toolTipCreator, _projectRetriever, _classificationPresenter, _observedDataInExplorerPresenter);

            _compoundFolderNode    = new RootNode(PKSimRootNodeTypes.CompoundFolder);
            _individualFolderNode  = new RootNode(PKSimRootNodeTypes.IndividualFolder);
            _formulationFolderNode = new RootNode(PKSimRootNodeTypes.FormulationFolder);
            _protocolFolderNode    = new RootNode(PKSimRootNodeTypes.ProtocolFolder);
            _populationFolderNode  = new RootNode(PKSimRootNodeTypes.PopulationFolder);
            _eventRootNode         = new RootNode(PKSimRootNodeTypes.EventFolder);
            _simulationNode        = new SimulationNode(new ClassifiableSimulation {
                Subject = new IndividualSimulation {
                    Id = "1"
                }
            });
            _compoundNode        = new ObjectWithIdAndNameNode <Compound>(compound);
            _individualNode      = new ObjectWithIdAndNameNode <Individual>(_individual);
            _observationRootNode = new RootNode(RootNodeTypes.ObservedDataFolder);
            A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.CompoundFolder)).Returns(_compoundFolderNode);
            A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.IndividualFolder)).Returns(_individualFolderNode);
            A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.ProtocolFolder)).Returns(_protocolFolderNode);
            A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.FormulationFolder)).Returns(_formulationFolderNode);
            A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.PopulationFolder)).Returns(_populationFolderNode);
            A.CallTo(() => _treeNodeFactory.CreateFor(RootNodeTypes.ObservedDataFolder)).Returns(_observationRootNode);
            A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.EventFolder)).Returns(_eventRootNode);
            A.CallTo(() => _treeNodeFactory.CreateFor(_individual)).Returns(_individualNode);
            A.CallTo(() => _treeNodeFactory.CreateFor(compound)).Returns(_compoundNode);

            A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.CompoundFolder.Id)).Returns(_compoundFolderNode);
            A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.IndividualFolder.Id)).Returns(_individualFolderNode);
            A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.ProtocolFolder.Id)).Returns(_protocolFolderNode);
            A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.FormulationFolder.Id)).Returns(_formulationFolderNode);
            A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.PopulationFolder.Id)).Returns(_populationFolderNode);
            A.CallTo(() => _view.TreeView.NodeById(RootNodeTypes.ObservedDataFolder.Id)).Returns(_observationRootNode);
            A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.EventFolder.Id)).Returns(_eventRootNode);

            A.CallTo(() => _view.AddNode(A <ITreeNode> ._)).ReturnsLazily(s => s.Arguments[0].DowncastTo <ITreeNode>());
        }