Example #1
0
        public void BuckyballTest()
        {
            var mol = MoleculeReader.ReadMolfile("NCDK.FaulonSignatures.Data.buckyball.mol");
            var mqg = new MoleculeQuotientGraph(mol);

            Console.Out.WriteLine(mqg);
            Assert.AreEqual(32, mqg.GetVertexCount());
            Assert.AreEqual(49, mqg.GetEdgeCount());
            Assert.AreEqual(6, mqg.NumberOfLoopEdges());
        }
Example #2
0
        public void TestLargeExample()
        {
            var filename = "NCDK.FaulonSignatures.Data.large_example.sdf";

            foreach (var molecule in MoleculeReader.ReadSDFFile(filename))
            {
                MoleculeSignature signature = new MoleculeSignature(molecule);
                Console.Out.WriteLine(signature.GetGraphSignature());
            }
        }
Example #3
0
        public void TestSDF()
        {
            var filename = "NCDK.FaulonSignatures.Data.test.sdf";
            int molNr    = 0;

            foreach (var molecule in MoleculeReader.ReadSDFFile(filename))
            {
                Console.Out.WriteLine(++molNr);
                MoleculeSignature signature = new MoleculeSignature(molecule);
                Console.Out.WriteLine(signature.GetGraphSignature());
                //Console.Out.WriteLine(signature.GetVertexSignature(0));
            }
        }
Example #4
0
        public void BuckyballWithoutMultipleBonds()
        {
            var mol = MoleculeReader.ReadMolfile("NCDK.FaulonSignatures.Data.buckyball.mol");

            foreach (Molecule.Bond bond in mol.Bonds())
            {
                bond.order = Molecule.BondOrder.Single;
            }
            var mqg = new MoleculeQuotientGraph(mol);

            Console.Out.WriteLine(mqg);
            Assert.AreEqual(1, mqg.GetVertexCount());
            Assert.AreEqual(1, mqg.GetEdgeCount());
            Assert.AreEqual(1, mqg.NumberOfLoopEdges());
        }
Example #5
0
        public void TestCanonicalLabelling()
        {
            var filename = "NCDK.FaulonSignatures.Data.multCycle.sdf";

            foreach (var molecule in MoleculeReader.ReadSDFFile(filename))
            {
                MoleculeSignature signature = new MoleculeSignature(molecule);
                Console.Out.WriteLine(molecule.GetAtomCount());
                Assert.AreEqual(false, signature.IsCanonicallyLabelled());
            }

            string filenameCanLabel = "NCDK.FaulonSignatures.Data.multCycleCanLabel.sdf";

            foreach (var molecule in MoleculeReader.ReadSDFFile(filenameCanLabel))
            {
                MoleculeSignature signatureCanLabel = new MoleculeSignature(molecule);
                Assert.AreEqual(true, signatureCanLabel.IsCanonicallyLabelled());
            }
        }
Example #6
0
        /// <summary>
        /// Read a list of Molecule from an InputStream, providing SDFile contents
        /// </summary>
        /// <param name="stream">InputStream to read from</param>
        /// <returns>List of Molecules</returns>
        public static List <Molecule> ReadSDFfromStream(Stream stream)
        {
            List <Molecule> molecules = new List <Molecule>();

            try
            {
                using (var reader = new StreamReader(stream))
                {
                    string line;
                    int    i     = 0;
                    var    block = new List <string>();
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.StartsWith("$$$$", StringComparison.Ordinal))
                        {
                            Molecule molecule;
                            try
                            {
                                molecule = MoleculeReader.MakeMolecule(block);
                                molecules.Add(molecule);
                            }
                            catch (Exception e)
                            {
                                Console.Error.WriteLine("failed for block " + i + " " + e);
                                Console.Error.WriteLine(e.StackTrace);
                            }
                            block.Clear();
                            i++;
                        }
                        else
                        {
                            block.Add(line);
                        }
                    }
                }
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.ToString());
            }
            return(molecules);
        }
Example #7
0
        public void FaulonsBuckySignatures()
        {
            var mol = MoleculeReader.ReadMolfile("data/buckyball.mol");

            try
            {
                var filename = "data/buckysigs3.txt";
                var sigs     = ReadSigs2(filename);
                var mqg      = new MoleculeQuotientGraph(mol, sigs);
                Console.Out.WriteLine(mqg);
                Assert.AreEqual(32, mqg.GetVertexCount());
                Assert.AreEqual(49, mqg.GetEdgeCount());
                Assert.AreEqual(6, mqg.NumberOfLoopEdges());
            }
            catch (Exception e)
            {
                Console.Out.WriteLine(e);
                return;
            }
        }
Example #8
0
        public static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.Out.WriteLine("Usage : SDFToSignatures <filename>");
            }
            string filename = args[0];
            int    molCount = 0;

            foreach (var molecule in MoleculeReader.ReadSDFFile(filename))
            {
                try
                {
                    molCount++;
                    Console.Out.WriteLine("Current molecule: " + molCount);
                    MoleculeSignature signature = new MoleculeSignature(molecule);
                    // get graph signature
                    Console.Out.WriteLine(signature.GetGraphSignature());
                }
                catch (Exception) { }
            }
        }