private ITreeNode addMoleculeBuilder(IMoleculeBuilder moleculeBuilder, IMoleculeBuildingBlock moleculeBuildingBlock)
        {
            var moleculeBuildingBlockNode = _view.NodeById(moleculeBuildingBlock.Id);

            return(_view.AddNode(_treeNodeFactory.CreateFor(moleculeBuilder)
                                 .Under(moleculeBuildingBlockNode)));
        }
 protected override void Context()
 {
     base.Context();
     _newAlias                     = "new_Name";
     _changedObject.Name           = "Name really old";
     _changedName                  = _changedObject.Name;
     _oldAlias                     = "Name_really_old";
     _theFormula                   = new ExplicitFormula(String.Format("k_{0}*{0}", _oldAlias));
     _formulaUsablePathNotToChange = new FormulaUsablePath(new[] { ObjectPath.PARENT_CONTAINER, "BLA", String.Format("k_{0}", _oldAlias) })
     {
         Alias = String.Format("k_{0}", _oldAlias)
     };
     _theFormula.AddObjectPath(_formulaUsablePathNotToChange);
     _formulaUsablePathToChange = new FormulaUsablePath(new[] { ObjectPath.PARENT_CONTAINER, _changedName })
     {
         Alias = _oldAlias
     };
     _theFormula.AddObjectPath(_formulaUsablePathToChange);
     _theFormula.Name = "F1";
     A.CallTo(() => _aliasCreator.CreateAliasFrom(_changedName)).Returns(_oldAlias);
     A.CallTo(() => _aliasCreator.CreateAliasFrom(_newName)).Returns(_newAlias);
     A.CallTo(() => _context.Get <IObjectBase>(A <string> ._)).Returns(_theFormula);
     _moleculeBuildingBlock = new MoleculeBuildingBlock().WithName("M").WithId("M");
     _moleculeBuildingBlock.AddFormula(_theFormula);
 }
Esempio n. 3
0
        public override void GlobalContext()
        {
            base.GlobalContext();
            _simulation            = DomainFactoryForSpecs.CreateDefaultSimulation();
            _moleculeBuildingBlock = new MoleculeBuildingBlock();
            var compoundProperties = _simulation.CompoundPropertiesList.First();

            _compoundName = compoundProperties.Compound.Name;
            _moleculeBuildingBlock.Add(new MoleculeBuilder {
                Name = _compoundName, QuantityType = QuantityType.Drug
            });
            _moleculeBuildingBlock.Add(new MoleculeBuilder {
                Name = "Enzyme", QuantityType = QuantityType.Enzyme
            });
            _moleculeBuildingBlock.Add(new MoleculeBuilder {
                Name = "Metabolite", QuantityType = QuantityType.Metabolite
            });
            _moleculeBuildingBlock.Add(new MoleculeBuilder {
                Name = "Protein", QuantityType = QuantityType.OtherProtein
            });
            var specificBindingSelection = new ProcessSelection {
                CompoundName = _compoundName, MoleculeName = "Protein", ProcessName = "Specific Binding"
            };
            var metabolizationSelection = new EnzymaticProcessSelection {
                CompoundName = _compoundName, MoleculeName = "Protein", ProcessName = "Metabolism"
            };

            _complexProductName    = specificBindingSelection.ProductName(CoreConstants.Molecule.Complex);
            _metaboliteProductName = specificBindingSelection.ProductName(CoreConstants.Molecule.Metabolite);
            _moleculeBuildingBlock.Add(new MoleculeBuilder {
                Name = _complexProductName, QuantityType = QuantityType.Complex
            });
            compoundProperties.Processes.SpecificBindingSelection.AddPartialProcessSelection(specificBindingSelection);
            compoundProperties.Processes.MetabolizationSelection.AddPartialProcessSelection(metabolizationSelection);
        }
