Jchem is not returning cd_ids using Importer class

User 73ad691ca3

21-11-2012 07:15:11

Dear Chemaxon Team,


we are using Importer class(Jchem .Net API) to import the structures and data from .sdf file to database.


After importing the structures to database, we need to get the cd_ids of the imported structures. 


At present, we are able to get the number of imported structures by calling getImportedNumber() method.


But jchem Importer method getImportedIDs() is not returning the results as mentioned in the jchem documentation.


Please let us know, how to get the imported cd_ids using jchem importer class ASAP.


 


Below is the sample code we used for importing the structures from a sdf file.


--------------------sample code - Importing structures to database from sdf file-----------


private static string databaseImport(string inputFile, ConnectionHandler connectionHandler, string structTableName, bool setHaltOnError, int linesToCheck, string connections)
        {
            try
            {


                Importer importer = new Importer();


                importer.setInput(inputFile);
                importer.setConnectionHandler(connectionHandler);
                importer.setTableName(structTableName);
                importer.setLinesToCheck(linesToCheck);
                importer.setHaltOnError(setHaltOnError);
                // Checking duplicates may slow down import!
                //importer.setDuplicateImportAllowed(UpdateHandler.DUPLICATE_FILTERING_OFF);
                importer.setDuplicateImportAllowed(UpdateHandler.DUPLICATE_FILTERING_ON);


                importer.setFieldConnections(connections);


                importer.setStoreDuplicates(true);


                // Gather information about file
                importer.init();


                // Import molecules into database table
                int imported = importer.importMols();


                System.Diagnostics.Debug.WriteLine("==>import start");
                System.Diagnostics.Debug.WriteLine(importer.getImportedNumber().ToString());


                int[] array = importer.getImportedIDs().toArray();


                if (array != null && array.Length > 0)
                {
                    foreach (int id in array)
                    {
                        System.Diagnostics.Debug.WriteLine(id.ToString());
                    }
                }
                System.Diagnostics.Debug.WriteLine("==>import end");
               


                /*
                //check progress
                 *
                while (importer.isFinished() == false)
                {
                    System.Diagnostics.Debug.WriteLine(importer.getImportedNumber().ToString());
                }
                 */


                return imported.ToString();


            }
            catch
            {
                throw;
            }
        }


--------------------------------------------------------


Thanks & Regards,


D. Senthil kumar vijai.

ChemAxon d9cc14700b

21-11-2012 12:29:52

Hi,


In order to retrieve the cd_ids of the imported structures, you need to setup the importer to store them. This can be done with calling Importer.setStoreImportedIDs(boolean) prior starting the import.


 


Best Regards,
Gabor