Example #1
0
        public void test1()
        {
            string strQmol = "[H]/N=C(C)/N1CCCCC1"; //shows problem!
            //string strQmol = "[H]/N=C(C)/N"; // still shows problem
            //string strQmol = "[H]/N=C(C)/C"; // no problem
            //string strQmol = "[H]/N=C(C)/C(C)(C)"; // no problem again
            // string strLmol = "[H]/N=C(C)/N1CCCCC1CCC";
            string       strLmol = "N(C(=N([H])[H])c1cccc(C=CCN(C(=O)CCC(=O)OCC)c2ccc(OC3CCN(C(=N[H])C)CC3)c(C(F)(F)F)c2)c1)([H])[H]";
            IndigoObject qmol    = indigo.loadQueryMolecule(strQmol);


            IndigoObject mol = indigo.loadMolecule(strLmol);

            System.Diagnostics.Debug.WriteLine("QueryMol 1: " + qmol.smiles());

            //qmol.clearCisTrans();

            //

            string problem = mol.checkAmbiguousH();

            problem = mol.checkBadValence();

            System.Diagnostics.Debug.WriteLine("QueryMol 2: " + qmol.smiles());
            System.Diagnostics.Debug.WriteLine("Largermol is : " + mol.smiles());

            IndigoObject matcher = indigo.substructureMatcher(mol);

            indigo.setOption("embedding-uniqueness", "atoms");
            foreach (IndigoObject m in matcher.iterateMatches(qmol))
            {
                System.Diagnostics.Debug.WriteLine(m.highlightedTarget().smiles());
            }
        }
Example #2
0
        /// <summary>
        /// Returns whether the chemical structure contains a specified substructure.
        /// </summary>
        /// <param name="substructureQuery">The specified substructure to search for.</param>
        /// <returns>True if this chemical structure contains the specified substructure.</returns>
        public bool HasSubstructure(ChemicalStructure substructureQuery)
        {
            bool hasSubstructure = false;

            using (Indigo indigo = new Indigo())
            {
                // Load inputs.
                IndigoObject structure    = CreateIndigoStructure(indigo);
                IndigoObject substructure = indigo.loadQueryMolecule(substructureQuery.MolfileContents);

                // Perform the match.
                IndigoObject substructureMatcher = indigo.substructureMatcher(structure);
                hasSubstructure = (substructureMatcher.match(substructure) != null);

                // Dispose.
                structure.Dispose();
                substructure.Dispose();
                substructureMatcher.Dispose();
            }

            return(hasSubstructure);
        }
Example #3
0
        static void Main(string[] args)
        {
            Indigo indigo = new Indigo();

            // By default Bingo loads a database and stores all the data in RAM for faster operations
            // But if the application is limited in the memory usage Bingo can work
            // in a file mode with loading only minor parts of data into the memory
            Bingo database = Bingo.createDatabaseFile(indigo, "db1", "molecule", "storage:file");

            // Insert structures from the file
            using (IndigoObject input = indigo.iterateSmilesFile("input.smi"))
                foreach (IndigoObject obj in input)
                {
                    Console.WriteLine("  Object: {0}", obj.name());

                    // When loading from SMILES the only information that we have is an object name
                    // that is stored on the same line with the SMILES in the file
                    int id = int.Parse(obj.name());

                    // Insert loaded object into the database
                    database.insert(obj, id);

                    // Dispose native Indigo object as .NET object is much smaller than native object
                    // and GC can postpone disposing of this object resulting in a large memory
                    // consumption
                    obj.Dispose();
                }

            // Bingo can also assign structure ID automatically
            int autoId1 = database.insert(indigo.loadMolecule("OC1C(C(=O)O)=CC=CC1O"));

            Console.WriteLine("Automatic id = {0}", autoId1);

            int autoId2 = database.insert(indigo.loadMolecule("OC1C(C(=O)O)=CC=CC1O"));

            Console.WriteLine("Automatic id = {0}", autoId2);

            // Search over the database
            Console.WriteLine("Search Benzene:");
            IndigoObject query  = indigo.loadQueryMolecule("C1=CC=CC=C1");
            BingoObject  search = database.searchSub(query);

            while (search.next())
            {
                Console.WriteLine("  Found id = {0}", search.getCurrentId());
            }

            // You can close and reopen database at any moment
            database.close();
            // Load Bingo in a RAM mode with caching all data into the memory
            // Search operations works faster in this mode
            database = Bingo.loadDatabaseFile(indigo, "db1", "molecule", "storage:ram");

            // Search the same query but in the aromatic form
            // Results are the same
            Console.WriteLine("Search Benzene in the aromatic form:");
            query  = indigo.loadQueryMolecule("c1ccccc1");
            search = database.searchSub(query);
            while (search.next())
            {
                Console.WriteLine("  Found id = {0}", search.getCurrentId());
            }

            Console.WriteLine("Search C=O");
            query = indigo.loadQueryMolecule("C=O");
            // Using block will automatically call search.Dispose() that calls search.close()
            // to terminate further search
            using (search = database.searchSub(query))
            {
                int count = 0;
                while (search.next())
                {
                    Console.WriteLine("  Found id = {0}", search.getCurrentId());
                    count++;
                    if (count == 4)
                    {
                        break;
                    }
                }
            }

            // Similarity search
            Console.WriteLine("Similarity search:");
            query  = indigo.loadMolecule("NC1C=CC=C(C1O)C(O)=O");
            search = database.searchSim(query, 0.7f, 1.0f);
            while (search.next())
            {
                Console.WriteLine("  Found id = {0}", search.getCurrentId());
            }

            // Database will be closed automatically in the object destructor
            // but we can close it manually to dispose memory
            database.close();
        }