Esempio n. 4
0
        protected override void Context()
        {
            _containerTask        = A.Fake <IContainerTask>();
            _objectBaseFactory    = A.Fake <IObjectBaseFactory>();
            _projectRetriever     = A.Fake <IMoBiProjectRetriever>();
            _eventPublisher       = A.Fake <IEventPublisher>();
            _cloneManagerForModel = A.Fake <ICloneManagerForModel>();
            _formulaTask          = A.Fake <IFormulaTask>();

            sut = new PassiveTransportConverter(_objectBaseFactory, _projectRetriever, _containerTask, _eventPublisher, _cloneManagerForModel, _formulaTask);

            A.CallTo(() => _containerTask.CreateUniqueName(A <IEnumerable <IWithName> > ._, A <string> ._, true))
            .ReturnsLazily(x => x.Arguments[1].ToString());

            _passiveTransportKinetic      = new ExplicitFormula("1+2");
            _moleculeWithPassiveTransport = new MoleculeBuilder().WithName("MOLECULE");
            _passiveTransport             = new TransportBuilder().WithName("PASSIVE TRANSPORT").WithFormula(_passiveTransportKinetic);
            _moleculeWithPassiveTransport.Add(_passiveTransport);
            _passiveTransports = new PassiveTransportBuildingBlock();
            _molecules         = new MoleculeBuildingBlock {
                _moleculeWithPassiveTransport
            }.WithName("MBB");
            _project = new MoBiProject();
            A.CallTo(() => _projectRetriever.Current).Returns(_project);
            A.CallTo(() => _eventPublisher.PublishEvent(A <ShowNotificationsEvent> ._))
            .Invokes(x => _showNotificationEvent = x.GetArgument <ShowNotificationsEvent>(0));
        }
Esempio n. 5
0
        protected override void Context()
        {
            _view                = A.Fake <ISelectEventAssignmentTargetView>();
            _context             = A.Fake <IMoBiContext>();
            _objectBaseDTOMapper = A.Fake <IObjectBaseToObjectBaseDTOMapper>();
            _containerDTOMapper  = A.Fake <IContainerToContainerDTOMapper>();
            _reactionMapper      = A.Fake <IReactionBuilderToDummyReactionDTOMapper>();
            _moleculeMapper      = A.Fake <IMoleculeBuilderToDummyMoleculeDTOMapper>();
            _objectPathFactory   = A.Fake <IObjectPathFactory>();
            _parameterMapper     = A.Fake <IParameterToDummyParameterDTOMapper>();
            _dimensionRetriever  = A.Fake <IReactionDimensionRetriever>();
            sut = new SelectEventAssingmentTargetPresenter(_view, _context, _objectBaseDTOMapper, _containerDTOMapper, _reactionMapper,
                                                           _moleculeMapper, _objectPathFactory, _parameterMapper, _dimensionRetriever);

            _mobiProject     = A.Fake <IMoBiProject>();
            _rootContainer   = new Container();
            _moleculeBuilder = new MoleculeBuilder().WithName("M");
            _reaction        = new ReactionBuilder().WithName("R");
            _localParameter  = new Parameter().WithMode(ParameterBuildMode.Local).WithName("LocalParam");
            _globalParameter = new Parameter().WithMode(ParameterBuildMode.Global).WithName("GlobalParam");
            _reaction.Add(_localParameter);
            _reaction.Add(_globalParameter);
            _reactionBB = new MoBiReactionBuildingBlock()
            {
                _reaction
            };
            _moleculeBB = new MoleculeBuildingBlock {
                _moleculeBuilder
            };
            A.CallTo(() => _mobiProject.ReactionBlockCollection).Returns(new [] { _reactionBB });
            A.CallTo(() => _mobiProject.MoleculeBlockCollection).Returns(new [] { _moleculeBB });
            sut.Init(_mobiProject, _rootContainer);
        }
