コード例 #1
0
 protected override void Context()
 {
     _spatialStructureFactory      = A.Fake <IPKSimSpatialStructureFactory>();
     _modelObserverQuery           = A.Fake <IModelObserverQuery>();
     _modelPassiveTransportQuery   = A.Fake <IModelPassiveTransportQuery>();
     _parameterStartValueCreator   = A.Fake <IPKSimParameterStartValuesCreator>();
     _moleculesAndReactionsCreator = A.Fake <IMoleculesAndReactionsCreator>();
     _eventBuildingBlockCreator    = A.Fake <IEventBuildingBlockCreator>();
     _moleculeStartValueCreator    = A.Fake <IPKSimMoleculeStartValuesCreator>();
     _moleculeCalculationRetriever = A.Fake <IMoleculeCalculationRetriever>();
     _distributedTableConverter    = A.Fake <IDistributedParameterToTableParameterConverter>();
     _parameterDefaultStateUpdater = A.Fake <IParameterDefaultStateUpdater>();
     _cm1        = new CoreCalculationMethod();
     _cm2        = new CoreCalculationMethod();
     _simulation = new IndividualSimulation {
         Properties = new SimulationProperties()
     };
     _simulation.SimulationSettings = new SimulationSettings();
     _simulation.ModelConfiguration = new ModelConfiguration();
     _individual                      = new Individual().WithName("MyIndividuyal");
     _compound                        = A.Fake <Compound>().WithName("MyCompound");
     _protocol                        = new SimpleProtocol().WithName("MyProtocol");
     _spatialStructure                = A.Fake <ISpatialStructure>();
     _passiveTransportBuilingBlock    = A.Fake <IPassiveTransportBuildingBlock>();
     _observerBuildingBlock           = A.Fake <IObserverBuildingBlock>();
     _eventBuildingBlock              = A.Fake <IEventGroupBuildingBlock>();
     _parameterValuesBuildingBlock    = A.Fake <IParameterStartValuesBuildingBlock>();
     _moleculeStartValueBuildingBlock = A.Fake <IMoleculeStartValuesBuildingBlock>();
     _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("Individual", PKSimBuildingBlockType.Individual)
     {
         BuildingBlock = _individual
     });
     _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("Compound", PKSimBuildingBlockType.Compound)
     {
         BuildingBlock = _compound
     });
     _simulation.AddUsedBuildingBlock(new UsedBuildingBlock("Protocol", PKSimBuildingBlockType.Protocol)
     {
         BuildingBlock = _protocol
     });
     A.CallTo(() => _moleculeCalculationRetriever.AllMoleculeCalculationMethodsUsedBy(_simulation)).Returns(new[] { _cm1, _cm2 });
     A.CallTo(() => _spatialStructureFactory.CreateFor(_individual, _simulation)).Returns(_spatialStructure);
     A.CallTo(() => _modelPassiveTransportQuery.AllPassiveTransportsFor(_simulation)).Returns(_passiveTransportBuilingBlock);
     A.CallTo(() => _modelObserverQuery.AllObserversFor(A <IMoleculeBuildingBlock> .Ignored, _simulation)).Returns(_observerBuildingBlock);
     A.CallTo(() => _eventBuildingBlockCreator.CreateFor(_simulation)).Returns(_eventBuildingBlock);
     A.CallTo(() => _parameterStartValueCreator.CreateFor(A <IBuildConfiguration> .Ignored, A <Simulation> .Ignored)).Returns(_parameterValuesBuildingBlock);
     A.CallTo(() => _moleculeStartValueCreator.CreateFor(A <IBuildConfiguration> .Ignored, A <Simulation> .Ignored)).Returns(_moleculeStartValueBuildingBlock);
     sut = new BuildConfigurationTask(_spatialStructureFactory, _modelObserverQuery, _modelPassiveTransportQuery, _parameterStartValueCreator,
                                      _moleculesAndReactionsCreator, _eventBuildingBlockCreator, _moleculeStartValueCreator, _moleculeCalculationRetriever,
                                      _distributedTableConverter, _parameterDefaultStateUpdater);
 }
コード例 #2
0
        public IBuildConfiguration CreateFor(Simulation simulation, bool shouldValidate, bool createAgingDataInSimulation)
        {
            var buildConfiguration = new BuildConfiguration {
                ShouldValidate = shouldValidate
            };
            var individual = simulation.Individual;

            //STEP1: Create spatial structure
            buildConfiguration.SpatialStructure = _spatialStructureFactory.CreateFor(individual, simulation);
            _parameterDefaultStateUpdater.UpdateDefaultFor(buildConfiguration.SpatialStructure);

            //STEP2: add used calculation method to the build configuration
            _moleculeCalculationRetriever.AllMoleculeCalculationMethodsUsedBy(simulation).Each(buildConfiguration.AddCalculationMethod);

            //STEP3: Add Passive Transports
            buildConfiguration.PassiveTransports = _modelPassiveTransportQuery.AllPassiveTransportsFor(simulation)
                                                   .WithName(simulation.Name);

            //STEP4 : Molecules, and Molecule Start and reactions are generated in one go from the molecule and reaction creator
            _moleculesAndReactionsCreator.CreateFor(buildConfiguration, simulation);

            //STEP5 Add Application, Formulation and events
            buildConfiguration.EventGroups = _eventBuildingBlockCreator.CreateFor(simulation);
            _parameterDefaultStateUpdater.UpdateDefaultFor(buildConfiguration.EventGroups);

            //STEP6: Add Observers
            buildConfiguration.Observers = _modelObserverQuery.AllObserversFor(buildConfiguration.Molecules, simulation);

            //STEP7 once all building blocks have been created, we need to create the default parameter and molecule values values
            buildConfiguration.MoleculeStartValues  = _moleculeStartValuesCreator.CreateFor(buildConfiguration, simulation);
            buildConfiguration.ParameterStartValues = _parameterStartValuesCreator.CreateFor(buildConfiguration, simulation);

            //STEP8 update simulation settings
            buildConfiguration.SimulationSettings = simulation.SimulationSettings.WithName(simulation.Name);

            //STEP9 Convert all parameters to table if required
            _distributedParameterToTableParameterConverter.UpdateBuildConfigurationForAging(buildConfiguration, simulation, createAgingDataInSimulation);

            return(buildConfiguration);
        }