Пример #1
0
        public override void GlobalContext()
        {
            base.GlobalContext();

            _objectPathFactory   = IoC.Resolve <IObjectPathFactory>();
            _modelCoreSimulation = IoC.Resolve <SimulationHelperForSpecs>().CreateSimulation();
            var simModelExporter          = IoC.Resolve <ISimModelExporter>();
            var simModelSimulationFactory = A.Fake <ISimModelSimulationFactory>();

            A.CallTo(() => simModelSimulationFactory.Create()).Returns(new Simulation());
            _simModelManagerForSpecs = new SimModelManagerForSpecs(simModelExporter, simModelSimulationFactory);

            _simModelSimulation     = _simModelManagerForSpecs.CreateSimulation(_modelCoreSimulation);
            _dataFactory            = A.Fake <IDataFactory>();
            _variableParameterPaths = new[]
            {
                _objectPathFactory.CreateObjectPathFrom(ConstantsForSpecs.Organism, ConstantsForSpecs.BW).PathAsString,
                _objectPathFactory.CreateObjectPathFrom(ConstantsForSpecs.Organism, ConstantsForSpecs.TableParameter1).PathAsString,
            };

            _variableSpeciesPath = new []
            {
                _objectPathFactory.CreateObjectPathFrom(ConstantsForSpecs.Organism, ConstantsForSpecs.ArterialBlood, ConstantsForSpecs.Plasma, "A").PathAsString,
                _objectPathFactory.CreateObjectPathFrom(ConstantsForSpecs.Organism, ConstantsForSpecs.VenousBlood, ConstantsForSpecs.Plasma, "B").PathAsString,
            };

            sut = new SimModelBatch(simModelExporter, simModelSimulationFactory, _dataFactory);
        }
        private void setupParticleBin(IApplicationBuilder applicBuilder, int binIndex, double binRadius, double binNumberOfParticlesFactor, IFormulaCache formulaCache)
        {
            var binName      = binContainerName(binIndex);
            var binContainer = applicBuilder.GetSingleChildByName <IContainer>(binName);

            var numberOfParticlesFactor = binContainer.Parameter(CoreConstants.Parameters.NUMBER_OF_PARTICLES_FACTOR);

            numberOfParticlesFactor.Value = binNumberOfParticlesFactor;

            var particleRadius = binContainer.Parameter(CoreConstants.Parameters.START_PARTICLE_RADIUS);

            particleRadius.Value = binRadius;

            // add application molecule in particle bin and set its formula
            var appMoleculeBuilder = _objectBaseFactory.Create <IApplicationMoleculeBuilder>().WithName(solubleMoleculeName(binIndex));

            appMoleculeBuilder.RelativeContainerPath = _objectPathFactory.CreateObjectPathFrom(binName);
            appMoleculeBuilder.Formula = particleDrugMassFormula(formulaCache);
            applicBuilder.AddMolecule(appMoleculeBuilder);

            // add insoluble molecule for particle bin
            appMoleculeBuilder = _objectBaseFactory.Create <IApplicationMoleculeBuilder>().WithName(insolubleMoleculeName(binIndex));
            appMoleculeBuilder.RelativeContainerPath = _objectPathFactory.CreateObjectPathFrom(binName, CoreConstants.ContainerName.InsolubleDrug);
            appMoleculeBuilder.Formula = insolubleDrugStartFormula(formulaCache);
            applicBuilder.AddMolecule(appMoleculeBuilder);
        }
        /// <summary>
        ///    Returns the quantity and the consolidated object path of that quantity in the simulation (adding the simulation name
        ///    at the beginning)
        /// </summary>
        /// <param name="simulation"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        private Tuple <IQuantity, IObjectPath> quantityAndPathFrom(Simulation simulation, IEnumerable <string> path)
        {
            var objectPath = _objectPathFactory.CreateObjectPathFrom(path).AndAddAtFront(simulation.Name);
            var quantity   = objectPath.TryResolve <IQuantity>(simulation.Model.Root);

            return(new Tuple <IQuantity, IObjectPath>(quantity, objectPath));
        }
Пример #4
0
        private string pathWithoutSimulationName(string simulationPath)
        {
            var quantityPath = _objectPathFactory.CreateObjectPathFrom(simulationPath.ToPathArray());

            quantityPath.Remove(_simulationName);
            return(quantityPath.PathAsString);
        }
Пример #5
0
        protected TMoleculeExpressionContainer AddVascularSystemExpression(TMolecule protein, string surrogateName)
        {
            var expressionContainer = addContainerExpression(protein, surrogateName, CoreConstants.Groups.VASCULAR_SYSTEM);

            expressionContainer.OrganPath = _objectPathFactory.CreateObjectPathFrom(surrogateName);
            return(expressionContainer);
        }
Пример #6
0
        /// <summary>
        ///    Add start formula for the drug molecule. Will be created in the root application container
        /// </summary>
        private void addDrugStartFormula(IApplicationBuilder applicationBuilder, IFormulaCache formulaCache)
        {
            var applicationMoleculeBuilder = _objectBaseFactory.Create <IApplicationMoleculeBuilder>().WithName(applicationBuilder.Name);

            applicationMoleculeBuilder.RelativeContainerPath = _objectPathFactory.CreateObjectPathFrom(ObjectPath.PARENT_CONTAINER, applicationBuilder.Name);
            applicationMoleculeBuilder.Formula = _formulaFactory.DrugMassFormulaFor(formulaCache);
            applicationBuilder.AddMolecule(applicationMoleculeBuilder);
        }
