Beispiel #1
0
        public override void Execute(IExecutionContext context)
        {
            ObjectType = context.TypeFor(_molecule);
            var containerName = string.IsNullOrEmpty(_simulationSubject.Name) ? CoreConstants.ContainerName.NameTemplate : _simulationSubject.Name;

            Description = PKSimConstants.Command.AddEntityToContainer(ObjectType, _molecule.Name, context.TypeFor(_simulationSubject), containerName);

            //First add the protein expression to the individual so that undo will be available
            Add(AddMoleculeToSimulationSubjectCommand(_molecule, _simulationSubject, context));

            //Then update the new expression values
            foreach (var expressionResult in _queryExpressionResults.ExpressionResults)
            {
                Add(new SetRelativeExpressionCommand(_molecule.GetRelativeExpressionParameterFor(expressionResult.ContainerName), expressionResult.RelativeExpression));
            }

            Add(new NormalizeRelativeExpressionCommand(_molecule, context));

            //update properties from first command
            this.UpdatePropertiesFrom(All().FirstOrDefault());

            base.Execute(context);

            //clear references
            _molecule = null;
            _queryExpressionResults = null;
            _simulationSubject      = null;
        }
Beispiel #2
0
 protected AddMoleculeExpressionsFromQueryToSimulationSubjectCommand(IndividualMolecule molecule, QueryExpressionResults queryExpressionResults, TSimulationSubject simulationSubject)
 {
     _molecule = molecule;
     _queryExpressionResults = queryExpressionResults;
     _simulationSubject      = simulationSubject;
     CommandType             = PKSimConstants.Command.CommandTypeAdd;
     ExtendedDescription     = queryExpressionResults.Description;
 }
Beispiel #3
0
 protected override void Context()
 {
     base.Context();
     _expressionProfile = DomainHelperForSpecs.CreateExpressionProfile <IndividualEnzyme>();
     _querySettings     = A.Fake <QueryExpressionSettings>();
     _queryResults      = A.Fake <QueryExpressionResults>();
     A.CallTo(() => _querySettingsMapper.MapFrom(_expressionProfile.Molecule, _expressionProfile.Individual, "NAME")).Returns(_querySettings);
     A.CallTo(() => _proteinExpressionPresenter.Start()).Returns(true);
     A.CallTo(() => _proteinExpressionPresenter.GetQueryResults()).Returns(_queryResults);
 }
        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;
        }
 protected override void Context()
 {
     base.Context();
     _clonedProtein = A.Fake <IndividualMolecule>();
     A.CallTo(() => _clonedProtein.AllExpressionsContainers()).Returns(_molecule.AllExpressionsContainers());
     _individual.AddMolecule(_molecule);
     _querySettings = A.Fake <QueryExpressionSettings>();
     _queryResults  = A.Fake <QueryExpressionResults>();
     A.CallTo(() => _executionContext.Clone(_molecule)).Returns(_clonedProtein);
     A.CallTo(() => _querySettingsMapper.MapFrom(_molecule)).Returns(_querySettings);
     A.CallTo(() => _proteinExpressionPresenter.Start()).Returns(true);
     A.CallTo(() => _proteinExpressionPresenter.GetQueryResults()).Returns(_queryResults);
 }
        protected override void Context()
        {
            _context = A.Fake <IExecutionContext>();
            var expressionProfile = DomainHelperForSpecs.CreateExpressionProfile <IndividualEnzyme>();

            (_molecule, _)     = expressionProfile;
            _protein           = _molecule.DowncastTo <IndividualProtein>();
            _result            = new QueryExpressionResults(_expressionResults);
            _simulationSubject = A.Fake <ISimulationSubject>();
            sut = new EditIndividualMoleculeExpressionInSimulationSubjectFromQueryCommand(_molecule, _result, _simulationSubject);

            A.CallTo(() => _simulationSubject.AllExpressionParametersFor(_molecule)).Returns(_allExpressionParameters);
        }
 protected override void Context()
 {
     base.Context();
     _querySettings            = A.Fake <QueryExpressionSettings>();
     _queryResults             = new QueryExpressionResults(new List <ExpressionResult>());
     _queryResults.ProteinName = _moleculeName;
     A.CallTo(() => _querySettingsMapper.MapFrom(_molecule)).Returns(_querySettings);
     A.CallTo(() => _proteinExpressionDbPathManager.HasDatabaseFor(_individual.Species)).Returns(true);
     A.CallTo(() => _proteinExpressionPresenter.Start()).Returns(true);
     A.CallTo(() => _proteinExpressionPresenter.GetQueryResults()).Returns(_queryResults);
     _queryResults.QueryConfiguration = _queryConfiguration;
     A.CallTo(() => _containerTask.CreateUniqueName(_individual, _queryResults.ProteinName, true)).Returns(_renamedName);
     A.CallTo(() => _executionContext.BuildingBlockContaining(_molecule)).Returns(_individual);
 }
