Hi, Working in C++, I am calling ForwardsSDMolSupplier's method "atEnd()", expecting that it returns false if there are more molecules and true if there are no more molecules. As such the line: while (!molSupplier->atEnd()) ought to be the obvious looping test with molSupplier->next() providing the molecules, one per loop. Sadly it seems that atEnd doesn't work. For example if I have a file with 2 molecules in it, the loop executes 3 times. On the first 2 "next()" provides me with the correct molecule. On the third "next()" returns NULL. Then when the loop test is checked for a fourth time atEnd() returns true.
I can work around this very easily so there is no urgency from me, just thought I should make the bug known. Below is code in full that demonstrates the problem. #include <fstream> using namespace std; #include <GraphMol/FileParsers/MolSupplier.h> using namespace RDKit; int main ( int argc, char* argv[]) { MolSupplier* molSupplier = NULL; ifstream in( argv[1] ); molSupplier = new ForwardSDMolSupplier( &in ); int molCount = 0; while (!molSupplier->atEnd()) { ROMol* mol = molSupplier->next(); if (mol == NULL) { cout << "The supplier said it wasn't at the end but returned a NULL mol when asked for the next one." << endl; } else { ++molCount; delete mol; } } cout << "We found " << molCount << " molecules in file \"" << argv[1] << "\"." << endl; in.close(); } Yours, Toby Wright -- InhibOx Ltd. ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss