protected override void Context()
        {
            base.Context();
            _project = new MoBiProject();
            var molecule          = new MoleculeBuilder().WithName(_moleculeName);
            var moleculeParameter = new Parameter().WithName(_moleculeParameterName);

            molecule.Add(moleculeParameter);
            var molecules = new MoleculeBuildingBlock()
            {
                molecule
            };

            _project.AddBuildingBlock(molecules);
            var parameter = new Parameter().WithName(_parameterName);
            var root      = new Container().WithName("Root");

            root.Add(parameter);
            var spatialStructure = new MoBiSpatialStructure().WithTopContainer(root);

            _project.AddBuildingBlock(spatialStructure);
            var reactionBuilder = new ReactionBuilder().WithName(_reactionName);
            var reactions       = new MoBiReactionBuildingBlock()
            {
                reactionBuilder
            };

            _project.AddBuildingBlock(reactions);

            A.CallTo(() => _context.CurrentProject).Returns(_project);
        }
        private static MoleculeBuilder createMoleculeBuilder(string moleculeName)
        {
            var drug = new MoleculeBuilder().WithName(moleculeName);

            drug.AddParameter(new Parameter().WithName("MoleculeProperty").WithFormula(new ConstantFormula(1)).WithMode(ParameterBuildMode.Global));
            return(drug);
        }
        protected override void Context()
        {
            base.Context();
            var moleculeBuildingBlock1 = new MoleculeBuildingBlock().WithName("Tada");
            var moleculeBuilderA       = new MoleculeBuilder().WithName("MSVa");
            var moleculeBuilderB       = new MoleculeBuilder().WithName("MSVb");

            moleculeBuildingBlock1.Add(moleculeBuilderA);
            moleculeBuildingBlock1.Add(moleculeBuilderB);


            var moleculeBuildingBlock2 = new MoleculeBuildingBlock().WithName("Toto");

            moleculeBuilderA = new MoleculeBuilder().WithName("MSVa");
            moleculeBuilderB = new MoleculeBuilder().WithName("MSVb");


            moleculeBuildingBlock2.Add(moleculeBuilderA);
            moleculeBuildingBlock2.Add(moleculeBuilderB);

            _object1 = moleculeBuildingBlock1;
            _object2 = moleculeBuildingBlock2;

            _comparerSettings.OnlyComputingRelevant = false;
        }
Beispiel #4
0
        protected override void Context()
        {
            _quantity = A.Fake <IParameter>().WithName("P");

            base.Context();
            _parameter.Name = "P";
            var moleculeBuilder1     = new MoleculeBuilder().WithName("Mol1");
            var moleculeBuilder2     = new MoleculeBuilder().WithName("Mol2");
            var transporterMolecule1 = new TransporterMoleculeContainer {
                TransportName = "TRANSPORT", Name = "TRANSPORTER"
            };
            var molecule1 = new Container().WithName("Mol1");

            molecule1.Add(transporterMolecule1);
            var molecule2            = new Container().WithName("Mol2");
            var transporterMolecule2 = new TransporterMoleculeContainer {
                TransportName = "TRANSPORT", Name = "TRANSPORTER"
            };

            molecule2.Add(transporterMolecule2);
            moleculeBuilder1.AddTransporterMoleculeContainer(transporterMolecule1);
            moleculeBuilder2.AddTransporterMoleculeContainer(transporterMolecule2);
            var moleculeBuildingBlock = new MoleculeBuildingBlock {
                moleculeBuilder1, moleculeBuilder2
            };

            _buildingBlockInfo.UntypedBuildingBlock = moleculeBuildingBlock;
            transporterMolecule1.AddParameter(_parameter);
            _quantity.ParentContainer.Name = transporterMolecule1.TransportName;
            _quantity.ParentContainer.ParentContainer.Name = moleculeBuilder1.Name;
        }