Beispiel #8
0
        protected override void Context()
        {
            base.Context();
            sut.IsEditMode = true;
            _expressionProfileDTO.MoleculeName = "MOLECULE";
            _result = new QueryExpressionResults(new ExpressionResult[] { })
            {
                ProteinName = "NEW_NAME"
            };

            A.CallTo(() => _expressionProfileProteinDatabaseTask.CanQueryProteinExpressionsFor(_expressionProfile)).Returns(true);
            A.CallTo(() => _expressionProfileProteinDatabaseTask.QueryDatabase(_expressionProfile, _expressionProfileDTO.MoleculeName))
            .Returns(_result);
        }
Beispiel #9
0
 protected override void Context()
 {
     base.Context();
     sut.IsEditMode = false;
     _command       = A.Fake <IPKSimCommand>();
     _result        = new QueryExpressionResults(new ExpressionResult[] { })
     {
         ProteinName = "NEW_NAME"
     };
     sut.Edit(_expressionProfile);
     _expressionProfileDTO.MoleculeName = "MOLECULE";
     A.CallTo(() => _expressionProfileProteinDatabaseTask.CanQueryProteinExpressionsFor(_expressionProfile)).Returns(true);
     A.CallTo(() => _expressionProfileProteinDatabaseTask.QueryDatabase(_expressionProfile, _expressionProfileDTO.MoleculeName))
     .Returns(_result);
     A.CallTo(() => _expressionProfileUpdater.UpdateExpressionFromQuery(_expressionProfile, _result)).Returns(_command);
 }
        public override void Execute(IExecutionContext context)
        {
            ObjectType = context.TypeFor(_molecule);
            var containerName = string.IsNullOrEmpty(_simulationSubject.Name) ? CoreConstants.ContainerName.NameTemplate : _simulationSubject.Name;

            Description = PKSimConstants.Command.AddEntityToContainer(ObjectType, _molecule.Name, context.TypeFor(_simulationSubject), containerName);


            var allExpressionParameters = _simulationSubject.AllExpressionParametersFor(_molecule);

            //Then update only the expression values that have changed
            foreach (var expressionResult in _queryExpressionResults.ExpressionResults)
            {
                var expressionParameter = allExpressionParameters[expressionResult.ContainerName];
                if (expressionParameter.Value == expressionResult.RelativeExpression)
                {
                    continue;
                }

                Add(new SetExpressionProfileValueCommand(expressionParameter, expressionResult.RelativeExpression, updateSimulationSubjects: false));
            }

            Add(new NormalizeRelativeExpressionCommand(_molecule, _simulationSubject, context));


            //update properties from first command
            this.UpdatePropertiesFrom(All().FirstOrDefault());

            //Execute the command first to update all relative expressions
            base.Execute(context);

            //special treatment for protein where we have to update localization after the fact
            if (_molecule is IndividualProtein protein)
            {
                updateLocalizationForProtein(protein, context);
            }

            // update depending object
            var updateTask = context.Resolve <IExpressionProfileUpdater>();

            updateTask.SynchronizeAllSimulationSubjectsWithExpressionProfile(_simulationSubject);

            //clear references
            _molecule = null;
            _queryExpressionResults = null;
            _simulationSubject      = null;
        }
        public QueryExpressionResults GetQueryResults()
        {
            var expResults = new List <ExpressionResult>();

            string selectedUnit = PresenterAt(ExpressionItems.Transfer).GetSelectedUnit();

            SelectTransferData(selectedUnit, selectedUnit);
            DataTable transferData = PresenterAt(ExpressionItems.Transfer).GetData();

            foreach (DataRow row in transferData.Rows)
            {
                string containerName = row[ColumnNamesOfTransferTable.Container.ToString()].ToString();

                double expRelValue;
                if (row[ColumnNamesOfTransferTable.RelativeExpressionNew.ToString()] == DBNull.Value)
                {
                    expRelValue = 0;
                }
                else
                {
                    expRelValue = (double)row[ColumnNamesOfTransferTable.RelativeExpressionNew.ToString()];
                }

                var expResult = new ExpressionResult {
                    ContainerName = containerName, RelativeExpression = expRelValue
                };
                expResults.Add(expResult);
            }

            _queryExpressionResults = new QueryExpressionResults(expResults)
            {
                ProteinName        = _proteinName,
                SelectedUnit       = selectedUnit,
                QueryConfiguration = getQueryConfiguration(),
                Description        = getQueryDescription()
            };
            return(_queryExpressionResults);
        }
