private void addActiveTransportToModel(IModel model, ITransportBuilder activeTransportBuilder, IEnumerable <INeighborhood> allNeighborhoods, IMoleculeBuilder molecule, TransporterMoleculeContainer transporterMolecule, IBuildConfiguration buildConfiguration) { var neighborhoods = getNeigborhoodsForActiveTransport(activeTransportBuilder, allNeighborhoods, molecule.Name, transporterMolecule.Name); foreach (var neighborhood in neighborhoods) { var activeTransport = mapFrom(activeTransportBuilder, neighborhood, molecule.Name, buildConfiguration); var activeTransportInMolecule = addActiveTransportToNeighborhood(neighborhood, activeTransport, transporterMolecule, molecule.Name, buildConfiguration); buildConfiguration.AddBuilderReference(activeTransportInMolecule, activeTransportBuilder); _keywordReplacerTask.ReplaceIn(activeTransport, model.Root, molecule.Name, neighborhood, transporterMolecule.TransportName, transporterMolecule.Name); } }
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); }
private IEnumerable <INeighborhood> getNeigborhoodsForActiveTransport(ITransportBuilder transport, IEnumerable <INeighborhood> allNeighborhoods, string moleculeName, string transporterMoleculeName) { try { return((from useNeighborhoods in getNeighborhoodsByNeighborCriteria(allNeighborhoods, transport.SourceCriteria, transport.TargetCriteria, moleculeName) where useNeighborhoods.GetNeighborSatisfying(transport.SourceCriteria).GetSingleChildByName <IMoleculeAmount>(transporterMoleculeName) != null select useNeighborhoods).ToList()); } catch (BothNeighborsSatisfyingCriteriaException exception) { throw new OSPSuiteException(Error.BothNeighborsSatisfyingForTransport(exception.Message, transport.Name)); } }
private IReadOnlyList <string> transportTypeTagsFor(ITransportBuilder transportBuilder) { if (!transportBuilder.TransportType.Is(TransportType.Active)) { return new[] { Constants.PASSIVE } } ; var activeType = transportBuilder.TransportType.Is(TransportType.Influx) ? Constants.INFLUX : Constants.NOT_INFLUX; return(new[] { Constants.ACTIVE, activeType }); } }
private void updateTransporterFormulaFromCache(ITransportBuilder transportBuilder, IFormulaCache formulaCache) { var formula = transportBuilder.Formula; //only add transporter formula if not already defined in the cache if (formulaCache.ExistsByName(formula.Name)) { transportBuilder.Formula = formulaCache.FindByName(formula.Name); } else { formulaCache.Add(formula); } }
public void TestSerialization() { MoleculeBuilder x1 = CreateObject <MoleculeBuilder>().WithName("Monica.Builder"); x1.IsFloating = true; x1.QuantityType = QuantityType.Metabolite; x1.DefaultStartFormula = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4); TransportBuilder t1 = CreateObject <TransportBuilder>().WithName("Passive Transport"); IFormula consFormula = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(5); IParameter transporterParameter = CreateObject <Parameter>().WithName("Passive Transport Param").WithFormula(consFormula).WithMode(ParameterBuildMode.Property) .WithDimension(DimensionLength); t1.AddParameter(transporterParameter); IFormula f1 = CreateObject <ExplicitFormula>().WithDimension(DimensionLength).WithFormulaString("3*Patty"); IFormulaUsablePath fup = new FormulaUsablePath(new[] { "Patricia" }).WithAlias("Patty").WithDimension(DimensionLength); f1.AddObjectPath(fup); IParameter p1 = CreateObject <Parameter>().WithName("Patricia").WithFormula(f1).WithValue(3.1).WithMode(ParameterBuildMode.Property); IParameter p2 = CreateObject <Parameter>().WithName("Pascal").WithFormula(f1).WithValue(3.2).WithMode(ParameterBuildMode.Local); IParameter p3 = CreateObject <Parameter>().WithName("Paul").WithFormula(f1).WithValue(3.3); x1.AddParameter(p1); x1.AddParameter(p2); var atbc1 = CreateObject <TransporterMoleculeContainer>().WithName("Tranquilo"); ITransportBuilder atb1 = CreateObject <TransportBuilder>(); atb1.Formula = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(2.5); atb1.AddParameter(p3); atb1.Name = "Tranquilo"; atbc1.AddActiveTransportRealization(atb1); var atbc2 = CreateObject <TransporterMoleculeContainer>().WithName("Tranquilo2"); ITransportBuilder atb2 = CreateObject <TransportBuilder>(); atb2.Formula = f1; atb2.Name = "Tranquilo2"; atbc2.AddActiveTransportRealization(atb2); x1.AddTransporterMoleculeContainer(atbc1); x1.AddTransporterMoleculeContainer(atbc2); x1.IsXenobiotic = !x1.IsXenobiotic; var interactionContainer = CreateObject <InteractionContainer>().WithName("Interactions"); x1.AddInteractionContainer(interactionContainer); var x2 = SerializeAndDeserialize(x1); AssertForSpecs.AreEqualMoleculeBuilder(x1, x2); }
public void AddApplicationTransportParametersTo(ITransportBuilder applicationTransportBuilder, string applicationName, string formulationName, IFormulaCache formulaCache) { //assuming that all application transports are located directly under //the application container var formulation = new Container().WithName(formulationName); var application = new Container().WithName(applicationName); var transport = new Container().WithName(applicationTransportBuilder.Name); formulation.Add(application); application.Add(transport); addParametersTo(transport, null, CoreConstants.CalculationMethod.ForApplications, x => true, formulaCache); updateProcessesParameters(transport, applicationTransportBuilder); }
protected override void Context() { base.Context(); _transportBuilder = new TransportBuilder(); _kinetic = A.Fake <IFormula>(); _transportBuilder.CreateProcessRateParameter = true; A.CallTo(() => _formulaBuilderToFormulaMapper.MapFrom(_kinetic, _buildConfiguration)).ReturnsLazily(x => new ExplicitFormula("clone")); _transportBuilder.TransportType = TransportType.Efflux; _transportBuilder.Name = "Active Transport"; _transportBuilder.Formula = _kinetic; A.CallTo(() => _parameterMapper.MapFrom(_transportBuilder.Parameters, _buildConfiguration)).Returns(new List <IParameter>()); _processRateParameter = new Parameter(); A.CallTo(() => _objecBaseFactory.Create <IParameter>()).Returns(_processRateParameter); }
private void updateTransporterTagsFor(IndividualTransporter transporter, ITransportBuilder transporterBuilder, string simulationProcessName) { //if one organ was specified already, no need to create the list of not tags! var allOrgans = transporter.AllOrgansWhereProcessTakesPlace(simulationProcessName).ToList(); var allMatchTags = transporterBuilder.SourceCriteria.OfType <MatchTagCondition>() .Select(x => x.Tag); if (allMatchTags.Intersect(allOrgans).Any()) { return; } foreach (var organName in transporter.AllOrgansWhereProcessDoesNotTakePlace(simulationProcessName)) { transporterBuilder.SourceCriteria.Add(new NotMatchTagCondition(organName)); } }
private IEnumerable <INeighborhood> getNeighborhoodsForActiveTransport(ITransportBuilder transport, IEnumerable <INeighborhood> allNeighborhoods, string moleculeName, string transporterName) { try { //Transporter can either be defined in source or target container. Therefore we need to check that at least ONE neighbor has a transporter instance return(getNeighborhoodsByNeighborCriteria(allNeighborhoods, transport.SourceCriteria, transport.TargetCriteria, moleculeName) .Where(x => x.GetNeighborSatisfying(transport.SourceCriteria).GetSingleChildByName <IMoleculeAmount>(transporterName) != null || x.GetNeighborSatisfying(transport.TargetCriteria).GetSingleChildByName <IMoleculeAmount>(transporterName) != null) .ToList()); } catch (BothNeighborsSatisfyingCriteriaException exception) { throw new OSPSuiteException(Error.BothNeighborsSatisfyingForTransport(exception.Message, transport.Name)); } }
private void addPassiveTransportToModel(IModel model, ITransportBuilder passiveTransportBuilder, IEnumerable <INeighborhood> allNeighborhoods, IMoleculeBuilder molecule, IBuildConfiguration buildConfiguration) { // first check if the molecule should be transported if (!passiveTransportBuilder.TransportsMolecule(molecule.Name)) { return; } var neighborhoods = getNeigborhoodsForPassiveTransport(passiveTransportBuilder, allNeighborhoods, molecule.Name); foreach (var neighborhood in neighborhoods) { var passiveTransport = mapFrom(passiveTransportBuilder, neighborhood, molecule.Name, buildConfiguration); addPassiveTransportToNeighborhood(neighborhood, molecule.Name, passiveTransport); _keywordReplacerTask.ReplaceIn(passiveTransport, model.Root, molecule.Name, neighborhood); } }
public TransporterMoleculeContainer GetTransporterMoleculeFrom(ITransportBuilder transportBuilder) { foreach (var moleculeBuildingBlock in _context.CurrentProject.MoleculeBlockCollection) { foreach (var moleculeBuider in moleculeBuildingBlock) { var transporteMolecule = moleculeBuider.TransporterMoleculeContainerCollection .FirstOrDefault(x => x.ActiveTransportRealizations.Contains(transportBuilder)); if (transporteMolecule != null) { return(transporteMolecule); } } } return(null); }
public void TestSerialization() { TransportBuilder x1 = CreateObject <TransportBuilder>().WithName("Acerola.Builder").WithDimension(DimensionLength); x1.Formula = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4); IFormula f1 = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(2.3); IParameter p1 = CreateObject <Parameter>().WithName("Patricia").WithFormula(f1).WithDimension(DimensionLength); x1.AddParameter(p1); x1.Name = "Tranquilo"; x1.CreateProcessRateParameter = true; x1.ProcessRateParameterPersistable = true; ITransportBuilder x2 = SerializeAndDeserialize(x1); AssertForSpecs.AreEqualTransportBuilder(x1, x2); }
/// <summary> /// Creates the Kinetic Formula for a passive Transport. /// </summary> private void CreateKinetic(Reaction sbmlReaction, ITransportBuilder passiveTransport) { _astHandler.NeedAbsolutePath = true; var formula = sbmlReaction.getKineticLaw() == null ? ObjectBaseFactory.Create <ExplicitFormula>().WithFormulaString(String.Empty) : _astHandler.Parse(sbmlReaction.getKineticLaw().getMath(), sbmlReaction.getId(), _sbmlProject, _sbmlInformation); if (formula == null) { passiveTransport.Formula = ObjectBaseFactory.Create <ExplicitFormula>() .WithFormulaString(String.Empty) .WithName(SBMLConstants.DEFAULT_FORMULA_NAME); } else { passiveTransport.Formula = formula; _passiveTransportBuildingBlock.FormulaCache.Add(formula); } }
private void addApplicationTransportToModel(ITransportBuilder appTransport, EntityDescriptorMapList <IContainer> allEventGroupParentChildContainers, string moleculeName) { var appTransportSourceContainers = sourceContainersFor(appTransport, allEventGroupParentChildContainers); var appTransportTargetContainers = _applicationTransportTargetContainerCache[appTransport.TargetCriteria].ToList(); foreach (var sourceContainer in appTransportSourceContainers) { var sourceAmount = sourceContainer.GetSingleChildByName <IMoleculeAmount>(moleculeName); if (sourceAmount == null) { throw new OSPSuiteException(Validation.CannotCreateApplicationSourceNotFound(appTransport.Name, moleculeName, sourceContainer.Name)); } foreach (var targetContainer in appTransportTargetContainers) { var targetAmount = targetContainer.GetSingleChildByName <IMoleculeAmount>(moleculeName); if (targetAmount == null) { throw new OSPSuiteException(Validation.CannotCreateApplicationTargetNotFound(appTransport.Name, moleculeName, targetContainer.Name)); } var transport = _transportMapper.MapFrom(appTransport, _buildConfiguration); transport.SourceAmount = sourceAmount; transport.TargetAmount = targetAmount; _keywordReplacerTask.ReplaceIn(transport, _model.Root, moleculeName); //At the moment, no neighborhoods between application sub-containers and //spatial structure sub-containers are defined. Application transports are //added as direct children of the source molecule amount if (!sourceAmount.ContainsName(transport.Name)) { sourceAmount.Add(transport); } else { throw new OSPSuiteException(Validation.TransportAlreadyCreatorForMolecule(appTransport.Name, transport.Name, moleculeName)); } } } }
public ITransport MapFrom(ITransportBuilder transportBuilder, IBuildConfiguration buildConfiguration) { var transport = _objectBaseFactory.Create <ITransport>() .WithName(transportBuilder.Name) .WithIcon(transportBuilder.Icon) .WithDimension(transportBuilder.Dimension) .WithFormula(_formulaMapper.MapFrom(transportBuilder.Formula, buildConfiguration)); buildConfiguration.AddBuilderReference(transport, transportBuilder); addLocalParameters(transport, transportBuilder, buildConfiguration); //lastly, add parameter rate transporter if required if (transportBuilder.CreateProcessRateParameter) { transport.Add(processRateParameterFor(transportBuilder, buildConfiguration)); } return(transport); }
public void TestSerialization() { TransportBuilder x1 = CreateObject <TransportBuilder>().WithName("Priscilla.Builder").WithDimension(DimensionLength); x1.Formula = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4); x1.CreateProcessRateParameter = true; IFormula f1 = CreateObject <ExplicitFormula>().WithDimension(DimensionLength).WithFormulaString("3*Patty"); IFormulaUsablePath fup = new FormulaUsablePath(new[] { "Patricia" }).WithAlias("Patty").WithDimension(DimensionLength); f1.AddObjectPath(fup); //WithValue to avoid formula evaluation in McAssertForSpecs-comparison. IParameter p1 = CreateObject <Parameter>().WithName("Patricia").WithFormula(f1).WithValue(3.1); IParameter p2 = CreateObject <Parameter>().WithName("Pascal").WithFormula(f1).WithValue(3.2); x1.AddParameter(p1); x1.AddParameter(p2); ITransportBuilder x2 = SerializeAndDeserialize(x1); AssertForSpecs.AreEqualProcessBuilder(x1, x2); }
protected override void Context() { base.Context(); _moleculeBuilder = A.Fake <IMoleculeBuilder>(); _startFormula = A.Fake <IFormula>(); _moleculeBuilder.DefaultStartFormula = _startFormula; _moleculeBuilder.Description = "Description"; _moleculeBuilder.Icon = "Icon"; _moleculeBuilder.Id = "ID"; _moleculeBuilder.IsFloating = true; _moleculeBuilder.QuantityType = QuantityType.Drug; _activeTransport = A.Fake <ITransportBuilder>(); _transporterMoleculeContainer = A.Fake <TransporterMoleculeContainer>(); A.CallTo(() => _moleculeBuilder.TransporterMoleculeContainerCollection).Returns(new[] { _transporterMoleculeContainer }); A.CallTo(() => _transporterMoleculeContainer.ActiveTransportRealizations).Returns(new[] { _activeTransport }); _parameter = A.Fake <IParameter>(); A.CallTo(() => _moleculeBuilder.Parameters).Returns(new[] { _parameter }); _calculationMethod = A.Fake <UsedCalculationMethod>(); A.CallTo(() => _moleculeBuilder.UsedCalculationMethods).Returns(new[] { _calculationMethod }); _interactionContainer = A.Fake <InteractionContainer>(); A.CallTo(() => _moleculeBuilder.InteractionContainerCollection).Returns(new[] { _interactionContainer }); }
public ObjectBaseSummaryDTO MapFrom(ITransportBuilder transportBuilder) { var dto = new ObjectBaseSummaryDTO { ApplicationIcon = ApplicationIcons.PassiveTransport, EntityName = transportBuilder.Name }; dto.AddToDictionary(AppConstants.Captions.Type, ObjectTypes.PassiveTransportBuilder); dto.AddToDictionary(AppConstants.Captions.SourceDescriptor, transportBuilder.SourceCriteria.ToString()); dto.AddToDictionary(AppConstants.Captions.TargetDescriptor, transportBuilder.TargetCriteria.ToString()); dto.AddToDictionary(AppConstants.Captions.ForAll, transportBuilder.ForAll.ToString()); if (transportBuilder.ForAll) { return(dto); } dto.AddToDictionary(AppConstants.Captions.MoleculesToInclude, transportBuilder.MoleculeList.MoleculeNames.ToString(", ")); dto.AddToDictionary(AppConstants.Captions.MoleculesToExclude, transportBuilder.MoleculeList.MoleculeNamesToExclude.ToString(", ")); return(dto); }
protected override void Because() { _transport = sut.PassiveTransportProcessFrom(_process, "DRUG", _formulaCache); }
public void Visit(ITransportBuilder transportBuilder) { checkMoleculeDependentBuilder(transportBuilder, _objectTypeResolver.TypeFor(transportBuilder)); checkDescriptorCriteria(transportBuilder, x => x.SourceCriteria); checkDescriptorCriteria(transportBuilder, x => x.TargetCriteria); }
private static bool isOldGallbladderEmptyingTransport(ITransportBuilder transpotBuilder) { return(transpotBuilder.Name.Equals(GallbladderEmptying) && ((ExplicitFormula)transpotBuilder.Formula).FormulaString.Equals(GallbladderEmptyingOldFormula)); }
/// <summary> /// Remove a localized realization of the transport process /// </summary> public virtual void RemoveActiveTransportRealization(ITransportBuilder activeTransportBuilderToRemove) { RemoveChild(activeTransportBuilderToRemove); }
/// <summary> /// Add a new localized realization of the transport process /// </summary> public virtual void AddActiveTransportRealization(ITransportBuilder activeTransportBuilder) => Add(activeTransportBuilder);
private bool similarPassiveTransportAlreadyExists(IPassiveTransportBuildingBlock passiveTransportBuildingBlock, ITransportBuilder passiveTransport, string passiveTransportName) { var existingPassiveTransport = passiveTransportBuildingBlock.FindByName(passiveTransportName); if (existingPassiveTransport == null) { return(false); } return(_formulaTask.FormulasAreTheSame(existingPassiveTransport.Formula, passiveTransport.Formula)); }
protected override void Because() { _clone = _cloneManagerForBuildingBlock.Clone(sut, new FormulaCache()); }
private void convertPreviousProblemWithPassiveTransportParametersGlobals(ITransportBuilder passiveTransportBuilder) { passiveTransportBuilder.Parameters.Each(p => p.BuildMode = ParameterBuildMode.Local); }
protected override void Because() { _result = sut.CreateNewEntity(_transporterMoleculeContainer); }
private IEnumerable <IContainer> sourceContainersFor(ITransportBuilder transport, EntityDescriptorMapList <IContainer> allEventGroupParentChildContainers) { return(allEventGroupParentChildContainers.AllSatisfiedBy(transport.SourceCriteria)); }
public TransportBuilderDTO(ITransportBuilder transportBuilder) { TransporBuilder = transportBuilder; }