Esempio n. 6
0
        public IObserverBuildingBlock AllObserversFor(IMoleculeBuildingBlock moleculeBuildingBlock, Simulation simulation)
        {
            var observerBuildingBlock = _objectBaseFactory.Create <IObserverBuildingBlock>().WithName(simulation.Name);

            addStandardObserversTo(simulation, observerBuildingBlock, moleculeBuildingBlock);

            //now add dynamic observers for molecules needing one
            createFractionExcretedToUrineObserver(simulation, observerBuildingBlock);
            createFractionOfDoseExcretedToBileObserver(simulation, observerBuildingBlock);
            createFractionOfDoseExcretedToFecesObserver(simulation, observerBuildingBlock);

            //add fraction observers for metabolite and complex
            createFractionOfDoseObserver(simulation, observerBuildingBlock);

            foreach (var compound in simulation.Compounds)
            {
                foreach (var specificBinding in simulation.CompoundPropertiesFor(compound).Processes.SpecificBindingSelection.AllEnabledProcesses())
                {
                    var complexName = specificBinding.ProductName(CoreConstants.Molecule.Complex);
                    var protein     = moleculeBuildingBlock[specificBinding.MoleculeName];
                    var complex     = moleculeBuildingBlock[complexName];

                    createReceptorOccupancyObserver(observerBuildingBlock, protein, complex);
                }
            }

            return(observerBuildingBlock);
        }
Esempio n. 7
0
        public void Visit(IMoleculeBuildingBlock moleculeBuildingBlock)
        {
            var command = synchronizeInParameters(moleculeBuildingBlock);

            if (!command.IsEmpty())
            {
                return;
            }

            var transporterMoleculeContainers = moleculeBuildingBlock.SelectMany(m => m.TransporterMoleculeContainerCollection).ToList();

            if (!transporterMoleculeContainers.Any())
            {
                return;
            }

            var parameterTransporterName = _parameter.ParentContainer.Name;
            var parameterMoleculeName    = _parameter.ParentContainer.ParentContainer?.Name;

            var transporterMoleculeContainer = findTransporterMoleculeContainerFor(transporterMoleculeContainers, parameterTransporterName, parameterMoleculeName);

            if (transporterMoleculeContainer == null)
            {
                return;
            }

            var buildingBlockParameter = transporterMoleculeContainer.Parameter(_parameter.Name);

            setSynchronizeCommand(buildingBlockParameter);
        }
Esempio n. 8
0
 protected override void Context()
 {
     base.Context();
     _moleculeBuildingBlock = new MoleculeBuildingBlock();
     _moleculeBuildingBlock.Add(new MoleculeBuilder().WithName("Drug"));
     _moleculeBuildingBlock.Add(new MoleculeBuilder().WithName("Transporter"));
 }
 /// <summary>
 ///    Adds event group to all model containers with defined criteria
 /// </summary>
 private void createEventGroupFrom(IEventGroupBuilder eventGroupBuilder, IMoleculeBuildingBlock molecules)
 {
     foreach (var sourceContainer in _sourceCriteriaTargetContainerCache[eventGroupBuilder.SourceCriteria])
     {
         createEventGroupInContainer(eventGroupBuilder, sourceContainer);
     }
 }
Esempio n. 10
0
 protected override void Context()
 {
     base.Context();
     _moleculeBuildingBlock = new MoleculeBuildingBlock();
     sut.Edit(_moleculeBuildingBlock);
     _moleculeBuilder = new MoleculeBuilder();
     _moleculeBuildingBlock.Add(_moleculeBuilder);
 }
 protected override void Context()
 {
     base.Context();
     _projectItem      = new MoleculeBuildingBlock();
     _editPresenter    = A.Fake <IEditMoleculeBuildingBlockPresenter>();
     _commandCollector = A.Fake <ICommandCollector>();
     A.CallTo(() => _container.Resolve <IEditMoleculeBuildingBlockPresenter>()).Returns(_editPresenter);
 }
Esempio n. 12
0
 protected override void Context()
 {
     base.Context();
     _moleculeBuildingBlock = A.Fake <IMoleculeBuildingBlock>();
     _moleculeBuilderToAdd  = new MoleculeBuilder();
     A.CallTo(() => _interactionTask.CorrectName(_moleculeBuilderToAdd, A <IEnumerable <string> > ._)).Returns(false);
     A.CallTo(() => _context.PublishEvent(A <AddedEvent <IMoleculeBuilder> > ._))
     .Invokes(x => _addEvent = x.GetArgument <AddedEvent <IMoleculeBuilder> >(0));
 }
 private void addMolecules(IMoleculeBuildingBlock moleculeBuilders, IList <DTOMoleculeSelection> dtos)
 {
     moleculeBuilders.Each(x => dtos.Add(new DTOMoleculeSelection
     {
         BuildingBlock   = moleculeBuilders.Name,
         Molecule        = x.Name,
         MoleculeBuilder = x
     }));
 }
