public IPKSimMacroCommand UpdateValues(PathCache <IParameter> sourceParameters, IContainer targetContainer)
        {
            var allTargetParameters = new PathCache <IParameter>(_entityPathResolver).For(targetContainer.GetAllChildren <IParameter>());

            return(UpdateValues(sourceParameters, allTargetParameters));
        }
Beispiel #2
0
        private void updateReferenceToIndividualParametersForStandardContainer(Individual individual, IndividualMolecule molecule, MoleculeExpressionContainer expressionContainer, IList <IContainer> allOrganismContainers, PathCache <IMoleculeAmount> moleculeAmountPath)
        {
            var allContainers = _expressionContainersRetriever.AllContainersFor(individual.Organism, allOrganismContainers, molecule, expressionContainer);

            foreach (var container in allContainers)
            {
                var amount = amountFor(container, molecule, moleculeAmountPath);
                if (amount == null)
                {
                    continue;
                }

                updateFromIndividualParameter(amount.Parameter(CoreConstants.Parameters.REL_EXP), expressionContainer.RelativeExpressionParameter, individual, molecule);
                updateFromIndividualParameter(amount.Parameter(CoreConstants.Parameters.REL_EXP_NORM), expressionContainer.RelativeExpressionNormParameter, individual, molecule);
            }
        }
Beispiel #3
0
        protected override void Context()
        {
            var entityPathFactory = new EntityPathResolverForSpecs();

            _objectPathFactory   = new ObjectPathFactory(new AliasCreator());
            _simulation          = A.Fake <IModelCoreSimulation>().WithName("Sim");
            _simModelManager     = A.Fake <ISimModelManager>();
            _containerTask       = A.Fake <IContainerTask>();
            _options             = new ScaleDivisorOptions();
            _moleculeAmountCache = new PathCache <IMoleculeAmount>(entityPathFactory);
            var rootContainer = new ARootContainer().WithName(_simulation.Name)
                                .WithContainerType(ContainerType.Simulation);

            _simulation.Model.Root = rootContainer;
            _moleculeAmount1       = new MoleculeAmount().WithName("M1");
            _moleculeAmount2       = new MoleculeAmount().WithName("M2");

            rootContainer.Add(_moleculeAmount1);
            rootContainer.Add(_moleculeAmount2);

            _moleculeAmountCache.Add(_moleculeAmount1);
            _moleculeAmountCache.Add(_moleculeAmount2);

            _molecule1Path = entityPathFactory.PathFor(_moleculeAmount1);
            _molecule2Path = entityPathFactory.PathFor(_moleculeAmount2);

            _originalResults    = new DataRepository();
            _simulation.Results = _originalResults;

            var baseGrid = new BaseGrid("Time", Constants.Dimension.NO_DIMENSION)
            {
                Values = new[] { 0f, 1f, 2f, 3f }
            };

            _originalDataColumn = new DataColumn("M1", Constants.Dimension.NO_DIMENSION, baseGrid)
            {
                Values = new[] { 0f, 10f, 20f, 30f }
            };
            _originalDataColumn.QuantityInfo.Path = _objectPathFactory.CreateAbsoluteObjectPath(_moleculeAmount1);
            _originalResults.Add(_originalDataColumn);

            A.CallTo(_containerTask).WithReturnType <PathCache <IMoleculeAmount> >().Returns(_moleculeAmountCache);
            var simResults = new DataRepository();
            var baseGrid2  = new BaseGrid("Time", Constants.Dimension.NO_DIMENSION)
            {
                Values = new[] { 0f, 1f, 2f, 3f }
            };
            var res1 = new DataColumn("M1", Constants.Dimension.NO_DIMENSION, baseGrid2)
            {
                Values = new[] { 0f, 10f, 20f, 30f }
            };

            res1.QuantityInfo.Path = _objectPathFactory.CreateAbsoluteObjectPath(_moleculeAmount1);
            simResults.Add(res1);

            var res2 = new DataColumn("M2", Constants.Dimension.NO_DIMENSION, baseGrid2)
            {
                Values = new[] { 0f, 11f, 12f, 13f }
            };

            res2.QuantityInfo.Path = _objectPathFactory.CreateAbsoluteObjectPath(_moleculeAmount2);
            simResults.Add(res2);

            var simulationRunResults = new SimulationRunResults(true, Enumerable.Empty <ISolverWarning>(), simResults);

            A.CallTo(() => _simModelManager.RunSimulation(_simulation)).Returns(simulationRunResults);
            sut = new ScaleDivisorCalculator(_simModelManager, _containerTask, _objectPathFactory);
        }
 public CloseInstruction(PathCache pathCache)
 {
     _pathCache = pathCache;
 }