Beispiel #5
0
        protected override void Context()
        {
            base.Context();
            var container = new Container {
                Mode = ContainerMode.Physical, Name = "containerName"
            };

            var subContainer = new Container {
                Mode = ContainerMode.Physical, Name = "subContainerName"
            };

            subContainer.Add(new Parameter {
                Name = "containerParameter"
            });
            container.Add(subContainer);
            _spatialStructure.AddTopContainer(container);

            var builder = new MoleculeBuilder {
                Name = "C1"
            };

            builder.AddParameter(new Parameter {
                BuildMode = ParameterBuildMode.Local, Name = "localParameter"
            });

            _moleculeBuildingBlock.Add(builder);
        }
 protected override void Context()
 {
     base.Context();
     A.CallTo(() => _reactionDimensionRetriever.SelectedDimensionMode).Returns(ReactionDimensionMode.ConcentrationBased);
     _moleculeBuilder = new MoleculeBuilder {
         DefaultStartFormula = new ConstantFormula(0), Dimension = DomainHelperForSpecs.AmountDimension
     };
 }
        protected override void Context()
        {
            base.Context();
            _moleculeParameter = new Parameter().WithName("RP");
            var moleculeBuilder = new MoleculeBuilder();

            moleculeBuilder.Add(_moleculeParameter);
        }
 protected override void Context()
 {
     base.Context();
     _explicitFormula = new ExplicitFormula("A+B");
     A.CallTo(() => _reactionDimensionRetriever.SelectedDimensionMode).Returns(ReactionDimensionMode.ConcentrationBased);
     _moleculeBuilder = new MoleculeBuilder {
         DefaultStartFormula = _explicitFormula, Dimension = DomainHelperForSpecs.AmountDimension
     };
     A.CallTo(() => _amoutToConcentrationFormulaMapper.HasMappingFor(_explicitFormula)).Returns(false);
 }
Beispiel #9
0
        protected override void Context()
        {
            base.Context();
            var builder = new MoleculeBuilder {
                Name = "C1"
            };

            builder.AddParameter(new Parameter {
                BuildMode = ParameterBuildMode.Local, Name = "localParameter"
            });

            _moleculeBuildingBlock.Add(builder);
        }
        protected override void Context()
        {
            base.Context();
            var molecule = new MoleculeBuilder {
                Name = "Mol", Dimension = Constants.Dimension.NO_DIMENSION
            };
            var nanStartValue = new MoleculeStartValue {
                Name = molecule.Name, StartValue = null, Dimension = Constants.Dimension.NO_DIMENSION
            };

            _moleculeStartValueBuildingBlock.Add(nanStartValue);
            A.CallTo(_moleculeResolver).WithReturnType <IMoleculeBuilder>().Returns(molecule);
        }
        protected override void Context()
        {
            base.Context();
            _dimension          = DimensionFactoryForSpecs.Factory.Dimension(DimensionFactoryForSpecs.DimensionNames.Mass);
            _moleculeStartValue = new MoleculeStartValue {
                Dimension = _dimension, Name = _name, Formula = null
            };

            _builder = new MoleculeBuilder
            {
                Name      = _name,
                Dimension = _dimension
            };
        }
        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);
        }
        protected override void Context()
        {
            base.Context();
            var builder = new MoleculeBuilder {
                Name = "molecule", Dimension = Constants.Dimension.NO_DIMENSION, DefaultStartFormula = new ExplicitFormula("50")
            };
            var startValue = new MoleculeStartValue {
                Name = builder.Name, StartValue = 45, Dimension = Constants.Dimension.NO_DIMENSION, Formula = null
            };

            _moleculeStartValueBuildingBlock.Add(startValue);
            A.CallTo(() => _cloneManagerForBuildingBlock.Clone(builder.DefaultStartFormula, _moleculeStartValueBuildingBlock.FormulaCache)).Returns(new ExplicitFormula("M/V"));
            A.CallTo(_moleculeResolver).WithReturnType <IMoleculeBuilder>().Returns(builder);
        }
