I've fixed this in the development version. - Noel
On 11 August 2010 10:19, Noel O'Boyle <[email protected]> wrote: > Your code is correct. > > Behind the scenes something has gone wrong with AddHydrogens(). Almost > in the first line of that function, it sets the AddedHydrogens Flags. > Then, it immediately calls Begin/EndModify() which wipes *all* flags > from the molecule. I'm pretty sure this is not the right thing to do, > although it apparently fixed some bug (PR#1665519). > > I could just move the Begin/EndModify to earlier in the function and > that would solve your immediate problem. I'm not so familiar with > EndModify though, and so am ccing to Geoff for comment... > > - Noel > > On 10 August 2010 18:21, Alex Henderson <[email protected]> wrote: >> Hi, >> >> I don't know if I'm doing something wrong (always a good chance of that!), >> but I seem to get the wrong answer when I ask if a molecule has hydrogens. >> Could someone please set me on the right track, I'm kind of new to >> OpenBabel. >> >> Thanks, >> Alex >> >> System: >> Windows Vista; Visual Studio 2008; OpenBabel trunk updated 10 Aug 2010 >> >> Example code: >> >> #include <string> >> #include <sstream> >> #include <openbabel/mol.h> >> #include <openbabel/obconversion.h> >> >> int main() >> { >> std::string smiles = "CCO"; >> std::stringstream smilesStream(smiles); >> OpenBabel::OBConversion conv(&smilesStream); >> OpenBabel::OBMol mol; >> >> conv.SetInFormat("smi"); >> conv.Read(&mol); >> >> int numberOfAtomsBefore = mol.NumAtoms(); // 3 >> >> bool resultOfAdding = mol.AddHydrogens(); // true >> bool resultOfChecking = mol.HasHydrogensAdded(); // false >> >> int numberOfAtomsAfter = mol.NumAtoms(); // 9 >> >> return 0; >> } >> >> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by >> >> Make an app they can't live without >> Enter the BlackBerry Developer Challenge >> http://p.sf.net/sfu/RIM-dev2dev >> _______________________________________________ >> OpenBabel-Devel mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/openbabel-devel >> >> > ------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev _______________________________________________ OpenBabel-Devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbabel-devel
