Example #1
0
        public ICommand LoadOntogenyForMolecule(IndividualMolecule molecule, TSimulationSubject simulationSubject)
        {
            var dataImporterSettings = new DataImporterSettings
            {
                Caption = $"{CoreConstants.ProductDisplayName} - {PKSimConstants.UI.ImportOntogeny}",
                Icon    = ApplicationIcons.Excel
            };

            var data = _dataImporter.ImportDataSet(new List <MetaDataCategory>(), getColumnInfos(), dataImporterSettings);

            if (data == null)
            {
                return(null);
            }

            var ontogeny = new UserDefinedOntogeny {
                Table = formulaFrom(data), Name = data.Name
            };

            //only first formulation will be imported
            if (_ontogenyRepository.AllNames().Contains(ontogeny.Name))
            {
                var name = _entityTask.NewNameFor(ontogeny, _ontogenyRepository.AllNames());
                if (string.IsNullOrEmpty(name))
                {
                    return(null);
                }

                ontogeny.Name = name;
            }

            return(SetOntogenyForMolecule(molecule, ontogeny, simulationSubject));
        }
Example #2
0
        protected override async Task Context()
        {
            await base.Context();

            _ontogeny = new UserDefinedOntogeny
            {
                Name        = "UserDefined",
                Description = "UserDefined description",
                Table       = _distributedTableFormula
            };
        }
 protected override void Context()
 {
     base.Context();
     _randomGenerator     = new RandomGenerator();
     _userDefinedOntogeny = A.Fake <UserDefinedOntogeny>();
     A.CallTo(() => _userDefinedOntogeny.PostmenstrualAges()).Returns(new [] { 1, 2, 3f });
     A.CallTo(() => _userDefinedOntogeny.OntogenyFactors()).Returns(new [] { 0, 1, 31f });
     A.CallTo(() => _userDefinedOntogeny.Deviations()).Returns(new [] { 1, 1, 1f });
     _originData = new OriginData {
         Species = new Species {
             Name = CoreConstants.Species.HUMAN
         }, Age = 1, GestationalAge = 24
     };
 }
Example #4
0
        protected override async Task Context()
        {
            await base.Context();

            _ontogeny = new UserDefinedOntogeny
            {
                Name        = "UserDefined",
                Description = "UserDefined description",
                Table       = _distributedTableFormula
            };

            _snapshot = await sut.MapToSnapshot(_ontogeny);

            A.CallTo(() => _distributedTableFormulaMapper.MapToModel(_snapshotTable)).Returns(_distributedTableFormula);
        }
        public ICommand LoadOntogenyForMolecule(IndividualMolecule molecule, ISimulationSubject simulationSubject)
        {
            var dataImporterSettings = new DataImporterSettings
            {
                Caption  = $"{CoreConstants.ProductDisplayName} - {PKSimConstants.UI.ImportOntogeny}",
                IconName = ApplicationIcons.Excel.IconName
            };

            dataImporterSettings.AddNamingPatternMetaData(Constants.FILE);

            var data = _dataImporter.ImportDataSets(
                new List <MetaDataCategory>(),
                getColumnInfos(),
                dataImporterSettings,
                _dialogCreator.AskForFileToOpen(Captions.Importer.OpenFile, Captions.Importer.ImportFileFilter, Constants.DirectoryKey.OBSERVED_DATA)
                ).DataRepositories.FirstOrDefault();

            if (data == null)
            {
                return(null);
            }

            var ontogeny = new UserDefinedOntogeny {
                Table = formulaFrom(data), Name = data.Name
            };

            //only first ontogeny will be imported
            if (_ontogenyRepository.AllNames().Contains(ontogeny.Name))
            {
                var name = _entityTask.NewNameFor(ontogeny, _ontogenyRepository.AllNames());
                if (string.IsNullOrEmpty(name))
                {
                    return(null);
                }

                ontogeny.Name = name;
            }

            return(SetOntogenyForMolecule(molecule, ontogeny, simulationSubject));
        }
Example #6
0
        public override async Task <ModelOntogeny> MapToModel(SnapshotOntogeny snapshot, ISimulationSubject simulationSubject)
        {
            if (snapshot == null)
            {
                return(new NullOntogeny());
            }

            var speciesName = simulationSubject.Species.Name;

            if (snapshot.Table == null)
            {
                return(_ontogenyRepository.AllFor(speciesName).FindByName(snapshot.Name));
            }

            var ontogeny = new UserDefinedOntogeny
            {
                Table       = await _distributedTableFormulaMapper.MapToModel(snapshot.Table),
                SpeciesName = speciesName
            };

            MapSnapshotPropertiesToModel(snapshot, ontogeny);
            return(ontogeny);
        }