Thanks a lot for your answer, I have been able to solve my problem. I had not understood previously what OBResidue could do. Concerning GetAminoAcid and GetTypeFromPDB, my mail was not clear. These functions don't exist but I was looking for similar functions.
If later people have the same issues as mines in C++, here is what I did: // First, load protein.pdb in obMol. unsigned int counterAtom=0; for (unsigned int i=0 ; i < obMol.NumResidues() ; i++) { OpenBabel::OBResidue *obResidue; obResidue = obMol.GetResidue(i); for (unsigned int j=1 ; j <= obResidue->GetNumAtoms() ; j++) { OpenBabel::OBAtom *atom; atom = obMol.GetAtom(counterAtom+j); cout << obResidue->GetName() << " " << obResidue->GetAtomID(atom) << "\t" << obResidue->GetSerialNum(atom) << "\t" << atom->GetX() << " " << atom->GetY() << " " << atom->GetZ() << endl; } counterAtom += obResidue->GetNumAtoms() ; } Nicolas 2014-06-06 4:28 GMT-04:00 Pascal Muller <pascal.jm.mul...@gmail.com>: > Hi, > > >> I have a protein structure in a .pdb file. In my program (using the >> C++ API), I load it (with obConversion.ReadFile) in a OBMol. What I am >> trying to do next, is to get data from the residues and the atom types >> of the pdb file. For example, let's say I have this line in my file: >> >> ATOM 4 CD PRO A 1 20.835 45.525 -5.625 1.00 0.00 >> C >> >> I am looking for a function which will tell me that atom 4 is a CD >> atom from a proline. Perhaps something like: >> >> for (unsigned int j=1; j<=obMol.NumAtoms() ; j++ ) { >> OpenBabel::OBAtom *atom; >> atom = obMol.GetAtom(j); >> atom->GetAminoAcid(); >> atom->GetTypeFromPDB(); >> ... >> } >> > > > Sorry, I don't know about doing it in C++ (furthermore,I didn't find > "GetTypeFromPDB" in the API, if you can give me the link? thanks !), but > with pybel, you can try: > > for mol in pybel.readfile("pdb", filename): > for res in openbabel.OBResidueIter(mol.OBMol): > for atom in openbabel.OBResidueAtomIter(res): > print res.GetName(), res.GetAtomID(atom), res.GetSerialNum(atom) > > > Output e.g. > PRO CD 806 > > I guess it could easily be translated in C++. > > Best, > Pascal > > > ------------------------------------------------------------------------------ > Learn Graph Databases - Download FREE O'Reilly Book > "Graph Databases" is the definitive new guide to graph databases and their > applications. Written by three acclaimed leaders in the field, > this first edition is now available. Download your free book today! > http://p.sf.net/sfu/NeoTech > _______________________________________________ > OpenBabel-discuss mailing list > OpenBabel-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss > ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech _______________________________________________ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss