Bump! Here is a very dirty fix. Torsion changes across any bond in proline will rotate the corresponding atoms properly.
Nick void createSingleBond(OBMol& mol, OBAtom * start, OBAtom * end) { OBBond *bond = mol.NewBond(); bond->SetBegin(start); bond->SetEnd(end); bond->SetBondOrder(1); start->AddBond(bond); end->AddBond(bond); double dist = start->GetDistance(end); bond->SetLength(dist); cout << "New bond length: " << dist << endl; } OBAtom * getAtomByAtomID(OBResidue *res, string type) { for (OBAtom * atom : res->GetAtoms()) { string atomID = res->GetAtomID(atom); boost::trim(atomID); if (atomID == type) { return atom; } } return NULL; } void fixProlines(OBMol & mol) { for (int a = 0; a < mol.NumResidues(); a++) { OBResidue* res = mol.GetResidue(a); if (res->GetName() == "PRO") { std::vector<OBBond *> bonds = res->GetBonds(false); OBAtom * CA = getAtomByAtomID(res, "CA"); OBAtom * CB = getAtomByAtomID(res, "CB"); OBAtom * CG = getAtomByAtomID(res, "CG"); OBAtom * CD = getAtomByAtomID(res, "CD"); if (CA == NULL || CB == NULL || CG == NULL || CD == NULL) { cout << "Cannot find proline ring carbons! Torsion updates will not work." << endl; cout << CA << " " << CB << " " << CG << " " << CD << endl; return; } string names[4] = { "CA", "CB", "CG", "CD" }; OBAtom connect[4] = { CA, CB, CG, CD }; for (int a = 0; a < 3; a++) { if (!connect[a]->IsConnected(connect[a + 1])) { cout << names[a] << " and " << names[a + 1] << " are not connected in OBMol, connecting." << endl; createSingleBond(mol, connect[a], connect[a + 1]); } } } } } ________________________________________ From: Browning Nicholas John Sent: Thursday, January 12, 2017 6:53 PM To: OpenBabel-Devel@lists.sourceforge.net Subject: Proline Bond Lists Dear All, I've noticed a problem with OB's internal representation of Proline. It's essentially missing a bond. Here's a bonds list of a PDB containing a single, standard Proline: vector<OBBond*> resbonds = res->GetBonds(false); cout << "---BONDS---" << endl; for (int b = 0; b < resbonds.size(); b++) { OBAtom* beginAtom = resbonds[b]->GetBeginAtom(); OBAtom* endAtom = resbonds[b]->GetEndAtom(); cout << res->GetAtomID(beginAtom) << "---" << res->GetAtomID(endAtom) << endl; } ---BONDS--- CA --- N N --- CD CD --- HD2 CD --- HD3 CB --- CG HG3--- CG CG --- HG2 HB3--- CB CA --- CB CB --- HB2 HA --- CA CA --- C C --- O As you can see, CD - CG is missing. This is important to fix, as anycode trying to modify Psi/Phi angles through SetTorsion(...) will inherently break for Prolines. Cheers, Nick PS: Below is the Proline PDB entry. Excuse the formatting, outlook does not like copypasta. ATOM 13 N PRO 2 18.343 22.469 0.670 N ATOM 14 CD PRO 2 18.562 21.226 1.430 C ATOM 15 HD2 PRO 2 18.753 22.245 1.765 H ATOM 16 HD3 PRO 2 19.309 20.557 1.858 H ATOM 17 CG PRO 2 17.148 20.774 1.723 C ATOM 18 HG2 PRO 2 16.438 20.207 2.325 H ATOM 19 HG3 PRO 2 18.078 20.213 1.634 H ATOM 20 CB PRO 2 16.526 21.128 0.228 C ATOM 21 HB2 PRO 2 15.701 21.008 0.929 H ATOM 22 HB3 PRO 2 16.205 20.816 -0.766 H ATOM 23 CA PRO 2 16.959 22.548 0.197 C ATOM 24 HA PRO 2 16.973 22.781 -0.868 H ATOM 25 C PRO 2 16.177 23.607 0.933 C ATOM 26 O PRO 2 16.455 23.874 2.099 O ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ OpenBabel-Devel mailing list OpenBabel-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-devel