Beispiel #12
0
 public EditIndividualMoleculeExpressionInIndividualFromQueryCommand(IndividualMolecule originalMolecule, IndividualMolecule editedMolecule, QueryExpressionResults queryExpressionResults,
                                                                     Individual individual) : base(originalMolecule, editedMolecule, queryExpressionResults, individual)
 {
 }
Beispiel #13
0
 public ICommand EditMolecule(IndividualMolecule moleculeToEdit, IndividualMolecule editedMolecule, QueryExpressionResults queryResults, Population population)
 {
     return(new EditIndividualMoleculeExpressionInPopulationFromQueryCommand(moleculeToEdit, editedMolecule, queryResults, population).Run(_executionContext));
 }
Beispiel #14
0
 public EditIndividualMoleculeExpressionInPopulationFromQueryCommand(IndividualMolecule originalMolecule, IndividualMolecule editedMolecule, QueryExpressionResults queryExpressionResults,
                                                                     Population population) : base(originalMolecule, editedMolecule, queryExpressionResults, population)
 {
 }
 public AddMoleculeExpressionsFromQueryToPopulationCommand(IndividualMolecule molecule, QueryExpressionResults queryExpressionResults, Population population)
     : base(molecule, queryExpressionResults, population)
 {
 }
Beispiel #16
0
        public ICommand AddMoleculeTo(IndividualMolecule molecule, Population population, QueryExpressionResults queryExpressionResults)
        {
            var baseCommand = new AddMoleculeExpressionsFromQueryToPopulationCommand(molecule, queryExpressionResults, population);

            return(addMoleculeToPopulation(molecule, population, baseCommand));
        }
Beispiel #17
0
 public ICommand UpdateExpressionFromQuery(ExpressionProfile expressionProfile, QueryExpressionResults queryResults)
 {
     var(molecule, individual)   = expressionProfile;
     molecule.QueryConfiguration = queryResults.QueryConfiguration;
     return(new EditIndividualMoleculeExpressionInSimulationSubjectFromQueryCommand(molecule, queryResults, individual)
            .Run(_executionContext));
 }
Beispiel #18
0
        private ICommand addMoleculeTo <TMolecule>(TMolecule molecule, TSimulationSubject simulationSubject, QueryExpressionResults queryExpressionResults) where TMolecule : IndividualMolecule
        {
            var command = _simulationSubjectExpressionTask.AddMoleculeTo(molecule, simulationSubject, queryExpressionResults);

            setDefaultFor(molecule, simulationSubject, queryExpressionResults.ProteinName);
            return(command);
        }
Beispiel #19
0
 private ICommand editMolecule <TMolecule>(TMolecule moleculeToEdit, TMolecule editedMolecule, QueryExpressionResults queryResults, TSimulationSubject simulationSubject)
     where TMolecule : IndividualMolecule
 {
     return(_simulationSubjectExpressionTask.EditMolecule(moleculeToEdit, editedMolecule, queryResults, simulationSubject));
 }
Beispiel #20
0
 protected override void Because()
 {
     _result = sut.QueryDatabase(_expressionProfile, "NAME");
 }
Beispiel #21
0
 public AddMoleculeExpressionsFromQueryToIndividualCommand(IndividualMolecule molecule, QueryExpressionResults queryExpressionResults, Individual individual) :
     base(molecule, queryExpressionResults, individual)
 {
 }
 public ICommand AddMoleculeTo(IndividualMolecule molecule, Individual individual, QueryExpressionResults queryExpressionResults)
 {
     return(new AddMoleculeExpressionsFromQueryToIndividualCommand(molecule, queryExpressionResults, individual).Run(_executionContext));
 }