示例#1
0
        public override async Task <ParameterAlternative> MapToModel(Alternative snapshot, ParameterAlternativeGroup parameterAlternativeGroup)
        {
            var alternative = _parameterAlternativeFactory.CreateAlternativeFor(parameterAlternativeGroup);

            alternative.IsDefault = ModelValueFor(snapshot.IsDefault, DEFAULT_IS_DEFAULT);
            MapSnapshotPropertiesToModel(snapshot, alternative);

            await UpdateParametersFromSnapshot(snapshot, alternative, parameterAlternativeGroup.Name);

            if (parameterAlternativeGroup.IsNamed(CoreConstants.Groups.COMPOUND_SOLUBILITY))
            {
                updateSolubilityAlternative(alternative);
            }

            var alternativeWithSpecies = alternative as ParameterAlternativeWithSpecies;

            if (alternativeWithSpecies == null)
            {
                return(alternative);
            }

            alternativeWithSpecies.Species = _speciesRepository.FindByName(snapshot.Species);
            if (alternativeWithSpecies.Species == null)
            {
                throw new SnapshotOutdatedException(PKSimConstants.Error.CouldNotFindSpecies(snapshot.Species, _speciesRepository.AllNames()));
            }

            return(alternativeWithSpecies);
        }
 private void removeUnlicensedSpeciesFrom(List <SpeciesDatabaseMap> speciesMaps)
 {
     foreach (var speciesMap in speciesMaps.ToList())
     {
         if (_speciesRepository.FindByName(speciesMap.Species) == null)
         {
             speciesMaps.Remove(speciesMap);
         }
     }
 }
示例#3
0
        public Individual CreateParameterLessIndividual()
        {
            var species    = _speciesRepository.FindByName(CoreConstants.Species.HUMAN);
            var originData = new OriginData
            {
                Species           = species,
                SpeciesPopulation = species.PopulationByName(CoreConstants.Population.ICRP)
            };

            return(createStandardIndividual(originData, x => x.CreateModelStructureFor));
        }
示例#4
0
        private void updateSpeciesDependentParameter(ModelCompoundProcess process, SnapshotCompoundProcess snapshot)
        {
            if (string.IsNullOrEmpty(snapshot.Species))
            {
                return;
            }

            var species = _speciesRepository.FindByName(snapshot.Species);

            _compoundProcessTask.SetSpeciesForProcess(process, species);
        }
        public SpeciesDatabaseMapDTO MapFrom(SpeciesDatabaseMap speciesDatabaseMap)
        {
            var dto     = new SpeciesDatabaseMapDTO();
            var species = _speciesRepository.FindByName(speciesDatabaseMap.Species);

            dto.DatabaseFullPath             = speciesDatabaseMap.DatabaseFullPath;
            dto.OriginalDatabasePathFullPath = speciesDatabaseMap.DatabaseFullPath;
            dto.SpeciesName        = speciesDatabaseMap.Species;
            dto.SpeciesDisplayName = _representationInfoRepository.DisplayNameFor(species);
            return(dto);
        }
        public Individual CreateParameterLessIndividual(Species species = null)
        {
            var speciesToUse = species ?? _speciesRepository.FindByName(CoreConstants.Species.HUMAN);

            var originData = new OriginData
            {
                Species    = speciesToUse,
                Gender     = speciesToUse.IsHuman ? _genderRepository.Female : _genderRepository.Undefined,
                Population = speciesToUse.DefaultPopulation
            };

            return(createStandardIndividual(originData, x => x.CreateOrganStructureFor));
        }
        public ExpressionProfile Create(QuantityType moleculeType, string speciesName, string moleculeName)
        {
            var species = _speciesRepository.FindByName(speciesName);

            switch (moleculeType)
            {
            case QuantityType.Enzyme:
                return(Create <IndividualEnzyme>(species, moleculeName));

            case QuantityType.OtherProtein:
                return(Create <IndividualOtherProtein>(species, moleculeName));

            case QuantityType.Transporter:
                return(Create <IndividualTransporter>(species, moleculeName));

            default:
                throw new OSPSuiteException(PKSimConstants.Error.MoleculeTypeNotSupported(moleculeType.ToString()));
            }
        }
示例#8
0
        private string defaultPopulationFor(string speciesName)
        {
            var species = _speciesRepository.FindByName(speciesName);

            return(species.Populations.First().Name);
        }
 public Individual DefaultHuman()
 {
     return(DefaultIndividualFor(_speciesRepository.FindByName(CoreConstants.Species.Human)));
 }
示例#10
0
 public override object ConvertFrom(string attributeValue, SerializationContext context)
 {
     return(_speciesRepository.FindByName(attributeValue));
 }
