Пример #1
0
        protected void AddTissueOrgansExpression(ISimulationSubject simulationSubject, string moleculeName)
        {
            var organism = simulationSubject.Organism;

            organism.NonGITissueContainers.Each(x => AddTissueParameters(x, moleculeName));
            organism.GITissueContainers.Each(x => AddTissueParameters(x, moleculeName));
        }
 protected override void Context()
 {
     base.Context();
     _selectedSubject  = A.Fake <ISimulationSubject>();
     _commandCollector = A.Fake <ICommandCollector>();
     A.CallTo(() => _simulationSubjectConfigurationPresenter.SelectedSubject).Returns(_selectedSubject);
 }
Пример #3
0
        public Simulation CreateFrom(ISimulationSubject simulationSubject, IReadOnlyList <Compound> compounds, ModelProperties modelProperties, Simulation originalSimulation = null)
        {
            var simulation = createSimulation(simulationSubject.GetType());

            //update the used building block in the simulation
            if (originalSimulation != null)
            {
                originalSimulation.UsedBuildingBlocks.Each(simulation.AddUsedBuildingBlock);
            }

            _simulationBuildingBlockUpdater.UpdateUsedBuildingBlockInSimulationFromTemplate(simulation, simulationSubject, PKSimBuildingBlockType.SimulationSubject);
            _simulationBuildingBlockUpdater.UpdateMultipleUsedBuildingBlockInSimulationFromTemplate(simulation, compounds, PKSimBuildingBlockType.Compound);

            //set basic properties
            if (originalSimulation != null)
            {
                simulation.UpdateFromOriginalSimulation(originalSimulation);
                simulation.Properties = originalSimulation.Properties;
            }

            //last but not least, update model properties to match new definition (this should be done last as UpdateFromOriginalSimulation resets the model properties)
            simulation.ModelProperties = modelProperties;
            updateCompoundProperties(simulation);

            return(simulation);
        }
Пример #4
0
        public ExpressionProfile SelectExpressionProfile <TMolecule>(ISimulationSubject simulationSubject) where TMolecule : IndividualMolecule
        {
            _moleculeType                  = typeof(TMolecule);
            _simulationSubject             = simulationSubject;
            _createExpressionProfileAction = () =>
            {
                _expressionProfileTask.AddForMoleculeToProject <TMolecule>();
                refreshExpressionProfilesForMolecule();
            };

            _loadExpressionProfileAsync = async() =>
            {
                await _expressionProfileTask.LoadSingleFromTemplateAsync();

                refreshExpressionProfilesForMolecule();
            };

            refreshExpressionProfilesForMolecule();

            var moleculeDisplay = _moleculePropertiesMapper.MoleculeDisplayFor <TMolecule>();

            _view.Caption         = PKSimConstants.UI.AddMolecule(moleculeDisplay);
            _view.ApplicationIcon = _moleculePropertiesMapper.MoleculeIconFor <TMolecule>();
            _expressionProfileSelectionDTO.AllExistingMolecules = simulationSubject.AllMolecules().AllNames();
            _view.BindTo(_expressionProfileSelectionDTO);
            _view.Display();
            if (_view.Canceled)
            {
                return(null);
            }

            return(_expressionProfileSelectionDTO.ExpressionProfile);
        }
Пример #5
0
        public override void Execute(IExecutionContext context)
        {
            Description = PKSimConstants.Command.SetProteinTissueLocationDescription(_protein.Localization.ToString(), _localization.ToString());
            var setLocationCommand = new SetExpressionLocalizationInProteinCommand(_protein, _localization, _simulationSubject, context).Run(context);

            Add(setLocationCommand);

            if (_localization.Is(InBloodCells))
            {
                AddRange(updateBloodCellsExpressionParameters(context));
            }

            if (_localization.Is(InVascularEndothelium))
            {
                AddRange(updateVascularEndotheliumExpressionParameters(context));
            }

            if (_localization.Is(InTissue))
            {
                AddRange(updateTissueExpressionParameters(context));
            }

            var expressionProfileUpdater = context.Resolve <IExpressionProfileUpdater>();

            expressionProfileUpdater.SynchronizeAllSimulationSubjectsWithExpressionProfile(_simulationSubject);

            _protein           = null;
            _simulationSubject = null;


            //update properties from first command
            this.UpdatePropertiesFrom(setLocationCommand);
        }
Пример #6
0
        private ITransporterExpressionContainer addTransporterExpressionForContainer(ISimulationSubject simulationSubject, IndividualTransporter transporter, IContainer container, string groupeName, TransporterContainerTemplate transportTemplate)
        {
            var containerExpression = base.AddContainerExpression(simulationSubject, transporter, container, groupeName);

            containerExpression.UpdatePropertiesFrom(transportTemplate);
            return(containerExpression);
        }