Beispiel #5
0
        private void updateAllParametersFor(Simulation simulation, Individual individual, IList <IContainer> allOrganismContainers, IndividualMolecule molecule, PathCache <IMoleculeAmount> moleculeAmountPath)
        {
            var globalMoleculeContainer = simulation.Model.Root
                                          .GetSingleChildByName <IContainer>(molecule.Name);

            hideGlobalParametersForUndefinedMolecule(globalMoleculeContainer);

            hideInterstialParametersForIntracellularLocalizationInTissue(individual, molecule, allOrganismContainers, moleculeAmountPath);

            foreach (var expressionContainer in molecule.AllExpressionsContainers())
            {
                if (expressionContainer.IsSurrogate())
                {
                    updateReferenceToIndividualParametersForSurrogateContainer(individual, molecule, expressionContainer, globalMoleculeContainer);
                }
                else
                {
                    updateReferenceToIndividualParametersForStandardContainer(individual, molecule, expressionContainer, allOrganismContainers, moleculeAmountPath);
                }
            }
        }
Beispiel #6
0
 public void UpdateParametersAndSpeciesValuesForIndividual(int individualId, IReadOnlyList <ParameterProperties> parameterProperties,
                                                           IReadOnlyList <SpeciesProperties> speciesProperties, PathCache <IParameter> parameterCache)
 {
     fillParameterAndSpeciesInitialValuesFor(individualId, parameterProperties, speciesProperties, parameterCache);
 }
 private ICommand updateParameterValues(PathCache <IParameter> sourceParameters, PathCache <IParameter> targetParameters)
 {
     return(_parameterSetUpdater.UpdateValues(sourceParameters, targetParameters));
 }
Beispiel #8
0
        public async Task <IReadOnlyCollection <ScaleDivisor> > CalculateScaleDivisorsAsync(IModelCoreSimulation simulation, ScaleDivisorOptions scaleDivisorOptions, PathCache <IMoleculeAmount> allMoleculeAmounts)
        {
            _simulationName = simulation.Name;
            var previousResults    = simulation.Results;
            var previousSelections = outputSelectionsFor(simulation);

            _allMoleculeAmounts  = allMoleculeAmounts;
            _scaleDivisorOptions = scaleDivisorOptions;
            var previousScaleDivisor = retrievePreviousScaleDivisor();

            try
            {
                resetScaleDivisor();
                settingsFor(simulation).OutputSelections = createOutputSelectionWithAllMoleculeAmountSelected();
                updateSelectedMoleculeAmount(simulation);

                var results = await runSimulation(simulation);

                return(computerScaleDivisorBasedOn(results));
            }
            finally
            {
                simulation.Results = previousResults;
                settingsFor(simulation).OutputSelections = previousSelections;
                updateSelectedMoleculeAmount(simulation);
                setPreviousScaleDivisor(previousScaleDivisor);
                _allMoleculeAmounts  = null;
                _scaleDivisorOptions = null;
            }
        }
        public void UpdateDistributedParameter(PathCache <IDistributedParameter> allDistributedParameter, PathCache <IDistributedParameter> allBaseDistributedParameters, OriginData originData)
        {
            foreach (var distributionsForOneContainer in _parameterQuery.AllParameterDistributionsFor(originData).GroupBy(dist => dist.ParentContainerPath))
            {
                foreach (var distributions in distributionsForOneContainer.GroupBy(x => x.ParameterName))
                {
                    var parameterPath    = distributionsForOneContainer.Key + ObjectPath.PATH_DELIMITER + distributions.Key;
                    var currentParameter = allDistributedParameter[parameterPath];
                    var baseParameter    = allBaseDistributedParameters[parameterPath];
                    if (currentParameter == null || baseParameter == null)
                    {
                        continue;
                    }

                    _distributionFactory.UpdateDistributionBasedOn(distributions, currentParameter, baseParameter, originData);
                }
            }
        }