Esempio n. 14
0
 protected override void Context()
 {
     sut = new ParameterResolver();
     _moleculeBuildingBlock = new MoleculeBuildingBlock();
     _spatialStructure      = new SpatialStructure {
         GlobalMoleculeDependentProperties = new Container()
     };
     _containerPath = new ObjectPath();
 }
 protected override void Context()
 {
     sut              = new FormulaUsageChecker();
     _formula         = new ExplicitFormula("1").WithName("Test Formula");
     _buildingBlock   = new MoleculeBuildingBlock();
     _moleculeBuilder = new MoleculeBuilder().WithName("Container");
     _moleculeBuilder.DefaultStartFormula = A.Fake <IFormula>();
     _buildingBlock.Add(_moleculeBuilder);
 }
Esempio n. 16
0
 protected override void Context()
 {
     base.Context();
     _moleculeBuildingBlock = new MoleculeBuildingBlock {
         Id = "1"
     };
     _moleculeBuildingBlock.Add(A.Fake <IMoleculeBuilder>().WithId("2"));
     _moleculeBuildingBlock.Add(A.Fake <IMoleculeBuilder>().WithId("3"));
 }
Esempio n. 17
0
        private StartValuesDTO createDto(string name, IMoleculeBuildingBlock moleculeBuildingBlock, IMoBiSpatialStructure spatialStructure)
        {
            var dto = new StartValuesDTO {
                Name = name, Molecules = moleculeBuildingBlock, SpatialStructrue = spatialStructure
            };

            dto.AddUsedNames(AppConstants.UnallowedNames);
            dto.AddUsedNames(_unallowedNames);
            return(dto);
        }
Esempio n. 18
0
        public void Visit(IMoleculeBuildingBlock moleculeBuildingBlock)
        {
            foreach (var moleculeBuilder in moleculeBuildingBlock.Where(x => !x.ContainsName(Constants.Parameters.CONCENTRATION)).ToList())
            {
                var concentrationParameter = _parameterFactory.CreateConcentrationParameter(moleculeBuildingBlock.FormulaCache);
                moleculeBuilder.AddParameter(concentrationParameter);
            }

            convertFormulaReferencingAeffIn(moleculeBuildingBlock);
        }
        public void TestComplexMoleculeBB()
        {
            MoleculeBuildingBlock x1 = _buildConfiguration.Molecules as MoleculeBuildingBlock;

            Assert.IsNotNull(x1);


            IMoleculeBuildingBlock x2 = SerializeAndDeserialize(x1);

            AssertForSpecs.AreEqualBuildingBlock(x2, x1);
        }
        public ITreeNode CreateFor(IMoleculeBuildingBlock moleculeBuildingBlock)
        {
            var moleculeBuildingBlockNode = createFor(moleculeBuildingBlock);

            foreach (var molecule in moleculeBuildingBlock)
            {
                var moleculeNode = CreateFor(molecule);
                moleculeBuildingBlockNode.AddChild(moleculeNode);
            }
            return(moleculeBuildingBlockNode);
        }
Esempio n. 21
0
        protected override void Context()
        {
            base.Context();
            _moleculeBuildingBlock = new MoleculeBuildingBlock {
                Id = "1"
            };
            _project = new MoBiProject();

            _project.AddBuildingBlock(new MoleculeStartValuesBuildingBlock {
                MoleculeBuildingBlockId = _moleculeBuildingBlock.Id, SpatialStructureId = ""
            });
        }
        protected override void Context()
        {
            base.Context();
            _moleculeNode = A.Fake <ITreeNode>();
            _moleculeBuildingBlockNode = A.Fake <ITreeNode>();
            _moleculeBuildingBlock     = A.Fake <IMoleculeBuildingBlock>().WithId("Id");
            _moleculeBuilder           = A.Fake <IMoleculeBuilder>();

            A.CallTo(() => _view.TreeView.NodeById(_moleculeBuildingBlock.Id)).Returns(_moleculeBuildingBlockNode);

            A.CallTo(() => _treeNodeFactory.CreateFor(_moleculeBuilder)).Returns(_moleculeNode);
        }
        protected override void Context()
        {
            base.Context();
            _moleculeBuilder       = A.Fake <IMoleculeBuilder>();
            _moleculeBuildingBlock = A.Fake <IMoleculeBuildingBlock>();
            var moleculeBuildingBlockNode = A.Fake <ITreeNode>();

            A.CallTo(() => moleculeBuildingBlockNode.TagAsObject).Returns(_moleculeBuildingBlock);
            _node            = A.Fake <ITreeNode>();
            _node.ParentNode = moleculeBuildingBlockNode;
            A.CallTo(() => _node.TagAsObject).Returns(_moleculeBuilder);
        }