Пример #7
0
        private void updateMoleculeParameters(IndividualMolecule sourceMolecule, ISimulationSubject sourceSimulationSubject, IndividualMolecule targetMolecule, ISimulationSubject targetSimulationSubject, bool updateParameterOriginId)
        {
            var allTargetMoleculeParameters = allMoleculeParametersFor(targetSimulationSubject, targetMolecule);
            var allSourceMoleculeParameters = allMoleculeParametersFor(sourceSimulationSubject, sourceMolecule);

            _parameterSetUpdater.UpdateValues(allSourceMoleculeParameters, allTargetMoleculeParameters, updateParameterOriginId);
        }
Пример #8
0
        public static Simulation CreateSimulationWith(ISimulationSubject simulationSubject, Compound compound, Protocol protocol, bool allowAging = false, Formulation formulation = null)
        {
            var simulation = CreateModelLessSimulationWith(simulationSubject, compound, protocol, allowAging, formulation);

            AddModelToSimulation(simulation);
            return(simulation);
        }
        public IndividualTransporter CreateFor(ISimulationSubject simulationSubject, string moleculeName, TransportType transporterType)
        {
            var transporter = CreateMolecule(moleculeName);

            if (HasAgeParameter(simulationSubject))
            {
                AddOntogenyParameterTo(transporter);
            }

            //default transporter type
            transporter.TransportType = transporterType;

            //default transport direction
            addGlobalExpression(transporter, BLOOD_CELLS, DefaultBloodCellsDirectionFor(transporterType), RelExpParam(REL_EXP_BLOOD_CELLS));

            //Special direction for vascular endothelium that is independent from the default direction choice
            addGlobalExpression(transporter, VASCULAR_ENDOTHELIUM, DefaultVascularEndotheliumDirectionFor(transporterType),
                                RelExpParam(REL_EXP_VASCULAR_ENDOTHELIUM));

            addVascularSystemInitialConcentration(simulationSubject, transporter);
            addTissueOrgansExpression(simulationSubject, transporter);
            addMucosaExpression(simulationSubject, transporter);

            simulationSubject.AddMolecule(transporter);

            _individualPathWithRootExpander.AddRootToPathIn(simulationSubject, moleculeName);

            return(transporter);
        }
Пример #10
0
 public static Simulation CreateModelLessSimulationWith(ISimulationSubject simulationSubject,
                                                        IReadOnlyList <Compound> compounds,
                                                        IReadOnlyList <Protocol> protocols,
                                                        bool allowAging = false, Formulation formulation = null)
 {
     return(CreateModelLessSimulationWith(simulationSubject, compounds, protocols, CreateDefaultModelPropertiesFor(simulationSubject), allowAging, formulation));
 }
Пример #11
0
        public static Simulation CreateSimulationWith(ISimulationSubject simulationSubject, Compound compound, Protocol protocol, string modelName, Formulation formulation = null)
        {
            var simulation = createModelLessSimulationWith(simulationSubject, compound, protocol, modelName, formulation);

            AddModelToSimulation(simulation);
            return(simulation);
        }
Пример #12
0
        public IndividualTransporterDTO MapFrom(IndividualTransporter transporter, ISimulationSubject simulationSubject)
        {
            var dto = new IndividualTransporterDTO(transporter);

            UpdateExpressionParameters(dto, simulationSubject);
            return(dto);
        }
Пример #13
0
        protected override async Task Context()
        {
            await base.Context();

            _snapshot = await sut.MapToSnapshot(_compoundProperties, _project);

            // Adds an incorrect compound process selection
            _snapshot.Processes = new List <CompoundProcessSelection>(_snapshot.Processes)
            {
                new CompoundProcessSelection()
            }.ToArray();
            _simulation        = A.Fake <Simulation>();
            _simulationSubject = A.Fake <ISimulationSubject>();
            A.CallTo(() => _simulationSubject.MoleculeByName("CYP3A4")).Returns(new IndividualEnzyme {
                Name = "CYP3A4"
            });
            A.CallTo(() => _simulation.BuildingBlock <ISimulationSubject>()).Returns(_simulationSubject);
            var newModelCompoundProperties = new Model.CompoundProperties {
                Compound = _compoundProperties.Compound
            };

            _compoundProperties.CompoundGroupSelections.Each(newModelCompoundProperties.AddCompoundGroupSelection);

            A.CallTo(() => _simulation.CompoundPropertiesFor(_snapshot.Name)).Returns(newModelCompoundProperties);
            _context = new CompoundPropertiesContext(_project, _simulation);
        }
