protected override void Context()
 {
     _simulation = BatchToolFactoryForSpecs.DefaultSimulation();
     _settings   = new JsonSerializerSettings {
         NullValueHandling = NullValueHandling.Ignore
     };
 }
Exemple #2
0
        public static Simulation SimulationFrom(Individual individual, Compound compound,
                                                ApplicationProtocol protocol, SimulationConfiguration configuration, IEnumerable <ParameterVariationSet> parameterVariationSets)
        {
            var simulation = new Simulation {
                Individual = individual
            };

            simulation.Compounds.Add(compound);
            simulation.ApplicationProtocols.Add(protocol);
            simulation.Configuration          = configuration;
            simulation.ParameterVariationSets = new List <ParameterVariationSet>(parameterVariationSets);
            return(simulation);
        }
        protected override void Context()
        {
            _simulation = BatchToolFactoryForSpecs.DefaultSimulation();
            var pv1 = new ParameterVariationSet {
                Name = "PV1"
            };

            pv1.ParameterValues.Add(new ParameterValue("A|B|C", 15, 0.2));
            pv1.ParameterValues.Add(new ParameterValue("A|B|C|D", 20, 0.6));
            _simulation.ParameterVariationSets.Add(pv1);

            _settings = new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            };
        }
        protected override void Because()
        {
            string output = JsonConvert.SerializeObject(_simulation, _settings);

            _converted = JsonConvert.DeserializeObject <Simulation>(output);
        }
        private void exportToFolder(string exportFolder)
        {
            var defaultIndividual = _defaultIndividualRetriever.DefaultHuman();
            var batchSimulation   = new Simulation();

            batchSimulation.Individual = new Individual
            {
                Age        = defaultIndividual.Age,
                Height     = defaultIndividual.MeanHeight,
                Species    = defaultIndividual.Species.Name,
                Population = defaultIndividual.Population.Name,
            };

            batchSimulation.Compounds.Add(new Compound {
                Name = "Standard Molecule", Lipophilicity = 3, FractionUnbound = 0.1, MolWeight = 4E-7, SolubilityAtRefpH = 9999, RefpH = 7
            });
            var intrevanousBolus = new ApplicationProtocol {
                CompoundName = "Standard Molecule", ApplicationType = CoreConstants.Application.Name.IntravenousBolus, Dose = 1, DoseUnit = "mg/kg", DosingInterval = DosingIntervals.Single.ToString()
            };


            batchSimulation.Configuration = new SimulationConfiguration {
                Model = CoreConstants.Model.FourComp
            };
            batchSimulation.ApplicationProtocols.Add(intrevanousBolus);
            var fourCompIvBolusMgPerKg = configurationFrom(batchSimulation);

            batchSimulation.Configuration = new SimulationConfiguration {
                Model = CoreConstants.Model.TwoPores
            };
            var twoPore = configurationFrom(batchSimulation);

            batchSimulation.ApplicationProtocols.Clear();
            intrevanousBolus.DoseUnit = "mg";
            batchSimulation.ApplicationProtocols.Add(intrevanousBolus);
            batchSimulation.Configuration = new SimulationConfiguration {
                Model = CoreConstants.Model.FourComp
            };
            var fourCompIvBolusMg = configurationFrom(batchSimulation);


            twoPore.SpatialStructure.Name  = "Human 2 Pores";
            twoPore.PassiveTransports.Name = "2 Pores Passive Transports";

            fourCompIvBolusMgPerKg.SpatialStructure.Name  = "Human Standard";
            fourCompIvBolusMgPerKg.PassiveTransports.Name = "Standard Passive Transports";
            fourCompIvBolusMgPerKg.EventGroups.Name       = "IV Bolus";
            fourCompIvBolusMgPerKg.Molecules.Name         = "Standard Molecule";
            fourCompIvBolusMgPerKg.Observers.Name         = "Standard Observer";


            fourCompIvBolusMg.EventGroups.Name = "IV Bolus (mg)";

            var defaultCompound = fourCompIvBolusMgPerKg.Molecules.First();

            defaultCompound.Name = string.Empty;
            defaultCompound.Parameter(CoreConstants.Parameter.LIPOPHILICITY).Value     = double.NaN;
            defaultCompound.Parameter(CoreConstants.Parameter.MOLECULAR_WEIGHT).Value  = double.NaN;
            defaultCompound.Parameter(CoreConstants.Parameter.FractionUnbound).Value   = double.NaN;
            defaultCompound.Parameter(CoreConstants.Parameter.SolubilityAtRefpH).Value = double.NaN;

            _moBiExportTask.UpdateObserverForAllFlag(fourCompIvBolusMgPerKg.Observers);

            var buildingBlocks = new IBuildingBlock[]
            {
                twoPore.SpatialStructure, twoPore.PassiveTransports,
                fourCompIvBolusMgPerKg.SpatialStructure, fourCompIvBolusMgPerKg.PassiveTransports, fourCompIvBolusMgPerKg.EventGroups, fourCompIvBolusMgPerKg.Molecules, fourCompIvBolusMgPerKg.Observers,
                fourCompIvBolusMg.EventGroups
            };

            buildingBlocks.Each(bb => saveToPKML(bb, exportFolder));
        }
 private IBuildConfiguration configurationFrom(Simulation batchSimulation)
 {
     return(_buildConfigurationTask.CreateFor(_simulationMapper.MapFrom(batchSimulation).Simulation, shouldValidate: false, createAgingDataInSimulation: false));
 }