Пример #7
0
        private DataTable createPopInitialValues()
        {
            var dt = new DataTable("InitialValues");

            dt.Columns.Add(Constants.Population.INDIVIDUAL_ID_COLUMN);

            var path = _objectPathFactory.CreateObjectPathFrom(ConstantsForSpecs.Organism,
                                                               ConstantsForSpecs.ArterialBlood,
                                                               ConstantsForSpecs.Plasma,
                                                               "A").PathAsString;

            dt.Columns.Add(path);

            path = _objectPathFactory.CreateObjectPathFrom(ConstantsForSpecs.Organism,
                                                           ConstantsForSpecs.VenousBlood,
                                                           ConstantsForSpecs.Plasma,
                                                           "A").PathAsString;
            dt.Columns.Add(path);


            dt.Rows.Add(0, 1.1, 2.2);
            dt.Rows.Add(1, 3.3, 4.4);
            dt.Rows.Add(2, 5.5, 6.6);

            return(dt);
        }
        public override object ConvertFrom(string attributeValue, SerializationContext context)
        {
            if (string.IsNullOrEmpty(attributeValue))
            {
                return(new ObjectPath());
            }

            return(_objectPathFactory.CreateObjectPathFrom(attributeValue.ToPathArray()));
        }
        private IBuildConfiguration createBuildConfiguration()
        {
            var buildConfiguration = new BuildConfigurationForSpecs();

            buildConfiguration.Molecules          = getMolecules();
            buildConfiguration.Reactions          = getReactions();
            buildConfiguration.SpatialStructure   = getSpatialStructure();
            buildConfiguration.PassiveTransports  = new PassiveTransportBuildingBlock();
            buildConfiguration.Observers          = new ObserverBuildingBlock();
            buildConfiguration.EventGroups        = new EventGroupBuildingBlock();
            buildConfiguration.SimulationSettings = createSimulationConfiguration();


            buildConfiguration.MoleculeStartValues = _moleculeStartValuesCreator.CreateFrom(buildConfiguration.SpatialStructure, buildConfiguration.Molecules);
            var objectPathForContainerThatDoesNotExist = _objectPathFactory.CreateObjectPathFrom("TOTO", "TATA");

            buildConfiguration.MoleculeStartValues.Add(_moleculeStartValuesCreator.CreateMoleculeStartValue(objectPathForContainerThatDoesNotExist, "A", _concentrationDimension));
            buildConfiguration.ParameterStartValues = _parameterStartValuesCreator.CreateFrom(buildConfiguration.SpatialStructure, buildConfiguration.Molecules);

            setMoleculeStartValues(buildConfiguration.MoleculeStartValues);
            return(buildConfiguration);
        }
Пример #10
0
        /// <summary>
        ///    Get Results from SimModel
        /// </summary>
        /// <param name="simulation">SimModel simulation</param>
        /// <param name="individualId">Individual id</param>
        private IndividualResults individualResultsFrom(SimModelNET.ISimulation simulation, int individualId)
        {
            var results = new IndividualResults {
                IndividualId = individualId
            };
            var simulationTimes       = simulation.SimulationTimes;
            var simulationTimesLength = simulationTimes.Length;

            foreach (var result in simulation.AllValues)
            {
                //Add quantity name and remove simulation name
                var quantityPath = _objectPathFactory.CreateObjectPathFrom(result.Path.ToPathArray());
                quantityPath.Remove(_simulationName);
                results.Add(quantityValuesFor(quantityPath.ToString(), result, simulationTimesLength));
            }

            results.Time = quantityValuesFor(Constants.TIME, simulation.SimulationTimes);
            return(results);
        }
        public IObjectPath MapFrom(long flatObjectPathId)
        {
            FlatRelativeObjectPath flatObjectPath = _flatObjectPathRepo.FlatRelativeObjectPathFor(flatObjectPathId);

            var relativePath = new List <string>();

            //first entry
            if (flatObjectPath.ContainerName != CoreConstants.ORM.ContainerMe)
            {
                relativePath.Add(flatObjectPath.ContainerName);
            }

            while (flatObjectPath.PathId != flatObjectPath.ParentPathId)
            {
                flatObjectPath = _flatObjectPathRepo.FlatRelativeObjectPathFor(flatObjectPath.ParentPathId);

                if (flatObjectPath.ContainerName != CoreConstants.ORM.ContainerMe)
                {
                    relativePath.Add(flatObjectPath.ContainerName);
                }
            }
            relativePath.Reverse();
            return(_objectPathFactory.CreateObjectPathFrom(relativePath.ToArray()));
        }
 private IObjectPath moleculeGlobalPathFor(string moleculeName)
 {
     return(_objectPathFactory.CreateObjectPathFrom(moleculeName));
 }
Пример #13
0
        private IParameterStartValue globalMoleculeParameterValueFor(IMoleculeBuilder moleculeBuilder, IParameter parameterTemplate)
        {
            var parameterPath = _objectPathFactory.CreateObjectPathFrom(moleculeBuilder.Name, parameterTemplate.Name);

            return(CreateParameterStartValue(parameterPath, parameterTemplate));
        }