Beispiel #14
0
        public static MoleculeReference AddSideChain(this MoleculeReference moleculeReference, params ElementName[] sideChainElements)
        {
            if (!moleculeReference.IsInitialized)
            {
                throw new InvalidOperationException("Cannot add atoms. Molecule reference is not initialized");
            }
            var sideChainBuilder   = new MoleculeBuilder();
            var sideChainReference = sideChainBuilder.Start.Add(sideChainElements);

            moleculeReference.Molecule.AddMolecule(sideChainReference,
                                                   moleculeReference.FirstAtomId,
                                                   moleculeReference.LastAtomId);
            return(moleculeReference);
        }
Beispiel #15
0
        protected override void Context()
        {
            _quantity = _parameter;

            base.Context();
            var moleculeBuilder = new MoleculeBuilder();

            moleculeBuilder.AddParameter(_parameter);
            var moleculeBuildingBlock = new MoleculeBuildingBlock {
                moleculeBuilder
            };

            _buildingBlockInfo.UntypedBuildingBlock = moleculeBuildingBlock;
        }
Beispiel #16
0
        protected override void Context()
        {
            base.Context();
            var moleculeBuilder1 = new MoleculeBuilder().WithName("Drug");

            moleculeBuilder1.DefaultStartFormula = new ConstantFormula(0);

            var moleculeBuilder2 = new MoleculeBuilder().WithName("Drug");

            moleculeBuilder2.DefaultStartFormula = new ConstantFormula(1.1);


            _object1 = moleculeBuilder1;
            _object2 = moleculeBuilder2;
        }
        protected override void Context()
        {
            base.Context();
            var moleculeBuindingBlock = new MoleculeBuildingBlock();
            var molecule = new MoleculeBuilder {
                Name = "Mol", Dimension = Constants.Dimension.NO_DIMENSION
            };

            moleculeBuindingBlock.Add(molecule);
            _nullStartValue = new MoleculeStartValue {
                Name = molecule.Name, StartValue = 1, Dimension = Constants.Dimension.NO_DIMENSION
            };
            _moleculeStartValueBuildingBlock.Add(_nullStartValue);
            A.CallTo(_context.Context).WithReturnType <IMoleculeBuildingBlock>().Returns(moleculeBuindingBlock);
        }
        protected override void Context()
        {
            base.Context();
            _parameter = new Parameter()
                         .WithName("P")
                         .WithMode(_parameterBuildMode)
                         .WithParentContainer(new Container().WithName("Drug"));

            var moleculeBuilder  = new MoleculeBuilder().WithName("Drug");
            var parameterBuilder = new Parameter()
                                   .WithName(_parameter.Name)
                                   .WithMode(_parameterBuildMode);

            moleculeBuilder.AddParameter(parameterBuilder);
            _moleculeBuidingBlock.Add(moleculeBuilder);
        }
Beispiel #19
0
        /// <summary>
        /// Add values to the NodeType Properties of a Node.
        /// </summary>
        /// <param name="Node">The Node whose properties are being filled in.</param>
        /// <param name="CurrentIndex">The current index in the ProductSize array in a CswC3Product object. This is ONLY needed for Size Nodes.</param>
        public void addNodeTypeProps(CswNbtNode Node, int CurrentIndex = 0)
        {
            CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(Node.NodeTypeId);

            foreach (CswNbtMetaDataNodeTypeProp NTP in NodeType.getNodeTypeProps())
            {
                if (null != Node.Properties[NTP] && _Mappings.ContainsKey(NTP.PropName))
                {
                    C3Mapping C3Mapping = _Mappings[NTP.PropName];
                    switch (Node.Properties[NTP].getFieldTypeValue())
                    {
                    case CswEnumNbtFieldType.MOL:
                        if (false == string.IsNullOrEmpty(C3Mapping.C3ProductPropertyValue))
                        {
                            string propAttr = new CswPropIdAttr(Node, NTP).ToString();
                            string molData  = C3Mapping.C3ProductPropertyValue;

                            CswNbtSdBlobData SdBlobData = new CswNbtSdBlobData(_CswNbtResources);

                            MolecularGraph Mol = MoleculeBuilder.CreateMolFromString(molData);
                            if (false == Mol.ContainsInvalidAtom())
                            {
                                string Href;
                                string FormattedMolString;
                                string errorMsg;
                                SdBlobData.saveMol(molData, propAttr, out Href, out FormattedMolString, out errorMsg, Node: Node);
                            }
                            else
                            {
                                _CswNbtResources.logMessage("Failed to save the MOL file for product with ProductId " + _ProductToImport.ProductId + " during the C3 import process because it contained an invalid atom.");
                            }
                        }
                        break;

                    default:
                        CswNbtSubField SubField = NTP.getFieldTypeRule().SubFields[(CswEnumNbtPropColumn)C3Mapping.NBTSubFieldPropColName];
                        if (null != SubField)
                        {
                            Node.Properties[NTP].SetSubFieldValue(SubField, C3Mapping.C3ProductPropertyValue);
                        }
                        break;
                    }
                } //if( null != Node.Properties[NTP] && _Mappings.ContainsKey( NTP.PropName ) )
            }     //foreach( CswNbtMetaDataNodeTypeProp NTP in NodeType.getNodeTypeProps() )
        }         //addNodeTypeProps()
        protected override void Context()
        {
            base.Context();
            var moleculeBuilder1 = new MoleculeBuilder().WithName("Drug");
            var formula1         = new ExplicitFormula("A+B");

            formula1.AddObjectPath(new FormulaUsablePath("Sim1", "A", "B", "C").WithAlias("Same"));
            moleculeBuilder1.DefaultStartFormula = formula1;

            var moleculeBuilder2 = new MoleculeBuilder().WithName("Drug");
            var formula2         = new ExplicitFormula("A+B");

            formula2.AddObjectPath(new FormulaUsablePath("Sim2", "A", "B", "C").WithAlias("Same"));
            moleculeBuilder2.DefaultStartFormula = formula2;

            _object1 = moleculeBuilder1;
            _object2 = moleculeBuilder2;
        }
Beispiel #21
0
        protected override void Context()
        {
            base.Context();
            var moleculeBuilder1 = new MoleculeBuilder().WithName("Drug");

            moleculeBuilder1.DefaultStartFormula = new ConstantFormula(0);
            moleculeBuilder1.AddUsedCalculationMethod(new UsedCalculationMethod("Cat1", "CM1"));
            moleculeBuilder1.AddUsedCalculationMethod(new UsedCalculationMethod("Cat2", "CM2"));

            var moleculeBuilder2 = new MoleculeBuilder().WithName("Drug");

            moleculeBuilder2.DefaultStartFormula = new ConstantFormula(0);
            moleculeBuilder2.AddUsedCalculationMethod(new UsedCalculationMethod("Cat1", "CM1"));
            moleculeBuilder2.AddUsedCalculationMethod(new UsedCalculationMethod("Cat2", "CM3"));


            _object1 = moleculeBuilder1;
            _object2 = moleculeBuilder2;
        }