Пример #14
0
 public void SetDefaultSettingsForTransporter(ISimulationSubject simulationSubject, IndividualTransporter transporter, TransportType transportType)
 {
     foreach (var transporterContainer in simulationSubject.AllMoleculeContainersFor <TransporterExpressionContainer>(transporter))
     {
         updateTransporterContainerFromTemplate(transporterContainer, null, transportType);
         updateFractionExpressedApical(transporterContainer, transportType);
     }
 }
 private void addMucosaExpression(ISimulationSubject simulationSubject, IndividualTransporter transporter)
 {
     foreach (var organ in simulationSubject.Organism.OrgansByName(CoreConstants.Organ.SMALL_INTESTINE, CoreConstants.Organ.LARGE_INTESTINE))
     {
         var organMucosa = organ.Compartment(MUCOSA);
         organMucosa.GetChildren <Compartment>().Each(x => addOrganWithLumenParameters(x, transporter));
     }
 }
Пример #16
0
 protected void AddMucosaExpression(ISimulationSubject simulationSubject, string moleculeName)
 {
     foreach (var organ in simulationSubject.Organism.OrgansByName(CoreConstants.Organ.SMALL_INTESTINE, CoreConstants.Organ.LARGE_INTESTINE))
     {
         var organMucosa = organ.Container(CoreConstants.Compartment.MUCOSA);
         organMucosa.GetChildren <Compartment>().Each(x => AddTissueParameters(x, moleculeName));
     }
 }
Пример #17
0
        public QueryExpressionSettings MapFrom(IndividualMolecule molecule, ISimulationSubject simulationSubject, string moleculeName)
        {
            var expressionContainer =
                new List <ExpressionContainerInfo>(simulationSubject.AllExpressionParametersFor(molecule).KeyValues
                                                   .Select(x => mapFrom(x.Key, x.Value)));

            return(new QueryExpressionSettings(expressionContainer, molecule.QueryConfiguration, moleculeName));
        }
 public void AddRootToPathIn(ISimulationSubject simulationSubject, string moleculeName)
 {
     _topContainers = new List <string>(_defaultTopContainer)
     {
         moleculeName
     };
     simulationSubject.AcceptVisitor(this);
 }
Пример #19
0
        protected void AddLumenExpressions(ISimulationSubject simulationSubject, TMolecule protein)
        {
            var lumen = simulationSubject.Organism.Organ(CoreConstants.Organ.Lumen);

            foreach (var segment in lumen.Compartments.Where(c => c.Visible))
            {
                var container = addContainerExpression(protein, lumen, CoreConstants.ContainerName.LumenSegmentNameFor(segment.Name), CoreConstants.Groups.GI_LUMEN);
                container.ContainerName = segment.Name;
            }
        }
Пример #20
0
        public void SynchronizeAllSimulationSubjectsWithExpressionProfile(ISimulationSubject internalSimulationSubject)
        {
            var expressionProfile = internalSimulationSubject.OwnedBy as ExpressionProfile;

            if (expressionProfile == null)
            {
                return;
            }
            SynchronizeAllSimulationSubjectsWithExpressionProfile(expressionProfile);
        }
 public NormalizeRelativeExpressionCommand(IndividualMolecule molecule, ISimulationSubject simulationSubject, IExecutionContext context)
 {
     _molecule          = molecule;
     _simulationSubject = simulationSubject;
     CommandType        = PKSimConstants.Command.CommandTypeEdit;
     ObjectType         = context.TypeFor(molecule);
     _moleculeId        = molecule.Id;
     //This command is necessary to insure consistency but does not need to be seen
     Visible = false;
 }
Пример #22
0
 protected void AddMucosaExpression(ISimulationSubject simulationSubject, TMolecule molecule)
 {
     foreach (var organ in simulationSubject.Organism.OrgansByName(CoreConstants.Organ.SmallIntestine, CoreConstants.Organ.LargeIntestine))
     {
         var organMucosa = organ.Compartment(CoreConstants.Compartment.Mucosa);
         foreach (var compartment in organMucosa.GetChildren <Compartment>().Where(c => c.Visible))
         {
             AddContainerExpression(simulationSubject, molecule, compartment, CoreConstants.Groups.GI_MUCOSA);
         }
     }
 }
        private void addVascularSystemInitialConcentration(ISimulationSubject simulationSubject, IndividualTransporter transporter)
        {
            var organism = simulationSubject.Organism;

            organism.OrgansByType(OrganType.VascularSystem).Each(organ =>
            {
                addContainerExpression(organ.Container(BLOOD_CELLS), transporter, TransportDirectionId.None,
                                       InitialConcentrationParam(CoreConstants.Rate.INITIAL_CONCENTRATION_BLOOD_CELLS_TRANSPORTER)
                                       );
            });
        }
        public EditIndividualMoleculeExpressionInSimulationSubjectFromQueryCommand(IndividualMolecule molecule, QueryExpressionResults queryExpressionResults, ISimulationSubject simulationSubject)
        {
            _molecule = molecule;
            _queryExpressionResults = queryExpressionResults;
            _simulationSubject      = simulationSubject;
            CommandType             = PKSimConstants.Command.CommandTypeEdit;
            var containerName = string.IsNullOrEmpty(simulationSubject.Name) ? CoreConstants.ContainerName.NameTemplate : simulationSubject.Name;

            Description         = PKSimConstants.Command.AddEntityToContainer(ObjectType, molecule.Name, PKSimConstants.ObjectTypes.Individual, containerName);
            ExtendedDescription = queryExpressionResults.Description;
        }
