Example #1
0
        public void R_penta_2_3_diene()
        {
            var parser    = new InChIToStructure("InChI=1S/C5H8/c1-3-5-4-2/h3-4H,1-2H3/t5-/m0/s1", CDK.Builder);
            var container = parser.AtomContainer;

            var ses = container.StereoElements.GetEnumerator();

            Assert.IsInstanceOfType(container, CDK.Builder.NewAtomContainer().GetType());
            var f = ses.MoveNext();

            Assert.IsTrue(f);
            var se = ses.Current;

            Assert.IsInstanceOfType(se, typeof(ExtendedTetrahedral));
            ExtendedTetrahedral element = (ExtendedTetrahedral)se;

            Assert.IsTrue(
                Compares.AreEqual(
                    new IAtom[] {
                container.Atoms[5], container.Atoms[0], container.Atoms[1], container.Atoms[6]
            },
                    element.Peripherals));
            Assert.AreEqual(container.Atoms[4], element.Focus);
            Assert.AreEqual(TetrahedralStereo.AntiClockwise, element.Winding);
        }
Example #2
0
        public void TestGetMessage()
        {
            var    parser    = new InChIToStructure("InChI=1S/CH5/h1H4", builder);
            var    container = parser.AtomContainer;
            string message   = parser.Message;

            Assert.IsNotNull(message);
        }
Example #3
0
        public void TestGetAtomContainer()
        {
            var parser    = new InChIToStructure("InChI=1S/CH4/h1H4", builder);
            var container = parser.AtomContainer;

            Assert.IsNotNull(container);
            Assert.AreEqual(1, container.Atoms.Count);
        }
Example #4
0
        public void TestGetReturnStatus_EOF()
        {
            var parser       = new InChIToStructure("InChI=1S", builder);
            var container    = parser.AtomContainer;
            var returnStatus = parser.ReturnStatus;

            Assert.IsNotNull(returnStatus);
            Assert.AreEqual(InChIReturnCode.EOF, returnStatus);
        }
Example #5
0
        public void Diazene()
        {
            InChIToStructure parse = new InChIToStructure("InChI=1S/H2N2/c1-2/h1-2H/b2-1+",
                                                          CDK.Builder);
            IAtomContainer mol = parse.AtomContainer;

            Assert.AreEqual(4, mol.Atoms.Count);
            Assert.AreEqual(true, mol.StereoElements.Any());
        }
Example #6
0
        public void AtomicOxygen()
        {
            var parser    = new InChIToStructure("InChI=1S/O", builder);
            var container = parser.AtomContainer;

            Assert.IsInstanceOfType(container, builder.NewAtomContainer().GetType());
            Assert.IsNotNull(container.Atoms[0].ImplicitHydrogenCount);
            Assert.AreEqual(0, container.Atoms[0].ImplicitHydrogenCount);
        }
Example #7
0
        public void TestGetAtomContainer_IChemObjectBuilder()
        {
            var parser    = new InChIToStructure("InChI=1S/CH5/h1H4", builder);
            var container = parser.AtomContainer;

            // test if the created IAtomContainer is done with the Silent module...
            // OK, this is not typical use, but maybe the above generate method should be private
            Assert.IsInstanceOfType(container, builder.NewAtomContainer().GetType());
        }
Example #8
0
        public void TestGetWarningFlags()
        {
            var parser    = new InChIToStructure("InChI=1S/CH5/h1H4", builder);
            var container = parser.AtomContainer;
            var flags     = parser.WarningFlags;

            Assert.IsNotNull(flags);
            Assert.AreEqual(4, flags.Count);
        }
Example #9
0
        public void TestFixedHydrogens()
        {
            var parser    = new InChIToStructure("InChI=1/CH2O2/c2-1-3/h1H,(H,2,3)/f/h2H", builder);
            var container = parser.AtomContainer;

            Assert.IsNotNull(container);
            Assert.AreEqual(3, container.Atoms.Count);
            Assert.AreEqual(2, container.Bonds.Count);
            Assert.IsTrue(container.Bonds[0].Order == BondOrder.Double || container.Bonds[1].Order == BondOrder.Double);
        }
Example #10
0
        public void HeavyOxygenWater()
        {
            var parser    = new InChIToStructure("InChI=1S/H2O/h1H2/i1+2", builder);
            var container = parser.AtomContainer;

            Assert.IsNotNull(container.Atoms[0].ImplicitHydrogenCount);
            Assert.IsInstanceOfType(container, builder.NewAtomContainer().GetType());
            Assert.IsNotNull(container.Atoms[0].ImplicitHydrogenCount);
            Assert.AreEqual(2, container.Atoms[0].ImplicitHydrogenCount);
            Assert.AreEqual(18, container.Atoms[0].MassNumber);
        }
Example #11
0
        public void NonNullAtomicNumbers()
        {
            var parser    = new InChIToStructure("InChI=1S/CH4/h1H4", builder);
            var container = parser.AtomContainer;

            foreach (var atom in container.Atoms)
            {
                Assert.IsNotNull(atom.AtomicNumber);
            }
            Assert.IsNotNull(container);
            Assert.AreEqual(1, container.Atoms.Count);
        }
Example #12
0
        public void Z_bute_2_ene()
        {
            var parser    = new InChIToStructure("InChI=1/C4H8/c1-3-4-2/h3-4H,1-2H3/b4-3-", builder);
            var container = parser.AtomContainer;
            var ses       = container.StereoElements.GetEnumerator();

            Assert.IsInstanceOfType(container, builder.NewAtomContainer().GetType());
            Assert.IsTrue(ses.MoveNext());
            var se = ses.Current;

            Assert.IsInstanceOfType(se, typeof(IDoubleBondStereochemistry));
            Assert.AreEqual(DoubleBondConformation.Together, ((IDoubleBondStereochemistry)se).Stereo);
        }
        static void Main()
        {
            string inchi = "inchi";

            #region
            // Get InChIToStructure
            InChIToStructure intostruct = InChIToStructure.FromInChI(inchi, ChemObjectBuilder.Instance);

            InChIReturnCode ret = intostruct.ReturnStatus;
            if (ret == InChIReturnCode.Warning)
            {
                // Structure generated, but with warning message
                Console.WriteLine($"InChI warning: {intostruct.Message}");
            }
            else if (ret != InChIReturnCode.Ok)
            {
                // Structure generation failed
                throw new CDKException($"Structure generation failed: {ret.ToString()} [{intostruct.Message}]");
            }
            IAtomContainer container = intostruct.AtomContainer;
            #endregion
        }
Example #14
0
        public void TestConstructor_String_IChemObjectBuilder()
        {
            var parser = new InChIToStructure("InChI=1S/CH4/h1H4", builder);

            Assert.IsNotNull(parser);
        }
Example #15
0
        public void TestGetInChIToStructure_String_IChemObjectBuilder_List()
        {
            var parser = InChIToStructure.FromInChI("InChI=1/ClH/h1H", ChemObjectBuilder.Instance, new List <string>());

            Assert.IsNotNull(parser);
        }
Example #16
0
 public void TestGetInChIToStructure_String_IChemObjectBuilder_NullList()
 {
     InChIToStructure.FromInChI("InChI=1/ClH/h1H", ChemObjectBuilder.Instance, (List <string>)null);
 }