Beispiel #22
0
        protected override void Context()
        {
            base.Context();
            _comparerSettings.OnlyComputingRelevant = false;
            var moleculeBuilder1 = new MoleculeBuilder().WithName("Drug");

            moleculeBuilder1.DefaultStartFormula = new ConstantFormula(0);
            moleculeBuilder1.IsFloating          = false;
            moleculeBuilder1.QuantityType        = QuantityType.Drug;

            var moleculeBuilder2 = new MoleculeBuilder().WithName("Drug");

            moleculeBuilder2.DefaultStartFormula = new ConstantFormula(0);
            moleculeBuilder2.IsFloating          = true;
            moleculeBuilder2.QuantityType        = QuantityType.Metabolite;

            _object1 = moleculeBuilder1;
            _object2 = moleculeBuilder2;
        }
        protected override void Context()
        {
            base.Context();
            var moleculeBuilder1 = new MoleculeBuilder().WithName("Drug");
            var formula1         = new SumFormula();

            formula1.Criteria = Create.Criteria(x => x.With("A").And.Not("B"));
            formula1.Variable = "X";
            moleculeBuilder1.DefaultStartFormula = formula1;

            var moleculeBuilder2 = new MoleculeBuilder().WithName("Drug");
            var formula2         = new SumFormula();

            formula2.Criteria = Create.Criteria(x => x.With("A").And.With("B"));
            formula2.Variable = "Y";
            moleculeBuilder2.DefaultStartFormula = formula2;

            _object1 = moleculeBuilder1;
            _object2 = moleculeBuilder2;
        }
        protected override void Context()
        {
            base.Context();
            _project = new MoBiProject();
            var molecule          = new MoleculeBuilder().WithName(_moleculeName);
            var moleculeParameter = new Parameter().WithName(_moleculeParameterName);

            molecule.Add(moleculeParameter);
            var molecules = new MoleculeBuildingBlock()
            {
                molecule
            };

            _project.AddBuildingBlock(molecules);
            var parameter = new Parameter().WithName(_parameterName);
            var root      = new Container().WithName(_topContainerName);

            root.Add(parameter);
            var spatialStructure = new MoBiSpatialStructure().WithTopContainer(root);

            spatialStructure.GlobalMoleculeDependentProperties = new Container().WithName(Constants.MOLECULE_PROPERTIES);
            spatialStructure.NeighborhoodsContainer            = new Container().WithName(Constants.NEIGHBORHOODS);
            _project.AddBuildingBlock(spatialStructure);

            var reactionBuilder = new ReactionBuilder().WithName(_reactionName);
            var reactions       = new MoBiReactionBuildingBlock()
            {
                reactionBuilder
            };

            _project.AddBuildingBlock(reactions);
            _project.AddSimulation(new MoBiSimulation().WithName(_simulationName));
            var eventGroupBuilder       = new EventGroupBuilder().WithName(_eventGroupName);
            var eventGroupBuildingBlock = new EventGroupBuildingBlock();

            eventGroupBuildingBlock.Add(eventGroupBuilder);
            _project.AddBuildingBlock(eventGroupBuildingBlock);


            A.CallTo(() => _context.CurrentProject).Returns(_project);
        }
Beispiel #25
0
        protected override void Context()
        {
            base.Context();
            sut.SelectionPredicate = p => true;
            var id = "mp";

            var physical           = new Container().WithName("PHYS").WithMode(ContainerMode.Physical);
            var moleculeProperties = new Container().WithName(Constants.MOLECULE_PROPERTIES).WithParentContainer(physical);
            var p1 = new Parameter().WithName("P1");

            moleculeProperties.Add(p1);
            var moleculeName = "Drug";

            _moleculePropertiesDTO =
                new DummyMoleculeContainerDTO()
            {
                MoleculePropertiesContainer = new ObjectBaseDTO().WithId(id)
            }.WithId("ANY")
            .WithName(moleculeName);
            A.CallTo(() => _context.Get <IContainer>(id)).Returns(moleculeProperties);
            var objectBaseRepository = A.Fake <IWithIdRepository>();

            A.CallTo(() => _context.ObjectRepository).Returns(objectBaseRepository);
            A.CallTo(() => objectBaseRepository.ContainsObjectWithId(id)).Returns(true);
            A.CallTo(() => _parameterMapper.MapFrom(p1, A <IContainer> ._, A <IObjectBaseDTO> ._)).Returns(_dtoP1);
            var project = A.Fake <IMoBiProject>();

            var moleculeBuildingBlock = new MoleculeBuildingBlock();
            var molecule = new MoleculeBuilder().WithName(moleculeName);
            var localP   = new Parameter().WithName("local").WithMode(ParameterBuildMode.Local).WithParentContainer(molecule);
            var globalP  =
                new Parameter().WithName("global").WithMode(ParameterBuildMode.Global).WithParentContainer(molecule);

            moleculeBuildingBlock.Add(molecule);
            A.CallTo(() => project.MoleculeBlockCollection).Returns(new[] { moleculeBuildingBlock });
            A.CallTo(() => _parameterMapper.MapFrom(localP, A <IContainer> ._, A <IObjectBaseDTO> ._)).Returns(_dtoPlocal);
            A.CallTo(() => _parameterMapper.MapFrom(globalP, A <IContainer> ._, A <IObjectBaseDTO> ._)).Returns(_dtoPglobal);
            A.CallTo(() => _context.CurrentProject).Returns(project);
        }
        protected override void Context()
        {
            base.Context();
            var moleculeBuildingBlock1 = new MoleculeBuildingBlock().WithName("Tada");
            var moleculeBuilderA       = new MoleculeBuilder().WithName("DrugA");
            var moleculeBuilderB       = new MoleculeBuilder().WithName("DrugB");

            moleculeBuildingBlock1.Add(moleculeBuilderA);
            moleculeBuildingBlock1.Add(moleculeBuilderB);


            var moleculeBuildingBlock2 = new MoleculeBuildingBlock().WithName("Tada");

            moleculeBuilderA = new MoleculeBuilder().WithName("DrugA");
            moleculeBuilderB = new MoleculeBuilder().WithName("DrugC");

            moleculeBuildingBlock2.Add(moleculeBuilderA);
            moleculeBuildingBlock2.Add(moleculeBuilderB);

            _object1 = moleculeBuildingBlock1;
            _object2 = moleculeBuildingBlock2;
        }