Esempio n. 24
0
        protected override void Context()
        {
            base.Context();
            _returnedBuildingBlocks = new List <IBuildingBlock>();
            _childReactionBuilder   = new ReactionBuilder().WithName("Test").WithId("FindME");
            _reactionParameter      = new Parameter().WithName("Para").WithId("ReactionPara");
            _childReactionBuilder.AddParameter(_reactionParameter);
            _reactionBuildingBlock = new MoBiReactionBuildingBlock()
            {
                _childReactionBuilder
            };
            _allBuildingBlocks.Add(_reactionBuildingBlock);
            _moleculeBuilder   = new MoleculeBuilder();
            _moleculeParameter = new Parameter().WithName("para");
            _moleculeBuilder.AddParameter(_moleculeParameter);
            _moleculeBuildingBlock = new MoleculeBuildingBlock()
            {
                _moleculeBuilder
            };
            _allBuildingBlocks.Add(_moleculeBuildingBlock);
            _passiveTranportBuilder    = new TransportBuilder();
            _passiveTransportParameter = new Parameter().WithName("PTParameter");
            _passiveTranportBuilder.AddParameter(_passiveTransportParameter);
            _passiveTranportBuildingBlock = new PassiveTransportBuildingBlock()
            {
                _passiveTranportBuilder
            };
            _allBuildingBlocks.Add(_passiveTranportBuildingBlock);
            _applicationBuilder      = new ApplicationBuilder();
            _eventGroupBuildingBlock = new EventGroupBuildingBlock()
            {
                _applicationBuilder
            };
            _applicationBuilderParameter = new ApplicationBuilder().WithName("AppParameter");
            _applicationBuilder.Add(_applicationBuilderParameter);
            _allBuildingBlocks.Add(_eventGroupBuildingBlock);
            _parameter = new Parameter().WithName("Para");
            var container = new Container().WithName("Cont");

            container.Add(_parameter);
            _objectBaseFactory = A.Fake <IObjectBaseFactory>();
            _parameterFactory  = A.Fake <IParameterFactory>();
            A.CallTo(() => _objectBaseFactory.Create <IContainer>()).Returns(new Container());
            A.CallTo(() => _objectBaseFactory.Create <IMoBiSpatialStructure>()).Returns(new MoBiSpatialStructure());
            var diagramManagerFactory = A.Fake <IDiagramManagerFactory>();

            _spatialStructure = new MoBiSpatialStructureFactory(_objectBaseFactory, _parameterFactory, A.Fake <IIconRepository>(), diagramManagerFactory).Create() as IMoBiSpatialStructure;
            _spatialStructure.AddTopContainer(container);
            _allBuildingBlocks.Add(_spatialStructure);
            _formula = new ExplicitFormula();
            _moleculeBuildingBlock.AddFormula(_formula);
        }
Esempio n. 25
0
        private void updateForPKSimChanges(IMoleculeBuildingBlock moleculeBuildingBlock)
        {
            var calculatedSpecificIntestinalPermeabilityTranscellularFormula =
                moleculeBuildingBlock.FormulaCache.FindByName("PARAM_P_int_InVitro");

            if (calculatedSpecificIntestinalPermeabilityTranscellularFormula == null)
            {
                return;
            }
            var velocity = _dimensionFactory.Dimension(AppConstants.DimensionNames.VELOCITY);

            moleculeBuildingBlock.Each(mb => addCalculatedSpecificIntestinalPermeabilityTranscellularParameterTo(mb, calculatedSpecificIntestinalPermeabilityTranscellularFormula, velocity));
        }