Beispiel #10
0
 private IPKSimCommand updateParameterValues(PathCache <IParameter> sourceParameters, PathCache <IParameter> targetParameters)
 {
     return(_parameterSetUpdater.UpdateValues(sourceParameters, targetParameters).DowncastTo <IPKSimCommand>());
 }
        private void ConnectCallback()
        {
            _doContentScanOn.Clear();
            Initialize();
            SetFavorites();
            var defaultPath = string.IsNullOrEmpty(Connection.Model.DefaultPath)
                                  ? GetDefaultDrive()
                                  : Connection.Model.DefaultPath;

            var drive = GetDriveFromPath(defaultPath);

            if (drive != null && FileManager.FolderExists(defaultPath))
            {
                PathCache.Add(drive, defaultPath);
            }
            Drive = drive ?? Drives.First();

            if (!IsContentScanTriggerAvailable)
            {
                return;
            }

            //HACK: for testing purposes only
            if (FileManager.ServerType == FtpServerType.IIS)
            {
                ScanFolders = new Dictionary <int, FsdScanPath>()
                {
                    { 1, new FsdScanPath
                      {
                          PathId    = 1,
                          Path      = "/Hdd1/Content/0000000000000000/",
                          ScanDepth = 2,
                          Drive     = "Hdd1"
                      } }
                };
                return;
            }

            var credentials = GetHttpLogin();
            var username    = credentials.UserName;
            var password    = credentials.Password;

            switch (GetScanFolders(username, password))
            {
            case HttpStatusCode.OK:
                if (!UserSettingsProvider.DisableFsdStatusPolling)
                {
                    _statusUpdateTimer.Elapsed += StatusUpdateTimerOnElapsed;
                    _statusUpdateTimer.Start();
                }
                return;

            case HttpStatusCode.Unauthorized:
                bool result;
                do
                {
                    var loginViewModel = Container.Resolve <ILoginViewModel>();
                    loginViewModel.Title    = Resx.Login;
                    loginViewModel.Message  = Resx.LoginToFreestyleDashHttpServer;
                    loginViewModel.Username = username;
                    loginViewModel.Password = password;
                    loginViewModel.IsRememberPasswordEnabled = true;

                    var login = WindowManager.ShowLoginDialog(loginViewModel);
                    if (login == null)
                    {
                        var answer = (DisableOption)WindowManager.ShowListInputDialog(Resx.DisableFsdContentScanTriggerTitle, Resx.DisableFsdContentScanTriggerMessage, DisableOption.None, GetDisableOptionList());
                        switch (answer)
                        {
                        case DisableOption.All:
                            UserSettingsProvider.FsdContentScanTrigger = FsdContentScanTrigger.Disabled;
                            break;

                        case DisableOption.Single:
                            Connection.IsHttpAccessDisabled = true;
                            break;
                        }
                        result = true;
                    }
                    else
                    {
                        username = login.Username;
                        password = login.Password;
                        var status = GetScanFolders(username, password);
                        if (status != HttpStatusCode.OK && status != HttpStatusCode.Unauthorized)
                        {
                            //TODO: handle different result then the previous one
                            result = true;
                        }
                        else
                        {
                            result = status != HttpStatusCode.Unauthorized;
                            if (result && login.RememberPassword == true)
                            {
                                Connection.HttpUsername = username;
                                Connection.HttpPassword = password;
                                EventAggregator.GetEvent <ConnectionDetailsChangedEvent>().Publish(new ConnectionDetailsChangedEventArgs(Connection));
                            }
                        }
                    }
                } while (!result);
                break;

            case HttpStatusCode.RequestTimeout:
            {
                var answer = (DisableOption)WindowManager.ShowListInputDialog(Resx.DisableFsdContentScanTriggerTitle, Resx.DisableFsdContentScanTriggerMessage, DisableOption.None, GetDisableOptionList());
                switch (answer)
                {
                case DisableOption.All:
                    UserSettingsProvider.FsdContentScanTrigger = FsdContentScanTrigger.Disabled;
                    break;

                case DisableOption.Single:
                    Connection.IsHttpAccessDisabled = true;
                    break;
                }
            }
            break;
            }
        }
 public LineToInstruction(Vector2D <float> position, PathCache pathCache)
 {
     _position  = position;
     _pathCache = pathCache;
 }