Beispiel #27
0
        protected override void Context()
        {
            base.Context();
            _passiveTransports2 = new PassiveTransportBuildingBlock();
            _project.AddBuildingBlock(_passiveTransports);
            _project.AddBuildingBlock(_passiveTransports2);
            _project.AddBuildingBlock(_molecules);

            var anotherMoleculeWithPassiveTransport = new MoleculeBuilder().WithName("MOLECULE");
            var molecules2 = new MoleculeBuildingBlock {
                anotherMoleculeWithPassiveTransport
            }.WithName("MBB2");
            var samePassiveTransport = new TransportBuilder().WithName("PASSIVE TRANSPORT").WithFormula(A.Fake <IFormula>());

            anotherMoleculeWithPassiveTransport.Add(samePassiveTransport);

            A.CallTo(() => _formulaTask.FormulasAreTheSame(_passiveTransportKinetic, samePassiveTransport.Formula)).Returns(true);

            A.CallTo(() => _cloneManagerForModel.Clone <ITransportBuilder>(_passiveTransport)).ReturnsLazily(x => new TransportBuilder().WithFormula(_passiveTransportKinetic));
            A.CallTo(() => _containerTask.CreateUniqueName(_passiveTransports, A <string> ._, true)).ReturnsLazily(x => x.Arguments[1].ConvertedTo <string>());
            _project.AddBuildingBlock(molecules2);
        }
Beispiel #28
0
        public void saveMol(string MolString, string PropId, out string Href, out string FormattedMolString, out string errorMsg, bool PostChanges = true, CswNbtNode Node = null)
        {
            CswPropIdAttr PropIdAttr = new CswPropIdAttr(PropId);
            CswNbtMetaDataNodeTypeProp MetaDataProp = _CswNbtResources.MetaData.getNodeTypeProp(PropIdAttr.NodeTypePropId);

            //Case 29769 - enforce correct mol file format
            FormattedMolString = MoleculeBuilder.FormatMolFile(MolString);

            errorMsg = string.Empty;
            Href     = string.Empty;
            if (null == Node)
            {
                Node = _CswNbtResources.Nodes[PropIdAttr.NodeId];
            }
            if (null != Node)
            {
                CswNbtNodePropMol molProp = Node.Properties[MetaDataProp];
                if (null != molProp)
                {
                    molProp.setMol(FormattedMolString);

                    //If DirectStructureSearch is enabled, use the new code to generate an image. Otherwise, use the legacy code.
                    byte[] molImage =
                        (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.DirectStructureSearch) ?
                         _CswNbtResources.AcclDirect.GetImage(FormattedMolString) :
                         CswStructureSearch.GetImage(FormattedMolString));

                    CswNbtSdBlobData SdBlobData = new CswNbtSdBlobData(_CswNbtResources);
                    Href = CswNbtNodePropMol.getLink(molProp.JctNodePropId, Node.NodeId);

                    //Save the mol image to blob_data
                    SdBlobData.saveFile(PropId, molImage, CswNbtNodePropMol.MolImgFileContentType, CswNbtNodePropMol.MolImgFileName, out Href, Int32.MinValue, PostChanges, Node: Node);

                    //case 28364 - calculate fingerprint and save it
                    _CswNbtResources.StructureSearchManager.InsertFingerprintRecord(PropIdAttr.NodeId.PrimaryKey, FormattedMolString, out errorMsg);
                }
            }
        }
