Exemplo n.º 1
0
 public void Update(Individual sourceIndividual, Individual targetIndividual)
 {
     foreach (var molecule in sourceIndividual.AllMolecules())
     {
         var newMolecule = _cloner.Clone(molecule);
         targetIndividual.AddMolecule(newMolecule);
         //we have to reset the new ontogeny for the molecule
         _ontogenyTask.SetOntogenyForMolecule(newMolecule, newMolecule.Ontogeny, targetIndividual);
     }
 }
Exemplo n.º 2
0
        private void setDefaultOntogeny(IndividualMolecule molecule, TSimulationSubject simulationSubject, string moleculeName)
        {
            var ontogeny = _ontogenyRepository.AllFor(simulationSubject.Species.Name).FindByName(moleculeName);

            if (ontogeny == null)
            {
                return;
            }
            _ontogenyTask.SetOntogenyForMolecule(molecule, ontogeny, simulationSubject);
        }
Exemplo n.º 3
0
        private void setDefaultOntogeny(IndividualMolecule molecule, Individual individual, string moleculeName)
        {
            var ontogeny = _ontogenyRepository.AllFor(individual.Species.Name).FindByName(moleculeName);

            if (ontogeny == null)
            {
                return;
            }

            _ontogenyTask.SetOntogenyForMolecule(molecule, ontogeny, individual);
        }
Exemplo n.º 4
0
        public void Update(Individual sourceIndividual, Individual targetIndividual)
        {
            foreach (var molecule in sourceIndividual.AllMolecules())
            {
                var newMolecule = _cloner.Clone(molecule);
                targetIndividual.AddMolecule(newMolecule);

                //Make sure parameters that user defined parameters are reset to default to ensure proper scaling
                resetMoleculeParametersToDefault(newMolecule);

                //we have to reset the ontogeny for the molecule based on the target individual properties
                _ontogenyTask.SetOntogenyForMolecule(newMolecule, newMolecule.Ontogeny, targetIndividual);
            }
        }
Exemplo n.º 5
0
        public override async Task <ModelExpressionProfile> MapToModel(SnapshotExpressionProfile snapshot, SnapshotContext snapshotContext)
        {
            var expressionProfile = _expressionProfileFactory.Create(snapshot.Type, snapshot.Species, snapshot.Molecule);

            expressionProfile.Description = snapshot.Description;
            expressionProfile.Category    = snapshot.Category;

            var(molecule, individual) = expressionProfile;
            //Update molecule properties first
            updateMoleculePropertiesToMolecule(molecule, snapshot, individual, snapshotContext);

            //Then override all parameters that were set
            await _parameterMapper.MapLocalizedParameters(snapshot.Parameters, individual, snapshotContext, !snapshotContext.IsV9FormatOrEarlier);

            var snapshotWithSubjectContext = new SnapshotContextWithSubject(individual, snapshotContext);
            var ontogeny = await _ontogenyMapper.MapToModel(snapshot.Ontogeny, snapshotWithSubjectContext);

            _ontogenyTask.SetOntogenyForMolecule(molecule, ontogeny, individual);

            var context = new ExpressionContainerMapperContext(snapshotContext)
            {
                Molecule                     = molecule,
                ExpressionParameters         = individual.AllExpressionParametersFor(molecule),
                MoleculeExpressionContainers = individual.AllMoleculeContainersFor(molecule),
            };
            await _expressionContainerMapper.MapToModels(snapshot.Expression, context);

            //We need to normalize relative expressions when loading from old format
            if (snapshotContext.IsV9FormatOrEarlier)
            {
                //Make sure we load the default parameters from db just in case we were dealing with a standard molecule
                _moleculeParameterTask.SetDefaultMoleculeParameters(molecule);

                //Global parameters were saved directly under the snapshot parameter
                await updateGlobalMoleculeParameters(snapshot, molecule, snapshotContext);

                NormalizeRelativeExpressionCommand.NormalizeExpressions(individual, molecule);
            }

            return(expressionProfile);
        }
Exemplo n.º 6
0
        public override async Task <IndividualMolecule> MapToModel(Molecule snapshot, ModelIndividual individual)
        {
            var molecule = createMoleculeFrom(snapshot, individual);

            MapSnapshotPropertiesToModel(snapshot, molecule);

            //This call should happen before updating parameters from snapshot to ensure that default molecule
            //parameters that were updated by the user are taking precedence.
            _moleculeExpressionTask.SetDefaulMoleculeParameters(molecule);

            await UpdateParametersFromSnapshot(snapshot, molecule, snapshot.Type.ToString());

            updateMoleculePropertiesToMolecule(molecule, snapshot);

            var ontogeny = await _ontogenyMapper.MapToModel(snapshot.Ontogeny, individual);

            _ontogenyTask.SetOntogenyForMolecule(molecule, ontogeny, individual);

            await updateExpression(snapshot, new ExpressionContainerMapperContext { Molecule = molecule, SimulationSubject = individual });

            return(molecule);
        }
Exemplo n.º 7
0
 private void updateGlobalMoleculeSettings(IndividualMolecule sourceMolecule, IndividualMolecule targetMolecule, ISimulationSubject targetSimulationSubject)
 {
     targetMolecule.UpdatePropertiesFrom(sourceMolecule, _cloner);
     _ontogenyTask.SetOntogenyForMolecule(targetMolecule, targetMolecule.Ontogeny, targetSimulationSubject);
 }
Exemplo n.º 8
0
 public void SelectedOntogenyIs(Ontogeny ontogeny)
 {
     AddCommand(_ontogenyTask.SetOntogenyForMolecule(_individualMolecule, ontogeny, _simulationSubject));
     updateShowOntogenyButton();
 }