Beispiel #13
0
        void _http_download(System.Net.HttpListenerContext req)
        {
            string path = req.Request.Url.AbsolutePath.Substring(1);

            string[] subpath = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            if (subpath.Length == 1)
            {//return the list;
                string downstr = "<html>";
                foreach (var p in _http_downcache)
                {
                    downstr += p.Key + ",locked=" + p.Value.locked + "<br/>";
                }
                downstr += "</html>";
                _http_response_html(req, downstr);
                return;
            }
            string path2 = subpath[1];

            if (System.IO.File.Exists(path) == false)
            {
                req.Response.StatusCode = 404;
                req.Response.Close();
            }
            else
            {
                if (_http_downcache.ContainsKey(path2) == false)
                {
                    _http_downcache[path2] = new PathCache("/publish/" + path2);
                }
                byte[] filebuf = _http_downcache[path2].GetBytes(path);
                //byte[] filebuf = System.IO.File.ReadAllBytes(path);
                string range = req.Request.Headers.Get("range");
                int    from  = 0;
                int    len   = filebuf.Length;
                if (string.IsNullOrWhiteSpace(range) == false)
                {
                    string[] ss = range.Split(new char[] { '-', '=' });
                    from = int.Parse(ss[1]);
                    len  = filebuf.Length - from;
                    if (string.IsNullOrWhiteSpace(ss[2]) == false)
                    {
                        int end = int.Parse(ss[2]);
                        len = end - from;
                    }
                }
                req.Response.AddHeader("Content-Range", "bytes " + from + "-");
                req.Response.ContentEncoding = System.Text.Encoding.UTF8;
                req.Response.ContentLength64 = filebuf.Length;
                req.Response.ContentType     = "application/octet-stream";
                AsyncCallback onResponse = onResponse = (rhr) =>
                {
                    try
                    {
                        req.Response.OutputStream.EndWrite(rhr);
                        req.Response.Close();
                    }
                    catch
                    {
                        try
                        {
                            req.Response.Close();
                        }catch
                        {
                        }
                    }
                };
                req.Response.OutputStream.BeginWrite(filebuf, from, len, onResponse, null);
            }
        }
        public IPKSimMacroCommand UpdateValues(PathCache <IParameter> sourceParameters, PathCache <IParameter> targetParameters, bool updateParameterOriginId = true)
        {
            var updateCommands = new PKSimMacroCommand {
                CommandType = PKSimConstants.Command.CommandTypeEdit, ObjectType = PKSimConstants.ObjectTypes.Parameter
            };

            //should update non distributed parameters first and then distributed parameter
            foreach (var sourceParameter in sourceParameters.KeyValues.OrderBy(x => x.Value.IsDistributed()))
            {
                var targetParameter = targetParameters[sourceParameter.Key];
                if (targetParameter == null)
                {
                    continue;
                }

                updateCommands.Add(UpdateValue(sourceParameter.Value, targetParameter, updateParameterOriginId));
            }

            return(updateCommands);
        }
 public void Edit(IEnumerable <IParameter> parameters)
 {
     _allParameterCache = _parameterTask.PathCacheFor(parameters);
     updateParameters();
 }
Beispiel #16
0
        private ICommand <IMoBiContext> updateSimulation(IMoBiSimulation simulationToUpdate, IBuildingBlock templateBuildingBlock, IMoBiBuildConfiguration buildConfigurationReferencingTemplates, IMoBiCommand configurationCommands, PathCache <IQuantity> fixedValueQuantities)
        {
            //create model using referencing templates
            var model = createModelAndValidate(simulationToUpdate.Model.Name, buildConfigurationReferencingTemplates);

            var simulationBuildConfiguration = createBuildConfigurationToUseInSimulation(buildConfigurationReferencingTemplates);

            var updateSimulationCommand = new UpdateSimulationCommand(simulationToUpdate, model, simulationBuildConfiguration, templateBuildingBlock).Run(_context);

            synchronizeFixedParameterValues(simulationToUpdate, fixedValueQuantities, templateBuildingBlock);

            var macro = new MoBiMacroCommand
            {
                Description = updateSimulationCommand.Description,
                CommandType = updateSimulationCommand.CommandType,
                ObjectType  = updateSimulationCommand.ObjectType
            };

            macro.Add(configurationCommands);
            macro.Add(updateSimulationCommand);
            return(macro);
        }