Beispiel #29
0
        protected override void Context()
        {
            base.Context();
            _reactionBuildingBlock = new MoBiReactionBuildingBlock
            {
                DiagramModel   = new DiagramModel(),
                DiagramManager = new MoBiReactionDiagramManager()
            };

            _moBiReactionDiagramManager = _reactionBuildingBlock.DiagramManager.DowncastTo <IReactionDiagramManager <IMoBiReactionBuildingBlock> >();

            _moBiReactionDiagramManager.InitializeWith(_reactionBuildingBlock, A.Fake <IDiagramOptions>());

            _molecule = new MoleculeBuilder().WithId("moleculeId").WithName("moleculeName");
            _reaction = new ReactionBuilder().WithId("reactionId");
            _reaction.AddEduct(new ReactionPartnerBuilder(_molecule.Name, 1.0));
            _reactionBuildingBlock.Add(_reaction);
            _moBiReactionDiagramManager.AddObjectBase(_reaction);
            _moBiReactionDiagramManager.AddMolecule(_reaction, "moleculeName");
            _moleculeNode           = _moBiReactionDiagramManager.GetMoleculeNodes("moleculeName").FirstOrDefault();
            _reactionNode           = _moBiReactionDiagramManager.PkModel.DiagramModel.GetAllChildren <ReactionNode>().FirstOrDefault();
            _interactionTask        = A.Fake <IInteractionTasksForChildren <IMoBiReactionBuildingBlock, IReactionBuilder> >();
            _activeSubjectRetriever = A.Fake <IActiveSubjectRetriever>();

            var reactionLink = new ReactionLink();

            reactionLink.Initialize(ReactionLinkType.Educt, _reactionNode, _moleculeNode);

            sut.Edit(_reactionBuildingBlock);

            var removeReactionCommand = new RemoveCommandFor <IMoBiReactionBuildingBlock, IReactionBuilder>(_interactionTask, _moBiContext, _activeSubjectRetriever);

            A.CallTo(() => _moBiContext.Get <IReactionBuilder>(_reaction.Id)).Returns(_reaction);
            A.CallTo(() => _moBiContext.Resolve <RemoveCommandFor <IMoBiReactionBuildingBlock, IReactionBuilder> >()).Returns(removeReactionCommand);
            A.CallTo(() => _activeSubjectRetriever.Active <IBuildingBlock>()).Returns(_reactionBuildingBlock);
            A.CallTo(() => _interactionTask.Remove(_reaction, _reactionBuildingBlock, _reactionBuildingBlock, A <bool> ._)).Invokes(x => _reactionBuildingBlock.Remove(_reaction));
        }
Beispiel #30
0
        protected override void Context()
        {
            base.Context();

            _moleculeStartValues = new MoleculeStartValuesBuildingBlock();
            _moleculeStartValues.Add(new MoleculeStartValue {
                Name = "drug", IsPresent = true
            });
            _moleculeStartValues.Add(new MoleculeStartValue {
                Name = "molecule", IsPresent = true
            });
            _moleculeStartValues.Add(new MoleculeStartValue {
                Name = "moleculeThatDoesNotExist", IsPresent = true
            });
            _moleculeStartValues.Add(new MoleculeStartValue {
                Name = "moleculeThatDoesExistButNotPresent", IsPresent = false
            });

            _drug = new MoleculeBuilder().WithName("drug");
            sut.Add(_drug);
            _molecule = new MoleculeBuilder().WithName("molecule");
            sut.Add(_molecule);
            sut.Add(new MoleculeBuilder().WithName("moleculeThatDoesExistButNotPresent"));
        }