Esempio n. 26
0
        protected override void Context()
        {
            base.Context();
            _moleculeBuildingBlock = A.Fake <IMoleculeBuildingBlock>();
            _moleculeBuilderToAdd  = new MoleculeBuilder();
            A.CallTo(() => _interactionTask.CorrectName(_moleculeBuilderToAdd, A <IEnumerable <string> > ._)).Returns(true);
            A.CallTo(() => _interactionTask.AdjustFormula(_moleculeBuilderToAdd, _moleculeBuildingBlock, A <IMoBiMacroCommand> ._)).Returns(false);
            A.CallTo(() => _context.PublishEvent(A <AddedEvent <IMoleculeBuilder> > ._))
            .Invokes(x => _addEvent = x.GetArgument <AddedEvent <IMoleculeBuilder> >(0));

            _cancelCommand = A.Fake <IMoBiCommand>();
            A.CallTo(() => _interactionTaskContext.CancelCommand(A <IMoBiCommand> ._)).Returns(_cancelCommand);
        }
        protected override void Context()
        {
            _view                  = A.Fake <ICreatePKSimMoleculeView>();
            _configuration         = A.Fake <IMoBiConfiguration>();
            _parameterDTOMapper    = A.Fake <IParameterToParameterDTOMapper>();
            _moleculeBuilderMapper = A.Fake <IMoleculeBuilderToMoleculeBuilderDTOMapper>();
            _quantityTask          = A.Fake <IQuantityTask>();
            _serializationTask     = A.Fake <ISerializationTask>();
            _moleculeBuildingBlock = A.Fake <IMoleculeBuildingBlock>();
            _editTask              = A.Fake <IEditTaskFor <IMoleculeBuilder> >();

            sut = new CreatePKSimMoleculePresenter(_view, _configuration, _parameterDTOMapper, _moleculeBuilderMapper, _serializationTask, _quantityTask, _editTask);
        }
        public ValidationResult Validate(IMoleculeBuildingBlock moleculeBuildingBlock)
        {
            var validationResults = new ValidationResult();

            foreach (var molecule in moleculeBuildingBlock.Where(m => m.IsFloating))
            {
                foreach (var parameter in molecule.Parameters.Where(parameterIsInvalid))
                {
                    validationResults.AddMessage(NotificationType.Error, parameter, Error.FloatingMoleculeParameterNotDefined(molecule.Name, parameter.Name, parameter.Value), moleculeBuildingBlock);
                }
            }

            return(validationResults);
        }
Esempio n. 29
0
        public void Visit(IMoleculeBuildingBlock moleculeBuildingBlock)
        {
            var amountDimension = _context.DimensionFactory.Dimension(Constants.Dimension.AMOUNT);
            var formula         = createTotalDrugMassFormula(amountDimension);

            foreach (var moleculeBuilder in moleculeBuildingBlock)
            {
                moleculeBuilder.Add(
                    createTotalDrugMassParameter(formula, amountDimension));
            }
            updateAllParameters(moleculeBuildingBlock.SelectMany(mb => mb.GetAllChildren <IParameter>()));
            moleculeBuildingBlock.AddFormula(formula);
            _converted = true;
        }
Esempio n. 30
0
        protected override void Context()
        {
            base.Context();
            _moleculeBuildingBlock   = new MoleculeBuildingBlock();
            _createMoleculePresenter = A.Fake <ICreatePKSimMoleculePresenter>();
            _molecule = new MoleculeBuilder();
            _molecule.DefaultStartFormula = A.Fake <IFormula>();
            A.CallTo(() => _createMoleculePresenter.CreateMolecule(_moleculeBuildingBlock)).Returns(_molecule);
            A.CallTo(() => _interactionTaskContext.ApplicationController.Start <ICreatePKSimMoleculePresenter>()).Returns(_createMoleculePresenter);
            _defaultStartFormula = new ConstantFormula();
            A.CallTo(_formulaTask).WithReturnType <ConstantFormula>().Returns(_defaultStartFormula);

            A.CallTo(() => _context.AddToHistory(A <ICommand> ._))
            .Invokes(x => _command = x.GetArgument <ICommand>(0));
        }