Пример #25
0
        protected void AddLumenExpression(ISimulationSubject simulationSubject, string moleculeName)
        {
            var lumen = simulationSubject.Organism.Organ(CoreConstants.Organ.LUMEN);

            //Only visible compartments as we do not want to create RelExp for example in Feces
            foreach (var segment in lumen.Compartments.Where(x => x.Visible))
            {
                AddContainerExpression(segment, moleculeName, RelExpParam(REL_EXP),
                                       InitialConcentrationParam(CoreConstants.Rate.INITIAL_CONCENTRATION_LUMEN));
            }
        }
Пример #26
0
 protected override void Context()
 {
     base.Context();
     _templatePresenter  = A.Fake <ITemplatePresenter>();
     _templateIndividual = new Individual().WithName("Existing");
     _existingIndiviudal = new Individual().WithName("ExiStIng");
     A.CallTo(() => _applicationController.Start <ITemplatePresenter>()).Returns(_templatePresenter);
     A.CallTo(_templatePresenter).WithReturnType <ISimulationSubject>().Returns(_templateIndividual);
     A.CallTo(() => _project.All(_templateIndividual.BuildingBlockType)).Returns(new[] { _existingIndiviudal });
     A.CallTo(() => _entityTask.Rename(_templateIndividual)).Returns(new PKSimEmptyCommand());
 }
Пример #27
0
        protected override void Context()
        {
            base.Context();
            _templatePresenter  = A.Fake <ITemplatePresenter>();
            _templateIndividual = new Individual();
            A.CallTo(() => _applicationController.Start <ITemplatePresenter>()).Returns(_templatePresenter);
            A.CallTo(_templatePresenter).WithReturnType <IReadOnlyList <ISimulationSubject> >().Returns(new[] { _templateIndividual });

            A.CallTo(() => _executionContext.AddToHistory((A <IPKSimCommand> ._)))
            .Invokes(x => _command = x.GetArgument <IPKSimCommand>(0));
        }
        public IndividualProteinDTO MapFrom(IndividualProtein protein, ISimulationSubject simulationSubject)
        {
            var dto = new IndividualProteinDTO(protein);

            simulationSubject.AllMoleculeContainersFor(protein)
            .SelectMany(x => x.AllParameters())
            .Union(protein.AllGlobalExpressionParameters)
            .MapAllUsing(_expressionContainerMapper)
            .Each(dto.AddExpressionParameter);

            return(dto);
        }
Пример #29
0
        private IndividualMolecule createMoleculeFrom(Molecule molecule, ISimulationSubject simulationSubject)
        {
            var moleculeFactory    = factoryFor(molecule);
            var transporterFactory = moleculeFactory as IIndividualTransporterFactory;

            if (transporterFactory == null || molecule.TransportType == null)
            {
                return(moleculeFactory.CreateFor(simulationSubject));
            }

            return(transporterFactory.CreateFor(simulationSubject, molecule.TransportType.Value));
        }
Пример #30
0
        public void SynchroniseSimulationSubjectWithExpressionProfile(ISimulationSubject simulationSubject, ExpressionProfile expressionProfile)
        {
            _lazyLoadTask.Load(simulationSubject);
            var moleculeInIndividual = simulationSubject.MoleculeByName(expressionProfile.MoleculeName);

            var(sourceMolecule, sourceIndividual) = expressionProfile;
            // ExpressionProfile => SimulationSubject, we want to make sure that the parameters in simulation subject are linked to their expression profile origin parameters
            synchronizeExpressionProfiles(sourceMolecule, sourceIndividual, moleculeInIndividual, simulationSubject, updateParameterOriginId: true);

            //Once the synchronization was performed, apply changes to simulation subject molecules based on disease state
            updateMoleculeParametersForDiseaseState(simulationSubject, moleculeInIndividual);
        }