示例#11
0
        public IndividualSettingsDTO DefaultSettingFor(SpeciesPopulation speciesPopulation)
        {
            var species = _speciesRepository.FindByName(speciesPopulation.Species);

            return(defaultSettingsFor(species, speciesPopulation));
        }
示例#12
0
        public Model.OriginData MapFrom(BatchOriginData batchOriginData)
        {
            var originData = new Model.OriginData();
            var species    = _speciesRepository.FindByName(batchOriginData.Species);

            if (species == null)
            {
                throw new PKSimException(PKSimConstants.Error.CouldNotFindSpecies(batchOriginData.Species, _speciesRepository.AllNames()));
            }

            originData.Species = species;

            var population = species.PopulationByName(batchOriginData.Population);

            if (population == null)
            {
                if (string.IsNullOrEmpty(batchOriginData.Population) && species.Populations.Count() == 1)
                {
                    population = species.Populations.ElementAt(0);
                }
                else
                {
                    throw new PKSimException(PKSimConstants.Error.CouldNotFindPopulationForSpecies(batchOriginData.Population, batchOriginData.Species, species.Populations.AllNames()));
                }
            }

            originData.SpeciesPopulation = population;

            var gender = population.GenderByName(batchOriginData.Gender);

            if (gender == null)
            {
                if (string.IsNullOrEmpty(batchOriginData.Gender))
                {
                    gender = population.Genders.ElementAt(0);
                }
                else
                {
                    throw new PKSimException(PKSimConstants.Error.CouldNotFindGenderForPopulation(batchOriginData.Gender, batchOriginData.Population, population.Genders.AllNames()));
                }
            }

            originData.Gender = gender;
            //this is not defined in matlab yet
            originData.SubPopulation = _originDataTask.DefaultSubPopulationFor(species);

            if (originData.SpeciesPopulation.IsAgeDependent)
            {
                originData.Age = batchOriginData.Age;
                var meanAgeParameter = _individualModelTask.MeanAgeFor(originData);
                originData.Age                = valueFrom(batchOriginData.Age, meanAgeParameter.Value);
                originData.AgeUnit            = meanAgeParameter.Dimension.BaseUnit.Name;
                originData.GestationalAge     = valueFrom(batchOriginData.GestationalAge, CoreConstants.NOT_PRETERM_GESTATIONAL_AGE_IN_WEEKS);
                originData.GestationalAgeUnit = CoreConstants.Units.Weeks;
            }

            var calculationMethodCategoryForSpecies = _originDataTask.AllCalculationMethodCategoryFor(species);

            foreach (var category in calculationMethodCategoryForSpecies)
            {
                string selectedCalculationMethod = batchOriginData.CalculationMethodFor(category.Name);
                if (string.IsNullOrEmpty(selectedCalculationMethod))
                {
                    originData.AddCalculationMethod(category.DefaultItemForSpecies(species));
                }
                else
                {
                    var calculationMethod = category.AllItems().FindByName(selectedCalculationMethod);
                    if (calculationMethod == null)
                    {
                        throw new PKSimException(PKSimConstants.Error.CouldNotFindCalculationMethodInCategory(selectedCalculationMethod, category.Name, category.AllItems().AllNames()));
                    }
                    if (calculationMethod.AllSpecies.Contains(species.Name))
                    {
                        originData.AddCalculationMethod(calculationMethod);
                    }
                    else
                    {
                        throw new PKSimException(PKSimConstants.Error.CalculationMethodIsNotDefinedForSpecies(selectedCalculationMethod, category.Name, species.Name));
                    }
                }
            }

            var meanWeightParameter = _individualModelTask.MeanWeightFor(originData);

            originData.Weight     = valueFrom(batchOriginData.Weight, meanWeightParameter.Value).Value;
            originData.WeightUnit = meanWeightParameter.Dimension.BaseUnit.Name;

            if (originData.SpeciesPopulation.IsHeightDependent)
            {
                var meanHeightParameter = _individualModelTask.MeanHeightFor(originData);
                originData.Height     = valueFrom(batchOriginData.Height, meanHeightParameter.Value);
                originData.HeightUnit = meanHeightParameter.Dimension.BaseUnit.Name;
            }

            return(originData);
        }
示例#13
0
        private Species speciesFrom(SnapshotOriginData snapshot)
        {
            var species = _speciesRepository.FindByName(snapshot.Species);

            return(species ?? throw new PKSimException(PKSimConstants.Error.CouldNotFindSpecies(snapshot.Species, _speciesRepository.AllNames())));
        }