Beispiel #17
0
        private void fillParameterAndSpeciesInitialValuesFor(int individualId, IReadOnlyList <ParameterProperties> parameters,
                                                             IReadOnlyList <SpeciesProperties> speciesProperties, PathCache <IParameter> parameterCache)
        {
            var nonTableParameterValues = parameterDataRowFromIndividualId(individualId);

            foreach (var parameter in parameters)
            {
                // first, assign all table points for the parameter from the aging data (if any)
                fillTableParameterValuesFor(parameter, individualId);

                // if no aging data found, parameter value is stored in the population data table
                // (single value)
                if (parameter.TablePoints.Any())
                {
                    continue;
                }

                var parameterValue = nonTableParameterValues[parameter.Path].ConvertedTo <double>();
                //reset the parameter to its default value if the value in the table is NaN
                parameter.Value = double.IsNaN(parameterValue) ? parameterCache[parameter.Path].Value : parameterValue;
            }

            var initialValues = initialValuesDataRowFromIndividualId(individualId);

            if (initialValues == null)
            {
                return;
            }

            foreach (var species in speciesProperties)
            {
                species.InitialValue = initialValues[species.Path].ConvertedTo <double>();
            }
        }
Beispiel #18
0
        public MisDummyPath(float lightArea, int numLightPaths, Vector3[] positions, Vector3[] normals)
        {
            this.lightArea     = lightArea;
            this.numLightPaths = numLightPaths;
            this.positions     = positions;
            this.normals       = normals;

            // Create the light path
            pathCache = new PathCache(1, 10);

            var emitterVertex = new PathVertex {
                Point = new SurfacePoint {
                    Position = positions[0],
                    Normal   = normals[0],
                },
                PdfFromAncestor    = -10000.0f,
                PdfReverseAncestor = -10000.0f, // Guard value: this is unused!
                AncestorId         = -1,
                Depth = 0
            };
            int emVertexId = pathCache.AddVertex(emitterVertex, 0);

            // Add all intermediate surface vertices
            var   prevLightVertex    = emitterVertex;
            int   prevLightVertexIdx = emVertexId;
            float lastReverse        = 0.0f;
            float lastNee            = 0.0f;

            for (int idx = 1; idx < normals.Length; ++idx)
            {
                // Add the vertex on the first surface
                var surfaceVertex = new PathVertex {
                    Point = new SurfacePoint {
                        Position = positions[idx],
                        Normal   = normals[idx],
                    },
                    AncestorId = prevLightVertexIdx,
                    Depth      = (byte)idx
                };

                // Compute the geometry terms
                Vector3 dirToLight = prevLightVertex.Point.Position - surfaceVertex.Point.Position;
                float   distSqr    = dirToLight.LengthSquared();
                dirToLight = Vector3.Normalize(dirToLight);
                float cosSurfToLight = Vector3.Dot(dirToLight, surfaceVertex.Point.Normal);
                float cosLightToSurf = Vector3.Dot(-dirToLight, prevLightVertex.Point.Normal);

                // pdf for diffuse sampling of the emission direction
                surfaceVertex.PdfFromAncestor      = (cosLightToSurf / MathF.PI) * (cosSurfToLight / distSqr);
                surfaceVertex.PdfReverseAncestor   = lastReverse;
                surfaceVertex.PdfNextEventAncestor = lastNee;

                lastReverse = (cosSurfToLight / MathF.PI) * (cosLightToSurf / distSqr);
                if (idx == 1)
                {
                    surfaceVertex.PdfFromAncestor *= 1.0f / lightArea; // emission surface sampling pdf
                    lastNee = 1.0f / lightArea;                        // Next event
                }
                else
                {
                    lastNee = 0.0f;
                }

                int lightVertexIndex = pathCache.AddVertex(surfaceVertex, 0);

                prevLightVertex    = surfaceVertex;
                prevLightVertexIdx = lightVertexIndex;
            }

            lightEndpointIdx = prevLightVertexIdx;

            // Create the camera path
            cameraVertices = new PathPdfPair[positions.Length];

            // sampling the camera itself / a point on the lens
            cameraVertices[0] = new PathPdfPair {
                PdfFromAncestor = 1.0f, // lens / sensor sampling is deterministic
                PdfToAncestor   = 0.0f
            };

            // primary surface vertex
            cameraVertices[1] = new PathPdfPair {
                PdfFromAncestor = numLightPaths * 0.8f, // surface area pdf of sampling this vertex from the camera
                PdfToAncestor   = 1.0f
            };

            // All other surface vertices
            float nextReverse  = lastReverse;
            int   lightVertIdx = lightEndpointIdx;

            for (int idx = 2; idx < positions.Length; ++idx)
            {
                var lightVert = pathCache[0, lightVertIdx];

                cameraVertices[idx] = new PathPdfPair {
                    PdfFromAncestor = nextReverse,
                    PdfToAncestor   = lightVert.PdfFromAncestor
                };

                nextReverse  = lightVert.PdfReverseAncestor;
                lightVertIdx = lightVert.AncestorId;
            }

            // The last camera path vertex is special: it should not already contain the NEE pdf
            var dir      = pathCache[0, 0].Point.Position - pathCache[0, 1].Point.Position;
            var cossurf  = Vector3.Dot(Vector3.Normalize(dir), pathCache[0, 1].Point.Normal);
            var coslight = Vector3.Dot(Vector3.Normalize(-dir), pathCache[0, 0].Point.Normal);
            var distsqr  = dir.LengthSquared();

            cameraVertices[^ 1].PdfFromAncestor = cossurf * coslight / distsqr / MathF.PI;
Beispiel #19
0
 public BidirPathPdfs(PathCache cache, Span <float> lightToCam, Span <float> camToLight)
 {
     PdfsCameraToLight = camToLight;
     PdfsLightToCamera = lightToCam;
     LightPathCache    = cache;
 }
Beispiel #20
0
 public override void StartAnalysis(IPopulationDataCollector populationDataCollector, PopulationAnalysis populationAnalysis)
 {
     _allQuantities = _entitiesInContainerRetriever.QuantitiesFrom(populationDataCollector);
     base.StartAnalysis(populationDataCollector, populationAnalysis);
 }
Beispiel #21
0
        private void synchronizeFixedParameterValues(IMoBiSimulation simulationToUpdate, IBuildingBlock templateBuildingBlock, PathCache <IQuantity> fixedValueQuantities)
        {
            if (fixedValueQuantities == null)
            {
                return;
            }

            var currentQuantities = new PathCache <IQuantity>(_entityPathResolver);

            currentQuantities.AddRange(simulationToUpdate.Model.Root.GetAllChildren <IQuantity>());

            foreach (var fixedValueQuantity in fixedValueQuantities.KeyValues)
            {
                //quantity does not exist anymore after update. Nothing to do
                var simulationQuantity = currentQuantities[fixedValueQuantity.Key];
                if (simulationQuantity == null)
                {
                    continue;
                }

                //building block corresponding to quantity could not be found. That should never happen
                var affectedBuildingBlock = _affectedBuildingBlockRetriever.RetrieveFor(simulationQuantity, simulationToUpdate);
                if (affectedBuildingBlock?.UntypedTemplateBuildingBlock == null)
                {
                    continue;
                }

                //The quantity previously fixed is part of the template building block. We should not reset the changes
                if (Equals(affectedBuildingBlock.UntypedTemplateBuildingBlock, templateBuildingBlock))
                {
                    continue;
                }

                synchronizeQuantities(fixedValueQuantity.Value, simulationQuantity);
            }
        }
        public IndividualValuesCache ImportFrom(string populationFileFullPath, IImportLogger logger, PathCache <IParameter> allParameters = null)
        {
            try
            {
                foreach (var delimiter in ALLOWED_DELIMITERS)
                {
                    var individualValuesCache = individualValuesCacheFrom(populationFileFullPath, delimiter);
                    //we found at least one individual, this is a valid file for the delimiter and we can exit
                    if (individualValuesCache?.Count > 0)
                    {
                        return(withPathsContainingUnitsUpdated(individualValuesCache, allParameters, logger));
                    }
                }

                //no match. Log
                logger.AddError(Warning.PopulationFileFormatIsNotSupported);
                return(new IndividualValuesCache());
            }
            catch (Exception e)
            {
                logger.AddError(e.FullMessage());
                return(new IndividualValuesCache());
            }
        }
Beispiel #23
0
 public virtual void Merge(IndividualPropertiesCache individualPropertiesCache, PathCache <IParameter> parameterCache)
 {
     AllCovariates.AddRange(individualPropertiesCache.AllCovariates);
     ParameterValuesCache.Merge(individualPropertiesCache.ParameterValuesCache, parameterCache);
 }
        private IndividualValuesCache withPathsContainingUnitsUpdated(IndividualValuesCache individualValuesCache, PathCache <IParameter> allParameters, IImportLogger logger)
        {
            // No parameters to check from, return as IS
            if (allParameters == null)
            {
                return(individualValuesCache);
            }

            //Use TO LIST here because collection might be modified
            foreach (var parameterValue in individualValuesCache.AllParameterValues.ToList())
            {
                var parameterPath = parameterValue.ParameterPath;
                if (allParameters.Contains(parameterPath))
                {
                    continue;
                }

                var pathWithUnitsRemoved = parameterPath.StripUnit();
                if (allParameters.Contains(pathWithUnitsRemoved))
                {
                    individualValuesCache.RenamePath(parameterPath, pathWithUnitsRemoved);
                    parameterValue.ParameterPath = pathWithUnitsRemoved;
                    continue;
                }

                logger.AddWarning(Warning.ParameterWithPathNotFoundInBaseIndividual(parameterPath));
                individualValuesCache.Remove(parameterPath);
            }

            return(individualValuesCache);
        }
Beispiel #25
0
        private void hideInterstialParametersForIntracellularLocalizationInTissue(Individual individual, IndividualMolecule molecule, IList <IContainer> allOrganismContainers, PathCache <IMoleculeAmount> moleculeAmountPath)
        {
            var protein = molecule as IndividualProtein;

            if (protein?.TissueLocation != TissueLocation.Intracellular || protein.IntracellularVascularEndoLocation != IntracellularVascularEndoLocation.Interstitial)
            {
                return;
            }

            var vascularEndothelium = protein.ExpressionContainer(CoreConstants.Compartment.VascularEndothelium);

            if (vascularEndothelium == null)
            {
                return;
            }

            var allInterstitialContainer = _expressionContainersRetriever.AllContainersFor(individual.Organism, allOrganismContainers, protein, vascularEndothelium);

            foreach (var interstitial in allInterstitialContainer)
            {
                var amount = amountFor(interstitial, molecule, moleculeAmountPath);
                if (amount == null)
                {
                    continue;
                }

                hideParameter(amount.Parameter(CoreConstants.Parameters.REL_EXP));
                hideParameter(amount.Parameter(CoreConstants.Parameters.REL_EXP_NORM));
            }
        }
Beispiel #26
0
        private void updateParameterValue(Population population, int individualId, IParameter parameter, PathCache <IParameter> extractedIndividualParameterCache)
        {
            var parameterPath      = _entityPathResolver.PathFor(parameter);
            var parameterValues    = population.AllValuesFor(parameterPath);
            var extractedParameter = extractedIndividualParameterCache[parameterPath];
            var value = parameterValues[individualId];

            if (!shouldUpdateParameter(extractedParameter, value))
            {
                return;
            }

            extractedParameter.Value = value;
        }
Beispiel #27
0
        private IMoleculeAmount amountFor(IContainer container, IndividualMolecule molecule, PathCache <IMoleculeAmount> moleculeAmountPath)
        {
            var amount = moleculeAmountPath[_entityPathResolver.ObjectPathFor(container).AndAdd(molecule.Name).ToString()];

            return(amount);
        }
Beispiel #28
0
 public virtual void Edit(IEnumerable <IParameter> parameters)
 {
     _visibleParameters = parameters.Where(x => x.Visible).ToList();
     _pathCache         = _parameterTask.PathCacheFor(_visibleParameters);
 }
 public TreeBrowserModel(BrowserController controller, PathCache cache, ListProgressListener listener)
 {
     _controller = controller;
     _cache      = cache;
 }
        public IndividualValuesCache ImportFrom(string fileFullPath, PathCache <IParameter> allParameters, IImportLogger logger)
        {
            var individualValuesCache = _individualValuesCacheImporter.ImportFrom(fileFullPath, logger, allParameters);

            return(withUpdatedGenderAndRace(individualValuesCache));
        }