diff --git a/.github/workflows/build-coot-with-coot-zerokara.yml b/.github/workflows/build-coot-with-coot-zerokara.yml index 7313fa7080..add2fe9a01 100644 --- a/.github/workflows/build-coot-with-coot-zerokara.yml +++ b/.github/workflows/build-coot-with-coot-zerokara.yml @@ -8,6 +8,8 @@ name: Coot CI (coot_zerokara build script) on: push: + branches: + - main workflow_dispatch: jobs: diff --git a/MoleculesToTriangles/CXXClasses/AtomPropertyRampColorRule.h b/MoleculesToTriangles/CXXClasses/AtomPropertyRampColorRule.h index 179fec24cb..b1f1e3b30d 100644 --- a/MoleculesToTriangles/CXXClasses/AtomPropertyRampColorRule.h +++ b/MoleculesToTriangles/CXXClasses/AtomPropertyRampColorRule.h @@ -220,7 +220,7 @@ class AtomPropertyRampColorRule : public ColorRule { if (value > endValue) value = endValue; } else if (rampType == BFactor){ - value= atom->tempFactor; + value= atom->tempFactor(); if (value < startValue) value = startValue; if (value > endValue) value = endValue; } else { diff --git a/MoleculesToTriangles/CXXClasses/BondsPrimitive.cpp b/MoleculesToTriangles/CXXClasses/BondsPrimitive.cpp index 9c9d8c9bb4..9c317ac8c3 100644 --- a/MoleculesToTriangles/CXXClasses/BondsPrimitive.cpp +++ b/MoleculesToTriangles/CXXClasses/BondsPrimitive.cpp @@ -45,7 +45,7 @@ void BondsPrimitive::evaluateGLPrimitives(std::map, i unsigned long midpointIndex = 0; int iBond = 0; for (; centralAtomPntr != bonds.end(); ++centralAtomPntr, iAtom++){ - FCXXCoord atom1Coord(centralAtomPntr->first->x, centralAtomPntr->first->y, centralAtomPntr->first->z, 0.); + FCXXCoord atom1Coord(centralAtomPntr->first->x(), centralAtomPntr->first->y(), centralAtomPntr->first->z(), 0.); FCXXCoord atom1Color = colorScheme->colorForAtom(centralAtomPntr->first, handles); for (int i=0; i<4; i++) { vertexColorArray[iAtom].vertex[i] = atom1Coord[i]; @@ -54,7 +54,7 @@ void BondsPrimitive::evaluateGLPrimitives(std::map, i std::vector::iterator bondedAtomPntr = centralAtomPntr->second.begin(); for (; bondedAtomPntr != centralAtomPntr->second.end(); ++bondedAtomPntr, iMidpoint++){ midpointIndex = bonds.size() + iMidpoint; - FCXXCoord atom2Coord((*bondedAtomPntr)->x, (*bondedAtomPntr)->y, (*bondedAtomPntr)->z, 0.); + FCXXCoord atom2Coord((*bondedAtomPntr)->x(), (*bondedAtomPntr)->y(), (*bondedAtomPntr)->z(), 0.); FCXXCoord midpoint = (atom1Coord + atom2Coord) / 2.; for (int i=0; i<4; i++) { vertexColorArray[midpointIndex].vertex[i] = midpoint[i]; diff --git a/MoleculesToTriangles/CXXClasses/CylindersPrimitive.cpp b/MoleculesToTriangles/CXXClasses/CylindersPrimitive.cpp index 3594f55552..5b08553c98 100644 --- a/MoleculesToTriangles/CXXClasses/CylindersPrimitive.cpp +++ b/MoleculesToTriangles/CXXClasses/CylindersPrimitive.cpp @@ -28,8 +28,8 @@ void CylindersPrimitive::addHalfAtomBond(mmdb::Atom* atom1, FCXXCoord &atom1Color, mmdb::Atom* atom2, FCXXCoord &atom2Color, float cylinderRadius) { - FCXXCoord coord1(atom1->x, atom1->y, atom1->z); - FCXXCoord coord2(atom2->x, atom2->y, atom2->z); + FCXXCoord coord1(atom1->x(), atom1->y(), atom1->z()); + FCXXCoord coord2(atom2->x(), atom2->y(), atom2->z()); addHalfAtomBondWithCoords(coord1, atom1, atom1Color, coord2,atom2, atom2Color, cylinderRadius); } diff --git a/MoleculesToTriangles/CXXClasses/DiscreteSegment.h b/MoleculesToTriangles/CXXClasses/DiscreteSegment.h index 62be785a4b..6d3e2ada1f 100644 --- a/MoleculesToTriangles/CXXClasses/DiscreteSegment.h +++ b/MoleculesToTriangles/CXXClasses/DiscreteSegment.h @@ -54,17 +54,17 @@ class DiscreteSegment { } void addCalpha(mmdb::Atom* calpha){ calphas.push_back(calpha); - calphaCoords.push_back(FCXXCoord (calpha->x, calpha->y, calpha->z, 1.0f)); + calphaCoords.push_back(FCXXCoord (calpha->x(), calpha->y(), calpha->z(), 1.0f)); anisoValues.push_back(std::make_tuple(1.0f, 1.0f, 1.0f)); } void addCalpha(mmdb::Atom* calpha, float radius){ calphas.push_back(calpha); - calphaCoords.push_back(FCXXCoord (calpha->x, calpha->y, calpha->z, radius)); + calphaCoords.push_back(FCXXCoord (calpha->x(), calpha->y(), calpha->z(), radius)); anisoValues.push_back(std::make_tuple(1.0f, 1.0f, 1.0f)); } void addCalpha(mmdb::Atom* calpha, float ax, float ay, float az){ calphas.push_back(calpha); - calphaCoords.push_back(FCXXCoord (calpha->x, calpha->y, calpha->z, 1.0f)); + calphaCoords.push_back(FCXXCoord (calpha->x(), calpha->y(), calpha->z(), 1.0f)); anisoValues.push_back(std::make_tuple(ax, ay, az)); } std::tuple anisoFor(float xVal) { @@ -72,7 +72,7 @@ class DiscreteSegment { return std::make_tuple(aniso.x(), aniso.y(), aniso.z()); } FCXXCoord operator [] (int i) { - return FCXXCoord (calphas[i]->x, calphas[i]->y, calphas[i]->z); + return FCXXCoord (calphas[i]->x(), calphas[i]->y(), calphas[i]->z()); } int nCalphas() { return int(calphas.size()); diff --git a/MoleculesToTriangles/CXXClasses/FlatFanPrimitive.cpp b/MoleculesToTriangles/CXXClasses/FlatFanPrimitive.cpp index eb42ccb320..cc49cfc9a8 100644 --- a/MoleculesToTriangles/CXXClasses/FlatFanPrimitive.cpp +++ b/MoleculesToTriangles/CXXClasses/FlatFanPrimitive.cpp @@ -40,17 +40,17 @@ void FlatFanPrimitive::generateArrays() int index = 0; for (; iAtomx, atom->y, atom->z); + FCXXCoord atomCoord(atom->x(), atom->y(), atom->z()); centre += atomCoord; size_t lastIAtom = iAtom-1; if (iAtom == 0) lastIAtom = atoms.size()-1; mmdb::Atom* lastAtom = atoms[lastIAtom]; - FCXXCoord lastAtomCoord(lastAtom->x, lastAtom->y, lastAtom->z); + FCXXCoord lastAtomCoord(lastAtom->x(), lastAtom->y(), lastAtom->z()); size_t nextIAtom = iAtom+1; if (nextIAtom == atoms.size()) nextIAtom = 0; mmdb::Atom* nextAtom = atoms[nextIAtom]; - FCXXCoord nextAtomCoord(nextAtom->x, nextAtom->y, nextAtom->z); + FCXXCoord nextAtomCoord(nextAtom->x(), nextAtom->y(), nextAtom->z()); FCXXCoord vecAB(lastAtomCoord-atomCoord); FCXXCoord vecAC(nextAtomCoord-atomCoord); diff --git a/MoleculesToTriangles/CXXClasses/MolecularRepresentation.cpp b/MoleculesToTriangles/CXXClasses/MolecularRepresentation.cpp index f368c7dff8..4f5e98dee7 100644 --- a/MoleculesToTriangles/CXXClasses/MolecularRepresentation.cpp +++ b/MoleculesToTriangles/CXXClasses/MolecularRepresentation.cpp @@ -63,7 +63,7 @@ int MolecularRepresentation::drawSpheres() for (int i=0; icolorForAtom(atom1, handles); - FCXXCoord atom1Coord(atom1->x,atom1->y, atom1->z); + FCXXCoord atom1Coord(atom1->x(),atom1->y(), atom1->z()); float atomRadius = CXXUtils::getAtomRadius(mmdb, atom1) * radiusMultiplier; balls->addBall(atom1Coord, atom1Color, atomRadius); @@ -147,7 +147,7 @@ int MolecularRepresentation::drawBondsAsCylinders() if (atom1->isInSelection(selHnd)){ FCXXCoord atom1Color = colorScheme->colorForAtom(atom1, handles); - FCXXCoord atom1Coord(atom1->x,atom1->y, atom1->z); + FCXXCoord atom1Coord(atom1->x(),atom1->y(), atom1->z()); balls->addBall(atom1Coord, atom1Color, ballRadius); //Because we might be restricted to GL_SHORT_INTs in the index array (don't ask !) @@ -165,21 +165,21 @@ int MolecularRepresentation::drawBondsAsCylinders() int nBondedAtoms; mmdb::AtomBond* bondedAtoms; atom1->GetBonds(bondedAtoms, nBondedAtoms); - FCXXCoord coord1(atom1->x, atom1->y, atom1->z); + FCXXCoord coord1(atom1->x(), atom1->y(), atom1->z()); for (int iOtherAtom = 0; iOtherAtom < nBondedAtoms; iOtherAtom++){ mmdb::Atom* atom2 = bondedAtoms[iOtherAtom].atom; if (atom2->GetIndex()>iAtom && atom2->isInSelection(selHnd)){ //Nasty kludge here...MMDB's MakeBonds screws up where there are multiple conformations bool doContinue = false; - if (!strcmp(atom1->altLoc,"") && - !strcmp(atom2->altLoc,"")) { + if (!strcmp(atom1->altLoc(),"") && + !strcmp(atom2->altLoc(),"")) { doContinue = true; } else { - float dx = atom1->x - atom2->x; - float dy = atom1->y - atom2->y; - float dz = atom1->z - atom2->z; + float dx = atom1->x() - atom2->x(); + float dy = atom1->y() - atom2->y(); + float dz = atom1->z() - atom2->z(); float dist = sqrtf (dx*dx + dy*dy + dz*dz); if (dist < 1.9f) doContinue = true; } @@ -242,8 +242,8 @@ int MolecularRepresentation::drawHydrogenBonds() mmdb::Atom* atom2 = selAtoms[contact.id2]; mmdb::Residue* residue1 = atom1->GetResidue(); mmdb::Residue* residue2 = atom2->GetResidue(); - std::string atom1Name = std::string(atom1->name); - std::string atom2Name = std::string(atom2->name); + std::string atom1Name = std::string(atom1->GetAtomName()); + std::string atom2Name = std::string(atom2->GetAtomName()); #ifdef DEBUG_MINE std::cout << residue1->GetSeqNum() << " [" << atom1Name << "]" << residue2->GetSeqNum() << "[" << atom2Name << "[" << std::string(" N ") << "]\n"; #endif @@ -256,8 +256,8 @@ int MolecularRepresentation::drawHydrogenBonds() (atom1Name.compare(std::string(" O "))==0 && atom2Name.compare(std::string(" N "))==0) ) ){ - FCXXCoord atom1Coord(atom1->x, atom1->y, atom1->z); - FCXXCoord atom2Coord(atom2->x, atom2->y, atom2->z); + FCXXCoord atom1Coord(atom1->x(), atom1->y(), atom1->z()); + FCXXCoord atom2Coord(atom2->x(), atom2->y(), atom2->z()); FCXXCoord diff = atom2Coord - atom1Coord; for (int iStep = 1; iStep < 7; iStep++){ float step = (float)iStep / 8.; @@ -308,15 +308,15 @@ int MolecularRepresentation::drawBondsAsNewSticks() atom2->isInSelection(selHnd)){ //Nasty kludge here...MMDB's MakeBonds screws up where there are multiple conformations - if (!strcmp(atom1->altLoc,"") && - !strcmp(atom2->altLoc,"")) { + if (!strcmp(atom1->altLoc(),"") && + !strcmp(atom2->altLoc(),"")) { sticks->addPair(atom1, atom2); nBonds++; } else { - float dx = atom1->x - atom2->x; - float dy = atom1->y - atom2->y; - float dz = atom1->z - atom2->z; + float dx = atom1->x() - atom2->x(); + float dy = atom1->y() - atom2->y(); + float dz = atom1->z() - atom2->z(); float dist = sqrtf (dx*dx + dy*dy + dz*dz); if (dist < 1.9f) { sticks->addPair(atom1, atom2); @@ -384,7 +384,7 @@ int MolecularRepresentation::drawDishyBases() auto riboseAtomIter = dishyBaseIter->ribose_atoms.begin(); for (; riboseAtomIter!= dishyBaseIter->ribose_atoms.end(); ++ riboseAtomIter){ - FCXXCoord coord((*riboseAtomIter)->x, (*riboseAtomIter)->y, (*riboseAtomIter)->z); + FCXXCoord coord((*riboseAtomIter)->x(), (*riboseAtomIter)->y(), (*riboseAtomIter)->z()); FCXXCoord atomColor = colorScheme->colorForAtom(*riboseAtomIter, handles); balls->addBall(coord, atomColor, ballRadius); if (balls->getBalls().size()%100 == 0){ @@ -403,9 +403,9 @@ int MolecularRepresentation::drawDishyBases() } // Draw a stick from ribose_atoms[1] to 1/3 of the way to // centre. - FCXXCoord atom1Coord(dishyBaseIter->ribose_atoms[1]->x, - dishyBaseIter->ribose_atoms[1]->y, - dishyBaseIter->ribose_atoms[1]->z); + FCXXCoord atom1Coord(dishyBaseIter->ribose_atoms[1]->x(), + dishyBaseIter->ribose_atoms[1]->y(), + dishyBaseIter->ribose_atoms[1]->z()); FCXXCoord basePseudoAtomPosition = atom1Coord + (dishyBaseIter->centre - atom1Coord) / 3.; cylinder->addHalfAtomBondWithCoords(atom1Coord, dishyBaseIter->ribose_atoms[1], atom1Color, basePseudoAtomPosition, dishyBaseIter->ribose_atoms[1], atom1Color, @@ -500,7 +500,7 @@ int MolecularRepresentation::drawStickBases() { FCXXCoord atom1Color = colorScheme->colorForAtom(atom_1, handles); FCXXCoord atom2Color = colorScheme->colorForAtom(atom_2, handles); cylinder->addHalfAtomBond(atom_1, atom1Color, atom_2, atom2Color, cylinderRadius); - FCXXCoord atom1Coord(atom_2->x,atom_2->y, atom_2->z); + FCXXCoord atom1Coord(atom_2->x(),atom_2->y(), atom_2->z()); balls->addBall(atom1Coord, atom1Color, ballRadius); } } diff --git a/MoleculesToTriangles/CXXClasses/MyMolecule.cpp b/MoleculesToTriangles/CXXClasses/MyMolecule.cpp index 521e338922..e02c69f80e 100644 --- a/MoleculesToTriangles/CXXClasses/MyMolecule.cpp +++ b/MoleculesToTriangles/CXXClasses/MyMolecule.cpp @@ -326,13 +326,13 @@ int MyMolecule::identifySegments(std::vector &segments, int s mmdb::Atom* calpha = atomsOfResidue[iAtom]; if (std::string(calpha->segID) == *segIDIter){ //std::cout << calpha->segID << "oops\n"; - if (!strcmp(calpha->name," CA ") && + if (!strcmp(calpha->GetAtomName()," CA ") && calpha->isInSelection(selHnd)){ //Consider only the main alternative location - if (!strcmp(calpha->altLoc,"") || - !strcmp(calpha->altLoc,"A") || - calpha->occupancy > 0.5){ - FCXXCoord calphaPosition(calpha->x, calpha->y, calpha->z); + if (!strcmp(calpha->altLoc(),"") || + !strcmp(calpha->altLoc(),"A") || + calpha->occupancy() > 0.5){ + FCXXCoord calphaPosition(calpha->x(), calpha->y(), calpha->z()); FCXXCoord difference = calphaPosition - lastCoord; float distance = difference.get3DLength(); if (distance > 4.1){ @@ -370,11 +370,11 @@ int MyMolecule::identifySegments(std::vector &segments, int s residue_p->GetAtomTable(residue_atoms, nAtoms); for (int iAtom=0; iAtom < nAtoms; iAtom++){ mmdb::Atom* atom_p = residue_atoms[iAtom]; - std::string atom_name(atom_p->name); + std::string atom_name(atom_p->GetAtomName()); // if (atom_name == " P ") { if (atom_name == " C3'") { if (atom_p->isInSelection(selHnd)) { - FCXXCoord atom_pos(atom_p->x, atom_p->y, atom_p->z); + FCXXCoord atom_pos(atom_p->x(), atom_p->y(), atom_p->z()); FCXXCoord difference = atom_pos - lastCoord; float distance = difference.get3DLength(); // std::cout << "distance " << distance << std::endl; almost all less than 7.5A @@ -475,7 +475,7 @@ int MyMolecule::identifyDishyBases(std::map for (int iAtom=0; iAtom < nAtoms; iAtom++){ mmdb::Atom* atom_p = residue_atoms[iAtom]; if (! atom_p->isTer()) { - std::string atom_alt_conf(atom_p->altLoc); + std::string atom_alt_conf(atom_p->altLoc()); residue_alt_confs_set.insert(atom_alt_conf); } } @@ -503,8 +503,8 @@ int MyMolecule::identifyDishyBases(std::map std::vector ribose_atoms(5,0); for (int iAtom=0; iAtom < nAtoms; iAtom++){ mmdb::Atom* atom_p = residue_atoms[iAtom]; - std::string atom_name(atom_p->name); - std::string atom_alt_conf(atom_p->altLoc); + std::string atom_name(atom_p->GetAtomName()); + std::string atom_alt_conf(atom_p->altLoc()); if (atom_alt_conf.empty() || (residue_alt_confs_set.find(atom_alt_conf) != residue_alt_confs_set.end())) { if (std::find(ref_base_names.begin(), ref_base_names.end(), atom_name) != ref_base_names.end()) { @@ -530,19 +530,19 @@ int MyMolecule::identifyDishyBases(std::map // FCXXCoord ribose_centre; for (std::size_t i=0; i<5; i++) { - FCXXCoord pos(ribose_atoms[i]->x, ribose_atoms[i]->y, ribose_atoms[i]->z); + FCXXCoord pos(ribose_atoms[i]->x(), ribose_atoms[i]->y(), ribose_atoms[i]->z()); ribose_centre += pos; } ribose_centre *= 0.2; FCXXCoord base_centre; for (std::size_t i=0; ix, base_atoms[i]->y, base_atoms[i]->z); + FCXXCoord pos(base_atoms[i]->x(), base_atoms[i]->y(), base_atoms[i]->z()); base_centre += pos; } base_centre /= float(base_atoms.size()); std::vector base_atom_positions(base_atoms.size()); for (unsigned int i=0; ix, base_atoms[i]->y, base_atoms[i]->z); + base_atom_positions[i] = FCXXCoord(base_atoms[i]->x(), base_atoms[i]->y(), base_atoms[i]->z()); DishyPlaneLSQ_t lsq(base_atom_positions); FCXXCoord base_normal = lsq.normal(); DishyBase_t db(base_centre, base_normal, radius, ribose_atoms, ribose_centre); @@ -598,8 +598,8 @@ int MyMolecule::identifyBonds() mmdb::Atom* CA_i = residue->GetAtom("CA", " C", "*"); mmdb::Atom* CA_i_minus_1 = lastResidue->GetAtom("CA", " C", "*"); if (CA_i != 0 && CA_i_minus_1 != 0) { - FCXXCoord Coord_CA_i( CA_i->x, CA_i->y, CA_i->z); - FCXXCoord Coord_CA_i_minus_1( CA_i_minus_1->x, CA_i_minus_1->y, CA_i_minus_1->z); + FCXXCoord Coord_CA_i( CA_i->x(), CA_i->y(), CA_i->z()); + FCXXCoord Coord_CA_i_minus_1( CA_i_minus_1->x(), CA_i_minus_1->y(), CA_i_minus_1->z()); FCXXCoord delta = (Coord_CA_i-Coord_CA_i_minus_1); if(delta.get3DLength()<4.1){ mmdb::Atom* N_i = residue->GetAtom("N", " N", "*"); diff --git a/MoleculesToTriangles/CXXClasses/SecondaryColorScheme.h b/MoleculesToTriangles/CXXClasses/SecondaryColorScheme.h index ab3d033036..2c3673e195 100644 --- a/MoleculesToTriangles/CXXClasses/SecondaryColorScheme.h +++ b/MoleculesToTriangles/CXXClasses/SecondaryColorScheme.h @@ -53,7 +53,7 @@ class SecondaryColorScheme : public ColorScheme { FCXXCoord result = FCXXCoord (1.,1.,1.,0.); std::vector::iterator pair = pairs.begin(); while (pair != pairs.end()){ - if (atom->residue->SSE == pair->getSecondary()){ + if (atom->GetResidue()->SSE == pair->getSecondary()){ result = pair->getColor(); } pair++; diff --git a/MoleculesToTriangles/CXXClasses/SticksPrimitive.cpp b/MoleculesToTriangles/CXXClasses/SticksPrimitive.cpp index aca3e0c11a..dcbcc26c60 100644 --- a/MoleculesToTriangles/CXXClasses/SticksPrimitive.cpp +++ b/MoleculesToTriangles/CXXClasses/SticksPrimitive.cpp @@ -50,7 +50,7 @@ void SticksPrimitive::generateArrays() if (atom1Iter == vcLookup.end()){ FCXXCoord color1 = colorScheme->colorForAtom(atom1, handles); VertexColor vc1 = { - {static_cast(atom1->x), static_cast(atom1->y), static_cast(atom1->z), 0.}, + {static_cast(atom1->x()), static_cast(atom1->y()), static_cast(atom1->z()), 0.}, {static_cast(color1[0]), static_cast(color1[1]), static_cast(color1[2]), static_cast(color1[3])} }; vcLookup[atom1] = vc1; @@ -67,7 +67,7 @@ void SticksPrimitive::generateArrays() if (atom2Iter == vcLookup.end()){ FCXXCoord color2 = colorScheme->colorForAtom(atom2, handles); VertexColor vc2 = { - {static_cast(atom2->x), static_cast(atom2->y), static_cast(atom2->z), 0.}, + {static_cast(atom2->x()), static_cast(atom2->y()), static_cast(atom2->z()), 0.}, {static_cast(color2[0]), static_cast(color2[1]), static_cast(color2[2]), static_cast(color2[3])} }; vcLookup[atom2] = vc2; @@ -102,7 +102,7 @@ void SticksPrimitive::generateArrays() for (; mapIter != mapEnd; ++mapIter){ mmdb::Atom *atom1 = mapIter->first; unsigned long atom1Index = indexLookup[atom1]; - FCXXCoord atom1Coord(atom1->x, atom1->y, atom1->z); + FCXXCoord atom1Coord(atom1->x(), atom1->y(), atom1->z()); FCXXCoord color1 = colorScheme->colorForAtom(atom1, handles); std::vector &bondsOfAtom(mapIter->second); @@ -111,7 +111,7 @@ void SticksPrimitive::generateArrays() for (; vecIter != vecEnd; ++vecIter){ mmdb::Atom *atom2 = *vecIter; unsigned long atom2Index = indexLookup[atom2]; - FCXXCoord atom2Coord(atom2->x, atom2->y, atom2->z); + FCXXCoord atom2Coord(atom2->x(), atom2->y(), atom2->z()); FCXXCoord color2 = colorScheme->colorForAtom(atom2, handles); FCXXCoord midCoord((atom1Coord + atom2Coord) * 0.5); diff --git a/MoleculesToTriangles/CXXSurface/CXXBall.h b/MoleculesToTriangles/CXXSurface/CXXBall.h index c07e760521..1284590cd9 100644 --- a/MoleculesToTriangles/CXXSurface/CXXBall.h +++ b/MoleculesToTriangles/CXXSurface/CXXBall.h @@ -72,7 +72,7 @@ class CXXAtomBall: public CXXBall { static CXXSphereElement unitSphereAtOrigin; public: CXXAtomBall(mmdb::Atom* theAtom_in, const double &radius_in) : theAtom (theAtom_in), theRadius(radius_in){ - theCoord=CXXCoord(theAtom->x, theAtom->y, theAtom->z); + theCoord=CXXCoord(theAtom->x(), theAtom->y(), theAtom->z()); }; virtual const double &getRadius() const{ return theRadius; diff --git a/MoleculesToTriangles/CXXSurface/CXXCircle.cpp b/MoleculesToTriangles/CXXSurface/CXXCircle.cpp index 85950932e9..ec8565c4d7 100644 --- a/MoleculesToTriangles/CXXSurface/CXXCircle.cpp +++ b/MoleculesToTriangles/CXXSurface/CXXCircle.cpp @@ -65,7 +65,7 @@ completelyEaten(0), nodeNumber(0), containsEatenNodes(0) { - centreOfSecondSphere = CXXCoord(theAtomJ->x, theAtomJ->y, theAtomJ->z); + centreOfSecondSphere = CXXCoord(theAtomJ->x(), theAtomJ->y(), theAtomJ->z()); theNormal = centreOfSecondSphere - getCentreOfSphere(); radiusOfSecondSphere = radiusOfAtom2 + probeRadius; diff --git a/MoleculesToTriangles/CXXSurface/CXXCircleNode.cpp b/MoleculesToTriangles/CXXSurface/CXXCircleNode.cpp index 094fac0176..3fc4ce9636 100644 --- a/MoleculesToTriangles/CXXSurface/CXXCircleNode.cpp +++ b/MoleculesToTriangles/CXXSurface/CXXCircleNode.cpp @@ -235,13 +235,13 @@ bool CXXCircleNode::shouldDeletePointer(CXXCircleNode* &aNodePointer){ bool CXXCircleNode::equals(CXXCircleNode &node1, CXXCircleNode &node2){ std::vectorijkCentral(3); std::vectorijkOther(3); - ijkCentral[0] = node1.getAtomI()->serNum; - ijkCentral[1] = node1.getAtomJ()->serNum; - ijkCentral[2] = node1.getAtomK()->serNum; + ijkCentral[0] = node1.getAtomI()->serNum(); + ijkCentral[1] = node1.getAtomJ()->serNum(); + ijkCentral[2] = node1.getAtomK()->serNum(); sort(ijkCentral.begin(), ijkCentral.end()); - ijkOther[0] = node2.getAtomI()->serNum; - ijkOther[1] = node2.getAtomJ()->serNum; - ijkOther[2] = node2.getAtomK()->serNum; + ijkOther[0] = node2.getAtomI()->serNum(); + ijkOther[1] = node2.getAtomJ()->serNum(); + ijkOther[2] = node2.getAtomK()->serNum(); sort(ijkOther.begin(), ijkOther.end()); if (ijkCentral[0] != ijkOther[0]) return false; if (ijkCentral[1] != ijkOther[1]) return false; diff --git a/MoleculesToTriangles/CXXSurface/CXXCreator.cpp b/MoleculesToTriangles/CXXSurface/CXXCreator.cpp index ed1681a5b9..7fdfb8afed 100644 --- a/MoleculesToTriangles/CXXSurface/CXXCreator.cpp +++ b/MoleculesToTriangles/CXXSurface/CXXCreator.cpp @@ -134,9 +134,9 @@ CXXCoordCXXCreator::getAtomCoord(int atomNr) { if(SelAtom){ mmdb::Atom* theAtom = SelAtom[atomNr]; if(theAtom){ - theCoord.setX(theAtom->x); - theCoord.setY(theAtom->y); - theCoord.setZ(theAtom->z); + theCoord.setX(theAtom->x()); + theCoord.setY(theAtom->y()); + theCoord.setZ(theAtom->z()); } } return theCoord; @@ -153,7 +153,7 @@ double CXXCreator::getAtomRadius(int atomNr) { if(SelAtom){ mmdb::Atom* theAtom = SelAtom[atomNr]; if(theAtom){ - radius = mmdb::getVdWaalsRadius(theAtom->element); + radius = mmdb::getVdWaalsRadius(theAtom->GetElementName()); } } return radius; @@ -170,7 +170,7 @@ string CXXCreator::getAtomElement(int atomNr) { } mmdb::Atom* theAtom = SelAtom[atomNr]; - theElement = theAtom->element; + theElement = theAtom->GetElementName(); return theElement; } @@ -184,7 +184,7 @@ string CXXCreator::getAtomName(int atomNr) { throw theException; } mmdb::Atom* theAtom = SelAtom[atomNr]; - theName = theAtom->name; + theName = theAtom->GetAtomName(); return theName; @@ -217,7 +217,7 @@ double CXXCreator::lookUpCharge(int atomNr) { if(SelAtom){ mmdb::Atom* theAtom = SelAtom[atomNr]; if(theAtom){ - theCharge = SelAtom[atomNr]->charge; + theCharge = SelAtom[atomNr]->charge(); } } return theCharge; diff --git a/MoleculesToTriangles/CXXSurface/CXXNewHood.cpp b/MoleculesToTriangles/CXXSurface/CXXNewHood.cpp index 69c5a795f9..aa6430eda7 100644 --- a/MoleculesToTriangles/CXXSurface/CXXNewHood.cpp +++ b/MoleculesToTriangles/CXXSurface/CXXNewHood.cpp @@ -49,7 +49,7 @@ CXXNewHood::CXXNewHood(mmdb::Atom* centralAtom, double radiusOfAtom1, double pro theAtomI(centralAtom), theRadius(radiusOfAtom1+probeRadius), theProbeRadius(probeRadius){ - theCentre = CXXCoord(theAtomI->x, theAtomI->y, theAtomI->z); + theCentre = CXXCoord(theAtomI->x(), theAtomI->y(), theAtomI->z()); } void CXXNewHood::initWith(const CXXCircleNode &aNode, double probeRadius) { @@ -67,12 +67,12 @@ void CXXNewHood::initWith(const CXXBall *aBall){ }; int CXXNewHood::addAtom(mmdb::Atom* anAtomJ, double radiusOfAtom2){ - if (anAtomJ->serNum == theAtomI->serNum) { + if (anAtomJ->serNum() == theAtomI->serNum()) { // std::cout << "Rejecting self " << anAtomJ->serNum << " " << theAtomI->serNum << endl; return 0; //Worried this might not be unique } double radiusOfAtomJ = radiusOfAtom2 + theProbeRadius; - CXXCoordcentreOfAtomJ = CXXCoord(anAtomJ->x, anAtomJ->y, anAtomJ->z); + CXXCoordcentreOfAtomJ = CXXCoord(anAtomJ->x(), anAtomJ->y(), anAtomJ->z()); CXXCoordcentreOfAtomI = theCentre; //This test is to deal with unlikely but possible event of being fed asphere with identical coordinates diff --git a/MoleculesToTriangles/CXXSurface/CXXNewHood.h b/MoleculesToTriangles/CXXSurface/CXXNewHood.h index d3b73ef13c..0add6d08e9 100644 --- a/MoleculesToTriangles/CXXSurface/CXXNewHood.h +++ b/MoleculesToTriangles/CXXSurface/CXXNewHood.h @@ -61,7 +61,7 @@ class CXXNewHood{ theAtomI= atomI; theRadius = radiusOfAtom1 + probeRadius; theProbeRadius = probeRadius; - theCentre = CXXCoord(atomI->x, atomI->y, atomI->z); + theCentre = CXXCoord(atomI->x(), atomI->y(), atomI->z()); }; void initWith(const CXXCircleNode &aNode, double probeRadius); void initWith(const CXXBall *aBall); diff --git a/MoleculesToTriangles/CXXSurface/CXXQADSurface.cpp b/MoleculesToTriangles/CXXSurface/CXXQADSurface.cpp index 84002b24bf..d6ef97ba9e 100644 --- a/MoleculesToTriangles/CXXSurface/CXXQADSurface.cpp +++ b/MoleculesToTriangles/CXXSurface/CXXQADSurface.cpp @@ -143,12 +143,12 @@ int CXXQADSurface::prepareGrids (){ xyzMax[i] = -1e30; } for (int i=0; i< nSelectedAtoms; i++){ - xyzMin[0] = fmin(xyzMin[0], selectedAtoms[i]->x); - xyzMin[1] = fmin(xyzMin[1], selectedAtoms[i]->y); - xyzMin[2] = fmin(xyzMin[2], selectedAtoms[i]->z); - xyzMax[0] = fmax(xyzMax[0], selectedAtoms[i]->x); - xyzMax[1] = fmax(xyzMax[1], selectedAtoms[i]->y); - xyzMax[2] = fmax(xyzMax[2], selectedAtoms[i]->z); + xyzMin[0] = fmin(xyzMin[0], selectedAtoms[i]->x()); + xyzMin[1] = fmin(xyzMin[1], selectedAtoms[i]->y()); + xyzMin[2] = fmin(xyzMin[2], selectedAtoms[i]->z()); + xyzMax[0] = fmax(xyzMax[0], selectedAtoms[i]->x()); + xyzMax[1] = fmax(xyzMax[1], selectedAtoms[i]->y()); + xyzMax[2] = fmax(xyzMax[2], selectedAtoms[i]->z()); } //Expand max and min coordinates by maximum estimated atom radius + probe radius + 1 grid point @@ -211,9 +211,9 @@ int CXXQADSurface::makeDistanceSqMap(){ Grid_range gd (clipperCell, clipperGridSampling, accessibleRadius); - Coord_orth atomCoordOrth(selectedAtoms[iAtom]->x, - selectedAtoms[iAtom]->y, - selectedAtoms[iAtom]->z); + Coord_orth atomCoordOrth(selectedAtoms[iAtom]->x(), + selectedAtoms[iAtom]->y(), + selectedAtoms[iAtom]->z()); Coord_frac uvw = atomCoordOrth.coord_frac( clipperCell); Coord_grid g0 = uvw.coord_grid(clipperGridSampling) + gd.min(); @@ -270,9 +270,9 @@ int CXXQADSurface::addProbesFromVdwSurface(){ for (int iAtom = 0; iAtom < nSelectedAtoms; iAtom++){ double vdwRadius = fastGetAtomRadius(iAtom); - Coord_orth atomCoordOrth(selectedAtoms[iAtom]->x, - selectedAtoms[iAtom]->y, - selectedAtoms[iAtom]->z); + Coord_orth atomCoordOrth(selectedAtoms[iAtom]->x(), + selectedAtoms[iAtom]->y(), + selectedAtoms[iAtom]->z()); Coord_frac uvw = atomCoordOrth.coord_frac( clipperCell); Grid_range gd (clipperCell, clipperGridSampling, vdwRadius); @@ -536,7 +536,7 @@ int CXXQADSurface::coordIsBuriedByNeighbours(Coord_orth &point,int iAtom1){ for (unsigned iAtom2 = 0; iAtom2x, Atom2->y, Atom2->z); + Coord_orth atomCoordOrth(Atom2->x(), Atom2->y(), Atom2->z()); double accessibleRadius = fastGetAtomRadius(iAtom2)+probeRadius; double accessibleRadiusSq = accessibleRadius * accessibleRadius; double dx = point[0] - atomCoordOrth[0]; @@ -824,9 +824,9 @@ double CXXQADSurface::getAtomRadius(mmdb::Atom* theAtom){ double theRadius; if (iRadiusHandle>0){ int success = theAtom->GetUDData (iRadiusHandle, theRadius); - if (success != mmdb::UDDATA_Ok) theRadius = mmdb::getVdWaalsRadius(theAtom->element); + if (success != mmdb::UDDATA_Ok) theRadius = mmdb::getVdWaalsRadius(theAtom->GetElementName()); } - else theRadius = mmdb::getVdWaalsRadius(theAtom->element); + else theRadius = mmdb::getVdWaalsRadius(theAtom->GetElementName()); return theRadius; } @@ -899,7 +899,7 @@ int CXXQADSurface::toruses() for (int atomNr = 0;atomNr < nSelectedAtoms; atomNr++) { mmdb::Atom* centralAtom = selectedAtoms[atomNr]; - Coord_orth atomCoordOrth(centralAtom->x, centralAtom->y, centralAtom->z); + Coord_orth atomCoordOrth(centralAtom->x(), centralAtom->y(), centralAtom->z()); Coord_frac uvw = atomCoordOrth.coord_frac(clipperCell); Grid_range gd (clipperCell, clipperGridSampling, getAtomRadius(centralAtom)+probeRadius); Coord_grid g0 = uvw.coord_grid(clipperGridSampling) + gd.min(); @@ -927,7 +927,7 @@ int CXXQADSurface::toruses() ++circleIter){ CXXCircle &theCircle(*circleIter); - if (centralAtom->serNum < theCircle.getAtomJ()->serNum){ + if (centralAtom->serNum() < theCircle.getAtomJ()->serNum()){ if (theCircle.nSegments()>0){ const CXXCoord&torusCentre(theCircle.getCentreOfCircle()); const CXXCoord&torusAxis(theCircle.getNormal()); @@ -1046,8 +1046,8 @@ int CXXQADSurface::toruses() ++nodeIter){ const CXXCircleNode &aNode(*nodeIter); if (!aNode.isDeleted()){ - if (aNode.getAtomK()->serNum > aNode.getAtomJ()->serNum && - aNode.getAtomJ()->serNum > aNode.getAtomI()->serNum){ + if (aNode.getAtomK()->serNum() > aNode.getAtomJ()->serNum() && + aNode.getAtomJ()->serNum() > aNode.getAtomI()->serNum()){ CXXCoordnodeCXXCoord(aNode.getCoord()); Coord_orth newProbe(nodeCXXCoord[0], nodeCXXCoord[1], nodeCXXCoord[2]); allowProbeToEatWithinGridRange(newProbe, gdAtom); diff --git a/MoleculesToTriangles/CXXSurface/CXXSphereElement.cpp b/MoleculesToTriangles/CXXSurface/CXXSphereElement.cpp index 559945d722..874cddc095 100644 --- a/MoleculesToTriangles/CXXSurface/CXXSphereElement.cpp +++ b/MoleculesToTriangles/CXXSurface/CXXSphereElement.cpp @@ -61,7 +61,7 @@ theAtom(anAtom), deltaRadians(del) { init(); - theCentre = CXXCoord(anAtom->x, anAtom->y, anAtom->z); + theCentre = CXXCoord(anAtom->x(), anAtom->y(), anAtom->z()); calculate(); } @@ -293,9 +293,9 @@ void CXXSphereElement::initWith(const CXXCircleNode &aNode, double delta, mmdb::Atom* atomJ=aNode.getAtomJ(); mmdb::Atom* atomI=aNode.getAtomI(); - CXXCoordu1(atomK->x, atomK->y, atomK->z); - CXXCoordu2(atomJ->x, atomJ->y, atomJ->z); - CXXCoordu3(atomI->x, atomI->y, atomI->z); + CXXCoordu1(atomK->x(), atomK->y(), atomK->z()); + CXXCoordu2(atomJ->x(), atomJ->y(), atomJ->z()); + CXXCoordu3(atomI->x(), atomI->y(), atomI->z()); u1 = u1 - theCentre; u1.normalise(); @@ -349,9 +349,9 @@ void CXXSphereElement::initWith(const CXXCoord&aCentre, mmdb::At deltaRadians=delta; init(); - CXXCoordu1(atomK->x, atomK->y, atomK->z); - CXXCoordu2(atomJ->x, atomJ->y, atomJ->z); - CXXCoordu3(atomI->x, atomI->y, atomI->z); + CXXCoordu1(atomK->x(), atomK->y(), atomK->z()); + CXXCoordu2(atomJ->x(), atomJ->y(), atomJ->z()); + CXXCoordu3(atomI->x(), atomI->y(), atomI->z()); u1 = u1 - theCentre; u1.normalise(); diff --git a/MoleculesToTriangles/CXXSurface/CXXSurface.cpp b/MoleculesToTriangles/CXXSurface/CXXSurface.cpp index 7f9ea7b6e1..d2dfd011f9 100644 --- a/MoleculesToTriangles/CXXSurface/CXXSurface.cpp +++ b/MoleculesToTriangles/CXXSurface/CXXSurface.cpp @@ -465,7 +465,7 @@ int CXXSurface::assignAtom (mmdb::Manager* allAtomsManager_in, int selHnd){ const CXXCoord&vertex = coordRef(vectors["vertices"], i); int j; for (j = 0, minDistSq=1e30; jatom (selAtom[j]->x, selAtom[j]->y, selAtom[j]->z); + CXXCoordatom (selAtom[j]->x(), selAtom[j]->y(), selAtom[j]->z()); CXXCoorddiff = atom - vertex; double dxsq = diff.x() * diff.x(); if (dxsqname[1]){ + switch (theAtom->GetAtomName()[1]){ case 'C': vertices[i].setXyz(vectors["colour"], greenColour); break; diff --git a/MoleculesToTriangles/CXXSurface/CXXSurfaceMaker.cpp b/MoleculesToTriangles/CXXSurface/CXXSurfaceMaker.cpp index 6ceda9d219..c85caad36f 100644 --- a/MoleculesToTriangles/CXXSurface/CXXSurfaceMaker.cpp +++ b/MoleculesToTriangles/CXXSurface/CXXSurfaceMaker.cpp @@ -79,7 +79,7 @@ double CXXSurfaceMaker::getAtomRadius(mmdb::Atom *theAtom) theRadius = 1.8; } else - theRadius = mmdb::getVdWaalsRadius(theAtom->element); + theRadius = mmdb::getVdWaalsRadius(theAtom->GetElementName()); return theRadius; } diff --git a/MoleculesToTriangles/CXXSurface/CXXUtils.cpp b/MoleculesToTriangles/CXXSurface/CXXUtils.cpp index ef8ea45973..a069c2a7ad 100644 --- a/MoleculesToTriangles/CXXSurface/CXXUtils.cpp +++ b/MoleculesToTriangles/CXXSurface/CXXUtils.cpp @@ -33,11 +33,11 @@ int CXXUtils::assignCharge(mmdb::Manager* theManager, int selHnd, CXXChargeTable //Assign atom charges for (int iAtom = 0; iAtom < nSelAtoms; iAtom++) { mmdb::Atom* theAtom = SelAtom[iAtom]; - string atomName(theAtom->name); - string residueName(theAtom->residue->name); + string atomName(theAtom->GetAtomName()); + string residueName(theAtom->GetResidue()->GetResName()); double theAtomCharge; theAtomCharge = theChargeTable->getCharge(residueName, atomName); - theAtom->charge = theAtomCharge; + theAtom->charge() = theAtomCharge; } return 0; } @@ -83,10 +83,10 @@ int CXXUtils::assignUnitedAtomRadius (mmdb::Manager* theManager, int selHnd) { for (int iAtom = 0; iAtom < nSelAtoms; iAtom++) { mmdb::Atom* anAtom = SelAtom[iAtom]; - std::string atomName(anAtom->name); + std::string atomName(anAtom->GetAtomName()); std::string residueName("* "); - if (anAtom->residue != NULL){ - residueName = std::string(anAtom->residue->name); + if (anAtom->GetResidue() != NULL){ + residueName = std::string(anAtom->GetResidue()->GetResName()); } std::map >::iterator residueMapIter = mappedRadii.find(residueName); @@ -114,7 +114,7 @@ double CXXUtils::getAtomRadius(mmdb::Manager* theManager, mmdb::Atom* theAtom){ int success = theAtom->GetUDData (iRadiusHandle, theRadius); if (success != mmdb::UDDATA_Ok) theRadius = 1.8; } - else theRadius = mmdb::getVdWaalsRadius(theAtom->element); + else theRadius = mmdb::getVdWaalsRadius(theAtom->GetElementName()); return theRadius; } @@ -188,7 +188,7 @@ int CXXUtils::unCharge(mmdb::Manager* theManager, int selHnd){ //Assign atom charges for (int iAtom = 0; iAtom < nSelAtoms; iAtom++) { mmdb::Atom* theAtom = SelAtom[iAtom]; - theAtom->charge = 0.; + theAtom->charge() = 0.; } return 0; } diff --git a/analysis/b-factor-histogram.cc b/analysis/b-factor-histogram.cc index 08072366c5..7d56f2dfaf 100644 --- a/analysis/b-factor-histogram.cc +++ b/analysis/b-factor-histogram.cc @@ -45,7 +45,7 @@ coot::b_factor_histogram::b_factor_histogram(mmdb::Manager *mol) { int n_atoms_in_residue = residue_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - const float &b = at->tempFactor; + const float &b = at->tempFactor(); if (b >= 0.0) { n_atoms++; if (b > b_max) { @@ -76,7 +76,7 @@ coot::b_factor_histogram::b_factor_histogram(mmdb::Manager *mol) { int n_atoms_in_residue = residue_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - const float &b = at->tempFactor; + const float &b = at->tempFactor(); if (b >= 0.0) { int bin_idx = b_to_bin(b); b_vector[bin_idx].push_back(b); @@ -100,7 +100,7 @@ coot::b_factor_histogram::b_factor_histogram(mmdb::Manager *mol, int atom_select mol->GetSelIndex(atom_selection_handle, atom_selection, n_selection_atoms); for (int i=0; itempFactor; + const float &b = at->tempFactor(); if (b >= 0.0) { n_atoms++; if (b > b_max) { @@ -115,7 +115,7 @@ coot::b_factor_histogram::b_factor_histogram(mmdb::Manager *mol, int atom_select b_vector.resize(n_bins); for (int i=0; itempFactor; + const float &b = at->tempFactor(); if (b >= 0.0) { int bin_idx = b_to_bin(b); b_vector[bin_idx].push_back(b); diff --git a/analysis/bfkurt.cc b/analysis/bfkurt.cc index 59bad012c3..68be369231 100644 --- a/analysis/bfkurt.cc +++ b/analysis/bfkurt.cc @@ -160,10 +160,10 @@ coot_extras::b_factor_analysis::stats(mmdb::Residue *residue_p) const { residue_p->GetAtomTable(residue_atoms, nResidueAtoms); if (nResidueAtoms > 0) { for (int i=0; ielement; + std::string ele = residue_atoms[i]->GetElementName(); if ((ele != " H") && (ele != " D")) { - bf = residue_atoms[i]->tempFactor; - occ = residue_atoms[i]->occupancy; + bf = residue_atoms[i]->tempFactor(); + occ = residue_atoms[i]->occupancy(); // ignore atoms with silly (or shelx?) B factors and occs if (((bf > 0.0) && (occ >= 0.0) && (occ <= 1.0)) || (is_mol_from_shelx_flag && (occ < 11.001) && (occ>10.999))) { @@ -181,7 +181,7 @@ coot_extras::b_factor_analysis::stats(mmdb::Residue *residue_p) const { } } mmdb::Atom *intel_at = coot::util::intelligent_this_residue_mmdb_atom(residue_p); - my_stats.atom_name = intel_at->name; + my_stats.atom_name = intel_at->GetAtomName(); double div = occ_sum; if (div > 0) { mean = running_sum / div; diff --git a/analysis/cablam.cc b/analysis/cablam.cc index 427b83a27b..52fb148c08 100644 --- a/analysis/cablam.cc +++ b/analysis/cablam.cc @@ -32,9 +32,9 @@ coot::cablam::get_closest_CA_CA_approach(const coot::torsion_atom_quad &quad) co // // get_closest_CA_CA_approach(CA_pos_p, CA_pos_t, O_pos_p); - clipper::Coord_orth CA_p(quad.atom_1->x, quad.atom_1->y, quad.atom_1->z); - clipper::Coord_orth CA_t(quad.atom_2->x, quad.atom_2->y, quad.atom_2->z); - clipper::Coord_orth O_t(quad.atom_4->x, quad.atom_4->y, quad.atom_4->z); + clipper::Coord_orth CA_p(quad.atom_1->x(), quad.atom_1->y(), quad.atom_1->z()); + clipper::Coord_orth CA_t(quad.atom_2->x(), quad.atom_2->y(), quad.atom_2->z()); + clipper::Coord_orth O_t(quad.atom_4->x(), quad.atom_4->y(), quad.atom_4->z()); clipper::Coord_orth PT = CA_t - CA_p; clipper::Coord_orth PT_unit(PT.unit()); @@ -135,11 +135,11 @@ coot::cablam::cablam(mmdb::PResidue *residues, int n_sel_residues) { if (CA_m_2 && CA_m_1 && CA_0 && CA_p_1 && CA_p_2) { - std::string ac_m_2 = CA_m_2->altLoc; - std::string ac_m_1 = CA_m_1->altLoc; - std::string ac_0 = CA_0->altLoc; - std::string ac_p_1 = CA_p_1->altLoc; - std::string ac_p_2 = CA_p_2->altLoc; + std::string ac_m_2 = CA_m_2->altLoc(); + std::string ac_m_1 = CA_m_1->altLoc(); + std::string ac_0 = CA_0->altLoc(); + std::string ac_p_1 = CA_p_1->altLoc(); + std::string ac_p_2 = CA_p_2->altLoc(); if (ac_m_2 == "") { if (ac_m_1 == "") { diff --git a/analysis/daca.cc b/analysis/daca.cc index d1aebf661c..26f945851a 100644 --- a/analysis/daca.cc +++ b/analysis/daca.cc @@ -307,12 +307,12 @@ coot::daca::make_symmetry_typed_atoms(mmdb::Manager *mol, for (int i=0; ix < xmin) xmin = at->x; - if (at->x > xmax) xmax = at->x; - if (at->y < ymin) ymin = at->y; - if (at->y > ymax) ymax = at->y; - if (at->z < zmin) zmin = at->z; - if (at->z > zmax) zmax = at->z; + if (at->x() < xmin) xmin = at->x(); + if (at->x() > xmax) xmax = at->x(); + if (at->y() < ymin) ymin = at->y(); + if (at->y() > ymax) ymax = at->y(); + if (at->z() < zmin) zmin = at->z(); + if (at->z() > zmax) zmax = at->z(); } // Expand bounding box by contact search distance xmin -= expansion_radius; xmax += expansion_radius; @@ -365,9 +365,9 @@ coot::daca::make_symmetry_typed_atoms(mmdb::Manager *mol, if (! at) continue; // Transform the atom position - float tx = mat[0][0]*at->x + mat[0][1]*at->y + mat[0][2]*at->z + mat[0][3]; - float ty = mat[1][0]*at->x + mat[1][1]*at->y + mat[1][2]*at->z + mat[1][3]; - float tz = mat[2][0]*at->x + mat[2][1]*at->y + mat[2][2]*at->z + mat[2][3]; + float tx = mat[0][0]*at->x() + mat[0][1]*at->y() + mat[0][2]*at->z() + mat[0][3]; + float ty = mat[1][0]*at->x() + mat[1][1]*at->y() + mat[1][2]*at->z() + mat[1][3]; + float tz = mat[2][0]*at->x() + mat[2][1]*at->y() + mat[2][2]*at->z() + mat[2][3]; // Quick bounding box test if (tx < xmin || tx > xmax) continue; @@ -377,9 +377,9 @@ coot::daca::make_symmetry_typed_atoms(mmdb::Manager *mol, // This atom is close enough — create a copy with transformed coords mmdb::Atom *new_at = new mmdb::Atom; new_at->Copy(at); - new_at->x = tx; - new_at->y = ty; - new_at->z = tz; + new_at->x() = tx; + new_at->y() = ty; + new_at->z() = tz; new_at->SetResidue(nullptr); // not part of the ASU symm_atom_store_p->push_back(new_at); @@ -597,7 +597,7 @@ coot::daca::get_daca_fragments(mmdb::Residue *reference_residue_p) const { int n_residue_atoms; reference_residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iataltLoc); + std::string alt_loc(residue_atoms[iat]->altLoc()); if (! alt_loc.empty()) { first_alt_conf = alt_loc; break; @@ -617,7 +617,7 @@ coot::daca::get_daca_fragments(mmdb::Residue *reference_residue_p) const { mmdb::Atom *at = residue_atoms[iat]; std::string this_atom_name(at->GetAtomName()); if (atom_name == this_atom_name) { - std::string alt_loc(at->altLoc); + std::string alt_loc(at->altLoc()); if (alt_loc.empty()) { atom_vec.push_back(at); break; @@ -637,7 +637,7 @@ coot::daca::get_daca_fragments(mmdb::Residue *reference_residue_p) const { mmdb::Atom *at = residue_atoms[iat]; std::string this_atom_name(at->GetAtomName()); if (atom_name == this_atom_name) { - std::string alt_loc(at->altLoc); + std::string alt_loc(at->altLoc()); if (alt_loc.empty() || alt_loc == first_alt_conf) { atom_vec.push_back(at); break; @@ -963,9 +963,9 @@ coot::daca::atom_is_close_to_a_residue_atom(mmdb::Atom *at, mmdb::Residue *refer for (int iat=0; iatx - ref_at->x) * (at->x - ref_at->x) + - (at->y - ref_at->y) * (at->y - ref_at->y) + - (at->z - ref_at->z) * (at->z - ref_at->z); + (at->x() - ref_at->x()) * (at->x() - ref_at->x()) + + (at->y() - ref_at->y()) * (at->y() - ref_at->y()) + + (at->z() - ref_at->z()) * (at->z() - ref_at->z()); if (dd < dd_close) { status = true; break; @@ -978,9 +978,9 @@ coot::daca::atom_is_close_to_a_residue_atom(mmdb::Atom *at, mmdb::Residue *refer bool coot::daca::atom_is_neighbour_mainchain(mmdb::Atom *at, mmdb::Residue *reference_residue_p) const { bool status = false; - if (! at->residue) return false; // symmetry atom — not a neighbour - int idx_res_1 = reference_residue_p->index; - int idx_res_2 = at->residue->index; + if (! at->GetResidue()) return false; // symmetry atom — not a neighbour + int idx_res_1 = reference_residue_p->GetIndex(); + int idx_res_2 = at->GetResidue()->GetIndex(); int idx_delta = abs(idx_res_2 - idx_res_1); if (idx_delta < 2) { std::string atom_name(at->GetAtomName()); @@ -1071,23 +1071,23 @@ coot::daca::calculate_daca(mmdb::Residue *reference_residue_p, const std::string &atom_type = typed_atoms[ita].second; // don't consider atoms in this residue, of course - if (at->residue == reference_residue_p) + if (at->GetResidue() == reference_residue_p) continue; // don't consider peptide neighbour mainchain // (symmetry atoms have residue set to nullptr — skip this check for them) - if (at->residue) { - int res_no_delta = at->residue->GetSeqNum() - reference_residue_seqnum; + if (at->GetResidue()) { + int res_no_delta = at->GetResidue()->GetSeqNum() - reference_residue_seqnum; if (std::abs(res_no_delta) < 2) - if (at->residue->chain == reference_residue_p->chain) + if (at->GetResidue()->chain == reference_residue_p->chain) if (is_main_chain_p(at)) continue; } double dd = - (at->x - frag_centre.x()) * (at->x - frag_centre.x()) + - (at->y - frag_centre.y()) * (at->y - frag_centre.y()) + - (at->z - frag_centre.z()) * (at->z - frag_centre.z()); + (at->x() - frag_centre.x()) * (at->x() - frag_centre.x()) + + (at->y() - frag_centre.y()) * (at->y() - frag_centre.y()) + + (at->z() - frag_centre.z()) * (at->z() - frag_centre.z()); if (dd < dd_crit) { // Good, found something if (atom_is_close_to_a_residue_atom(at, reference_residue_p)) { @@ -1620,16 +1620,16 @@ coot::daca::self_test(const std::string &pdb_file_name) { for (unsigned int ita=0; itaresidue == residue_p) continue; - int res_no_delta = at->residue->GetSeqNum() - seqnum; + if (at->GetResidue() == residue_p) continue; + int res_no_delta = at->GetResidue()->GetSeqNum() - seqnum; if (std::abs(res_no_delta) < 2) - if (at->residue->chain == residue_p->chain) + if (at->GetResidue()->chain == residue_p->chain) if (is_main_chain_p(at)) continue; double dd = - (at->x - frag_centre.x()) * (at->x - frag_centre.x()) + - (at->y - frag_centre.y()) * (at->y - frag_centre.y()) + - (at->z - frag_centre.z()) * (at->z - frag_centre.z()); + (at->x() - frag_centre.x()) * (at->x() - frag_centre.x()) + + (at->y() - frag_centre.y()) * (at->y() - frag_centre.y()) + + (at->z() - frag_centre.z()) * (at->z() - frag_centre.z()); if (dd < 64.0) { // 8.0^2 if (atom_is_close_to_a_residue_atom(at, residue_p)) { if (! atom_is_neighbour_mainchain(at, residue_p)) { @@ -1710,9 +1710,9 @@ coot::daca::self_test_perturbed(const std::string &pdb_file_name, float perturba float dx = perturbation * (2.0f * static_cast(rand()) / static_cast(RAND_MAX) - 1.0f); float dy = perturbation * (2.0f * static_cast(rand()) / static_cast(RAND_MAX) - 1.0f); float dz = perturbation * (2.0f * static_cast(rand()) / static_cast(RAND_MAX) - 1.0f); - at->x += dx; - at->y += dy; - at->z += dz; + at->x() += dx; + at->y() += dy; + at->z() += dz; } } @@ -1750,16 +1750,16 @@ coot::daca::self_test_perturbed(const std::string &pdb_file_name, float perturba for (unsigned int ita=0; itaresidue == residue_p) continue; - int res_no_delta = at->residue->GetSeqNum() - seqnum; + if (at->GetResidue() == residue_p) continue; + int res_no_delta = at->GetResidue()->GetSeqNum() - seqnum; if (std::abs(res_no_delta) < 2) - if (at->residue->chain == residue_p->chain) + if (at->GetResidue()->chain == residue_p->chain) if (is_main_chain_p(at)) continue; double dd = - (at->x - frag_centre.x()) * (at->x - frag_centre.x()) + - (at->y - frag_centre.y()) * (at->y - frag_centre.y()) + - (at->z - frag_centre.z()) * (at->z - frag_centre.z()); + (at->x() - frag_centre.x()) * (at->x() - frag_centre.x()) + + (at->y() - frag_centre.y()) * (at->y() - frag_centre.y()) + + (at->z() - frag_centre.z()) * (at->z() - frag_centre.z()); if (dd < 64.0) { // 8.0^2 if (atom_is_close_to_a_residue_atom(at, residue_p)) { if (! atom_is_neighbour_mainchain(at, residue_p)) { @@ -2091,13 +2091,13 @@ coot::daca::solvent_exposure(mmdb::Manager *mol, bool side_chain_only) const { // we could do the selection wthout waters, but also filter out waters this way std::vector is_water(n_atoms, false); for (int iat=0; iatresidue->GetResName()); + std::string rn(atom_selection[iat]->GetResidue()->GetResName()); if (rn == "HOH") is_water[iat] = true; } std::vector radius(n_atoms); for (int iat=0; iatelement); + std::string ele(atom_selection[iat]->GetElementName()); radius[iat] = get_radius(ele); // could be more clever, use atom type. } for (int i=0; iresidue->GetResName()); + std::string rn(at->GetResidue()->GetResName()); if (rn == "HOH") { - std::cout << "HOH " << residue_spec_t(at->residue) + std::cout << "HOH " << residue_spec_t(at->GetResidue()) << " with n-neighbs " << neighbour_atoms.size() << " returning " << count << std::endl; } @@ -2180,7 +2180,7 @@ coot::daca::solvent_exposure(mmdb::Manager *mol, bool side_chain_only) const { n_dots_for_atom = dot_count(atom_index, neighbours, radius[atom_index], atom_selection, unit_sphere_points); - residue_count_map[at->residue] += n_dots_for_atom; + residue_count_map[at->GetResidue()] += n_dots_for_atom; } { @@ -2256,7 +2256,7 @@ coot::daca::solvent_exposure_old_version_v2(mmdb::Manager *mol, mmdb::Residue *residue_p_2 = at_2->GetResidue(); if (residue_p_2 == residue_p_1) continue; std::string res_name_1(residue_p_1->GetResName()); - std::string res_name_2(at_2->residue->GetResName()); + std::string res_name_2(at_2->GetResidue()->GetResName()); if (res_name_1 == "HOH") continue; if (res_name_2 == "HOH") continue; if (! util::is_standard_amino_acid_name(res_name_1)) continue; @@ -2316,7 +2316,7 @@ coot::daca::solvent_exposure_old_version(int SelHnd_in, mmdb::Manager *mol) cons std::vector radius(n_atoms); for (int iat=0; iatelement); + std::string ele(atoms[iat]->GetElementName()); radius[iat] = get_radius(ele); } @@ -2328,9 +2328,9 @@ coot::daca::solvent_exposure_old_version(int SelHnd_in, mmdb::Manager *mol) cons for (int iatom=0; iatomisTer()) { - clipper::Coord_orth centre(atoms[iatom]->x, - atoms[iatom]->y, - atoms[iatom]->z); + clipper::Coord_orth centre(atoms[iatom]->x(), + atoms[iatom]->y(), + atoms[iatom]->z()); bool even = 1; int n_points = 0; int n_sa = 0; @@ -2355,11 +2355,11 @@ coot::daca::solvent_exposure_old_version(int SelHnd_in, mmdb::Manager *mol) cons std::string other_res_name = other_at->GetResName(); if (other_res_name != "HOH") { if (atoms[iatom] != other_at) { - std::string other_ele = other_at->element; + std::string other_ele = other_at->GetElementName(); if (other_ele != " H") { double other_atom_r = fudge * (get_radius(other_ele) + water_radius); double other_atom_r_sq = other_atom_r * other_atom_r; - clipper::Coord_orth pt_other(other_at->x, other_at->y, other_at->z); + clipper::Coord_orth pt_other(other_at->x(), other_at->y(), other_at->z()); if ((pt-pt_other).lengthsq() < other_atom_r_sq) { is_solvent_accessible = 0; break; @@ -2377,7 +2377,7 @@ coot::daca::solvent_exposure_old_version(int SelHnd_in, mmdb::Manager *mol) cons double exposure_frac = double(n_sa)/double(n_points); if (0) - std::cout << "Atom " << atoms[iatom]->name << " has exposure " << n_sa << "/" << n_points + std::cout << "Atom " << atoms[iatom]->GetAtomName() << " has exposure " << n_sa << "/" << n_points << " = " << exposure_frac << std::endl; std::pair p(atoms[iatom], exposure_frac); v.push_back(p); diff --git a/analysis/mogul.cc b/analysis/mogul.cc index 02e558096e..6c2c306c92 100644 --- a/analysis/mogul.cc +++ b/analysis/mogul.cc @@ -387,8 +387,8 @@ coot::mogul::make_restraints(mmdb::Residue *residue_p, int idx_2 = items[i].idx_2 - 1; if (idx_1 >= 0 && idx_1 < n_residue_atoms) { if (idx_2 >= 0 && idx_2 < n_residue_atoms) { - std::string name_1(residue_atoms[idx_1]->name); - std::string name_2(residue_atoms[idx_2]->name); + std::string name_1(residue_atoms[idx_1]->GetAtomName()); + std::string name_2(residue_atoms[idx_2]->GetAtomName()); std::string type; if (current_restraints.first) type = get_bond_type(current_restraints.second, name_1, name_2); @@ -408,9 +408,9 @@ coot::mogul::make_restraints(mmdb::Residue *residue_p, if (idx_1 >= 0 && idx_1 < n_residue_atoms) { if (idx_2 >= 0 && idx_2 < n_residue_atoms) { if (idx_3 >= 0 && idx_3 < n_residue_atoms) { - std::string name_1(residue_atoms[idx_1]->name); - std::string name_2(residue_atoms[idx_2]->name); - std::string name_3(residue_atoms[idx_3]->name); + std::string name_1(residue_atoms[idx_1]->GetAtomName()); + std::string name_2(residue_atoms[idx_2]->GetAtomName()); + std::string name_3(residue_atoms[idx_3]->GetAtomName()); float angle = items[i].median; float esd = items[i].std_dev; dict_angle_restraint_t rest(name_1, name_2, name_3, angle, esd); diff --git a/analysis/typed-distances.cc b/analysis/typed-distances.cc index f7da63b502..a6eae4c594 100644 --- a/analysis/typed-distances.cc +++ b/analysis/typed-distances.cc @@ -186,7 +186,7 @@ coot::typed_distances::atom_type_t coot::typed_distances::get_type(mmdb::Atom *at) const { atom_type_t t1(NONE); - std::string ele(at->element); + std::string ele(at->GetElementName()); if (ele == " C") t1 = atom_type_t(C); if (ele == " O") t1 = atom_type_t(O); if (ele == " S") t1 = atom_type_t(O); diff --git a/api/add-terminal-residue.cc b/api/add-terminal-residue.cc index b0b8586b1b..10b876501b 100644 --- a/api/add-terminal-residue.cc +++ b/api/add-terminal-residue.cc @@ -400,11 +400,11 @@ move_atom(const std::string &atom_name_in, mmdb::Residue *res_p, const clipper:: res_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; iname); + std::string atom_name(at->GetAtomName()); if (atom_name == atom_name_in) { - at->x = new_O_pos.x(); - at->y = new_O_pos.y(); - at->z = new_O_pos.z(); + at->x() = new_O_pos.x(); + at->y() = new_O_pos.y(); + at->z() = new_O_pos.z(); done = true; break; } @@ -444,23 +444,23 @@ move_std_residue(mmdb::Residue *moving_residue, const mmdb::Residue *reference_r if (false) std::cout << "DEBUG:: move_std_residue: " << nResidueAtoms << " atoms in residue " - << moving_residue << " " << moving_residue->seqNum << " " + << moving_residue << " " << moving_residue->GetSeqNum() << " " << moving_residue->GetChainID() << std::endl; for (int iat=0; iatx, - residue_atoms[iat]->y, - residue_atoms[iat]->z); - std::string alt_conf = residue_atoms[iat]->altLoc; + clipper::Coord_orth co(residue_atoms[iat]->x(), + residue_atoms[iat]->y(), + residue_atoms[iat]->z()); + std::string alt_conf = residue_atoms[iat]->altLoc(); std::map::const_iterator it = rtops.find(alt_conf); if (it != rtops.end()) { clipper::Coord_orth rotted = co.transform(it->second); // an rtop - residue_atoms[iat]->x = rotted.x(); - residue_atoms[iat]->y = rotted.y(); - residue_atoms[iat]->z = rotted.z(); + residue_atoms[iat]->x() = rotted.x(); + residue_atoms[iat]->y() = rotted.y(); + residue_atoms[iat]->z() = rotted.z(); } } else { istat = 0; @@ -571,7 +571,7 @@ coot::add_side_chain_to_terminal_res(atom_selection_container_t asc, // set the b factor for the new atoms. for(int i=0; itempFactor = b_factor_for_new_atoms; + std_residue_atoms[i]->tempFactor() = b_factor_for_new_atoms; }; bool verb = false; @@ -589,13 +589,13 @@ coot::add_side_chain_to_terminal_res(atom_selection_container_t asc, } for(int i=0; iname); + std::string residue_this_atom (residue_atoms[i]->GetAtomName()); if (residue_this_atom != " O ") residue_p->DeleteAtom(i); }; for(int i=0; iname); + std::string std_residue_this_atom (std_residue_atoms[i]->GetAtomName()); if (std_residue_this_atom != " O ") { // std::cout << "Adding atom " << std_residue_atoms[i] << std::endl; residue_p->AddAtom(std_residue_atoms[i]); @@ -749,16 +749,16 @@ coot::add_terminal_residue(int imol_no, const std::string &terminus_type, mmdb:: mmdb::Residue *res_tmp_p = residue_p; res_tmp_p->GetAtomTable(residue_atoms, nResidueAtoms); for (int i=0; iname) { + if (atom_name == residue_atoms[i]->GetAtomName()) { terminal_at = residue_atoms[i]; break; } if (terminal_at) { mol->SelectSphere(SelHndSphere, mmdb::STYPE_ATOM, - terminal_at->x, - terminal_at->y, - terminal_at->z, + terminal_at->x(), + terminal_at->y(), + terminal_at->z(), radius, mmdb::SKEY_NEW); mol->GetSelIndex(SelHndSphere, atom_sel, n_selected_atoms); @@ -902,7 +902,7 @@ coot::add_terminal_residue(int imol_no, const std::string &terminus_type, mmdb:: if (is_from_shelx_ins) { for (int i=0; ioccupancy = 11.0; + tmp_asc.atom_selection[i]->occupancy() = 11.0; } } diff --git a/api/coot-molecule-bonds-instanced.cc b/api/coot-molecule-bonds-instanced.cc index 531b3dfe9e..b22f69d2fc 100644 --- a/api/coot-molecule-bonds-instanced.cc +++ b/api/coot-molecule-bonds-instanced.cc @@ -242,7 +242,7 @@ make_instanced_graphical_bonds_spherical_atoms(coot::instanced_mesh_t &m, // add if (sar > 0.65) sar = 0.65f; glm::vec3 sc(sar, sar, sar); - glm::vec3 t(at->x, at->y, at->z); + glm::vec3 t(at->x(), at->y(), at->z()); bool atom_is_aniso = at->WhatIsSet & mmdb::ASET_Anis_tFac; // std::cout << " " << coot::atom_spec_t(at) << " atom_is_aniso " << atom_is_aniso << std::endl; @@ -256,9 +256,9 @@ make_instanced_graphical_bonds_spherical_atoms(coot::instanced_mesh_t &m, // add sc = glm::vec3(sar); - GL_matrix mat(at->u11, at->u12, at->u13, - at->u12, at->u22, at->u23, - at->u13, at->u23, at->u33); + GL_matrix mat(at->u11(), at->u12(), at->u13(), + at->u12(), at->u22(), at->u23(), + at->u13(), at->u23(), at->u33()); std::pair chol_pair = mat.eigensystem(); if (chol_pair.first) { @@ -269,7 +269,7 @@ make_instanced_graphical_bonds_spherical_atoms(coot::instanced_mesh_t &m, // add 0.0f, 0.0f, 0.0f, 1.0f); if (false) std::cout << "atom at " << at << " ori:: " << glm::to_string(ori) - << " Us: " << at->u11 << " " << at->u22 << " " << at->u33 << std::endl; + << " Us: " << at->u11() << " " << at->u22() << " " << at->u33() << std::endl; coot::instancing_data_type_B_t idB(t, col, sc, ori); if (render_aniso_atoms_as_ortep) ig_ortep.instancing_data_B.push_back(idB); @@ -377,7 +377,7 @@ make_instanced_graphical_bonds_hemispherical_atoms(coot::instanced_mesh_t &m, // for (unsigned int i=0; ix, at->y, at->z); + glm::vec3 t(at->x(), at->y(), at->z()); glm::mat4 ori(1.0); // 20230114-PE needs fixing. float scale = 1.0; if (at_info.is_hydrogen_atom) scale *= 0.5; @@ -422,7 +422,7 @@ void make_graphical_bonds_spherical_atoms_with_vdw_radii_instanced(coot::instanc for (unsigned int i=0; ielement); + std::string ele(at->GetElementName()); std::map::const_iterator it = ele_to_radius_map.find(ele); float atom_radius = 1.0; if (it != ele_to_radius_map.end()) { @@ -434,7 +434,7 @@ void make_graphical_bonds_spherical_atoms_with_vdw_radii_instanced(coot::instanc ele_to_radius_map[ele] = atom_radius; } - glm::vec3 t(at->x, at->y, at->z); + glm::vec3 t(at->x(), at->y(), at->z()); glm::vec3 sc(atom_radius, atom_radius, atom_radius); coot::instancing_data_type_A_t id(t, col, sc); ig.instancing_data_A.push_back(id); diff --git a/api/coot-molecule-bonds.cc b/api/coot-molecule-bonds.cc index 11c0e03eea..9f48d645df 100644 --- a/api/coot-molecule-bonds.cc +++ b/api/coot-molecule-bonds.cc @@ -155,7 +155,7 @@ coot::molecule_t::apply_user_defined_atom_colour_selections(const std::vector 0) { for(int iat=0; iatelement); + std::string element(at->GetElementName()); if (element == " C" || colour_applies_to_non_carbon_atoms_also) { int ierr = at->PutUDData(udd_handle, colour_index); if (ierr != mmdb::UDDATA_Ok) { @@ -201,7 +201,7 @@ coot::molecule_t::add_to_non_drawn_bonds(const std::string &atom_selection_cid) if (nSelAtoms > 0) { for(int iat=0; iatresidue); + selected_residues.insert(at->GetResidue()); } } atom_sel.mol->DeleteSelection(selHnd); @@ -569,7 +569,7 @@ void make_graphical_bonds_spherical_atoms_with_vdw_radii(coot::simple_mesh_t &m, for (unsigned int i=0; ielement); + std::string ele(at->GetElementName()); std::map::const_iterator it = ele_to_radius_map.find(ele); float atom_radius = 1.0; if (it != ele_to_radius_map.end()) { @@ -581,7 +581,7 @@ void make_graphical_bonds_spherical_atoms_with_vdw_radii(coot::simple_mesh_t &m, ele_to_radius_map[ele] = atom_radius; } - glm::vec3 t(at->x, at->y, at->z); + glm::vec3 t(at->x(), at->y(), at->z()); glm::vec3 sc(atom_radius, atom_radius, atom_radius); std::vector local_vertices(octosphere_geom.first.size()); @@ -750,7 +750,7 @@ make_graphical_bonds_hemispherical_atoms(coot::simple_mesh_t &m, // fill m mmdb::Atom *other_at = index_to_atom[other_atom_index]; if (other_at) { // std::cout << " other_at " << other_at << " " << coot::atom_spec_t(other_at) << std::endl; - glm::vec3 other_atom_pos(other_at->x, other_at->y, other_at->z); + glm::vec3 other_atom_pos(other_at->x(), other_at->y(), other_at->z()); glm::mat4 mm = get_octahemi_matrix(t, other_atom_pos, bond_radius); // a rotation matrix std::vector local_vertices(octasphere_geom.first.size()); @@ -1920,7 +1920,7 @@ coot::molecule_t::get_simple_molecule(int imol, mmdb::Residue *residue_p, bool d const graphical_bonds_atom_info_t &at_info = gbc.consolidated_atom_centres[icol].points[i]; int fc = 0; bool arom = false; - sm.add_atom(simple::atom_t(at_info.atom_p->GetAtomName(), at_info.atom_p->element, at_info.position, fc, arom)); + sm.add_atom(simple::atom_t(at_info.atom_p->GetAtomName(), at_info.atom_p->GetElementName(), at_info.position, fc, arom)); } } diff --git a/api/coot-molecule-json.cc b/api/coot-molecule-json.cc index f6a071243d..1f32c10cb9 100644 --- a/api/coot-molecule-json.cc +++ b/api/coot-molecule-json.cc @@ -13,16 +13,16 @@ std::string coot::molecule_t::get_molecule_selection_as_json(const std::string & auto atom_to_json = [] (mmdb::Atom *at) { nlohmann::json j; // 2025-10-10-PE add more attributes later - std::string se = util::remove_whitespace(std::string(at->element)); - std::string sn = util::remove_whitespace(std::string(at->name)); - j["x"] = at->x; - j["y"] = at->y; - j["z"] = at->z; - j["tempFactor"] = at->tempFactor; - j["occupancy"] = at->occupancy; + std::string se = util::remove_whitespace(std::string(at->GetElementName())); + std::string sn = util::remove_whitespace(std::string(at->GetAtomName())); + j["x"] = at->x(); + j["y"] = at->y(); + j["z"] = at->z(); + j["tempFactor"] = at->tempFactor(); + j["occupancy"] = at->occupancy(); j["name"] = sn; j["element"] = se; - j["altLoc"] = std::string(at->altLoc); + j["altLoc"] = std::string(at->altLoc()); return j; }; @@ -101,7 +101,7 @@ coot::molecule_t::get_torsions_for_residues_in_chain_as_json(const std::string & for (int i=0; iGetAtom(i); if (at->isTer()) continue; - if (std::string(at->altLoc) != "") + if (std::string(at->altLoc()) != "") return true; } return false; @@ -112,8 +112,8 @@ coot::molecule_t::get_torsions_for_residues_in_chain_as_json(const std::string & for (int i=0; iGetAtom(i); if (!at->isTer()) { - if (std::string(at->name) == name) - return {true, clipper::Coord_orth(at->x, at->y, at->z)}; + if (std::string(at->GetAtomName()) == name) + return {true, clipper::Coord_orth(at->x(), at->y(), at->z())}; } } return {false, clipper::Coord_orth()}; diff --git a/api/coot-molecule-maps.cc b/api/coot-molecule-maps.cc index f4ab346553..15f515be0e 100644 --- a/api/coot-molecule-maps.cc +++ b/api/coot-molecule-maps.cc @@ -1238,9 +1238,9 @@ coot::molecule_t::fit_to_map_by_random_jiggle(mmdb::PPAtom atom_selection, // do it lots of times in jiggle_atoms. Inefficient. std::vector p(3, 0.0); for (int iat=0; iatx; - p[1] += atom_selection[iat]->y; - p[2] += atom_selection[iat]->z; + p[0] += atom_selection[iat]->x(); + p[1] += atom_selection[iat]->y(); + p[2] += atom_selection[iat]->z(); } double fact = 1.0; if (n_atoms) @@ -1526,7 +1526,7 @@ coot::molecule_t::fit_to_map_by_random_jiggle(mmdb::PPAtom atom_selection, for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - clipper::Coord_orth pt(at->x, at->y, at->z); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); float d = coot::util::density_at_point(xmap, pt); std::cout << coot::atom_spec_t(at) << " " << d << std::endl; } @@ -1589,9 +1589,9 @@ coot::molecule_t::fit_to_map_by_random_jiggle(mmdb::PPAtom atom_selection, coot::util::transform_chain(chains_for_moving[ich], bias_rtop); } else { for (int iat=0; iatx += bias.x(); - atom_selection[iat]->y += bias.y(); - atom_selection[iat]->z += bias.z(); + atom_selection[iat]->x() += bias.x(); + atom_selection[iat]->y() += bias.y(); + atom_selection[iat]->z() += bias.z(); } } } else { diff --git a/api/coot-molecule-merge-molecules.cc b/api/coot-molecule-merge-molecules.cc index 78cd07a01e..bea7927865 100644 --- a/api/coot-molecule-merge-molecules.cc +++ b/api/coot-molecule-merge-molecules.cc @@ -246,7 +246,7 @@ coot::molecule_t::merge_molecules_just_one_residue_homogeneous(atom_selection_co std::vector r = coot::util::residue_types_in_chain(this_chain_p); if (r.size() == 1) { - std::string adding_model_resname(molecule_to_add.atom_selection[0]->residue->GetResName()); + std::string adding_model_resname(molecule_to_add.atom_selection[0]->GetResidue()->GetResName()); if (r[0] == adding_model_resname) { // poly-ala helices (say) should not go into concatenated residues in the same chain if (adding_model_resname != "ALA") { @@ -260,7 +260,7 @@ coot::molecule_t::merge_molecules_just_one_residue_homogeneous(atom_selection_co if (has_single_residue_type_chain_flag) { if (molecule_to_add.n_selected_atoms > 0) { - mmdb::Residue *add_model_residue = molecule_to_add.atom_selection[0]->residue; + mmdb::Residue *add_model_residue = molecule_to_add.atom_selection[0]->GetResidue(); copy_and_add_residue_to_chain(add_residue_to_this_chain, add_model_residue); done_homogeneous_addition_flag = true; atom_sel.mol->FinishStructEdit(); @@ -301,7 +301,7 @@ coot::molecule_t::merge_molecules_just_one_residue_at_given_spec(atom_selection_ if (r) { make_backup("merge_molecules_just_one_residue_at_given_spec"); mmdb::Residue *new_residue_p = copy_and_add_residue_to_chain(this_chain_p, r); - new_residue_p->seqNum = target_spec.res_no; + new_residue_p->GetSeqNum() = target_spec.res_no; status = true; } } else { @@ -369,7 +369,7 @@ coot::molecule_t::copy_and_add_residue_to_chain(mmdb::Chain *this_model_chain, int new_res_resno = 9999; if (res_info.first) new_res_resno = res_info.second; - residue_copy->seqNum = new_res_resno; // try changing the seqNum before AddResidue(). + residue_copy->GetSeqNum() = new_res_resno; // try changing the seqNum before AddResidue(). this_model_chain->AddResidue(residue_copy); res_copied = residue_copy; } @@ -597,11 +597,11 @@ coot::molecule_t::next_residue_number_in_chain(mmdb::Chain *w, if (nres > 0) { for (int ires=nres-1; ires>=0; ires--) { residue_p = w->GetResidue(ires); - if (residue_p->seqNum > max_res_no) { - max_res_no = residue_p->seqNum; + if (residue_p->GetSeqNum() > max_res_no) { + max_res_no = residue_p->GetSeqNum(); bool is_het_residue_flag = is_het_residue(residue_p); if (is_het_residue_flag) { - p = std::pair(1, residue_p->seqNum+1); + p = std::pair(1, residue_p->GetSeqNum()+1); } else { if (new_res_no_by_hundreds) { if (max_res_no < 9999) { @@ -623,7 +623,7 @@ coot::molecule_t::next_residue_number_in_chain(mmdb::Chain *w, while (! is_clear) { is_clear = true; for (int iser=0; iserGetResidue(iser)->seqNum; + int resno_res = w->GetResidue(iser)->GetSeqNum(); if (resno_res >= test_resno_start) { if (resno_res <= (test_resno_start+10)) { is_clear = false; diff --git a/api/coot-molecule-modelling.cc b/api/coot-molecule-modelling.cc index feba8fd6a4..7faa900a50 100644 --- a/api/coot-molecule-modelling.cc +++ b/api/coot-molecule-modelling.cc @@ -201,7 +201,7 @@ coot::molecule_t::execute_simple_nucleotide_addition(const std::string &term_typ if (rtop_pair.first) { // fix up the residue number and chain id to match the clicked atom int new_resno = res_p->GetSeqNum() + interesting_resno - match_resno; - interesting_residue_p->seqNum = new_resno; + interesting_residue_p->GetSeqNum() = new_resno; // we always want to remove OP3 from the residue to which a new residue // is added when we add to the "N-terminus" @@ -214,7 +214,7 @@ coot::molecule_t::execute_simple_nucleotide_addition(const std::string &term_typ for (int iat=0; iatname); + std::string at_name(at->GetAtomName()); if (at_name == " OP3") { // PDBv3 FIXME delete at; at = NULL; diff --git a/api/coot-molecule-refine.cc b/api/coot-molecule-refine.cc index 611a7842d9..bce2e1ad3e 100644 --- a/api/coot-molecule-refine.cc +++ b/api/coot-molecule-refine.cc @@ -159,16 +159,16 @@ coot::molecule_t::generate_local_self_restraints(int selHnd, float local_dist_ma mmdb::Atom *at_1 = SelAtom[pscontact[i].id1]; mmdb::Atom *at_2 = SelAtom[pscontact[i].id2]; - std::string ele_1 = at_1->element; - std::string ele_2 = at_2->element; + std::string ele_1 = at_1->GetElementName(); + std::string ele_2 = at_2->GetElementName(); if (ele_1 != " H" && ele_2 != " H") { bool ignore_this = false; // set for bonded and angled atoms bool in_same_res = false; - if (at_1->residue == at_2->residue) + if (at_1->GetResidue() == at_2->GetResidue()) in_same_res = true; if (in_same_res) { - std::string comp_id = at_1->residue->GetResName(); + std::string comp_id = at_1->GetResidue()->GetResName(); std::string at_name_1 = at_1->GetAtomName(); std::string at_name_2 = at_2->GetAtomName(); diff --git a/api/coot-molecule-replace-fragment.cc b/api/coot-molecule-replace-fragment.cc index 89e9ad82fa..e47506c368 100644 --- a/api/coot-molecule-replace-fragment.cc +++ b/api/coot-molecule-replace-fragment.cc @@ -132,9 +132,9 @@ coot::molecule_t::replace_fragment(atom_selection_container_t asc) { if (idx != -1) { mmdb::Atom *ref_atom = atom_sel.atom_selection[idx]; - ref_atom->x = at->x; - ref_atom->y = at->y; - ref_atom->z = at->z; + ref_atom->x() = at->x(); + ref_atom->y() = at->y(); + ref_atom->z() = at->z(); } else { @@ -149,8 +149,8 @@ coot::molecule_t::replace_fragment(atom_selection_container_t asc) { mmdb::Chain *chain_p = new mmdb::Chain; chain_p->SetChainID(at->GetChainID()); residue_p = new mmdb::Residue; - residue_p->seqNum = at->GetSeqNum(); - residue_p->SetResName(at->residue->GetResName()); + residue_p->GetSeqNum() = at->GetSeqNum(); + residue_p->SetResName(at->GetResidue()->GetResName()); chain_p->AddResidue(residue_p); model_p->AddChain(chain_p); atom_sel.mol->PDBCleanup(mmdb::PDBCLEAN_SERIAL|mmdb::PDBCLEAN_INDEX); @@ -161,7 +161,7 @@ coot::molecule_t::replace_fragment(atom_selection_container_t asc) { // std::cout << " ======= found the residue " << std::endl; } else { residue_p = new mmdb::Residue; - residue_p->SetResID(at->residue->GetResName(), at->residue->seqNum, at->residue->insCode); + residue_p->SetResID(at->GetResidue()->GetResName(), at->GetResidue()->GetSeqNum(), at->GetResidue()->GetInsCode()); int res_no = at->GetSeqNum(); std::string ins_code(at->GetInsCode()); std::pair sn = @@ -225,9 +225,9 @@ coot::molecule_t::replace_fragment(mmdb::Manager *mol_ref, int old_atom_index_ha if (ierr == mmdb::UDDATA_Ok) { mmdb::Atom *at = atom_sel.atom_selection[idx]; // std::cout << "replacing position of " << atom_spec_t(at) << " from " << atom_spec_t(at_frag) << std::endl; - at->x = at_frag->x; - at->y = at_frag->y; - at->z = at_frag->z; + at->x() = at_frag->x(); + at->y() = at_frag->y(); + at->z() = at_frag->z(); status = 1; // at least one atom was found } else { std::cout << "GetUDData() failed for " << coot::atom_spec_t(at_frag) << " " << old_atom_index_handle << std::endl; diff --git a/api/coot-molecule-validation.cc b/api/coot-molecule-validation.cc index 2a70557477..23eac762aa 100644 --- a/api/coot-molecule-validation.cc +++ b/api/coot-molecule-validation.cc @@ -736,8 +736,8 @@ coot::molecule_t::get_mesh_for_ligand_validation_vs_dictionary(const std::string mmdb::Atom *at_1 = residue_p->GetAtom(rest.atom_index_1); mmdb::Atom *at_2 = residue_p->GetAtom(rest.atom_index_2); if (at_1 && at_2) { - clipper::Coord_orth p1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth p2(at_2->x, at_2->y, at_2->z); + clipper::Coord_orth p1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth p2(at_2->x(), at_2->y(), at_2->z()); double d = sqrt((p2-p1).lengthsq()); double distortion = d - rest.target_value; double pen_score = fabs(distortion/rest.sigma); @@ -764,9 +764,9 @@ coot::molecule_t::get_mesh_for_ligand_validation_vs_dictionary(const std::string mmdb::Atom *at_2 = residue_p->GetAtom(rest.atom_index_2); mmdb::Atom *at_3 = residue_p->GetAtom(rest.atom_index_3); if (at_1 && at_2 && at_3) { - clipper::Coord_orth p1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth p2(at_2->x, at_2->y, at_2->z); - clipper::Coord_orth p3(at_3->x, at_3->y, at_3->z); + clipper::Coord_orth p1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth p2(at_2->x(), at_2->y(), at_2->z()); + clipper::Coord_orth p3(at_3->x(), at_3->y(), at_3->z()); double angle_rad = clipper::Coord_orth::angle(p1, p2, p3); double angle = clipper::Util::rad2d(angle_rad); double distortion = fabs(angle - rest.target_value); @@ -794,10 +794,10 @@ coot::molecule_t::get_mesh_for_ligand_validation_vs_dictionary(const std::string mmdb::Atom *at_2 = residue_p->GetAtom(rest.atom_index_2); mmdb::Atom *at_3 = residue_p->GetAtom(rest.atom_index_3); if (at_c && at_1 && at_2 && at_3) { - clipper::Coord_orth pc(at_c->x, at_c->y, at_c->z); - clipper::Coord_orth p1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth p2(at_2->x, at_2->y, at_2->z); - clipper::Coord_orth p3(at_3->x, at_3->y, at_3->z); + clipper::Coord_orth pc(at_c->x(), at_c->y(), at_c->z()); + clipper::Coord_orth p1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth p2(at_2->x(), at_2->y(), at_2->z()); + clipper::Coord_orth p3(at_3->x(), at_3->y(), at_3->z()); clipper::Coord_orth bl_1 = 0.6 * pc + 0.4 * p1; clipper::Coord_orth bl_2 = 0.6 * pc + 0.4 * p2; clipper::Coord_orth bl_3 = 0.6 * pc + 0.4 * p3; @@ -825,7 +825,7 @@ coot::molecule_t::get_mesh_for_ligand_validation_vs_dictionary(const std::string mmdb::Atom *at_4th = coot::chiral_4th_atom(residue_p, at_c, at_1, at_2, at_3); if (at_4th) { std::cout << " " << coot::atom_spec_t(at_4th) << std::endl; - clipper::Coord_orth p4(at_4th->x, at_4th->y, at_4th->z); + clipper::Coord_orth p4(at_4th->x(), at_4th->y(), at_4th->z()); clipper::Coord_orth bl_4 = 0.6 * pc + 0.4 * p4; add_chiral_lines(obj, bl_1, bl_2, bl_3, bl_4, line_radius, col, n_slices); // add to obj } else { @@ -1093,9 +1093,9 @@ coot::molecule_t::get_distances_between_atoms_of_residues(const std::string &cid for (int jj=0; jjx - at_1->x) * (at_2->x - at_1->x) + - (at_2->y - at_1->y) * (at_2->y - at_1->y) + - (at_2->z - at_1->z) * (at_2->z - at_1->z); + (at_2->x() - at_1->x()) * (at_2->x() - at_1->x()) + + (at_2->y() - at_1->y()) * (at_2->y() - at_1->y()) + + (at_2->z() - at_1->z()) * (at_2->z() - at_1->z()); double d = std::sqrt(dd); if (d < dist_max) { atom_spec_t spec_1(at_1); diff --git a/api/coot-molecule.cc b/api/coot-molecule.cc index f39d204364..ffefa7d562 100644 --- a/api/coot-molecule.cc +++ b/api/coot-molecule.cc @@ -346,7 +346,7 @@ coot::molecule_t::get_number_of_hydrogen_atoms() const { int n_atoms = residue_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - std::string ele(at->element); + std::string ele(at->GetElementName()); if (ele == " H") { if (! at->isTer()) { n++; @@ -573,16 +573,16 @@ coot::molecule_t::transform_by(mmdb::mat44 mat) { } for (int i=0; ix, at->y, at->z); + co = clipper::Coord_orth(at->x(), at->y(), at->z()); trans_pos = co.transform(rtop); - at->x = trans_pos.x(); - at->y = trans_pos.y(); - at->z = trans_pos.z(); + at->x() = trans_pos.x(); + at->y() = trans_pos.y(); + at->z() = trans_pos.z(); if (false) // debugging if (co.x() < 0.0 && co.x() > -10.0) if (co.y() < 20.0 && co.y() > 10.0) if (co.z() < 30.0 && co.z() > 20.0) - std::cout << i << " from " << co.format() << " to " << at->x << " " << at->y << " " << at->z << std::endl; + std::cout << i << " from " << co.format() << " to " << at->x() << " " << at->y() << " " << at->z() << std::endl; } atom_sel.mol->PDBCleanup(mmdb::PDBCLEAN_SERIAL|mmdb::PDBCLEAN_INDEX); atom_sel.mol->FinishStructEdit(); @@ -796,15 +796,15 @@ coot::molecule_t::moving_atom_matches(mmdb::Atom *at, int this_mol_index_maybe) if (this_mol_index_maybe >= atom_sel.n_selected_atoms) { return false; } else { - std::string atom_name_mov = at->name; + std::string atom_name_mov = at->GetAtomName(); std::string ins_code_mov = at->GetInsCode(); - std::string alt_conf_mov = at->altLoc; + std::string alt_conf_mov = at->altLoc(); std::string chain_id_mov = at->GetChainID(); int resno_mov = at->GetSeqNum(); - std::string atom_name_ref = atom_sel.atom_selection[this_mol_index_maybe]->name; + std::string atom_name_ref = atom_sel.atom_selection[this_mol_index_maybe]->GetAtomName(); std::string ins_code_ref = atom_sel.atom_selection[this_mol_index_maybe]->GetInsCode(); - std::string alt_conf_ref = atom_sel.atom_selection[this_mol_index_maybe]->altLoc; + std::string alt_conf_ref = atom_sel.atom_selection[this_mol_index_maybe]->altLoc(); std::string chain_id_ref = atom_sel.atom_selection[this_mol_index_maybe]->GetChainID(); int resno_ref = atom_sel.atom_selection[this_mol_index_maybe]->GetSeqNum(); @@ -915,10 +915,10 @@ coot::molecule_t::full_atom_spec_to_atom_index(const std::string &chain, // the wildcard atom selection case "*HO2" for (int i=0; iGetChainID()) == chain) { - if (local_SelAtom[i]->residue->seqNum == resno) { + if (local_SelAtom[i]->GetResidue()->GetSeqNum() == resno) { if (std::string(local_SelAtom[i]->GetInsCode()) == insertion_code) { - if (std::string(local_SelAtom[i]->name) == atom_name) { - if (std::string(local_SelAtom[i]->altLoc) == alt_conf) { + if (std::string(local_SelAtom[i]->GetAtomName()) == atom_name) { + if (std::string(local_SelAtom[i]->altLoc()) == alt_conf) { idx = i; break; } @@ -957,8 +957,8 @@ coot::molecule_t::movable_atom(mmdb::Atom *mol_atom, bool replace_coords_with_ze bool m = true; - if ((mol_atom->occupancy < 0.0001) && - (mol_atom->occupancy > -0.0001)) + if ((mol_atom->occupancy() < 0.0001) && + (mol_atom->occupancy() > -0.0001)) if (replace_coords_with_zero_occ_flag == 0) m = 0; // zero occupancy and "dont move zero occ atoms is set" return m; @@ -981,18 +981,18 @@ coot::molecule_t::adjust_occupancy_other_residue_atoms(mmdb::Atom *at, int nResidueAtoms; mmdb::PPAtom ResidueAtoms = 0; residue->GetAtomTable(ResidueAtoms, nResidueAtoms); - float new_atom_occ = at->occupancy; - std::string new_atom_name(at->name); - std::string new_atom_altconf(at->altLoc); + float new_atom_occ = at->occupancy(); + std::string new_atom_name(at->GetAtomName()); + std::string new_atom_altconf(at->altLoc()); std::vector same_name_atoms; float sum_occ = 0; for (int i=0; iname); - std::string this_atom_altloc(ResidueAtoms[i]->altLoc); + std::string this_atom_name(ResidueAtoms[i]->GetAtomName()); + std::string this_atom_altloc(ResidueAtoms[i]->altLoc()); if (this_atom_name == new_atom_name) { if (this_atom_altloc != new_atom_altconf) { same_name_atoms.push_back(ResidueAtoms[i]); - sum_occ += ResidueAtoms[i]->occupancy; + sum_occ += ResidueAtoms[i]->occupancy(); } } } @@ -1002,16 +1002,16 @@ coot::molecule_t::adjust_occupancy_other_residue_atoms(mmdb::Atom *at, if (same_name_atoms.size() > 0) { float other_atom_occ_sum = 0.0; for (unsigned int i=0; ioccupancy; + other_atom_occ_sum += same_name_atoms[i]->occupancy(); float remainder = 1.0 - new_atom_occ; float f = remainder/other_atom_occ_sum; for (unsigned int i=0; ioccupancy + << " mulitplying occ " << same_name_atoms[i]->occupancy() << " by " << remainder << "/" << other_atom_occ_sum << "\n"; - same_name_atoms[i]->occupancy *= f; + same_name_atoms[i]->occupancy() *= f; } } } @@ -1052,12 +1052,12 @@ coot::molecule_t::replace_coords(const atom_selection_container_t &asc, bool is_ter_state = atom->isTer(); std::cout << "DEBUG:: in replace_coords, intermediate atom: " << i << " " << atom << " " << "chain-id: " - << atom->residue->GetChainID() << ": " - << atom->residue->seqNum << " inscode \"" + << atom->GetResidue()->GetChainID() << ": " + << atom->GetResidue()->GetSeqNum() << " inscode \"" << atom->GetInsCode() << "\" name \"" - << atom->name << "\" altloc \"" - << atom->altLoc << "\" occupancy: " - << atom->occupancy << " :" + << atom->GetAtomName() << "\" altloc \"" + << atom->altLoc() << "\" occupancy: " + << atom->occupancy() << " :" << " TER state: " << is_ter_state << std::endl; } } @@ -1101,21 +1101,21 @@ coot::molecule_t::replace_coords(const atom_selection_container_t &asc, idx = tmp_index; } else { // std::cout << "DEBUG:: atom index mismatch" << std::endl; - idx = full_atom_spec_to_atom_index(std::string(atom->residue->GetChainID()), - atom->residue->seqNum, + idx = full_atom_spec_to_atom_index(std::string(atom->GetResidue()->GetChainID()), + atom->GetResidue()->GetSeqNum(), std::string(atom->GetInsCode()), - std::string(atom->name), - std::string(atom->altLoc)); + std::string(atom->GetAtomName()), + std::string(atom->altLoc())); // std::cout << "DEBUG:: full_atom_spec_to_atom_index gives index: " << idx << std::endl; } } else { // This shouldn't happen. std::cout << "Good Handle, bad index found for old atom: specing" << std::endl; - idx = full_atom_spec_to_atom_index(std::string(atom->residue->GetChainID()), - atom->residue->seqNum, + idx = full_atom_spec_to_atom_index(std::string(atom->GetResidue()->GetChainID()), + atom->GetResidue()->GetSeqNum(), std::string(atom->GetInsCode()), - std::string(atom->name), - std::string(atom->altLoc)); + std::string(atom->GetAtomName()), + std::string(atom->altLoc())); } } else { @@ -1130,11 +1130,11 @@ coot::molecule_t::replace_coords(const atom_selection_container_t &asc, << asc.UDDOldAtomIndexHandle << " using full atom spec to atom index..." << std::endl; - idx = full_atom_spec_to_atom_index(std::string(atom->residue->GetChainID()), - atom->residue->seqNum, + idx = full_atom_spec_to_atom_index(std::string(atom->GetResidue()->GetChainID()), + atom->GetResidue()->GetSeqNum(), std::string(atom->GetInsCode()), - std::string(atom->name), - std::string(atom->altLoc)); + std::string(atom->GetAtomName()), + std::string(atom->altLoc())); std::cout << "full_atom_spec_to_atom_index() returned " << idx << " for " << coot::atom_spec_t(atom) << std::endl; if (idx != -1) { @@ -1145,11 +1145,11 @@ coot::molecule_t::replace_coords(const atom_selection_container_t &asc, if (idx == -1) { std::cout << "DEBUG:: idx: " << idx << "\n"; std::cout << "ERROR:: failed to find atom in molecule: chain-id :" - << std::string(atom->residue->GetChainID()) << ": res_no " - << atom->residue->seqNum << " inscode :" + << std::string(atom->GetResidue()->GetChainID()) << ": res_no " + << atom->GetResidue()->GetSeqNum() << " inscode :" << std::string(atom->GetInsCode()) << ": name :" - << std::string(atom->name) << ": altloc :" - << std::string(atom->altLoc) << ":" << std::endl; + << std::string(atom->GetAtomName()) << ": altloc :" + << std::string(atom->altLoc()) << ":" << std::endl; } } @@ -1159,11 +1159,11 @@ coot::molecule_t::replace_coords(const atom_selection_container_t &asc, if (idx >= 0) { n_atom++; mmdb::Atom *mol_atom = atom_sel.atom_selection[idx]; - float atom_occ = atom->occupancy; + float atom_occ = atom->occupancy(); // if this is a shelx molecule, then we don't change // occupancies this way. We do it by changing the FVAR if (is_from_shelx_ins_flag) { - atom_occ = mol_atom->occupancy; + atom_occ = mol_atom->occupancy(); // OK, one more go. We have an occupancy of 31 or -31 // say. Now, the alt conf atoms has been immediately @@ -1182,8 +1182,8 @@ coot::molecule_t::replace_coords(const atom_selection_container_t &asc, } if (true) { - coot::Cartesian old_pos(mol_atom->x, mol_atom->y, mol_atom->z); - coot::Cartesian new_pos(atom->x, atom->y, atom->z); + coot::Cartesian old_pos(mol_atom->x(), mol_atom->y(), mol_atom->z()); + coot::Cartesian new_pos(atom->x(), atom->y(), atom->z()); double d = (new_pos - old_pos).amplitude(); if (false) { std::cout << " changing coords for atom with idx " << idx << " " @@ -1193,23 +1193,23 @@ coot::molecule_t::replace_coords(const atom_selection_container_t &asc, } if (movable_atom(mol_atom, replace_coords_with_zero_occ_flag)) - mol_atom->SetCoordinates(atom->x, - atom->y, - atom->z, + mol_atom->SetCoordinates(atom->x(), + atom->y(), + atom->z(), atom_occ, - mol_atom->tempFactor); + mol_atom->tempFactor()); } else { if (movable_atom(mol_atom, replace_coords_with_zero_occ_flag)) - mol_atom->SetCoordinates(atom->x, - atom->y, - atom->z, + mol_atom->SetCoordinates(atom->x(), + atom->y(), + atom->z(), atom_occ, - mol_atom->tempFactor); + mol_atom->tempFactor()); } // similarly we adjust occupancy if this is not a shelx molecule if (! is_from_shelx_ins_flag) { - adjust_occupancy_other_residue_atoms(mol_atom, mol_atom->residue, 0); + adjust_occupancy_other_residue_atoms(mol_atom, mol_atom->GetResidue(), 0); } // std::cout << atom << " coords replace " << idx << " " << mol_atom << std::endl; } else { @@ -1229,8 +1229,8 @@ coot::molecule_t::replace_coords(const atom_selection_container_t &asc, bool is_movable_atom = movable_atom(mol_atom, replace_coords_with_zero_occ_flag); if (is_movable_atom) { if (debug) { // debug - coot::Cartesian old_pos(mol_atom->x, mol_atom->y, mol_atom->z); - coot::Cartesian new_pos(atom->x, atom->y, atom->z); + coot::Cartesian old_pos(mol_atom->x(), mol_atom->y(), mol_atom->z()); + coot::Cartesian new_pos(atom->x(), atom->y(), atom->z()); double d = (new_pos - old_pos).amplitude(); if (false) { // debug std::cout << " changing coords for atom with idx " << idx << " " << coot::atom_spec_t(mol_atom) @@ -1238,11 +1238,11 @@ coot::molecule_t::replace_coords(const atom_selection_container_t &asc, std::cout << " " << old_pos << " " << new_pos << " moved-by " << d << std::endl; } } - mol_atom->SetCoordinates(atom->x, - atom->y, - atom->z, - mol_atom->occupancy, - mol_atom->tempFactor); + mol_atom->SetCoordinates(atom->x(), + atom->y(), + atom->z(), + mol_atom->occupancy(), + mol_atom->tempFactor()); n_atom++; } } else { @@ -1298,7 +1298,7 @@ coot::molecule_t::ramachandran_validation(const ramachandrans_container_t &rc) c if (! at_1->isTer()) { std::string atom_name_1(at_1->GetAtomName()); if (atom_name_1 == " C ") { - coot::Cartesian pt_c(at_1->x, at_1->y, at_1->z); + coot::Cartesian pt_c(at_1->x(), at_1->y(), at_1->z()); mmdb::Atom **residue_atoms_2 = 0; int n_residue_atoms_2 = 0; // I should iterate over all alt confs @@ -1308,7 +1308,7 @@ coot::molecule_t::ramachandran_validation(const ramachandrans_container_t &rc) c if (! at_2->isTer()) { std::string atom_name_2(at_2->GetAtomName()); if (atom_name_2 == " N ") { - coot::Cartesian pt_n(at_1->x, at_1->y, at_1->z); + coot::Cartesian pt_n(at_1->x(), at_1->y(), at_1->z()); double dd = coot::Cartesian::lengthsq(pt_c, pt_n); double d = std::sqrt(dd); if (d < 3.0) { @@ -1333,10 +1333,10 @@ coot::molecule_t::ramachandran_validation(const ramachandrans_container_t &rc) c mmdb::Atom *CB = r->GetAtom(" CB "); if (CA && C && N && CB) { - coot::Cartesian ca_pos(CA->x, CA->y, CA->z); - coot::Cartesian c_pos( C->x, C->y, C->z); - coot::Cartesian n_pos( N->x, N->y, N->z); - coot::Cartesian cb_pos(CB->x, CB->y, CB->z); + coot::Cartesian ca_pos(CA->x(), CA->y(), CA->z()); + coot::Cartesian c_pos( C->x(), C->y(), C->z()); + coot::Cartesian n_pos( N->x(), N->y(), N->z()); + coot::Cartesian cb_pos(CB->x(), CB->y(), CB->z()); coot::Cartesian dir_1 = ca_pos - c_pos; coot::Cartesian dir_2 = ca_pos - n_pos; coot::Cartesian dir_3 = ca_pos - cb_pos; @@ -1345,9 +1345,9 @@ coot::molecule_t::ramachandran_validation(const ramachandrans_container_t &rc) c status = true; } else { if (CA && C && N) { - coot::Cartesian ca_pos(CA->x, CA->y, CA->z); - coot::Cartesian c_pos( C->x, C->y, C->z); - coot::Cartesian n_pos( N->x, N->y, N->z); + coot::Cartesian ca_pos(CA->x(), CA->y(), CA->z()); + coot::Cartesian c_pos( C->x(), C->y(), C->z()); + coot::Cartesian n_pos( N->x(), N->y(), N->z()); coot::Cartesian dir_1 = ca_pos - c_pos; coot::Cartesian dir_2 = ca_pos - n_pos; coot::Cartesian r = dir_1 + dir_2; @@ -1376,7 +1376,7 @@ coot::molecule_t::ramachandran_validation(const ramachandrans_container_t &rc) c if (have_close_peptide_bond(rt, rn)) { mmdb::Atom *at = rt->GetAtom(" CA "); // 20221006-PE alt-confs another day if (at) { - coot::Cartesian pos(at->x, at->y, at->z); + coot::Cartesian pos(at->x(), at->y(), at->z()); std::pair hav = get_HA_unit_vector(rt); coot::Cartesian offset(0,0,rama_ball_pos_offset_scale); if (hav.first) offset = hav.second * rama_ball_pos_offset_scale; @@ -1438,10 +1438,10 @@ coot::molecule_t::get_HA_unit_vector(mmdb::Residue *r) const { mmdb::Atom *CB = r->GetAtom(" CB "); if (CA && C && N && CB) { - coot::Cartesian ca_pos(CA->x, CA->y, CA->z); - coot::Cartesian c_pos( C->x, C->y, C->z); - coot::Cartesian n_pos( N->x, N->y, N->z); - coot::Cartesian cb_pos(CB->x, CB->y, CB->z); + coot::Cartesian ca_pos(CA->x(), CA->y(), CA->z()); + coot::Cartesian c_pos( C->x(), C->y(), C->z()); + coot::Cartesian n_pos( N->x(), N->y(), N->z()); + coot::Cartesian cb_pos(CB->x(), CB->y(), CB->z()); coot::Cartesian dir_1 = ca_pos - c_pos; coot::Cartesian dir_2 = ca_pos - n_pos; coot::Cartesian dir_3 = ca_pos - cb_pos; @@ -1450,9 +1450,9 @@ coot::molecule_t::get_HA_unit_vector(mmdb::Residue *r) const { status = true; } else { if (CA && C && N) { - coot::Cartesian ca_pos(CA->x, CA->y, CA->z); - coot::Cartesian c_pos( C->x, C->y, C->z); - coot::Cartesian n_pos( N->x, N->y, N->z); + coot::Cartesian ca_pos(CA->x(), CA->y(), CA->z()); + coot::Cartesian c_pos( C->x(), C->y(), C->z()); + coot::Cartesian n_pos( N->x(), N->y(), N->z()); coot::Cartesian dir_1 = ca_pos - c_pos; coot::Cartesian dir_2 = ca_pos - n_pos; coot::Cartesian r = dir_1 + dir_2; @@ -1723,9 +1723,9 @@ coot::molecule_t::backrub_rotamer(const std::string &chain_id, int res_no, mmdb::Atom *at = residue_atoms[i]; std::string atom_name(at->GetAtomName()); if (atom_name == atom.name) { - at->x = atom.pos.x(); - at->y = atom.pos.y(); - at->z = atom.pos.z(); + at->x() = atom.pos.x(); + at->y() = atom.pos.y(); + at->z() = atom.pos.z(); } } } @@ -2006,10 +2006,10 @@ coot::molecule_t::delete_atom(coot::atom_spec_t &atom_spec) { res->GetAtomTable(residue_atoms, nResidueAtoms); for (int iat=0; iatname; + mol_atom_name = residue_atoms[iat]->GetAtomName(); if (atname == mol_atom_name) { - if (std::string(residue_atoms[iat]->altLoc) == altconf) { + if (std::string(residue_atoms[iat]->altLoc()) == altconf) { make_backup("delete_atom"); atom_sel.mol->DeleteSelection(atom_sel.SelectionHandle); @@ -2046,7 +2046,7 @@ coot::molecule_t::delete_atom(coot::atom_spec_t &atom_spec) { int n_matching_name = 0; residue_of_deleted_atom->GetAtomTable(atoms, n_atoms); for (int iat=0; iatname; + std::string res_atom_name = atoms[iat]->GetAtomName(); if (res_atom_name == atname) { at = atoms[iat]; n_matching_name++; @@ -2055,10 +2055,10 @@ coot::molecule_t::delete_atom(coot::atom_spec_t &atom_spec) { if (n_matching_name == 1) { // one atom of this name left in the residue, so // remove its altconf string if (at) { - strncpy(at->altLoc, "", 2); + strncpy(at->altLoc(), "", 2); // set the occupancy to 1.0 of the remaining atom if it was not zero. - if (at->occupancy > 0.009) - at->occupancy = 1.0; + if (at->occupancy() > 0.009) + at->occupancy() = 1.0; } } @@ -2231,7 +2231,7 @@ coot::molecule_t::delete_residue_atoms_with_alt_conf(coot::residue_spec_t &resid residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iataltLoc); + std::string al(at->altLoc()); if (al == alt_conf) atoms_to_be_deleted.push_back(at); } @@ -2344,12 +2344,12 @@ coot::molecule_t::change_alt_locs(const std::string &cid, const std::string &cha residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iataltLoc; + std::string alt_loc = at->altLoc(); if (alt_loc == "A") atoms_with_alt_loc_A.push_back(at); if (alt_loc == "B") atoms_with_alt_loc_B.push_back(at); } - for (auto atom : atoms_with_alt_loc_A) strncpy(atom->altLoc, "B", 2); - for (auto atom : atoms_with_alt_loc_B) strncpy(atom->altLoc, "A", 2); + for (auto atom : atoms_with_alt_loc_A) strncpy(atom->altLoc(), "B", 2); + for (auto atom : atoms_with_alt_loc_B) strncpy(atom->altLoc(), "A", 2); if (! atoms_with_alt_loc_A.empty()) status = 1; if (! atoms_with_alt_loc_B.empty()) status = 1; return status; @@ -2366,13 +2366,13 @@ coot::molecule_t::change_alt_locs(const std::string &cid, const std::string &cha mmdb::Atom *at = residue_atoms[iat]; if (is_main_chain_p(at)) { } else { - std::string alt_loc = at->altLoc; + std::string alt_loc = at->altLoc(); if (alt_loc == "A") atoms_with_alt_loc_A.push_back(at); if (alt_loc == "B") atoms_with_alt_loc_B.push_back(at); } } - for (auto atom : atoms_with_alt_loc_A) strncpy(atom->altLoc, "B", 2); - for (auto atom : atoms_with_alt_loc_B) strncpy(atom->altLoc, "A", 2); + for (auto atom : atoms_with_alt_loc_A) strncpy(atom->altLoc(), "B", 2); + for (auto atom : atoms_with_alt_loc_B) strncpy(atom->altLoc(), "A", 2); if (! atoms_with_alt_loc_A.empty()) status = 1; if (! atoms_with_alt_loc_B.empty()) status = 1; return status; @@ -2388,13 +2388,13 @@ coot::molecule_t::change_alt_locs(const std::string &cid, const std::string &cha for (int iat=0; iataltLoc; + std::string alt_loc = at->altLoc(); if (alt_loc == "A") atoms_with_alt_loc_A.push_back(at); if (alt_loc == "B") atoms_with_alt_loc_B.push_back(at); } } - for (auto atom : atoms_with_alt_loc_A) strncpy(atom->altLoc, "B", 2); - for (auto atom : atoms_with_alt_loc_B) strncpy(atom->altLoc, "A", 2); + for (auto atom : atoms_with_alt_loc_A) strncpy(atom->altLoc(), "B", 2); + for (auto atom : atoms_with_alt_loc_B) strncpy(atom->altLoc(), "A", 2); if (! atoms_with_alt_loc_A.empty()) status = 1; if (! atoms_with_alt_loc_B.empty()) status = 1; return status; @@ -2415,15 +2415,15 @@ coot::molecule_t::change_alt_locs(const std::string &cid, const std::string &cha residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); + std::string atom_name(at->GetAtomName()); if (atom_name == name) { - std::string alt_loc = at->altLoc; + std::string alt_loc = at->altLoc(); if (alt_loc == "A") { - strncpy(at->altLoc, "B", 2); + strncpy(at->altLoc(), "B", 2); status = 1; } else { if (alt_loc == "B") { - strncpy(at->altLoc, "A", 2); + strncpy(at->altLoc(), "A", 2); status = 1; } } @@ -2777,9 +2777,9 @@ coot::molecule_t::move_molecule_to_new_centre(const coot::Cartesian &new_centre) for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - at->x += delta.x(); - at->y += delta.y(); - at->z += delta.z(); + at->x() += delta.x(); + at->y() += delta.y(); + at->z() += delta.z(); } } } @@ -2798,7 +2798,7 @@ coot::Cartesian coot::molecule_t::get_molecule_centre() const { auto mmdb_to_cartesian = [] (mmdb::Atom *at) { - return Cartesian(at->x, at->y, at->z); + return Cartesian(at->x(), at->y(), at->z()); }; coot::Cartesian c(0,0,0); @@ -2974,9 +2974,9 @@ coot::molecule_t::jed_flip(coot::residue_spec_t &spec, int n_residue_atoms; residue->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); + std::string an(residue_atoms[iat]->GetAtomName()); if (an == atom_name) { - std::string ac(residue_atoms[iat]->altLoc); + std::string ac(residue_atoms[iat]->altLoc()); if (ac == alt_conf) { clicked_atom = residue_atoms[iat]; clicked_atom_idx = iat; @@ -3161,7 +3161,7 @@ coot::molecule_t::apply_transformation_to_atom_selection(const std::string &atom clipper::RTop_orth &rtop) { auto mmdb_to_clipper = [] (mmdb::Atom *at) { - return clipper::Coord_orth(at->x, at->y, at->z); + return clipper::Coord_orth(at->x(), at->y(), at->z()); }; int n_atoms_moved = 0; @@ -3186,9 +3186,9 @@ coot::molecule_t::apply_transformation_to_atom_selection(const std::string &atom clipper::Coord_orth p1 = pt - rotation_centre; clipper::Coord_orth p2 = rtop * p1; clipper::Coord_orth p3 = p2 - rotation_centre; - at->x = p3.x(); - at->y = p3.y(); - at->z = p3.z(); + at->x() = p3.x(); + at->y() = p3.y(); + at->z() = p3.z(); n_atoms_moved++; } } @@ -3238,11 +3238,11 @@ coot::molecule_t::new_positions_for_residue_atoms(mmdb::Residue *residue_p, cons if (! at->isTer()) { std::string atom_name(at->GetAtomName()); if (atom_name == mva.atom_name) { - std::string alt_conf(at->altLoc); + std::string alt_conf(at->altLoc()); if (alt_conf == mva.alt_conf) { - at->x = mva.x; - at->y = mva.y; - at->z = mva.z; + at->x() = mva.x; + at->y() = mva.y; + at->z() = mva.z; n_atoms_moved++; } } @@ -3293,9 +3293,9 @@ coot::molecule_t::get_residue_closest_to(mmdb::Manager *mol, const clipper::Coor for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - double dx = at->x - co.x(); - double dy = at->y - co.y(); - double dz = at->z - co.z(); + double dx = at->x() - co.x(); + double dy = at->y() - co.y(); + double dz = at->z() - co.z(); double dd = dx * dx + dy * dy + dz * dz; if (dd < d_best) { d_best = dd; @@ -3498,7 +3498,7 @@ coot::molecule_t::insert_waters_into_molecule(const coot::minimol::molecule &wat for (unsigned int iatom=0; iatomSetResName(res_name.c_str()); - new_residue_p->seqNum = prev_max_resno + 1 + water_count; + new_residue_p->GetSeqNum() = prev_max_resno + 1 + water_count; water_count++; bf = water_mol[ifrag][ires][iatom].temperature_factor; new_atom_p = new mmdb::Atom; @@ -3510,8 +3510,8 @@ coot::molecule_t::insert_waters_into_molecule(const coot::minimol::molecule &wat << " with b " << bf << std::endl; new_atom_p->SetAtomName(water_mol[ifrag][ires][iatom].name.c_str()); new_atom_p->Het = 1; // waters are now HETATMs - strncpy(new_atom_p->element, water_mol[ifrag][ires][iatom].element.c_str(), 3); - strncpy(new_atom_p->altLoc, water_mol[ifrag][ires][iatom].altLoc.c_str(), 2); + new_atom_p->SetElementName(water_mol[ifrag][ires][iatom].element.c_str()); + strncpy(new_atom_p->altLoc(), water_mol[ifrag][ires][iatom].altLoc.c_str(), 2); // residue number, atom name, occ, coords, b factor @@ -3597,8 +3597,8 @@ coot::molecule_t::append_to_molecule(const coot::minimol::molecule &water_mol) { if (water_mol[ifrag][ires].atoms.size() > 0) { new_residue_p = new mmdb::Residue; - new_residue_p->seqNum = ires; - strcpy(new_residue_p->name, water_mol[ifrag][ires].name.c_str()); + new_residue_p->GetSeqNum() = ires; + new_residue_p->SetResName(water_mol[ifrag][ires].name.c_str()); new_chain_p->AddResidue(new_residue_p); for (unsigned int iatom=0; iatomx += o.x(); - at->y += o.y(); - at->z += o.z(); + at->x() += o.x(); + at->y() += o.y(); + at->z() += o.z(); }; auto set_offset = [] (clipper::Coord_orth &offset, mmdb::Residue *residue_p) { @@ -4008,8 +4008,8 @@ coot::molecule_t::add_alternative_conformation(const std::string &cid) { if (atom_name == " C ") c_at = at; } if (c_at && n_at) { - clipper::Coord_orth c_pos(c_at->x, c_at->y, c_at->z); - clipper::Coord_orth n_pos(n_at->x, n_at->y, n_at->z); + clipper::Coord_orth c_pos(c_at->x(), c_at->y(), c_at->z()); + clipper::Coord_orth n_pos(n_at->x(), n_at->y(), n_at->z()); clipper::Coord_orth cn_unit((c_pos-n_pos).unit()); clipper::Coord_orth arb(1,2,3); clipper::Coord_orth arb_uv(arb.unit()); @@ -4037,18 +4037,18 @@ coot::molecule_t::add_alternative_conformation(const std::string &cid) { // be more complex. Let's just use this for now - it will // handle the vast majority of cases. // - std::string current_alt_conf(at->altLoc); + std::string current_alt_conf(at->altLoc()); if (current_alt_conf.empty()) { mmdb::Atom *at_new = new mmdb::Atom; at_new->Copy(at); move(at_new, -offset); - strcpy(at_new->altLoc, "B"); - at_new->occupancy = 0.5; + strcpy(at_new->altLoc(), "B"); + at_new->occupancy() = 0.5; new_atoms.push_back(at_new); move(at, offset); - at->occupancy = 0.5; - strcpy(at->altLoc, "A"); + at->occupancy() = 0.5; + strcpy(at->altLoc(), "A"); } } } @@ -4335,16 +4335,16 @@ coot::molecule_t::set_residue_to_rotamer_move_atoms(mmdb::Residue *res, mmdb::Re int n_atoms = 0; for (int imov=0; imovname); - std::string alt_loc_mov(mov_residue_atoms[imov]->altLoc); + std::string atom_name_mov(mov_residue_atoms[imov]->GetAtomName()); + std::string alt_loc_mov(mov_residue_atoms[imov]->altLoc()); for (int iref=0; irefname); - std::string alt_loc_ref(ref_residue_atoms[iref]->altLoc); + std::string atom_name_ref(ref_residue_atoms[iref]->GetAtomName()); + std::string alt_loc_ref(ref_residue_atoms[iref]->altLoc()); if (atom_name_mov == atom_name_ref) { if (alt_loc_mov == alt_loc_ref) { - ref_residue_atoms[iref]->x = mov_residue_atoms[imov]->x; - ref_residue_atoms[iref]->y = mov_residue_atoms[imov]->y; - ref_residue_atoms[iref]->z = mov_residue_atoms[imov]->z; + ref_residue_atoms[iref]->x() = mov_residue_atoms[imov]->x(); + ref_residue_atoms[iref]->y() = mov_residue_atoms[imov]->y(); + ref_residue_atoms[iref]->z() = mov_residue_atoms[imov]->z(); n_atoms++; i_done = 1; } @@ -4403,7 +4403,7 @@ coot::molecule_t::add_target_position_restraint_and_refine(const std::string &at const auto &pp = atoms_with_position_restraints[i]; clipper::Coord_orth p = pp.second; mmdb::Atom *at = pp.first; - at->x = p.x(); at->y = p.y(); at->z = p.z(); + at->x() = p.x(); at->y() = p.y(); at->z() = p.z(); } if (n_cycles < 0) { @@ -4801,8 +4801,8 @@ coot::molecule_t::multiply_residue_temperature_factors(const std::string &cid, f for (int i=0; iisTer()) { - float new_B = at->tempFactor * factor; - at->tempFactor = new_B; + float new_B = at->tempFactor() * factor; + at->tempFactor() = new_B; } } } @@ -4867,13 +4867,13 @@ coot::molecule_t::transform_by(const clipper::RTop_orth &rtop, mmdb::Residue *re int n_residue_atoms = 0; residue_moving->GetAtomTable(residue_atoms, n_residue_atoms); for (int iatom=0; iatomx, - residue_atoms[iatom]->y, - residue_atoms[iatom]->z); + clipper::Coord_orth p(residue_atoms[iatom]->x(), + residue_atoms[iatom]->y(), + residue_atoms[iatom]->z()); clipper::Coord_orth p2 = p.transform(rtop); - residue_atoms[iatom]->x = p2.x(); - residue_atoms[iatom]->y = p2.y(); - residue_atoms[iatom]->z = p2.z(); + residue_atoms[iatom]->x() = p2.x(); + residue_atoms[iatom]->y() = p2.y(); + residue_atoms[iatom]->z() = p2.z(); } atom_sel.mol->PDBCleanup(mmdb::PDBCLEAN_SERIAL|mmdb::PDBCLEAN_INDEX); @@ -4901,9 +4901,9 @@ coot::molecule_t::transform_by(const clipper::RTop_orth &rtop) { if (! at->isTer()) { clipper::Coord_orth pos = coot::co(at); clipper::Coord_orth p2 = pos.transform(rtop); - at->x = p2.x(); - at->y = p2.y(); - at->z = p2.z(); + at->x() = p2.x(); + at->y() = p2.y(); + at->z() = p2.z(); } } } @@ -4954,7 +4954,7 @@ coot::molecule_t::get_temperature_factor_of_atom(const std::string &atom_cid) co float b = -1.1f; mmdb:: Atom *at = cid_to_atom(atom_cid); if (at) { - b = at->tempFactor; + b = at->tempFactor(); } return b; @@ -5119,9 +5119,9 @@ coot::molecule_t::get_residue_CA_position(const std::string &cid) const { if (! at->isTer()) { std::string name = at->GetAtomName(); if (name == " CA ") { - v.push_back(at->x); - v.push_back(at->y); - v.push_back(at->z); + v.push_back(at->x()); + v.push_back(at->y()); + v.push_back(at->z()); break; } } @@ -5237,7 +5237,7 @@ coot::molecule_t::set_occupancy(const std::string &cid, float occ_new) { for (int i=0; iisTer()) { - at->occupancy = occ_new; + at->occupancy() = occ_new; } } atom_sel.mol->DeleteSelection(selHnd); @@ -5413,7 +5413,7 @@ coot::molecule_t::set_temperature_factors_using_cid(const std::string &cid, floa if (nSelAtoms > 0) { for (int i=0; itempFactor = temp_fact; + atom->tempFactor() = temp_fact; } } atom_sel.mol->DeleteSelection(selHnd); diff --git a/api/filo-tests.cc b/api/filo-tests.cc index a3c5a3337f..2bdde586da 100644 --- a/api/filo-tests.cc +++ b/api/filo-tests.cc @@ -296,8 +296,8 @@ int test_change_rotamer(molecules_container_t &molecules_container) { mmdb::Residue *res_new = molecules_container.get_residue(imol_molecule, resSpec); mmdb::Atom *atom_new = res_new->GetAtom(5); - std::cout << "atom_fragment pos: " << atom_fragment->x << " " << atom_fragment->y << " " << atom_fragment->z << std::endl; - std::cout << "atom_new pos: " << atom_new->x << " " << atom_new->y << " " << atom_new->z << std::endl; + std::cout << "atom_fragment pos: " << atom_fragment->x() << " " << atom_fragment->y() << " " << atom_fragment->z() << std::endl; + std::cout << "atom_new pos: " << atom_new->x() << " " << atom_new->y() << " " << atom_new->z() << std::endl; // This fails... // expect(atom_new.x).toBe(atom_fragment.x) diff --git a/api/model-analysis.cc b/api/model-analysis.cc index 37f375ba85..e1ece3e533 100644 --- a/api/model-analysis.cc +++ b/api/model-analysis.cc @@ -37,8 +37,8 @@ molecules_container_t::get_atom_differences(int imol1, int imol2) { mmdb::Atom *atom2 = res2->GetAtom(atom_name); if (atom2) { coot::atom_spec_t as1 = coot::atom_spec_t(atom1); - coot::Cartesian pos1 = coot::Cartesian(atom1->x, atom1->y, atom1->z); - coot::Cartesian pos2 = coot::Cartesian(atom2->x, atom2->y, atom2->z); + coot::Cartesian pos1 = coot::Cartesian(atom1->x(), atom1->y(), atom1->z()); + coot::Cartesian pos2 = coot::Cartesian(atom2->x(), atom2->y(), atom2->z()); positioned_atom_spec_t pas; pas.atom_spec = as1; pas.pos1 = pos1; diff --git a/api/molecules-container-ligand-fitting.cc b/api/molecules-container-ligand-fitting.cc index 34273d4e86..e1f5271ada 100644 --- a/api/molecules-container-ligand-fitting.cc +++ b/api/molecules-container-ligand-fitting.cc @@ -507,9 +507,9 @@ get_eigenvalues(mmdb::Residue *residue_p) { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - x.push_back(at->x); - y.push_back(at->y); - z.push_back(at->z); + x.push_back(at->x()); + y.push_back(at->y()); + z.push_back(at->z()); } } if (! x.empty()) { @@ -523,12 +523,12 @@ get_eigenvalues(mmdb::Residue *residue_p) { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - mat(0,0) += (double(at->x) - x_mean) * (double(at->x) - x_mean); - mat(1,1) += (double(at->y) - y_mean) * (double(at->y) - y_mean); - mat(2,2) += (double(at->z) - z_mean) * (double(at->z) - z_mean); - mat(0,1) += (double(at->x) - x_mean) * (double(at->y) - y_mean); - mat(0,2) += (double(at->x) - x_mean) * (double(at->z) - z_mean); - mat(1,2) += (double(at->y) - y_mean) * (double(at->z) - z_mean); + mat(0,0) += (double(at->x()) - x_mean) * (double(at->x()) - x_mean); + mat(1,1) += (double(at->y()) - y_mean) * (double(at->y()) - y_mean); + mat(2,2) += (double(at->z()) - z_mean) * (double(at->z()) - z_mean); + mat(0,1) += (double(at->x()) - x_mean) * (double(at->y()) - y_mean); + mat(0,2) += (double(at->x()) - x_mean) * (double(at->z()) - z_mean); + mat(1,2) += (double(at->y()) - y_mean) * (double(at->z()) - z_mean); } } mat(1,0) = mat(0,1); @@ -581,9 +581,9 @@ molecules_container_t::get_eigenvectors_and_eigenvalues(int imol, const std::str for (int i=0; iisTer()) { - x.push_back(at->x); - y.push_back(at->y); - z.push_back(at->z); + x.push_back(at->x()); + y.push_back(at->y()); + z.push_back(at->z()); } } mol->DeleteSelection(selhandle); diff --git a/api/molecules-container-maps.cc b/api/molecules-container-maps.cc index 58f7f5c90b..1c6a8e06f6 100644 --- a/api/molecules-container-maps.cc +++ b/api/molecules-container-maps.cc @@ -506,7 +506,7 @@ molecules_container_t::get_q_score_validation_information(mmdb::Manager *mol, in at->GetUDData(udd_q_score, q); if (false) std::cout << " " << coot::atom_spec_t(at) << " B " - << at->tempFactor << " Q-Score: " << q + << at->tempFactor() << " Q-Score: " << q << std::endl; } } @@ -787,7 +787,7 @@ molecules_container_t::get_spherical_variance(int imol_map, int imol_model, coot::atom_spec_t atom_spec(at_m); mmdb::Atom *at = molecules[imol_model].get_atom(atom_spec); if (at) { - clipper::Coord_orth pt(at->x, at->y, at->z); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); float mean_d = mean_density_other_atoms; coot::ligand::spherical_density_score_t sds; float sv = sds.get_spherical_variance(pt, xmap, mean_d); diff --git a/api/molecules-container-modelling.cc b/api/molecules-container-modelling.cc index 3cab6a3cb7..b7ba72ed9d 100644 --- a/api/molecules-container-modelling.cc +++ b/api/molecules-container-modelling.cc @@ -319,7 +319,7 @@ molecules_container_t::add_compound(int imol, const std::string &tlc, int imol_d mmdb::Atom *at = residue_atoms[iat]; if (! at->isTer()) { n_atoms++; - position_sum + coot::Cartesian(at->x, at->y, at->z); + position_sum + coot::Cartesian(at->x(), at->y(), at->z()); } } if (n_atoms > 0) { @@ -328,9 +328,9 @@ molecules_container_t::add_compound(int imol, const std::string &tlc, int imol_d for (int iat=0; iatisTer()) { - at->x += position.x() - current_position.x(); - at->y += position.y() - current_position.y(); - at->z += position.z() - current_position.z(); + at->x() += position.x() - current_position.x(); + at->y() += position.y() - current_position.y(); + at->z() += position.z() - current_position.z(); } } } diff --git a/api/molecules-container-molecular-placement.cc b/api/molecules-container-molecular-placement.cc index bad5093f02..f5f1eafa66 100644 --- a/api/molecules-container-molecular-placement.cc +++ b/api/molecules-container-molecular-placement.cc @@ -84,7 +84,7 @@ molecules_container_t::molecular_placement_fit(int imol_map, int imol_model, if (n_atoms > 0) { float sum = 0.0f; for (int j=0; jx, atoms[j]->y, atoms[j]->z); + clipper::Coord_orth pt(atoms[j]->x(), atoms[j]->y(), atoms[j]->z()); sum += coot::util::density_at_point(molecules[imol_map].xmap, pt); } mean_density_ca = sum / static_cast(n_atoms); diff --git a/api/molecules-container-nanobind.cc b/api/molecules-container-nanobind.cc index a2936f415c..0188f38d42 100644 --- a/api/molecules-container-nanobind.cc +++ b/api/molecules-container-nanobind.cc @@ -190,23 +190,23 @@ NB_MODULE(coot_headless_api, m) { # else nb::class_(m,"Atom") .def(nb::init<>()) - .def_prop_rw("x",[](mmdb::Atom &t) { return t.x ; },[](mmdb::Atom &t, float value) { t.x = value; }) - .def_prop_rw("y",[](mmdb::Atom &t) { return t.y ; },[](mmdb::Atom &t, float value) { t.y = value; }) - .def_prop_rw("z",[](mmdb::Atom &t) { return t.z ; },[](mmdb::Atom &t, float value) { t.z = value; }) - .def_prop_rw("serNum",[](mmdb::Atom &t) { return t.serNum ; },[](mmdb::Atom &t, float value) { t.serNum = value; }) - .def_prop_rw("occupancy",[](mmdb::Atom &t) { return t.occupancy ; },[](mmdb::Atom &t, float value) { t.occupancy = value; }) - .def_prop_rw("tempFactor",[](mmdb::Atom &t) { return t.tempFactor ; },[](mmdb::Atom &t, float value) { t.tempFactor = value; }) - .def_prop_rw("charge",[](mmdb::Atom &t) { return t.charge ; },[](mmdb::Atom &t, float value) { t.charge = value; }) - .def_prop_rw("sigX",[](mmdb::Atom &t) { return t.sigX ; },[](mmdb::Atom &t, float value) { t.sigX = value; }) - .def_prop_rw("sigY",[](mmdb::Atom &t) { return t.sigY ; },[](mmdb::Atom &t, float value) { t.sigY = value; }) - .def_prop_rw("sigZ",[](mmdb::Atom &t) { return t.sigZ ; },[](mmdb::Atom &t, float value) { t.sigZ = value; }) - .def_prop_rw("sigOcc",[](mmdb::Atom &t) { return t.sigOcc ; },[](mmdb::Atom &t, float value) { t.sigOcc = value; }) - .def_prop_rw("sigTemp",[](mmdb::Atom &t) { return t.sigTemp ; },[](mmdb::Atom &t, float value) { t.sigTemp = value; }) - .def_prop_rw("u11",[](mmdb::Atom &t) { return t.u11 ; },[](mmdb::Atom &t, float value) { t.u11 = value; }) - .def_prop_rw("u22",[](mmdb::Atom &t) { return t.u22 ; },[](mmdb::Atom &t, float value) { t.u22 = value; }) - .def_prop_rw("u33",[](mmdb::Atom &t) { return t.u33 ; },[](mmdb::Atom &t, float value) { t.u33 = value; }) - .def_prop_rw("u13",[](mmdb::Atom &t) { return t.u13 ; },[](mmdb::Atom &t, float value) { t.u13 = value; }) - .def_prop_rw("u23",[](mmdb::Atom &t) { return t.u23 ; },[](mmdb::Atom &t, float value) { t.u23 = value; }) + .def_prop_rw("x",[](mmdb::Atom &t) { return t.x() ; },[](mmdb::Atom &t, float value) { t.x() = value; }) + .def_prop_rw("y",[](mmdb::Atom &t) { return t.y() ; },[](mmdb::Atom &t, float value) { t.y() = value; }) + .def_prop_rw("z",[](mmdb::Atom &t) { return t.z() ; },[](mmdb::Atom &t, float value) { t.z() = value; }) + .def_prop_rw("serNum",[](mmdb::Atom &t) { return t.serNum() ; },[](mmdb::Atom &t, float value) { t.serNum() = value; }) + .def_prop_rw("occupancy",[](mmdb::Atom &t) { return t.occupancy() ; },[](mmdb::Atom &t, float value) { t.occupancy() = value; }) + .def_prop_rw("tempFactor",[](mmdb::Atom &t) { return t.tempFactor() ; },[](mmdb::Atom &t, float value) { t.tempFactor() = value; }) + .def_prop_rw("charge",[](mmdb::Atom &t) { return t.charge() ; },[](mmdb::Atom &t, float value) { t.charge() = value; }) + .def_prop_rw("sigX",[](mmdb::Atom &t) { return t.sigX() ; },[](mmdb::Atom &t, float value) { t.sigX() = value; }) + .def_prop_rw("sigY",[](mmdb::Atom &t) { return t.sigY() ; },[](mmdb::Atom &t, float value) { t.sigY() = value; }) + .def_prop_rw("sigZ",[](mmdb::Atom &t) { return t.sigZ() ; },[](mmdb::Atom &t, float value) { t.sigZ() = value; }) + .def_prop_rw("sigOcc",[](mmdb::Atom &t) { return t.sigOcc() ; },[](mmdb::Atom &t, float value) { t.sigOcc() = value; }) + .def_prop_rw("sigTemp",[](mmdb::Atom &t) { return t.sigTemp() ; },[](mmdb::Atom &t, float value) { t.sigTemp() = value; }) + .def_prop_rw("u11",[](mmdb::Atom &t) { return t.u11() ; },[](mmdb::Atom &t, float value) { t.u11() = value; }) + .def_prop_rw("u22",[](mmdb::Atom &t) { return t.u22() ; },[](mmdb::Atom &t, float value) { t.u22() = value; }) + .def_prop_rw("u33",[](mmdb::Atom &t) { return t.u33() ; },[](mmdb::Atom &t, float value) { t.u33() = value; }) + .def_prop_rw("u13",[](mmdb::Atom &t) { return t.u13() ; },[](mmdb::Atom &t, float value) { t.u13() = value; }) + .def_prop_rw("u23",[](mmdb::Atom &t) { return t.u23() ; },[](mmdb::Atom &t, float value) { t.u23() = value; }) .def_prop_rw("Het",[](mmdb::Atom &t) { return t.Het ; },[](mmdb::Atom &t, bool value) { t.Het = value; }) .def_prop_rw("Ter",[](mmdb::Atom &t) { return t.Ter ; },[](mmdb::Atom &t, bool value) { t.Ter = value; }) .def("GetNBonds",&mmdb::Atom::GetNBonds) @@ -232,10 +232,10 @@ NB_MODULE(coot_headless_api, m) { ; nb::class_(m,"Residue") .def(nb::init<>()) - .def_prop_rw("seqNum",[](mmdb::Residue &t) { return t.seqNum ; },[](mmdb::Residue &t, int value) { t.seqNum = value; }) + .def_prop_rw("seqNum",[](mmdb::Residue &t) { return t.GetSeqNum() ; },[](mmdb::Residue &t, int value) { t.GetSeqNum() = value; }) .def_prop_rw("label_seq_id",[](mmdb::Residue &t) { return t.label_seq_id ; },[](mmdb::Residue &t, int value) { t.label_seq_id = value; }) .def_prop_rw("label_entity_id",[](mmdb::Residue &t) { return t.label_entity_id ; },[](mmdb::Residue &t, int value) { t.label_entity_id = value; }) - .def_prop_rw("index",[](mmdb::Residue &t) { return t.index ; },[](mmdb::Residue &t, int value) { t.index = value; }) + .def_prop_rw("index",[](mmdb::Residue &t) { return t.GetIndex() ; },[](mmdb::Residue &t, int value) { t.GetIndex() = value; }) .def_prop_rw("nAtoms",[](mmdb::Residue &t) { return t.nAtoms ; },[](mmdb::Residue &t, int value) { t.nAtoms = value; }) .def("GetModelNum",&mmdb::Residue::GetModelNum) .def("GetSeqNum",&mmdb::Residue::GetSeqNum) diff --git a/api/molecules-container-superpose.cc b/api/molecules-container-superpose.cc index 94f297e6dd..78a4a5298b 100644 --- a/api/molecules-container-superpose.cc +++ b/api/molecules-container-superpose.cc @@ -539,7 +539,7 @@ molecules_container_t::get_pairs(ssm::Align *SSMAlign, if (t_index == -1) { coot::residue_validation_information_t ref; coot::residue_validation_information_t mov; - coot::residue_spec_t ref_res_spec(atom_selection1[i1]->residue); + coot::residue_spec_t ref_res_spec(atom_selection1[i1]->GetResidue()); coot::residue_spec_t mov_res_spec; ref.residue_spec = ref_res_spec; mov.residue_spec = mov_res_spec; @@ -551,8 +551,8 @@ molecules_container_t::get_pairs(ssm::Align *SSMAlign, if (s_index == i1) { coot::residue_validation_information_t ref; coot::residue_validation_information_t mov; - coot::residue_spec_t ref_res_spec(atom_selection1[i1]->residue); - coot::residue_spec_t mov_res_spec(atom_selection2[t_index]->residue); + coot::residue_spec_t ref_res_spec(atom_selection1[i1]->GetResidue()); + coot::residue_spec_t mov_res_spec(atom_selection2[t_index]->GetResidue()); ref.residue_spec = ref_res_spec; mov.residue_spec = mov_res_spec; clipper::Coord_orth pt_1 = coot::co(atom_selection1[i1]); diff --git a/api/molecules-container.cc b/api/molecules-container.cc index 2692d49e78..97160c7e0d 100644 --- a/api/molecules-container.cc +++ b/api/molecules-container.cc @@ -610,7 +610,7 @@ molecules_container_t::get_active_atom(float x, float y, float z, const std::str s += std::string(at->GetInsCode()); s += "/"; s += std::string(at->GetAtomName()); - std::string a(at->altLoc); + std::string a(at->altLoc()); if (! a.empty()) { s += ":"; s += std::string(); @@ -653,7 +653,7 @@ molecules_container_t::get_active_atom(float x, float y, float z, const std::str for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - coot::Cartesian atom_pos(at->x, at->y, at->z); + coot::Cartesian atom_pos(at->x(), at->y(), at->z()); float dd = coot::Cartesian::lengthsq(screen_centre, atom_pos); if (dd < best_distance_sqrd) { best_distance_sqrd = dd; @@ -1627,7 +1627,7 @@ molecules_container_t::rotamer_analysis(int imol_model) const { // (GLY and ALA have <= 5 heavy atoms and so are correctly skipped here.) int n_heavy_atoms = 0; for (int iat=0; iatelement); + std::string ele(residue_atoms[iat]->GetElementName()); if (ele != " H" && ele != " D") n_heavy_atoms++; } @@ -2161,7 +2161,7 @@ molecules_container_t::get_atom_position(int imol, coot::atom_spec_t &atom_spec) mmdb::Atom *at = get_atom(imol, atom_spec); if (at) { - return std::pair (true, coot::Cartesian(at->x, at->y, at->z)); + return std::pair (true, coot::Cartesian(at->x(), at->y(), at->z())); } else { return std::pair (false, coot::Cartesian(0,0,0)); } @@ -3533,7 +3533,7 @@ molecules_container_t::create_mmdbmanager_from_res_vector(const std::vectorindex + << "had index " << flankers_in_reference_mol[ires]->GetIndex() << std::endl; // get rid of this function at some stage @@ -3544,7 +3544,7 @@ molecules_container_t::create_mmdbmanager_from_res_vector(const std::vectorPutUDData(index_from_reference_residue_handle, flankers_in_reference_mol[ires]->index); + r->PutUDData(index_from_reference_residue_handle, flankers_in_reference_mol[ires]->GetIndex()); // copy over the atom indices. UDDAtomIndexHandle in mol_n becomes UDDOldAtomIndexHandle // indices in the returned molecule @@ -3566,7 +3566,7 @@ molecules_container_t::create_mmdbmanager_from_res_vector(const std::vectorAddResidue(r); // at the end else chain_p->InsResidue(r, sni); - r->seqNum = flankers_in_reference_mol[ires]->GetSeqNum(); + r->GetSeqNum() = flankers_in_reference_mol[ires]->GetSeqNum(); r->SetResName(flankers_in_reference_mol[ires]->GetResName()); n_flanker++; @@ -3592,7 +3592,7 @@ molecules_container_t::create_mmdbmanager_from_res_vector(const std::vectorGetResidue(ires); std::cout << "create_mmdb.. ^^^ " << coot::residue_spec_t(residue_p) << " " - << residue_p << " index " << residue_p->index + << residue_p << " index " << residue_p->GetIndex() << std::endl; } } @@ -4081,7 +4081,7 @@ molecules_container_t::generate_molecule_and_refine(int imol, // needed for UDD std::cout << "DEBUG:: in generate_molecule_and_refine() residues_mol_and_res_vec mol: residue " << coot::residue_spec_t(residue_p) << " residue " << residue_p << " chain " << residue_p->chain << " index " - << residue_p->index << std::endl; + << residue_p->GetIndex() << std::endl; } } } @@ -4575,9 +4575,9 @@ molecules_container_t::apply_translation_to_molecule(int imol, float tx, float t mol->GetSelIndex(selHnd, atoms, n_atoms); if (n_atoms > 0) { for (int i=0; ix += tx; - atoms[i]->y += ty; - atoms[i]->z += tz; + atoms[i]->x() += tx; + atoms[i]->y() += ty; + atoms[i]->z() += tz; } mol->FinishStructEdit(); set_updating_maps_need_an_update(imol); @@ -4626,7 +4626,7 @@ std::vector molecules_container_t::pepflips_using_difference_map(int imol_coords, int imol_difference_map, float n_sigma) const { auto mmdb_to_clipper = [] (mmdb::Atom *at) { - return clipper::Coord_orth(at->x, at->y, at->z); + return clipper::Coord_orth(at->x(), at->y(), at->z()); }; std::vector v; diff --git a/api/moorhen-h-bonds.cc b/api/moorhen-h-bonds.cc index dd39f0d386..eb60477d68 100644 --- a/api/moorhen-h-bonds.cc +++ b/api/moorhen-h-bonds.cc @@ -35,20 +35,20 @@ molecules_container_t::get_h_bonds(int imol, const std::string &cid_str, bool mc if (atom_in) { // can be null (strange). - m_at.serial = atom_in->serNum; - m_at.x = atom_in->x; - m_at.y = atom_in->y; - m_at.z = atom_in->z; - m_at.charge = atom_in->charge; - m_at.occ = atom_in->occupancy; - m_at.b_iso = atom_in->tempFactor; - m_at.element = std::string(atom_in->element); - m_at.name = std::string(atom_in->name); + m_at.serial = atom_in->serNum(); + m_at.x = atom_in->x(); + m_at.y = atom_in->y(); + m_at.z = atom_in->z(); + m_at.charge = atom_in->charge(); + m_at.occ = atom_in->occupancy(); + m_at.b_iso = atom_in->tempFactor(); + m_at.element = std::string(atom_in->GetElementName()); + m_at.name = std::string(atom_in->GetAtomName()); m_at.model = atom_in->GetModelNum(); m_at.chain = std::string(atom_in->GetChainID()); m_at.res_no = atom_in->GetSeqNum(); - m_at.altLoc = std::string(atom_in->altLoc); - m_at.residue_name = std::string(atom_in->GetResidue()->name); + m_at.altLoc = std::string(atom_in->altLoc()); + m_at.residue_name = std::string(atom_in->GetResidue()->GetResName()); } }; diff --git a/api/rama-plot-phi-psi.cc b/api/rama-plot-phi-psi.cc index 6688c0ed97..577349b595 100644 --- a/api/rama-plot-phi-psi.cc +++ b/api/rama-plot-phi-psi.cc @@ -30,11 +30,11 @@ rama_plot::util::get_phi_psi(mmdb::Residue *residue_0, mmdb::Residue *residue_1, residue_0->GetAtomTable(res_selection, nResidueAtoms); if (nResidueAtoms > 0) { for (int j=0; jname; + std::string atom_name = res_selection[j]->GetAtomName(); if (atom_name == " C ") { - c_prev = clipper::Coord_orth(res_selection[j]->x, - res_selection[j]->y, - res_selection[j]->z); + c_prev = clipper::Coord_orth(res_selection[j]->x(), + res_selection[j]->y(), + res_selection[j]->z()); natom++; } } @@ -44,23 +44,23 @@ rama_plot::util::get_phi_psi(mmdb::Residue *residue_0, mmdb::Residue *residue_1, residue_1->GetAtomTable(res_selection, nResidueAtoms); if (nResidueAtoms > 0) { for (int j=0; jname; + std::string atom_name = res_selection[j]->GetAtomName(); if (atom_name == " C ") { - c_this = clipper::Coord_orth(res_selection[j]->x, - res_selection[j]->y, - res_selection[j]->z); + c_this = clipper::Coord_orth(res_selection[j]->x(), + res_selection[j]->y(), + res_selection[j]->z()); natom++; } if (atom_name == " CA ") { - ca_this = clipper::Coord_orth(res_selection[j]->x, - res_selection[j]->y, - res_selection[j]->z); + ca_this = clipper::Coord_orth(res_selection[j]->x(), + res_selection[j]->y(), + res_selection[j]->z()); natom++; } if (atom_name == " N ") { - n_this = clipper::Coord_orth(res_selection[j]->x, - res_selection[j]->y, - res_selection[j]->z); + n_this = clipper::Coord_orth(res_selection[j]->x(), + res_selection[j]->y(), + res_selection[j]->z()); natom++; } } @@ -71,11 +71,11 @@ rama_plot::util::get_phi_psi(mmdb::Residue *residue_0, mmdb::Residue *residue_1, is_pre_pro = 1; if (nResidueAtoms > 0) { for (int j=0; jname; + std::string atom_name = res_selection[j]->GetAtomName(); if (atom_name == " N ") { - n_next = clipper::Coord_orth(res_selection[j]->x, - res_selection[j]->y, - res_selection[j]->z); + n_next = clipper::Coord_orth(res_selection[j]->x(), + res_selection[j]->y(), + res_selection[j]->z()); natom++; } } @@ -91,13 +91,13 @@ rama_plot::util::get_phi_psi(mmdb::Residue *residue_0, mmdb::Residue *residue_1, label += " "; label += segid; label += " "; - label += residue_1->name; + label += residue_1->GetResName(); double phi = clipper::Util::rad2d(ca_this.torsion(c_prev, n_this, ca_this, c_this)); double psi = clipper::Util::rad2d(ca_this.torsion(n_this, ca_this, c_this, n_next)); phi_psi = rama_plot::phi_psi_t(phi, psi, - residue_1->name, + residue_1->GetResName(), label.c_str(), ires, inscode, diff --git a/api/rigid-body-fit.cc b/api/rigid-body-fit.cc index 2cee9ae0f3..e64112ff8a 100644 --- a/api/rigid-body-fit.cc +++ b/api/rigid-body-fit.cc @@ -56,11 +56,11 @@ coot::api::rigid_body_fit(mmdb::Manager *mol, int udd_atom_selection_fitting_ato if (! at->isTer()) { std::string this_atom_name(at->GetAtomName()); if (moved_atoms_mol[ifrag][ires][iat].name == this_atom_name) { - std::string this_atom_alt_conf(at->altLoc); + std::string this_atom_alt_conf(at->altLoc()); if (this_atom_alt_conf == moved_atoms_mol[ifrag][ires][iat].altLoc) { - at->x = moved_atoms_mol[ifrag][ires][iat].pos.x(); - at->y = moved_atoms_mol[ifrag][ires][iat].pos.y(); - at->z = moved_atoms_mol[ifrag][ires][iat].pos.z(); + at->x() = moved_atoms_mol[ifrag][ires][iat].pos.x(); + at->y() = moved_atoms_mol[ifrag][ires][iat].pos.y(); + at->z() = moved_atoms_mol[ifrag][ires][iat].pos.z(); n_moved++; } } diff --git a/api/test-molecules-container.cc b/api/test-molecules-container.cc index 71a7a7c749..ad10ffd005 100644 --- a/api/test-molecules-container.cc +++ b/api/test-molecules-container.cc @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #define GLM_ENABLE_EXPERIMENTAL @@ -310,9 +312,9 @@ int test_auto_fit_rotamer_1(molecules_container_t &mc_in) { if (r) { mmdb::Atom *cz = r->GetAtom(" CZ "); if (cz) { - coot::Cartesian pt_1(cz->x, cz->y, cz->z); + coot::Cartesian pt_1(cz->x(), cz->y(), cz->z()); status = mc.auto_fit_rotamer(imol, "A", 61, "", "", imol_map); - coot::Cartesian pt_2(cz->x, cz->y, cz->z); + coot::Cartesian pt_2(cz->x(), cz->y(), cz->z()); double dd = coot::Cartesian::lengthsq(pt_1, pt_2); double d = std::sqrt(dd); std::cout << "d " << d << std::endl; @@ -398,9 +400,9 @@ int test_pepflips(molecules_container_t &mc) { coot::atom_spec_t atom_spec(res_spec.chain_id, res_spec.res_no, res_spec.ins_code, " O ",""); mmdb::Atom *at = mc.get_atom(imol, atom_spec); if (at) { - coot::Cartesian pt_1(at->x, at->y, at->z); + coot::Cartesian pt_1(at->x(), at->y(), at->z()); mc.flip_peptide(imol, atom_spec, ""); - coot::Cartesian pt_2(at->x, at->y, at->z); + coot::Cartesian pt_2(at->x(), at->y(), at->z()); double dd = coot::Cartesian::lengthsq(pt_1, pt_2); double d = std::sqrt(dd); std::cout << "debug:: in test_pepflips() for " << atom_spec << " d is " << d << std::endl; @@ -423,9 +425,9 @@ int test_pepflips(molecules_container_t &mc) { coot::atom_spec_t atom_spec_of_moving_O("A", 99, "", " O ", ""); mmdb::Atom *at = mc.get_atom(imol, atom_spec_of_moving_O); if (at) { - coot::Cartesian pt_1(at->x, at->y, at->z); + coot::Cartesian pt_1(at->x(), at->y(), at->z()); mc.flip_peptide_using_cid(imol, atom_cid, ""); - coot::Cartesian pt_2(at->x, at->y, at->z); + coot::Cartesian pt_2(at->x(), at->y(), at->z()); double dd = coot::Cartesian::lengthsq(pt_1, pt_2); double d = std::sqrt(dd); if (d > 3.0) { @@ -500,12 +502,12 @@ int test_undo_and_redo(molecules_container_t &mc) { std::string atom_cid = "//A/14/CA"; coot::atom_spec_t atom_spec("A", 14, "", " O ", ""); mmdb::Atom *at_1 = mc.get_atom(imol, atom_spec); - coot::Cartesian pt_1(at_1->x, at_1->y, at_1->z); + coot::Cartesian pt_1(at_1->x(), at_1->y(), at_1->z()); mc.flip_peptide_using_cid(imol, atom_cid, ""); - coot::Cartesian pt_2(at_1->x, at_1->y, at_1->z); + coot::Cartesian pt_2(at_1->x(), at_1->y(), at_1->z()); mc.undo(imol); // deletes atoms so now at_1 is out of date mmdb::Atom *at_2 = mc.get_atom(imol, atom_spec); - coot::Cartesian pt_3(at_2->x, at_2->y, at_2->z); + coot::Cartesian pt_3(at_2->x(), at_2->y(), at_2->z()); double dd_1 = coot::Cartesian::lengthsq(pt_1, pt_2); double dd_2 = coot::Cartesian::lengthsq(pt_1, pt_3); @@ -519,7 +521,7 @@ int test_undo_and_redo(molecules_container_t &mc) { // now let's test redo mc.redo(imol); // deletes atoms so now at_1 is out of date mmdb::Atom *at_3 = mc.get_atom(imol, atom_spec); - coot::Cartesian pt_4(at_3->x, at_3->y, at_3->z); + coot::Cartesian pt_4(at_3->x(), at_3->y(), at_3->z()); // modified and redone should be the same: double dd_3 = coot::Cartesian::lengthsq(pt_2, pt_4); double d_3 = std::sqrt(dd_3); @@ -531,16 +533,16 @@ int test_undo_and_redo(molecules_container_t &mc) { coot::atom_spec_t atom_spec_b("A", 24, "", " O ", ""); mmdb::Atom *at_5 = mc.get_atom(imol, atom_spec_b); - coot::Cartesian pt_5(at_5->x, at_5->y, at_5->z); + coot::Cartesian pt_5(at_5->x(), at_5->y(), at_5->z()); mc.flip_peptide_using_cid(imol, "//A/24/CA", ""); mmdb::Atom *at_6 = mc.get_atom(imol, atom_spec_b); - coot::Cartesian pt_6(at_6->x, at_6->y, at_6->z); + coot::Cartesian pt_6(at_6->x(), at_6->y(), at_6->z()); mc.undo(imol); mmdb::Atom *at_7 = mc.get_atom(imol, atom_spec_b); - coot::Cartesian pt_7(at_7->x, at_7->y, at_7->z); + coot::Cartesian pt_7(at_7->x(), at_7->y(), at_7->z()); mc.redo(imol); mmdb::Atom *at_8 = mc.get_atom(imol, atom_spec_b); - coot::Cartesian pt_8(at_8->x, at_8->y, at_8->z); + coot::Cartesian pt_8(at_8->x(), at_8->y(), at_8->z()); if (true) { // debugging std::cout << "pt_4 " << pt_4 << std::endl; @@ -576,17 +578,17 @@ int test_undo_and_redo_2(molecules_container_t &mc) { coot::atom_spec_t atom_spec("A", 61, "", " CZ ", ""); mmdb::Atom *at_1 = mc.get_atom(imol, atom_spec); if (at_1) { - coot::Cartesian pt_1(at_1->x, at_1->y, at_1->z); + coot::Cartesian pt_1(at_1->x(), at_1->y(), at_1->z()); int status_af = mc.auto_fit_rotamer(imol, "A", 61, "", "", imol_map); if (status_af == 1) { - coot::Cartesian pt_2(at_1->x, at_1->y, at_1->z); + coot::Cartesian pt_2(at_1->x(), at_1->y(), at_1->z()); double dd = coot::Cartesian::lengthsq(pt_1, pt_2); double d = std::sqrt(dd); if (d > 6.0) { // OK, it moved (fitted) mc.undo(imol); mmdb::Atom *at_3 = mc.get_atom(imol, atom_spec); - coot::Cartesian pt_3(at_3->x, at_3->y, at_3->z); + coot::Cartesian pt_3(at_3->x(), at_3->y(), at_3->z()); dd = coot::Cartesian::lengthsq(pt_1, pt_3); d = std::sqrt(dd); std::cout << "debug:: in test_undo_and_redo_2() d " << d << std::endl; @@ -631,7 +633,7 @@ int test_set_residue_to_rotamer_number(molecules_container_t &mc) { mc.close_molecule(imol); return status; } - coot::Cartesian pos_start = coot::Cartesian(at_start->x, at_start->y, at_start->z); + coot::Cartesian pos_start = coot::Cartesian(at_start->x(), at_start->y(), at_start->z()); int result = mc.set_residue_to_rotamer_number(imol, residue_cid, alt_conf, rotamer_number); @@ -642,7 +644,7 @@ int test_set_residue_to_rotamer_number(molecules_container_t &mc) { mc.close_molecule(imol); return status; } - coot::Cartesian pos_end = coot::Cartesian(at_end->x, at_end->y, at_end->z); + coot::Cartesian pos_end = coot::Cartesian(at_end->x(), at_end->y(), at_end->z()); double dist_moved = std::sqrt(coot::Cartesian::lengthsq(pos_start, pos_end)); std::cout << "CG atom moved " << dist_moved << " Å by set_residue_to_rotamer_number()" << std::endl; @@ -1211,9 +1213,9 @@ int test_crowther_rotation_with_model(molecules_container_t &mc) { int n_atoms; mol->GetSelIndex(SelHnd, sel_atoms, n_atoms); for (int i=0; ix += shift.x(); - sel_atoms[i]->y += shift.y(); - sel_atoms[i]->z += shift.z(); + sel_atoms[i]->x() += shift.x(); + sel_atoms[i]->y() += shift.y(); + sel_atoms[i]->z() += shift.z(); } std::cout << "INFO:: model centre: " << mol_centre.second.format() @@ -1439,9 +1441,9 @@ int test_crowther_rotation_with_model(molecules_container_t &mc) { int na2; mol2->GetSelIndex(sel2, atoms2, na2); for (int i=0; ix += cc2.x() - mc2.second.x(); - atoms2[i]->y += cc2.y() - mc2.second.y(); - atoms2[i]->z += cc2.z() - mc2.second.z(); + atoms2[i]->x() += cc2.x() - mc2.second.x(); + atoms2[i]->y() += cc2.y() - mc2.second.y(); + atoms2[i]->z() += cc2.z() - mc2.second.z(); } clipper::Xmap model_map2 = coot::util::calc_atom_map(mol2, sel2, cell2, spacegroup, gs2); mol2->DeleteSelection(sel2); @@ -1588,9 +1590,9 @@ int test_phased_translation_function(molecules_container_t &mc) { int n_atoms; mol->GetSelIndex(SelHnd, sel_atoms, n_atoms); for (int i=0; ix += shift.x(); - sel_atoms[i]->y += shift.y(); - sel_atoms[i]->z += shift.z(); + sel_atoms[i]->x() += shift.x(); + sel_atoms[i]->y() += shift.y(); + sel_atoms[i]->z() += shift.z(); } // Compute atom map for the model, extract fragment @@ -1630,26 +1632,26 @@ int test_phased_translation_function(molecules_container_t &mc) { // Shift model back to origin (undo the cell-centre shift) for (int i=0; ix -= shift.x(); - sel_atoms[i]->y -= shift.y(); - sel_atoms[i]->z -= shift.z(); + sel_atoms[i]->x() -= shift.x(); + sel_atoms[i]->y() -= shift.y(); + sel_atoms[i]->z() -= shift.z(); } // Now centre at the true origin clipper::Coord_orth mc2 = mol_centre.second; for (int i=0; ix -= mc2.x(); - sel_atoms[i]->y -= mc2.y(); - sel_atoms[i]->z -= mc2.z(); + sel_atoms[i]->x() -= mc2.x(); + sel_atoms[i]->y() -= mc2.y(); + sel_atoms[i]->z() -= mc2.z(); } // Apply the rotation glm::mat3 rot_mat = glm::mat3_cast(best_rotation); for (int i=0; ix, sel_atoms[i]->y, sel_atoms[i]->z); + glm::vec3 pos(sel_atoms[i]->x(), sel_atoms[i]->y(), sel_atoms[i]->z()); glm::vec3 rotated = rot_mat * pos; - sel_atoms[i]->x = rotated.x; - sel_atoms[i]->y = rotated.y; - sel_atoms[i]->z = rotated.z; + sel_atoms[i]->x() = rotated.x; + sel_atoms[i]->y() = rotated.y; + sel_atoms[i]->z() = rotated.z; } std::cout << "INFO:: model centred at origin and rotated, n_atoms=" << n_atoms << std::endl; @@ -1787,7 +1789,7 @@ int test_molecular_placement_pipeline(molecules_container_t &mc) { for (int i=0; iGetAtomName()); if (aname == " CA " || aname == "CA") - ca_coords.push_back(clipper::Coord_orth(atoms[i]->x, atoms[i]->y, atoms[i]->z)); + ca_coords.push_back(clipper::Coord_orth(atoms[i]->x(), atoms[i]->y(), atoms[i]->z())); } mol_p->DeleteSelection(sel); return ca_coords; @@ -1931,7 +1933,7 @@ int test_molecular_placement_pipeline_r_chain(molecules_container_t &mc) { for (int i=0; iGetAtomName()); if (aname == " CA " || aname == "CA") - ca_coords.push_back(clipper::Coord_orth(atoms[i]->x, atoms[i]->y, atoms[i]->z)); + ca_coords.push_back(clipper::Coord_orth(atoms[i]->x(), atoms[i]->y(), atoms[i]->z())); } mol_p->DeleteSelection(sel); return ca_coords; @@ -2123,7 +2125,7 @@ int test_delete_residue(molecules_container_t &mc) { coot::Cartesian atom_to_cartesian(mmdb::Atom *at) { - return coot::Cartesian(at->x, at->y, at->z); + return coot::Cartesian(at->x(), at->y(), at->z()); } @@ -2342,20 +2344,20 @@ int test_rsr_using_multi_atom_cid(molecules_container_t &mc) { mmdb::Atom *at_1 = residue_p_1->GetAtom(iat); if (! at_1->isTer()) { std::string atom_name_1(at_1->GetAtomName()); - std::string alt_conf_1(at_1->altLoc); + std::string alt_conf_1(at_1->altLoc()); int n_atoms_2 = residue_p_2->GetNumberOfAtoms(); for (int jat=0; jatGetAtom(jat); if (! at_2->isTer()) { std::string atom_name_2(at_2->GetAtomName()); - std::string alt_conf_2(at_2->altLoc); + std::string alt_conf_2(at_2->altLoc()); if (atom_name_1 == atom_name_2) { if (alt_conf_1 == alt_conf_2) { n_checked++; - float dx = at_1->x - at_2->x; - float dy = at_1->y - at_2->y; - float dz = at_1->z - at_2->z; + float dx = at_1->x() - at_2->x(); + float dy = at_1->y() - at_2->y(); + float dz = at_1->z() - at_2->z(); if ((fabsf(dx) + fabsf(dy) + fabsf(dz)) > 0.01) n_diffs++; } @@ -2406,7 +2408,7 @@ int test_rsr_using_multi_atom_cid(molecules_container_t &mc) { int test_add_terminal_residue(molecules_container_t &mc) { auto mmdb_to_cartesian = [] (mmdb::Atom *at) { - return coot::Cartesian(at->x, at->y, at->z); + return coot::Cartesian(at->x(), at->y(), at->z()); }; auto glm_to_cartesian = [] (const glm::vec3 &gp) { @@ -4351,7 +4353,7 @@ int test_add_alt_conf(molecules_container_t &mc) { for (int iat=0; iatisTer()) { - std::cout << iat << " " << coot::atom_spec_t(at) << " " << at->x << " " << at->y << " " << at->z << std::endl; + std::cout << iat << " " << coot::atom_spec_t(at) << " " << at->x() << " " << at->y() << " " << at->z() << std::endl; } } if (n_residue_atoms > 22) @@ -6528,11 +6530,11 @@ int test_mask_atom_selection(molecules_container_t &mc) { if (n_selected_atoms > 0) { for (int i=0; ix, at->y, at->z); + clipper::Coord_orth pos(at->x(), at->y(), at->z()); std::cout << "in test_mask_atom_selection() found atom " << at->GetResName() << " " << at->GetSeqNum() << " " << ":" << at->GetAtomName() << ": " << pos.format() << std::endl; - float f = mc.get_density_at_position(imol_masked, at->x, at->y, at-> z); + float f = mc.get_density_at_position(imol_masked, at->x(), at->y(), at-> z()); if (f < 0.00001) { status = 1; } @@ -6589,7 +6591,7 @@ int test_B_factor_multiply(molecules_container_t &mc) { for (int iat=0; iatisTer()) { - B_pre.push_back(at->tempFactor); + B_pre.push_back(at->tempFactor()); } } @@ -6601,7 +6603,7 @@ int test_B_factor_multiply(molecules_container_t &mc) { for (int iat=0; iatisTer()) { - B_post.push_back(at->tempFactor); + B_post.push_back(at->tempFactor()); } } } @@ -6789,7 +6791,7 @@ int test_shiftfield_b_factor_refinement(molecules_container_t &mc) { for (int iat=0; iatisTer()) { - sum += at->tempFactor; + sum += at->tempFactor(); count++; } } @@ -7707,7 +7709,7 @@ int test_set_occupancy(molecules_container_t &mc) { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - if (at->occupancy < 0.00001) n_zero++; + if (at->occupancy() < 0.00001) n_zero++; } } } @@ -8301,18 +8303,42 @@ print_results_summary() { } +template +int run_test_maybe(const std::string& filter, Function test_func, const char* test_name, Args&&... args) { + std::string name_str(test_name); + + // If a filter is provided and the test name doesn't contain it, skip the test + if (!filter.empty() && name_str.find(filter) == std::string::npos) { + return 0; // Skipped test contributes 0 to the fail/error count + } + + // Run the actual test function + std::cout << "Running " << test_name << std::endl; + return run_test(test_func, test_name, std::forward(args)...); + std::cout << "Completed " << test_name << std::endl; +} int main(int argc, char **argv) { int status = 0; write_test_name("---"); bool last_test_only = false; - if (argc > 1) { - std::string arg(argv[1]); - if (arg == "last-test-only") + std::string filter = ""; + + // Parse command line arguments + for (int i = 1; i < argc; ++i) { + std::string arg(argv[i]); + + if (arg == "last-test-only") { last_test_only = true; + } + else if (arg == "--filter" && i + 1 < argc) { + filter = argv[++i]; // Get the next argument as the filter term + } + else if (arg.rfind("--filter=", 0) == 0) { // Handles --filter=my_test syntax + filter = arg.substr(9); + } } - int all_tests_status = 1; // fail! { @@ -8337,173 +8363,173 @@ int main(int argc, char **argv) { if (! last_test_only) { - status += run_test(test_new_position_for_atoms_in_residues, "new positions for atoms in residues", mc); - status += run_test(test_transformation_for_atom_selection, "transformation for atoms", mc); - status += run_test(test_copy_fragment_using_residue_range, "copy-fragment using residue range", mc); - status += run_test(test_density_correlation_validation, "density correlation validation", mc); - status += run_test(test_pepflips_using_difference_map, "Pepflips from Difference Map", mc); - status += run_test(test_difference_map_contours, "difference map density mesh", mc); - status += run_test(test_rota_dodecs_mesh, "rotamer dodecahedra mesh", mc); - status += run_test(test_rsr_using_residue_range, "rsr using residue range", mc); - status += run_test(test_rsr_using_multi_atom_cid, "multi-atom-cid RSR", mc); - status += run_test(test_copy_fragment_using_cid, "copy-fragment using cid", mc); - status += run_test(test_no_dictionary_residues, "no-dictionary residues", mc); - status += run_test(test_cis_trans, "cis_trans conversion", mc); - status += run_test(test_rsr_using_atom_cid, "rsr using atom cid", mc); - status += run_test(test_auto_fit_rotamer_1, "auto-fit rotamer", mc); - status += run_test(test_auto_fit_rotamer_2, "auto-fit rotamer t2", mc); - status += run_test(test_delete_molecule, "delete_moelcule", mc); - status += run_test(test_rama_balls_mesh, "rama balls mesh", mc); - status += run_test(test_density_mesh, "density mesh", mc); - status += run_test(test_updating_maps, "updating maps", mc); - status += run_test(test_delete_residue, "delete residue", mc); - status += run_test(test_delete_chain, "delete chain", mc); - status += run_test(test_fill_partial, "Fill partially-filled residues", mc); - status += run_test(test_delete_atom, "delete atom", mc); - status += run_test(test_pepflips, "pepflips", mc); - status += run_test(test_mutate, "mutate", mc); - status += run_test(test_rsr, "rsr", mc); - status += run_test(test_jed_flip, "JED Flip", mc); - status += run_test(test_add_water, "add waters", mc); - status += run_test(test_bonds_mesh, "bonds mesh", mc); - status += run_test(test_eigen_flip, "Eigen Flip", mc); - status += run_test(test_read_a_map, "read a map", mc); - status += run_test(test_add_compound, "add compound", mc); - status += run_test(test_weird_delete, "delete II", mc); - status += run_test(test_add_alt_conf, "add alt conf", mc); - status += run_test(test_delete_literal, "delete literal", mc); - status += run_test(test_side_chain_180, "side-chain 180", mc); - status += run_test(test_peptide_omega, "peptide omega", mc); + status += run_test_maybe(filter, test_new_position_for_atoms_in_residues, "new positions for atoms in residues", mc); + status += run_test_maybe(filter, test_transformation_for_atom_selection, "transformation for atoms", mc); + status += run_test_maybe(filter, test_copy_fragment_using_residue_range, "copy-fragment using residue range", mc); + status += run_test_maybe(filter, test_density_correlation_validation, "density correlation validation", mc); + status += run_test_maybe(filter, test_pepflips_using_difference_map, "Pepflips from Difference Map", mc); + status += run_test_maybe(filter, test_difference_map_contours, "difference map density mesh", mc); + status += run_test_maybe(filter, test_rota_dodecs_mesh, "rotamer dodecahedra mesh", mc); + status += run_test_maybe(filter, test_rsr_using_residue_range, "rsr using residue range", mc); + status += run_test_maybe(filter, test_rsr_using_multi_atom_cid, "multi-atom-cid RSR", mc); + status += run_test_maybe(filter, test_copy_fragment_using_cid, "copy-fragment using cid", mc); + status += run_test_maybe(filter, test_no_dictionary_residues, "no-dictionary residues", mc); + status += run_test_maybe(filter, test_cis_trans, "cis_trans conversion", mc); + status += run_test_maybe(filter, test_rsr_using_atom_cid, "rsr using atom cid", mc); + status += run_test_maybe(filter, test_auto_fit_rotamer_1, "auto-fit rotamer", mc); + status += run_test_maybe(filter, test_auto_fit_rotamer_2, "auto-fit rotamer t2", mc); + status += run_test_maybe(filter, test_delete_molecule, "delete_moelcule", mc); + status += run_test_maybe(filter, test_rama_balls_mesh, "rama balls mesh", mc); + status += run_test_maybe(filter, test_density_mesh, "density mesh", mc); + status += run_test_maybe(filter, test_updating_maps, "updating maps", mc); + status += run_test_maybe(filter, test_delete_residue, "delete residue", mc); + status += run_test_maybe(filter, test_delete_chain, "delete chain", mc); + status += run_test_maybe(filter, test_fill_partial, "Fill partially-filled residues", mc); + status += run_test_maybe(filter, test_delete_atom, "delete atom", mc); + status += run_test_maybe(filter, test_pepflips, "pepflips", mc); + status += run_test_maybe(filter, test_mutate, "mutate", mc); + status += run_test_maybe(filter, test_rsr, "rsr", mc); + status += run_test_maybe(filter, test_jed_flip, "JED Flip", mc); + status += run_test_maybe(filter, test_add_water, "add waters", mc); + status += run_test_maybe(filter, test_bonds_mesh, "bonds mesh", mc); + status += run_test_maybe(filter, test_eigen_flip, "Eigen Flip", mc); + status += run_test_maybe(filter, test_read_a_map, "read a map", mc); + status += run_test_maybe(filter, test_add_compound, "add compound", mc); + status += run_test_maybe(filter, test_weird_delete, "delete II", mc); + status += run_test_maybe(filter, test_add_alt_conf, "add alt conf", mc); + status += run_test_maybe(filter, test_delete_literal, "delete literal", mc); + status += run_test_maybe(filter, test_side_chain_180, "side-chain 180", mc); + status += run_test_maybe(filter, test_peptide_omega, "peptide omega", mc); // Molecular replacement tests (moved here to run before potentially-crashing tests) - status += run_test(test_patterson_from_map_using_mtz, "patterson from mtz", mc); - status += run_test(test_patterson_from_map_using_map, "patterson from map", mc); - status += run_test(test_self_rotation_function, "self rotation function", mc); - status += run_test(test_cross_rotation_function, "cross rotation function", mc); - status += run_test(test_crowther_rotation_function, "crowther rotation fn", mc); - status += run_test(test_crowther_rotation_with_model, "crowther with model", mc); - status += run_test(test_phased_translation_function, "phased translation fn", mc); - status += run_test(test_molecular_placement_pipeline, "MR pipeline", mc); - status += run_test(test_molecular_placement_pipeline_r_chain, "MR R-chain", mc); - - status += run_test(test_undo_and_redo, "undo and redo", mc); - status += run_test(test_undo_and_redo_2, "undo/redo 2", mc); - status += run_test(test_merge_molecules, "merge molecules", mc); - status += run_test(test_dictionary_bonds, "dictionary bonds", mc); - status += run_test(test_replace_fragment, "replace fragment", mc); - status += run_test(test_gaussian_surface, "Gaussian surface", mc); - status += run_test(test_missing_atoms_info, "missing atom info", mc); - status += run_test(test_move_molecule_here, "move_molecule_here", mc); - status += run_test(test_rotamer_validation, "rotamer validation", mc); - status += run_test(test_ligand_contact_dots, "ligand contact dots", mc); - status += run_test(test_difference_map_peaks, "Difference Map Peaks", mc); - status += run_test(test_rama_validation, "rama validation 2", mc); // for the plot, not the graph - status += run_test(test_ramachandran_analysis, "ramachandran analysis", mc); // for the graph, not the plot - status += run_test(test_non_standard_residues, "non-standard residues", mc); - status += run_test(test_import_cif_dictionary, "import cif dictionary", mc); - status += run_test(test_add_terminal_residue, "add terminal residue", mc); - status += run_test(test_sequence_generator, "Make a sequence string", mc); - status += run_test(test_instanced_rota_markup, "Instanced rotamer mesh", mc); - status += run_test(test_new_position_for_atoms,"New positions for atoms", mc); - status += run_test(test_molecular_representation, "Molecular representation mesh", mc); + status += run_test_maybe(filter, test_patterson_from_map_using_mtz, "patterson from mtz", mc); + status += run_test_maybe(filter, test_patterson_from_map_using_map, "patterson from map", mc); + status += run_test_maybe(filter, test_self_rotation_function, "self rotation function", mc); + status += run_test_maybe(filter, test_cross_rotation_function, "cross rotation function", mc); + status += run_test_maybe(filter, test_crowther_rotation_function, "crowther rotation fn", mc); + status += run_test_maybe(filter, test_crowther_rotation_with_model, "crowther with model", mc); + status += run_test_maybe(filter, test_phased_translation_function, "phased translation fn", mc); + status += run_test_maybe(filter, test_molecular_placement_pipeline, "MR pipeline", mc); + status += run_test_maybe(filter, test_molecular_placement_pipeline_r_chain, "MR R-chain", mc); + + status += run_test_maybe(filter, test_undo_and_redo, "undo and redo", mc); + status += run_test_maybe(filter, test_undo_and_redo_2, "undo/redo 2", mc); + status += run_test_maybe(filter, test_merge_molecules, "merge molecules", mc); + status += run_test_maybe(filter, test_dictionary_bonds, "dictionary bonds", mc); + status += run_test_maybe(filter, test_replace_fragment, "replace fragment", mc); + status += run_test_maybe(filter, test_gaussian_surface, "Gaussian surface", mc); + status += run_test_maybe(filter, test_missing_atoms_info, "missing atom info", mc); + status += run_test_maybe(filter, test_move_molecule_here, "move_molecule_here", mc); + status += run_test_maybe(filter, test_rotamer_validation, "rotamer validation", mc); + status += run_test_maybe(filter, test_ligand_contact_dots, "ligand contact dots", mc); + status += run_test_maybe(filter, test_difference_map_peaks, "Difference Map Peaks", mc); + status += run_test_maybe(filter, test_rama_validation, "rama validation 2", mc); // for the plot, not the graph + status += run_test_maybe(filter, test_ramachandran_analysis, "ramachandran analysis", mc); // for the graph, not the plot + status += run_test_maybe(filter, test_non_standard_residues, "non-standard residues", mc); + status += run_test_maybe(filter, test_import_cif_dictionary, "import cif dictionary", mc); + status += run_test_maybe(filter, test_add_terminal_residue, "add terminal residue", mc); + status += run_test_maybe(filter, test_sequence_generator, "Make a sequence string", mc); + status += run_test_maybe(filter, test_instanced_rota_markup, "Instanced rotamer mesh", mc); + status += run_test_maybe(filter, test_new_position_for_atoms,"New positions for atoms", mc); + status += run_test_maybe(filter, test_molecular_representation, "Molecular representation mesh", mc); // remove these for now - I know why they don't work and they are slow. - // status += run_test(test_rigid_body_fit, "Rigid-body fit", mc); - // status += run_test(test_ligand_fitting_here, "Ligand fitting here", mc); - // status += run_test(test_jiggle_fit, "Jiggle-fit", mc); - // status += run_test(test_jiggle_fit_with_blur, "Jiggle-fit-with-blur", mc); - // status += run_test(test_ligand_fitting_in_map, "ligand fitting in map", mc); - status += run_test(test_multiligands_lig_bonding, "Some multiligands bonding", mc); - status += run_test(test_gltf_export_via_api, "glTF via api", mc); - status += run_test(test_long_name_ligand_cif_merge, "Long-name ligand cif merge", mc); - status += run_test(test_user_defined_bond_colours_v3, "user-defined colours v3", mc); - status += run_test(test_gltf_export, "glTF export", mc); - status += run_test(test_5char_ligand_merge, "5-char ligand merge", mc); - status += run_test(test_thread_pool, "thread pool", mc); - // status += run_test(test_thread_launching, "thread launching", mc); // this is not a helpful test - status += run_test(test_cif_gphl_chem_comp_info, "extracting gphl info", mc); - // status += run_test(test_test_the_threading, "threading speed test", mc); // not helpful - // status += run_test(test_contouring_timing, "contouring timing", mc); // not helpful + // status += run_test_maybe(filter, test_rigid_body_fit, "Rigid-body fit", mc); + // status += run_test_maybe(filter, test_ligand_fitting_here, "Ligand fitting here", mc); + // status += run_test_maybe(filter, test_jiggle_fit, "Jiggle-fit", mc); + // status += run_test_maybe(filter, test_jiggle_fit_with_blur, "Jiggle-fit-with-blur", mc); + // status += run_test_maybe(filter, test_ligand_fitting_in_map, "ligand fitting in map", mc); + status += run_test_maybe(filter, test_multiligands_lig_bonding, "Some multiligands bonding", mc); + status += run_test_maybe(filter, test_gltf_export_via_api, "glTF via api", mc); + status += run_test_maybe(filter, test_long_name_ligand_cif_merge, "Long-name ligand cif merge", mc); + status += run_test_maybe(filter, test_user_defined_bond_colours_v3, "user-defined colours v3", mc); + status += run_test_maybe(filter, test_gltf_export, "glTF export", mc); + status += run_test_maybe(filter, test_5char_ligand_merge, "5-char ligand merge", mc); + status += run_test_maybe(filter, test_thread_pool, "thread pool", mc); + // status += run_test_maybe(filter, test_thread_launching, "thread launching", mc); // this is not a helpful test + status += run_test_maybe(filter, test_cif_gphl_chem_comp_info, "extracting gphl info", mc); + // status += run_test_maybe(filter, test_test_the_threading, "threading speed test", mc); // not helpful + // status += run_test_maybe(filter, test_contouring_timing, "contouring timing", mc); // not helpful //reinstate this test when mmdb chain selection works - // status += run_test(test_mmcif_atom_selection, "mmCIF atom selection", mc); + // status += run_test_maybe(filter, test_mmcif_atom_selection, "mmCIF atom selection", mc); //reinstate this test when gemmi is used for writing cif files - // status += run_test(test_mmcif_as_string, "mmCIF as string", mc); - status += run_test(test_pdb_as_string, "PDB as string", mc); - status += run_test(test_cif_writer, "mmCIF dictionary writer", mc); - status += run_test(test_residues_near_residues, "residues near residues", mc); - status += run_test(test_electro_molecular_representation, "electro molecular representation mesh", mc); - status += run_test(test_replace_fragment, "replace fragment", mc); - status += run_test(test_ncs_chains, "NCS chains", mc); - status += run_test(test_omega_5tig_cif, "Omega for 5tig cif", mc); - // status += run_test(test_jiggle_fit_params, "actually testing for goodness pr params", mc); // not useful - status += run_test(test_dark_mode_colours, "light vs dark mode colours", mc); - status += run_test(test_read_extra_restraints, "read extra restraints", mc); - status += run_test(test_map_histogram, "map histogram", mc); - status += run_test(test_auto_read_mtz, "auto-read-mtz", mc); - status += run_test(test_read_a_missing_map, "read a missing map file ", mc); - status += run_test(test_colour_map_by_other_map, "colour-map-by-other-map", mc); - status += run_test(test_something_filo, "Self something filo", mc); - status += run_test(test_self_restraints, "Self restraints mesh", mc); - status += run_test(test_other_user_defined_colours_other, "New colour test", mc); - status += run_test(test_is_em_map, "EM map flag is correctly set?", mc); - status += run_test(test_user_defined_bond_colours_v2, "user-defined bond colours v2", mc); + // status += run_test_maybe(filter, test_mmcif_as_string, "mmCIF as string", mc); + status += run_test_maybe(filter, test_pdb_as_string, "PDB as string", mc); + status += run_test_maybe(filter, test_cif_writer, "mmCIF dictionary writer", mc); + status += run_test_maybe(filter, test_residues_near_residues, "residues near residues", mc); + status += run_test_maybe(filter, test_electro_molecular_representation, "electro molecular representation mesh", mc); + status += run_test_maybe(filter, test_replace_fragment, "replace fragment", mc); + status += run_test_maybe(filter, test_ncs_chains, "NCS chains", mc); + status += run_test_maybe(filter, test_omega_5tig_cif, "Omega for 5tig cif", mc); + // status += run_test_maybe(filter, test_jiggle_fit_params, "actually testing for goodness pr params", mc); // not useful + status += run_test_maybe(filter, test_dark_mode_colours, "light vs dark mode colours", mc); + status += run_test_maybe(filter, test_read_extra_restraints, "read extra restraints", mc); + status += run_test_maybe(filter, test_map_histogram, "map histogram", mc); + status += run_test_maybe(filter, test_auto_read_mtz, "auto-read-mtz", mc); + status += run_test_maybe(filter, test_read_a_missing_map, "read a missing map file ", mc); + status += run_test_maybe(filter, test_colour_map_by_other_map, "colour-map-by-other-map", mc); + status += run_test_maybe(filter, test_something_filo, "Self something filo", mc); + status += run_test_maybe(filter, test_self_restraints, "Self restraints mesh", mc); + status += run_test_maybe(filter, test_other_user_defined_colours_other, "New colour test", mc); + status += run_test_maybe(filter, test_is_em_map, "EM map flag is correctly set?", mc); + status += run_test_maybe(filter, test_user_defined_bond_colours_v2, "user-defined bond colours v2", mc); // reinstate when add alt conf has been added - // status += run_test(test_alt_conf_and_rotamer, "Alt Conf then rotamer", mc); - status += run_test(test_editing_session_tutorial_1, "an Tutorial 1 editing session", mc); - status += run_test(test_broken_function, "Something was broken", mc); - status += run_test(test_delete_side_chain, "delete side chain", mc); - status += run_test(test_colour_rules, "colour rules", mc); - status += run_test(test_mmrrcc, "MMRRCC", mc); - status += run_test(test_instanced_bonds_mesh, "insta bonds mesh", mc); - status += run_test(test_instanced_bonds_mesh_v2, "test instanced bond selection v2", mc); - status += run_test(test_utils, "utils", mc); - status += run_test(test_svg, "svg string", mc); - status += run_test(test_superpose, "SSM superpose ", mc); - status += run_test(test_multi_colour_rules, "multi colour rules ", mc); - status += run_test(test_non_drawn_atoms, "non-drawn atoms", mc); - status += run_test(test_symmetry, "symmetry", mc); - status += run_test(test_add_hydrogen_atoms, "add hydrogen atoms", mc); - status += run_test(test_set_rotamer, "set rotamer ", mc); - status += run_test(test_alt_conf_and_rotamer_v2, "alt-conf and rotamer v2 ", mc); - status += run_test(test_moorhen_h_bonds, "moorhen H-bonds ", mc); - status += run_test(test_number_of_hydrogen_atoms, "number of hydrogen atoms ", mc); - status += run_test(test_cell, "cell", mc); - status += run_test(test_map_centre, "map centre", mc); - status += run_test(test_dragged_atom_refinement, "dragged atom refinement", mc); - status += run_test(test_bespoke_carbon_colour, "bespoke carbon colours ", mc); - status += run_test(test_replace_model_from_file, "replace model from file", mc); - status += run_test(test_user_defined_bond_colours, "user-defined bond colours", mc); - status += run_test(test_replace_map, "replace map from mtz", mc); - status += run_test(test_residue_name_group, "residue name group", mc); - status += run_test(test_mask_atom_selection, "mask atom selection", mc); - status += run_test(test_write_map_is_sane, "write map is sane", mc); - status += run_test(test_replace_large_fragment, "refine and replace large fragment", mc); - status += run_test(test_molecule_diameter, "molecule diameter", mc); - status += run_test(test_B_factor_multiply, "B-factor multiply", mc); - status += run_test(test_change_chain_id, "change chain id", mc); - status += run_test(test_17257, "read emd_17257.map.gz", mc); + // status += run_test_maybe(filter, test_alt_conf_and_rotamer, "Alt Conf then rotamer", mc); + status += run_test_maybe(filter, test_editing_session_tutorial_1, "an Tutorial 1 editing session", mc); + status += run_test_maybe(filter, test_broken_function, "Something was broken", mc); + status += run_test_maybe(filter, test_delete_side_chain, "delete side chain", mc); + status += run_test_maybe(filter, test_colour_rules, "colour rules", mc); + status += run_test_maybe(filter, test_mmrrcc, "MMRRCC", mc); + status += run_test_maybe(filter, test_instanced_bonds_mesh, "insta bonds mesh", mc); + status += run_test_maybe(filter, test_instanced_bonds_mesh_v2, "test instanced bond selection v2", mc); + status += run_test_maybe(filter, test_utils, "utils", mc); + status += run_test_maybe(filter, test_svg, "svg string", mc); + status += run_test_maybe(filter, test_superpose, "SSM superpose ", mc); + status += run_test_maybe(filter, test_multi_colour_rules, "multi colour rules ", mc); + status += run_test_maybe(filter, test_non_drawn_atoms, "non-drawn atoms", mc); + status += run_test_maybe(filter, test_symmetry, "symmetry", mc); + status += run_test_maybe(filter, test_add_hydrogen_atoms, "add hydrogen atoms", mc); + status += run_test_maybe(filter, test_set_rotamer, "set rotamer ", mc); + status += run_test_maybe(filter, test_alt_conf_and_rotamer_v2, "alt-conf and rotamer v2 ", mc); + status += run_test_maybe(filter, test_moorhen_h_bonds, "moorhen H-bonds ", mc); + status += run_test_maybe(filter, test_number_of_hydrogen_atoms, "number of hydrogen atoms ", mc); + status += run_test_maybe(filter, test_cell, "cell", mc); + status += run_test_maybe(filter, test_map_centre, "map centre", mc); + status += run_test_maybe(filter, test_dragged_atom_refinement, "dragged atom refinement", mc); + status += run_test_maybe(filter, test_bespoke_carbon_colour, "bespoke carbon colours ", mc); + status += run_test_maybe(filter, test_replace_model_from_file, "replace model from file", mc); + status += run_test_maybe(filter, test_user_defined_bond_colours, "user-defined bond colours", mc); + status += run_test_maybe(filter, test_replace_map, "replace map from mtz", mc); + status += run_test_maybe(filter, test_residue_name_group, "residue name group", mc); + status += run_test_maybe(filter, test_mask_atom_selection, "mask atom selection", mc); + status += run_test_maybe(filter, test_write_map_is_sane, "write map is sane", mc); + status += run_test_maybe(filter, test_replace_large_fragment, "refine and replace large fragment", mc); + status += run_test_maybe(filter, test_molecule_diameter, "molecule diameter", mc); + status += run_test_maybe(filter, test_B_factor_multiply, "B-factor multiply", mc); + status += run_test_maybe(filter, test_change_chain_id, "change chain id", mc); + status += run_test_maybe(filter, test_17257, "read emd_17257.map.gz", mc); // 2026-02-14-PE too many gemmi errors. Let's shut it down for now mc.set_use_gemmi(false); - status += run_test(test_get_diff_map_peaks, "get diff map peaks", mc); - status += run_test(test_shiftfield_b_factor_refinement, "Shiftfield B", mc); - status += run_test(test_non_drawn_CA_bonds, "non-drawn bonds in CA+LIGANDS", mc); - status += run_test(test_change_chain_id_1, "change chain-id filo-1", mc); - status += run_test(test_split_model, "Split model", mc); - status += run_test(test_make_ensemble, "Make Ensemble", mc); - status += run_test(test_end_delete_closed_molecules, "end delete close molecules", mc); - status += run_test(test_moorhen_h_bonds, "moorhen H-bonds ", mc); - status += run_test(test_texture_as_floats, "Texture as Floats ", mc); - status += run_test(test_n_map_sections, "N map sections ", mc); + status += run_test_maybe(filter, test_get_diff_map_peaks, "get diff map peaks", mc); + // status += run_test_maybe(filter, test_shiftfield_b_factor_refinement, "Shiftfield B", mc); + status += run_test_maybe(filter, test_non_drawn_CA_bonds, "non-drawn bonds in CA+LIGANDS", mc); + status += run_test_maybe(filter, test_change_chain_id_1, "change chain-id filo-1", mc); + status += run_test_maybe(filter, test_split_model, "Split model", mc); + status += run_test_maybe(filter, test_make_ensemble, "Make Ensemble", mc); + status += run_test_maybe(filter, test_end_delete_closed_molecules, "end delete close molecules", mc); + status += run_test_maybe(filter, test_moorhen_h_bonds, "moorhen H-bonds ", mc); + status += run_test_maybe(filter, test_texture_as_floats, "Texture as Floats ", mc); + status += run_test_maybe(filter, test_n_map_sections, "N map sections ", mc); #ifdef MAKE_ENHANCED_LIGAND_TOOLS - status += run_test(test_pdbe_dictionary_depiction, "pdbe dictionary depiction", mc); - // status += run_test(test_rdkit_mol, "RDKit mol", mc); + status += run_test_maybe(filter, test_pdbe_dictionary_depiction, "pdbe dictionary depiction", mc); + // status += run_test_maybe(filter, test_rdkit_mol, "RDKit mol", mc); #endif #ifdef USE_GEMMI - status += run_test(test_disappearing_ligand, "Disappearing ligand", mc); + status += run_test_maybe(filter, test_disappearing_ligand, "Disappearing ligand", mc); #endif // Note to self: // change the autofit_rotamer test so that it tests the change of positions of the atoms of the neighboring residues. @@ -8512,54 +8538,54 @@ int main(int argc, char **argv) { { #ifdef MAKE_ENHANCED_LIGAND_TOOLS #endif - // status += run_test(test_lsq_superpose, "LSQ superpose", mc); - // status += run_test(test_change_rotamer, "Change Rotamer (Filo)", mc); - // status += run_test(test_alpha_in_colour_holder, "Alpha value in colour holder", mc); - // status += run_test(test_gaussian_surface, "Gaussian surface", mc); - // status += run_test(test_Q_Score, "Q Score", mc); - // status += run_test(test_assign_sequence, "Assign Sequence", mc); - // status += run_test(test_undo_and_redo_2, "Undo and redo 2", mc); - // status += run_test(test_gltf_export_via_api, "glTF via api", mc); - // status += run_test(test_import_ligands_with_same_name_and_animated_refinement, "Test import ligands with same name and animated refinement", mc); - // status += run_test(test_dictionary_conformers, "Dictionary Conformers", mc); - // status += run_test(test_ligand_distortion, "Ligand Distortion", mc); - // status += run_test(test_import_LIG_dictionary, "Import LIG.cif", mc); - // status += run_test(test_tricky_ligand_problem, "Tricky Ligand import/refine", mc); - // status += run_test(test_dictionary_acedrg_atom_types, "Acedrg atom types", mc); - // status += run_test(test_dictionary_acedrg_atom_types_for_ligand, "Acedrg atom types for ligand", mc); - // status += run_test(test_long_name_ligand_cif_merge, "test long name ligand cif merge", mc); - // status += run_test(test_merge_ligand_and_gemmi_parse_mmcif, "test_merge_ligand_and_gemmi_parse_mmcif", mc); - // status += run_test(test_delete_two_add_one_using_gemmi, "test_delete_two_add_one_using_gemmi", mc); - // status += run_test(test_dictionary_atom_name_match, "dictionary atom names match", mc); - // status += run_test(test_average_position_functions, "average position functions", mc); - - // status += run_test(test_get_torsion, "get_torsion", mc); - // status += run_test(test_set_occupancy, "set occupancy", mc); - // status += run_test(test_missing_residues, "missing residues", mc); - // status += run_test(test_mutation_info, "mutation info", mc); - // status += run_test(test_scale_map, "scale_map", mc); - // status += run_test(test_add_RNA_residue, "add RNA residue", mc); - // status += run_test(test_HOLE, "HOLE", mc); - // status += run_test(test_is_nucleic_acid, "is nucleic acid?", mc); - // status += run_test(test_delete_all_carbohydrate, "delete all carbohydrate", mc); - // status += run_test(test_instanced_goodsell_style_mesh, "instanced goodsell style mesh", mc); - // status += run_test(test_map_vertices_histogram, "map vertices histogram", mc); - // status += run_test(test_non_XYZ_EM_map_status, "non-XYZ map status", mc); + // status += run_test_maybe(filter, test_lsq_superpose, "LSQ superpose", mc); + // status += run_test_maybe(filter, test_change_rotamer, "Change Rotamer (Filo)", mc); + // status += run_test_maybe(filter, test_alpha_in_colour_holder, "Alpha value in colour holder", mc); + // status += run_test_maybe(filter, test_gaussian_surface, "Gaussian surface", mc); + // status += run_test_maybe(filter, test_Q_Score, "Q Score", mc); + // status += run_test_maybe(filter, test_assign_sequence, "Assign Sequence", mc); + // status += run_test_maybe(filter, test_undo_and_redo_2, "Undo and redo 2", mc); + // status += run_test_maybe(filter, test_gltf_export_via_api, "glTF via api", mc); + // status += run_test_maybe(filter, test_import_ligands_with_same_name_and_animated_refinement, "Test import ligands with same name and animated refinement", mc); + // status += run_test_maybe(filter, test_dictionary_conformers, "Dictionary Conformers", mc); + // status += run_test_maybe(filter, test_ligand_distortion, "Ligand Distortion", mc); + // status += run_test_maybe(filter, test_import_LIG_dictionary, "Import LIG.cif", mc); + // status += run_test_maybe(filter, test_tricky_ligand_problem, "Tricky Ligand import/refine", mc); + // status += run_test_maybe(filter, test_dictionary_acedrg_atom_types, "Acedrg atom types", mc); + // status += run_test_maybe(filter, test_dictionary_acedrg_atom_types_for_ligand, "Acedrg atom types for ligand", mc); + // status += run_test_maybe(filter, test_long_name_ligand_cif_merge, "test long name ligand cif merge", mc); + // status += run_test_maybe(filter, test_merge_ligand_and_gemmi_parse_mmcif, "test_merge_ligand_and_gemmi_parse_mmcif", mc); + // status += run_test_maybe(filter, test_delete_two_add_one_using_gemmi, "test_delete_two_add_one_using_gemmi", mc); + // status += run_test_maybe(filter, test_dictionary_atom_name_match, "dictionary atom names match", mc); + // status += run_test_maybe(filter, test_average_position_functions, "average position functions", mc); + + // status += run_test_maybe(filter, test_get_torsion, "get_torsion", mc); + // status += run_test_maybe(filter, test_set_occupancy, "set occupancy", mc); + // status += run_test_maybe(filter, test_missing_residues, "missing residues", mc); + // status += run_test_maybe(filter, test_mutation_info, "mutation info", mc); + // status += run_test_maybe(filter, test_scale_map, "scale_map", mc); + // status += run_test_maybe(filter, test_add_RNA_residue, "add RNA residue", mc); + // status += run_test_maybe(filter, test_HOLE, "HOLE", mc); + // status += run_test_maybe(filter, test_is_nucleic_acid, "is nucleic acid?", mc); + // status += run_test_maybe(filter, test_delete_all_carbohydrate, "delete all carbohydrate", mc); + // status += run_test_maybe(filter, test_instanced_goodsell_style_mesh, "instanced goodsell style mesh", mc); + // status += run_test_maybe(filter, test_map_vertices_histogram, "map vertices histogram", mc); + // status += run_test_maybe(filter, test_non_XYZ_EM_map_status, "non-XYZ map status", mc); // put these up - // status += run_test(test_radius_of_gyration, "radius of gyration", mc); - // status += run_test(test_temperature_factor_of_atom, "temperature factor of atom", mc); - // status += run_test(test_water_spherical_variance, "water spherical variance", mc); - // status += run_test(test_dedust, "dedust", mc); .... maybe not this one - // status += run_test(test_atom_overlaps, "atom overlaps", mc); - // status += run_test(test_pucker_info, "pucker info", mc); - // status += run_test(test_set_residue_to_rotamer_number, "set residue", mc); - // status += run_test(test_inner_bond_kekulization, "inner-bond kekulization", mc); - // status += run_test(test_gaussian_surface_to_map_molecule, "gaussian-surface to map", mc); - // status += run_test(test_density_mesh, "density mesh", mc); - // status += run_test(test_molecular_placement_pipeline_r_chain, "MR R-chain", mc); - // status += run_test(test_molecular_placement_pipeline, "MR pipeline", mc); - status += run_test(test_rdkit_mol_pickle, "RDKit Mol Pickle", mc); + // status += run_test_maybe(filter, test_radius_of_gyration, "radius of gyration", mc); + // status += run_test_maybe(filter, test_temperature_factor_of_atom, "temperature factor of atom", mc); + // status += run_test_maybe(filter, test_water_spherical_variance, "water spherical variance", mc); + // status += run_test_maybe(filter, test_dedust, "dedust", mc); .... maybe not this one + // status += run_test_maybe(filter, test_atom_overlaps, "atom overlaps", mc); + // status += run_test_maybe(filter, test_pucker_info, "pucker info", mc); + // status += run_test_maybe(filter, test_set_residue_to_rotamer_number, "set residue", mc); + // status += run_test_maybe(filter, test_inner_bond_kekulization, "inner-bond kekulization", mc); + // status += run_test_maybe(filter, test_gaussian_surface_to_map_molecule, "gaussian-surface to map", mc); + // status += run_test_maybe(filter, test_density_mesh, "density mesh", mc); + // status += run_test_maybe(filter, test_molecular_placement_pipeline_r_chain, "MR R-chain", mc); + // status += run_test_maybe(filter, test_molecular_placement_pipeline, "MR pipeline", mc); + status += run_test_maybe(filter, test_rdkit_mol_pickle, "RDKit Mol Pickle", mc); if (status == n_tests) all_tests_status = 0; print_results_summary(); diff --git a/coords/Bond_lines.cc b/coords/Bond_lines.cc index 2686d4d34d..19874f1f27 100644 --- a/coords/Bond_lines.cc +++ b/coords/Bond_lines.cc @@ -515,14 +515,14 @@ Bond_lines_container::construct_from_atom_selection(const atom_selection_contain std::string chain_id1(atom_p_1->GetChainID()); std::string chain_id2(atom_p_2->GetChainID()); - std::string aloc_1(atom_p_1->altLoc); - std::string aloc_2(atom_p_2->altLoc); + std::string aloc_1(atom_p_1->altLoc()); + std::string aloc_2(atom_p_2->altLoc()); - element_1 = atom_p_1->element; - element_2 = atom_p_2->element; + element_1 = atom_p_1->GetElementName(); + element_2 = atom_p_2->GetElementName(); - coot::Cartesian atom_1_pos(atom_p_1->x, atom_p_1->y, atom_p_1->z); - coot::Cartesian atom_2_pos(atom_p_2->x, atom_p_2->y, atom_p_2->z); + coot::Cartesian atom_1_pos(atom_p_1->x(), atom_p_1->y(), atom_p_1->z()); + coot::Cartesian atom_2_pos(atom_p_2->x(), atom_p_2->y(), atom_p_2->z()); if (chain_id1 == chain_id2) { @@ -553,7 +553,7 @@ Bond_lines_container::construct_from_atom_selection(const atom_selection_contain if (labs(res_1 - res_2) < 2) is_neighbour = true; if (! is_neighbour) - if (labs(atom_p_1->residue->index - atom_p_2->residue->index) < 2) + if (labs(atom_p_1->GetResidue()->GetIndex() - atom_p_2->GetResidue()->GetIndex()) < 2) is_neighbour = true; // Maybe DUM-DUM needs it's own bonding selection and drawing function @@ -701,11 +701,11 @@ Bond_lines_container::construct_from_atom_selection(const atom_selection_contain // should this test be here or further up? // Don't bond water Oxygens to each other... 20210817-PE - or anything else. bool do_it = true; - if (atom_p_1->residue != atom_p_2->residue) { - std::string res_name_1(atom_p_1->residue->GetResName()); + if (atom_p_1->GetResidue() != atom_p_2->GetResidue()) { + std::string res_name_1(atom_p_1->GetResidue()->GetResName()); if (res_name_1 == "HOH") do_it = false; - std::string res_name_2(atom_p_2->residue->GetResName()); + std::string res_name_2(atom_p_2->GetResidue()->GetResName()); if (res_name_2 == "HOH") do_it = false; } @@ -766,15 +766,15 @@ Bond_lines_container::add_bond_by_dictionary_maybe(int imol, bool bond_het_residue_by_dictionary = false; if (have_dictionary && geom) - if (atom_p_1->residue == atom_p_2->residue) + if (atom_p_1->GetResidue() == atom_p_2->GetResidue()) if (atom_p_1->Het) if (atom_p_2->Het) { // Have we checked this residue type before and failed to find // a dictionary for it? If so, add it to the vector. - std::pair tp0(0, atom_p_1->residue); - std::pair tp1(1, atom_p_1->residue); + std::pair tp0(0, atom_p_1->GetResidue()); + std::pair tp1(1, atom_p_1->GetResidue()); // add this residue to the vector if it is not there already) // @@ -792,9 +792,9 @@ Bond_lines_container::add_bond_by_dictionary_maybe(int imol, if (it_2 == het_residues->end()) { - if (geom->have_at_least_minimal_dictionary_for_residue_type(atom_p_1->residue->GetResName(), imol)) { + if (geom->have_at_least_minimal_dictionary_for_residue_type(atom_p_1->GetResidue()->GetResName(), imol)) { - if (geom->atoms_match_dictionary(imol, atom_p_1->residue, true, true).first) { + if (geom->atoms_match_dictionary(imol, atom_p_1->GetResidue(), true, true).first) { het_residues->push_back(tp1); bond_het_residue_by_dictionary = true; @@ -828,23 +828,23 @@ Bond_lines_container::mark_atoms_as_bonded(mmdb::Atom *atom_p_1, mmdb::Atom *ato // if (have_udd_atoms) { if (! done_bond_udd_handle) { // already happened for bonds to Hs. - if (! ((!strcmp(atom_p_1->element, " S")) || - (!strcmp(atom_p_1->element, "SE")) || - (!strcmp(atom_p_1->element, "CL")) || - (!strcmp(atom_p_1->element, "BR")) || - (!strcmp(atom_p_1->element, "Cl")) || - (!strcmp(atom_p_1->element, "Br")) || - (!strcmp(atom_p_1->element, " P")))) { + if (! ((!strcmp(atom_p_1->GetElementName(), " S")) || + (!strcmp(atom_p_1->GetElementName(), "SE")) || + (!strcmp(atom_p_1->GetElementName(), "CL")) || + (!strcmp(atom_p_1->GetElementName(), "BR")) || + (!strcmp(atom_p_1->GetElementName(), "Cl")) || + (!strcmp(atom_p_1->GetElementName(), "Br")) || + (!strcmp(atom_p_1->GetElementName(), " P")))) { atom_p_1->PutUDData(udd_handle, graphical_bonds_container::BONDED_WITH_STANDARD_ATOM_BOND); } - if (! ((!strcmp(atom_p_2->element, " S")) || - (!strcmp(atom_p_2->element, "SE")) || - (!strcmp(atom_p_2->element, "CL")) || - (!strcmp(atom_p_2->element, "BR")) || - (!strcmp(atom_p_2->element, "Cl")) || - (!strcmp(atom_p_2->element, "Br")) || - (!strcmp(atom_p_2->element, " P")))) { + if (! ((!strcmp(atom_p_2->GetElementName(), " S")) || + (!strcmp(atom_p_2->GetElementName(), "SE")) || + (!strcmp(atom_p_2->GetElementName(), "CL")) || + (!strcmp(atom_p_2->GetElementName(), "BR")) || + (!strcmp(atom_p_2->GetElementName(), "Cl")) || + (!strcmp(atom_p_2->GetElementName(), "Br")) || + (!strcmp(atom_p_2->GetElementName(), " P")))) { atom_p_2->PutUDData(udd_handle, graphical_bonds_container::BONDED_WITH_STANDARD_ATOM_BOND); } } @@ -873,8 +873,8 @@ Bond_lines_container::add_half_bonds(const coot::Cartesian &atom_1_pos, // (dashed bonds are not double by nature) // graphics_line_t::cylinder_class_t cc = graphics_line_t::SINGLE; - mmdb::Residue *residue_p_1 = at_1->residue; - mmdb::Residue *residue_p_2 = at_2->residue; + mmdb::Residue *residue_p_1 = at_1->GetResidue(); + mmdb::Residue *residue_p_2 = at_2->GetResidue(); // is this slow? if so, pass it. // int udd_user_defined_atom_colour_index_handle = asc.mol->GetUDDHandle(mmdb::UDR_ATOM, "user-defined-atom-colour-index"); @@ -904,8 +904,8 @@ Bond_lines_container::draw_bonded_quad_atoms_rings(const std::vectorx, bq.atom_2->y, bq.atom_2->z); - coot::Cartesian p3(bq.atom_3->x, bq.atom_3->y, bq.atom_3->z); + coot::Cartesian p2(bq.atom_2->x(), bq.atom_2->y(), bq.atom_2->z()); + coot::Cartesian p3(bq.atom_3->x(), bq.atom_3->y(), bq.atom_3->z()); int atom_2_index = -1; int atom_3_index = -1; bq.atom_2->GetUDData(udd_atom_index_handle, atom_2_index); @@ -913,8 +913,8 @@ Bond_lines_container::draw_bonded_quad_atoms_rings(const std::vectorelement); - std::string ele_3(at_3->element); + std::string ele_2(at_2->GetElementName()); + std::string ele_3(at_3->GetElementName()); // std::cout << "ring quad " << i << " " << bq << " has bond_type " << bq.bond_type << std::endl; @@ -941,10 +941,10 @@ Bond_lines_container::draw_bonded_quad_atoms_rings(const std::vectorx, bq.atom_1->y, bq.atom_1->z); - coot::Cartesian pt_1(bq.atom_2->x, bq.atom_2->y, bq.atom_2->z); - coot::Cartesian pt_2(bq.atom_3->x, bq.atom_3->y, bq.atom_3->z); - coot::Cartesian pt_3(bq.atom_4->x, bq.atom_4->y, bq.atom_4->z); + coot::Cartesian pt_0(bq.atom_1->x(), bq.atom_1->y(), bq.atom_1->z()); + coot::Cartesian pt_1(bq.atom_2->x(), bq.atom_2->y(), bq.atom_2->z()); + coot::Cartesian pt_2(bq.atom_3->x(), bq.atom_3->y(), bq.atom_3->z()); + coot::Cartesian pt_3(bq.atom_4->x(), bq.atom_4->y(), bq.atom_4->z()); coot::Cartesian mp = pt_0.mid_point(pt_3); // doesn't work for cyclopropane coot::Cartesian v1 = pt_1 - mp; @@ -1015,10 +1015,10 @@ Bond_lines_container::draw_trp_rings(const std::vector &ring_atoms int col = atom_colour(at_1, atom_colour_type, udd_user_defined_atom_colour_index_handle, atom_colour_map_p); int atom_1_index = -1; int atom_2_index = -1; - coot::Cartesian p1(ring_atoms[iat]->x, ring_atoms[iat]->y, ring_atoms[iat]->z); - coot::Cartesian p2(ring_atoms[jat]->x, ring_atoms[jat]->y, ring_atoms[jat]->z); - std::string ele_1(at_1->element); - std::string ele_2(at_2->element); + coot::Cartesian p1(ring_atoms[iat]->x(), ring_atoms[iat]->y(), ring_atoms[iat]->z()); + coot::Cartesian p2(ring_atoms[jat]->x(), ring_atoms[jat]->y(), ring_atoms[jat]->z()); + std::string ele_1(at_1->GetElementName()); + std::string ele_2(at_2->GetElementName()); if (ele_1 == ele_2) { ring_atoms[iat]->GetUDData(udd_atom_index_handle, atom_1_index); ring_atoms[jat]->GetUDData(udd_atom_index_handle, atom_2_index); @@ -1042,10 +1042,10 @@ Bond_lines_container::draw_trp_rings(const std::vector &ring_atoms // find the mid point of atom 0 and 3. the innner bond ends will be on the vector from there to // atoms 1 and 2. - coot::Cartesian pt_0(ring_atoms[iat_0]->x, ring_atoms[iat_0]->y, ring_atoms[iat_0]->z); - coot::Cartesian pt_1(ring_atoms[iat_1]->x, ring_atoms[iat_1]->y, ring_atoms[iat_1]->z); - coot::Cartesian pt_2(ring_atoms[iat_2]->x, ring_atoms[iat_2]->y, ring_atoms[iat_2]->z); - coot::Cartesian pt_3(ring_atoms[iat_3]->x, ring_atoms[iat_3]->y, ring_atoms[iat_3]->z); + coot::Cartesian pt_0(ring_atoms[iat_0]->x(), ring_atoms[iat_0]->y(), ring_atoms[iat_0]->z()); + coot::Cartesian pt_1(ring_atoms[iat_1]->x(), ring_atoms[iat_1]->y(), ring_atoms[iat_1]->z()); + coot::Cartesian pt_2(ring_atoms[iat_2]->x(), ring_atoms[iat_2]->y(), ring_atoms[iat_2]->z()); + coot::Cartesian pt_3(ring_atoms[iat_3]->x(), ring_atoms[iat_3]->y(), ring_atoms[iat_3]->z()); coot::Cartesian mp = pt_0.mid_point(pt_3); coot::Cartesian v1 = pt_1 - mp; @@ -1059,8 +1059,8 @@ Bond_lines_container::draw_trp_rings(const std::vector &ring_atoms int atom_2_index = -1; ring_atoms[iat_1]->GetUDData(udd_atom_index_handle, atom_1_index); ring_atoms[iat_2]->GetUDData(udd_atom_index_handle, atom_2_index); - std::string ele_1(at_1->element); - std::string ele_2(at_2->element); + std::string ele_1(at_1->GetElementName()); + std::string ele_2(at_2->GetElementName()); graphics_line_t::cylinder_class_t cc = graphics_line_t::KEK_DOUBLE_BOND_INNER_BOND; if (ele_1 == ele_2) { bool add_end_cap = true; @@ -1094,7 +1094,7 @@ Bond_lines_container::draw_GA_rings(const std::vector &ring_atoms, for (unsigned int i=0; iresidue->GetResName(); + std::string rt = ring_atoms[0]->GetResidue()->GetResName(); // single bonds std::vector > vp_single; @@ -1128,10 +1128,10 @@ Bond_lines_container::draw_GA_rings(const std::vector &ring_atoms, int col = atom_colour(at_1, atom_colour_type, udd_user_defined_atom_colour_index_handle, atom_colour_map_p); int atom_1_index = -1; int atom_2_index = -1; - coot::Cartesian p1(ring_atoms[iat]->x, ring_atoms[iat]->y, ring_atoms[iat]->z); - coot::Cartesian p2(ring_atoms[jat]->x, ring_atoms[jat]->y, ring_atoms[jat]->z); - std::string ele_1(at_1->element); - std::string ele_2(at_2->element); + coot::Cartesian p1(ring_atoms[iat]->x(), ring_atoms[iat]->y(), ring_atoms[iat]->z()); + coot::Cartesian p2(ring_atoms[jat]->x(), ring_atoms[jat]->y(), ring_atoms[jat]->z()); + std::string ele_1(at_1->GetElementName()); + std::string ele_2(at_2->GetElementName()); graphics_line_t::cylinder_class_t cc = graphics_line_t::SINGLE; if (ele_1 == ele_2) { ring_atoms[iat]->GetUDData(udd_atom_index_handle, atom_1_index); @@ -1153,10 +1153,10 @@ Bond_lines_container::draw_GA_rings(const std::vector &ring_atoms, // find the mid point of atom 0 and 3. the innner bond ends will be on the vector from there to // atoms 1 and 2. - coot::Cartesian pt_0(ring_atoms[iat_0]->x, ring_atoms[iat_0]->y, ring_atoms[iat_0]->z); - coot::Cartesian pt_1(ring_atoms[iat_1]->x, ring_atoms[iat_1]->y, ring_atoms[iat_1]->z); - coot::Cartesian pt_2(ring_atoms[iat_2]->x, ring_atoms[iat_2]->y, ring_atoms[iat_2]->z); - coot::Cartesian pt_3(ring_atoms[iat_3]->x, ring_atoms[iat_3]->y, ring_atoms[iat_3]->z); + coot::Cartesian pt_0(ring_atoms[iat_0]->x(), ring_atoms[iat_0]->y(), ring_atoms[iat_0]->z()); + coot::Cartesian pt_1(ring_atoms[iat_1]->x(), ring_atoms[iat_1]->y(), ring_atoms[iat_1]->z()); + coot::Cartesian pt_2(ring_atoms[iat_2]->x(), ring_atoms[iat_2]->y(), ring_atoms[iat_2]->z()); + coot::Cartesian pt_3(ring_atoms[iat_3]->x(), ring_atoms[iat_3]->y(), ring_atoms[iat_3]->z()); coot::Cartesian mp = pt_0.mid_point(pt_3); coot::Cartesian v1 = pt_1 - mp; @@ -1170,8 +1170,8 @@ Bond_lines_container::draw_GA_rings(const std::vector &ring_atoms, int atom_2_index = -1; ring_atoms[iat_1]->GetUDData(udd_atom_index_handle, atom_1_index); ring_atoms[iat_2]->GetUDData(udd_atom_index_handle, atom_2_index); - std::string ele_1(at_1->element); - std::string ele_2(at_2->element); + std::string ele_1(at_1->GetElementName()); + std::string ele_2(at_2->GetElementName()); graphics_line_t::cylinder_class_t cc = graphics_line_t::KEK_DOUBLE_BOND_INNER_BOND; if (ele_1 == ele_2) { addBond(col, ip1, ip2, cc, imodel, atom_1_index, atom_2_index, true, true); @@ -1202,10 +1202,10 @@ Bond_lines_container::draw_6_membered_ring(const std::string &residue_name, if (iat == 5) jat = 0; mmdb::Atom *at_1 = ring_atoms[iat]; mmdb::Atom *at_2 = ring_atoms[jat]; - std::string ele_1(at_1->element); - std::string ele_2(at_2->element); - coot::Cartesian p1(ring_atoms[iat]->x, ring_atoms[iat]->y, ring_atoms[iat]->z); - coot::Cartesian p2(ring_atoms[jat]->x, ring_atoms[jat]->y, ring_atoms[jat]->z); + std::string ele_1(at_1->GetElementName()); + std::string ele_2(at_2->GetElementName()); + coot::Cartesian p1(ring_atoms[iat]->x(), ring_atoms[iat]->y(), ring_atoms[iat]->z()); + coot::Cartesian p2(ring_atoms[jat]->x(), ring_atoms[jat]->y(), ring_atoms[jat]->z()); int atom_1_index = -1; int atom_2_index = -1; ring_atoms[iat]->GetUDData(udd_atom_index_handle, atom_1_index); @@ -1254,10 +1254,10 @@ Bond_lines_container::draw_6_membered_ring(const std::string &residue_name, // find the mid point of atom 0 and 3. the innner bond ends will be on the vector from thre to // atoms 1 and 2. - coot::Cartesian pt_0(ring_atoms[iat_0]->x, ring_atoms[iat_0]->y, ring_atoms[iat_0]->z); - coot::Cartesian pt_1(ring_atoms[iat_1]->x, ring_atoms[iat_1]->y, ring_atoms[iat_1]->z); - coot::Cartesian pt_2(ring_atoms[iat_2]->x, ring_atoms[iat_2]->y, ring_atoms[iat_2]->z); - coot::Cartesian pt_3(ring_atoms[iat_3]->x, ring_atoms[iat_3]->y, ring_atoms[iat_3]->z); + coot::Cartesian pt_0(ring_atoms[iat_0]->x(), ring_atoms[iat_0]->y(), ring_atoms[iat_0]->z()); + coot::Cartesian pt_1(ring_atoms[iat_1]->x(), ring_atoms[iat_1]->y(), ring_atoms[iat_1]->z()); + coot::Cartesian pt_2(ring_atoms[iat_2]->x(), ring_atoms[iat_2]->y(), ring_atoms[iat_2]->z()); + coot::Cartesian pt_3(ring_atoms[iat_3]->x(), ring_atoms[iat_3]->y(), ring_atoms[iat_3]->z()); coot::Cartesian mp = pt_0.mid_point(pt_3); coot::Cartesian v1 = pt_1 - mp; @@ -1266,8 +1266,8 @@ Bond_lines_container::draw_6_membered_ring(const std::string &residue_name, coot::Cartesian ip2 = mp + v2 * 0.78; mmdb::Atom *at_1 = ring_atoms[iat_1]; mmdb::Atom *at_2 = ring_atoms[iat_2]; - std::string ele_1(at_1->element); - std::string ele_2(at_2->element); + std::string ele_1(at_1->GetElementName()); + std::string ele_2(at_2->GetElementName()); int atom_1_index = -1; int atom_2_index = -1; ring_atoms[iat_1]->GetUDData(udd_atom_index_handle, atom_1_index); @@ -1299,8 +1299,8 @@ Bond_lines_container::add_double_bond(int imol, int imodel, int iat_1, int iat_2 const std::vector &bond_restraints, bool is_deloc) { - std::string ele_1 = residue_atoms[iat_1]->element; - std::string ele_2 = residue_atoms[iat_2]->element; + std::string ele_1 = residue_atoms[iat_1]->GetElementName(); + std::string ele_2 = residue_atoms[iat_2]->GetElementName(); graphics_line_t::cylinder_class_t cc = graphics_line_t::DOUBLE; @@ -1315,8 +1315,8 @@ Bond_lines_container::add_double_bond(int imol, int imodel, int iat_1, int iat_2 // perp_n is the direction of the offset (from the atom position) of the start and // finish points in the plane of the double bond. // - clipper::Coord_orth pos_at_1(residue_atoms[iat_1]->x, residue_atoms[iat_1]->y, residue_atoms[iat_1]->z); - clipper::Coord_orth pos_at_2(residue_atoms[iat_2]->x, residue_atoms[iat_2]->y, residue_atoms[iat_2]->z); + clipper::Coord_orth pos_at_1(residue_atoms[iat_1]->x(), residue_atoms[iat_1]->y(), residue_atoms[iat_1]->z()); + clipper::Coord_orth pos_at_2(residue_atoms[iat_2]->x(), residue_atoms[iat_2]->y(), residue_atoms[iat_2]->z()); clipper::Coord_orth n_n = get_neighb_normal(imol, iat_1, iat_2, residue_atoms, n_residue_atoms); clipper::Coord_orth b(pos_at_1 - pos_at_2); clipper::Coord_orth b_n(b.unit()); @@ -1380,11 +1380,11 @@ Bond_lines_container::add_triple_bond(int imol, int imodel, int iat_1, int iat_2 graphics_line_t::cylinder_class_t cc = graphics_line_t::TRIPLE; // - std::string ele_1 = atoms[iat_1]->element; - std::string ele_2 = atoms[iat_2]->element; + std::string ele_1 = atoms[iat_1]->GetElementName(); + std::string ele_2 = atoms[iat_2]->GetElementName(); - mmdb::Residue *residue_p_1 = atoms[iat_1]->residue; - mmdb::Residue *residue_p_2 = atoms[iat_2]->residue; + mmdb::Residue *residue_p_1 = atoms[iat_1]->GetResidue(); + mmdb::Residue *residue_p_2 = atoms[iat_2]->GetResidue(); try { @@ -1399,8 +1399,8 @@ Bond_lines_container::add_triple_bond(int imol, int imodel, int iat_1, int iat_2 bool also_2nd_order = 1; // because linear nature of bonds to // atoms in triple bond means we need // more atoms. - clipper::Coord_orth pos_at_1(atoms[iat_1]->x, atoms[iat_1]->y, atoms[iat_1]->z); - clipper::Coord_orth pos_at_2(atoms[iat_2]->x, atoms[iat_2]->y, atoms[iat_2]->z); + clipper::Coord_orth pos_at_1(atoms[iat_1]->x(), atoms[iat_1]->y(), atoms[iat_1]->z()); + clipper::Coord_orth pos_at_2(atoms[iat_2]->x(), atoms[iat_2]->y(), atoms[iat_2]->z()); clipper::Coord_orth n_n = get_neighb_normal(imol, iat_1, iat_2, atoms, n_atoms, also_2nd_order); clipper::Coord_orth b(pos_at_1 - pos_at_2); clipper::Coord_orth b_n(b.unit()); @@ -1450,9 +1450,9 @@ Bond_lines_container::get_neighb_normal(int imol, int iat_1, int iat_2, mmdb::PP clipper::Coord_orth pt(0,0,0); if (have_dictionary) { - std::string rn = atoms[iat_1]->residue->GetResName(); - std::string at_n_1 = atoms[iat_1]->name; - std::string at_n_2 = atoms[iat_2]->name; + std::string rn = atoms[iat_1]->GetResidue()->GetResName(); + std::string at_n_1 = atoms[iat_1]->GetAtomName(); + std::string at_n_2 = atoms[iat_2]->GetAtomName(); std::vector neighbours = geom->get_bonded_neighbours(rn, imol, at_n_1, at_n_2, also_2nd_order_neighbs_flag); @@ -1462,14 +1462,14 @@ Bond_lines_container::get_neighb_normal(int imol, int iat_1, int iat_2, mmdb::PP std::cout << " " << neighbours[i] << std::endl; } - std::string alt_conf_bond = atoms[iat_1]->altLoc; // same as iat_2 by the time we get here, I think + std::string alt_conf_bond = atoms[iat_1]->altLoc(); // same as iat_2 by the time we get here, I think if (neighbours.size() > 2) { std::vector neighb_atoms; for (unsigned int i=0; iname; + std::string atom_name = atoms[j]->GetAtomName(); if (neighbours[i] == atom_name) { - std::string alt_conf_atom = atoms[j]->altLoc; + std::string alt_conf_atom = atoms[j]->altLoc(); if (alt_conf_atom == alt_conf_bond) { // only add them if they are not there already (belt and braces test) if (std::find(neighb_atoms.begin(), neighb_atoms.end(), atoms[j]) == @@ -1485,15 +1485,15 @@ Bond_lines_container::get_neighb_normal(int imol, int iat_1, int iat_2, mmdb::PP std::vector neighb_atoms_pos(neighb_atoms.size()); for (unsigned int i=0; ix, - neighb_atoms[i]->y, - neighb_atoms[i]->z); + neighb_atoms_pos[i] = clipper::Coord_orth(neighb_atoms[i]->x(), + neighb_atoms[i]->y(), + neighb_atoms[i]->z()); coot::lsq_plane_info_t lp(neighb_atoms_pos); pt = lp.normal(); } } else { std::string m = "Not enough atoms to determine orientation of "; - m += atoms[iat_1]->residue->GetResName(); + m += atoms[iat_1]->GetResidue()->GetResName(); m += " - dictionary bonding fails"; m += " found "; m += coot::util::int_to_string(neighbours.size()); @@ -1509,7 +1509,7 @@ Bond_lines_container::get_neighb_normal(int imol, int iat_1, int iat_2, mmdb::PP } else { // this should not happend std::string m = "No dictionary for "; - m += atoms[iat_1]->residue->GetResName(); + m += atoms[iat_1]->GetResidue()->GetResName(); m += " - dictionary bonding fails"; throw(std::runtime_error(m)); } @@ -1528,12 +1528,12 @@ Bond_lines_container::invert_deloc_bond_displacement_vector(const clipper::Coord // << residue_atoms[iat_1]->name << ": to :" // << residue_atoms[iat_2]->name << ": =========================" << std::endl; - std::string atom_name_iat = residue_atoms[iat_1]->name; - std::string atom_name_jat = residue_atoms[iat_2]->name; + std::string atom_name_iat = residue_atoms[iat_1]->GetAtomName(); + std::string atom_name_jat = residue_atoms[iat_2]->GetAtomName(); std::map atom_name_map; for (int iat=0; iatname] = iat; + atom_name_map[residue_atoms[iat]->GetAtomName()] = iat; for (unsigned int ib=0; ibx, - residue_atoms[iat_1]->y, - residue_atoms[iat_1]->z); + clipper::Coord_orth pt_1(residue_atoms[iat_1]->x(), + residue_atoms[iat_1]->y(), + residue_atoms[iat_1]->z()); std::map::const_iterator it; it = atom_name_map.find(bond_restraints[ib].atom_id_2_4c()); if (it != atom_name_map.end()) { - clipper::Coord_orth pt_2(residue_atoms[it->second]->x, - residue_atoms[it->second]->y, - residue_atoms[it->second]->z); + clipper::Coord_orth pt_2(residue_atoms[it->second]->x(), + residue_atoms[it->second]->y(), + residue_atoms[it->second]->z()); clipper::Coord_orth diff = pt_2 - pt_1; double d = clipper::Coord_orth::dot(vect, diff); // std::cout << " dot 1 : " << d << std::endl; @@ -1577,15 +1577,15 @@ Bond_lines_container::invert_deloc_bond_displacement_vector(const clipper::Coord // << std::endl; if (bond_restraints[ib].type() == "deloc") { - clipper::Coord_orth pt_1(residue_atoms[iat_1]->x, - residue_atoms[iat_1]->y, - residue_atoms[iat_1]->z); + clipper::Coord_orth pt_1(residue_atoms[iat_1]->x(), + residue_atoms[iat_1]->y(), + residue_atoms[iat_1]->z()); std::map::const_iterator it; it = atom_name_map.find(bond_restraints[ib].atom_id_1_4c()); if (it != atom_name_map.end()) { - clipper::Coord_orth pt_2(residue_atoms[it->second]->x, - residue_atoms[it->second]->y, - residue_atoms[it->second]->z); + clipper::Coord_orth pt_2(residue_atoms[it->second]->x(), + residue_atoms[it->second]->y(), + residue_atoms[it->second]->z()); clipper::Coord_orth diff = pt_2 - pt_1; double d = clipper::Coord_orth::dot(vect, diff); // std::cout << " dot 2 : " << d << std::endl; @@ -1648,20 +1648,20 @@ Bond_lines_container::add_bonds_het_residues(const std::vectorname); + std::string residue_atom_name_1(residue_atoms[iat]->GetAtomName()); if (atom_name_1 == residue_atom_name_1) { for (int jat=0; jatname); + std::string residue_atom_name_2(residue_atoms[jat]->GetAtomName()); if (atom_name_2 == residue_atom_name_2) { - std::string aloc_1 = residue_atoms[iat]->altLoc; - std::string aloc_2 = residue_atoms[jat]->altLoc; + std::string aloc_1 = residue_atoms[iat]->altLoc(); + std::string aloc_2 = residue_atoms[jat]->altLoc(); if (aloc_1 == aloc_2 || aloc_1.empty() || aloc_2.empty()) { - coot::Cartesian p1(residue_atoms[iat]->x, - residue_atoms[iat]->y, - residue_atoms[iat]->z); - coot::Cartesian p2(residue_atoms[jat]->x, - residue_atoms[jat]->y, - residue_atoms[jat]->z); + coot::Cartesian p1(residue_atoms[iat]->x(), + residue_atoms[iat]->y(), + residue_atoms[iat]->z()); + coot::Cartesian p2(residue_atoms[jat]->x(), + residue_atoms[jat]->y(), + residue_atoms[jat]->z()); int iat_1_atom_index = -1; int iat_2_atom_index = -1; @@ -1669,12 +1669,12 @@ Bond_lines_container::add_bonds_het_residues(const std::vectorGetUDData(udd_atom_index_handle, iat_2_atom_index); if (false) - std::cout << "making bond between :" << residue_atoms[iat]->name - << ": and :" << residue_atoms[jat]->name << ": " + std::cout << "making bond between :" << residue_atoms[iat]->GetAtomName() + << ": and :" << residue_atoms[jat]->GetAtomName() << ": " << bt << std::endl; - std::string element_1 = residue_atoms[iat]->element; - std::string element_2 = residue_atoms[jat]->element; + std::string element_1 = residue_atoms[iat]->GetElementName(); + std::string element_2 = residue_atoms[jat]->GetElementName(); if (element_1 != element_2) { @@ -1890,8 +1890,8 @@ Bond_lines_container::add_aromatic_ring_bond_lines(const std::vectorGetAtomTable(residue_atoms, n_residue_atoms); for (unsigned int i=0; iname); - std::string atom_alt_conf(residue_atoms[iat]->altLoc); + std::string atom_name(residue_atoms[iat]->GetAtomName()); + std::string atom_alt_conf(residue_atoms[iat]->altLoc()); if (atom_alt_conf == alt_confs[i_alt_conf]) { if (atom_name == ring_atom_names[i]) { found_atoms.push_back(residue_atoms[iat]); @@ -1906,9 +1906,9 @@ Bond_lines_container::add_aromatic_ring_bond_lines(const std::vector pts(ring_atom_names.size()); for (unsigned int iat=0; iatx, - found_atom->y, - found_atom->z); + pts[iat] = clipper::Coord_orth(found_atom->x(), + found_atom->y(), + found_atom->z()); int idx_mol = -1; found_atom->GetUDData(udd_atom_index_handle, idx_mol); if (! skip_this_ring) @@ -2101,8 +2101,8 @@ Bond_lines_container::add_link_bond_templ(mmdb::Model *model_p, int udd_atom_ind for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - if (std::string(at->name) == std::string(link->atName1)) { - if (std::string(at->altLoc) == std::string(link->aloc1)) { + if (std::string(at->GetAtomName()) == std::string(link->atName1)) { + if (std::string(at->altLoc()) == std::string(link->aloc1)) { atom_1 = at; break; } @@ -2137,9 +2137,9 @@ Bond_lines_container::add_link_bond_templ(mmdb::Model *model_p, int udd_atom_ind for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - if (std::string(at->name) == + if (std::string(at->GetAtomName()) == std::string(link->atName2)) { - if (std::string(at->altLoc) == + if (std::string(at->altLoc()) == std::string(link->aloc2)) { atom_2 = at; break; @@ -2198,11 +2198,11 @@ Bond_lines_container::add_link_bond_templ(mmdb::Model *model_p, int udd_atom_ind // Even if the atom_index_1 or atom_index_2 were not correctly set, we can still draw // the bond - this needs to be fixed however. - coot::Cartesian pos_1(atom_1->x, atom_1->y, atom_1->z); - coot::Cartesian pos_2(atom_2->x, atom_2->y, atom_2->z); + coot::Cartesian pos_1(atom_1->x(), atom_1->y(), atom_1->z()); + coot::Cartesian pos_2(atom_2->x(), atom_2->y(), atom_2->z()); - std::string ele_1 = atom_1->element; - std::string ele_2 = atom_2->element; + std::string ele_1 = atom_1->GetElementName(); + std::string ele_2 = atom_2->GetElementName(); if (ele_1 == ele_2) { int col = atom_colour(atom_1, atom_colour_type, udd_user_defined_atom_colour_index_handle); add_dashed_bond(col, pos_1, pos_2, NOT_HALF_BOND, graphics_line_t::SINGLE, model_number, atom_index_1, atom_index_2); @@ -2508,10 +2508,10 @@ Bond_lines_container::construct_from_asc(const atom_selection_container_t &SelAt if (non_Hydrogen_atoms[i]->GetUDData(udd_found_bond_handle, ic) == mmdb::UDDATA_Ok) { if ((ic == 0) || - ((!strcmp(non_Hydrogen_atoms[i]->element, " S")) && (ic != graphical_bonds_container::BONDED_WITH_HETATM_BOND)) || - ((!strcmp(non_Hydrogen_atoms[i]->element, "SE")) && (ic != graphical_bonds_container::BONDED_WITH_HETATM_BOND)) || - ((!strcmp(non_Hydrogen_atoms[i]->element, "FE")) && (ic != graphical_bonds_container::BONDED_WITH_HETATM_BOND)) || - ((!strcmp(non_Hydrogen_atoms[i]->element, " P")) && (ic != graphical_bonds_container::BONDED_WITH_HETATM_BOND))) { + ((!strcmp(non_Hydrogen_atoms[i]->GetElementName(), " S")) && (ic != graphical_bonds_container::BONDED_WITH_HETATM_BOND)) || + ((!strcmp(non_Hydrogen_atoms[i]->GetElementName(), "SE")) && (ic != graphical_bonds_container::BONDED_WITH_HETATM_BOND)) || + ((!strcmp(non_Hydrogen_atoms[i]->GetElementName(), "FE")) && (ic != graphical_bonds_container::BONDED_WITH_HETATM_BOND)) || + ((!strcmp(non_Hydrogen_atoms[i]->GetElementName(), " P")) && (ic != graphical_bonds_container::BONDED_WITH_HETATM_BOND))) { // std::cout << ":::: No contact for " << non_Hydrogen_atoms[i] // << " with ic " << ic << std::endl; @@ -2520,7 +2520,7 @@ Bond_lines_container::construct_from_asc(const atom_selection_container_t &SelAt // So, was this a seleno-methione? // - mmdb::Residue *atom_residue_p = non_Hydrogen_atoms[i]->residue; + mmdb::Residue *atom_residue_p = non_Hydrogen_atoms[i]->GetResidue(); if (atom_residue_p) { std::string resname = non_Hydrogen_atoms[i]->GetResName(); @@ -2539,7 +2539,7 @@ Bond_lines_container::construct_from_asc(const atom_selection_container_t &SelAt udd_atom_index_handle, udd_user_defined_atom_colour_index_handle); } else { - std::string ele = non_Hydrogen_atoms[i]->element; + std::string ele = non_Hydrogen_atoms[i]->GetElementName(); if (ele == "CL" || ele == "BR" || ele == " S" || ele == " I" || ele == "Cl" || ele == "Br" || ele == "MO" || ele == "Mo" || ele == "AL" || ele == "PT" || ele == "RU" || ele == " W" @@ -2571,7 +2571,7 @@ Bond_lines_container::construct_from_asc(const atom_selection_container_t &SelAt if (non_Hydrogen_atoms[i]->GetUDData(udd_found_bond_handle, ic) == mmdb::UDDATA_Ok) { if (ic == graphical_bonds_container::NO_BOND) { // no contact found - mmdb::Residue *residue_p = non_Hydrogen_atoms[i]->residue; + mmdb::Residue *residue_p = non_Hydrogen_atoms[i]->GetResidue(); std::string res_name(residue_p->GetResName()); if (res_name == "HOH") @@ -2579,9 +2579,9 @@ Bond_lines_container::construct_from_asc(const atom_selection_container_t &SelAt continue; col = atom_colour(non_Hydrogen_atoms[i], atom_colour_type, udd_user_defined_atom_colour_index_handle); - coot::Cartesian atom_pos(non_Hydrogen_atoms[i]->x, - non_Hydrogen_atoms[i]->y, - non_Hydrogen_atoms[i]->z); + coot::Cartesian atom_pos(non_Hydrogen_atoms[i]->x(), + non_Hydrogen_atoms[i]->y(), + non_Hydrogen_atoms[i]->z()); int iat_1 = -1; int udd_status_1 = non_Hydrogen_atoms[i]->GetUDData(udd_atom_index_handle, iat_1); @@ -2600,7 +2600,7 @@ Bond_lines_container::construct_from_asc(const atom_selection_container_t &SelAt if (ic == graphical_bonds_container::NO_BOND) { // no contact found - mmdb::Residue *residue_p = Hydrogen_atoms[i]->residue; + mmdb::Residue *residue_p = Hydrogen_atoms[i]->GetResidue(); if (! residue_p) std::cout << "ERROR:: catched condition for crashetty crash!" << std::endl; @@ -2610,9 +2610,9 @@ Bond_lines_container::construct_from_asc(const atom_selection_container_t &SelAt continue; col = atom_colour(Hydrogen_atoms[i], atom_colour_type, udd_user_defined_atom_colour_index_handle); - coot::Cartesian atom(Hydrogen_atoms[i]->x, - Hydrogen_atoms[i]->y, - Hydrogen_atoms[i]->z); + coot::Cartesian atom(Hydrogen_atoms[i]->x(), + Hydrogen_atoms[i]->y(), + Hydrogen_atoms[i]->z()); // 20171224-PE FIXME by lookup int iat_1 = -1; @@ -2656,7 +2656,7 @@ Bond_lines_container::handle_MET_or_MSE_case(mmdb::PAtom mse_atom, // std::cout << "Handling MET/MSE case for atom " << mse_atom << std::endl; - std::string atom_name(mse_atom->name); + std::string atom_name(mse_atom->GetAtomName()); std::string residue_name(mse_atom->GetResName()); int model_number = mse_atom->GetModelNum(); if (residue_name == "MET" || residue_name == "MSE" || residue_name == "MSO") { @@ -2666,19 +2666,19 @@ Bond_lines_container::handle_MET_or_MSE_case(mmdb::PAtom mse_atom, // We need to add special bonds SE -> CE and SE -> CG. mmdb::PPAtom residue_atoms; int nResidueAtoms; - mse_atom->residue->GetAtomTable(residue_atoms, nResidueAtoms); + mse_atom->GetResidue()->GetAtomTable(residue_atoms, nResidueAtoms); for (int i=0; iname); + std::string table_atom_name(residue_atoms[i]->GetAtomName()); if (table_atom_name == " CG " || table_atom_name == " CE " ) { // mse_atom or met_atom now of course. - coot::Cartesian cart_at1(mse_atom->x, mse_atom->y, mse_atom->z); - coot::Cartesian cart_at2(residue_atoms[i]->x, - residue_atoms[i]->y, - residue_atoms[i]->z); + coot::Cartesian cart_at1(mse_atom->x(), mse_atom->y(), mse_atom->z()); + coot::Cartesian cart_at2(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z()); - std::string altconf1 = mse_atom->altLoc; - std::string altconf2 = residue_atoms[i]->altLoc; + std::string altconf1 = mse_atom->altLoc(); + std::string altconf2 = residue_atoms[i]->altLoc(); if ( (altconf1=="") || (altconf2=="") || (altconf1==altconf2) ) { coot::Cartesian bond_mid_point = cart_at1.mid_point(cart_at2); int colc = atom_colour(residue_atoms[i], atom_colour_type, udd_user_defined_atom_colour_index_handle, atom_colour_map_p); @@ -2710,17 +2710,17 @@ Bond_lines_container::handle_MET_or_MSE_case(mmdb::PAtom mse_atom, // We need to add special bonds CB -> SG mmdb::PPAtom residue_atoms; int nResidueAtoms; - mse_atom->residue->GetAtomTable(residue_atoms, nResidueAtoms); + mse_atom->GetResidue()->GetAtomTable(residue_atoms, nResidueAtoms); for (int i=0; iname); + std::string table_atom_name(residue_atoms[i]->GetAtomName()); if (table_atom_name == " CB ") { - coot::Cartesian cart_at1(mse_atom->x, mse_atom->y, mse_atom->z); - coot::Cartesian cart_at2(residue_atoms[i]->x, - residue_atoms[i]->y, - residue_atoms[i]->z); + coot::Cartesian cart_at1(mse_atom->x(), mse_atom->y(), mse_atom->z()); + coot::Cartesian cart_at2(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z()); - std::string altconf1 = mse_atom->altLoc; - std::string altconf2 = residue_atoms[i]->altLoc; + std::string altconf1 = mse_atom->altLoc(); + std::string altconf2 = residue_atoms[i]->altLoc(); if ( (altconf1=="") || (altconf2=="") || (altconf1==altconf2) ) { float len2 = (cart_at1 - cart_at2).amplitude_squared(); if (len2 < 16) { // protection for weirdness @@ -2760,10 +2760,10 @@ Bond_lines_container::handle_long_bonded_atom(mmdb::PAtom atom, // some wiggle room (2.1 was too short for // some dictionary S-S). - std::string atom_name(atom->name); + std::string atom_name(atom->GetAtomName()); std::string residue_name(atom->GetResName()); - std::string element(atom->element); - mmdb::Residue *res = atom->residue; + std::string element(atom->GetElementName()); + mmdb::Residue *res = atom->GetResidue(); int model_number = atom->GetModelNum(); // std::cout << "handling long bonds for " << atom << " ele " << element << std::endl; @@ -2788,26 +2788,26 @@ Bond_lines_container::handle_long_bonded_atom(mmdb::PAtom atom, if (res) { // do the bonding by hand: - coot::Cartesian atom_pos(atom->x, atom->y, atom->z); + coot::Cartesian atom_pos(atom->x(), atom->y(), atom->z()); int col = atom_colour(atom, atom_colour_type, udd_user_defined_atom_colour_index_handle, atom_colour_map_p); mmdb::PPAtom residue_atoms = 0; int nResidueAtoms; res->GetAtomTable(residue_atoms, nResidueAtoms); for (int i=0; ix, - residue_atoms[i]->y, - residue_atoms[i]->z); + coot::Cartesian res_atom_pos(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z()); // We compared squard bond distances (so that we don't // have to take the square root for everything of course). // - std::string res_atom_ele = residue_atoms[i]->element; + std::string res_atom_ele = residue_atoms[i]->GetElementName(); float len2 = (atom_pos - res_atom_pos).amplitude_squared(); if (((len2 < bl2) && (! is_hydrogen(res_atom_ele))) || ((len2 < h_bl2) && (is_hydrogen(res_atom_ele)))) { - std::string altconf1 = atom->altLoc; - std::string altconf2 = residue_atoms[i]->altLoc; + std::string altconf1 = atom->altLoc(); + std::string altconf2 = residue_atoms[i]->altLoc(); if ( (altconf1=="") || (altconf2=="") || (altconf1==altconf2) ) { coot::Cartesian bond_mid_point = atom_pos.mid_point(res_atom_pos); int colc = atom_colour(residue_atoms[i], atom_colour_type, udd_user_defined_atom_colour_index_handle, atom_colour_map_p); @@ -2844,7 +2844,7 @@ Bond_lines_container::handle_long_bonded_atom(mmdb::PAtom atom, coot::Cartesian small_vec_z(0.0, 0.0, star_size); int col = atom_colour(atom, atom_colour_type, udd_user_defined_atom_colour_index_handle, atom_colour_map_p); - coot::Cartesian atom_pos(atom->x, atom->y, atom->z); + coot::Cartesian atom_pos(atom->x(), atom->y(), atom->z()); graphics_line_t::cylinder_class_t cc = graphics_line_t::SINGLE; // 20171224-PE FIXME lookup iat_1, iat_1 int iat_1 = -1; @@ -2929,16 +2929,16 @@ Bond_lines_container::Bond_lines_container(const atom_selection_container_t &Sel mmdb::Atom *atom_1 = residue_atoms[ contact[i].id1 ]; mmdb::Atom *atom_2 = SelAtom.atom_selection[ contact[i].id2]; - coot::Cartesian atom_1_pos(residue_atoms[ contact[i].id1 ]->x, - residue_atoms[ contact[i].id1 ]->y, - residue_atoms[ contact[i].id1 ]->z); - coot::Cartesian atom_2_pos(SelAtom.atom_selection[ contact[i].id2 ]->x, - SelAtom.atom_selection[ contact[i].id2 ]->y, - SelAtom.atom_selection[ contact[i].id2 ]->z); - std::string ele1 = residue_atoms[ contact[i].id1 ]->element; - std::string ele2 = SelAtom.atom_selection[ contact[i].id2 ]->element; - std::string alt_conf_1 = residue_atoms[ contact[i].id1 ]->altLoc; - std::string alt_conf_2 = SelAtom.atom_selection[ contact[i].id2 ]->altLoc; + coot::Cartesian atom_1_pos(residue_atoms[ contact[i].id1 ]->x(), + residue_atoms[ contact[i].id1 ]->y(), + residue_atoms[ contact[i].id1 ]->z()); + coot::Cartesian atom_2_pos(SelAtom.atom_selection[ contact[i].id2 ]->x(), + SelAtom.atom_selection[ contact[i].id2 ]->y(), + SelAtom.atom_selection[ contact[i].id2 ]->z()); + std::string ele1 = residue_atoms[ contact[i].id1 ]->GetElementName(); + std::string ele2 = SelAtom.atom_selection[ contact[i].id2 ]->GetElementName(); + std::string alt_conf_1 = residue_atoms[ contact[i].id1 ]->altLoc(); + std::string alt_conf_2 = SelAtom.atom_selection[ contact[i].id2 ]->altLoc(); int model_number = residue_atoms[ contact[i].id1 ]->GetModelNum(); // 20110119 environment distances for Hydrogens. We don't @@ -3154,7 +3154,7 @@ Bond_lines_container::Bond_lines_container(const atom_selection_container_t &Sel graphics_line_t::cylinder_class_t cc = graphics_line_t::SINGLE; for (int iresatom=0; iresatom< nResidueAtoms; iresatom++) { mmdb::Atom *res_atom = residue_atoms[iresatom]; - coot::Cartesian res_atom_pos(res_atom->x, res_atom->y, res_atom->z); + coot::Cartesian res_atom_pos(res_atom->x(), res_atom->y(), res_atom->z()); int model_number = residue_atoms[iresatom]->GetModelNum(); molecule_extents_t mol_extents(SelAtom, max_dist); @@ -3170,15 +3170,15 @@ Bond_lines_container::Bond_lines_container(const atom_selection_container_t &Sel int iat_2 = -1; mmdb::Atom *trans_atom = translated[it]; - coot::Cartesian symm_atom_pos(translated[it]->x, - translated[it]->y, - translated[it]->z); + coot::Cartesian symm_atom_pos(translated[it]->x(), + translated[it]->y(), + translated[it]->z()); float d = coot::Cartesian::LineLength(symm_atom_pos, res_atom_pos); // std::cout << translated[it] << " d = " << d << std::endl; if (d < max_dist && d >= min_dist) { - std::string ele1 = residue_atoms[iresatom]->element; - std::string ele2 = translated[it]->element; + std::string ele1 = residue_atoms[iresatom]->GetElementName(); + std::string ele2 = translated[it]->GetElementName(); if (draw_env_distances_to_hydrogens_flag || // ((ele1 != " H") && (ele2 != " H"))) { @@ -3262,8 +3262,8 @@ Bond_lines_container::find_intermolecular_symmetry(const atom_selection_containe mmdb::Atom *at_1 = SelAtom.atom_selection[contact[i].id1]; mmdb::Atom *at_2 = SelAtom.atom_selection[contact[i].id2]; - std::string ele_1 = at_1->element; - std::string ele_2 = at_2->element; + std::string ele_1 = at_1->GetElementName(); + std::string ele_2 = at_2->GetElementName(); if (ele_1 == " H" || ele_1 == "H") max_bond_dist -= 0.8; if (ele_2 == " H" || ele_2 == "H") max_bond_dist -= 0.8; @@ -3277,9 +3277,9 @@ Bond_lines_container::find_intermolecular_symmetry(const atom_selection_containe mmdb::Atom t_atom2; t_atom2.Copy(at_2); t_atom2.Transform(my_matt); - coot::Cartesian atom_1_pt(at_1->x, at_1->y, at_1->z); - coot::Cartesian atom_2_pt(at_2->x, at_2->y, at_2->z); - coot::Cartesian t_atom_2_pt(t_atom2.x, t_atom2.y, t_atom2.z); + coot::Cartesian atom_1_pt(at_1->x(), at_1->y(), at_1->z()); + coot::Cartesian atom_2_pt(at_2->x(), at_2->y(), at_2->z()); + coot::Cartesian t_atom_2_pt(t_atom2.x(), t_atom2.y(), t_atom2.z()); std::cout << "store at_1: " << atom_1_pt << " "; std::cout << "at_2: " << atom_2_pt << " "; std::cout << "t-at_2: " << t_atom_2_pt << " "; @@ -3468,7 +3468,7 @@ Bond_lines_container::addSymmetry_whole_chain(const atom_selection_container_t & for (int i=0; iCopy(SelAtom.atom_selection[i]); - transsel[i]->residue = SelAtom.atom_selection[i]->residue; + transsel[i]->GetResidue() = SelAtom.atom_selection[i]->GetResidue(); transsel[i]->Transform(mol_to_origin_matt); transsel[i]->Transform(my_matt); } @@ -3654,18 +3654,18 @@ Bond_lines_container::intermolecular_symmetry_graphical_bonds(mmdb::Manager *mol for (unsigned int i=0; ix, sabv[i].at_1->y, sabv[i].at_1->z); + coot::Cartesian atom_1_pt(sabv[i].at_1->x(), sabv[i].at_1->y(), sabv[i].at_1->z()); int ierr = sabv[i].GetTMatrix(mol, &my_matt); // check that my_matt gets changed to something sensible int model_number = sabv[i].at_1->GetModelNum(); if (! ierr) { - coot::Cartesian atom_2_pt(sabv[i].at_2->x, sabv[i].at_2->y, sabv[i].at_2->z); + coot::Cartesian atom_2_pt(sabv[i].at_2->x(), sabv[i].at_2->y(), sabv[i].at_2->z()); mmdb::Atom t_atom2; t_atom2.Copy(sabv[i].at_2); t_atom2.Transform(my_matt); - coot::Cartesian t_atom_2_pt(t_atom2.x, t_atom2.y, t_atom2.z); + coot::Cartesian t_atom_2_pt(t_atom2.x(), t_atom2.y(), t_atom2.z()); if (0) std::cout << "gbc int-symm bond: atom_1: " << atom_1_pt << " atom_2: " @@ -3739,8 +3739,8 @@ Bond_lines_container::addSymmetry_calphas(const atom_selection_container_t &SelA res1->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname) == " CA " || - std::string(residue_atoms[iat]->name) == " P ") { + if (std::string(residue_atoms[iat]->GetAtomName()) == " CA " || + std::string(residue_atoms[iat]->GetAtomName()) == " P ") { ca_this.push_back(residue_atoms[iat]); } } @@ -3748,8 +3748,8 @@ Bond_lines_container::addSymmetry_calphas(const atom_selection_container_t &SelA res2->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname) == " CA " || - std::string(residue_atoms[iat]->name) == " P ") { + if (std::string(residue_atoms[iat]->GetAtomName()) == " CA " || + std::string(residue_atoms[iat]->GetAtomName()) == " P ") { ca_next.push_back(residue_atoms[iat]); } } @@ -3760,19 +3760,19 @@ Bond_lines_container::addSymmetry_calphas(const atom_selection_container_t &SelA if (ca_this.size() > 0) { if (ca_next.size() > 0) { for (unsigned int iat=0; iataltLoc; + std::string altconf1 = ca_this[iat]->altLoc(); for (unsigned int jat=0; jataltLoc; + std::string altconf2 = ca_next[jat]->altLoc(); if ((altconf1 == altconf2) || (altconf1 == "") || (altconf2 == "")) { - coot::Cartesian ca_1(ca_this[iat]->x, - ca_this[iat]->y, - ca_this[iat]->z); - coot::Cartesian ca_2(ca_next[jat]->x, - ca_next[jat]->y, - ca_next[jat]->z); + coot::Cartesian ca_1(ca_this[iat]->x(), + ca_this[iat]->y(), + ca_this[iat]->z()); + coot::Cartesian ca_2(ca_next[jat]->x(), + ca_next[jat]->y(), + ca_next[jat]->z()); double len = (ca_1 - ca_2).amplitude(); // CA-CA or P-P @@ -3786,8 +3786,8 @@ Bond_lines_container::addSymmetry_calphas(const atom_selection_container_t &SelA t_atom1.Transform(my_matt); t_atom2.Transform(my_matt); - coot::Cartesian atom1(t_atom1.x, t_atom1.y, t_atom1.z); - coot::Cartesian atom2(t_atom2.x, t_atom2.y, t_atom2.z); + coot::Cartesian atom1(t_atom1.x(), t_atom1.y(), t_atom1.z()); + coot::Cartesian atom2(t_atom2.x(), t_atom2.y(), t_atom2.z()); int iat_1 = -1; // 20171224-PE FIXME maybe lookup int iat_2 = -1; @@ -3918,7 +3918,7 @@ Bond_lines_container::add_NCS_molecule_whole_chain(const atom_selection_containe for (int i=0; iCopy(SelAtom.atom_selection[i]); - transsel[i]->residue = SelAtom.atom_selection[i]->residue; + transsel[i]->GetResidue() = SelAtom.atom_selection[i]->GetResidue(); transsel[i]->Transform(my_matt); } // So now we have transsel. We need to calculate bonds from @@ -4065,7 +4065,7 @@ Bond_lines_container::trans_sel(atom_selection_container_t AtomSel, // trans_selection[ii]->SetChain( AtomSel.atom_selection[ii]->GetChain()); trans_selection[ii]->Copy(AtomSel.atom_selection[ii]); - trans_selection[ii]->residue = AtomSel.atom_selection[ii]->residue; + trans_selection[ii]->GetResidue() = AtomSel.atom_selection[ii]->GetResidue(); trans_selection[ii]->Transform(mol_to_origin_matt); trans_selection[ii]->Transform(my_matt); } @@ -4198,17 +4198,17 @@ Bond_lines_container::do_disulphide_bonds_by_distance(atom_selection_container_t Sulfur_selection[contact[i].id1]->GetUDData(udd_atom_index_handle, iat_1); Sulfur_selection[contact[i].id2]->GetUDData(udd_atom_index_handle, iat_2); - std::string aloc_1(Sulfur_selection[ contact[i].id1 ]->altLoc); - std::string aloc_2(Sulfur_selection[ contact[i].id2 ]->altLoc); + std::string aloc_1(Sulfur_selection[ contact[i].id1 ]->altLoc()); + std::string aloc_2(Sulfur_selection[ contact[i].id2 ]->altLoc()); if ( (aloc_1=="") || (aloc_2=="") || (aloc_1==aloc_2) ) { - coot::Cartesian atom_1(Sulfur_selection[ contact[i].id1 ]->x, - Sulfur_selection[ contact[i].id1 ]->y, - Sulfur_selection[ contact[i].id1 ]->z); + coot::Cartesian atom_1(Sulfur_selection[ contact[i].id1 ]->x(), + Sulfur_selection[ contact[i].id1 ]->y(), + Sulfur_selection[ contact[i].id1 ]->z()); - coot::Cartesian atom_2(Sulfur_selection[ contact[i].id2 ]->x, - Sulfur_selection[ contact[i].id2 ]->y, - Sulfur_selection[ contact[i].id2 ]->z); + coot::Cartesian atom_2(Sulfur_selection[ contact[i].id2 ]->x(), + Sulfur_selection[ contact[i].id2 ]->y(), + Sulfur_selection[ contact[i].id2 ]->z()); col = atom_colour(Sulfur_selection[ contact[i].id1 ], coot::DISULFIDE_COLOUR, udd_user_defined_atom_colour_index_handle); @@ -4905,9 +4905,9 @@ Bond_lines_container::do_Ca_loop(int imod, int ires, int nres, mmdb::Atom *N_this = residue_this->GetAtom(" N "); if (N_this) { float dist_sqrd = - (C_prev->x - N_this->x) * (C_prev->x - N_this->x) + - (C_prev->y - N_this->y) * (C_prev->y - N_this->y) + - (C_prev->z - N_this->z) * (C_prev->z - N_this->z); + (C_prev->x() - N_this->x()) * (C_prev->x() - N_this->x()) + + (C_prev->y() - N_this->y()) * (C_prev->y() - N_this->y()) + + (C_prev->z() - N_this->z()) * (C_prev->z() - N_this->z()); if (dist_sqrd < 2.5 * 2.5) C_and_N_are_close = true; } @@ -4925,9 +4925,9 @@ Bond_lines_container::do_Ca_loop(int imod, int ires, int nres, mmdb::Atom *P_this = residue_this->GetAtom(" P "); if (P_this) { float dist_sqrd = - (O3prime_prev->x - P_this->x) * (O3prime_prev->x - P_this->x) + - (O3prime_prev->y - P_this->y) * (O3prime_prev->y - P_this->y) + - (O3prime_prev->z - P_this->z) * (O3prime_prev->z - P_this->z); + (O3prime_prev->x() - P_this->x()) * (O3prime_prev->x() - P_this->x()) + + (O3prime_prev->y() - P_this->y()) * (O3prime_prev->y() - P_this->y()) + + (O3prime_prev->z() - P_this->z()) * (O3prime_prev->z() - P_this->z()); if (dist_sqrd < 2.5 * 2.5) // c.f 1.6 * 1.6 P_and_O3prime_are_close = true; } @@ -4939,8 +4939,8 @@ Bond_lines_container::do_Ca_loop(int imod, int ires, int nres, if (loop_is_possible) { if (at_pp_1 && at_pp_2 && at_pp_3 && at_pp_4) { - coot::Cartesian pp_2(at_pp_2->x, at_pp_2->y, at_pp_2->z); - coot::Cartesian pp_3(at_pp_3->x, at_pp_3->y, at_pp_3->z); + coot::Cartesian pp_2(at_pp_2->x(), at_pp_2->y(), at_pp_2->z()); + coot::Cartesian pp_3(at_pp_3->x(), at_pp_3->y(), at_pp_3->z()); float a = (pp_3-pp_2).amplitude(); int n_line_segments = static_cast(a*1.2); std::pair > lp = @@ -5078,11 +5078,11 @@ Bond_lines_container::do_Ca_or_P_bonds_internal(atom_selection_container_t SelAt mmdb::Atom *at_2 = residue_this->GetAtom(jat); std::string atom_name_2(at_2->GetAtomName()); if (atom_name_2 == " P ") { - std::string alt_conf_1 = at_1->altLoc; - std::string alt_conf_2 = at_2->altLoc; + std::string alt_conf_1 = at_1->altLoc(); + std::string alt_conf_2 = at_2->altLoc(); if (alt_conf_1.empty() || alt_conf_2.empty() || alt_conf_2 == alt_conf_1) { - coot::Cartesian pt_1(at_1->x, at_1->y, at_1->z); - coot::Cartesian pt_2(at_2->x, at_2->y, at_2->z); + coot::Cartesian pt_1(at_1->x(), at_1->y(), at_1->z()); + coot::Cartesian pt_2(at_2->x(), at_2->y(), at_2->z()); coot::Cartesian bond_mid_point = pt_1.mid_point(pt_2); int iat_1 = -1; int iat_2 = -1; @@ -5115,11 +5115,11 @@ Bond_lines_container::do_Ca_or_P_bonds_internal(atom_selection_container_t SelAt } } if (do_base_stick_bond) { // at least potentially... - std::string alt_conf_1 = at_1->altLoc; - std::string alt_conf_2 = at_2->altLoc; + std::string alt_conf_1 = at_1->altLoc(); + std::string alt_conf_2 = at_2->altLoc(); if (alt_conf_1.empty() || alt_conf_2.empty() || alt_conf_2 == alt_conf_1) { - coot::Cartesian pt_1(at_1->x, at_1->y, at_1->z); - coot::Cartesian pt_2(at_2->x, at_2->y, at_2->z); + coot::Cartesian pt_1(at_1->x(), at_1->y(), at_1->z()); + coot::Cartesian pt_2(at_2->x(), at_2->y(), at_2->z()); int iat_1 = -1; int iat_2 = -1; at_1->GetUDData(udd_atom_index_handle, iat_1); @@ -5144,11 +5144,11 @@ Bond_lines_container::do_Ca_or_P_bonds_internal(atom_selection_container_t SelAt mmdb::Atom *at_2 = residue_this->GetAtom(jat); std::string atom_name_2(at_2->GetAtomName()); if (atom_name_2 == " P ") { // PDBv3 FIXME - std::string alt_conf_prev = at_1->altLoc; - std::string alt_conf_this = at_2->altLoc; + std::string alt_conf_prev = at_1->altLoc(); + std::string alt_conf_this = at_2->altLoc(); if (alt_conf_prev.empty() || alt_conf_this.empty() || alt_conf_prev == alt_conf_this) { - coot::Cartesian pt_1(at_1->x, at_1->y, at_1->z); - coot::Cartesian pt_2(at_2->x, at_2->y, at_2->z); + coot::Cartesian pt_1(at_1->x(), at_1->y(), at_1->z()); + coot::Cartesian pt_2(at_2->x(), at_2->y(), at_2->z()); int iat_1 = -1; int iat_2 = -1; at_1->GetUDData(udd_atom_index_handle, iat_1); @@ -5190,8 +5190,8 @@ Bond_lines_container::do_Ca_or_P_bonds_internal(atom_selection_container_t SelAt for (int jat=0; jatGetAtom(jat); std::string atom_name_2(at_2->GetAtomName()); - std::string alt_conf_prev = at_1->altLoc; - std::string alt_conf_this = at_2->altLoc; + std::string alt_conf_prev = at_1->altLoc(); + std::string alt_conf_this = at_2->altLoc(); // Allow MSE hetgroups in CA mode if ((!at_1->Het || res_name_1 == "MSE") && (!at_2->Het || res_name_2 == "MSE")) { if (!at_1->isTer() && !at_2->isTer()) { @@ -5209,8 +5209,8 @@ Bond_lines_container::do_Ca_or_P_bonds_internal(atom_selection_container_t SelAt if (Calpha_pair || phosphate_pair) { if (alt_conf_prev == alt_conf_this || alt_conf_this == "" || alt_conf_prev == "") { int col = 0; // overridden. - coot::Cartesian ca_1(at_1->x, at_1->y, at_1->z); - coot::Cartesian ca_2(at_2->x, at_2->y, at_2->z); + coot::Cartesian ca_1(at_1->x(), at_1->y(), at_1->z()); + coot::Cartesian ca_2(at_2->x(), at_2->y(), at_2->z()); int iat_1 = -1; int iat_2 = -1; at_1->GetUDData(udd_atom_index_handle, iat_1); @@ -5419,7 +5419,7 @@ Bond_lines_container::do_Ca_or_P_bonds_internal(atom_selection_container_t SelAt int iat_1 = -1; // 20171224-PE FIXME int udd_status_1 = at->GetUDData(udd_atom_index_handle, iat_1); - coot::Cartesian pos(at->x, at->y, at->z); + coot::Cartesian pos(at->x(), at->y(), at->z()); addBond(col, pos+small_vec_x, pos-small_vec_x, cc, imod, iat_1, iat_1, true, true); addBond(col, pos+small_vec_y, pos-small_vec_y, cc, imod, iat_1, iat_1, true, true); addBond(col, pos+small_vec_z, pos-small_vec_z, cc, imod, iat_1, iat_1, true, true); @@ -5521,7 +5521,7 @@ Bond_lines_container::set_b_factor_colours(mmdb::Manager *mol) { for (int iat=0; iatGetAtom(iat); if (! atom_p->Het) { - float b_factor = atom_p->tempFactor; + float b_factor = atom_p->tempFactor(); float bs = b_factor * b_factor_scale; float f = bs/max_b_factor; if (f < 0.0) f = 0.0; @@ -5591,7 +5591,7 @@ Bond_lines_container::atom_colour(mmdb::Atom *at, int bond_colour_type, std::string ch_id(std::string(at->GetChainID())); int col_idx = atom_colour_map_p->index_for_chain(ch_id); col = 2 * col_idx; - std::string ele = at->element; + std::string ele = at->GetElementName(); if (ele != " C") col += 1; // std::cout << "here in atom_colour(): with goodsell colours with chain-id " << ch_id @@ -5601,7 +5601,7 @@ Bond_lines_container::atom_colour(mmdb::Atom *at, int bond_colour_type, } else { if (bond_colour_type == coot::COLOUR_BY_HYDROPHOBIC_SIDE_CHAIN) { - mmdb::Residue *r = at->residue; + mmdb::Residue *r = at->GetResidue(); if (r) { std::string res_name(r->GetResName()); if (coot::util::is_standard_amino_acid_name(res_name)) { @@ -5619,7 +5619,7 @@ Bond_lines_container::atom_colour(mmdb::Atom *at, int bond_colour_type, } if (bond_colour_type == coot::COLOUR_BY_SEC_STRUCT) { - int sse = at->residue->SSE; + int sse = at->GetResidue()->SSE; switch (sse) { case mmdb::SSE_None: col = 0; @@ -5647,7 +5647,7 @@ Bond_lines_container::atom_colour(mmdb::Atom *at, int bond_colour_type, } } else { if (bond_colour_type == coot::COLOUR_BY_ATOM_TYPE) { - std::string element(at->element); + std::string element(at->GetElementName()); if (element == " C") { return CARBON_BOND; @@ -5711,7 +5711,7 @@ Bond_lines_container::atom_colour(mmdb::Atom *at, int bond_colour_type, } else { if (bond_colour_type == coot::COLOUR_BY_CHAIN_C_ONLY) { - std::string element(at->element); + std::string element(at->GetElementName()); if (element == " C") { // PDBv3 FIXME (and below) if (atom_colour_map_p) { @@ -5787,19 +5787,19 @@ Bond_lines_container::atom_colour(mmdb::Atom *at, int bond_colour_type, return YELLOW_BOND; } else { if (bond_colour_type == coot::COLOUR_BY_OCCUPANCY) { - if (at->occupancy > 0.95) { + if (at->occupancy() > 0.95) { return BLUE_BOND; } else { - if (at->occupancy < 0.05) { + if (at->occupancy() < 0.05) { return RED_BOND; } else { - if (at->occupancy > 0.7) { + if (at->occupancy() > 0.7) { return CYAN_BOND; } else { - if (at->occupancy > 0.45) { + if (at->occupancy() > 0.45) { return GREEN_BOND; } else { - if (at->occupancy > 0.25) { + if (at->occupancy() > 0.25) { return YELLOW_BOND; } else { return ORANGE_BOND; @@ -5811,7 +5811,7 @@ Bond_lines_container::atom_colour(mmdb::Atom *at, int bond_colour_type, } else { if (bond_colour_type == coot::COLOUR_BY_B_FACTOR) { // B-factors by atom are done this way. - float scaled_b = at->tempFactor * b_factor_scale; + float scaled_b = at->tempFactor() * b_factor_scale; float max_b = 100.0; // std::cout << "here we go! scaled_b " << scaled_b << std::endl; float f = scaled_b/max_b; @@ -6001,7 +6001,7 @@ Bond_lines_container::do_Ca_plus_ligands_bonds(atom_selection_container_t SelAto if (residue_p->GetUDData(udd_has_ca_handle, ic) == mmdb::UDDATA_Ok) { if (ic == 0) { // Residue was not rendered as CA, needs normal bonds - std::string resname(residue_p->name); + std::string resname(residue_p->GetResName()); if (resname != "WAT" && resname != "HOH") { // can we do this residue by dictionary? @@ -6269,13 +6269,13 @@ Bond_lines_container::do_symmetry_Ca_bonds(atom_selection_container_t SelAtom, for (int i=0; i< ncontacts; i++) { if ( contact[i].id2 > contact[i].id1 ) { - coot::Cartesian ca_1(trans_ca_selection[ contact[i].id1 ]->x, - trans_ca_selection[ contact[i].id1 ]->y, - trans_ca_selection[ contact[i].id1 ]->z); + coot::Cartesian ca_1(trans_ca_selection[ contact[i].id1 ]->x(), + trans_ca_selection[ contact[i].id1 ]->y(), + trans_ca_selection[ contact[i].id1 ]->z()); - coot::Cartesian ca_2(trans_ca_selection[ contact[i].id2 ]->x, - trans_ca_selection[ contact[i].id2 ]->y, - trans_ca_selection[ contact[i].id2 ]->z); + coot::Cartesian ca_2(trans_ca_selection[ contact[i].id2 ]->x(), + trans_ca_selection[ contact[i].id2 ]->y(), + trans_ca_selection[ contact[i].id2 ]->z()); // 20171224-PE FIXME int iat_1 = -1; @@ -6306,7 +6306,7 @@ Bond_lines_container::draw_GA_rings_outer(mmdb::Residue *residue_p, int model_nu for (int iat=0; iatisTer()) { - std::string a(at->altLoc); + std::string a(at->altLoc()); residue_alt_confs.insert(a); } } @@ -6325,9 +6325,9 @@ Bond_lines_container::draw_GA_rings_outer(mmdb::Residue *residue_p, int model_nu for (int iat=0; iatisTer()) { - std::string atom_name(at->name); + std::string atom_name(at->GetAtomName()); if (atom_name == G_rings_atom_name) { - std::string a(at->altLoc); + std::string a(at->altLoc()); if (a == alt_loc || a == "") { G_rings_atoms[i] = at; n_found++; @@ -6365,7 +6365,7 @@ Bond_lines_container::draw_trp_ring_outer(mmdb::Residue *residue_p, int model_nu for (int iat=0; iatisTer()) { - std::string a(at->altLoc); + std::string a(at->altLoc()); residue_alt_confs.insert(a); } } @@ -6384,9 +6384,9 @@ Bond_lines_container::draw_trp_ring_outer(mmdb::Residue *residue_p, int model_nu for (int iat=0; iatisTer()) { - std::string atom_name(at->name); + std::string atom_name(at->GetAtomName()); if (atom_name == trp_rings_atom_name) { - std::string a(at->altLoc); + std::string a(at->altLoc()); if (a == alt_loc || a == "") { trp_rings_atoms[i] = at; n_found++; @@ -6423,7 +6423,7 @@ Bond_lines_container::draw_CUT_ring(mmdb::Residue *residue_p, int model_number, for (int iat=0; iatisTer()) { - std::string a(at->altLoc); + std::string a(at->altLoc()); residue_alt_confs.insert(a); } } @@ -6442,9 +6442,9 @@ Bond_lines_container::draw_CUT_ring(mmdb::Residue *residue_p, int model_number, for (int iat=0; iatisTer()) { - std::string atom_name(at->name); + std::string atom_name(at->GetAtomName()); if (atom_name == ring_atom_name) { - std::string a(at->altLoc); + std::string a(at->altLoc()); if (a == alt_loc || a == "") { ring_atoms[i] = at; n_found++; @@ -6483,9 +6483,9 @@ Bond_lines_container::draw_phenyl_ring_outer(mmdb::Residue *residue_p, int model for (int iat=0; iatisTer()) { - std::string atom_name(at->name); + std::string atom_name(at->GetAtomName()); if (atom_name == ring_atom_name) { - std::string a(at->altLoc); + std::string a(at->altLoc()); if (a == alt_loc || a == "") { ring_atoms[i] = at; n_found++; @@ -6525,7 +6525,7 @@ Bond_lines_container::draw_het_group_rings(mmdb::Residue *residue_p, for (int iat=0; iatisTer()) { - std::string atom_name(at->name); + std::string atom_name(at->GetAtomName()); if (names.atom_name(0) == atom_name) bq.atom_1 = at; if (names.atom_name(1) == atom_name) bq.atom_2 = at; if (names.atom_name(2) == atom_name) bq.atom_3 = at; @@ -6585,9 +6585,9 @@ Bond_lines_container::add_residue_monomer_bonds(const std::mapisTer()) { - std::string atom_name(at->name); - std::string ele(at->element); - std::string alt_loc(at->altLoc); + std::string atom_name(at->GetAtomName()); + std::string ele(at->GetElementName()); + std::string alt_loc(at->altLoc()); atom_string_bits_t asb(atom_name, ele, alt_loc, at); atom_name_ele_map[monomer_name][i].push_back(asb); if (at->Het) @@ -6725,7 +6725,7 @@ Bond_lines_container::add_residue_monomer_bonds(const std::mapisTer()) { - std::string a(at->altLoc); + std::string a(at->altLoc()); residue_alt_confs.insert(a); } } @@ -6785,10 +6785,10 @@ Bond_lines_container::add_residue_monomer_bonds(const std::mapelement); - std::string element_2(atom_p_2->element); - coot::Cartesian p1(atom_p_1->x, atom_p_1->y, atom_p_1->z); - coot::Cartesian p2(atom_p_2->x, atom_p_2->y, atom_p_2->z); + std::string element_1(atom_p_1->GetElementName()); + std::string element_2(atom_p_2->GetElementName()); + coot::Cartesian p1(atom_p_1->x(), atom_p_1->y(), atom_p_1->z()); + coot::Cartesian p2(atom_p_2->x(), atom_p_2->y(), atom_p_2->z()); int iat_1_atom_index = -1; int iat_2_atom_index = -1; @@ -7102,7 +7102,7 @@ Bond_lines_container::do_colour_by_dictionary_and_by_chain_bonds_carbons_only(co mmdb::Atom *at = asc.atom_selection[iat]; if (at->GetUDData(udd_found_bond_handle, ic) == mmdb::UDDATA_Ok) { if (ic == graphical_bonds_container::NO_BOND) { - mmdb::Residue *residue_p = at->residue; + mmdb::Residue *residue_p = at->GetResidue(); std::string res_name(residue_p->GetResName()); if (res_name == "HOH") if (! do_sticks_for_waters) @@ -7118,7 +7118,7 @@ Bond_lines_container::do_colour_by_dictionary_and_by_chain_bonds_carbons_only(co coot::Cartesian small_vec_y(0.0, star_size, 0.0); coot::Cartesian small_vec_z(0.0, 0.0, star_size); int col = atom_colour(at, atom_colour_type, udd_user_defined_atom_colour_index_handle, &atom_colour_map); - coot::Cartesian atom_pos(at->x, at->y, at->z); + coot::Cartesian atom_pos(at->x(), at->y(), at->z()); int iat_1 = -1; int udd_status_1 = at->GetUDData(udd_atom_index_handle, iat_1); @@ -7206,19 +7206,19 @@ Bond_lines_container::add_polymer_bonds_generic(const atom_selection_container_t for (int iat=0; iatGetAtom(iat); if (! at_1->isTer()) { - std::string at_1_name(at_1->name); + std::string at_1_name(at_1->GetAtomName()); if (at_1_name == res_1_atom_name) { for (int jat=0; jatGetAtom(jat); if (! at_2->isTer()) { - std::string at_2_name(at_2->name); + std::string at_2_name(at_2->GetAtomName()); if (at_2_name == res_2_atom_name) { - std::string alt_conf_1(at_1->altLoc); - std::string alt_conf_2(at_2->altLoc); + std::string alt_conf_1(at_1->altLoc()); + std::string alt_conf_2(at_2->altLoc()); if (alt_conf_1 == alt_conf_2 || alt_conf_1 == "" || alt_conf_2 == "") { - coot::Cartesian atom_1_pos(at_1->x, at_1->y, at_1->z); - coot::Cartesian atom_2_pos(at_2->x, at_2->y, at_2->z); + coot::Cartesian atom_1_pos(at_1->x(), at_1->y(), at_1->z()); + coot::Cartesian atom_2_pos(at_2->x(), at_2->y(), at_2->z()); int res_no_delta = residue_next_p->GetSeqNum() - residue_this_p->GetSeqNum(); bool do_it = true; @@ -7545,20 +7545,20 @@ Bond_lines_container::do_colour_by_chain_bonds(const atom_selection_container_t if (chain_id_1 == chain_id_2) { - element1 = at1->element; - element2 = at2->element; + element1 = at1->GetElementName(); + element2 = at2->GetElementName(); if ( (draw_hydrogens_flag == 1) || // (element1 != " H" && element1 != " D" && // element2 != " H" && element2 != " D") ) { (! is_hydrogen(element1) && ! is_hydrogen(element2))) { - coot::Cartesian atom_1(at1->x, at1->y, at1->z); - coot::Cartesian atom_2(at2->x, at2->y, at2->z); + coot::Cartesian atom_1(at1->x(), at1->y(), at1->z()); + coot::Cartesian atom_2(at2->x(), at2->y(), at2->z()); // alternate location test // - std::string aloc_1(at1->altLoc); - std::string aloc_2(at2->altLoc); + std::string aloc_1(at1->altLoc()); + std::string aloc_2(at2->altLoc()); // if (aloc_1 == "" || aloc_2 == "" || aloc_1 == aloc_2) { bonds_size_colour_check(col); @@ -7606,9 +7606,9 @@ Bond_lines_container::do_colour_by_chain_bonds(const atom_selection_container_t << std::endl; } else { if ((ic == graphical_bonds_container::NO_BOND) || - (!strcmp(atom_selection[i]->element, " S")) || - (!strcmp(atom_selection[i]->element, "SE")) || - (!strcmp(atom_selection[i]->element, " P"))) { + (!strcmp(atom_selection[i]->GetElementName(), " S")) || + (!strcmp(atom_selection[i]->GetElementName(), "SE")) || + (!strcmp(atom_selection[i]->GetElementName(), " P"))) { std::string segid(atom_selection[i]->GetChainID()); col = atom_colour_map.index_for_chain(segid); @@ -7617,14 +7617,14 @@ Bond_lines_container::do_colour_by_chain_bonds(const atom_selection_container_t // So, was this a seleno-methione? // - mmdb::Residue *atom_residue_p = atom_selection[i]->residue; + mmdb::Residue *atom_residue_p = atom_selection[i]->GetResidue(); if (atom_residue_p) { std::string resname = atom_selection[i]->GetResName(); if (resname == "MSE" || resname == "MET" || resname == "MSO" || resname == "CYS") { // handle_MET_or_MSE_case(atom_selection[i], uddHnd, udd_atom_index_handle, col); } else { - std::string ele = atom_selection[i]->element; + std::string ele = atom_selection[i]->GetElementName(); if (ele == "CL" || ele == "BR" || ele == " S" || ele == " I" || ele == "Cl" || ele == "Br" || ele == "MO" || ele == "PT" || ele == "RU" @@ -7649,16 +7649,16 @@ Bond_lines_container::do_colour_by_chain_bonds(const atom_selection_container_t if (atom_selection[i]->GetUDData(uddHnd, ic) == mmdb::UDDATA_Ok) { if (ic == graphical_bonds_container::NO_BOND) { // no contact found - std::string res_name(atom_selection[i]->residue->GetResName()); + std::string res_name(atom_selection[i]->GetResidue()->GetResName()); if (res_name == "HOH") if (! do_sticks_for_waters) continue; col = atom_colour(atom_selection[i], atom_colour_type, udd_user_defined_atom_colour_index_handle); - std::string ele = atom_selection[i]->element; + std::string ele = atom_selection[i]->GetElementName(); if (!is_hydrogen(ele) || draw_hydrogens_flag) { - coot::Cartesian atom(atom_selection[i]->x, - atom_selection[i]->y, - atom_selection[i]->z); + coot::Cartesian atom(atom_selection[i]->x(), + atom_selection[i]->y(), + atom_selection[i]->z()); int iat_1 = 1; // 20171224-PE FIXME real addBond(col, atom+small_vec_x, atom-small_vec_x, cc, imodel, iat_1, iat_1, true, true); @@ -7808,8 +7808,8 @@ Bond_lines_container::do_colour_by_chain_bonds_carbons_only(const atom_selection if (segid1 == segid2) { - element1 = at1->element; - element2 = at2->element; + element1 = at1->GetElementName(); + element2 = at2->GetElementName(); if ( (draw_hydrogens_flag == 1) || // (element1 != " H" && element1 != " D" && @@ -7817,13 +7817,13 @@ Bond_lines_container::do_colour_by_chain_bonds_carbons_only(const atom_selection (! is_hydrogen(element1) && ! is_hydrogen(element2))) { - coot::Cartesian atom_1(at1->x, at1->y, at1->z); - coot::Cartesian atom_2(at2->x, at2->y, at2->z); + coot::Cartesian atom_1(at1->x(), at1->y(), at1->z()); + coot::Cartesian atom_2(at2->x(), at2->y(), at2->z()); // alternate location test // - std::string aloc_1(at1->altLoc); - std::string aloc_2(at2->altLoc); + std::string aloc_1(at1->altLoc()); + std::string aloc_2(at2->altLoc()); // if (aloc_1 == "" || aloc_2 == "" || aloc_1 == aloc_2) { @@ -7849,8 +7849,8 @@ Bond_lines_container::do_colour_by_chain_bonds_carbons_only(const atom_selection // unbonded (stared) hydrogen atoms. // check the distance. - coot::Cartesian pt_1(at1->x, at1->y, at1->z); - coot::Cartesian pt_2(at2->x, at2->y, at2->z); + coot::Cartesian pt_1(at1->x(), at1->y(), at1->z()); + coot::Cartesian pt_2(at2->x(), at2->y(), at2->z()); double d = (pt_1-pt_2).amplitude(); if (d < 1.5) { @@ -7889,8 +7889,8 @@ Bond_lines_container::do_colour_by_chain_bonds_carbons_only(const atom_selection // 20190921-PE no longer consider P for additional bonds. Stops bond flashing in Goodsell // mode. if ((ic == graphical_bonds_container::NO_BOND) || - (!strcmp(atom_selection[i]->element, " S")) || - (!strcmp(atom_selection[i]->element, "SE")) + (!strcmp(atom_selection[i]->GetElementName(), " S")) || + (!strcmp(atom_selection[i]->GetElementName(), "SE")) // (!strcmp(atom_selection[i]->element, " P") ) { @@ -7904,7 +7904,7 @@ Bond_lines_container::do_colour_by_chain_bonds_carbons_only(const atom_selection // So, was this a seleno-methione? // - mmdb::Residue *atom_residue_p = atom_selection[i]->residue; + mmdb::Residue *atom_residue_p = atom_selection[i]->GetResidue(); if (atom_residue_p) { std::string resname = atom_selection[i]->GetResName(); if (resname == "MSE" || resname == "MET" || resname == "MSO" || resname == "CYS") { @@ -7912,7 +7912,7 @@ Bond_lines_container::do_colour_by_chain_bonds_carbons_only(const atom_selection udd_user_defined_atom_colour_index_handle, atom_colour_type, &atom_colour_map); } else { - std::string ele = atom_selection[i]->element; + std::string ele = atom_selection[i]->GetElementName(); if (ele == "CL" || ele == "BR" || ele == " S" || ele == " I" || ele == "Cl" || ele == "Br" || ele == "MO" || ele == "PT" || ele == "RU" @@ -7939,18 +7939,18 @@ Bond_lines_container::do_colour_by_chain_bonds_carbons_only(const atom_selection if (atom_selection[i]->GetUDData(uddHnd, ic) == mmdb::UDDATA_Ok) { if (ic == graphical_bonds_container::NO_BOND) { // no contact found - mmdb::Residue *residue_p = atom_selection[i]->residue; + mmdb::Residue *residue_p = atom_selection[i]->GetResidue(); std::string res_name(residue_p->GetResName()); if (res_name == "HOH") if (! do_sticks_for_waters) continue; col = atom_colour(atom_selection[i], atom_colour_type, udd_user_defined_atom_colour_index_handle); - std::string ele = atom_selection[i]->element; + std::string ele = atom_selection[i]->GetElementName(); // if (ele != " H" || draw_hydrogens_flag) { if (! is_hydrogen(ele) || draw_hydrogens_flag) { - coot::Cartesian atom(atom_selection[i]->x, - atom_selection[i]->y, - atom_selection[i]->z); + coot::Cartesian atom(atom_selection[i]->x(), + atom_selection[i]->y(), + atom_selection[i]->z()); addBond(col, atom+small_vec_x, atom-small_vec_x, cc, imodel, i, i, true, true); addBond(col, atom+small_vec_y, atom-small_vec_y, cc, imodel, i, i, true, true); @@ -8275,15 +8275,15 @@ Bond_lines_container::do_colour_by_ncs_related_chains_atoms_only(const atom_sele icol = icol_base * 2 + 100; // this is the way for Goodsell colours bool is_C = false; // only care about this if goodsell mode if (goodsell_mode) - is_C = strncmp(at->element, " C", 2); - bool is_H_flag = (is_hydrogen(std::string(at->element))); - coot::Cartesian pos(at->x, at->y, at->z); + is_C = strncmp(at->GetElementName(), " C", 2); + bool is_H_flag = (is_hydrogen(std::string(at->GetElementName()))); + coot::Cartesian pos(at->x(), at->y(), at->z()); graphical_bonds_atom_info_t gbai(pos, iat, is_H_flag); gbai.atom_p = at; bool make_fat_atom = false; // because atoms are rendered as BALLS_NOT_BONDS, they don't // need fattening here. gbai.set_radius_scale_for_atom(at, make_fat_atom); - if (std::string(at->residue->GetResName()) == "HOH") gbai.is_water = true; + if (std::string(at->GetResidue()->GetResName()) == "HOH") gbai.is_water = true; if (goodsell_mode) { if (is_C) icol += 1; // pastel versions } @@ -8411,11 +8411,11 @@ Bond_lines_container::do_colour_by_molecule_bonds(const atom_selection_container res2 = at2->GetSeqNum(); if (abs(res1 - res2) < 2) { - coot::Cartesian atom_1(at1->x, at1->y, at1->z); - coot::Cartesian atom_2(at2->x, at2->y, at2->z); + coot::Cartesian atom_1(at1->x(), at1->y(), at1->z()); + coot::Cartesian atom_2(at2->x(), at2->y(), at2->z()); - element1 = at1->element; - element2 = at2->element; + element1 = at1->GetElementName(); + element2 = at2->GetElementName(); if ( (draw_hydrogens_flag == 1) || // (element1 != " H" && element1 != " D" && // element2 != " H" && element2 != " D") ) { @@ -8423,8 +8423,8 @@ Bond_lines_container::do_colour_by_molecule_bonds(const atom_selection_container // alternate location test // - std::string aloc_1(at1->altLoc); - std::string aloc_2(at2->altLoc); + std::string aloc_1(at1->altLoc()); + std::string aloc_2(at2->altLoc()); // if (aloc_1 == "" || aloc_2 == "" || aloc_1 == aloc_2) { @@ -8470,7 +8470,7 @@ Bond_lines_container::do_colour_by_molecule_bonds(const atom_selection_container if ( atom_selection[i]->GetUDData(uddHnd,ic) == mmdb::UDDATA_Ok ) { // uddHnd for bond state if (ic == 0) { - std::string res_name(atom_selection[i]->residue->GetResName()); + std::string res_name(atom_selection[i]->GetResidue()->GetResName()); if (res_name == "HOH") if (! do_sticks_for_waters) continue; @@ -8478,9 +8478,9 @@ Bond_lines_container::do_colour_by_molecule_bonds(const atom_selection_container std::string segid(atom_selection[i]->GetChainID()); int col_inner = atom_colour_map.index_for_chain(segid); bonds_size_colour_check(col_inner); - coot::Cartesian atom(atom_selection[i]->x, - atom_selection[i]->y, - atom_selection[i]->z); + coot::Cartesian atom(atom_selection[i]->x(), + atom_selection[i]->y(), + atom_selection[i]->z()); addBond(col_inner, atom+small_vec_x, atom-small_vec_x, cc, imodel, i, i, true, true); addBond(col_inner, atom+small_vec_y, atom-small_vec_y, cc, imodel, i, i, true, true); @@ -8508,17 +8508,17 @@ Bond_lines_container::add_zero_occ_spots(const atom_selection_container_t &SelAt zero_occ_spots.clear(); for (int i=0; ioccupancy < 0.01 && - SelAtom.atom_selection[i]->occupancy > -1) { // shelx occ test + if (SelAtom.atom_selection[i]->occupancy() < 0.01 && + SelAtom.atom_selection[i]->occupancy() > -1) { // shelx occ test // we don't want to see atoms with occupancy -61 from a shelx ins // file with zero occupancy spots. - std::string ele(SelAtom.atom_selection[i]->element); + std::string ele(SelAtom.atom_selection[i]->GetElementName()); if (do_bonds_to_hydrogens || ((do_bonds_to_hydrogens == 0) && (! is_hydrogen(ele)))) { if (no_bonds_to_these_atoms.find(i) == no_bonds_to_these_atoms.end()) - zero_occ_spots.push_back(coot::Cartesian(SelAtom.atom_selection[i]->x, - SelAtom.atom_selection[i]->y, - SelAtom.atom_selection[i]->z)); + zero_occ_spots.push_back(coot::Cartesian(SelAtom.atom_selection[i]->x(), + SelAtom.atom_selection[i]->y(), + SelAtom.atom_selection[i]->z())); } } } @@ -8530,11 +8530,11 @@ Bond_lines_container::add_deuterium_spots(const atom_selection_container_t &SelA deuterium_spots.clear(); for (int i=0; ielement); + std::string ele(SelAtom.atom_selection[i]->GetElementName()); if (do_bonds_to_hydrogens && ele == " D") - deuterium_spots.push_back(coot::Cartesian(SelAtom.atom_selection[i]->x, - SelAtom.atom_selection[i]->y, - SelAtom.atom_selection[i]->z)); + deuterium_spots.push_back(coot::Cartesian(SelAtom.atom_selection[i]->x(), + SelAtom.atom_selection[i]->y(), + SelAtom.atom_selection[i]->z())); } } @@ -8558,10 +8558,10 @@ Bond_lines_container::add_ramachandran_goodness_spots(const atom_selection_conta mmdb::Atom *CB = r->GetAtom(" CB "); if (CA && C && N && CB) { - coot::Cartesian ca_pos(CA->x, CA->y, CA->z); - coot::Cartesian c_pos( C->x, C->y, C->z); - coot::Cartesian n_pos( N->x, N->y, N->z); - coot::Cartesian cb_pos(CB->x, CB->y, CB->z); + coot::Cartesian ca_pos(CA->x(), CA->y(), CA->z()); + coot::Cartesian c_pos( C->x(), C->y(), C->z()); + coot::Cartesian n_pos( N->x(), N->y(), N->z()); + coot::Cartesian cb_pos(CB->x(), CB->y(), CB->z()); coot::Cartesian dir_1 = ca_pos - c_pos; coot::Cartesian dir_2 = ca_pos - n_pos; coot::Cartesian dir_3 = ca_pos - cb_pos; @@ -8570,9 +8570,9 @@ Bond_lines_container::add_ramachandran_goodness_spots(const atom_selection_conta status = true; } else { if (CA && C && N) { - coot::Cartesian ca_pos(CA->x, CA->y, CA->z); - coot::Cartesian c_pos( C->x, C->y, C->z); - coot::Cartesian n_pos( N->x, N->y, N->z); + coot::Cartesian ca_pos(CA->x(), CA->y(), CA->z()); + coot::Cartesian c_pos( C->x(), C->y(), C->z()); + coot::Cartesian n_pos( N->x(), N->y(), N->z()); coot::Cartesian dir_1 = ca_pos - c_pos; coot::Cartesian dir_2 = ca_pos - n_pos; coot::Cartesian r = dir_1 + dir_2; @@ -8587,7 +8587,7 @@ Bond_lines_container::add_ramachandran_goodness_spots(const atom_selection_conta std::set sorted_residues_set(residue_sort_function); for (int i=0; iresidue; + mmdb::Residue *this_res = SelAtom.atom_selection[i]->GetResidue(); if (this_res) { sorted_residues_set.insert(this_res); } @@ -8623,7 +8623,7 @@ Bond_lines_container::add_ramachandran_goodness_spots(const atom_selection_conta mmdb::Atom *at = this_res->GetAtom(" CA "); // PDBv3 FIXME if (at) { - coot::Cartesian pos(at->x, at->y, at->z); + coot::Cartesian pos(at->x(), at->y(), at->z()); coot::Cartesian offset_in_HA_dir_uv(0,0,1); auto r = get_HA_unit_vector(this_res); if (r.first) @@ -8722,11 +8722,11 @@ Bond_lines_container::add_atom_centres(int imol, std::cout << " geom: " << geom << " " << coot::atom_spec_t(at) << " have_dict_for_this_type: " << have_dict_for_this_type << std::endl; - if (is_hydrogen(std::string(at->element))) + if (is_hydrogen(std::string(at->GetElementName()))) is_H_flag = true; if (do_bonds_to_hydrogens || (do_bonds_to_hydrogens == 0 && (!is_H_flag))) { - coot::Cartesian pos(at->x, at->y, at->z); + coot::Cartesian pos(at->x(), at->y(), at->z()); graphical_bonds_atom_info_t gbai(pos, idx, is_H_flag); // Fat atoms are for atom in residues with no dictionary - except @@ -8756,7 +8756,7 @@ Bond_lines_container::add_atom_centres(int imol, // because the add_bond function doesn't take a "thin" flag // (thinning is only currently done by bond colour) // - mmdb::Residue *r = at->residue; + mmdb::Residue *r = at->GetResidue(); if (r) { const char *rn = r->GetResName(); if (rn) { @@ -9003,10 +9003,10 @@ graphical_bonds_container::add_cis_peptide_markup(const std::vectorx, q.atom_1->y, q.atom_1->z); - coot::Cartesian c_2(q.atom_2->x, q.atom_2->y, q.atom_2->z); - coot::Cartesian c_3(q.atom_3->x, q.atom_3->y, q.atom_3->z); - coot::Cartesian c_4(q.atom_4->x, q.atom_4->y, q.atom_4->z); + coot::Cartesian c_1(q.atom_1->x(), q.atom_1->y(), q.atom_1->z()); + coot::Cartesian c_2(q.atom_2->x(), q.atom_2->y(), q.atom_2->z()); + coot::Cartesian c_3(q.atom_3->x(), q.atom_3->y(), q.atom_3->z()); + coot::Cartesian c_4(q.atom_4->x(), q.atom_4->y(), q.atom_4->z()); bool pre_pro_flag = false; bool twisted_trans_flag = false; if (cis_peptide_quads[i].type == coot::util::cis_peptide_quad_info_t::PRE_PRO_CIS) diff --git a/coords/Bond_lines.hh b/coords/Bond_lines.hh index ce1a414916..c496f2361b 100644 --- a/coords/Bond_lines.hh +++ b/coords/Bond_lines.hh @@ -112,7 +112,7 @@ namespace coot { int n_H() const { return hydrogen_atoms_.size(); } int n_non_H() const { return non_hydrogen_atoms_.size(); } void add_atom(mmdb::Atom *atom) { - std::string element = atom->element; + std::string element = atom->GetElementName(); if (element == " H" || element == " D") { hydrogen_atoms_.push_back(atom); } else { diff --git a/coords/Bond_lines_ext.cc b/coords/Bond_lines_ext.cc index 0488d3306a..07c99e11fb 100644 --- a/coords/Bond_lines_ext.cc +++ b/coords/Bond_lines_ext.cc @@ -94,13 +94,13 @@ Bond_lines_ext::find_skel_atom_bonds(atom_selection_container_t SelAtom) { int iat_1 = contact[i].id1; int iat_2 = contact[i].id2; - coot::Cartesian atom_1(atom_sel[ contact[i].id1 ]->x, - atom_sel[ contact[i].id1 ]->y, - atom_sel[ contact[i].id1 ]->z); + coot::Cartesian atom_1(atom_sel[ contact[i].id1 ]->x(), + atom_sel[ contact[i].id1 ]->y(), + atom_sel[ contact[i].id1 ]->z()); - coot::Cartesian atom_2(atom_sel[ contact[i].id2 ]->x, - atom_sel[ contact[i].id2 ]->y, - atom_sel[ contact[i].id2 ]->z); + coot::Cartesian atom_2(atom_sel[ contact[i].id2 ]->x(), + atom_sel[ contact[i].id2 ]->y(), + atom_sel[ contact[i].id2 ]->z()); addBond(col, atom_1, atom_2, cc, model_number, iat_1, iat_2, true, true); @@ -186,9 +186,9 @@ Bond_lines_ext::find_molecule_middle(atom_selection_container_t SelAtom, if (max_neighbour_atom_index != -1) { // - centre.set_them(atom_sel[max_neighbour_atom_index]->x, - atom_sel[max_neighbour_atom_index]->y, - atom_sel[max_neighbour_atom_index]->z); + centre.set_them(atom_sel[max_neighbour_atom_index]->x(), + atom_sel[max_neighbour_atom_index]->y(), + atom_sel[max_neighbour_atom_index]->z()); } else { // diff --git a/coords/graphical-bonds-container.hh b/coords/graphical-bonds-container.hh index fbea4fbf23..7dc6d59ff3 100644 --- a/coords/graphical-bonds-container.hh +++ b/coords/graphical-bonds-container.hh @@ -112,7 +112,7 @@ public: float scale = 1.0f; mmdb::Residue *r = atom_p->GetResidue(); if (r) { - std::string ele(atom_p->element); + std::string ele(atom_p->GetElementName()); if (ele == " H") return 0.5f; std::string res_name = r->GetResName(); if (res_name == "HOH") @@ -146,7 +146,7 @@ public: if (atom_index < n_atoms) { if (atom_index >= 0) { mmdb::Atom *at = atom_selection[atom_index]; - position = coot::Cartesian(at->x, at->y, at->z); + position = coot::Cartesian(at->x(), at->y(), at->z()); } } } diff --git a/coords/graphics-line.cc b/coords/graphics-line.cc index 58542e0b59..df141051a1 100644 --- a/coords/graphics-line.cc +++ b/coords/graphics-line.cc @@ -10,8 +10,8 @@ graphics_line_t::update(mmdb::Atom **atom_selection, int n_atoms) { if (atom_index_2 >= 0) { mmdb::Atom *at_1 = atom_selection[atom_index_1]; mmdb::Atom *at_2 = atom_selection[atom_index_2]; - coot::Cartesian p1(at_1->x, at_1->y, at_1->z); - coot::Cartesian p2(at_2->x, at_2->y, at_2->z); + coot::Cartesian p1(at_1->x(), at_1->y(), at_1->z()); + coot::Cartesian p2(at_2->x(), at_2->y(), at_2->z()); positions = coot::CartesianPair(p1, p2); } } diff --git a/coords/loop-path.cc b/coords/loop-path.cc index 231ee0ec25..be877740d7 100644 --- a/coords/loop-path.cc +++ b/coords/loop-path.cc @@ -60,8 +60,8 @@ coot::loop_path(mmdb::Atom *start_back_2, // between them should be flagged with something big and red. // Also, they will be drawn as a straight line, not a spline. - int res_no_start = start->residue->GetSeqNum(); - int res_no_end = end->residue->GetSeqNum(); + int res_no_start = start->GetResidue()->GetSeqNum(); + int res_no_end = end->GetResidue()->GetSeqNum(); int res_no_delta = res_no_end - res_no_start; n_line_segments = 2 * res_no_delta; // don't listen to call parameter! if (n_line_segments < 8) n_line_segments = 8; // sanitize diff --git a/coords/mmdb-crystal.cc b/coords/mmdb-crystal.cc index d59dcdff97..4d1c159678 100644 --- a/coords/mmdb-crystal.cc +++ b/coords/mmdb-crystal.cc @@ -85,9 +85,9 @@ molecule_extents_t::molecule_extents_t(atom_selection_container_t selection, for (int i=0; i< selection.n_selected_atoms; i++) { - atom_x = selection.atom_selection[i]->x; - atom_y = selection.atom_selection[i]->y; - atom_z = selection.atom_selection[i]->z; + atom_x = selection.atom_selection[i]->x(); + atom_y = selection.atom_selection[i]->y(); + atom_z = selection.atom_selection[i]->z(); // if there is only one atom, it will be all the limits, // so we don't use the else. @@ -182,9 +182,9 @@ molecule_extents_t::molecule_extents_t(atom_selection_container_t selection, coot::minimol::residue res(1, "EXT"); for (int i=0; i<6; i++) { coot::minimol::atom at(" CA ", " C", - extents_selection[i]->x, - extents_selection[i]->y, - extents_selection[i]->z, "", 10.0, 1.0); + extents_selection[i]->x(), + extents_selection[i]->y(), + extents_selection[i]->z(), "", 10.0, 1.0); res.addatom(at); } @@ -491,9 +491,9 @@ molecule_extents_t::which_strict_ncs(const coot::Cartesian ¢re_pt, // OK, so what now is the fractional difference between atom and trans_atom? // - diff_x = centre_pt.x() - trans_atom.x; - diff_y = centre_pt.y() - trans_atom.y; - diff_z = centre_pt.z() - trans_atom.z; + diff_x = centre_pt.x() - trans_atom.x(); + diff_y = centre_pt.y() - trans_atom.y(); + diff_z = centre_pt.z() - trans_atom.z(); AtomSel.mol->Orth2Frac(diff_x, diff_y, diff_z, u, v, w); // fill u, v, w. @@ -513,11 +513,11 @@ molecule_extents_t::which_strict_ncs(const coot::Cartesian ¢re_pt, shift_matrix(AtomSel.mol, m[ii], x_shift, y_shift, z_shift, shifted_mat); tmp_atom.Transform(shifted_mat); b = 0.0; - dist = tmp_atom.x - centre_pt.x(); + dist = tmp_atom.x() - centre_pt.x(); b += dist*dist; - dist = tmp_atom.y - centre_pt.y(); + dist = tmp_atom.y() - centre_pt.y(); b += dist*dist; - dist = tmp_atom.z - centre_pt.z(); + dist = tmp_atom.z() - centre_pt.z(); b += dist*dist; if (b < min_dist) { min_dist = b; @@ -672,9 +672,9 @@ molecule_extents_t::trans_sel(mmdb::Cryst *my_cryst, for (int ii=0; ii<6; ii++) { trans_selection[ii] = new mmdb::Atom; - trans_selection[ii]->SetCoordinates(extents_selection[ii]->x, - extents_selection[ii]->y, - extents_selection[ii]->z, + trans_selection[ii]->SetCoordinates(extents_selection[ii]->x(), + extents_selection[ii]->y(), + extents_selection[ii]->z(), 1.0, 99.9); trans_selection[ii]->Transform(my_matt); } @@ -698,9 +698,9 @@ molecule_extents_t::trans_sel(mmdb::Manager *mol, for (int ii=0; ii<6; ii++) { trans_selection[ii] = new mmdb::Atom; - trans_selection[ii]->SetCoordinates(extents_selection[ii]->x, - extents_selection[ii]->y, - extents_selection[ii]->z, + trans_selection[ii]->SetCoordinates(extents_selection[ii]->x(), + extents_selection[ii]->y(), + extents_selection[ii]->z(), 1.0, 99.9); trans_selection[ii]->Transform(my_matt); } @@ -750,9 +750,9 @@ molecule_extents_t::trans_sel(mmdb::Manager *mol, mmdb::mat44 my_mat, for (int ii=0; ii<6; ii++) { trans_selection[ii] = new mmdb::Atom; - trans_selection[ii]->SetCoordinates(extents_selection[ii]->x, - extents_selection[ii]->y, - extents_selection[ii]->z, + trans_selection[ii]->SetCoordinates(extents_selection[ii]->x(), + extents_selection[ii]->y(), + extents_selection[ii]->z(), 1.0, 99.9); trans_selection[ii]->Transform(amat); } @@ -784,32 +784,32 @@ molecule_extents_t::trans_sel_o(mmdb::Manager *mol, const symm_trans_t &symm_tra atom.Copy(extents_selection[0]); atom.Transform(to_origin_matt); atom.Transform(my_matt); - t.front = coot::Cartesian(atom.x, atom.y, atom.z); + t.front = coot::Cartesian(atom.x(), atom.y(), atom.z()); atom.Copy(extents_selection[1]); atom.Transform(to_origin_matt); atom.Transform(my_matt); - t.back = coot::Cartesian(atom.x, atom.y, atom.z); + t.back = coot::Cartesian(atom.x(), atom.y(), atom.z()); atom.Copy(extents_selection[2]); atom.Transform(to_origin_matt); atom.Transform(my_matt); - t.left = coot::Cartesian(atom.x, atom.y, atom.z); + t.left = coot::Cartesian(atom.x(), atom.y(), atom.z()); atom.Copy(extents_selection[3]); atom.Transform(to_origin_matt); atom.Transform(my_matt); - t.right = coot::Cartesian(atom.x, atom.y, atom.z); + t.right = coot::Cartesian(atom.x(), atom.y(), atom.z()); atom.Copy(extents_selection[4]); atom.Transform(to_origin_matt); atom.Transform(my_matt); - t.bottom = coot::Cartesian(atom.x, atom.y, atom.z); + t.bottom = coot::Cartesian(atom.x(), atom.y(), atom.z()); atom.Copy(extents_selection[5]); atom.Transform(to_origin_matt); atom.Transform(my_matt); - t.top = coot::Cartesian(atom.x, atom.y, atom.z); + t.top = coot::Cartesian(atom.x(), atom.y(), atom.z()); return t; } @@ -823,12 +823,12 @@ molecule_extents_t::point_is_in_box(const coot::Cartesian &point, mmdb::PPAtom T // front back left right bottom top // z x y // - coot::Cartesian front(TransSel[0]->x, TransSel[0]->y, TransSel[0]->z); - coot::Cartesian back(TransSel[1]->x, TransSel[1]->y, TransSel[1]->z); - coot::Cartesian left(TransSel[2]->x, TransSel[2]->y, TransSel[2]->z); - coot::Cartesian right(TransSel[3]->x, TransSel[3]->y, TransSel[3]->z); - coot::Cartesian bottom(TransSel[4]->x, TransSel[4]->y, TransSel[4]->z); - coot::Cartesian top(TransSel[5]->x, TransSel[5]->y, TransSel[5]->z); + coot::Cartesian front(TransSel[0]->x(), TransSel[0]->y(), TransSel[0]->z()); + coot::Cartesian back(TransSel[1]->x(), TransSel[1]->y(), TransSel[1]->z()); + coot::Cartesian left(TransSel[2]->x(), TransSel[2]->y(), TransSel[2]->z()); + coot::Cartesian right(TransSel[3]->x(), TransSel[3]->y(), TransSel[3]->z()); + coot::Cartesian bottom(TransSel[4]->x(), TransSel[4]->y(), TransSel[4]->z()); + coot::Cartesian top(TransSel[5]->x(), TransSel[5]->y(), TransSel[5]->z()); coot::Cartesian back_to_front = front - back; coot::Cartesian left_to_right = right - left; @@ -1072,7 +1072,7 @@ coot::Cartesian translate_atom(atom_selection_container_t AtomSel, int ii, trans_atom->Copy(AtomSel.atom_selection[ii]); trans_atom->Transform(my_matt); - coot::Cartesian c(trans_atom->x, trans_atom->y, trans_atom->z); + coot::Cartesian c(trans_atom->x(), trans_atom->y(), trans_atom->z()); delete trans_atom; return c; @@ -1108,7 +1108,7 @@ translate_atom_with_pre_shift(atom_selection_container_t AtomSel, int ii, trans_atom.Transform(pre_shift_matt); trans_atom.Transform(my_matt); - coot::Cartesian c(trans_atom.x, trans_atom.y, trans_atom.z); + coot::Cartesian c(trans_atom.x(), trans_atom.y(), trans_atom.z()); return c; } diff --git a/coords/mmdb-extras.cc b/coords/mmdb-extras.cc index 116476ba2c..03cf055f0c 100644 --- a/coords/mmdb-extras.cc +++ b/coords/mmdb-extras.cc @@ -144,7 +144,7 @@ coot::deep_copy_this_residue_old_style(mmdb::Residue *residue, mmdb::Atom *at = residue_atoms[iat]; if (at) { // can have been deleted if (! at->isTer()) { - std::string this_atom_alt_loc(residue_atoms[iat]->altLoc); + std::string this_atom_alt_loc(residue_atoms[iat]->altLoc()); if (whole_residue_flag || this_atom_alt_loc == altconf || this_atom_alt_loc == "") { atom_p = new mmdb::Atom; @@ -210,10 +210,10 @@ coot::deep_copy_this_residue_and_make_asc(mmdb::Manager *orig_mol, mmdb::Chain *chain_p = new mmdb::Chain; std::string chain_id1 = ((mmdb::Residue *)residue)->GetChainID(); chain_p->SetChainID(chain_id1.c_str()); - rres->seqNum = ((mmdb::Residue *)residue)->GetSeqNum(); + rres->GetSeqNum() = ((mmdb::Residue *)residue)->GetSeqNum(); /* Copy insertion code - a char[10] */ memcpy(rres->insCode, residue->insCode, sizeof(mmdb::InsCode)); - memcpy(rres->name, residue->name, sizeof(mmdb::ResName)); + rres->SetResName(residue->name); mmdb::PPAtom residue_atoms; int nResidueAtoms; @@ -225,7 +225,7 @@ coot::deep_copy_this_residue_and_make_asc(mmdb::Manager *orig_mol, for(int iat=0; iatisTer()) { - std::string this_atom_alt_loc(residue_atoms[iat]->altLoc); + std::string this_atom_alt_loc(residue_atoms[iat]->altLoc()); if (whole_residue_flag || this_atom_alt_loc == altconf || this_atom_alt_loc == "") { atom_p = new mmdb::Atom; @@ -311,7 +311,7 @@ coot::get_first_atom_with_atom_name(const std::string &atomname, mmdb::Atom *atom = NULL; for (int i=0; iname); + std::string name(asc.atom_selection[i]->GetAtomName()); if (name == atomname) { atom = asc.atom_selection[i]; break; diff --git a/coords/mmdb.cc b/coords/mmdb.cc index 9f067067a2..fdaff931b1 100644 --- a/coords/mmdb.cc +++ b/coords/mmdb.cc @@ -65,7 +65,7 @@ centre_of_molecule(atom_selection_container_t SelAtom) { for (int i=0; i< SelAtom.n_selected_atoms; i++) { atom = SelAtom.atom_selection[i]; - coot::Cartesian atom_pos (atom->x, atom->y, atom->z); + coot::Cartesian atom_pos (atom->x(), atom->y(), atom->z()); rs += atom_pos; } @@ -86,9 +86,9 @@ std::ostream& operator<<(std::ostream& s, mmdb::Atom &atom) { // s << atom.GetModelNum() << "/" << atom.GetChainID() << "/" << atom.GetSeqNum() << atom.GetInsCode() << "/" << atom.GetResName() - << "/" << atom.name << " altLoc :" << atom.altLoc << ": pos: (" - << atom.x << "," << atom.y << "," << atom.z - << ") B-factor: " << atom.tempFactor; + << "/" << atom.GetAtomName() << " altLoc :" << atom.altLoc() << ": pos: (" + << atom.x() << "," << atom.y() << "," << atom.z() + << ") B-factor: " << atom.tempFactor(); return s; @@ -103,10 +103,10 @@ std::ostream& operator<<(std::ostream& s, mmdb::PAtom atom) { s << atom->GetModelNum() << "/" << atom->GetChainID() << "/" << atom->GetSeqNum() << atom->GetInsCode() << " {" << atom->GetResName() << "}/" - << atom->name << " altLoc :" << atom->altLoc << ": segid :" + << atom->GetAtomName() << " altLoc :" << atom->altLoc() << ": segid :" << atom->segID << ":" << " pos: (" - << atom->x << "," << atom->y << "," << atom->z - << ") B-factor: " << atom->tempFactor; + << atom->x() << "," << atom->y() << "," << atom->z() + << ") B-factor: " << atom->tempFactor(); } else { s << "NULL"; } @@ -233,7 +233,7 @@ coot::delete_hydrogens_from_mol(mmdb::Manager *mol) { bool deleted = 0; for (int iat=0; iatGetAtom(iat); - std::string ele(at->element); + std::string ele(at->GetElementName()); if (is_hydrogen(ele)) { // delete this atom deleted = 1; diff --git a/coords/phenix-geo-bonds.cc b/coords/phenix-geo-bonds.cc index 5961f829d3..3a48118100 100644 --- a/coords/phenix-geo-bonds.cc +++ b/coords/phenix-geo-bonds.cc @@ -65,13 +65,13 @@ Bond_lines_container::Bond_lines_container(mmdb::Manager *mol, if (previous_atom_1) { atom_1 = previous_atom_1; - atom_1_res = atom_1->residue; + atom_1_res = atom_1->GetResidue(); } coot::residue_spec_t res_2_spec(gb.atom_2); if (atom_1) { - mmdb::Atom *atom_2 = coot::util::get_atom(atom_2_spec, atom_1->residue); + mmdb::Atom *atom_2 = coot::util::get_atom(atom_2_spec, atom_1->GetResidue()); if (res_2_spec == res_1_spec) { @@ -148,7 +148,7 @@ Bond_lines_container::Bond_lines_container(mmdb::Manager *mol, if (atom_1) { coot::residue_spec_t res_2_spec(gb.atom_2); if (res_2_spec == res_1_spec) { - mmdb::Atom *atom_2 = coot::util::get_atom(atom_2_spec, atom_1->residue); + mmdb::Atom *atom_2 = coot::util::get_atom(atom_2_spec, atom_1->GetResidue()); if (atom_2) { bonded_atom_pairs.push_back(bonded_atom_pair_t(atom_1, atom_2, gb.residual)); } else { @@ -176,11 +176,11 @@ Bond_lines_container::Bond_lines_container(mmdb::Manager *mol, if (atom_1) { res_1_spec = coot::residue_spec_t(atom_1->GetResidue()); - atom_1_res=atom_1->residue; + atom_1_res=atom_1->GetResidue(); coot::residue_spec_t res_2_spec(gb.atom_2); if (res_2_spec == res_1_spec) { - mmdb::Atom *atom_2 = coot::util::get_atom(atom_2_spec, atom_1->residue); + mmdb::Atom *atom_2 = coot::util::get_atom(atom_2_spec, atom_1->GetResidue()); if (atom_2) { bonded_atom_pairs.push_back(bonded_atom_pair_t(atom_1, atom_2, gb.residual)); } else { @@ -238,8 +238,8 @@ Bond_lines_container::Bond_lines_container(mmdb::Manager *mol, a1->GetUDData(udd_atom_index_handle, atom_index_1); a2->GetUDData(udd_atom_index_handle, atom_index_2); int col = atom_colour(bap.residual); - addBond(col, coot::Cartesian(a1->x, a1->y, a1->z), - coot::Cartesian(a2->x, a2->y, a2->z), + addBond(col, coot::Cartesian(a1->x(), a1->y(), a1->z()), + coot::Cartesian(a2->x(), a2->y(), a2->z()), cc, model_number, atom_index_1, atom_index_2); } @@ -325,7 +325,7 @@ Bond_lines_container::stars_for_unbonded_atoms(mmdb::Manager *mol, int uddHnd) { if (at) { if (at->GetUDData(uddHnd, ic) == mmdb::UDDATA_Ok) { if (ic == graphical_bonds_container::NO_BOND) { - coot::Cartesian atom_pos(at->x, at->y, at->z); + coot::Cartesian atom_pos(at->x(), at->y(), at->z()); addBond(col, atom_pos+small_vec_x, atom_pos-small_vec_x, cc, -1, -1, -1, true, true); addBond(col, atom_pos+small_vec_y, atom_pos-small_vec_y, cc, -1, -1, -1, true, true); addBond(col, atom_pos+small_vec_z, atom_pos-small_vec_z, cc, -1, -1, -1, true, true); diff --git a/coot-utils/atom-overlaps.cc b/coot-utils/atom-overlaps.cc index d17513195b..28ce1d414f 100644 --- a/coot-utils/atom-overlaps.cc +++ b/coot-utils/atom-overlaps.cc @@ -272,8 +272,8 @@ coot::atom_overlaps_container_t::mark_donors_and_acceptors_central_residue(int u res_central->GetAtomTable(central_residue_atoms, n_central_residue_atoms); for (int iat=0; iatname); - std::string ele = at->element; + std::string atom_name(at->GetAtomName()); + std::string ele = at->GetElementName(); if (ele == " H") { molecule_has_hydrogens = true; // Hydrogens have energy type "H" from Refmac and acedrg, that doesn't @@ -372,8 +372,8 @@ coot::atom_overlaps_container_t::mark_donors_and_acceptors_for_neighbours(int ud neighbours[i]->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); - std::string ele = n_at->element; + std::string atom_name(n_at->GetAtomName()); + std::string ele = n_at->GetElementName(); if (ele == " H") { molecule_has_hydrogens = true; // as above @@ -649,14 +649,14 @@ coot::atom_overlaps_container_t::kludge_filter(mmdb::Atom *at_1, mmdb::Atom *at_ // generate full restraints - which we don't do. bool reject = false; - if (at_1->residue->chain == at_2->residue->chain) { - std::string res_name_1(at_1->residue->GetResName()); + if (at_1->GetResidue()->chain == at_2->GetResidue()->chain) { + std::string res_name_1(at_1->GetResidue()->GetResName()); if (res_name_1 == "ASN") { - std::string res_name_2(at_2->residue->GetResName()); + std::string res_name_2(at_2->GetResidue()->GetResName()); if (res_name_2 == "NAG") { - std::string atom_name_1(at_1->name); + std::string atom_name_1(at_1->GetAtomName()); if (atom_name_1 == " NE2") { - std::string atom_name_2(at_2->name); + std::string atom_name_2(at_2->GetAtomName()); if (atom_name_2 == " C2 ") { reject = true; } @@ -664,11 +664,11 @@ coot::atom_overlaps_container_t::kludge_filter(mmdb::Atom *at_1, mmdb::Atom *at_ } } if (res_name_1 == "NAG") { - std::string res_name_2(at_2->residue->GetResName()); + std::string res_name_2(at_2->GetResidue()->GetResName()); if (res_name_2 == "ASN") { - std::string atom_name_1(at_1->name); + std::string atom_name_1(at_1->GetAtomName()); if (atom_name_1 == " C2 ") { - std::string atom_name_2(at_2->name); + std::string atom_name_2(at_2->GetAtomName()); if (atom_name_2 == " NE2") { reject = true; } @@ -1098,7 +1098,7 @@ coot::hb_t coot::atom_overlaps_container_t::get_h_bond_type(mmdb::Atom *at) { hb_t type = HB_UNASSIGNED; - std::string atom_name = at->name; + std::string atom_name = at->GetAtomName(); std::string res_name = at->GetResName(); type = geom_p->get_h_bond_type(atom_name, res_name, protein_geometry::IMOL_ENC_ANY); // heavyweight @@ -1123,12 +1123,12 @@ coot::atom_overlaps_container_t::contact_dots_for_overlaps() const { // std::cout << "considering overlap idx: " << i << std::endl; - clipper::Coord_orth pt_at_1(overlaps[i].atom_1->x, - overlaps[i].atom_1->y, - overlaps[i].atom_1->z); - clipper::Coord_orth pt_at_2(overlaps[i].atom_2->x, - overlaps[i].atom_2->y, - overlaps[i].atom_2->z); + clipper::Coord_orth pt_at_1(overlaps[i].atom_1->x(), + overlaps[i].atom_1->y(), + overlaps[i].atom_1->z()); + clipper::Coord_orth pt_at_2(overlaps[i].atom_2->x(), + overlaps[i].atom_2->y(), + overlaps[i].atom_2->z()); const double &r_1 = overlaps[i].r_1; const double &r_2 = overlaps[i].r_2; const int &idx = overlaps[i].ligand_atom_index; @@ -1152,7 +1152,7 @@ coot::atom_overlaps_container_t::contact_dots_for_overlaps() const { bool draw_it = ! is_inside_another_ligand_atom(idx, pt_at_surface); if (false) // debugging - if (std::string(overlaps[i].atom_1->name) != " HO3") + if (std::string(overlaps[i].atom_1->GetAtomName()) != " HO3") draw_it = false; if (draw_it) { @@ -1365,7 +1365,7 @@ coot::atom_overlaps_container_t::contact_dots_for_ligand(double dot_density_in) double r_1 = get_vdw_radius_ligand_atom(cr_at); std::vector &sphere_points_for_atom = sphere_points; - if (std::string(cr_at->element) == " H") + if (std::string(cr_at->GetElementName()) == " H") sphere_points_for_atom = H_sphere_points; for (unsigned int j=0; j &sphere_points_for_atom = sphere_points; - if (std::string(at->element) == " H") + if (std::string(at->GetElementName()) == " H") sphere_points_for_atom = H_sphere_points; // if (std::string(at->element) == " H") // dot_density *=0.66; // so that surface dots on H atoms don't appear (weirdly) more fine - if (std::string(at->element) == " H") + if (std::string(at->GetElementName()) == " H") sphere_points_for_atom = H_sphere_points; for (unsigned int j=0; jresidue != atom_with_biggest_overlap->residue) { + if (at->GetResidue() != atom_with_biggest_overlap->GetResidue()) { atom_overlaps_dots_container_t::dot_t dot(overlap_delta, col, pt_at_surface); ao.dots[c_type].push_back(dot); } @@ -2033,7 +2033,7 @@ coot::atom_overlaps_container_t::contacts_for_atom(int iat, std::vector H_sphere_points = fibonacci_sphere(n_sphere_points_for_H); // less than above std::vector sphere_points_for_atom; - if (std::string(at->element) == " H") + if (std::string(at->GetElementName()) == " H") sphere_points_for_atom = H_sphere_points; else sphere_points_for_atom = sphere_points; @@ -2072,7 +2072,7 @@ coot::atom_overlaps_container_t::contacts_for_atom(int iat, for (unsigned int jj=0; jjresidue == at->residue) continue; + if (neighb_atom->GetResidue() == at->GetResidue()) continue; double r_2 = neighb_atom_radius[v[jj]]; double r_2_sqrd = r_2 * r_2; double r_2_plus_prb_squard = r_2_sqrd + 2 * r_2 * probe_radius + @@ -2136,7 +2136,7 @@ coot::atom_overlaps_container_t::contacts_for_atom(int iat, // draw dot if these are atoms from different residues or this is not // a wide contact - if (at->residue != atom_with_biggest_overlap->residue) { + if (at->GetResidue() != atom_with_biggest_overlap->GetResidue()) { atom_overlaps_dots_container_t::dot_t dot(overlap_delta, col, pt_at_surface); ao.dots[c_type].push_back(dot); } else { @@ -2181,8 +2181,8 @@ coot::atom_overlaps_container_t::clashable_alt_confs(mmdb::Atom *at_1, mmdb::Ato bool r = true; - std::string alt_conf_1 = at_1->altLoc; - std::string alt_conf_2 = at_2->altLoc; + std::string alt_conf_1 = at_1->altLoc(); + std::string alt_conf_2 = at_2->altLoc(); if (alt_conf_1.empty()) { return true; @@ -2244,7 +2244,7 @@ coot::atom_overlaps_container_t::is_inside_an_env_atom_to_which_its_bonded(int i // std::cout << "testing env_atom: " << atom_spec_t(env_atom) << std::endl; clipper::Coord_orth pt_env_atom = co(env_atom); double r_2 = 1.6; - std::string ele(env_atom->element); + std::string ele(env_atom->GetElementName()); if (ele == " H") r_2 = 0.97; double r_2_sqrd = r_2 * r_2; @@ -2521,7 +2521,7 @@ coot::atom_overlaps_container_t::setup_env_residue_atoms_radii(int i_sel_hnd_env std::cout << ":::::::::::::::::: in setup_env_residue_atoms_radii() the dictionary_map is of size " << dictionary_map.size() << " and residue_index is " << residue_index << std::endl; - mmdb::Residue *res = at->residue; + mmdb::Residue *res = at->GetResidue(); const dictionary_residue_restraints_t &rest = get_dictionary(res, residue_index); // is rest sane? // std::cout << "debug:: rest has " << rest.atom_info.size() << " atoms "<< std::endl; @@ -2675,8 +2675,8 @@ coot::atom_overlaps_container_t::bonded_angle_or_ring_related(mmdb::Manager *mol // std::string res_name = res_1->GetResName(); std::vector > bps; - std::string atom_name_1 = at_1->name; - std::string atom_name_2 = at_2->name; + std::string atom_name_1 = at_1->GetAtomName(); + std::string atom_name_2 = at_2->GetAtomName(); std::map > >::const_iterator it; it = bonded_neighbours->find(res_name); if (it == bonded_neighbours->end()) { @@ -2912,9 +2912,9 @@ coot::atom_overlaps_container_t::is_ss_bonded_or_CYS_CYS_SGs(mmdb::Atom *at_1, // There is no mmdb class for SSBOND! - must fix. bool status = false; - std::string res_name_1 = at_1->residue->GetResName(); + std::string res_name_1 = at_1->GetResidue()->GetResName(); if (res_name_1 == "CYS") { - std::string res_name_2 = at_2->residue->GetResName(); + std::string res_name_2 = at_2->GetResidue()->GetResName(); if (res_name_2 == "CYS") { std::string atom_name_1 = at_1->GetAtomName(); if (atom_name_1 == " SG ") { @@ -3119,8 +3119,8 @@ coot::atom_overlaps_container_t::are_bonded_residues(mmdb::Residue *res_1, mmdb: if (! r) { // perhaps they are next to each other by serial number but not sequence number - int ser_1 = res_1->index; - int ser_2 = res_2->index; + int ser_1 = res_1->GetIndex(); + int ser_2 = res_2->GetIndex(); if (ser_2 > ser_1) { if ((ser_2 - ser_1) == 1) { if (! res_1->isCTerminus()) { diff --git a/coot-utils/atom-selection-container.cc b/coot-utils/atom-selection-container.cc index cd39f6eccb..603293d883 100644 --- a/coot-utils/atom-selection-container.cc +++ b/coot-utils/atom-selection-container.cc @@ -526,7 +526,7 @@ get_atom_selection(std::string pdb_name, std::cout << i << " " << asc.atom_selection[i]->GetChainID() << " " << asc.atom_selection[i]->GetSeqNum() << " :" - << asc.atom_selection[i]->name << ":" <GetAtomName() << ":" <GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - std::string ele(at->element); + std::string ele(at->GetElementName()); if (ele.length() == 1) { ele = " " + ele; at->SetElementName(ele.c_str()); @@ -677,7 +677,7 @@ fix_nucleic_acid_residue_names(atom_selection_container_t asc) { mmdb::PResidue residue_p; for (int ires=0; iresGetResidue(ires); - std::string residue_name(residue_p->name); + std::string residue_name(residue_p->GetResName()); if (residue_name == "T" || residue_name == "U" || @@ -711,7 +711,7 @@ int fix_nucleic_acid_residue_name(mmdb::Residue *r) { r->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; iname); + std::string atom_name(residue_atoms[i]->GetAtomName()); if (atom_name == " O2*") { found_o2_star = 1; break; @@ -727,7 +727,7 @@ int fix_nucleic_acid_residue_name(mmdb::Residue *r) { convert_to_old_nucleotide_atom_names(r); - std::string res_name = r->name; + std::string res_name = r->GetResName(); std::string new_name_stub = res_name.substr(0,1); if (res_name == "DA" || res_name == "DT" || res_name == "DC" || res_name == "DG") @@ -757,9 +757,9 @@ convert_to_old_nucleotide_atom_names(mmdb::Residue *r) { int n_residue_atoms; r->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; iname); + std::string atom_name(residue_atoms[i]->GetAtomName()); std::string name_orig = atom_name; - std::string ele(residue_atoms[i]->element); + std::string ele(residue_atoms[i]->GetElementName()); char c3 = atom_name[2]; // 3rd char char c4 = atom_name[3]; // 4th char if (coot::is_hydrogen(ele)) { @@ -777,21 +777,21 @@ convert_to_old_nucleotide_atom_names(mmdb::Residue *r) { atom_name[3] = '*'; } } - strncpy(residue_atoms[i]->name, atom_name.c_str(),5); + residue_atoms[i]->SetAtomName(atom_name.c_str()); } else { // if it is not a hydrogen, simply change the prime to a star if (c4 == '\'') { atom_name[3] = '*'; - strncpy(residue_atoms[i]->name, atom_name.c_str(),5); + residue_atoms[i]->SetAtomName(atom_name.c_str()); } if (atom_name == " OP1") { atom_name = " O1P"; - strncpy(residue_atoms[i]->name, atom_name.c_str(),5); + residue_atoms[i]->SetAtomName(atom_name.c_str()); } if (atom_name == " OP2") { atom_name = " O2P"; - strncpy(residue_atoms[i]->name, atom_name.c_str(),5); + residue_atoms[i]->SetAtomName(atom_name.c_str()); } } // debug @@ -806,12 +806,12 @@ fix_away_atoms(atom_selection_container_t asc) { int nat = 0; for (int i=0; ix > 9998.0) && - (asc.atom_selection[i]->y > 9998.0) && - (asc.atom_selection[i]->z > 9998.0)) { - asc.atom_selection[i]->x = 0.0; - asc.atom_selection[i]->y = 0.0; - asc.atom_selection[i]->z = 0.0; + if ((asc.atom_selection[i]->x() > 9998.0) && + (asc.atom_selection[i]->y() > 9998.0) && + (asc.atom_selection[i]->z() > 9998.0)) { + asc.atom_selection[i]->x() = 0.0; + asc.atom_selection[i]->y() = 0.0; + asc.atom_selection[i]->z() = 0.0; nat++; } } @@ -837,7 +837,7 @@ fix_wrapped_names(atom_selection_container_t asc) { // std::string ele(asc.atom_selection[i]->element); if (1) { - std::string atom_name(asc.atom_selection[i]->name); + std::string atom_name(asc.atom_selection[i]->GetAtomName()); if (atom_name[0] == '1' || atom_name[0] == '2' || atom_name[0] == '3' || @@ -864,7 +864,7 @@ fix_wrapped_names(atom_selection_container_t asc) { // << new_atom_name << ":\n"; if (uddHnd_old >= 0) asc.atom_selection[i]->PutUDData(uddHnd_old, - asc.atom_selection[i]->name); + asc.atom_selection[i]->GetAtomName()); if (uddHnd_new >= 0) asc.atom_selection[i]->PutUDData(uddHnd_new, new_atom_name.c_str()); @@ -876,7 +876,7 @@ fix_wrapped_names(atom_selection_container_t asc) { std::string new_atom_name = " H "; if (uddHnd_old >= 0) asc.atom_selection[i]->PutUDData(uddHnd_old, - asc.atom_selection[i]->name); + asc.atom_selection[i]->GetAtomName()); if (uddHnd_new >= 0) asc.atom_selection[i]->PutUDData(uddHnd_new, (char *) new_atom_name.c_str()); @@ -1100,9 +1100,9 @@ coot::get_molecule_diameter(const atom_selection_container_t &asc) { if (idx_1 != idx_2) { mmdb:: Atom *at_1 = asc.atom_selection[idx_1]; mmdb:: Atom *at_2 = asc.atom_selection[idx_2]; - float dx = at_2->x - at_1->x; - float dy = at_2->y - at_1->y; - float dz = at_2->z - at_1->z; + float dx = at_2->x() - at_1->x(); + float dy = at_2->y() - at_1->y(); + float dz = at_2->z() - at_1->z(); float dd = dx*dx + dy*dy + dz*dz; float d = std::sqrt(dd); s.add(d); diff --git a/coot-utils/atom-selection-container.hh b/coot-utils/atom-selection-container.hh index 4ed88d5187..ed03cb95be 100644 --- a/coot-utils/atom-selection-container.hh +++ b/coot-utils/atom-selection-container.hh @@ -142,7 +142,7 @@ public: for (int i=0; ix, at->y, at->z); + sum += clipper::Coord_orth(at->x(), at->y(), at->z()); count++; } } @@ -158,18 +158,18 @@ public: //! apply shift void apply_shift(float x_shift, float y_shift, float z_shift) { for (int i=0; ix += x_shift; - atom_selection[i]->y += y_shift; - atom_selection[i]->z += z_shift; + atom_selection[i]->x() += x_shift; + atom_selection[i]->y() += y_shift; + atom_selection[i]->z() += z_shift; } } //! apply shift void apply_shift(const clipper::Coord_orth &shift) { for (int i=0; ix += shift.x(); - atom_selection[i]->y += shift.y(); - atom_selection[i]->z += shift.z(); + atom_selection[i]->x() += shift.x(); + atom_selection[i]->y() += shift.y(); + atom_selection[i]->z() += shift.z(); } } diff --git a/coot-utils/bonded-pairs.cc b/coot-utils/bonded-pairs.cc index 883c9d0773..6945f6666d 100644 --- a/coot-utils/bonded-pairs.cc +++ b/coot-utils/bonded-pairs.cc @@ -180,7 +180,7 @@ coot::bonded_pair_t::delete_atom(mmdb::Residue *res, const std::string &atom_nam for (int iat=0; iatname); + std::string at_name(at->GetAtomName()); if (at_name == atom_name) { delete at; at = NULL; diff --git a/coot-utils/c-beta-deviations.cc b/coot-utils/c-beta-deviations.cc index 27b474c452..2c839804b7 100644 --- a/coot-utils/c-beta-deviations.cc +++ b/coot-utils/c-beta-deviations.cc @@ -80,7 +80,7 @@ coot::get_c_beta_deviations(mmdb::Residue *residue_p) { for (int iat=0; iatGetAtom(iat); std::string atom_name(at->GetAtomName()); - std::string alt_conf(at->altLoc); + std::string alt_conf(at->altLoc()); if (atom_name == " N ") alt_conf_map[alt_conf].atom_1 = at; if (atom_name == " CA ") alt_conf_map[alt_conf].atom_2 = at; if (atom_name == " C ") alt_conf_map[alt_conf].atom_3 = at; @@ -95,7 +95,7 @@ coot::get_c_beta_deviations(mmdb::Residue *residue_p) { for(it=alt_conf_map.begin(); it!=alt_conf_map.end(); it++) { const atom_quad &q = it->second; if (q.filled_p()) { - clipper::Coord_orth CB_real_pos(q.atom_4->x, q.atom_4->y, q.atom_4->z); // no coot-utils.h included + clipper::Coord_orth CB_real_pos(q.atom_4->x(), q.atom_4->y(), q.atom_4->z()); // no coot-utils.h included clipper::Coord_orth CB_ideal_pos = make_CB_ideal_pos(q, res_name); double dsqrd = (CB_ideal_pos-CB_real_pos).lengthsq(); double d = sqrt(dsqrd); @@ -124,9 +124,9 @@ coot::make_CB_ideal_pos(const coot::atom_quad &q, const std::string &res_name) { if (res_name == std::string("PRO")) is_PRO = true; - clipper::Coord_orth pt_1(q.atom_1->x, q.atom_1->y, q.atom_1->z); - clipper::Coord_orth pt_2(q.atom_2->x, q.atom_2->y, q.atom_2->z); - clipper::Coord_orth pt_3(q.atom_3->x, q.atom_3->y, q.atom_3->z); + clipper::Coord_orth pt_1(q.atom_1->x(), q.atom_1->y(), q.atom_1->z()); + clipper::Coord_orth pt_2(q.atom_2->x(), q.atom_2->y(), q.atom_2->z()); + clipper::Coord_orth pt_3(q.atom_3->x(), q.atom_3->y(), q.atom_3->z()); double l = 1.53; double a1 = clipper::Util::d2rad(111.0); diff --git a/coot-utils/cablam-markup.cc b/coot-utils/cablam-markup.cc index 07a0f7f82d..1b35008435 100644 --- a/coot-utils/cablam-markup.cc +++ b/coot-utils/cablam-markup.cc @@ -49,7 +49,7 @@ coot::cablam_markup_t::cablam_markup_t(mmdb::Atom *O_prev_at, if (! CA_this_at) return; if (! CA_next_at) return; score = -1; - residue = O_this_at->residue; + residue = O_this_at->GetResidue(); O_prev_pos = co(O_prev_at); O_this_pos = co(O_this_at); O_next_pos = co(O_next_at); @@ -127,7 +127,7 @@ coot::calc_cablam(mmdb::Chain *chain_p, mmdb::Residue *residue_this_p, int n_atoms_next_next = residue_next_next_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - std::string alt_loc(at->altLoc); + std::string alt_loc(at->altLoc()); if (alt_loc.empty()) { // no cablams for altconfed atoms std::string atom_name(at->GetAtomName()); if (atom_name == " O ") { @@ -142,7 +142,7 @@ coot::calc_cablam(mmdb::Chain *chain_p, mmdb::Residue *residue_this_p, } for (int iat=0; iatGetAtom(iat); - std::string alt_loc(at->altLoc); + std::string alt_loc(at->altLoc()); if (alt_loc.empty()) { // no cablams for altconfed atoms std::string atom_name(at->GetAtomName()); if (atom_name == " O ") { @@ -157,7 +157,7 @@ coot::calc_cablam(mmdb::Chain *chain_p, mmdb::Residue *residue_this_p, } for (int iat=0; iatGetAtom(iat); - std::string alt_loc(at->altLoc); + std::string alt_loc(at->altLoc()); if (alt_loc.empty()) { // no cablams for altconfed atoms std::string atom_name(at->GetAtomName()); if (atom_name == " O ") { @@ -172,7 +172,7 @@ coot::calc_cablam(mmdb::Chain *chain_p, mmdb::Residue *residue_this_p, } for (int iat=0; iatGetAtom(iat); - std::string alt_loc(at->altLoc); + std::string alt_loc(at->altLoc()); if (alt_loc.empty()) { // no cablams for altconfed atoms std::string atom_name(at->GetAtomName()); if (atom_name == " CA ") { diff --git a/coot-utils/cfc.cc b/coot-utils/cfc.cc index 46886b4eda..853584f18a 100644 --- a/coot-utils/cfc.cc +++ b/coot-utils/cfc.cc @@ -112,10 +112,10 @@ cfc::chemical_feature_clustering(const std::vector &mol_infos for (int iat=0; iatisTer()) { - clipper::Coord_orth posc(at->x, at->y, at->z); + clipper::Coord_orth posc(at->x(), at->y(), at->z()); double dd = (posc - pt_ref).lengthsq(); if (dd < dist_crit_sq) { - RDGeom::Point3D pos(at->x, at->y, at->z); + RDGeom::Point3D pos(at->x(), at->y(), at->z()); coot::residue_spec_t res_spec(residue_p); water_info_t wi(imol, res_spec, pos); waters.push_back(wi); @@ -615,9 +615,9 @@ cfc::chemical_feature_clustering(const std::vector &mol_infos for (int iat=0; iatisTer()) { - float delta_x = at->x - fi.pos.x; - float delta_y = at->y - fi.pos.y; - float delta_z = at->z - fi.pos.z; + float delta_x = at->x() - fi.pos.x; + float delta_y = at->y() - fi.pos.y; + float delta_z = at->z() - fi.pos.z; float dd = delta_x * delta_x + delta_y * delta_y + delta_z * delta_z; if (dd < dist_crit * dist_crit) return true; diff --git a/coot-utils/contact-info.cc b/coot-utils/contact-info.cc index d2a546c807..0aaf3164b1 100644 --- a/coot-utils/contact-info.cc +++ b/coot-utils/contact-info.cc @@ -44,11 +44,11 @@ coot::contact_info::contact_info(mmdb::PPAtom atom_selection, mmdb::Contact *con for (int i=0; ielement; - std::string ele_2 = at_2->element; - mmdb::realtype dx = at_1->x - at_2->x; - mmdb::realtype dy = at_1->y - at_2->y; - mmdb::realtype dz = at_1->z - at_2->z; + std::string ele_1 = at_1->GetElementName(); + std::string ele_2 = at_2->GetElementName(); + mmdb::realtype dx = at_1->x() - at_2->x(); + mmdb::realtype dy = at_1->y() - at_2->y(); + mmdb::realtype dz = at_1->z() - at_2->z(); mmdb::realtype dist_2 = dx*dx + dy*dy + dz*dz; mmdb::realtype dist = sqrt(dist_2); mmdb::realtype r1 = get_radius(ele_1); @@ -77,7 +77,7 @@ coot::contact_info::contact_info(const atom_selection_container_t &asc, if (r.first) { std::map name_map; for (int i=0; iname); + std::string atom_name(asc.atom_selection[i]->GetAtomName()); name_map[atom_name] = map_index_t(i); } @@ -112,8 +112,8 @@ coot::contact_info::contact_info(const atom_selection_container_t &asc, if (r.first) { std::map name_map; for (int i=0; iname); - std::string atom_alt_conf(asc.atom_selection[i]->altLoc); + std::string atom_name(asc.atom_selection[i]->GetAtomName()); + std::string atom_alt_conf(asc.atom_selection[i]->altLoc()); if (atom_alt_conf.empty() || atom_alt_conf == alt_conf) { name_map[atom_name] = map_index_t(i); } @@ -148,7 +148,7 @@ coot::contact_info::contact_info(const atom_selection_container_t &asc, int imol // fill residues and atoms_in_residue for (int i=0; iresidue; + mmdb::Residue *r = asc.atom_selection[i]->GetResidue(); if (std::find(residues.begin(), residues.end(), r) == residues.end()) residues.push_back(r); atoms_in_residue[r].push_back(i); @@ -198,10 +198,10 @@ coot::contact_info::contact_info(const atom_selection_container_t &asc, int imol if (order_switch == false) { for (unsigned int iat_1=0; iat_1name; + std::string atom_name_1 = asc.atom_selection[iat_1]->GetAtomName(); if (link_bond_atom_name_1 == atom_name_1) { for (unsigned int iat_2=0; iat_2name; + std::string atom_name_2 = asc.atom_selection[iat_2]->GetAtomName(); if (link_bond_atom_name_2 == atom_name_2) { contacts_pair p(iat_1, iat_2); contacts.push_back(p); @@ -213,10 +213,10 @@ coot::contact_info::contact_info(const atom_selection_container_t &asc, int imol // order switch for (unsigned int iat_1=0; iat_1name; + std::string atom_name_1 = asc.atom_selection[iat_1]->GetAtomName(); if (link_bond_atom_name_2 == atom_name_1) { for (unsigned int iat_2=0; iat_2name; + std::string atom_name_2 = asc.atom_selection[iat_2]->GetAtomName(); if (link_bond_atom_name_1 == atom_name_2) { contacts_pair p(iat_1, iat_2); contacts.push_back(p); @@ -242,15 +242,15 @@ coot::contact_info::contacts_from_monomer_restraints(const atom_selection_contai // for (int iat=0; iatname; + std::string atom_name_1 = at_1->GetAtomName(); for (int jat=0; jatresidue == at_2->residue) { - std::string atom_name_2 = at_2->name; + if (at_1->GetResidue() == at_2->GetResidue()) { + std::string atom_name_2 = at_2->GetAtomName(); // was there a bond between them? const std::vector &bond_restraints = - res_restraints[at_1->residue].bond_restraint; + res_restraints[at_1->GetResidue()].bond_restraint; for (unsigned int ibond=0; ibondresidue; + mmdb::Residue *r = asc.atom_selection[i]->GetResidue(); if (std::find(residues.begin(), residues.end(), r) == residues.end()) residues.push_back(r); atoms_in_residue[r].push_back(i); @@ -344,8 +344,8 @@ coot::contact_info::contact_info(mmdb::Manager *mol, int imol, // now the bond between monomers (middle atoms must be in different residues). for (unsigned int itor=0; itorresidue; - mmdb::Residue *r2 = link_torsions[itor].atom_3->residue; + mmdb::Residue *r1 = link_torsions[itor].atom_2->GetResidue(); + mmdb::Residue *r2 = link_torsions[itor].atom_3->GetResidue(); if (r1 != r2) { for (int i=0; iname; + std::string atom_name = asc.atom_selection[i]->GetAtomName(); if (atom_name == "SE ") SE_index = i; if (atom_name == " CE ") CE_index = i; if (atom_name == " CG ") CG_index = i; diff --git a/coot-utils/contacts-by-bricks.cc b/coot-utils/contacts-by-bricks.cc index 50e2a68818..cd18de7e85 100644 --- a/coot-utils/contacts-by-bricks.cc +++ b/coot-utils/contacts-by-bricks.cc @@ -75,9 +75,9 @@ coot::contacts_by_bricks::fill_the_bricks() { mmdb::Atom *at = atoms[i]; int idx_3d[3]; // beware when copying this later - when atoms move? - idx_3d[0] = static_cast ((at->x - lower_left[0]) * inv_brick_size); - idx_3d[1] = static_cast ((at->y - lower_left[1]) * inv_brick_size); - idx_3d[2] = static_cast ((at->z - lower_left[2]) * inv_brick_size); + idx_3d[0] = static_cast ((at->x() - lower_left[0]) * inv_brick_size); + idx_3d[1] = static_cast ((at->y() - lower_left[1]) * inv_brick_size); + idx_3d[2] = static_cast ((at->z() - lower_left[2]) * inv_brick_size); unsigned int idx_1d = idx_3d_to_idx_1d(idx_3d); // atoms that fly over the edge don't have NBCs :-) unsigned int n_bricks = atoms_in_bricks.size(); @@ -135,7 +135,7 @@ coot::contacts_by_bricks::set_lower_left_and_range(mmdb::PAtom *atoms_in, int n_ for(unsigned int i=0; ix; pos[1] = atom->y; pos[2] = atom->z; + pos[0] = atom->x(); pos[1] = atom->y(); pos[2] = atom->z(); for (int j=0; j<3; j++) if (pos[j] < lower_left[j]) lower_left[j] = pos[j]; @@ -148,7 +148,7 @@ coot::contacts_by_bricks::set_lower_left_and_range(mmdb::PAtom *atoms_in, int n_ for(unsigned int i=0; ix; pos[1] = atom->y; pos[2] = atom->z; + pos[0] = atom->x(); pos[1] = atom->y(); pos[2] = atom->z(); for (int j=0; j<3; j++) { if (false) std::cout @@ -208,11 +208,11 @@ coot::contacts_by_bricks::find_the_contacts_in_bricks(std::vectorresidue == at_1->residue) + if (at_2->GetResidue() == at_1->GetResidue()) continue; - float d_x(at_1->x - at_2->x); - float d_y(at_1->y - at_2->y); - float d_z(at_1->z - at_2->z); + float d_x(at_1->x() - at_2->x()); + float d_y(at_1->y() - at_2->y()); + float d_z(at_1->z() - at_2->z()); float dd = d_x * d_x + d_y * d_y + d_z * d_z; if (dd < dist_max_sqrd) { vec->at(*it_base).insert(*it_neighb); @@ -324,11 +324,11 @@ coot::contacts_by_bricks::find_the_contacts_between_bricks_multi_thread_workpack for (it_neighb=brick_neighb.begin(); it_neighb!=brick_neighb.end(); it_neighb++) { mmdb::Atom *at_2 = atoms[*it_neighb]; if (only_between_different_residues_flag) - if (at_2->residue == at_1->residue) + if (at_2->GetResidue() == at_1->GetResidue()) continue; - float d_x(at_1->x - at_2->x); - float d_y(at_1->y - at_2->y); - float d_z(at_1->z - at_2->z); + float d_x(at_1->x() - at_2->x()); + float d_y(at_1->y() - at_2->y()); + float d_z(at_1->z() - at_2->z()); float dd(d_x * d_x + d_y * d_y + d_z * d_z); // std::cout << "MP " << *it_base << " " << *it_neighb << " sqrt(dd) " << sqrt(dd) << std::endl; if (dd < dist_max_sqrd) { @@ -390,11 +390,11 @@ coot::contacts_by_bricks::find_the_contacts_between_bricks_simple(std::vectorresidue == at_1->residue) + if (at_2->GetResidue() == at_1->GetResidue()) continue; - float d_x(at_1->x - at_2->x); - float d_y(at_1->y - at_2->y); - float d_z(at_1->z - at_2->z); + float d_x(at_1->x() - at_2->x()); + float d_y(at_1->y() - at_2->y()); + float d_z(at_1->z() - at_2->z()); float dd(d_x * d_x + d_y * d_y + d_z * d_z); if (dd < dist_max_sqrd) { vec->at(*it_base).insert(*it_neighb); diff --git a/coot-utils/coot-coord-extras.cc b/coot-utils/coot-coord-extras.cc index b521b56241..9e933f2e76 100644 --- a/coot-utils/coot-coord-extras.cc +++ b/coot-utils/coot-coord-extras.cc @@ -60,7 +60,7 @@ coot::util::check_dictionary_for_residues(mmdb::PResidue *SelResidues, int nSelR int fail = 0; // not fail initially. for (int ires=0; iresname); + std::string resname(SelResidues[ires]->GetResName()); status = geom_p->have_dictionary_for_residue_type(resname, imol_enc, read_number); // This bit is redundant now that try_dynamic_add has been added // to have_dictionary_for_residue_type(): @@ -104,7 +104,7 @@ coot::GetResidue(const minimol::residue &res_in) { // reset new_alt_loc for (unsigned int ic=0; icaltLoc, mat.altLoc.c_str(), new_length); + strncpy(at->altLoc(), mat.altLoc.c_str(), new_length); res->AddAtom(at); } @@ -132,7 +132,7 @@ coot::util::get_contact_indices_from_restraints(mmdb::Residue *residue, int nResidueAtoms = residue->GetNumberOfAtoms(); std::vector > contact_indices(nResidueAtoms); - std::string restype(residue->name); + std::string restype(residue->GetResName()); int n_monomers = geom_p->size(); @@ -142,7 +142,7 @@ coot::util::get_contact_indices_from_restraints(mmdb::Residue *residue, for (int iat=0; iatGetAtom(iat); if (! atom_p->isTer()) { - std::string atom_ele(atom_p->element); + std::string atom_ele(atom_p->GetElementName()); if (atom_ele == " D") { has_deuterium_atoms = true; break; @@ -600,7 +600,7 @@ coot::match_torsions::get_torsion(mmdb::Residue *res, const coot::atom_name_quad if (atoms[0] && atoms[1] && atoms[2] && atoms[3]) { clipper::Coord_orth pts[4]; for (unsigned int i=0; i<4; i++) - pts[i] = clipper::Coord_orth(atoms[i]->x, atoms[i]->y, atoms[i]->z); + pts[i] = clipper::Coord_orth(atoms[i]->x(), atoms[i]->y(), atoms[i]->z()); tors = clipper::Coord_orth::torsion(pts[0], pts[1], pts[2], pts[3]); // radians status = 1; } @@ -674,11 +674,11 @@ coot::match_torsions::apply_torsion_by_contacts(const coot::atom_name_quad &movi if (at) { if (0) std::cout << "transfering coords was " - << at->z << " " << at->y << " " << at->z << " to " + << at->z() << " " << at->y() << " " << at->z() << " to " << ligand_residue.atoms[iat] << std::endl; - at->x = wiggled_ligand_residue.atoms[iat].pos.x(); - at->y = wiggled_ligand_residue.atoms[iat].pos.y(); - at->z = wiggled_ligand_residue.atoms[iat].pos.z(); + at->x() = wiggled_ligand_residue.atoms[iat].pos.x(); + at->y() = wiggled_ligand_residue.atoms[iat].pos.y(); + at->z() = wiggled_ligand_residue.atoms[iat].pos.z(); n_transfered++; } } @@ -728,13 +728,13 @@ coot::torsionable_bonds_monomer_internal(mmdb::Residue *residue_p, std::string tr_atom_name_3 = tors_restraints[itor].atom_id_3_4c(); for (int iat1=0; iat1residue; - std::string atom_name_1 = atom_selection[iat1]->name; + mmdb::Residue *res_1 = atom_selection[iat1]->GetResidue(); + std::string atom_name_1 = atom_selection[iat1]->GetAtomName(); for (int iat2=0; iat2residue; + mmdb::Residue *res_2 = atom_selection[iat2]->GetResidue(); if (res_1 == res_2) { - std::string atom_name_2 = atom_selection[iat2]->name; + std::string atom_name_2 = atom_selection[iat2]->GetAtomName(); if (atom_name_1 == tr_atom_name_2) { if (atom_name_2 == tr_atom_name_3) { @@ -792,8 +792,8 @@ coot::torsionable_bonds_monomer_internal_quads(mmdb::Residue *residue_p, (! is_pyranose)) { for (unsigned int ialt=0; ialtname; - std::string alt_conf = atom_selection[iat]->altLoc; + std::string atom_name = atom_selection[iat]->GetAtomName(); + std::string alt_conf = atom_selection[iat]->altLoc(); if (alt_conf == residue_alt_confs[ialt]) { for (unsigned int jtor=1; jtor<5; jtor++) { if (atom_name == tor_atom_name[jtor]) @@ -829,7 +829,7 @@ coot::linkrs_in_atom_selection(mmdb::Manager *mol, mmdb::PPAtom atom_selection, // normal case std::vector residues; for (int i=0; iresidue; + mmdb::Residue *r = atom_selection[i]->GetResidue(); if (std::find(residues.begin(), residues.end(), r) == residues.end()) residues.push_back(r); } @@ -949,7 +949,7 @@ coot::util::CO_orientations(mmdb::Manager *mol) { for (int iat=0; iatGetAtom(iat); std::string atom_name(at->GetAtomName()); - std::string alt_conf(at->altLoc); + std::string alt_conf(at->altLoc()); if (alt_conf == "") { if (atom_name == " C ") prev_C = at; if (atom_name == " O ") prev_O = at; @@ -960,7 +960,7 @@ coot::util::CO_orientations(mmdb::Manager *mol) { for (int iat=0; iatGetAtom(iat); std::string atom_name(at->GetAtomName()); - std::string alt_conf(at->altLoc); + std::string alt_conf(at->altLoc()); if (alt_conf == "") { if (atom_name == " C ") this_C = at; if (atom_name == " O ") this_O = at; @@ -971,7 +971,7 @@ coot::util::CO_orientations(mmdb::Manager *mol) { for (int iat=0; iatGetAtom(iat); std::string atom_name(at->GetAtomName()); - std::string alt_conf(at->altLoc); + std::string alt_conf(at->altLoc()); if (alt_conf == "") { if (atom_name == " C ") next_C = at; if (atom_name == " O ") next_O = at; @@ -1261,7 +1261,7 @@ coot::util::missing_atoms(mmdb::Manager *mol, int n_atoms = residue_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - std::string atom_name(at->name); + std::string atom_name(at->GetAtomName()); // check against each atom in the dictionary: for (unsigned int idictat=0; idictat alt_confs; std::string ac[4]; - ac[0] = ca_first->altLoc; - ac[1] = c_first->altLoc; - ac[2] = n_next->altLoc; - ac[3] = ca_next->altLoc; + ac[0] = ca_first->altLoc(); + ac[1] = c_first->altLoc(); + ac[2] = n_next->altLoc(); + ac[3] = ca_next->altLoc(); for (int i=0; i<4; i++) if (!ac[i].empty()) alt_confs.insert(ac[i]); @@ -1403,10 +1403,10 @@ coot::cis_peptide_quads_from_coords(mmdb::Manager *mol, } } if (! is_ter) { - clipper::Coord_orth caf(ca_first->x, ca_first->y, ca_first->z); - clipper::Coord_orth cf( c_first->x, c_first->y, c_first->z); - clipper::Coord_orth can( ca_next->x, ca_next->y, ca_next->z); - clipper::Coord_orth nn( n_next->x, n_next->y, n_next->z); + clipper::Coord_orth caf(ca_first->x(), ca_first->y(), ca_first->z()); + clipper::Coord_orth cf( c_first->x(), c_first->y(), c_first->z()); + clipper::Coord_orth can( ca_next->x(), ca_next->y(), ca_next->z()); + clipper::Coord_orth nn( n_next->x(), n_next->y(), n_next->z()); double tors = clipper::Coord_orth::torsion(caf, cf, nn, can); double torsion = clipper::Util::rad2d(tors); @@ -1727,18 +1727,18 @@ coot::util::get_dictionary_conformers(const dictionary_residue_restraints_t &res residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatelement); + std::string ele_1(at_1->GetElementName()); if (ele_1 == " H") continue; if (! at_1->isTer()) { for (int jat=0; jatelement); + std::string ele_2(at_2->GetElementName()); if (ele_2 == " H") continue; if (! at_2->isTer()) { - float dx = at_2->x - at_1->x; - float dy = at_2->y - at_1->y; - float dz = at_2->z - at_1->z; + float dx = at_2->x() - at_1->x(); + float dy = at_2->y() - at_1->y(); + float dz = at_2->z() - at_1->z(); if (fabsf(dx) < dist_crit) { if (fabsf(dy) < dist_crit) { if (fabsf(dz) < dist_crit) { @@ -1847,7 +1847,7 @@ coot::util::get_dictionary_conformers(const dictionary_residue_restraints_t &res if (! at_from->isTer()) { std::string atom_name_from = at_from->GetAtomName(); - std::string alt_conf_from = at_from->altLoc; + std::string alt_conf_from = at_from->altLoc(); mmdb::Atom **to_residue_atoms = 0; int n_to_residue_atoms = 0; @@ -1857,26 +1857,26 @@ coot::util::get_dictionary_conformers(const dictionary_residue_restraints_t &res if (! at_to->isTer()) { std::string atom_name_to = at_to->GetAtomName(); - std::string alt_conf_to = at_to->altLoc; + std::string alt_conf_to = at_to->altLoc(); if (atom_name_from == atom_name_to) { if (alt_conf_from == alt_conf_to) { if (debug) { - std::vector was = {at_to->x, at_to->y, at_to->z}; + std::vector was = {at_to->x(), at_to->y(), at_to->z()}; std::cout << "transfered " << coot::atom_spec_t(at_to) << " " << std::setw(8) << was[0] << " " << std::setw(8) << was[1] << " " << std::setw(8) << was[2] << " now " - << std::setw(8) << at_from->x << " " - << std::setw(8) << at_from->y << " " - << std::setw(8) << at_from->z << " " + << std::setw(8) << at_from->x() << " " + << std::setw(8) << at_from->y() << " " + << std::setw(8) << at_from->z() << " " << std::endl; } - at_to->x = at_from->x; - at_to->y = at_from->y; - at_to->z = at_from->z; + at_to->x() = at_from->x(); + at_to->y() = at_from->y(); + at_to->z() = at_from->z(); break; } @@ -1987,7 +1987,7 @@ coot::util::get_dictionary_conformers(const dictionary_residue_restraints_t &res mmdb::Atom *at = residue_atoms[iat]; if (! at->isTer()) { std::cout << " " << lab << " " << iat << " " << coot::atom_spec_t(at) << " " - << at->x << " " << at->y << " " << at->z << std::endl; + << at->x() << " " << at->y() << " " << at->z() << std::endl; } } }; @@ -2135,12 +2135,12 @@ coot::util::mutate_by_overlap(mmdb::Residue *residue_p, mmdb::Manager *mol, if (atom_name != " O " || move_O_atom) { - at_mutable->x = at->x; - at_mutable->y = at->y; - at_mutable->z = at->z; + at_mutable->x() = at->x(); + at_mutable->y() = at->y(); + at_mutable->z() = at->z(); if (false) std::cout << "moved atom " << coot::atom_spec_t(at_mutable) - << " to " << at->x << " " << at->y << " " << at->z << std::endl; + << " to " << at->x() << " " << at->y() << " " << at->z() << std::endl; } } } @@ -2158,7 +2158,7 @@ coot::util::mutate_by_overlap(mmdb::Residue *residue_p, mmdb::Manager *mol, std::string at_name = at->GetAtomName(); if (atom_name != " OXT") { // extra atom in an amino acid if (! (atom_name != " OP3" && is_nucleotide)) { // extra atom in a nucleic acid - std::string ele = at->element; + std::string ele = at->GetElementName(); if (ele == " H") continue; at_copy->Copy(at); res_mutable->AddAtom(at_copy); diff --git a/coot-utils/coot-coord-lsq.cc b/coot-utils/coot-coord-lsq.cc index adbdaf86d7..ce8a1c40d7 100644 --- a/coot-utils/coot-coord-lsq.cc +++ b/coot-utils/coot-coord-lsq.cc @@ -308,8 +308,8 @@ coot::util::get_matching_indices(mmdb::Manager *mol1, << std::endl; } if (at1 && at2) { - v1.push_back(clipper::Coord_orth(at1->x, at1->y, at1->z)); - v2.push_back(clipper::Coord_orth(at2->x, at2->y, at2->z)); + v1.push_back(clipper::Coord_orth(at1->x(), at1->y(), at1->z())); + v2.push_back(clipper::Coord_orth(at2->x(), at2->y(), at2->z())); } } @@ -340,8 +340,8 @@ coot::util::get_matching_indices(mmdb::Manager *mol1, std::cout << "Found match " << atom_spec_t(at1) << " to " << atom_spec_t(at2) << std::endl; - v1.push_back(clipper::Coord_orth(at1->x, at1->y, at1->z)); - v2.push_back(clipper::Coord_orth(at2->x, at2->y, at2->z)); + v1.push_back(clipper::Coord_orth(at1->x(), at1->y(), at1->z())); + v2.push_back(clipper::Coord_orth(at2->x(), at2->y(), at2->z())); } } } @@ -360,8 +360,8 @@ coot::util::get_matching_indices(mmdb::Manager *mol1, if (at2) { if (! at1->isTer()) { if (! at2->isTer()) { - v1.push_back(clipper::Coord_orth(at1->x, at1->y, at1->z)); - v2.push_back(clipper::Coord_orth(at2->x, at2->y, at2->z)); + v1.push_back(clipper::Coord_orth(at1->x(), at1->y(), at1->z())); + v2.push_back(clipper::Coord_orth(at2->x(), at2->y(), at2->z())); } } } @@ -383,17 +383,17 @@ coot::util::get_matching_indices(mmdb::Manager *mol1, SelResidue_2[0]->GetAtomTable(residue_atoms2, n_residue_atoms2); for (int iat=0; iatname); - std::string at1_altconf(at1->altLoc); + std::string at1_name(at1->GetAtomName()); + std::string at1_altconf(at1->altLoc()); for (int jat=0; jatname); - std::string at2_altconf(at2->altLoc); + std::string at2_name(at2->GetAtomName()); + std::string at2_altconf(at2->altLoc()); if (at1_name == at2_name) { if (at1_altconf == at2_altconf) { - v1.push_back(clipper::Coord_orth(at1->x, at1->y, at1->z)); - v2.push_back(clipper::Coord_orth(at2->x, at2->y, at2->z)); + v1.push_back(clipper::Coord_orth(at1->x(), at1->y(), at1->z())); + v2.push_back(clipper::Coord_orth(at2->x(), at2->y(), at2->z())); break; } } @@ -415,18 +415,18 @@ coot::util::get_matching_indices(mmdb::Manager *mol1, // << std::endl; for (int iat=0; iatname); - std::string at1_altconf(at1->altLoc); + std::string at1_name(at1->GetAtomName()); + std::string at1_altconf(at1->altLoc()); if (at1_name == match.reference_atom_name) { if (at1_altconf == match.reference_alt_conf) { for (int jat=0; jatname); - std::string at2_altconf(at2->altLoc); + std::string at2_name(at2->GetAtomName()); + std::string at2_altconf(at2->altLoc()); if (at2_name == match.matcher_atom_name) { if (at2_altconf == match.matcher_alt_conf) { - v1.push_back(clipper::Coord_orth(at1->x, at1->y, at1->z)); - v2.push_back(clipper::Coord_orth(at2->x, at2->y, at2->z)); + v1.push_back(clipper::Coord_orth(at1->x(), at1->y(), at1->z())); + v2.push_back(clipper::Coord_orth(at2->x(), at2->y(), at2->z())); } } } diff --git a/coot-utils/coot-coord-utils-glyco.cc b/coot-utils/coot-coord-utils-glyco.cc index 553f61b13b..ee65d1ab19 100644 --- a/coot-utils/coot-coord-utils-glyco.cc +++ b/coot-utils/coot-coord-utils-glyco.cc @@ -302,16 +302,16 @@ coot::beam_in_linked_residue::get_residue() const { current_torsion = quad.torsion(); double diff = clipper::Util::d2rad(template_torsion - current_torsion); clipper::Coord_orth base; - base = clipper::Coord_orth(at_C5->x, at_C5->y, at_C5->z); - origin_shift = clipper::Coord_orth(at_C6->x, at_C6->y, at_C6->z); - position = clipper::Coord_orth(at_O6->x, at_O6->y, at_O6->z); + base = clipper::Coord_orth(at_C5->x(), at_C5->y(), at_C5->z()); + origin_shift = clipper::Coord_orth(at_C6->x(), at_C6->y(), at_C6->z()); + position = clipper::Coord_orth(at_O6->x(), at_O6->y(), at_O6->z()); direction = origin_shift - base; clipper::Coord_orth new_pos = coot::util::rotate_around_vector(direction, position, origin_shift, diff); - at_O6->x = new_pos.x(); - at_O6->y = new_pos.y(); - at_O6->z = new_pos.z(); + at_O6->x() = new_pos.x(); + at_O6->y() = new_pos.y(); + at_O6->z() = new_pos.z(); } } catch (const std::runtime_error &rte) { @@ -325,26 +325,26 @@ coot::beam_in_linked_residue::get_residue() const { if (r) { // now rotate r and O6 back to current_torsion if (at_O6) { - position = clipper::Coord_orth(at_O6->x, at_O6->y, at_O6->z); + position = clipper::Coord_orth(at_O6->x(), at_O6->y(), at_O6->z()); double diff = clipper::Util::d2rad(template_torsion - current_torsion); clipper::Coord_orth new_pos = coot::util::rotate_around_vector(direction, position, origin_shift, -diff); - at_O6->x = new_pos.x(); - at_O6->y = new_pos.y(); - at_O6->z = new_pos.z(); + at_O6->x() = new_pos.x(); + at_O6->y() = new_pos.y(); + at_O6->z() = new_pos.z(); mmdb::PPAtom residue_atoms = 0; int n_residue_atoms; r->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; ix, at->y, at->z); + clipper::Coord_orth p(at->x(), at->y(), at->z()); clipper::Coord_orth n = coot::util::rotate_around_vector(direction, p, origin_shift, -diff); - at->x = n.x(); - at->y = n.y(); - at->z = n.z(); + at->x() = n.x(); + at->y() = n.y(); + at->z() = n.z(); } } } @@ -502,8 +502,8 @@ coot::beam_in_linked_residue::lsq_fit(mmdb::Residue *ref_res, std::vector co_1(n); std::vector co_2(n); for (unsigned int iat=0; iatx, va_1[iat]->y, va_1[iat]->z); - co_2[iat] = clipper::Coord_orth(va_2[iat]->x, va_2[iat]->y, va_2[iat]->z); + co_1[iat] = clipper::Coord_orth(va_1[iat]->x(), va_1[iat]->y(), va_1[iat]->z()); + co_2[iat] = clipper::Coord_orth(va_2[iat]->x(), va_2[iat]->y(), va_2[iat]->z()); } clipper::RTop_orth rtop(co_1, co_2); coot::util::transform_atoms(mov_res, rtop); @@ -525,7 +525,7 @@ coot::beam_in_linked_residue::delete_atom(mmdb::Residue *res, const std::string for (int iat=0; iatname); + std::string at_name(at->GetAtomName()); if (at_name == atom_name) { // std::cout << "..... delete_atom() deleting atom with index " << iat // << " and name \"" << at_name << "\"" << std::endl; @@ -672,7 +672,7 @@ coot::glyco_tree_t::glyco_tree_t(mmdb::Residue *residue_p, mmdb::Manager *mol, std::vector considered; // std::vector linked_residues; - if (is_pyranose(residue_p) || std::string(residue_p->name) == "ASN") + if (is_pyranose(residue_p) || std::string(residue_p->GetResName()) == "ASN") q.push(residue_p); while (q.size()) { @@ -680,7 +680,7 @@ coot::glyco_tree_t::glyco_tree_t(mmdb::Residue *residue_p, mmdb::Manager *mol, q.pop(); std::vector residues = residues_near_residue(test_residue, mol, dist_crit); for (unsigned int ires=0; iresname) == "ASN") { + if (is_pyranose(residues[ires]) || std::string(residues[ires]->GetResName()) == "ASN") { if (std::find(considered.begin(), considered.end(), residues[ires]) == considered.end()) { q.push(residues[ires]); linked_residues.push_back(residues[ires]); @@ -698,7 +698,7 @@ coot::glyco_tree_t::glyco_tree_t(mmdb::Residue *residue_p, mmdb::Manager *mol, std::cout << "INFO:: " << linked_residues.size() << " glycan/ASN residues" << std::endl; for (unsigned int ires=0; iresname); + std::string residue_name(linked_residues[ires]->GetResName()); // std::cout << " " << ires << " " << residue_name << std::endl; if (residue_name == "ASN") { if (false) @@ -1041,7 +1041,7 @@ coot::glyco_tree_t::residues(const coot::residue_spec_t &containing_res_spec) co std::vector v; for (unsigned int ires=0; iresname); + std::string residue_name(this_res->GetResName()); if (false) std::cout << "residues(): considering residue " << coot::residue_spec_t(this_res) << " " << residue_name << std::endl; @@ -1066,7 +1066,7 @@ void coot::glyco_tree_t::internal_distances(double dist_lim, const std::string &file_name) const { for (unsigned int ires=0; iresname); + std::string residue_name(linked_residues[ires]->GetResName()); if (residue_name == "ASN") { tree tr = find_ASN_rooted_tree(linked_residues[ires], linked_residues); if (tr.size() < 2) { @@ -1152,14 +1152,14 @@ coot::glyco_tree_t::output_internal_distances(mmdb::Residue *residue_p, for (int iat=0; iatisTer()) { - std::string ele_i(at_i->element); + std::string ele_i(at_i->GetElementName()); if (include_hydrogen_atoms || (ele_i != " H")) { // PDBv3 FIXME and below clipper::Coord_orth pos_atom_i = co(at_i); // don't do forwards and backwards distances for (int jat=iat; jatelement); + std::string ele_j(at_j->GetElementName()); if (include_hydrogen_atoms || (ele_j != " H")) { if (! at_j->isTer()) { clipper::Coord_orth pos_atom_j = co(at_j); @@ -1182,7 +1182,7 @@ coot::glyco_tree_t::output_internal_distances(mmdb::Residue *residue_p, for (int iat=0; iatisTer()) { - std::string ele_i(at_i->element); + std::string ele_i(at_i->GetElementName()); if (include_hydrogen_atoms || (ele_i != " H")) { // PDBv3 FIXME clipper::Coord_orth pos_atom_i = co(at_i); mmdb::Atom **parent_residue_atoms = 0; @@ -1192,7 +1192,7 @@ coot::glyco_tree_t::output_internal_distances(mmdb::Residue *residue_p, mmdb::Atom *at_j = parent_residue_atoms[jat]; clipper::Coord_orth pos_atom_j = co(at_j); if (! at_j->isTer()) { - std::string ele_j(at_j->element); + std::string ele_j(at_j->GetElementName()); if (include_hydrogen_atoms || (ele_j != " H")) { // PDBv3 FIXME double d = clipper::Coord_orth::length(pos_atom_i, pos_atom_j); if (! at_j->isTer()) { diff --git a/coot-utils/coot-coord-utils-nucleotides.cc b/coot-utils/coot-coord-utils-nucleotides.cc index 55ada4f262..d51d98a946 100644 --- a/coot-utils/coot-coord-utils-nucleotides.cc +++ b/coot-utils/coot-coord-utils-nucleotides.cc @@ -73,11 +73,11 @@ coot::pucker_analysis_info_t::pucker_analysis_info_t(mmdb::Residue *res_p, for (int i=0; iisTer()) { - std::string atm_name(atm->name); - std::string alt_name(atm->altLoc); + std::string atm_name(atm->GetAtomName()); + std::string alt_name(atm->altLoc()); if (altconf == alt_name) { if (atm_name == " P ") { // PDBv3 FIXME - clipper::Coord_orth p(atm->x, atm->y, atm->z); + clipper::Coord_orth p(atm->x(), atm->y(), atm->z()); markup_info.phosphorus_position = p; markup_info.projected_point = lsq_plane.value().projected_point(p); } @@ -87,8 +87,8 @@ coot::pucker_analysis_info_t::pucker_analysis_info_t(mmdb::Residue *res_p, // find the ribose atoms res_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; iname); - std::string alt_name(residue_atoms[i]->altLoc); + std::string atm_name(residue_atoms[i]->GetAtomName()); + std::string alt_name(residue_atoms[i]->altLoc()); if (altconf == alt_name) { if (atm_name == " C1*") ribose_atoms[0] = residue_atoms[i]; if (atm_name == " C1'") ribose_atoms[0] = residue_atoms[i]; @@ -107,9 +107,9 @@ coot::pucker_analysis_info_t::pucker_analysis_info_t(mmdb::Residue *res_p, throw std::runtime_error(mess); } else { for (int i_oop_atom=0; i_oop_atom<5; i_oop_atom++) { - clipper::Coord_orth c(ribose_atoms[i_oop_atom]->x, - ribose_atoms[i_oop_atom]->y, - ribose_atoms[i_oop_atom]->z); + clipper::Coord_orth c(ribose_atoms[i_oop_atom]->x(), + ribose_atoms[i_oop_atom]->y(), + ribose_atoms[i_oop_atom]->z()); ribose_atoms_coords.push_back(c); } @@ -123,16 +123,16 @@ coot::pucker_analysis_info_t::pucker_analysis_info_t(mmdb::Residue *res_p, std::vector plane_atom_coords; for (int i=0; i<5; i++) { if (i != i_oop_atom) { - clipper::Coord_orth c(ribose_atoms[i]->x, ribose_atoms[i]->y, ribose_atoms[i]->z); + clipper::Coord_orth c(ribose_atoms[i]->x(), ribose_atoms[i]->y(), ribose_atoms[i]->z()); plane_atom.push_back(ribose_atoms[i]); plane_atom_coords.push_back(c); } } // plane atom is now filled with 4 atoms from which the plane // should be calculated. - clipper::Coord_orth pt(ribose_atoms[i_oop_atom]->x, - ribose_atoms[i_oop_atom]->y, - ribose_atoms[i_oop_atom]->z); + clipper::Coord_orth pt(ribose_atoms[i_oop_atom]->x(), + ribose_atoms[i_oop_atom]->y(), + ribose_atoms[i_oop_atom]->z()); // lsq_plane_deviation returns pair(out-of-plane-dist, rms_deviation_plane); std::pair dev = coot::lsq_plane_deviation(plane_atom_coords, pt); @@ -254,8 +254,8 @@ coot::pucker_analysis_info_t::assign_base_atom_coords(mmdb::Residue *residue_p) // Assign N1_or_9 and C1_prime for (int i=0; iname); - std::string alt_name(residue_atoms[i]->altLoc); + std::string atom_name(residue_atoms[i]->GetAtomName()); + std::string alt_name(residue_atoms[i]->altLoc()); if (alt_name == altconf) { if (atom_name == " N1 ") N1_or_9 = residue_atoms[i]; @@ -294,13 +294,13 @@ coot::pucker_analysis_info_t::assign_base_atom_coords(mmdb::Residue *residue_p) if (base_names.size() > 0) { for (int i=0; iname); - std::string alt_name(residue_atoms[i]->altLoc); + std::string atm_name(residue_atoms[i]->GetAtomName()); + std::string alt_name(residue_atoms[i]->altLoc()); for (unsigned int j=0; jx, - residue_atoms[i]->y, - residue_atoms[i]->z)); + base_atoms_coords.push_back(clipper::Coord_orth(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z())); } } } @@ -377,13 +377,13 @@ coot::pucker_analysis_info_t::phosphate_distance_to_base_plane(mmdb::Residue *fo following_res->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; iname); - std::string alt_name(residue_atoms[i]->altLoc); + std::string atm_name(residue_atoms[i]->GetAtomName()); + std::string alt_name(residue_atoms[i]->altLoc()); if (atm_name == " P ") { if (altconf == alt_name) { - clipper::Coord_orth pt(residue_atoms[i]->x, - residue_atoms[i]->y, - residue_atoms[i]->z); + clipper::Coord_orth pt(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z()); // lsq_plane_deviation returns pair(out-of-plane-dist, rms_deviation_plane); if (base_atoms_coords.size() < 4) { @@ -453,15 +453,15 @@ coot::pucker_analysis_info_t::phosphate_distance(mmdb::Residue *following_res) { bool found = 0; following_res->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; iname); - std::string alt_name(residue_atoms[i]->altLoc); + std::string atm_name(residue_atoms[i]->GetAtomName()); + std::string alt_name(residue_atoms[i]->altLoc()); if (atm_name == " P ") { if (altconf == alt_name) { - clipper::Coord_orth P_pt(residue_atoms[i]->x, - residue_atoms[i]->y, - residue_atoms[i]->z); - clipper::Coord_orth N_pt( N1_or_9->x, N1_or_9->y, N1_or_9->z); - clipper::Coord_orth C_pt(C1_prime->x, C1_prime->y, C1_prime->z); + clipper::Coord_orth P_pt(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z()); + clipper::Coord_orth N_pt( N1_or_9->x(), N1_or_9->y(), N1_or_9->z()); + clipper::Coord_orth C_pt(C1_prime->x(), C1_prime->y(), C1_prime->z()); clipper::Coord_orth CN = N_pt - C_pt; clipper::Coord_orth CP = P_pt - C_pt; diff --git a/coot-utils/coot-coord-utils.cc b/coot-utils/coot-coord-utils.cc index cc19989eac..f55e8eed42 100644 --- a/coot-utils/coot-coord-utils.cc +++ b/coot-utils/coot-coord-utils.cc @@ -86,7 +86,7 @@ coot::util::residue_types_in_molecule(mmdb::Manager *mol) { // mmdb::Atom *atom_p = residue_p->GetAtom(iat); // } - std::string resname = residue_p->name; + std::string resname = residue_p->GetResName(); if (! is_member_p(v, resname)) { v.push_back(resname); @@ -133,11 +133,11 @@ coot::util::pair_residue_atoms(mmdb::Residue *a_residue_p, b_residue_p->GetAtomTable(residue_atoms_2, n_residue_atoms_2); for (int i=0; iname); - std::string alt1(residue_atoms_1[i]->altLoc); + std::string atn1(residue_atoms_1[i]->GetAtomName()); + std::string alt1(residue_atoms_1[i]->altLoc()); for (int j=0; jname); - std::string alt2(residue_atoms_2[j]->altLoc); + std::string atn2(residue_atoms_2[j]->GetAtomName()); + std::string alt2(residue_atoms_2[j]->altLoc()); if (atn1 == atn2) { if (alt1 == alt2) { std::pair p(i,j); @@ -180,9 +180,9 @@ coot::util::translate_close_to_origin(mmdb::Manager *mol) { int n_atoms = residue_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - at->x += co.x(); - at->y += co.y(); - at->z += co.z(); + at->x() += co.x(); + at->y() += co.y(); + at->z() += co.z(); } } } @@ -211,9 +211,9 @@ coot::util::shift(mmdb::Manager *mol, clipper::Coord_orth pt) { int n_atoms = residue_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - at->x += pt.x(); - at->y += pt.y(); - at->z += pt.z(); + at->x() += pt.x(); + at->y() += pt.y(); + at->z() += pt.z(); } } } @@ -374,15 +374,15 @@ coot::residues_near_residue(mmdb::Residue *res_ref, // std::cout << " comparing " << atom_selection[pscontact[i].id2] // << " " << coot::atom_spec_t(atom_selection[pscontact[i].id2]) // << " " << " to " << rs << " " << res_p << std::endl; - if (atom_selection[pscontact[i].id2]->residue != res_ref) { + if (atom_selection[pscontact[i].id2]->GetResidue() != res_ref) { n_cont_diff++; std::vector::iterator result = std::find(close_residues.begin(), close_residues.end(), - atom_selection[pscontact[i].id2]->residue); + atom_selection[pscontact[i].id2]->GetResidue()); if (result == close_residues.end()) { - close_residues.push_back(atom_selection[pscontact[i].id2]->residue); + close_residues.push_back(atom_selection[pscontact[i].id2]->GetResidue()); } } else { n_cont_same++; @@ -498,8 +498,8 @@ coot::residues_near_residues(const std::vector > for (int i=0; iresidue; - mmdb::Residue *data = atom_2->residue; + mmdb::Residue *key = atom_1->GetResidue(); + mmdb::Residue *data = atom_2->GetResidue(); if (data != key) { if (m.find(key) != m.end()) { m[key].insert(data); @@ -583,8 +583,8 @@ coot::residues_near_residues(mmdb::Manager *mol, float dist_crit) { for (int i=0; iresidue; - mmdb::Residue *data = atom_2->residue; + mmdb::Residue *key = atom_1->GetResidue(); + mmdb::Residue *data = atom_2->GetResidue(); if (data != key) { m[key].insert(data); } @@ -634,7 +634,7 @@ coot::residues_near_position(const clipper::Coord_orth &pt, int n_atoms = residue_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - clipper::Coord_orth at_pt(at->x, at->y, at->z); + clipper::Coord_orth at_pt(at->x(), at->y(), at->z()); double d = clipper::Coord_orth::length(pt, at_pt); if (d < radius) { v.push_back(residue_p); @@ -670,15 +670,15 @@ coot::filter_residues_by_solvent_contact(mmdb::Residue *res_ref, residues[i]->GetAtomTable(residue_atoms, n_residue_atoms); bool i_added = 0; for (int jat=0; jatx, - lig_residue_atoms[jat]->y, - lig_residue_atoms[jat]->z); - std::string ligand_atom_ele = lig_residue_atoms[jat]->element; + clipper::Coord_orth lig_pt(lig_residue_atoms[jat]->x(), + lig_residue_atoms[jat]->y(), + lig_residue_atoms[jat]->z()); + std::string ligand_atom_ele = lig_residue_atoms[jat]->GetElementName(); for (int iat=0; iatx, - residue_atoms[iat]->y, - residue_atoms[iat]->z); + clipper::Coord_orth pt(residue_atoms[iat]->x(), + residue_atoms[iat]->y(), + residue_atoms[iat]->z()); if ((lig_pt-pt).lengthsq() < (water_dist_max*water_dist_max)) { if (0) std::cout << "pushing back " << coot::residue_spec_t(residues[i]) @@ -714,13 +714,13 @@ coot::closest_approach(mmdb::Manager *mol, r1->GetAtomTable( residue_atoms_1, n_res_1_atoms); r2->GetAtomTable( residue_atoms_2, n_res_2_atoms); for (int i=0; ix, - residue_atoms_1[i]->y, - residue_atoms_1[i]->z); + clipper::Coord_orth pt1(residue_atoms_1[i]->x(), + residue_atoms_1[i]->y(), + residue_atoms_1[i]->z()); for (int j=0; jx, - residue_atoms_2[j]->y, - residue_atoms_2[j]->z); + clipper::Coord_orth pt2(residue_atoms_2[j]->x(), + residue_atoms_2[j]->y(), + residue_atoms_2[j]->z()); double d_sqrd = (pt2 - pt1).lengthsq(); if (d_sqrd < dist_sqrd_best) { @@ -840,8 +840,8 @@ coot::distance(mmdb::Atom *at_1, mmdb::Atom *at_2) { double d = -1; if (at_1 && at_2) { - clipper::Coord_orth pt_1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth pt_2(at_2->x, at_2->y, at_2->z); + clipper::Coord_orth pt_1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth pt_2(at_2->x(), at_2->y(), at_2->z()); d = clipper::Coord_orth::length(pt_1, pt_2); } @@ -858,9 +858,9 @@ coot::angle(mmdb::Atom *at_1, mmdb::Atom *at_2, mmdb::Atom *at_3) { if (at_1 && at_2 && at_3) { - clipper::Coord_orth pt_1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth pt_2(at_2->x, at_2->y, at_2->z); - clipper::Coord_orth pt_3(at_3->x, at_3->y, at_3->z); + clipper::Coord_orth pt_1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth pt_2(at_2->x(), at_2->y(), at_2->z()); + clipper::Coord_orth pt_3(at_3->x(), at_3->y(), at_3->z()); ang = clipper::Util::rad2d(clipper::Coord_orth::angle(pt_1, pt_2, pt_3)); @@ -980,7 +980,7 @@ coot::util::get_reorientation_matrix(mmdb::Residue *residue_current, bool coot::is_hydrogen_atom(mmdb::Atom *at_p) { - std::string ele = at_p->element; + std::string ele = at_p->GetElementName(); if ((ele == "H") || (ele == " H")) return true; else @@ -1149,7 +1149,7 @@ coot::util::residue_types_in_chain(mmdb::Chain *chain_p) { for (int ires=0; iresGetResidue(ires); if (residue_p) { - std::string n(residue_p->name); + std::string n(residue_p->GetResName()); if (! is_member_p(v, n)) v.push_back(n); } @@ -1163,7 +1163,7 @@ coot::util::residue_types_in_residue_vec(const std::vector &res std::vector v; for (unsigned int ires=0; iresname); + std::string n(residues[ires]->GetResName()); if (! is_member_p(v, n)) v.push_back(n); } @@ -1353,9 +1353,9 @@ coot::util::get_residue_centre(mmdb::Residue *residue_p) { if (n_residue_atoms>0) { status = 1; for (int i=0; ix, - residue_atoms[i]->y, - residue_atoms[i]->z); + clipper::Coord_orth pt(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z()); centre += pt; } double scale = 1.0/double(n_residue_atoms); @@ -1376,9 +1376,9 @@ coot::util::get_CA_position_in_residue(mmdb::Residue *residue_p) { for (int i=0; iGetAtomName()); if (atom_name == " CA ") { // PDBv3 FIXME - clipper::Coord_orth pt(residue_atoms[i]->x, - residue_atoms[i]->y, - residue_atoms[i]->z); + clipper::Coord_orth pt(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z()); pos = pt; status = true; break; @@ -1398,9 +1398,9 @@ coot::util::get_CB_position_in_residue(mmdb::Residue *residue_p) { for (int i=0; iGetAtomName()); if (atom_name == " CB ") { // PDBv3 FIXME - clipper::Coord_orth pt(residue_atoms[i]->x, - residue_atoms[i]->y, - residue_atoms[i]->z); + clipper::Coord_orth pt(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z()); pos = pt; status = true; break; @@ -1569,9 +1569,9 @@ coot::util::get_fragment_from_atom_spec(const coot::atom_spec_t &atom_spec, for (int iat=0; iatGetAtom(iat); - std::string mol_atom_name = at->name; + std::string mol_atom_name = at->GetAtomName(); if (mol_atom_name == atom_spec.atom_name) { - std::string alt_conf = at->altLoc; + std::string alt_conf = at->altLoc(); if (alt_conf == atom_spec.alt_conf) { search_atom = at; } @@ -1798,7 +1798,7 @@ coot::util::min_resno_in_chain(mmdb::Chain *chain_p) { int resno; for (int ires=0; iresGetResidue(ires); - resno = residue_p->seqNum; + resno = residue_p->GetSeqNum(); if (resno < min_resno) { min_resno = resno; found_residues = 1; @@ -1828,7 +1828,7 @@ coot::util::max_resno_in_chain(mmdb::Chain *chain_p) { if (nres > 0) { for (int ires=0; iresGetResidue(ires); - resno = residue_p->seqNum; + resno = residue_p->GetSeqNum(); if (resno > max_resno) { max_resno = resno; found_residues = 1; @@ -1867,7 +1867,7 @@ coot::util::min_max_residues_in_polymer_chain(mmdb::Chain *chain_p) { if (nres > 0) { for (int ires=0; iresGetResidue(ires); - int resno = residue_p->seqNum; + int resno = residue_p->GetSeqNum(); if (resno > max_resno) { if (! residue_has_hetatms(residue_p)) { max_resno = resno; @@ -2142,10 +2142,10 @@ coot::graph_match(mmdb::Residue *res_moving, // ipair, V1->GetName(), V2->GetName()); mmdb::Atom *at1 = cleaned_res_moving->atom[V1->GetUserID()]; mmdb::Atom *at2 = cleaned_res_reference->atom[V2->GetUserID()]; - coords_1_local.push_back(clipper::Coord_orth(at1->x, at1->y, at1->z)); - coords_2_local.push_back(clipper::Coord_orth(at2->x, at2->y, at2->z)); - std::pair atom_info_1(at1->name, at1->altLoc); - std::pair atom_info_2(at2->name, at2->altLoc); + coords_1_local.push_back(clipper::Coord_orth(at1->x(), at1->y(), at1->z())); + coords_2_local.push_back(clipper::Coord_orth(at2->x(), at2->y(), at2->z())); + std::pair atom_info_1(at1->GetAtomName(), at1->altLoc()); + std::pair atom_info_2(at2->GetAtomName(), at2->altLoc()); std::pair, std::pair > atom_pair(atom_info_1, atom_info_2); matching_atoms.push_back(atom_pair); } @@ -2224,7 +2224,7 @@ coot::graph_match_info_t::match_names(mmdb::Residue *res_with_moving_names) { int n_residue_atoms; res_with_moving_names->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); + std::string atom_name(residue_atoms[iat]->GetAtomName()); // add the name if is not already there. if (std::find(residue_atom_names.begin(), residue_atom_names.end(), atom_name) == residue_atom_names.end()) @@ -2287,7 +2287,7 @@ coot::graph_match_info_t::match_names(mmdb::Residue *res_with_moving_names) { // check for a collision. Is the reference name in existing // atom names that are not due to be replaced? - std::string this_atom_name(residue_atoms[iat]->name); + std::string this_atom_name(residue_atoms[iat]->GetAtomName()); bool replace_name = 0; std::string new_atom_name = ""; @@ -2298,7 +2298,7 @@ coot::graph_match_info_t::match_names(mmdb::Residue *res_with_moving_names) { this_atom_name) != orig_moving_atom_names_non_mapped_non_same.end()) { // OK, this atom name is in the list of atoms non-mapped needing a name change - std::string ele = residue_atoms[iat]->element; + std::string ele = residue_atoms[iat]->GetElementName(); new_atom_name = invent_new_name(this_atom_name, ele, residue_atom_names); residue_atom_names.push_back(new_atom_name); replace_name = 1; @@ -2368,7 +2368,7 @@ coot::util::median_temperature_factor(mmdb::PPAtom atom_selection, float median = 0; std::vector b; for (int i=0; itempFactor; + this_b = atom_selection[i]->tempFactor(); if ((apply_low_cutoff && (this_b > low_cutoff)) || !apply_low_cutoff) { if ((apply_high_cutoff && (this_b > high_cutoff)) || @@ -2399,7 +2399,7 @@ coot::util::average_temperature_factor(mmdb::PPAtom atom_selection, int n_sum = 0; for (int i=0; itempFactor; + this_b = atom_selection[i]->tempFactor(); if ((apply_low_cutoff && (this_b > low_cutoff)) || !apply_low_cutoff) { if ((apply_high_cutoff && (this_b > high_cutoff)) || @@ -2430,7 +2430,7 @@ coot::util::standard_deviation_temperature_factor(mmdb::PPAtom atom_selection, int n_sum = 0; for (int i=0; itempFactor; + this_b = atom_selection[i]->tempFactor(); if ((apply_low_cutoff && (this_b > low_cutoff)) || !apply_low_cutoff) { if ((apply_high_cutoff && (this_b > high_cutoff)) || @@ -2469,7 +2469,7 @@ coot::util::delete_alt_confs_except(mmdb::Residue *residue_p, const std::string int n_residue_atoms; residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; ialtLoc); + std::string atom_alt_conf(residue_atoms[i]->altLoc()); if (atom_alt_conf != alt_conf) { atoms_to_be_deleted.push_back(residue_atoms[i]); } @@ -2540,9 +2540,9 @@ coot::util::get_residue_mid_point(mmdb::Manager *mol, const coot::residue_spec_t for (int iat=0; iatisTer()) { - sum_x += at->x; - sum_y += at->y; - sum_z += at->z; + sum_x += at->x(); + sum_y += at->y(); + sum_z += at->z(); n += 1; } } @@ -2997,8 +2997,8 @@ coot::util::get_atom(const atom_spec_t &spec, mmdb::Manager *mol) { res->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname; - std::string at_alt_conf = test_at->altLoc; + std::string at_name = test_at->GetAtomName(); + std::string at_alt_conf = test_at->altLoc(); if (spec.atom_name == at_name) { if (spec.alt_conf == at_alt_conf) { if (! test_at->isTer()) { @@ -3039,7 +3039,7 @@ coot::util::get_atom_using_fuzzy_search(const atom_spec_t &spec, mmdb::Manager * for (int iat=0; iatisTer()) { - std::string atom_name(at->name); + std::string atom_name(at->GetAtomName()); if (atom_name == spec.atom_name) { rat = at; break; @@ -3060,7 +3060,7 @@ coot::util::get_atom_using_fuzzy_search(const atom_spec_t &spec, mmdb::Manager * for (int iat=0; iatisTer()) { - std::string atom_name(at->name); + std::string atom_name(at->GetAtomName()); if (atom_name == t) { rat = at; break; @@ -3095,8 +3095,8 @@ coot::util::get_atom(const atom_spec_t &spec, mmdb::Residue *res) { res->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname; - std::string at_alt_conf = test_at->altLoc; + std::string at_name = test_at->GetAtomName(); + std::string at_alt_conf = test_at->altLoc(); if (spec.atom_name == at_name) { if (spec.alt_conf == at_alt_conf) { if (! test_at->isTer()) { @@ -3116,7 +3116,7 @@ coot::util::get_atom(const atom_spec_t &spec, mmdb::Residue *res) { clipper::Coord_orth coot::util::get_coords(mmdb::Atom *at) { - clipper::Coord_orth pt(at->x, at->y, at->z); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); return pt; } @@ -3148,8 +3148,8 @@ coot::util::add_atom(mmdb::Residue *res, if (res) { res->GetAtomTable(residue_atoms, nResidueAtoms); for (int i=0; iname); - std::string atom_alt_conf(residue_atoms[i]->altLoc); + std::string atom_name(residue_atoms[i]->GetAtomName()); + std::string atom_alt_conf(residue_atoms[i]->altLoc()); if (atom_alt_conf == alt_conf) { if (atom_name == atom_name_1) { a = residue_atoms[i]; @@ -3164,9 +3164,9 @@ coot::util::add_atom(mmdb::Residue *res, } if (a && b && c) { - clipper::Coord_orth ac(a->x, a->y, a->z); - clipper::Coord_orth bc(b->x, b->y, b->z); - clipper::Coord_orth cc(c->x, c->y, c->z); + clipper::Coord_orth ac(a->x(), a->y(), a->z()); + clipper::Coord_orth bc(b->x(), b->y(), b->z()); + clipper::Coord_orth cc(c->x(), c->y(), c->z()); double ang = clipper::Util::d2rad(angle); double tors = clipper::Util::d2rad(torsion); clipper::Coord_orth pos(ac, bc, cc, length, ang, tors); @@ -3543,7 +3543,7 @@ coot::util::create_mmdbmanager_from_residue_vector(const std::vectorPutUDData(index_from_reference_residue_handle, residue_old_p->index); + residue_new_p->PutUDData(index_from_reference_residue_handle, residue_old_p->GetIndex()); mmdb::Atom **new_residue_atoms = 0; mmdb::Atom **old_residue_atoms = 0; int n_old_residue_atoms; @@ -3567,8 +3567,8 @@ coot::util::create_mmdbmanager_from_residue_vector(const std::vectorGetAtomName(); std::string at_name_new = at_new->GetAtomName(); if (at_name_old == at_name_new) { - std::string alt_conf_old = at_old->altLoc; - std::string alt_conf_new = at_new->altLoc; + std::string alt_conf_old = at_old->altLoc(); + std::string alt_conf_new = at_new->altLoc(); if (alt_conf_new == alt_conf_old) { int idx = -1; if (at_old->GetUDData(udd_atom_index_handle, idx) == mmdb::UDDATA_Ok) { @@ -3596,12 +3596,12 @@ coot::util::create_mmdbmanager_from_residue_vector(const std::vectorGetAtomName(); - std::string alt_conf_new = at_new->altLoc; + std::string alt_conf_new = at_new->altLoc(); for (int jat=0; jatGetAtomName(); if (at_name_old == at_name_new) { - std::string alt_conf_old = at_old->altLoc; + std::string alt_conf_old = at_old->altLoc(); if (alt_conf_new == alt_conf_old) { int idx = -1; if (at_old->GetUDData(udd_atom_index_handle, idx) == mmdb::UDDATA_Ok) { @@ -3728,7 +3728,7 @@ mmdb::Manager *coot::util::create_mmdbmanager_from_points(const std::vectorSetElementName(" C"); mmdb::Residue *residue_p = new mmdb::Residue; residue_p->SetResName("ALA"); - residue_p->seqNum = i; + residue_p->GetSeqNum() = i; residue_p->AddAtom(at); chain_p->AddResidue(residue_p); } @@ -3750,7 +3750,7 @@ coot::util::pdbcleanup_serial_residue_numbers(mmdb::Manager *mol) { int nres = chain_p->GetNumberOfResidues(); for (int ires=0; iresGetResidue(ires); - residue_p->index = ires; + residue_p->GetIndex() = ires; } } } @@ -4521,14 +4521,14 @@ coot::util::transfer_links(mmdb::Manager *mol_orig, mmdb::Manager *mol_new) { mmdb::Link *link = new mmdb::Link; // sym ids default to 1555 1555 strncpy(link->atName1, at_1->GetAtomName(), 20); - strncpy(link->aloc1, at_1->altLoc, 20); + strncpy(link->aloc1, at_1->altLoc(), 20); strcpy(link->resName1, at_1->GetResName()); strcpy(link->chainID1, at_1->GetChainID()); strcpy(link->insCode1, at_1->GetInsCode()); link->seqNum1 = at_1->GetSeqNum(); strncpy(link->atName2, at_2->GetAtomName(), 20); - strncpy(link->aloc2, at_2->altLoc, 20); + strncpy(link->aloc2, at_2->altLoc(), 20); strcpy(link->resName2, at_2->GetResName()); strcpy(link->chainID2, at_2->GetChainID()); strcpy(link->insCode2, at_2->GetInsCode()); @@ -4624,8 +4624,8 @@ coot::util::deep_copy_this_residue_add_chain(mmdb::Residue *residue, chain_p = new mmdb::Chain; chain_p->SetChainID(residue->GetChainID()); } - rres->seqNum = residue->GetSeqNum(); - strcpy(rres->name, residue->name); + rres->GetSeqNum() = residue->GetSeqNum(); + rres->SetResName(residue->name); // BL says:: should copy insCode too, maybe more things... strncpy(rres->insCode, residue->GetInsCode(), 3); @@ -4635,7 +4635,7 @@ coot::util::deep_copy_this_residue_add_chain(mmdb::Residue *residue, mmdb::Atom *atom_p; for(int iat=0; iatisTer()) { - std::string this_atom_alt_loc(residue_atoms[iat]->altLoc); + std::string this_atom_alt_loc(residue_atoms[iat]->altLoc()); if (whole_residue_flag || this_atom_alt_loc == altconf || this_atom_alt_loc == "") { atom_p = new mmdb::Atom; @@ -4657,8 +4657,8 @@ coot::util::deep_copy_this_residue(mmdb::Residue *residue) { if (residue) { rres = new mmdb::Residue; - rres->seqNum = residue->GetSeqNum(); - strcpy(rres->name, residue->name); + rres->GetSeqNum() = residue->GetSeqNum(); + rres->SetResName(residue->name); strncpy(rres->insCode, residue->GetInsCode(), 3); mmdb::PPAtom residue_atoms = 0; @@ -4691,8 +4691,8 @@ coot::util::deep_copy_this_residue(mmdb::Residue *residue, if (residue) { rres = new mmdb::Residue; - rres->seqNum = residue->GetSeqNum(); - strcpy(rres->name, residue->name); + rres->GetSeqNum() = residue->GetSeqNum(); + rres->SetResName(residue->name); // BL says:: should copy insCode too, maybe more things... strncpy(rres->insCode, residue->GetInsCode(), 3); @@ -4706,7 +4706,7 @@ coot::util::deep_copy_this_residue(mmdb::Residue *residue, if (! at->isTer()) { if (use_alt_conf.first) { - std::string alt_conf(at->altLoc); + std::string alt_conf(at->altLoc()); if (! alt_conf.empty()) if (alt_conf != use_alt_conf.second) continue; @@ -4751,8 +4751,8 @@ coot::util::deep_copy_this_residue_with_atom_index_and_afix_transfer(mmdb::Manag mmdb::Residue *rres = new mmdb::Residue; mmdb::Chain *chain_p = new mmdb::Chain; chain_p->SetChainID(((mmdb::Residue *)residue)->GetChainID()); - rres->seqNum = ((mmdb::Residue *)residue)->GetSeqNum(); - strcpy(rres->name, residue->name); + rres->GetSeqNum() = ((mmdb::Residue *)residue)->GetSeqNum(); + rres->SetResName(residue->name); // BL says:: should copy insCode too, maybe more things... strncpy(rres->insCode, ((mmdb::Residue *)residue)->GetInsCode(), 3); @@ -4770,7 +4770,7 @@ coot::util::deep_copy_this_residue_with_atom_index_and_afix_transfer(mmdb::Manag } for(int iat=0; iataltLoc); + std::string this_atom_alt_loc(residue_atoms[iat]->altLoc()); if (whole_residue_flag || this_atom_alt_loc == altconf || this_atom_alt_loc == "") { atom_p = new mmdb::Atom; @@ -4806,7 +4806,7 @@ mmdb::Residue *coot::util::copy_and_delete_hydrogens(mmdb::Residue *residue_in) copy->GetAtomTable(residue_atoms, nResidueAtoms); for(int i=0; ielement); + std::string element(residue_atoms[i]->GetElementName()); if (element == " H" || element == " D") { copy->DeleteAtom(i); } @@ -4826,7 +4826,7 @@ coot::util::transform_chain(mmdb::Manager *mol, for (int iat=0; iatresidue->chain == moving_chain) { + if (at->GetResidue()->chain == moving_chain) { at->Transform(my_matt); } } @@ -4843,9 +4843,9 @@ coot::util::transform_chain(mmdb::Chain *chain_p, const clipper::RTop_orth &rtop mmdb::Atom *at = residue_p->GetAtom(iat); clipper::Coord_orth pt(co(at)); clipper::Coord_orth new_pt(rtop * pt); - at->x = new_pt.x(); - at->y = new_pt.y(); - at->z = new_pt.z(); + at->x() = new_pt.x(); + at->y() = new_pt.y(); + at->z() = new_pt.z(); } } } @@ -4861,13 +4861,13 @@ coot::util::transform_atoms(mmdb::Residue *res, const clipper::RTop_orth &rtop) clipper::Coord_orth trans_pos; res->GetAtomTable(residue_atoms, natoms); for (int iatom=0; iatomx, - residue_atoms[iatom]->y, - residue_atoms[iatom]->z); + co = clipper::Coord_orth(residue_atoms[iatom]->x(), + residue_atoms[iatom]->y(), + residue_atoms[iatom]->z()); trans_pos = co.transform(rtop); - residue_atoms[iatom]->x = trans_pos.x(); - residue_atoms[iatom]->y = trans_pos.y(); - residue_atoms[iatom]->z = trans_pos.z(); + residue_atoms[iatom]->x() = trans_pos.x(); + residue_atoms[iatom]->y() = trans_pos.y(); + residue_atoms[iatom]->z() = trans_pos.z(); } } @@ -4893,11 +4893,11 @@ coot::util::transform_mol(mmdb::Manager *mol, const clipper::RTop_orth &rtop) { int n_atoms = residue_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - clipper::Coord_orth co(at->x, at->y, at->z); + clipper::Coord_orth co(at->x(), at->y(), at->z()); clipper::Coord_orth trans_pos = co.transform(rtop); - at->x = trans_pos.x(); - at->y = trans_pos.y(); - at->z = trans_pos.z(); + at->x() = trans_pos.x(); + at->y() = trans_pos.y(); + at->z() = trans_pos.z(); } } } @@ -4915,11 +4915,11 @@ coot::util::transform_selection(mmdb::Manager *mol, int SelHnd, const clipper::R mol->GetSelIndex(SelHnd, atoms, n_selected_atoms); for (int iat=0; iatx, at->y, at->z); + clipper::Coord_orth co(at->x(), at->y(), at->z()); clipper::Coord_orth trans_pos = co.transform(rtop); - at->x = trans_pos.x(); - at->y = trans_pos.y(); - at->z = trans_pos.z(); + at->x() = trans_pos.x(); + at->y() = trans_pos.y(); + at->z() = trans_pos.z(); sum_dist += (trans_pos - co).lengthsq(); } if (0) // for debugging @@ -4992,7 +4992,7 @@ coot::util::intelligent_this_residue_mmdb_atom(mmdb::Residue *res_p) { res_p->GetAtomTable(residue_atoms, nResidueAtoms); for (int i=0; iname); + std::string atom_name(residue_atoms[i]->GetAtomName()); if (atom_name == " CA ") { return residue_atoms[i]; } @@ -5017,7 +5017,7 @@ coot::util::occupancy_sum(mmdb::PAtom *atoms, int n_atoms) { for (int i=0; iisTer()) - os += atoms[i]->occupancy; + os += atoms[i]->occupancy(); } return os; } @@ -5030,7 +5030,7 @@ coot::util::is_nucleotide(mmdb::Residue *residue_p) { short int nuc = 0; if (residue_p) { - std::string type(residue_p->name); // all spaces cut + std::string type(residue_p->GetResName()); // all spaces cut if (type == "A") { nuc = 1; @@ -5129,7 +5129,7 @@ coot::util::nucleotide_is_DNA(mmdb::Residue *r) { int n_residue_atoms; r->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; iname; + std::string atom_name = residue_atoms[i]->GetAtomName(); if (atom_name == " O2'") { has_o2_prime = 1; break; @@ -5167,7 +5167,7 @@ coot::util::chain_only_of_type(mmdb::Manager *mol, const std::string &residue_ty bool all_same_type_flag = true; for (int ires=0; iresGetResidue(ires); - std::string resname(residue_p->name); + std::string resname(residue_p->GetResName()); if (! (resname == residue_type)) { all_same_type_flag = false; break; @@ -5266,13 +5266,13 @@ coot::util::extents(mmdb::Manager *mol, float least_y = 99999; float least_z = 99999; for (int i=0; ix > most_x) most_x = atoms[i]->x; - if (atoms[i]->y > most_y) most_y = atoms[i]->y; - if (atoms[i]->z > most_z) most_z = atoms[i]->z; + if (atoms[i]->x() > most_x) most_x = atoms[i]->x(); + if (atoms[i]->y() > most_y) most_y = atoms[i]->y(); + if (atoms[i]->z() > most_z) most_z = atoms[i]->z(); - if (atoms[i]->x < least_x) least_x = atoms[i]->x; - if (atoms[i]->y < least_y) least_y = atoms[i]->y; - if (atoms[i]->z < least_z) least_z = atoms[i]->z; + if (atoms[i]->x() < least_x) least_x = atoms[i]->x(); + if (atoms[i]->y() < least_y) least_y = atoms[i]->y(); + if (atoms[i]->z() < least_z) least_z = atoms[i]->z(); } clipper::Coord_orth p1( most_x, most_y, most_z); @@ -5299,12 +5299,12 @@ coot::util::extents(mmdb::Manager *mol, residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatx < least_x) least_x = at->x; - if (at->y < least_y) least_y = at->y; - if (at->z < least_z) least_z = at->z; - if (at->x > most_x) most_x = at->x; - if (at->y > most_y) most_y = at->y; - if (at->z > most_z) most_z = at->z; + if (at->x() < least_x) least_x = at->x(); + if (at->y() < least_y) least_y = at->y(); + if (at->z() < least_z) least_z = at->z(); + if (at->x() > most_x) most_x = at->x(); + if (at->y() > most_y) most_y = at->y(); + if (at->z() > most_z) most_z = at->z(); } } } @@ -5329,12 +5329,12 @@ coot::util::get_ori_to_this_res(mmdb::Residue *residue_p) { std::map > atoms; // first size up the vectors in the atom map for (int iat=0; iataltLoc; + std::string alt_conf = residue_atoms[iat]->altLoc(); atoms[alt_conf].resize(3,0); } for (int iat=0; iataltLoc; - std::string atom_name = residue_atoms[iat]->name; + std::string alt_conf = residue_atoms[iat]->altLoc(); + std::string atom_name = residue_atoms[iat]->GetAtomName(); int name_index = -1; if (atom_name == " N ") name_index = 0; if (atom_name == " CA ") name_index = 1; @@ -5348,9 +5348,9 @@ coot::util::get_ori_to_this_res(mmdb::Residue *residue_p) { std::map >::const_iterator it; for(it=atoms.begin(); it!=atoms.end(); ++it) { if (it->second[0] && it->second[1] && it->second[2]) { - clipper::Coord_orth n(it->second[0]->x, it->second[0]->y, it->second[0]->z); - clipper::Coord_orth ca(it->second[1]->x, it->second[1]->y, it->second[1]->z); - clipper::Coord_orth c(it->second[2]->x, it->second[2]->y, it->second[2]->z); + clipper::Coord_orth n(it->second[0]->x(), it->second[0]->y(), it->second[0]->z()); + clipper::Coord_orth ca(it->second[1]->x(), it->second[1]->y(), it->second[1]->z()); + clipper::Coord_orth c(it->second[2]->x(), it->second[2]->y(), it->second[2]->z()); clipper::Coord_orth can_unit = clipper::Coord_orth((n - ca).unit()); clipper::Coord_orth cac_unit = clipper::Coord_orth((c - ca).unit()); @@ -5529,8 +5529,8 @@ coot::util::omega_torsion(mmdb::Residue *C_residue, mmdb::Residue *N_residue, co mmdb::Atom *N_residue_N_atom_p = NULL; for (int i=0; iname; - std::string altconf_atom = C_residue_atoms[i]->altLoc; + std::string atom_name = C_residue_atoms[i]->GetAtomName(); + std::string altconf_atom = C_residue_atoms[i]->altLoc(); if (atom_name == " CA ") if (altconf_atom == altconf) C_residue_CA_atom_p = C_residue_atoms[i]; @@ -5540,8 +5540,8 @@ coot::util::omega_torsion(mmdb::Residue *C_residue, mmdb::Residue *N_residue, co } for (int i=0; iname; - std::string altconf_atom = N_residue_atoms[i]->altLoc; + std::string atom_name = N_residue_atoms[i]->GetAtomName(); + std::string altconf_atom = N_residue_atoms[i]->altLoc(); if (atom_name == " CA ") if (altconf_atom == altconf) N_residue_CA_atom_p = N_residue_atoms[i]; @@ -5551,18 +5551,18 @@ coot::util::omega_torsion(mmdb::Residue *C_residue, mmdb::Residue *N_residue, co } if (C_residue_CA_atom_p && C_residue_C_atom_p && N_residue_N_atom_p && N_residue_CA_atom_p) { - clipper::Coord_orth ca1(C_residue_CA_atom_p->x, - C_residue_CA_atom_p->y, - C_residue_CA_atom_p->z); - clipper::Coord_orth c1(C_residue_C_atom_p->x, - C_residue_C_atom_p->y, - C_residue_C_atom_p->z); - clipper::Coord_orth ca2(N_residue_CA_atom_p->x, - N_residue_CA_atom_p->y, - N_residue_CA_atom_p->z); - clipper::Coord_orth n2(N_residue_N_atom_p->x, - N_residue_N_atom_p->y, - N_residue_N_atom_p->z); + clipper::Coord_orth ca1(C_residue_CA_atom_p->x(), + C_residue_CA_atom_p->y(), + C_residue_CA_atom_p->z()); + clipper::Coord_orth c1(C_residue_C_atom_p->x(), + C_residue_C_atom_p->y(), + C_residue_C_atom_p->z()); + clipper::Coord_orth ca2(N_residue_CA_atom_p->x(), + N_residue_CA_atom_p->y(), + N_residue_CA_atom_p->z()); + clipper::Coord_orth n2(N_residue_N_atom_p->x(), + N_residue_N_atom_p->y(), + N_residue_N_atom_p->z()); omega = clipper::Coord_orth::torsion(ca1, c1, n2, ca2); istatus = true; @@ -5947,11 +5947,11 @@ coot::util::nucleotide_to_nucleotide(mmdb::Residue *residue, for (int j=0; jname; + std::string atom_name = mol_base_atoms[i]->GetAtomName(); if (refrce_name_vector[j] == atom_name) { - refrce_atom_positions.push_back(clipper::Coord_orth(mol_base_atoms[i]->x, - mol_base_atoms[i]->y, - mol_base_atoms[i]->z)); + refrce_atom_positions.push_back(clipper::Coord_orth(mol_base_atoms[i]->x(), + mol_base_atoms[i]->y(), + mol_base_atoms[i]->z())); if (0) std::cout << "Found " << atom_name << " in reference " << std::endl; } @@ -5960,11 +5960,11 @@ coot::util::nucleotide_to_nucleotide(mmdb::Residue *residue, for (int j=0; jname; + std::string atom_name = std_base_atoms[i]->GetAtomName(); if (moving_name_vector[j] == atom_name) { - moving_atom_positions.push_back(clipper::Coord_orth(std_base_atoms[i]->x, - std_base_atoms[i]->y, - std_base_atoms[i]->z)); + moving_atom_positions.push_back(clipper::Coord_orth(std_base_atoms[i]->x(), + std_base_atoms[i]->y(), + std_base_atoms[i]->z())); if (0) std::cout << "Found " << atom_name << " in moving (std) base " << std::endl; } @@ -6004,20 +6004,20 @@ coot::util::nucleotide_to_nucleotide(mmdb::Residue *residue, for (unsigned int inuc=0; inucname; + std::string std_base_atom_name = std_base_atoms[istd]->GetAtomName(); if (std_base_atom_name == const_nuc_atoms[inuc]) { for (int imol=0; imolname; + std::string mol_base_atom_name = mol_base_atoms[imol]->GetAtomName(); if (mol_base_atom_name == std_base_atom_name) { - std::string altconf1 = std_base_atoms[istd]->altLoc; - std::string altconf2 = mol_base_atoms[imol]->altLoc; + std::string altconf1 = std_base_atoms[istd]->altLoc(); + std::string altconf2 = mol_base_atoms[imol]->altLoc(); if (altconf1 == altconf2) { - clipper::Coord_orth s(std_base_atoms[istd]->x, - std_base_atoms[istd]->y, - std_base_atoms[istd]->z); - clipper::Coord_orth m(mol_base_atoms[imol]->x, - mol_base_atoms[imol]->y, - mol_base_atoms[imol]->z); + clipper::Coord_orth s(std_base_atoms[istd]->x(), + std_base_atoms[istd]->y(), + std_base_atoms[istd]->z()); + clipper::Coord_orth m(mol_base_atoms[imol]->x(), + mol_base_atoms[imol]->y(), + mol_base_atoms[imol]->z()); // std::cout << "---" << std::endl; // std::cout << std_base_atoms[istd]->GetSeqNum() << " " @@ -6083,7 +6083,7 @@ coot::util::gln_asn_b_factor_outliers(mmdb::Manager *mol) { int n_residue_atoms = 0; for (int iat=0; iatGetAtom(iat); - std::string altloc(at->altLoc); + std::string altloc(at->altLoc()); if (altloc == "") { std::string atom_name(at->GetAtomName()); @@ -6112,8 +6112,8 @@ coot::util::gln_asn_b_factor_outliers(mmdb::Manager *mol) { } } else { // is a normal atom of the residue: - b_sum += at->tempFactor; - b_sum_sq += at->tempFactor * at->tempFactor; + b_sum += at->tempFactor(); + b_sum_sq += at->tempFactor() * at->tempFactor(); n_residue_atoms++; } // find the atom to centre on when the button is @@ -6136,7 +6136,7 @@ coot::util::gln_asn_b_factor_outliers(mmdb::Manager *mol) { float mean = b_sum/float(n_residue_atoms); float var = b_sum_sq/float(n_residue_atoms) - mean*mean; float std_dev = sqrt(var); - float diff = (oatom->tempFactor - natom->tempFactor)/2.0; + float diff = (oatom->tempFactor() - natom->tempFactor())/2.0; // we are only interested in cases that have the // O atom B-factor greater than the N atom // B-factor because only they can be fixed by @@ -6191,7 +6191,7 @@ coot::util::residue_has_hydrogens_p(mmdb::Residue *res) { for (int iat=0; iatisTer()) { - std::string ele(at->element); + std::string ele(at->GetElementName()); if ((ele == " H") || (ele == " D")) { result = 1; break; @@ -6244,11 +6244,11 @@ coot::util::rotate_residue(mmdb::Residue *residue_p, mmdb::Atom *at = residue_atoms[iat]; if (at) { if (! at->isTer()) { - clipper::Coord_orth pt(at->x, at->y, at->z); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); clipper::Coord_orth pt_new = rotate_around_vector(direction, pt, origin_shift, angle); - at->x = pt_new.x(); - at->y = pt_new.y(); - at->z = pt_new.z(); + at->x() = pt_new.x(); + at->y() = pt_new.y(); + at->z() = pt_new.z(); } } } @@ -6263,11 +6263,11 @@ coot::util::rotate_atom_about(const clipper::Coord_orth &direction, double angle, mmdb::Atom *at) { if (at) { - clipper::Coord_orth pos(at->x, at->y, at->z); + clipper::Coord_orth pos(at->x(), at->y(), at->z()); clipper::Coord_orth new_pos = rotate_around_vector(direction, pos, origin_shift, angle); - at->x = new_pos.x(); - at->y = new_pos.y(); - at->z = new_pos.z(); + at->x() = new_pos.x(); + at->y() = new_pos.y(); + at->z() = new_pos.z(); } } @@ -6291,12 +6291,12 @@ coot::util::standardize_peptide_C_N_distances(const std::vectorx += shift * uv.x(); - c_at->y += shift * uv.y(); - c_at->z += shift * uv.z(); - n_at->x -= shift * uv.x(); - n_at->y -= shift * uv.y(); - n_at->z -= shift * uv.z(); + c_at->x() += shift * uv.x(); + c_at->y() += shift * uv.y(); + c_at->z() += shift * uv.z(); + n_at->x() -= shift * uv.x(); + n_at->y() -= shift * uv.y(); + n_at->z() -= shift * uv.z(); } } } @@ -6339,8 +6339,8 @@ coot::util::peptide_C_N_pairs(mmdb::Chain *chain_p) { if (c_first) { if (n_next) { if (! c_first->isTer() && ! n_next->isTer()) { - std::string alt_conf_1(c_first->altLoc); - std::string alt_conf_2(n_next->altLoc); + std::string alt_conf_1(c_first->altLoc()); + std::string alt_conf_2(n_next->altLoc()); if (alt_conf_1.empty() || alt_conf_2.empty() || alt_conf_1 == alt_conf_2) { clipper::Coord_orth pt_1 = co(c_first); clipper::Coord_orth pt_2 = co(n_next); @@ -6453,10 +6453,10 @@ coot::util::cis_peptides_info_from_coords(mmdb::Manager *mol) { } } if (! is_ter) { - clipper::Coord_orth caf(ca_first->x, ca_first->y, ca_first->z); - clipper::Coord_orth cf( c_first->x, c_first->y, c_first->z); - clipper::Coord_orth can( ca_next->x, ca_next->y, ca_next->z); - clipper::Coord_orth nn( n_next->x, n_next->y, n_next->z); + clipper::Coord_orth caf(ca_first->x(), ca_first->y(), ca_first->z()); + clipper::Coord_orth cf( c_first->x(), c_first->y(), c_first->z()); + clipper::Coord_orth can( ca_next->x(), ca_next->y(), ca_next->z()); + clipper::Coord_orth nn( n_next->x(), n_next->y(), n_next->z()); double tors = clipper::Coord_orth::torsion(caf, cf, nn, can); double torsion = clipper::Util::rad2d(tors); double pos_torsion = (torsion > 0.0) ? torsion : 360.0 + torsion; @@ -6692,7 +6692,7 @@ coot::util::cis_trans_convert(std::pair mol_re int n_residue_atoms; mol_residues.first->GetAtomTable(mol_residue_atoms, n_residue_atoms); for (int i=0; iname; + std::string atom_name = mol_residue_atoms[i]->GetAtomName(); if (atom_name == " CA ") { mol_residue_CA_1 = mol_residue_atoms[i]; } @@ -6706,7 +6706,7 @@ coot::util::cis_trans_convert(std::pair mol_re mol_residue_atoms = NULL; mol_residues.second->GetAtomTable(mol_residue_atoms, n_residue_atoms); for (int i=0; iname; + std::string atom_name = mol_residue_atoms[i]->GetAtomName(); if (atom_name == " CA ") { mol_residue_CA_2 = mol_residue_atoms[i]; } @@ -6735,7 +6735,7 @@ coot::util::cis_trans_convert(std::pair mol_re cis_trans_init_match[0]->GetAtomTable(cis_trans_init_match_residue_atoms, n_residue_atoms); for (int i=0; iname; + std::string atom_name = cis_trans_init_match_residue_atoms[i]->GetAtomName(); if (atom_name == " CA ") { cis_trans_init_match_residue_CA_1 = cis_trans_init_match_residue_atoms[i]; } @@ -6750,7 +6750,7 @@ coot::util::cis_trans_convert(std::pair mol_re cis_trans_init_match[1]->GetAtomTable(cis_trans_init_match_residue_atoms, n_residue_atoms); for (int i=0; iname; + std::string atom_name = cis_trans_init_match_residue_atoms[i]->GetAtomName(); if (atom_name == " CA ") { cis_trans_init_match_residue_CA_2 = cis_trans_init_match_residue_atoms[i]; } @@ -6779,7 +6779,7 @@ coot::util::cis_trans_convert(std::pair mol_re converted_residues[0]->GetAtomTable(converted_residues_residue_atoms, n_residue_atoms_converted); for (int i=0; iname; + std::string atom_name = converted_residues_residue_atoms[i]->GetAtomName(); if (atom_name == " CA ") { converted_residues_residue_CA_1 = converted_residues_residue_atoms[i]; } @@ -6795,7 +6795,7 @@ coot::util::cis_trans_convert(std::pair mol_re converted_residues[1]->GetAtomTable(converted_residues_residue_atoms, n_residue_atoms_converted); for (int i=0; iname; + std::string atom_name = converted_residues_residue_atoms[i]->GetAtomName(); if (atom_name == " CA ") { converted_residues_residue_CA_2 = converted_residues_residue_atoms[i]; } @@ -6814,61 +6814,61 @@ coot::util::cis_trans_convert(std::pair mol_re std::vector cis_trans_init; std::vector converted; - current.push_back(clipper::Coord_orth(mol_residue_CA_1->x, - mol_residue_CA_1->y, - mol_residue_CA_1->z)); - current.push_back(clipper::Coord_orth(mol_residue_C_1->x, - mol_residue_C_1->y, - mol_residue_C_1->z)); - current.push_back(clipper::Coord_orth(mol_residue_O_1->x, - mol_residue_O_1->y, - mol_residue_O_1->z)); - current.push_back(clipper::Coord_orth(mol_residue_CA_2->x, - mol_residue_CA_2->y, - mol_residue_CA_2->z)); - current.push_back(clipper::Coord_orth(mol_residue_N_2->x, - mol_residue_N_2->y, - mol_residue_N_2->z)); - - cis_trans_init.push_back(clipper::Coord_orth(cis_trans_init_match_residue_CA_1->x, - cis_trans_init_match_residue_CA_1->y, - cis_trans_init_match_residue_CA_1->z)); - - cis_trans_init.push_back(clipper::Coord_orth(cis_trans_init_match_residue_C_1->x, - cis_trans_init_match_residue_C_1->y, - cis_trans_init_match_residue_C_1->z)); - - cis_trans_init.push_back(clipper::Coord_orth(cis_trans_init_match_residue_O_1->x, - cis_trans_init_match_residue_O_1->y, - cis_trans_init_match_residue_O_1->z)); - - cis_trans_init.push_back(clipper::Coord_orth(cis_trans_init_match_residue_CA_2->x, - cis_trans_init_match_residue_CA_2->y, - cis_trans_init_match_residue_CA_2->z)); - - cis_trans_init.push_back(clipper::Coord_orth(cis_trans_init_match_residue_N_2->x, - cis_trans_init_match_residue_N_2->y, - cis_trans_init_match_residue_N_2->z)); - - converted.push_back(clipper::Coord_orth(converted_residues_residue_CA_1->x, - converted_residues_residue_CA_1->y, - converted_residues_residue_CA_1->z)); - - converted.push_back(clipper::Coord_orth(converted_residues_residue_C_1->x, - converted_residues_residue_C_1->y, - converted_residues_residue_C_1->z)); - - converted.push_back(clipper::Coord_orth(converted_residues_residue_O_1->x, - converted_residues_residue_O_1->y, - converted_residues_residue_O_1->z)); - - converted.push_back(clipper::Coord_orth(converted_residues_residue_CA_2->x, - converted_residues_residue_CA_2->y, - converted_residues_residue_CA_2->z)); - - converted.push_back(clipper::Coord_orth(converted_residues_residue_N_2->x, - converted_residues_residue_N_2->y, - converted_residues_residue_N_2->z)); + current.push_back(clipper::Coord_orth(mol_residue_CA_1->x(), + mol_residue_CA_1->y(), + mol_residue_CA_1->z())); + current.push_back(clipper::Coord_orth(mol_residue_C_1->x(), + mol_residue_C_1->y(), + mol_residue_C_1->z())); + current.push_back(clipper::Coord_orth(mol_residue_O_1->x(), + mol_residue_O_1->y(), + mol_residue_O_1->z())); + current.push_back(clipper::Coord_orth(mol_residue_CA_2->x(), + mol_residue_CA_2->y(), + mol_residue_CA_2->z())); + current.push_back(clipper::Coord_orth(mol_residue_N_2->x(), + mol_residue_N_2->y(), + mol_residue_N_2->z())); + + cis_trans_init.push_back(clipper::Coord_orth(cis_trans_init_match_residue_CA_1->x(), + cis_trans_init_match_residue_CA_1->y(), + cis_trans_init_match_residue_CA_1->z())); + + cis_trans_init.push_back(clipper::Coord_orth(cis_trans_init_match_residue_C_1->x(), + cis_trans_init_match_residue_C_1->y(), + cis_trans_init_match_residue_C_1->z())); + + cis_trans_init.push_back(clipper::Coord_orth(cis_trans_init_match_residue_O_1->x(), + cis_trans_init_match_residue_O_1->y(), + cis_trans_init_match_residue_O_1->z())); + + cis_trans_init.push_back(clipper::Coord_orth(cis_trans_init_match_residue_CA_2->x(), + cis_trans_init_match_residue_CA_2->y(), + cis_trans_init_match_residue_CA_2->z())); + + cis_trans_init.push_back(clipper::Coord_orth(cis_trans_init_match_residue_N_2->x(), + cis_trans_init_match_residue_N_2->y(), + cis_trans_init_match_residue_N_2->z())); + + converted.push_back(clipper::Coord_orth(converted_residues_residue_CA_1->x(), + converted_residues_residue_CA_1->y(), + converted_residues_residue_CA_1->z())); + + converted.push_back(clipper::Coord_orth(converted_residues_residue_C_1->x(), + converted_residues_residue_C_1->y(), + converted_residues_residue_C_1->z())); + + converted.push_back(clipper::Coord_orth(converted_residues_residue_O_1->x(), + converted_residues_residue_O_1->y(), + converted_residues_residue_O_1->z())); + + converted.push_back(clipper::Coord_orth(converted_residues_residue_CA_2->x(), + converted_residues_residue_CA_2->y(), + converted_residues_residue_CA_2->z())); + + converted.push_back(clipper::Coord_orth(converted_residues_residue_N_2->x(), + converted_residues_residue_N_2->y(), + converted_residues_residue_N_2->z())); clipper::RTop_orth lsq_mat(cis_trans_init, current); @@ -6879,29 +6879,29 @@ coot::util::cis_trans_convert(std::pair mol_re clipper::Coord_orth newpos; newpos = converted[0].transform(lsq_mat); - mol_residue_CA_1->x = newpos.x(); - mol_residue_CA_1->y = newpos.y(); - mol_residue_CA_1->z = newpos.z(); + mol_residue_CA_1->x() = newpos.x(); + mol_residue_CA_1->y() = newpos.y(); + mol_residue_CA_1->z() = newpos.z(); newpos = converted[1].transform(lsq_mat); - mol_residue_C_1->x = newpos.x(); - mol_residue_C_1->y = newpos.y(); - mol_residue_C_1->z = newpos.z(); + mol_residue_C_1->x() = newpos.x(); + mol_residue_C_1->y() = newpos.y(); + mol_residue_C_1->z() = newpos.z(); newpos = converted[2].transform(lsq_mat); - mol_residue_O_1->x = newpos.x(); - mol_residue_O_1->y = newpos.y(); - mol_residue_O_1->z = newpos.z(); + mol_residue_O_1->x() = newpos.x(); + mol_residue_O_1->y() = newpos.y(); + mol_residue_O_1->z() = newpos.z(); newpos = converted[3].transform(lsq_mat); - mol_residue_CA_2->x = newpos.x(); - mol_residue_CA_2->y = newpos.y(); - mol_residue_CA_2->z = newpos.z(); + mol_residue_CA_2->x() = newpos.x(); + mol_residue_CA_2->y() = newpos.y(); + mol_residue_CA_2->z() = newpos.z(); newpos = converted[4].transform(lsq_mat); - mol_residue_N_2->x = newpos.x(); - mol_residue_N_2->y = newpos.y(); - mol_residue_N_2->z = newpos.z(); + mol_residue_N_2->x() = newpos.x(); + mol_residue_N_2->y() = newpos.y(); + mol_residue_N_2->z() = newpos.z(); if (mol_residue_H_2) { // 20180510 place H on N as a riding atom, not using transformation @@ -6911,9 +6911,9 @@ coot::util::cis_trans_convert(std::pair mol_re double bl = 0.86; double angle = clipper::Util::d2rad(125.0); clipper::Coord_orth H_pos(at_ca_pos, at_c_pos, at_n_pos, bl, angle, M_PI); - mol_residue_H_2->x = H_pos.x(); - mol_residue_H_2->y = H_pos.y(); - mol_residue_H_2->z = H_pos.z(); + mol_residue_H_2->x() = H_pos.x(); + mol_residue_H_2->y() = H_pos.y(); + mol_residue_H_2->z() = H_pos.z(); } istatus = 1; } @@ -7167,14 +7167,14 @@ coot::mol_by_symmetry(mmdb::Manager *mol, int n_atoms = residue_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - clipper::Coord_orth co(at->x, at->y, at->z); + clipper::Coord_orth co(at->x(), at->y(), at->z()); co -= origin_shift_orth; clipper::Coord_orth to = co.transform(rtop); to += origin_shift_orth; // std::cout << " atom from " // << at->x << " " << at->y << " " << at->z << " " // << " to " << to.format() << std::endl; - at->x = to.x(); at->y = to.y(); at->z = to.z(); + at->x() = to.x(); at->y() = to.y(); at->z() = to.z(); } } } @@ -7471,7 +7471,7 @@ coot::util::move_waters_around_protein(mmdb::Manager *mol) { for (int ires=0; iresGetResidue(ires); int n_atoms = residue_p->GetNumberOfAtoms(); - std::string residue_name(residue_p->name); + std::string residue_name(residue_p->GetResName()); if (residue_name == "WAT" || residue_name == "HOH") { @@ -7479,7 +7479,7 @@ coot::util::move_waters_around_protein(mmdb::Manager *mol) { at = residue_p->GetAtom(iat); if (! at->isTer()) { at = residue_p->GetAtom(iat); - clipper::Coord_orth c(at->x, at->y, at->z); + clipper::Coord_orth c(at->x(), at->y(), at->z()); std::pair pair(at, c); water_atoms.push_back(pair); } @@ -7488,9 +7488,9 @@ coot::util::move_waters_around_protein(mmdb::Manager *mol) { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - std::string ele(at->element); + std::string ele(at->GetElementName()); if (ele != " C") { - clipper::Coord_orth pt(at->x, at->y, at->z); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); protein_coords.push_back(pt); } } @@ -7520,9 +7520,9 @@ coot::util::move_waters_around_protein(mmdb::Manager *mol) { for (unsigned int iw=0; iwx = water_atoms_moved[iw].second.x(); - water_atoms_moved[iw].first->y = water_atoms_moved[iw].second.y(); - water_atoms_moved[iw].first->z = water_atoms_moved[iw].second.z(); + water_atoms_moved[iw].first->x() = water_atoms_moved[iw].second.x(); + water_atoms_moved[iw].first->y() = water_atoms_moved[iw].second.y(); + water_atoms_moved[iw].first->z() = water_atoms_moved[iw].second.z(); n_moved++; } } @@ -7581,9 +7581,9 @@ coot::util::move_hetgroups_around_protein(mmdb::Manager *mol) { for (int iat=0; iatGetAtom(iat); if (! at->Het) { - std::string element(at->element); + std::string element(at->GetElementName()); if (element != "C" && element != " C") { - clipper::Coord_orth pt(at->x, at->y, at->z); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); protein_coords.push_back(pt); } } @@ -7600,7 +7600,7 @@ coot::util::move_hetgroups_around_protein(mmdb::Manager *mol) { mmdb::Atom *at = 0; for (int ires=0; iresGetResidue(ires); - std::string residue_name(residue_p->name); + std::string residue_name(residue_p->GetResName()); if (residue_name == "WAT" || residue_name == "HOH") { // Waters are handled above. @@ -7616,9 +7616,9 @@ coot::util::move_hetgroups_around_protein(mmdb::Manager *mol) { int n_residue_atoms; residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatx, - residue_atoms[iat]->y, - residue_atoms[iat]->z); + clipper::Coord_orth co(residue_atoms[iat]->x(), + residue_atoms[iat]->y(), + residue_atoms[iat]->z()); std::pair p(residue_atoms[iat], co); hetgroup_atoms.push_back(p); } @@ -7628,9 +7628,9 @@ coot::util::move_hetgroups_around_protein(mmdb::Manager *mol) { for (unsigned int iw=0; iwx = atoms_moved[iw].second.x(); - atoms_moved[iw].first->y = atoms_moved[iw].second.y(); - atoms_moved[iw].first->z = atoms_moved[iw].second.z(); + atoms_moved[iw].first->x() = atoms_moved[iw].second.x(); + atoms_moved[iw].first->y() = atoms_moved[iw].second.y(); + atoms_moved[iw].first->z() = atoms_moved[iw].second.z(); } } } @@ -7831,11 +7831,11 @@ coot::util::residue_orientation(mmdb::Residue *residue_p, const clipper::Mat33GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; ix, - residue_atoms[i]->y, - residue_atoms[i]->z)); + pts.push_back(clipper::Coord_orth(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z())); } else { - std::string atom_name(residue_atoms[i]->name); + std::string atom_name(residue_atoms[i]->GetAtomName()); if (atom_name == " CA ") ca = residue_atoms[i]; if (atom_name == " N ") @@ -7846,13 +7846,13 @@ coot::util::residue_orientation(mmdb::Residue *residue_p, const clipper::Mat33 0) { if (ca) { - clipper::Coord_orth ca_pos(ca->x, ca->y, ca->z); + clipper::Coord_orth ca_pos(ca->x(), ca->y(), ca->z()); clipper::Coord_orth average_pos = coot::util::average_position(pts); clipper::Coord_orth u((average_pos-ca_pos).unit()); // reset n_vect to something sensible, if we have the CA and N. if (ca && n) { - clipper::Coord_orth n_pos( n->x, n->y, n->z); + clipper::Coord_orth n_pos( n->x(), n->y(), n->z()); n_vec = n_pos - ca_pos; } @@ -7972,9 +7972,9 @@ coot::util::median_position(mmdb::Manager *mol) { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - pts_x.push_back(at->x); - pts_y.push_back(at->y); - pts_z.push_back(at->z); + pts_x.push_back(at->x()); + pts_y.push_back(at->y()); + pts_z.push_back(at->z()); } } } @@ -8112,9 +8112,9 @@ coot::centre_of_molecule(mmdb::Manager *mol) { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - xs += at->x; - ys += at->y; - zs += at->z; + xs += at->x(); + ys += at->y(); + zs += at->z(); n_atoms++; } } @@ -8174,12 +8174,12 @@ coot::centre_of_molecule_using_masses(mmdb::Manager *mol) { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - std::string ele = at->element; + std::string ele = at->GetElementName(); double w = 6.0; std::map::const_iterator it; it = pdb_element_weights.find(ele); if (it != pdb_element_weights.end()) w = it->second; - xs += w * at->x; ys += w * at->y; zs += w * at->z; + xs += w * at->x(); ys += w * at->y(); zs += w * at->z(); sum_weight += w; n_atoms++; } @@ -8243,12 +8243,12 @@ coot::radius_of_gyration(mmdb::Manager *mol) { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - std::string ele = at->element; + std::string ele = at->GetElementName(); double w = 14.0; std::map::const_iterator it; it = pdb_element_weights.find(ele); if (it != pdb_element_weights.end()) w = it->second; - clipper::Coord_orth pt(at->x, at->y, at->z); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); clipper::Coord_orth delta = pt - centre; double dd = delta.lengthsq(); sum_dd += dd * w; @@ -8290,12 +8290,12 @@ coot::hiranuma_inversion(mmdb::Manager *mol) { mmdb::Atom *at = residue_p->GetAtom(iat); if (! at) continue; if (at->isTer()) continue; - double plddt = at->tempFactor; + double plddt = at->tempFactor(); if (plddt < 0.0) plddt = 0.0; if (plddt > 100.0) plddt = 100.0; double rmsd = 1.5 * std::exp(4.0 * (0.7 - plddt / 100.0)); double b = eight_pi_sq_over_3 * rmsd * rmsd; - at->tempFactor = static_cast(b); + at->tempFactor() = static_cast(b); } } } @@ -8317,9 +8317,9 @@ coot::centre_of_residues(const std::vector &residues) { int n_residue_atoms; residues[ires]->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatx; - ys += residue_atoms[iat]->y; - zs += residue_atoms[iat]->z; + xs += residue_atoms[iat]->x(); + ys += residue_atoms[iat]->y(); + zs += residue_atoms[iat]->z(); n_atoms++; } } @@ -8501,7 +8501,7 @@ coot::position_residue_by_internal_coordinates::get_atom(mmdb::Residue *res_1, residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); + std::string atom_name(atom->GetAtomName()); if (atom_name == torsion_atom_name) { at = atom; break; @@ -8519,9 +8519,9 @@ coot::arc_info_type::arc_info_type(mmdb::Atom *at_1, mmdb::Atom *at_2, mmdb::Ato if (! at_2) throw("null at_2"); if (! at_3) throw("null at_3"); - clipper::Coord_orth p1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth p2(at_2->x, at_2->y, at_2->z); - clipper::Coord_orth p3(at_3->x, at_3->y, at_3->z); + clipper::Coord_orth p1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth p2(at_2->x(), at_2->y(), at_2->z()); + clipper::Coord_orth p3(at_3->x(), at_3->y(), at_3->z()); clipper::Coord_orth v1(clipper::Coord_orth(p3 - p2).unit()); clipper::Coord_orth v2(clipper::Coord_orth(p1 - p2).unit()); // vectors away from central atom @@ -8543,14 +8543,14 @@ coot::arc_info_type::arc_info_type(mmdb::Atom *at_1, mmdb::Atom *at_2, mmdb::Ato clipper::Coord_orth coot::co(mmdb::Atom *at) { - return clipper::Coord_orth(at->x, at->y, at->z); + return clipper::Coord_orth(at->x(), at->y(), at->z()); } void coot::update_position(mmdb::Atom *at, const clipper::Coord_orth &pos) { - at->x = pos.x(); - at->y = pos.y(); - at->z = pos.z(); + at->x() = pos.x(); + at->y() = pos.y(); + at->z() = pos.z(); } @@ -8567,7 +8567,7 @@ coot::chiral_4th_atom(mmdb::Residue *residue_p, mmdb::Atom *at_centre, mmdb::PPAtom residue_atoms = 0; int n_residue_atoms; clipper::Coord_orth p_c = co(at_centre); - std::string alt_conf = at_centre->altLoc; + std::string alt_conf = at_centre->altLoc(); residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iattempFactor / (8 * M_PI * M_PI); + double u = at->tempFactor() / (8 * M_PI * M_PI); double v = 2 * u; v = std::max(v, 0.38); // don't have tiny atoms @@ -8845,8 +8845,8 @@ coot::interface_residues(mmdb::Manager *mol, for (int i=0; iresidue; - mmdb::Residue *r_2 = at_2->residue; + mmdb::Residue *r_1 = at_1->GetResidue(); + mmdb::Residue *r_2 = at_2->GetResidue(); mmdb::Chain *ch_1 = r_1->chain; mmdb::Chain *ch_2 = r_2->chain; if (r_1 != r_2) { @@ -8920,9 +8920,9 @@ coot::util::copy_atoms_from_chain_to_chain(mmdb::Chain *from_chain, mmdb::Chain for (int iat=0; iatGetAtom(iat); mmdb::Atom *at_to = residue_to_p->GetAtom(iat); - at_to->x = at_from->x; - at_to->y = at_from->y; - at_to->z = at_from->z; + at_to->x() = at_from->x(); + at_to->y() = at_from->y(); + at_to->z() = at_from->z(); } } else { std::cout << "ERROR:: mismatching atom count in copy_atoms_from_chain_to_chain() " << std::endl; @@ -8981,10 +8981,10 @@ coot::get_position_hash(mmdb::Manager *mol) { mmdb::Atom *at = residue_p->GetAtom(iat); if (! at->isTer()) { if (atom_count > 0) { - h += at->x - x_prev; + h += at->x() - x_prev; } atom_count++; - x_prev = at->x; + x_prev = at->x(); } } } @@ -9013,7 +9013,7 @@ coot::atoms_with_zero_occupancy(mmdb::Manager *mol) { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - if (at->occupancy < 0.01) { + if (at->occupancy() < 0.01) { v.push_back(at); } } @@ -9045,7 +9045,7 @@ coot::residues_with_alt_confs(mmdb::Manager *mol) { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - std::string a(at->altLoc); + std::string a(at->altLoc()); if (a.length() > 0) { found = true; break; @@ -9217,7 +9217,7 @@ coot::util::alt_confs_in_molecule(mmdb::Manager *mol) { int n_atoms = residue_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - std::string alt_conf(at->altLoc); + std::string alt_conf(at->altLoc()); if (! at->isTer()) { s.insert(alt_conf); } diff --git a/coot-utils/coot-fffear.cc b/coot-utils/coot-fffear.cc index 089be12801..16ed4f04d1 100644 --- a/coot-utils/coot-fffear.cc +++ b/coot-utils/coot-fffear.cc @@ -263,11 +263,11 @@ coot::util::fffear_search::fill_nxmap(mmdb::Manager *mol, int SelectionHandle, clipper::NXmap::Map_reference_coord i0, iu, iv, iw; for ( int i = 0; i < n_atoms; i++ ) if ( atom_selection[i] ) { - clipper::Coord_orth p(atom_selection[i]->x, atom_selection[i]->y, atom_selection[i]->z); + clipper::Coord_orth p(atom_selection[i]->x(), atom_selection[i]->y(), atom_selection[i]->z()); p -= mid_point; - clipper::AtomShapeFn sf( p, std::string(atom_selection[i]->element), - atom_selection[i]->tempFactor, - atom_selection[i]->occupancy); + clipper::AtomShapeFn sf( p, std::string(atom_selection[i]->GetElementName()), + atom_selection[i]->tempFactor(), + atom_selection[i]->occupancy()); g0 = nxmap.coord_map(p).coord_grid() + gd.min(); g1 = nxmap.coord_map(p).coord_grid() + gd.max(); i0 = clipper::NXmap::Map_reference_coord( nxmap, g0 ); @@ -337,7 +337,7 @@ coot::util::fffear_search::fill_nxmap_mask(mmdb::Manager *mol, int SelectionHand clipper::NXmap::Map_reference_coord i0, iu, iv, iw; for ( int i = 0; i < n_atoms; i++ ) if ( atom_selection[i] ) { - clipper::Coord_orth xyz(atom_selection[i]->x, atom_selection[i]->y, atom_selection[i]->z); + clipper::Coord_orth xyz(atom_selection[i]->x(), atom_selection[i]->y(), atom_selection[i]->z()); xyz -= mid_point; g0 = nxmap.coord_map( xyz ).coord_grid() + gd.min(); g1 = nxmap.coord_map( xyz ).coord_grid() + gd.max(); diff --git a/coot-utils/coot-h-bonds.cc b/coot-utils/coot-h-bonds.cc index 006101c1cd..35e69c5fea 100644 --- a/coot-utils/coot-h-bonds.cc +++ b/coot-utils/coot-h-bonds.cc @@ -382,13 +382,13 @@ coot::h_bonds::get_mcdonald_and_thornton(int selHnd_1, int selHnd_2, mmdb::Manag mmdb::Atom *at_2 = sel_2_atoms[pscontact[i_contact].id2]; // move on if these are interacting atoms - std::string alt_conf_1 = at_1->altLoc; - std::string alt_conf_2 = at_2->altLoc; + std::string alt_conf_1 = at_1->altLoc(); + std::string alt_conf_2 = at_2->altLoc(); if (!alt_conf_1.empty() && ! alt_conf_2.empty()) if (alt_conf_1 != alt_conf_2) continue; - if (at_1->residue != at_2->residue) { + if (at_1->GetResidue() != at_2->GetResidue()) { // are they HB_HYDROGEN and HB_ACCEPTOR? // @@ -729,7 +729,7 @@ coot::h_bonds::mark_donors_and_acceptors(int selHnd_1, int selHnd_2, mmdb::Manag int udd_h_bond_type_handle = mol->RegisterUDInteger(mmdb::UDR_ATOM, "hb_type"); for (int i=0; iname; + std::string name = sel_1_atoms[i]->GetAtomName(); std::string res_name = sel_1_atoms[i]->GetResName(); int h_bond_type = geom.get_h_bond_type(name, res_name, imol); @@ -745,7 +745,7 @@ coot::h_bonds::mark_donors_and_acceptors(int selHnd_1, int selHnd_2, mmdb::Manag if (selHnd_1 != selHnd_2) { for (int i=0; iname; + std::string name = sel_2_atoms[i]->GetAtomName(); std::string res_name = sel_2_atoms[i]->GetResName(); int h_bond_type = geom.get_h_bond_type(name, res_name, imol); sel_2_atoms[i]->PutUDData(udd_h_bond_type_handle, h_bond_type); @@ -795,12 +795,12 @@ coot::h_bonds::make_neighbour_map(int selHnd_1, int selHnd_2, mmdb::Manager *mol if (n_contacts) { if (pscontact) { for (int i_contact=0; i_contactx, - sel_1_atoms[pscontact[i_contact].id1]->y, - sel_1_atoms[pscontact[i_contact].id1]->z); - clipper::Coord_orth pt_2(sel_1_atoms[pscontact[i_contact].id2]->x, - sel_1_atoms[pscontact[i_contact].id2]->y, - sel_1_atoms[pscontact[i_contact].id2]->z); + clipper::Coord_orth pt_1(sel_1_atoms[pscontact[i_contact].id1]->x(), + sel_1_atoms[pscontact[i_contact].id1]->y(), + sel_1_atoms[pscontact[i_contact].id1]->z()); + clipper::Coord_orth pt_2(sel_1_atoms[pscontact[i_contact].id2]->x(), + sel_1_atoms[pscontact[i_contact].id2]->y(), + sel_1_atoms[pscontact[i_contact].id2]->z()); float d = clipper::Coord_orth::length(pt_1, pt_2); coot::residue_spec_t res_1(sel_1_atoms[pscontact[i_contact].id1]->GetResidue()); coot::residue_spec_t res_2(sel_1_atoms[pscontact[i_contact].id2]->GetResidue()); @@ -829,12 +829,12 @@ coot::h_bonds::make_neighbour_map(int selHnd_1, int selHnd_2, mmdb::Manager *mol if (n_contacts) { if (pscontact) { for (int i_contact=0; i_contactx, - sel_2_atoms[pscontact[i_contact].id1]->y, - sel_2_atoms[pscontact[i_contact].id1]->z); - clipper::Coord_orth pt_2(sel_2_atoms[pscontact[i_contact].id2]->x, - sel_2_atoms[pscontact[i_contact].id2]->y, - sel_2_atoms[pscontact[i_contact].id2]->z); + clipper::Coord_orth pt_1(sel_2_atoms[pscontact[i_contact].id1]->x(), + sel_2_atoms[pscontact[i_contact].id1]->y(), + sel_2_atoms[pscontact[i_contact].id1]->z()); + clipper::Coord_orth pt_2(sel_2_atoms[pscontact[i_contact].id2]->x(), + sel_2_atoms[pscontact[i_contact].id2]->y(), + sel_2_atoms[pscontact[i_contact].id2]->z()); coot::residue_spec_t res_1(sel_2_atoms[pscontact[i_contact].id1]->GetResidue()); coot::residue_spec_t res_2(sel_2_atoms[pscontact[i_contact].id2]->GetResidue()); diff --git a/coot-utils/coot-map-heavy.cc b/coot-utils/coot-map-heavy.cc index 218cda4927..ec094e4722 100644 --- a/coot-utils/coot-map-heavy.cc +++ b/coot-utils/coot-map-heavy.cc @@ -62,9 +62,9 @@ coot::util::fit_to_map_by_simplex_rigid(mmdb::PPAtom atom_selection, par.orig_atoms = atom_selection; clipper::Coord_orth co(0.0, 0.0, 0.0); for (int i=0; ix, - atom_selection[i]->y, - atom_selection[i]->z); + co += clipper::Coord_orth(atom_selection[i]->x(), + atom_selection[i]->y(), + atom_selection[i]->z()); co = 1/float(n_selected_atoms) * co; par.atoms_centre = co; par.xmap = ⟼ @@ -167,16 +167,16 @@ coot::util::simplex_apply_shifts_rigid_internal(gsl_vector *s, for (int i=0; ix, - par.orig_atoms[i]->y, - par.orig_atoms[i]->z); + clipper::Coord_orth orig_p(par.orig_atoms[i]->x(), + par.orig_atoms[i]->y(), + par.orig_atoms[i]->z()); clipper::Coord_orth point = orig_p.transform(rtop); point = par.atoms_centre + (orig_p - par.atoms_centre).transform(rtop); - par.orig_atoms[i]->x = point.x(); - par.orig_atoms[i]->y = point.y(); - par.orig_atoms[i]->z = point.z(); + par.orig_atoms[i]->x() = point.x(); + par.orig_atoms[i]->y() = point.y(); + par.orig_atoms[i]->z() = point.z(); } } @@ -220,9 +220,9 @@ coot::util::my_f_simplex_rigid_internal (const gsl_vector *v, for (int i=0; in_atoms; i++) { - clipper::Coord_orth orig_p(p->orig_atoms[i]->x, - p->orig_atoms[i]->y, - p->orig_atoms[i]->z); + clipper::Coord_orth orig_p(p->orig_atoms[i]->x(), + p->orig_atoms[i]->y(), + p->orig_atoms[i]->z()); point = p->atoms_centre + (orig_p - p->atoms_centre).transform(rtop); // we are trying to minimize, don't forget: @@ -278,8 +278,8 @@ coot::util::z_weighted_density_score(const std::vector &atoms, const clipper::Xmap &map) { float sum_d = 0; for (unsigned int iat=0; iatx, atoms[iat]->y, atoms[iat]->z); - float d = z_weighted_density_at_point(co, atoms[iat]->element, atom_number_list, map); + clipper::Coord_orth co(atoms[iat]->x(), atoms[iat]->y(), atoms[iat]->z()); + float d = z_weighted_density_at_point(co, atoms[iat]->GetElementName(), atom_number_list, map); sum_d += d; } return sum_d; @@ -332,7 +332,7 @@ coot::util::z_weighted_density_score_new(const std::vectorx, at->y, at->z); + clipper::Coord_orth co(at->x(), at->y(), at->z()); float d = coot::util::density_at_point(map, co) * atom_atom_number_pairs[iat].second; sum_d += d; } @@ -348,12 +348,12 @@ coot::util::debug_z_weighted_density_score_new(const std::vector(atc); - clipper::Coord_orth co(at->x, at->y, at->z); + clipper::Coord_orth co(at->x(), at->y(), at->z()); float d = coot::util::density_at_point(map, co); float w = atom_atom_number_pairs[iat].second; sum_d += d * w; std::cout << "debug score " << iat << " " << atom_spec_t(at) - << " pos " << at->x << " " << at->y << " " << at->z + << " pos " << at->x() << " " << at->y() << " " << at->z() << " weight: " << w << " density:" << d << " running sum " << sum_d << std::endl; } std::cout << "debug:: debug_z_weighted_density_score_new(): total: " << sum_d << std::endl; @@ -418,14 +418,14 @@ coot::util::jiggle_atoms(const std::vector &atoms, // now apply rtop to atoms (shift the atoms relative to the // centre_pt before doing the wiggle for (unsigned int i=0; ix - centre_pt.x(), - atoms[i]->y - centre_pt.y(), - atoms[i]->z - centre_pt.z()); + clipper::Coord_orth pt_rel(atoms[i]->x() - centre_pt.x(), + atoms[i]->y() - centre_pt.y(), + atoms[i]->z() - centre_pt.z()); clipper::Coord_orth new_pt = pt_rel.transform(rtop); new_pt += centre_pt; - new_atoms[i].x = new_pt.x(); - new_atoms[i].y = new_pt.y(); - new_atoms[i].z = new_pt.z(); + new_atoms[i].x() = new_pt.x(); + new_atoms[i].y() = new_pt.y(); + new_atoms[i].z() = new_pt.z(); } return std::pair > (rtop, new_atoms); } @@ -447,14 +447,14 @@ coot::util::jiggle_atoms(const std::vector &atoms, // centre_pt before doing the wiggle clipper::RTop_orth rtop = make_rtop_orth_for_jiggle_atoms(jiggle_trans_scale_factor, annealing_factor); for (unsigned int i=0; i > (rtop, new_atoms); } @@ -772,12 +772,12 @@ coot::util::make_edcalc_map(const clipper::NXmap& map_ref, // for metric mol->GetSelIndex(atom_selection_handle, sel_atoms, n_sel_atoms); for (int ii=0; iielement); - clipper::Coord_orth pt(at->x, at->y, at->z); + std::string ele(at->GetElementName()); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); clipper::Atom cat; cat.set_element(ele); cat.set_coord_orth(pt); - cat.set_u_iso(at->tempFactor * 0.0125); + cat.set_u_iso(at->tempFactor() * 0.0125); // cat.set_u_iso(0.1); cat.set_occupancy(1.0); l.push_back(cat); diff --git a/coot-utils/coot-map-utils.cc b/coot-utils/coot-map-utils.cc index e6dec99493..40e402f30b 100644 --- a/coot-utils/coot-map-utils.cc +++ b/coot-utils/coot-map-utils.cc @@ -441,10 +441,10 @@ coot::util::map_score(mmdb::PPAtom atom_selection, for (int i=0; iisTer()) { - f1 = density_at_point(xmap, clipper::Coord_orth(atom_selection[i]->x, - atom_selection[i]->y, - atom_selection[i]->z)); - f1 *= atom_selection[i]->occupancy; + f1 = density_at_point(xmap, clipper::Coord_orth(atom_selection[i]->x(), + atom_selection[i]->y(), + atom_selection[i]->z())); + f1 *= atom_selection[i]->occupancy(); f += f1; // std::cout << "debug:: map_score() adding " << atom_spec_t(at) << " f1 " << f1 << std::endl; } @@ -460,7 +460,7 @@ coot::util::map_score(std::vector atoms, for (unsigned int i=0; ioccupancy; + f1 *= atoms[i]->occupancy(); f += f1; } } @@ -473,7 +473,7 @@ float coot::util::map_score_atom(mmdb::Atom *atom, float f = 0; if (atom) { - f = density_at_point(xmap, clipper::Coord_orth(atom->x, atom->y, atom->z)); + f = density_at_point(xmap, clipper::Coord_orth(atom->x(), atom->y(), atom->z())); } return f; } @@ -1069,10 +1069,10 @@ coot::util::spin_search(const clipper::Xmap &xmap, mmdb::Residue *res, co std::cout << " (found " << match_atoms.size() << " atoms.)" << std::endl; } else { - clipper::Coord_orth pa1(match_atoms[0]->x, match_atoms[0]->y, match_atoms[0]->z); - clipper::Coord_orth pa2(match_atoms[1]->x, match_atoms[1]->y, match_atoms[1]->z); - clipper::Coord_orth pa3(match_atoms[2]->x, match_atoms[2]->y, match_atoms[2]->z); - clipper::Coord_orth pa4(match_atoms[3]->x, match_atoms[3]->y, match_atoms[3]->z); + clipper::Coord_orth pa1(match_atoms[0]->x(), match_atoms[0]->y(), match_atoms[0]->z()); + clipper::Coord_orth pa2(match_atoms[1]->x(), match_atoms[1]->y(), match_atoms[1]->z()); + clipper::Coord_orth pa3(match_atoms[2]->x(), match_atoms[2]->y(), match_atoms[2]->z()); + clipper::Coord_orth pa4(match_atoms[3]->x(), match_atoms[3]->y(), match_atoms[3]->z()); float best_d = -99999999.9; clipper::Coord_orth best_pos; @@ -1280,8 +1280,8 @@ coot::util::backrub_residue_triple_t::trim_residue_atoms_generic(mmdb::Residue * int n_residue_atoms; residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; iname); - std::string atom_alt_conf(residue_atoms[i]->altLoc); + std::string atom_name(residue_atoms[i]->GetAtomName()); + std::string atom_alt_conf(residue_atoms[i]->altLoc()); bool delete_this_atom_flag = 1; if (use_keep_atom_vector) { @@ -2037,15 +2037,15 @@ coot::util::calc_atom_map(mmdb::Manager *mol, for (int iat=0; iatisTer()) continue; - clipper::Coord_orth pt(at->x, at->y, at->z); - std::string ele(at->element); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); + std::string ele(at->GetElementName()); clipper::Atom cat; cat.set_element(ele); cat.set_coord_orth(pt); - float u_iso = at->tempFactor * rescale_b_u; + float u_iso = at->tempFactor() * rescale_b_u; if (u_iso < 0.1f) u_iso = 0.1f; // B < ~8.0: EDcalc_iso produces NaN from 0/0 cat.set_u_iso(u_iso); - cat.set_occupancy(at->occupancy); + cat.set_occupancy(at->occupancy()); l.push_back(cat); } @@ -2306,7 +2306,7 @@ coot::util::map_to_model_correlation_stats(mmdb::Manager *mol, if (debug) { std::cout << "debug:: selected " << n_atoms << " atoms " << std::endl; for (int iat=0; iatname << " " + std::cout << " " << iat << ": " << atom_selection[iat]->GetAtomName() << " " << atom_spec_t(atom_selection[iat]) << std::endl; } @@ -2401,9 +2401,9 @@ coot::util::map_to_model_correlation_stats(mmdb::Manager *mol, } for (int iat=0; iatx, - atom_selection[iat]->y, - atom_selection[iat]->z); + clipper::Coord_orth co(atom_selection[iat]->x(), + atom_selection[iat]->y(), + atom_selection[iat]->z()); if (atom_mask_mode == ATOM_MASK_ALL_ATOM_B_FACTOR) atom_radius = refmac_atom_radius(atom_selection[iat]); @@ -2809,9 +2809,9 @@ coot::util::map_to_model_correlation_per_residue(mmdb::Manager *mol, for (int iat=0; iatGetResidue()); int spec_idx = spec_to_index[res_spec]; - clipper::Coord_orth co(atom_selection[iat]->x, - atom_selection[iat]->y, - atom_selection[iat]->z); + clipper::Coord_orth co(atom_selection[iat]->x(), + atom_selection[iat]->y(), + atom_selection[iat]->z()); clipper::Coord_frac cf = co.coord_frac(reference_map.cell()); clipper::Coord_frac box0( cf.u() - atom_radius/reference_map.cell().descr().a(), @@ -2981,9 +2981,9 @@ coot::util::map_to_model_correlation_stats_per_residue(mmdb::Manager *mol, for (int iat=0; iatGetResidue()); - clipper::Coord_orth co(atom_selection[iat]->x, - atom_selection[iat]->y, - atom_selection[iat]->z); + clipper::Coord_orth co(atom_selection[iat]->x(), + atom_selection[iat]->y(), + atom_selection[iat]->z()); clipper::Coord_frac cf = co.coord_frac(xmap.cell()); clipper::Coord_frac box0( cf.u() - atom_radius/xmap.cell().descr().a(), @@ -3222,7 +3222,7 @@ coot::util::map_to_model_correlation_stats_per_residue_run(mmdb::Manager *mol, mmdb::Atom *at = residue_atoms[iat]; if (! at->isTer()) { - clipper::Coord_orth co(at->x, at->y, at->z); + clipper::Coord_orth co(at->x(), at->y(), at->z()); clipper::Coord_frac cf = co.coord_frac(contributor_map.cell()); clipper::Coord_frac box0(cf.u() - atom_radius/contributor_map.cell().descr().a(), cf.v() - atom_radius/contributor_map.cell().descr().b(), @@ -3297,9 +3297,9 @@ coot::util::map_to_model_correlation_stats_per_residue_run(mmdb::Manager *mol, mol->GetSelIndex(SelHnd, atom_selection, n_atoms); for (int iat=0; iatresidue; + mmdb::Residue *residue_p = at->GetResidue(); residue_spec_t res_spec(at->GetResidue()); - clipper::Coord_orth co(at->x, at->y, at->z); + clipper::Coord_orth co(at->x(), at->y(), at->z()); clipper::Coord_frac cf = co.coord_frac(contributor_map.cell()); clipper::Coord_frac box0(cf.u() - atom_radius/contributor_map.cell().descr().a(), cf.v() - atom_radius/contributor_map.cell().descr().b(), @@ -3470,7 +3470,7 @@ coot::util::qq_plot_for_map_over_model(mmdb::Manager *mol, for (int iat=0; iattempFactor*1.5/80.0; // should be some function of tempFactor; + float radius = 1.5 + at->tempFactor()*1.5/80.0; // should be some function of tempFactor; float radius_sq = radius * radius; clipper::Coord_frac cf = c_o.coord_frac(xmap.cell()); @@ -5460,10 +5460,10 @@ coot::util::split_residue_using_map(mmdb::Residue *residue_p, mmdb::Atom *at = residue_atoms[iat]; if (! at->isTer()) { // let's handle the perverse case where B alt confs come before the A alt confs - std::string atom_name(at->name); + std::string atom_name(at->GetAtomName()); std::map >::iterator it; it = atom_name_map.find(atom_name); - std::string alt_loc = at->altLoc; + std::string alt_loc = at->altLoc(); if (it == atom_name_map.end()) { if (alt_loc == "A") atom_name_map[atom_name] = std::make_pair(at, nullptr); if (alt_loc == "B") atom_name_map[atom_name] = std::make_pair(nullptr, at); @@ -5515,10 +5515,10 @@ coot::util::split_residue_using_map(mmdb::Residue *residue_p, mmdb::Atom *at = residue_atoms[iat]; mmdb::Atom *at_copy = new mmdb::Atom; at_copy->Copy(at); - strncpy(at->altLoc, "A", 2); - strncpy(at_copy->altLoc, "B", 2); - at->x += h.x(); at->y += h.y(); at->z += h.z(); - at_copy->x -= h.x(); at_copy->y -= h.y(); at_copy->z -= h.z(); + strncpy(at->altLoc(), "A", 2); + strncpy(at_copy->altLoc(), "B", 2); + at->x() += h.x(); at->y() += h.y(); at->z() += h.z(); + at_copy->x() -= h.x(); at_copy->y() -= h.y(); at_copy->z() -= h.z(); atoms_to_be_added.push_back(at_copy); } for(mmdb::Atom *at_copy : atoms_to_be_added) diff --git a/coot-utils/coot-rama.cc b/coot-utils/coot-rama.cc index d888c02070..924e553121 100644 --- a/coot-utils/coot-rama.cc +++ b/coot-utils/coot-rama.cc @@ -80,11 +80,11 @@ coot::util::get_phi_psi(mmdb::Residue *residue_0, mmdb::Residue *residue_1, mmdb residue_0->GetAtomTable(res_selection, nResidueAtoms); if (nResidueAtoms > 0) { for (int j=0; jname; + std::string atom_name = res_selection[j]->GetAtomName(); if (atom_name == " C ") { - c_prev = clipper::Coord_orth(res_selection[j]->x, - res_selection[j]->y, - res_selection[j]->z); + c_prev = clipper::Coord_orth(res_selection[j]->x(), + res_selection[j]->y(), + res_selection[j]->z()); natom++; } } @@ -92,23 +92,23 @@ coot::util::get_phi_psi(mmdb::Residue *residue_0, mmdb::Residue *residue_1, mmdb residue_1->GetAtomTable(res_selection, nResidueAtoms); if (nResidueAtoms > 0) { for (int j=0; jname; + std::string atom_name = res_selection[j]->GetAtomName(); if (atom_name == " C ") { - c_this = clipper::Coord_orth(res_selection[j]->x, - res_selection[j]->y, - res_selection[j]->z); + c_this = clipper::Coord_orth(res_selection[j]->x(), + res_selection[j]->y(), + res_selection[j]->z()); natom++; } if (atom_name == " CA ") { - ca_this = clipper::Coord_orth(res_selection[j]->x, - res_selection[j]->y, - res_selection[j]->z); + ca_this = clipper::Coord_orth(res_selection[j]->x(), + res_selection[j]->y(), + res_selection[j]->z()); natom++; } if (atom_name == " N ") { - n_this = clipper::Coord_orth(res_selection[j]->x, - res_selection[j]->y, - res_selection[j]->z); + n_this = clipper::Coord_orth(res_selection[j]->x(), + res_selection[j]->y(), + res_selection[j]->z()); natom++; } } @@ -119,11 +119,11 @@ coot::util::get_phi_psi(mmdb::Residue *residue_0, mmdb::Residue *residue_1, mmdb is_pre_pro = 1; if (nResidueAtoms > 0) { for (int j=0; jname; + std::string atom_name = res_selection[j]->GetAtomName(); if (atom_name == " N ") { - n_next = clipper::Coord_orth(res_selection[j]->x, - res_selection[j]->y, - res_selection[j]->z); + n_next = clipper::Coord_orth(res_selection[j]->x(), + res_selection[j]->y(), + res_selection[j]->z()); natom++; } } @@ -139,13 +139,13 @@ coot::util::get_phi_psi(mmdb::Residue *residue_0, mmdb::Residue *residue_1, mmdb label += " "; label += segid; label += " "; - label += residue_1->name; + label += residue_1->GetResName(); double phi = clipper::Util::rad2d(ca_this.torsion(c_prev, n_this, ca_this, c_this)); double psi = clipper::Util::rad2d(ca_this.torsion(n_this, ca_this, c_this, n_next)); phi_psi = coot::util::phi_psi_t(phi, psi, - residue_1->name, + residue_1->GetResName(), label.c_str(), ires, inscode, diff --git a/coot-utils/coot-shelx-ins.cc b/coot-utils/coot-shelx-ins.cc index 42715d59bb..9f918c9c19 100644 --- a/coot-utils/coot-shelx-ins.cc +++ b/coot-utils/coot-shelx-ins.cc @@ -667,14 +667,14 @@ coot::ShelxIns::read_file(const std::string &filename) { } else { if (false) // debug std::cout << "Mol Hierarchy atom: " << iat << " " - << " " << at->name << " " + << " " << at->GetAtomName() << " " << at->GetResName() << " " << at->GetSeqNum() << " " - << at->x << " " << at->y << " " << at->z << std::endl; - clipper::Coord_frac pf(at->x, at->y, at->z); + << at->x() << " " << at->y() << " " << at->z() << std::endl; + clipper::Coord_frac pf(at->x(), at->y(), at->z()); clipper::Coord_orth po = pf.coord_orth(cell); - at->x = po.x(); - at->y = po.y(); - at->z = po.z(); + at->x() = po.x(); + at->y() = po.y(); + at->z() = po.z(); } } } @@ -763,9 +763,9 @@ coot::ShelxIns::make_atom(const coot::shelx_card_info_t &card, const std::string } else { at->SetAtomName(make_atom_name(card.words[0].c_str(), element).c_str()); - at->x = atof(card.words[2].c_str()); - at->y = atof(card.words[3].c_str()); - at->z = atof(card.words[4].c_str()); + at->x() = atof(card.words[2].c_str()); + at->y() = atof(card.words[3].c_str()); + at->z() = atof(card.words[4].c_str()); float occupancy = 1.0; float b_synth= 10.0; @@ -778,7 +778,7 @@ coot::ShelxIns::make_atom(const coot::shelx_card_info_t &card, const std::string util::string_to_float(card.words[4].c_str()), occupancy, b_synth); at->SetElementName(element.c_str()); - strncpy(at->altLoc, altconf.c_str(), 2); + strncpy(at->altLoc(), altconf.c_str(), 2); } catch (const std::runtime_error &rte) { // do nothing @@ -798,7 +798,7 @@ coot::ShelxIns::make_atom(const coot::shelx_card_info_t &card, const std::string // isotropic temperature factor mmdb::realtype u_factor_from_card = atof(card.words[6].c_str()); if (u_factor_from_card > 0.0 ) { - at->tempFactor = u_to_b * u_factor_from_card; + at->tempFactor() = u_to_b * u_factor_from_card; at->WhatIsSet = at->WhatIsSet | 4; // is isotropic at->PutUDData(udd_non_riding_atom_flag_handle_in, 1); } else { @@ -812,26 +812,26 @@ coot::ShelxIns::make_atom(const coot::shelx_card_info_t &card, const std::string mmdb::Atom *prev = previous_non_riding_atom(atom_vector, udd_non_riding_atom_flag_handle_in); if (prev) { int status = at->PutUDData(udd_riding_atom_negative_u_value_handle_in, u_factor_from_card); - at->tempFactor = prev->tempFactor * -u_factor_from_card; + at->tempFactor() = prev->tempFactor() * -u_factor_from_card; } else { // Don't know what to do. Does this ever happen? - at->tempFactor = u_factor_from_card; + at->tempFactor() = u_factor_from_card; } // } else { // Don't know what to do. Does this ever happen? - at->tempFactor = u_factor_from_card; + at->tempFactor() = u_factor_from_card; } } } else { if (card.words.size() > 11) { // anisotropic temperature factor - at->u11 = atof(card.words[ 6].c_str()); - at->u22 = atof(card.words[ 7].c_str()); - at->u33 = atof(card.words[ 8].c_str()); - at->u23 = atof(card.words[ 9].c_str()); - at->u13 = atof(card.words[10].c_str()); - at->u12 = atof(card.words[11].c_str()); + at->u11() = atof(card.words[ 6].c_str()); + at->u22() = atof(card.words[ 7].c_str()); + at->u33() = atof(card.words[ 8].c_str()); + at->u23() = atof(card.words[ 9].c_str()); + at->u13() = atof(card.words[10].c_str()); + at->u12() = atof(card.words[11].c_str()); double a = cell_in.a(); double b = cell_in.b(); @@ -840,31 +840,31 @@ coot::ShelxIns::make_atom(const coot::shelx_card_info_t &card, const std::string // Now othogonalize the U values: // clipper::U_aniso_frac ocaf(at->u11, at->u22, at->u33, // at->u12, at->u13, at->u23); - clipper::U_aniso_frac caf(at->u11/(a*a), at->u22/(b*b), at->u33/(c*c), - at->u12/(a*b), at->u13/(a*c), at->u23/(b*c)); + clipper::U_aniso_frac caf(at->u11()/(a*a), at->u22()/(b*b), at->u33()/(c*c), + at->u12()/(a*b), at->u13()/(a*c), at->u23()/(b*c)); clipper::U_aniso_orth cao = caf.u_aniso_orth(cell_in); - at->u11 = cao(0,0); - at->u22 = cao(1,1); - at->u33 = cao(2,2); - at->u12 = cao(0,1); - at->u13 = cao(0,2); - at->u23 = cao(1,2); + at->u11() = cao(0,0); + at->u22() = cao(1,1); + at->u33() = cao(2,2); + at->u12() = cao(0,1); + at->u13() = cao(0,2); + at->u23() = cao(1,2); // std::cout << "DEBUG:: pre-orthog:\n" << ocaf.format() << std::endl; // std::cout << "DEBUG:: post-orthog:\n" << cao.format() << std::endl; at->WhatIsSet |= mmdb::ASET_Anis_tFac; // is anisotropic - float u_synth = (at->u11 + at->u22 + at->u33)/3.0; + float u_synth = (at->u11() + at->u22() + at->u33())/3.0; at->WhatIsSet |= mmdb::ASET_tempFactor; // has synthetic B factor - at->tempFactor = 8.0 * M_PI * M_PI * u_synth; + at->tempFactor() = 8.0 * M_PI * M_PI * u_synth; at->PutUDData(udd_non_riding_atom_flag_handle_in, 1); } } } else { // An atom with minimal description. Let's make up a // temperature factor: - at->tempFactor = 1.0; + at->tempFactor() = 1.0; at->WhatIsSet = at->WhatIsSet | 4; // is isotropic } // std::cout << "on setting WhatIsSet is " @@ -957,7 +957,7 @@ coot::ShelxIns::add_shelx_residue(std::vector &atom_vector, mmdb::Residue *residue = new mmdb::Residue; residue->SetResName(current_res_name.c_str()); - residue->seqNum = current_res_no; + residue->GetSeqNum() = current_res_no; bool srn = util::is_standard_residue_name(current_res_name); for (unsigned int i=0; ielement) << "_" + << util::remove_leading_spaces(hr.range_first->GetElementName()) << "_" << hr.range_first->GetSeqNum() + hr.resno_offset << " > " - << util::remove_leading_spaces(hr.range_last->element) << "_" + << util::remove_leading_spaces(hr.range_last->GetElementName()) << "_" << hr.range_last->GetSeqNum() + hr.resno_offset << "\n"; } } for (unsigned int ir=0; irelement) << "_" + << util::remove_leading_spaces(hr.range_first->GetElementName()) << "_" << hr.range_first->GetSeqNum() + hr.resno_offset << " > " - << util::remove_leading_spaces(hr.range_last->element) << "_" + << util::remove_leading_spaces(hr.range_last->GetElementName()) << "_" << hr.range_last->GetSeqNum() + hr.resno_offset << "\n"; // << " > LAST\n"; } @@ -1508,7 +1508,7 @@ coot::ShelxIns::get_atomic_contents(mmdb::Manager *mol) const { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - std::string ele(at->element); + std::string ele(at->GetElementName()); if (! ele.empty()) // now we added the isTer() test this probably // won't catch anything. m[ele]++; // initial/default value is 0. @@ -1635,15 +1635,15 @@ coot::ShelxIns::write_ins_file_internal(mmdb::Manager *mol, for (int iat=0; iatGetAtom(iat); - float site_occ_factor = at->occupancy; + float site_occ_factor = at->occupancy(); // reset occupancy to shelx standard occ // (FVAR 1 is implied if not set in the .ins file) if (! mol_is_from_shelx_ins) site_occ_factor = 11.000; - clipper::Coord_orth co(at->x, at->y, at->z); + clipper::Coord_orth co(at->x(), at->y(), at->z()); clipper::Coord_frac cf = co.coord_frac(cell); - int sfac_index = get_sfac_index(at->element); + int sfac_index = get_sfac_index(at->GetElementName()); // AFIX comes before PART if (at->GetUDData(udd_afix_handle, ic) == mmdb::UDDATA_Ok) { @@ -1665,19 +1665,19 @@ coot::ShelxIns::write_ins_file_internal(mmdb::Manager *mol, // std::cout << "on writting WhatIsSet is " << at->WhatIsSet // << "\n"; - std::string this_altloc = at->altLoc; + std::string this_altloc = at->altLoc(); if (this_altloc != current_altloc) { - int ipart = altloc_to_part_no(std::string(at->altLoc)); + int ipart = altloc_to_part_no(std::string(at->altLoc())); f << "PART " << ipart << "\n"; } if (at->WhatIsSet & mmdb::ASET_Anis_tFac) { // Anisotropic - clipper::U_aniso_orth cao(at->u11, at->u22, at->u33, - at->u12, at->u13, at->u23); + clipper::U_aniso_orth cao(at->u11(), at->u22(), at->u33(), + at->u12(), at->u13(), at->u23()); clipper::U_aniso_frac caf = cao.u_aniso_frac(cell); - std::string at_name(at->name); + std::string at_name(at->GetAtomName()); f.setf(std::ios::fixed); f.precision(9); f << coot::util::remove_leading_spaces(at_name) @@ -1695,8 +1695,8 @@ coot::ShelxIns::write_ins_file_internal(mmdb::Manager *mol, } else { if (at->WhatIsSet & mmdb::ASET_tempFactor) { // Isotropic B factor - std::string at_name(at->name); - float b_factor = at->tempFactor; + std::string at_name(at->GetAtomName()); + float b_factor = at->tempFactor(); f.setf(std::ios::fixed); f.precision(7); @@ -1799,10 +1799,10 @@ coot::ShelxIns::message_for_atom(const std::string &in_string, mmdb::Atom *at) c s += "\""; s += at->GetAtomName(); s += "\""; - if (std::string(at->altLoc).length()) { + if (std::string(at->altLoc()).length()) { s += " ,"; s += "\""; - s += at->altLoc; + s += at->altLoc(); s += "\""; } return s; @@ -2620,7 +2620,7 @@ coot::unshelx(mmdb::Manager *shelx_mol) { for (int ires=0; iresGetResidue(ires); if (residue_p) - residue_p->index = ires; + residue_p->GetIndex() = ires; } } mol->FinishStructEdit(); @@ -2680,7 +2680,7 @@ coot::reshelx(mmdb::Manager *mol) { for (int ires=0; iresGetResidue(ires); mmdb::Residue *copy_residue_p = coot::util::deep_copy_this_residue(residue_p); - copy_residue_p->seqNum = residue_p->GetSeqNum() + residue_offset; + copy_residue_p->GetSeqNum() = residue_p->GetSeqNum() + residue_offset; shelx_chain_p->AddResidue(copy_residue_p); // apply the shelx afix numbers: diff --git a/coot-utils/coot-tree-extras.cc b/coot-utils/coot-tree-extras.cc index c0916f3866..875c05e87a 100644 --- a/coot-utils/coot-tree-extras.cc +++ b/coot-utils/coot-tree-extras.cc @@ -131,7 +131,7 @@ void coot::atom_tree_t::construct_internal(const coot::dictionary_residue_restra for (int iat=0; iatGetAtom(iat); if (! atom_p->isTer()) { - std::string atom_ele(atom_p->element); + std::string atom_ele(atom_p->GetElementName()); if (atom_ele == " D") { has_deuterium_atoms = true; break; @@ -163,8 +163,8 @@ void coot::atom_tree_t::construct_internal(const coot::dictionary_residue_restra int idx1 = -1; int idx2 = -1; for (int iat=0; iatname; - std::string atom_altl = residue_atoms[iat]->altLoc; + std::string atom_name = residue_atoms[iat]->GetAtomName(); + std::string atom_altl = residue_atoms[iat]->altLoc(); // std::cout << "comparing :" << atom_name << ": with :" << rest.bond_restraint[i].atom_id_1() // << ":" << std::endl; if (atom_name == rest.bond_restraint[i].atom_id_1_4c()) @@ -184,8 +184,8 @@ void coot::atom_tree_t::construct_internal(const coot::dictionary_residue_restra // same again with dictionary atom name changes for (int iat=0; iatname; - std::string atom_altl = residue_atoms[iat]->altLoc; + std::string atom_name = residue_atoms[iat]->GetAtomName(); + std::string atom_altl = residue_atoms[iat]->altLoc(); // std::cout << "comparing :" << atom_name << ": with :" << rest.bond_restraint[i].atom_id_1() // << ":" << std::endl; std::string bond_restraint_atom_name_1 = rest.bond_restraint[i].atom_id_1_4c(); @@ -237,8 +237,8 @@ coot::atom_tree_t::fill_name_map(const std::string &altconf) { // atom-name -> index, now class variable // std::map > name_to_index; for (int iat=0; iatname); - std::string atom_altl = residue_atoms[iat]->altLoc; + std::string atom_name(residue_atoms[iat]->GetAtomName()); + std::string atom_altl = residue_atoms[iat]->altLoc(); if (false) std::cout << "debug:: in fill_name_map(): comparing altconf of this atom :" << atom_altl << ": to (passed arg) :" << altconf << ": or blank" << std::endl; @@ -471,8 +471,8 @@ coot::atom_tree_t::get_atom_index_quad(const coot::dict_torsion_restraint_t &tr, int n_residue_atoms; res->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); - std::string atom_altconf(residue_atoms[iat]->altLoc); + std::string atom_name( residue_atoms[iat]->GetAtomName()); + std::string atom_altconf(residue_atoms[iat]->altLoc()); if (atom_name == tr.atom_id_1_4c()) if (atom_altconf == "" || atom_altconf == altconf) quad.index1 = iat; @@ -957,8 +957,8 @@ coot::atom_tree_t::rotate_about(const std::string &atom1, const std::string &ato residue->GetAtomTable(residue_atoms, n_residue_atoms); mmdb::Atom *at2 = residue_atoms[index2.index()]; mmdb::Atom *at3 = residue_atoms[index3.index()]; - clipper::Coord_orth base_atom_pos(at2->x, at2->y, at2->z); - clipper::Coord_orth third_atom(at3->x, at3->y, at3->z);; + clipper::Coord_orth base_atom_pos(at2->x(), at2->y(), at2->z()); + clipper::Coord_orth third_atom(at3->x(), at3->y(), at3->z());; clipper::Coord_orth direction = third_atom - base_atom_pos; if (xor_reverse) { direction = base_atom_pos - third_atom; @@ -1127,8 +1127,8 @@ coot::atom_tree_t::rotate_about(int index2, int index3, double angle, bool rever } if (at2 && at3) { - clipper::Coord_orth base_atom_pos(at2->x, at2->y, at2->z); - clipper::Coord_orth third_atom(at3->x, at3->y, at3->z);; + clipper::Coord_orth base_atom_pos(at2->x(), at2->y(), at2->z()); + clipper::Coord_orth third_atom(at3->x(), at3->y(), at3->z());; clipper::Coord_orth direction = third_atom - base_atom_pos; if (xor_reverse) { direction = base_atom_pos - third_atom; @@ -1168,18 +1168,18 @@ coot::atom_tree_t::quad_to_torsion(const coot::map_index_t &index2) const { mmdb::PPAtom residue_atoms; int n_residue_atoms; residue->GetAtomTable(residue_atoms, n_residue_atoms); - co[0] = clipper::Coord_orth(residue_atoms[quad.index1]->x, - residue_atoms[quad.index1]->y, - residue_atoms[quad.index1]->z); - co[1] = clipper::Coord_orth(residue_atoms[quad.index2]->x, - residue_atoms[quad.index2]->y, - residue_atoms[quad.index2]->z); - co[2] = clipper::Coord_orth(residue_atoms[quad.index3]->x, - residue_atoms[quad.index3]->y, - residue_atoms[quad.index3]->z); - co[3] = clipper::Coord_orth(residue_atoms[quad.index4]->x, - residue_atoms[quad.index4]->y, - residue_atoms[quad.index4]->z); + co[0] = clipper::Coord_orth(residue_atoms[quad.index1]->x(), + residue_atoms[quad.index1]->y(), + residue_atoms[quad.index1]->z()); + co[1] = clipper::Coord_orth(residue_atoms[quad.index2]->x(), + residue_atoms[quad.index2]->y(), + residue_atoms[quad.index2]->z()); + co[2] = clipper::Coord_orth(residue_atoms[quad.index3]->x(), + residue_atoms[quad.index3]->y(), + residue_atoms[quad.index3]->z()); + co[3] = clipper::Coord_orth(residue_atoms[quad.index4]->x(), + residue_atoms[quad.index4]->y(), + residue_atoms[quad.index4]->z()); double ar = clipper::Coord_orth::torsion(co[0], co[1], co[2], co[3]); double new_torsion = clipper::Util::rad2d(ar); return new_torsion; @@ -1371,15 +1371,15 @@ coot::atom_tree_t::rotate_internal(std::vector moving_atom_in for (unsigned int im=0; imx, at->y, at->z); + clipper::Coord_orth po(at->x(), at->y(), at->z()); clipper::Coord_orth pt = coot::util::rotate_around_vector(dir, po, base_atom_pos, angle); if (debug) - std::cout << " rotate_internal() moving atom number " << im << " " << at->name - << " from\n " << at->x << "," << at->y << "," << at->z << " to " + std::cout << " rotate_internal() moving atom number " << im << " " << at->GetAtomName() + << " from\n " << at->x() << "," << at->y() << "," << at->z() << " to " << pt.format() << std::endl; - at->x = pt.x(); - at->y = pt.y(); - at->z = pt.z(); + at->x() = pt.x(); + at->y() = pt.y(); + at->z() = pt.z(); } } diff --git a/coot-utils/coot_shiftfield.cpp b/coot-utils/coot_shiftfield.cpp index 68f49a988f..2c681f29dc 100644 --- a/coot-utils/coot_shiftfield.cpp +++ b/coot-utils/coot_shiftfield.cpp @@ -70,23 +70,23 @@ test_import_minimol(clipper::MMDBfile* mfile, clipper::MiniMol& minimol, const i if ( !p_atm->Ter ) { // import the atom clipper::MAtom atm( clipper::Atom::null() ); - atm.set_name( p_atm->GetAtomName(), p_atm->altLoc ); - atm.set_element( p_atm->element ); + atm.set_name( p_atm->GetAtomName(), p_atm->altLoc() ); + atm.set_element( p_atm->GetElementName() ); if ( p_atm->WhatIsSet & ::mmdb::ASET_Coordinates ) - atm.set_coord_orth(clipper::Coord_orth( p_atm->x, p_atm->y, p_atm->z ) ); + atm.set_coord_orth(clipper::Coord_orth( p_atm->x(), p_atm->y(), p_atm->z() ) ); if ( p_atm->WhatIsSet & ::mmdb::ASET_Occupancy ) - atm.set_occupancy( p_atm->occupancy ); + atm.set_occupancy( p_atm->occupancy() ); if ( p_atm->WhatIsSet & ::mmdb::ASET_tempFactor ) - atm.set_u_iso( clipper::Util::b2u( p_atm->tempFactor ) ); + atm.set_u_iso( clipper::Util::b2u( p_atm->tempFactor() ) ); if ( p_atm->WhatIsSet & ::mmdb::ASET_Anis_tFac ) atm.set_u_aniso_orth( - clipper::U_aniso_orth( p_atm->u11, p_atm->u22, p_atm->u33, - p_atm->u12, p_atm->u13, p_atm->u23 ) ); + clipper::U_aniso_orth( p_atm->u11(), p_atm->u22(), p_atm->u33(), + p_atm->u12(), p_atm->u13(), p_atm->u23() ) ); p_atm->GetAtomID( txt ); atm.set_property("CID",clipper::Property(clipper::String(txt))); - if ( p_atm->altLoc[0] != '\0' ) + if ( p_atm->altLoc()[0] != '\0' ) atm.set_property("AltConf", - clipper::Property(clipper::String(p_atm->altLoc))); + clipper::Property(clipper::String(p_atm->altLoc()))); mon.insert( atm ); // store the atom } } diff --git a/coot-utils/dict-link-info.cc b/coot-utils/dict-link-info.cc index eec534cd43..8b3f929891 100644 --- a/coot-utils/dict-link-info.cc +++ b/coot-utils/dict-link-info.cc @@ -56,14 +56,14 @@ coot::dict_link_info_t::dict_link_info_t(mmdb::Residue *residue_ref, int n_residue_atoms_1; res_1->GetAtomTable(residue_atoms_1, n_residue_atoms_1); for (int iat1=0; iat1name); + std::string atom_name_1(residue_atoms_1[iat1]->GetAtomName()); if (atom_name_1 == rr.link_bond_restraint[ibond].atom_id_1_4c()) { // OK so the first atom matched mmdb::PPAtom residue_atoms_2 = 0; int n_residue_atoms_2; res_2->GetAtomTable(residue_atoms_2, n_residue_atoms_2); for (int iat2=0; iat2name); + std::string atom_name_2(residue_atoms_2[iat2]->GetAtomName()); if (atom_name_2 == rr.link_bond_restraint[ibond].atom_id_2_4c()) { ifound = 1; spec_ref = coot::atom_spec_t(res_spec_ref.chain_id, diff --git a/coot-utils/edcalc.cc b/coot-utils/edcalc.cc index 96ef95cce9..be42a4314d 100644 --- a/coot-utils/edcalc.cc +++ b/coot-utils/edcalc.cc @@ -77,13 +77,13 @@ coot::calc_atom_map_edcalc(mmdb::Manager *mol, if (at->isTer()) continue; atom_edcalc_data_t ad; - ad.pos = clipper::Coord_orth(at->x, at->y, at->z); - ad.occ = at->occupancy; + ad.pos = clipper::Coord_orth(at->x(), at->y(), at->z()); + ad.occ = at->occupancy(); - float u_iso = at->tempFactor * rescale_b_u; + float u_iso = at->tempFactor() * rescale_b_u; if (u_iso < 0.1f) u_iso = 0.1f; // avoid NaN from very low B-factors - std::string ele(at->element); + std::string ele(at->GetElementName()); const clipper::ScatteringFactorsData &sf = clipper::ScatteringFactors::instance()[ele]; for (int i = 0; i < 6; i++) { diff --git a/coot-utils/find-water-baddies.cc b/coot-utils/find-water-baddies.cc index 516b94bb36..7923887240 100644 --- a/coot-utils/find-water-baddies.cc +++ b/coot-utils/find-water-baddies.cc @@ -105,8 +105,8 @@ coot::find_water_baddies_OR(atom_selection_container_t atom_sel, at = residue_p->GetAtom(iat); bool water_atom_is_hydrogen_atom = false; // PDBv3 FIXME - if (! strncmp(at->name, " H", 2)) water_atom_is_hydrogen_atom = true; - if (! strncmp(at->name, " D", 2)) water_atom_is_hydrogen_atom = true; + if (! strncmp(at->GetAtomName(), " H", 2)) water_atom_is_hydrogen_atom = true; + if (! strncmp(at->GetAtomName(), " D", 2)) water_atom_is_hydrogen_atom = true; if (water_atom_is_hydrogen_atom) continue; @@ -119,7 +119,7 @@ coot::find_water_baddies_OR(atom_selection_container_t atom_sel, // density check: if (map_in_sigma > 0.0) { // it *should* be! - clipper::Coord_orth a(at->x, at->y, at->z); + clipper::Coord_orth a(at->x(), at->y(), at->z()); den = coot::util::density_at_point(xmap_in, a); den /= map_in_sigma; @@ -136,7 +136,7 @@ coot::find_water_baddies_OR(atom_selection_container_t atom_sel, // B factor check: if (! this_is_marked) { - if (at->tempFactor > b_factor_lim && use_b_factor_limit_test) { + if (at->tempFactor() > b_factor_lim && use_b_factor_limit_test) { marked_for_display.push_back(std::pair(at, den)); } } @@ -148,23 +148,23 @@ coot::find_water_baddies_OR(atom_selection_container_t atom_sel, // (ignoring things means less marked atoms) if (ignore_part_occ_contact_flag == 0) { - if (ignore_zero_occ_flag == false || at->occupancy > 0.01) { + if (ignore_zero_occ_flag == false || at->occupancy() > 0.01) { double dist_to_atoms_min = 99999; double dc_sqrd = dist_to_atoms_min * dist_to_atoms_min; double d_sqrd_min = 999999999; - clipper::Coord_orth a(at->x, at->y, at->z); + clipper::Coord_orth a(at->x(), at->y(), at->z()); for (int j=0; jelement, " H", 2)) + if (! strncmp(atom_sel.atom_selection[j]->GetElementName(), " H", 2)) is_H = true; if (! is_H) { - clipper::Coord_orth p(atom_sel.atom_selection[j]->x, - atom_sel.atom_selection[j]->y, - atom_sel.atom_selection[j]->z); + clipper::Coord_orth p(atom_sel.atom_selection[j]->x(), + atom_sel.atom_selection[j]->y(), + atom_sel.atom_selection[j]->z()); double d_sqrd = (p-a).lengthsq(); if (d_sqrd < d_sqrd_min) { d_sqrd_min = d_sqrd; @@ -209,14 +209,14 @@ coot::find_water_baddies_OR(atom_selection_container_t atom_sel, for (unsigned int i=0; itempFactor); + s += coot::util::float_to_string(marked_for_display[i].first->tempFactor()); if (map_in_sigma > 0.0) { s += " ED: "; s += coot::util::float_to_string(marked_for_display[i].second); s += " rmsd"; } coot::atom_spec_t as(marked_for_display[i].first, s); - as.float_user_data = marked_for_display[i].first->occupancy; + as.float_user_data = marked_for_display[i].first->occupancy(); v.push_back(as); } return v; diff --git a/coot-utils/gaussian-atom-map-for-mask.cc b/coot-utils/gaussian-atom-map-for-mask.cc index 2b2d5704b9..dfcb54c94b 100644 --- a/coot-utils/gaussian-atom-map-for-mask.cc +++ b/coot-utils/gaussian-atom-map-for-mask.cc @@ -66,7 +66,7 @@ clipper::Xmap coot::util::make_gaussian_atom_map_for_mask(const clipper:: for (int i=0; iisTer()) { - clipper::Coord_orth pos(at->x, at->y, at->z); + clipper::Coord_orth pos(at->x(), at->y(), at->z()); place_atom_in_grid(pos, xmap, sigma, box_radius); // change xmap } } diff --git a/coot-utils/glyco-torsions.cc b/coot-utils/glyco-torsions.cc index b6709db1ba..c95b705244 100644 --- a/coot-utils/glyco-torsions.cc +++ b/coot-utils/glyco-torsions.cc @@ -215,7 +215,7 @@ coot::link_by_torsion_t::make_residue(mmdb::Residue *base_residue_p) const { if (geom_atom_torsions.size()) { r = new mmdb::Residue; r->SetResName(new_residue_type.c_str()); - r->seqNum = new_res_no; + r->GetSeqNum() = new_res_no; for (unsigned int i=0; iname); + std::string nb_name = coot::util::remove_whitespace(at->GetAtomName()); if (names.prior_atom_1.first) if (names.prior_atom_1.second == nb_name) p_1 = at; @@ -275,7 +275,7 @@ coot::atom_by_torsion_t::atom_by_torsion_t(const atom_by_torsion_base_t &names, } for (int iat=0; iatname); + std::string nb_name = coot::util::remove_whitespace(at->GetAtomName()); if (! names.prior_atom_1.first) if (names.prior_atom_1.second == nb_name) p_1 = at; diff --git a/coot-utils/grid-balls.cc b/coot-utils/grid-balls.cc index c6b4d0185a..36b21f9df2 100644 --- a/coot-utils/grid-balls.cc +++ b/coot-utils/grid-balls.cc @@ -36,12 +36,12 @@ coot::grid_balls_t::get_extents(mmdb::Manager *mol) const { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - if (at->x < mol_x_min) mol_x_min = at->x; - if (at->y < mol_y_min) mol_y_min = at->y; - if (at->z < mol_z_min) mol_z_min = at->z; - if (at->x > mol_x_max) mol_x_max = at->x; - if (at->y > mol_y_max) mol_y_max = at->y; - if (at->z > mol_z_max) mol_z_max = at->z; + if (at->x() < mol_x_min) mol_x_min = at->x(); + if (at->y() < mol_y_min) mol_y_min = at->y(); + if (at->z() < mol_z_min) mol_z_min = at->z(); + if (at->x() > mol_x_max) mol_x_max = at->x(); + if (at->y() > mol_y_max) mol_y_max = at->y(); + if (at->z() > mol_z_max) mol_z_max = at->z(); } } } @@ -253,10 +253,10 @@ namespace { mmdb::Atom *at, const std::string &residue_name) { double radius = -1.1; if (geom_p) - radius = geom_p->get_vdw_radius(std::string(at->name), residue_name, + radius = geom_p->get_vdw_radius(std::string(at->GetAtomName()), residue_name, imol, false); // heavy-atom VdW, as in KVFinder if (radius <= 0.0) - radius = element_to_vdw_radius(at->element); + radius = element_to_vdw_radius(at->GetElementName()); return static_cast(radius); } } @@ -286,7 +286,7 @@ coot::grid_balls_t::brick_the_model(mmdb::Manager *mol) { float radius = atom_vdw_radius(geom_p, imol, at, residue_name); // rasterise the VdW sphere into the grid - point_3d_t atom_pos(at->x, at->y, at->z); + point_3d_t atom_pos(at->x(), at->y(), at->z()); triple_index_t centre = mol_space_to_grid_point(atom_pos); int ir = static_cast(std::ceil(radius * n_grids_per_angstrom)); float radius_sqrd = radius * radius; @@ -353,7 +353,7 @@ coot::grid_balls_t::make_blocked_grid(float probe_radius) const { float radius = atom_vdw_radius(geom_p, imol, at, residue_name) + probe_radius; - point_3d_t atom_pos(at->x, at->y, at->z); + point_3d_t atom_pos(at->x(), at->y(), at->z()); triple_index_t centre = mol_space_to_grid_point(atom_pos); int ir = static_cast(std::ceil(radius * n_grids_per_angstrom)); float radius_sqrd = radius * radius; @@ -675,7 +675,7 @@ coot::grid_balls_t::compute_lining_residues_for(std::vector &cavs, flo mmdb::Atom *at = residue_p->GetAtom(iat); if (at->isTer()) continue; - point_3d_t ap(at->x, at->y, at->z); + point_3d_t ap(at->x(), at->y(), at->z()); triple_index_t centre = mol_space_to_grid_point(ap); std::set hit; // labels this atom is in contact with diff --git a/coot-utils/helix-analysis.cc b/coot-utils/helix-analysis.cc index 64a502e43b..cc01a7d044 100644 --- a/coot-utils/helix-analysis.cc +++ b/coot-utils/helix-analysis.cc @@ -120,8 +120,8 @@ void coot::helix_params_t::calc_B() { if (quad.atom_2 && quad.atom_3) { - clipper::Coord_orth pt_2(quad.atom_2->x, quad.atom_2->y, quad.atom_2->z); - clipper::Coord_orth pt_3(quad.atom_3->x, quad.atom_3->y, quad.atom_3->z); + clipper::Coord_orth pt_2(quad.atom_2->x(), quad.atom_2->y(), quad.atom_2->z()); + clipper::Coord_orth pt_3(quad.atom_3->x(), quad.atom_3->y(), quad.atom_3->z()); double d = clipper::Coord_orth::length(pt_2, pt_3); B = clipper::Coord_orth(d, 0, 0); clipper::RTop_orth A_rtop(A, clipper::Coord_orth(0,0,0)); diff --git a/coot-utils/helix-like.cc b/coot-utils/helix-like.cc index f4172f1a4f..8463f5af00 100644 --- a/coot-utils/helix-like.cc +++ b/coot-utils/helix-like.cc @@ -129,14 +129,14 @@ coot::compare_to_helix(const std::vector &helical_residues, for (int iat=0; iatname); + std::string atom_name(at->GetAtomName()); if (atom_name == " N ") idx = 0; if (atom_name == " CA ") idx = 1; if (atom_name == " C ") idx = 2; if (atom_name == " O ") idx = 3; if (idx != -1) { int idx_match_set = i*4 + idx; - clipper::Coord_orth co(at->x, at->y, at->z); + clipper::Coord_orth co(at->x(), at->y(), at->z()); match_set[idx_match_set] = co; n_found++; // also count n_found_this (for this residue) diff --git a/coot-utils/hole.cc b/coot-utils/hole.cc index a2ae857378..6c2deec884 100644 --- a/coot-utils/hole.cc +++ b/coot-utils/hole.cc @@ -72,7 +72,7 @@ coot::hole::assign_vdw_radii(const coot::protein_geometry &geom) { for (int iat=0; iatGetAtom(iat); - std::string atom_name = at->name; + std::string atom_name = at->GetAtomName(); // try cache first std::pair p(atom_name, residue_name); @@ -85,7 +85,7 @@ coot::hole::assign_vdw_radii(const coot::protein_geometry &geom) { if (radius > 0) { at->PutUDData(radius_handle, radius); } else { - std::string ele = at->element; + std::string ele = at->GetElementName(); // make a reasonable default mmdb::realtype radius = 1.7; if (ele == " N") @@ -317,9 +317,9 @@ coot::hole::sphere_size(const clipper::Coord_orth &pt, int selhnd) const { mmdb::realtype atom_vdw_radius; for (int iat=0; iatx, - atom_selection[iat]->y, - atom_selection[iat]->z); + clipper::Coord_orth atom_pos(atom_selection[iat]->x(), + atom_selection[iat]->y(), + atom_selection[iat]->z()); double r_1 = clipper::Coord_orth::length(atom_pos, pt); atom_selection[iat]->GetUDData(radius_handle, atom_vdw_radius); double r = r_1 - atom_vdw_radius; diff --git a/coot-utils/jed-flip.cc b/coot-utils/jed-flip.cc index f6c58ff73a..7ddd876e53 100644 --- a/coot-utils/jed-flip.cc +++ b/coot-utils/jed-flip.cc @@ -88,7 +88,7 @@ coot::util::jed_flip(int imol_no, mmdb::Residue *residue_p, mmdb::Atom *atom_p, message = "Selected atom was not in the residue"; } else { // Happy Path - std::string alt_conf(atom_p->altLoc); + std::string alt_conf(atom_p->altLoc()); atom_selection_container_t residue_asc(residue_atoms, n_residue_atoms); contact_info contact = getcontacts(residue_asc, monomer_type, imol_no, geom); std::vector > contact_indices = diff --git a/coot-utils/lsq-improve.cc b/coot-utils/lsq-improve.cc index b085f5c394..7cfb7b59e0 100644 --- a/coot-utils/lsq-improve.cc +++ b/coot-utils/lsq-improve.cc @@ -122,7 +122,7 @@ coot::lsq_improve::CAs_to_model(mmdb::Manager *mol_in, int model_number) { mmdb::Residue *residue_new = new mmdb::Residue(chain_new); chain_new->AddResidue(residue_new); residue_new->SetResName(residue_p->GetResName()); - residue_new->seqNum = residue_p->GetSeqNum(); + residue_new->GetSeqNum() = residue_p->GetSeqNum(); strncpy(residue_new->insCode, residue_p->GetInsCode(), 3); mmdb::Atom *atom_new = new mmdb::Atom(residue_new); residue_new->AddAtom(atom_new); diff --git a/coot-utils/maps-spherical.cc b/coot-utils/maps-spherical.cc index 0ed17c0353..3a8ab83d23 100644 --- a/coot-utils/maps-spherical.cc +++ b/coot-utils/maps-spherical.cc @@ -27,6 +27,7 @@ #include "utils/coot-utils.hh" #include "coot-map-utils.hh" +#include "mmdb-to-clipper-atom-list.hh" #include "emma.hh" #include "peak-search.hh" #include "xmap-stats.hh" // needed? @@ -86,7 +87,7 @@ coot::util::emma::sfs_from_boxed_molecule(mmdb::Manager *mol_orig, float border) std::cout << "DEBUG:: P1-sfs: cell " << cell.format() << std::endl; std::cout << "DEBUG:: P1-sfs: resolution limit " << reso.limit() << std::endl; - clipper::MMDBAtom_list atoms(atom_selection, n_selected_atoms); + coot::MMDBAtom_list atoms(atom_selection, n_selected_atoms); std::cout << "DEBUG:: P1-sfs: n_selected_atoms: " << n_selected_atoms << std::endl; fc_from_model = clipper::HKL_data(hkl_info, cell); diff --git a/coot-utils/merge-C-and-N-terminii.cc b/coot-utils/merge-C-and-N-terminii.cc index 1a0e538884..e10f992a09 100644 --- a/coot-utils/merge-C-and-N-terminii.cc +++ b/coot-utils/merge-C-and-N-terminii.cc @@ -277,7 +277,7 @@ coot::merge_C_and_N_terminii(mmdb::Manager *mol, mmdb::Residue *residue_p = chain_with_N_p->GetResidue(ires); if (residue_p) { mmdb::Residue *new_residue = util::deep_copy_this_residue(residue_p); - new_residue->seqNum = rn_base + ires + gap_size; + new_residue->GetSeqNum() = rn_base + ires + gap_size; chain_with_CO_p->AddResidue(new_residue); } } @@ -335,11 +335,11 @@ coot::merge_C_and_N_terminii(mmdb::Manager *mol, mmdb::Atom *at_ca = residue_p->GetAtom(" CA "); mmdb::Atom *at_c = residue_p->GetAtom(" C "); if (at_n) - n_pos = clipper::Coord_orth( at_n->x, at_n->y, at_n->z); + n_pos = clipper::Coord_orth( at_n->x(), at_n->y(), at_n->z()); if (at_ca) - ca_pos = clipper::Coord_orth(at_ca->x, at_ca->y, at_ca->z); + ca_pos = clipper::Coord_orth(at_ca->x(), at_ca->y(), at_ca->z()); if (at_c) - n_pos = clipper::Coord_orth( at_c->x, at_c->y, at_c->z); + n_pos = clipper::Coord_orth( at_c->x(), at_c->y(), at_c->z()); if (at_n && at_ca && at_c) { @@ -389,7 +389,7 @@ coot::merge_C_and_N_terminii(mmdb::Manager *mol, // we have a CA at least, and possibly a N and C too. mmdb::Residue *residue_p = new mmdb::Residue; chain_p->AddResidue(residue_p); - residue_p->seqNum = ires+first_res_no; + residue_p->GetSeqNum() = ires+first_res_no; mmdb::Atom *at_p = new mmdb::Atom; residue_p->AddAtom(at_p); residue_p->SetResName("UNK"); // Or ALA. diff --git a/coot-utils/merge-atom-selections.cc b/coot-utils/merge-atom-selections.cc index 1761fb02d0..4d0cd8ef09 100644 --- a/coot-utils/merge-atom-selections.cc +++ b/coot-utils/merge-atom-selections.cc @@ -127,8 +127,8 @@ coot::mergeable_atom_selections(mmdb::Manager *mol, int selection_handle_1, int void coot::match_container_t::add(mmdb::Atom *at_1, mmdb::Atom *at_2) { - mmdb::Residue *res_1 = at_1->residue; - mmdb::Residue *res_2 = at_2->residue; + mmdb::Residue *res_1 = at_1->GetResidue(); + mmdb::Residue *res_2 = at_2->GetResidue(); if (res_1) { if (res_2) { bool added = false; @@ -172,8 +172,8 @@ coot::match_container_t::find_best_match() const { for (unsigned int iat=0; iatx, at_1->y, at_1->z); - clipper::Coord_orth pt_2(at_2->x, at_2->y, at_2->z); + clipper::Coord_orth pt_1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth pt_2(at_2->x(), at_2->y(), at_2->z()); double dd = (pt_1-pt_2).lengthsq(); sum_devi += sqrt(dd); } @@ -452,7 +452,7 @@ coot::renumber_chains_start_at_least_at_1(mmdb::Manager *mol) { if (offset != 0) { for (int ires=0; iresGetResidue(ires); - residue_p->seqNum += offset; + residue_p->GetSeqNum() += offset; } } } @@ -494,13 +494,13 @@ coot::match_container_for_residues_t::delete_upstream(mmdb::Manager *mol, bool f if (atom_pairs[ip].first == at) { found_matchers = true; std::cout << "DEBUG:: -- A -- setting matchers residue from atom " << atom_spec_t(at) << std::endl; - matchers_residue = at->residue; + matchers_residue = at->GetResidue(); break; } } else { if (atom_pairs[ip].second == at) { found_matchers = true; - matchers_residue = at->residue; + matchers_residue = at->GetResidue(); std::cout << "DEBUG:: -- B -- setting matchers residue from atom " << atom_spec_t(at) << std::endl; break; } @@ -509,9 +509,9 @@ coot::match_container_for_residues_t::delete_upstream(mmdb::Manager *mol, bool f if (found_matchers) break; - if (at->residue != matchers_residue) - if (std::find(delete_these_residues.begin(), delete_these_residues.end(), at->residue) == delete_these_residues.end()) - delete_these_residues.push_back(at->residue); + if (at->GetResidue() != matchers_residue) + if (std::find(delete_these_residues.begin(), delete_these_residues.end(), at->GetResidue()) == delete_these_residues.end()) + delete_these_residues.push_back(at->GetResidue()); } if (delete_these_residues.size() > 0) { @@ -558,7 +558,7 @@ coot::match_container_for_residues_t::delete_downstream(mmdb::Manager *mol, bool for (unsigned int ip=0; ip < atom_pairs.size(); ip++) { if (atom_pairs[ip].first == at) { found_matchers = true; - matchers_residue = at->residue; + matchers_residue = at->GetResidue(); break; } } @@ -566,7 +566,7 @@ coot::match_container_for_residues_t::delete_downstream(mmdb::Manager *mol, bool for (unsigned int ip=0; ip residue; + matchers_residue = at->GetResidue(); break; } } @@ -574,9 +574,9 @@ coot::match_container_for_residues_t::delete_downstream(mmdb::Manager *mol, bool // if we are *past* the matching atoms (not in them) if (found_matchers) - if (at->residue != matchers_residue) - if (std::find(delete_these_residues.begin(), delete_these_residues.end(), at->residue) == delete_these_residues.end()) - delete_these_residues.push_back(at->residue); + if (at->GetResidue() != matchers_residue) + if (std::find(delete_these_residues.begin(), delete_these_residues.end(), at->GetResidue()) == delete_these_residues.end()) + delete_these_residues.push_back(at->GetResidue()); } @@ -711,7 +711,7 @@ coot::match_container_for_residues_t::meld(mmdb::Manager *mol, std::pairseqNum += res_no_delta; + residue_p->GetSeqNum() += res_no_delta; } mmdb::Chain *to_chain_p = residue_2->GetChain(); @@ -733,7 +733,7 @@ coot::match_container_for_residues_t::meld(mmdb::Manager *mol, std::pairseqNum += res_no_delta; + r->GetSeqNum() += res_no_delta; } } } @@ -776,7 +776,7 @@ coot::match_container_for_residues_t::meld_residues(std::vector if (! residue_p) continue; if (residue_p != residue_2) { residue_spec_t spec_pre(residue_p); - residue_p->seqNum += res_no_delta; + residue_p->GetSeqNum() += res_no_delta; residue_spec_t spec_post(residue_p); if (false) // debug std::cout << "in meld_residues() res_no_delta " << res_no_delta << " " << " residue " << spec_pre << " becomes " diff --git a/coot-utils/mmdb-to-clipper-atom-list.hh b/coot-utils/mmdb-to-clipper-atom-list.hh new file mode 100644 index 0000000000..daeff1e26e --- /dev/null +++ b/coot-utils/mmdb-to-clipper-atom-list.hh @@ -0,0 +1,76 @@ +/* + * coot-utils/mmdb-to-clipper-atom-list.hh + * + * Copyright 2026 Jordan Dialpuri, Medical Research Council Laboratory of Molecular Biology + * + * This file is part of Coot + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copies of the GNU General Public License and + * the GNU Lesser General Public License along with this program; if not, + * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301, USA. + * See http://www.gnu.org/licenses/ + */ + +#ifndef COOT_UTILS_MMDB_TO_CLIPPER_ATOM_LIST_HH +#define COOT_UTILS_MMDB_TO_CLIPPER_ATOM_LIST_HH + +#include +#include +#include + +namespace coot { + + //! A drop-in replacement for clipper::MMDBAtom_list. + // + // clipper::MMDBAtom (clipper/mmdb/clipper_mmdb.cpp) derives from mmdb::CAtom and + // reads the atom's coordinate/element/occupancy/B as *public data members* + // (`return Coord_orth(x,y,z);`, `String(mmdb::CAtom::element)`, ...). Those method + // bodies are compiled into libclipper-mmdb against real MMDB's memory layout, so + // reinterpret-casting an mmdb-shim atom (which is gemmi-backed, with a completely + // different layout, and exposes x()/element via accessor methods) to MMDBAtom* + // reads garbage — every structure-factor calculation then sees junk coordinates. + // + // clipper::Atom / Atom_list are pure clipper value types with no MMDB dependency, + // so we build the Atom_list ourselves through the shim's accessor methods. The + // result feeds clipper's SFcalc unchanged. Matches clipper::MMDBAtom's field + // semantics: element as the PDB-aligned 2-char string, isotropic U from B, and + // anisotropic U only when ANISOU was present. + class MMDBAtom_list : public clipper::Atom_list { + public: + MMDBAtom_list(const mmdb::PPAtom ppcatom, const int natom) { + reserve(natom); + for (int i = 0; i < natom; i++) { + mmdb::Atom *at = ppcatom[i]; + if (!at) continue; + clipper::Atom a; + a.set_element(clipper::String(at->GetElementName())); + if (!at->isTer()) + a.set_coord_orth(clipper::Coord_orth(at->x(), at->y(), at->z())); + else + a.set_coord_orth(clipper::Coord_orth(clipper::Coord_orth::null())); + a.set_occupancy(at->occupancy()); + a.set_u_iso(clipper::Util::b2u(at->tempFactor())); + if (at->WhatIsSet & ::mmdb::ASET_Anis_tFac) + a.set_u_aniso_orth(clipper::U_aniso_orth(at->u11(), at->u22(), at->u33(), + at->u12(), at->u13(), at->u23())); + else + a.set_u_aniso_orth(clipper::U_aniso_orth(clipper::U_aniso_orth::null())); + push_back(a); + } + } + }; + +} // namespace coot + +#endif // COOT_UTILS_MMDB_TO_CLIPPER_ATOM_LIST_HH diff --git a/coot-utils/mutate.cc b/coot-utils/mutate.cc index 2609042b65..cfd4c539a7 100644 --- a/coot-utils/mutate.cc +++ b/coot-utils/mutate.cc @@ -60,18 +60,18 @@ coot::util::mutate_internal(mmdb::Residue *residue, std::cout << "mutate_internal() Mutate Atom Tables" << std::endl; std::cout << "mutate_internal() Before " << residue_spec_t(residue) <name << std::endl; + std::cout << residue_atoms[i]->GetAtomName() << std::endl; std::cout << "mutate_internal() To be replaced by: " << residue_spec_t(std_residue) << std::endl; for(int i=0; iname << std::endl; + std::cout << std_residue_atoms[i]->GetAtomName() << std::endl; } // only touch the atoms with given alt conf, ignore the others. std::string to_residue_type = std_residue->GetResName(); for(int i=0; ialtLoc); + std::string atom_alt_conf(residue_atoms[i]->altLoc()); if (atom_alt_conf == alt_conf) { - std::string residue_this_atom (residue_atoms[i]->name); + std::string residue_this_atom (residue_atoms[i]->GetAtomName()); if (coot::is_main_chain_p(residue_atoms[i])) { if (to_residue_type == "MSE") { residue_atoms[i]->Het = 1; @@ -80,12 +80,12 @@ coot::util::mutate_internal(mmdb::Residue *residue, residue_atoms[i]->Het = 0; // from MSE to MET, say } if (to_residue_type == "PRO") { - std::string atom_name(residue_atoms[i]->name); + std::string atom_name(residue_atoms[i]->GetAtomName()); if (atom_name == " H ") // PDBv3 FIXME residue->DeleteAtom(i); } if (to_residue_type == "GLY") { - std::string atom_name(residue_atoms[i]->name); + std::string atom_name(residue_atoms[i]->GetAtomName()); if (atom_name == " HA ") // PDBv3 FIXME residue->DeleteAtom(i); if (atom_name == " CB ") // PDBv3 FIXME @@ -101,11 +101,11 @@ coot::util::mutate_internal(mmdb::Residue *residue, } for(int i=0; iname); + std::string std_residue_this_atom (std_residue_atoms[i]->GetAtomName()); if (! coot::is_main_chain_p(std_residue_atoms[i])) { if (is_from_shelx_ins_flag) - std_residue_atoms[i]->occupancy = 11.0; - std_residue_atoms[i]->tempFactor = b_factor; + std_residue_atoms[i]->occupancy() = 11.0; + std_residue_atoms[i]->tempFactor() = b_factor; mmdb::Atom *copy_at = new mmdb::Atom; copy_at->Copy(std_residue_atoms[i]); // std::cout << "adding atom " << coot::atom_spec_t(copy_at) << std::endl; @@ -114,7 +114,7 @@ coot::util::mutate_internal(mmdb::Residue *residue, strcpy(copy_at->segID, old_seg_id_for_residue_atoms.c_str()); } if (alt_conf != "") - strcpy(copy_at->altLoc, alt_conf.c_str()); + strcpy(copy_at->altLoc(), alt_conf.c_str()); } } @@ -147,14 +147,14 @@ coot::util::mutate(mmdb::Residue *res, mmdb::Residue *std_res_unoriented, const } else { for(int iat=0; iatx, at->y, at->z); + clipper::Coord_orth co(at->x(), at->y(), at->z()); std::map::const_iterator it = rtops.find(alt_conf); if (it != rtops.end()) { clipper::Coord_orth rotted = co.transform(it->second); - at->x = rotted.x(); - at->y = rotted.y(); - at->z = rotted.z(); + at->x() = rotted.x(); + at->y() = rotted.y(); + at->z() = rotted.z(); } } @@ -393,11 +393,11 @@ coot::util::mutate_base(mmdb::Residue *residue, mmdb::Residue *std_base, for (int j=0; jname; + std::string atom_name = mol_base_atoms[i]->GetAtomName(); if (refrce_name_vector[j] == atom_name) { - refrce_atom_positions.push_back(clipper::Coord_orth(mol_base_atoms[i]->x, - mol_base_atoms[i]->y, - mol_base_atoms[i]->z)); + refrce_atom_positions.push_back(clipper::Coord_orth(mol_base_atoms[i]->x(), + mol_base_atoms[i]->y(), + mol_base_atoms[i]->z())); if (debug) std::cout << "Found " << atom_name << " in reference " << std::endl; } @@ -406,11 +406,11 @@ coot::util::mutate_base(mmdb::Residue *residue, mmdb::Residue *std_base, for (int j=0; jname; + std::string atom_name = std_base_atoms[i]->GetAtomName(); if (moving_name_vector[j] == atom_name) { - moving_atom_positions.push_back(clipper::Coord_orth(std_base_atoms[i]->x, - std_base_atoms[i]->y, - std_base_atoms[i]->z)); + moving_atom_positions.push_back(clipper::Coord_orth(std_base_atoms[i]->x(), + std_base_atoms[i]->y(), + std_base_atoms[i]->z())); if (debug) std::cout << "Found " << atom_name << " in moving (std) base " << std::endl; } @@ -505,10 +505,10 @@ coot::util::mutate_base(mmdb::Residue *residue, mmdb::Residue *std_base, for (int i=0; iname) { + if (mol_base_atom_names[iat] == mol_base_atoms[i]->GetAtomName()) { if (debug) - std::cout << ".... Deleting Atom " << mol_base_atoms[i]->name + std::cout << ".... Deleting Atom " << mol_base_atoms[i]->GetAtomName() << " i = " << i << std::endl; residue->DeleteAtom(i); @@ -543,18 +543,18 @@ coot::util::mutate_base(mmdb::Residue *residue, mmdb::Residue *std_base, for (unsigned int iat=0; iatname) { - clipper::Coord_orth p(std_base_atoms[i]->x, - std_base_atoms[i]->y, - std_base_atoms[i]->z); + if (std_base_atom_names[iat] == std_base_atoms[i]->GetAtomName()) { + clipper::Coord_orth p(std_base_atoms[i]->x(), + std_base_atoms[i]->y(), + std_base_atoms[i]->z()); clipper::Coord_orth pt = p.transform(rtop); std::string ele = std_base_atom_names[iat].substr(0,2); at = new mmdb::Atom; if (debug) - std::cout << ".... Adding Atom " << std_base_atoms[i]->name + std::cout << ".... Adding Atom " << std_base_atoms[i]->GetAtomName() << std::endl; at->SetCoordinates(pt.x(), pt.y(), pt.z(), 1.0, b_factor); - std::string new_atom_name = std_base_atoms[i]->name; + std::string new_atom_name = std_base_atoms[i]->GetAtomName(); if (std_base_name == "DT") if (new_atom_name == " C5M") if (! use_old_style_naming) @@ -563,7 +563,7 @@ coot::util::mutate_base(mmdb::Residue *residue, mmdb::Residue *std_base, at->SetElementName(ele.c_str()); std::string new_alt_conf(""); // force it down the atom's throat :) [is there a better way?] - strncpy(at->altLoc, new_alt_conf.c_str(), 2); + strncpy(at->altLoc(), new_alt_conf.c_str(), 2); residue->AddAtom(at); if (use_old_seg_id) strcpy(at->segID, old_seg_id_for_residue_atoms.c_str()); diff --git a/coot-utils/peak-search.cc b/coot-utils/peak-search.cc index 364df2330e..1c036aafd6 100644 --- a/coot-utils/peak-search.cc +++ b/coot-utils/peak-search.cc @@ -710,7 +710,7 @@ coot::peak_search::make_sample_protein_coords(mmdb::Manager *mol, int every_n) c for (int iat=0; iatGetAtom(iat); - r.push_back(clipper::Coord_orth(at->x, at->y, at->z)); + r.push_back(clipper::Coord_orth(at->x(), at->y(), at->z())); atom_count = 0; } atom_count++; diff --git a/coot-utils/pepflip-using-difference-map.cc b/coot-utils/pepflip-using-difference-map.cc index 0601e75baa..53e4450434 100644 --- a/coot-utils/pepflip-using-difference-map.cc +++ b/coot-utils/pepflip-using-difference-map.cc @@ -74,7 +74,7 @@ coot::pepflip_using_difference_map::get_suggested_flips(float n_sigma) const { float d2 = util::density_at_point(diff_map, pt_2); float delta = d2-d1; if (delta > cut) { - residue_spec_t spec(t.CA_this->residue); + residue_spec_t spec(t.CA_this->GetResidue()); rv.push_back(spec); // std::cout << "INFO:: Adding pepflip: " << spec << " z: " << delta/sd << std::endl; } @@ -120,13 +120,13 @@ coot::pepflip_using_difference_map::get_peptide_atom_triplets() const { if (! at->isTer()) { std::string atom_name(at->GetAtomName()); if (atom_name == " O ") { - std::string alt_loc(at->altLoc); + std::string alt_loc(at->altLoc()); if (alt_loc == "") { O_this = at; } } if (atom_name == " CA ") { - std::string alt_loc(at->altLoc); + std::string alt_loc(at->altLoc()); if (alt_loc == "") { CA_this = at; } @@ -141,7 +141,7 @@ coot::pepflip_using_difference_map::get_peptide_atom_triplets() const { if (! at->isTer()) { std::string atom_name(at->GetAtomName()); if (atom_name == " CA ") { - std::string alt_loc(at->altLoc); + std::string alt_loc(at->altLoc()); if (alt_loc == "") { CA_next = at; break; diff --git a/coot-utils/plane-utils.cc b/coot-utils/plane-utils.cc index c21a1734d4..55692b9919 100644 --- a/coot-utils/plane-utils.cc +++ b/coot-utils/plane-utils.cc @@ -49,7 +49,7 @@ coot::angle_betwen_plane_and_vector(mmdb::Residue *residue_p, for (int iat=0; iatGetAtomName()); - std::string alt_conf(at->altLoc); + std::string alt_conf(at->altLoc()); std::vector::const_iterator it = std::find(ring_atom_names.begin(), ring_atom_names.end(), atom_name); if (it != ring_atom_names.end()) { @@ -84,7 +84,7 @@ coot::angle_betwen_plane_and_vector(mmdb::Residue *residue_p, clipper::Coord_orth pt_2 = co(bonding_atom); clipper::Coord_orth dv = pt_1 - pt_2; - std::string alt_conf(bonding_atom->altLoc); + std::string alt_conf(bonding_atom->altLoc()); std::string res_name(residue_p->GetResName()); std::vector ring_atom_names; diff --git a/coot-utils/polar-atoms.cc b/coot-utils/polar-atoms.cc index 8c4c790764..c44961d596 100644 --- a/coot-utils/polar-atoms.cc +++ b/coot-utils/polar-atoms.cc @@ -83,7 +83,7 @@ coot::buried_unsatisfied_polar_atoms(mmdb::Manager *mol) { std::vector is_polar(n_selected_atoms, false); for (int i=0; iresidue->GetResName()); + std::string res_name(at->GetResidue()->GetResName()); std::string at_name(at->GetAtomName()); quick_protein_donor_acceptors::key k(res_name, at_name); hb_t hb_type = pda.get_type(k); @@ -103,7 +103,7 @@ coot::buried_unsatisfied_polar_atoms(mmdb::Manager *mol) { if (at) { if (! at->isTer()) { bool found_something = false; - std::string res_name(at->residue->GetResName()); + std::string res_name(at->GetResidue()->GetResName()); std::string at_name(at->GetAtomName()); quick_protein_donor_acceptors::key key_1(res_name, at_name); std::set::const_iterator it; @@ -111,7 +111,7 @@ coot::buried_unsatisfied_polar_atoms(mmdb::Manager *mol) { mmdb::Atom *at_neighb = atom_selection[*it]; if (at_neighb) { if (! at_neighb->isTer()) { - std::string res_name_n(at->residue->GetResName()); + std::string res_name_n(at->GetResidue()->GetResName()); std::string at_name_n(at->GetAtomName()); quick_protein_donor_acceptors::key key_2(res_name_n, at_name_n); std::pair is_valid = pda.is_hydrogen_bond_by_types(key_1, key_2); diff --git a/coot-utils/q-score.hh b/coot-utils/q-score.hh index 218271e040..86551b2bc3 100644 --- a/coot-utils/q-score.hh +++ b/coot-utils/q-score.hh @@ -270,7 +270,7 @@ namespace coot { at->PutUDData(udd_q_score, q_score); if (false) std::cout << "results per atom " << atom_spec_t(at) << " " << q_score - << " B-factor " << at->tempFactor << std::endl; + << " B-factor " << at->tempFactor() << std::endl; if (q_score > -1000.0) residue_q_scores[res_spec].add(q_score); } diff --git a/coot-utils/read-sm-cif.cc b/coot-utils/read-sm-cif.cc index 29597f616f..430f8d45b8 100644 --- a/coot-utils/read-sm-cif.cc +++ b/coot-utils/read-sm-cif.cc @@ -29,6 +29,7 @@ #include #include #include +#include "mmdb-to-clipper-atom-list.hh" #include "clipper/core/clipper_instance.h" // tidy up space group cache #include "clipper/core/resol_basisfn.h" #include "clipper/contrib/sfcalc_obs.h" @@ -262,10 +263,10 @@ coot::smcif::read_coordinates(mmdb::mmcif::PData data, const clipper::Cell &cell if (ele.first == "BR") charge = -1; if (ele.first == "I") charge = -1; - at->charge = charge; + at->charge() = charge; if (alt_loc.length()) - strncpy(at->altLoc, alt_loc.c_str(), (alt_loc.size()+1)); // shove. + strncpy(at->altLoc(), alt_loc.c_str(), (alt_loc.size()+1)); // shove. if (false) std::cout << " found atom: \"" << label << "\" symbol: \"" << symbol @@ -331,12 +332,12 @@ coot::smcif::read_coordinates(mmdb::mmcif::PData data, const clipper::Cell &cell clipper::U_aniso_frac caf(u11/(a*a), u22/(b*b), u33/(c*c), u12/(a*b), u13/(a*c), u23/(b*c)); clipper::U_aniso_orth cao = caf.u_aniso_orth(cell); - at->u11 = cao(0,0); - at->u22 = cao(1,1); - at->u33 = cao(2,2); - at->u12 = cao(0,1); - at->u13 = cao(0,2); - at->u23 = cao(1,2); + at->u11() = cao(0,0); + at->u22() = cao(1,1); + at->u33() = cao(2,2); + at->u12() = cao(0,1); + at->u13() = cao(0,2); + at->u23() = cao(1,2); at->WhatIsSet |= mmdb::ASET_Anis_tFac; // is anisotropic } } @@ -448,7 +449,7 @@ coot::smcif::read_sm_cif(const std::string &file_name) const { mmdb::Chain *chain_p = new mmdb::Chain; mmdb::Residue *residue_p = new mmdb::Residue; chain_p->SetChainID(""); - residue_p->seqNum = 1; + residue_p->GetSeqNum() = 1; residue_p->SetResName("XXX"); for (unsigned int iat=0; iatAddAtom(atoms[iat]); @@ -1089,7 +1090,7 @@ coot::smcif::sigmaa_maps_by_calc_sfs(mmdb::Atom **atom_selection, int n_selected mydata.cell(), hkl_sampling_local); // get a list of all the atoms - clipper::MMDBAtom_list atoms(atom_selection, n_selected_atoms); + coot::MMDBAtom_list atoms(atom_selection, n_selected_atoms); clipper::HKL_data< clipper::datatypes::F_phi > fphidata(mydata.spacegroup(), mydata.cell(), hkl_sampling_local); diff --git a/coot-utils/reduce.cc b/coot-utils/reduce.cc index e7411f1cfe..9cbcc09032 100644 --- a/coot-utils/reduce.cc +++ b/coot-utils/reduce.cc @@ -603,7 +603,7 @@ coot::reduce::add_main_chain_H(mmdb::Residue *residue_p, mmdb::Residue *residue_ clipper::Coord_orth at_ca_pos = co(at_ca); double angle = clipper::Util::d2rad(125.0); clipper::Coord_orth H_pos(at_ca_pos, at_c_pos, at_n_pos, bl, angle, M_PI); - mmdb::realtype bf = at_n->tempFactor; + mmdb::realtype bf = at_n->tempFactor(); add_hydrogen_atom(" H ", H_pos, bf, alt_confs[i], residue_p); } } @@ -653,7 +653,7 @@ coot::reduce::add_main_chain_HA(mmdb::Residue *residue_p) { mmdb::Atom *at_n3 = residue_p->GetAtom(" CB ", 0, alt_confs[i].c_str()); if (at_ca && at_n1 && at_n2 && at_n3) { clipper::Coord_orth pos = position_by_tetrahedron(at_ca, at_n1, at_n2, at_n3, bl); - mmdb::realtype bf = at_ca->tempFactor; + mmdb::realtype bf = at_ca->tempFactor(); add_hydrogen_atom(" HA ", pos, bf, alt_confs[i], residue_p); } } @@ -670,7 +670,7 @@ coot::reduce::add_hydrogen_atom(std::string atom_name, clipper::Coord_orth &pos, new_H->SetElementName(" H"); // PDBv3 FIXME new_H->SetCoordinates(pos.x(), pos.y(), pos.z(), 1.0, bf); if (! altconf.empty()) - strncpy(new_H->altLoc, altconf.c_str(), 18); // 19 is mmdb limit, I think + strncpy(new_H->altLoc(), altconf.c_str(), 18); // 19 is mmdb limit, I think // now test if the atom is there already. // @@ -682,8 +682,8 @@ coot::reduce::add_hydrogen_atom(std::string atom_name, clipper::Coord_orth &pos, bool already_exits = 0; residue_p->GetAtomTable(residue_atoms, n_atoms); for (int i=0; iname; - std::string residue_atom_alt_conf = residue_atoms[i]->altLoc; + std::string residue_atom_name = residue_atoms[i]->GetAtomName(); + std::string residue_atom_alt_conf = residue_atoms[i]->altLoc(); if (residue_atom_name == atom_name) { if (residue_atom_alt_conf == altconf) { already_exits = true; @@ -770,7 +770,7 @@ coot::reduce::add_methyl_Hs(const std::string &at_name_1, // HB1 (for example) clipper::Coord_orth pav_2 = p12; clipper::Coord_orth pav_3 = p13; if (at_3) { - mmdb::realtype bf = at_3->tempFactor; + mmdb::realtype bf = at_3->tempFactor(); mmdb::Atom *at_H_0 = add_hydrogen_atom(at_name_1, pav_1, bf, alt_confs[i], residue_p); mmdb::Atom *at_H_1 = add_hydrogen_atom(at_name_2, pav_2, bf, alt_confs[i], residue_p); mmdb::Atom *at_H_2 = add_hydrogen_atom(at_name_3, pav_3, bf, alt_confs[i], residue_p); @@ -819,7 +819,7 @@ coot::reduce::add_methyl_Hs(const std::string &at_name_1, // HB1 (for example) clipper::Coord_orth pav_1 = p11; clipper::Coord_orth pav_2 = p12; clipper::Coord_orth pav_3 = p13; - mmdb::realtype bf = at_3->tempFactor; + mmdb::realtype bf = at_3->tempFactor(); mmdb::Atom *at_0 = add_hydrogen_atom(at_name_1, pav_1, bf, alt_confs[i], residue_p); mmdb::Atom *at_1 = add_hydrogen_atom(at_name_2, pav_2, bf, alt_confs[i], residue_p); mmdb::Atom *at_2 = add_hydrogen_atom(at_name_3, pav_3, bf, alt_confs[i], residue_p); @@ -859,7 +859,7 @@ coot::reduce::add_2_sp3_hydrogens(const std::string &H_at_name_1, std::pair Hs = position_pair_by_bisection(at_1, at_2, at_3, bond_length, clipper::Util::d2rad(angle_between_Hs)); - mmdb::realtype bf = at_2->tempFactor; + mmdb::realtype bf = at_2->tempFactor(); if (! choose_only_farthest_position) { add_hydrogen_atom(H_at_name_1, Hs.first, bf, alt_confs[i], residue_p); add_hydrogen_atom(H_at_name_2, Hs.second, bf, alt_confs[i], residue_p); @@ -937,7 +937,7 @@ coot::reduce::add_tetrahedral_hydrogen(const std::string &H_at_name, if (at_central && at_n_1 && at_n_2 && at_n_3) { clipper::Coord_orth H_pos = position_by_tetrahedron(at_central, at_n_1, at_n_2, at_n_3, bond_length); - mmdb::realtype bf = at_central->tempFactor; + mmdb::realtype bf = at_central->tempFactor(); add_hydrogen_atom(H_at_name, H_pos, bf, alt_confs[i], residue_p); } } @@ -982,7 +982,7 @@ coot::reduce::add_aromatic_hydrogen(const std::string &H_at_name, mmdb::Atom *at_n_2 = residue_p->GetAtom(neighb_at_name_2.c_str(), 0, alt_confs[i].c_str()); mmdb::Atom *at_n_3 = residue_p->GetAtom(neighb_at_name_3.c_str(), 0, alt_confs[i].c_str()); if (at_n_1 && at_n_2 && at_n_3) { - mmdb::realtype bf = at_n_2->tempFactor; + mmdb::realtype bf = at_n_2->tempFactor(); clipper::Coord_orth H_pos = position_by_bisection(at_n_1, at_n_2, at_n_3, bl); add_hydrogen_atom(H_at_name, H_pos, bf, alt_confs[i], residue_p); } else { @@ -1031,7 +1031,7 @@ coot::reduce::add_amino_hydrogens(const std::string &H_at_name_1, bl_amino, clipper::Util::d2rad(120), clipper::Util::d2rad(0)); - mmdb::realtype bf = at_n_1->tempFactor; + mmdb::realtype bf = at_n_1->tempFactor(); add_hydrogen_atom(H_at_name_1, Hp1, bf, alt_confs[i], residue_p); add_hydrogen_atom(H_at_name_2, Hp2, bf, alt_confs[i], residue_p); } @@ -1085,7 +1085,7 @@ coot::reduce::add_guanidinium_hydrogens(mmdb::Residue *residue_p) { mmdb::Atom *at_n_2 = residue_p->GetAtom(" NE ", 0, alt_confs[i].c_str()); mmdb::Atom *at_n_3 = residue_p->GetAtom(" CZ ", 0, alt_confs[i].c_str()); if (at_n_1 && at_n_2 && at_n_3) { - mmdb::realtype bf = at_n_2->tempFactor; + mmdb::realtype bf = at_n_2->tempFactor(); clipper::Coord_orth H_pos = position_by_bisection(at_n_1, at_n_2, at_n_3, bl); add_hydrogen_atom(H_at_name, H_pos, bf, alt_confs[i], residue_p); } else { @@ -1107,8 +1107,8 @@ coot::reduce::add_guanidinium_hydrogens(mmdb::Residue *residue_p) { mmdb::Atom *at_nh1 = residue_p->GetAtom(" NH1", 0, alt_confs[i].c_str()); mmdb::Atom *at_nh2 = residue_p->GetAtom(" NH2", 0, alt_confs[i].c_str()); if (at_n_1 && at_n_2 && at_nh1 && at_nh2) { - double bf_nh1 = at_nh1->tempFactor; - double bf_nh2 = at_nh2->tempFactor; + double bf_nh1 = at_nh1->tempFactor(); + double bf_nh2 = at_nh2->tempFactor(); double a = clipper::Util::d2rad(120); double t = clipper::Util::d2rad(180); clipper::Coord_orth hh11 = position_by_bond_length_angle_torsion(at_n_1, at_n_2, at_nh1, bl, a, 0); @@ -1149,7 +1149,7 @@ coot::reduce::add_trp_indole_hydrogen(const std::string &H_name, mmdb::Atom *at_3 = residue_p->GetAtom(at_name_3.c_str(), 0, alt_confs[i].c_str()); if (at_1 && at_2 && at_3) { clipper::Coord_orth H_pos = position_by_bisection(at_1, at_2, at_3, bl); - double bf = at_2->tempFactor; + double bf = at_2->tempFactor(); add_hydrogen_atom(H_name, H_pos, bf, alt_confs[i], residue_p); } } @@ -1244,7 +1244,7 @@ coot::reduce::add_xH_H(const std::string &H_name, clipper::Coord_orth H_pos = position_by_bond_length_angle_torsion(at_3, at_2, at_1, bl, clipper::Util::d2rad(angle), clipper::Util::d2rad(tor_inital)); - double bf = at_2->tempFactor; + double bf = at_2->tempFactor(); mmdb::Atom *at = add_hydrogen_atom(H_name, H_pos, bf, alt_confs[i], residue_p); r.push_back(at); spinables.add(at_1, atom_with_attached_Hs::HYDROXYL, at); // maybe need SULFHYDRYL separate? @@ -1280,7 +1280,7 @@ coot::reduce::add_his_ring_H(const std::string &H_name, mmdb::Atom *at_3 = residue_p->GetAtom(at_name_3.c_str(), 0, alt_confs[i].c_str()); if (at_1 && at_2 && at_3) { clipper::Coord_orth H_pos = position_by_bisection(at_1, at_2, at_3, bl_arom); - double bf = at_2->tempFactor; + double bf = at_2->tempFactor(); mmdb::Atom *at = add_hydrogen_atom(H_name, H_pos, bf, alt_confs[i], residue_p); r.push_back(at); } @@ -1381,7 +1381,7 @@ coot::reduce::switch_his_protonation(mmdb::Residue *residue_p, // double bl_arom = 0.93; if (current_H_atom) { - std::string atom_name = current_H_atom->name; + std::string atom_name = current_H_atom->GetAtomName(); std::string new_atom_name; if (atom_name == " HD1") new_atom_name = " HE2"; if (atom_name == " HE2") new_atom_name = " HD1"; @@ -1399,7 +1399,7 @@ coot::reduce::switch_his_protonation(mmdb::Residue *residue_p, at_name_2 = " NE2"; at_name_3 = " CD2"; } - std::string alt_conf = current_H_atom->altLoc; + std::string alt_conf = current_H_atom->altLoc(); mmdb::Atom *at_1 = residue_p->GetAtom(at_name_1.c_str(), 0, alt_conf.c_str()); mmdb::Atom *at_2 = residue_p->GetAtom(at_name_2.c_str(), 0, alt_conf.c_str()); mmdb::Atom *at_3 = residue_p->GetAtom(at_name_3.c_str(), 0, alt_conf.c_str()); @@ -1407,7 +1407,7 @@ coot::reduce::switch_his_protonation(mmdb::Residue *residue_p, std::cout << "switch_his_protonation() " << 2 << " " << new_atom_name << std::endl; current_H_atom->SetAtomName(new_atom_name.c_str()); clipper::Coord_orth pos = position_by_bisection(at_1, at_2, at_3, bl_arom); - double bf = current_H_atom->tempFactor; + double bf = current_H_atom->tempFactor(); current_H_atom->SetCoordinates(pos.x(), pos.y(), pos.z(), 1.0, bf); } } @@ -1553,7 +1553,7 @@ coot::reduce::delete_atom_by_name(const std::string &at_name, mmdb::Residue *res int n_atoms = residue_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - std::string ele(at->element); + std::string ele(at->GetElementName()); if (ele == " H" || ele == " D") { residue_p->DeleteAtom(iat); an_atom_was_deleted = true; @@ -1582,7 +1582,7 @@ coot::reduce::delete_hydrogen_atoms() { int n_atoms = residue_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - std::string ele(at->element); + std::string ele(at->GetElementName()); if (ele == " H" || ele == " D") { atoms_to_be_deleted.push_back(at); } @@ -1910,7 +1910,7 @@ coot::reduce::atoms_with_spinnable_Hs::add(mmdb::Atom *at, atom_with_attached_Hs::hydrogen_t type, const std::vector &attached_hydrogen_atoms) { - std::string alt_loc(at->altLoc); + std::string alt_loc(at->altLoc()); atom_with_attached_Hs awaH(at, type, attached_hydrogen_atoms); typed_atoms[alt_loc].push_back(awaH); } @@ -1920,7 +1920,7 @@ coot::reduce::atoms_with_spinnable_Hs::add(mmdb::Atom *at, atom_with_attached_Hs::hydrogen_t type, mmdb::Atom *attahed_hydrogen_atom) { - std::string alt_loc(at->altLoc); + std::string alt_loc(at->altLoc()); std::vector v; v.push_back(attahed_hydrogen_atom); atom_with_attached_Hs awaH(at, type, v); @@ -1958,7 +1958,7 @@ coot::reduce::atoms_with_spinnable_Hs::cliquize() { clipper::Coord_orth at_pos = co(atoms[iat].at); for (unsigned int icl=0; iclresidue != cliques[icl][j].at->residue) { + if (atoms[iat].at->GetResidue() != cliques[icl][j].at->GetResidue()) { clipper::Coord_orth pos = co(cliques[icl][j].at); clipper::Coord_orth diff(at_pos - pos); double dv_sqrd = diff.lengthsq(); diff --git a/coot-utils/secondary-structure-headers.cc b/coot-utils/secondary-structure-headers.cc index 9d07819442..e01746c9de 100644 --- a/coot-utils/secondary-structure-headers.cc +++ b/coot-utils/secondary-structure-headers.cc @@ -371,8 +371,8 @@ coot::secondary_structure_header_records::get_sheet_order(mmdb::Manager *mol, for (int ic=0; icresidue; - mmdb::Residue *r_2 = at_2->residue; + mmdb::Residue *r_1 = at_1->GetResidue(); + mmdb::Residue *r_2 = at_2->GetResidue(); if (r_1 != r_2) { int rn_1 = r_1->GetSeqNum(); int rn_2 = r_2->GetSeqNum(); diff --git a/coot-utils/sfcalc-genmap.cc b/coot-utils/sfcalc-genmap.cc index 871100dd39..4f2b3e04ed 100644 --- a/coot-utils/sfcalc-genmap.cc +++ b/coot-utils/sfcalc-genmap.cc @@ -34,6 +34,7 @@ #include #include "sfcalc-genmap.hh" +#include "mmdb-to-clipper-atom-list.hh" // calculate structure factors from the given model and data // and update the map xmap_p @@ -64,7 +65,7 @@ void coot::util::sfcalc_genmap(mmdb::Manager *mol, int hndl = mol->NewSelection(); // d mol->SelectAtoms(hndl, 0, 0, ::mmdb::SKEY_NEW); mol->GetSelIndex(hndl, atom_sel, nsel); - clipper::MMDBAtom_list atoms(atom_sel, nsel); + coot::MMDBAtom_list atoms(atom_sel, nsel); // clipper::MTZcrystal cxtl; clipper::HKL_info hkls; @@ -245,7 +246,7 @@ coot::util::sfcalc_genmaps_using_bulk_solvent(mmdb::Manager *mol, int hndl = mol->NewSelection(); // d mol->SelectAtoms(hndl, 0, 0, ::mmdb::SKEY_NEW); mol->GetSelIndex(hndl, atom_sel, nsel); - clipper::MMDBAtom_list atoms(atom_sel, nsel); + coot::MMDBAtom_list atoms(atom_sel, nsel); // std::cout << "DEBUG:: in sfcalc_genmaps_using_bulk_solvent() nsel for atoms " << nsel << std::endl; auto tp_2 = std::chrono::high_resolution_clock::now(); diff --git a/coot-utils/stack-and-pair.cc b/coot-utils/stack-and-pair.cc index 1e4c3eb212..0c0d678daa 100644 --- a/coot-utils/stack-and-pair.cc +++ b/coot-utils/stack-and-pair.cc @@ -77,7 +77,7 @@ coot::stack_and_pair::get_base_normal(mmdb::Residue *residue_p) const { residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); + std::string atom_name(at->GetAtomName()); if (base_atom_name_set.find(atom_name) != base_atom_name_set.end()) { v.push_back(co(at)); } @@ -100,7 +100,7 @@ coot::stack_and_pair::get_base_atom_names(mmdb::Residue *residue_p) const { residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); + std::string atom_name(at->GetAtomName()); if (base_atom_name_set.find(atom_name) != base_atom_name_set.end()) { v.push_back(atom_name); } @@ -120,7 +120,7 @@ coot::stack_and_pair::get_base_centre(mmdb::Residue *residue_p) const { residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); + std::string atom_name(at->GetAtomName()); if (base_atom_name_set.find(atom_name) != base_atom_name_set.end()) { centre_sum += co(at); n_centres++; @@ -160,7 +160,7 @@ coot::stack_and_pair::calculate_residue_normals(mmdb::Atom **SelAtom, int n_sel_ std::set done_res; std::map m; for (int i=0; iresidue; + mmdb::Residue *r = SelAtom[i]->GetResidue(); if (done_res.find(r) == done_res.end()) { std::pair bn = get_base_normal(r); if (bn.first) { @@ -186,7 +186,7 @@ coot::stack_and_pair::mark_donors_and_acceptors(mmdb::Manager *mol, int selectio int udd_h_bond_type_handle = mol->RegisterUDInteger(mmdb::UDR_ATOM, "hb_type"); for (int i=0; iname; + std::string name = at->GetAtomName(); std::string res_name = at->GetResName(); std::map::const_iterator it; @@ -342,17 +342,17 @@ coot::stack_and_pair::paired_residues(mmdb::Manager *mol, // in different residues and both are are O or N, and are close // enough together and both are nucleic acids - if (at_1->residue != at_2->residue) { - std::string ele_1(at_1->element); - std::string ele_2(at_2->element); + if (at_1->GetResidue() != at_2->GetResidue()) { + std::string ele_1(at_1->GetElementName()); + std::string ele_2(at_2->GetElementName()); // PDBv3 FIXME if (ele_1 == " O" || ele_1 == " N") { if (ele_2 == " O" || ele_2 == " N") { - float dx = at_1->x - at_2->x; - float dy = at_1->y - at_2->y; - float dz = at_1->z - at_2->z; + float dx = at_1->x() - at_2->x(); + float dy = at_1->y() - at_2->y(); + float dz = at_1->z() - at_2->z(); float dd = dx * dx + dy * dy + dz * dz; if (dd < dist_crit_sqrt) { int hb_type_1 = coot::HB_UNASSIGNED; @@ -365,17 +365,17 @@ coot::stack_and_pair::paired_residues(mmdb::Manager *mol, if (hb_type_2 == coot::HB_DONOR || hb_type_2 == coot::HB_BOTH) { if (at_1->GetChain() == at_2->GetChain()) { - int residue_index_1 = at_1->residue->index; - int residue_index_2 = at_2->residue->index; + int residue_index_1 = at_1->GetResidue()->GetIndex(); + int residue_index_2 = at_2->GetResidue()->GetIndex(); int residue_index_delta = residue_index_2 - residue_index_1; if (abs(residue_index_delta) < 2) continue; } - if (util::is_nucleotide(at_1->residue)) { - if (util::is_nucleotide(at_2->residue)) { + if (util::is_nucleotide(at_1->GetResidue())) { + if (util::is_nucleotide(at_2->GetResidue())) { - if (similar_normals(at_1->residue, at_2->residue, normal_map)) { + if (similar_normals(at_1->GetResidue(), at_2->GetResidue(), normal_map)) { // also, to stop base pairing the residue above // or below, we need to check the dot product @@ -388,8 +388,8 @@ coot::stack_and_pair::paired_residues(mmdb::Manager *mol, clipper::Coord_orth pt_2 = co(at_2); clipper::Coord_orth atom_atom_unit_vector((pt_2 - pt_1).unit()); - double dp_1 = clipper::Coord_orth::dot(atom_atom_unit_vector, normal_map[at_1->residue]); - double dp_2 = clipper::Coord_orth::dot(atom_atom_unit_vector, normal_map[at_2->residue]); + double dp_1 = clipper::Coord_orth::dot(atom_atom_unit_vector, normal_map[at_1->GetResidue()]); + double dp_2 = clipper::Coord_orth::dot(atom_atom_unit_vector, normal_map[at_2->GetResidue()]); if (false) { std::cout << " dot product 1 " << dp_1 << " " << atom_spec_t(at_1) << " " << atom_spec_t(at_2) << "\n"; @@ -400,8 +400,8 @@ coot::stack_and_pair::paired_residues(mmdb::Manager *mol, if (std::abs(dp_2) < 0.5) { // no ribose or phosphate atoms: - std::string name_1(at_1->name); - std::string name_2(at_2->name); + std::string name_1(at_1->GetAtomName()); + std::string name_2(at_2->GetAtomName()); if (excluded_oxygens.find(name_1) == excluded_oxygens.end()) { if (excluded_oxygens.find(name_2) == excluded_oxygens.end()) { @@ -438,8 +438,8 @@ coot::stack_and_pair::paired_residues(mmdb::Manager *mol, for (std::size_t i=0; iresidue; - mmdb::Residue *res_2 = at_2->residue; + mmdb::Residue *res_1 = at_1->GetResidue(); + mmdb::Residue *res_2 = at_2->GetResidue(); bool found = false; for (std::size_t j=0; jGetNumberOfResidues(); for (int ires=0; iresGetResidue(ires); - std::string resname = residue_p->name; + std::string resname = residue_p->GetResName(); if (((resname == "WAT" || resname == "HOH") && waters_only_flag) || !waters_only_flag) { @@ -68,7 +68,7 @@ coot::util::trim_molecule_by_map(mmdb::Manager *mol, for (int iat=0; iatGetAtom(iat); - clipper::Coord_orth co(at->x, at->y, at->z); + clipper::Coord_orth co(at->x(), at->y(), at->z()); if (density_at_point(xmap, co) < map_level) { // A baddie. What do we do with it? Set its @@ -80,7 +80,7 @@ coot::util::trim_molecule_by_map(mmdb::Manager *mol, } if (remove_or_zero_occ_flag == coot::util::TRIM_BY_MAP_ZERO_OCC) { - at->occupancy = 0.0; + at->occupancy() = 0.0; n_changed++; } } diff --git a/coot-utils/water-coordination.cc b/coot-utils/water-coordination.cc index 9a46269cd0..dc2d8f1951 100644 --- a/coot-utils/water-coordination.cc +++ b/coot-utils/water-coordination.cc @@ -132,8 +132,8 @@ coot::util::water_coordination_t::init_internal(mmdb::Manager *mol, coot::util::contact_atoms_info_t::contact_atom_t::contact_atom_t(mmdb::Atom *contactor, mmdb::Atom *central_atom) { - clipper::Coord_orth co_1( contactor->x, contactor->y, contactor->z); - clipper::Coord_orth co_2(central_atom->x, central_atom->y, central_atom->z); + clipper::Coord_orth co_1( contactor->x(), contactor->y(), contactor->z()); + clipper::Coord_orth co_2(central_atom->x(), central_atom->y(), central_atom->z()); dist = clipper::Coord_orth::length(co_1, co_2); at = contactor; for (int i=0; i<4; i++) @@ -148,8 +148,8 @@ coot::util::contact_atoms_info_t::contact_atom_t::contact_atom_t(mmdb::Atom *con mmdb::Atom *central_atom, const mmdb::mat44 &m) { - clipper::Coord_orth co_1( contactor->x, contactor->y, contactor->z); - clipper::Coord_orth co_2(central_atom->x, central_atom->y, central_atom->z); + clipper::Coord_orth co_1( contactor->x(), contactor->y(), contactor->z()); + clipper::Coord_orth co_2(central_atom->x(), central_atom->y(), central_atom->z()); dist = clipper::Coord_orth::length(co_1, co_2); at = contactor; for (int i=0; i<4; i++) @@ -165,13 +165,13 @@ coot::util::water_coordination_t::add_contact(mmdb::Atom *atom_central, mmdb::Atom *atom_contactor, const mmdb::mat44 &mat) { - std::string alt_conf_1 = atom_contactor->altLoc; - std::string alt_conf_2 = atom_central->altLoc; + std::string alt_conf_1 = atom_contactor->altLoc(); + std::string alt_conf_2 = atom_central->altLoc(); if ((alt_conf_1 == alt_conf_2) || (alt_conf_1 == "") || (alt_conf_2 == "")) { // filter out H water contacts. - std::string ele(atom_contactor->element); + std::string ele(atom_contactor->GetElementName()); if (ele != " H") { coot::util::contact_atoms_info_t::contact_atom_t con_at(atom_contactor, atom_central, mat); // @@ -363,7 +363,7 @@ coot::util::contact_atoms_info_t::test_for_ele(coot::util::contact_atoms_info_t: int n_contacts = 0; if (contact_atoms.size() > 2) { for (unsigned int j=0; jelement); + std::string ele(contact_atoms[j].at->GetElementName()); double Rj = contact_atoms[j].dist; if (Rj < R0) { // it's too close to a neighbor to be the required metal type. sum_v_j = 0; @@ -371,7 +371,7 @@ coot::util::contact_atoms_info_t::test_for_ele(coot::util::contact_atoms_info_t: } if (ele == " O") { double v_j = pow(Rj/R0, -N); - double occ = contact_atoms[j].at->occupancy; // symmetry overlaps handled. + double occ = contact_atoms[j].at->occupancy(); // symmetry overlaps handled. sum_v_j += v_j * occ; // was it a protein atom contact < 3.5A? We need at least 1 of them. std::string resname(contact_atoms[j].at->GetResName()); @@ -410,7 +410,7 @@ coot::util::contact_atoms_info_t::test_for_ele(coot::util::contact_atoms_info_t: << ele_index << std::endl; sum_v_j = 0.0; for (unsigned int j=0; jelement); + std::string ele(contact_atoms[j].at->GetElementName()); double Rj = contact_atoms[j].dist; if (ele == " O") { double v_j = pow(Rj/R0, -N); diff --git a/db-main/db-strands.cc b/db-main/db-strands.cc index 5b04a6b5c2..41fb2ad626 100644 --- a/db-main/db-strands.cc +++ b/db-main/db-strands.cc @@ -246,7 +246,7 @@ coot::db_strands::trim_to_mainchain(mmdb::Manager *mol) const { for (int iat=0; iatGetAtom(iat); - std::string ele = at->element; + std::string ele = at->GetElementName(); if (!is_main_chain_or_cb_p(at) || ele == " H" || ele == " D") { residue_p->DeleteAtom(iat); @@ -282,17 +282,17 @@ coot::db_strands::orient_strand_on_z(int SelHnd, mmdb::Manager *mol) const { residue_p->GetAtomTable(atoms, n_atoms); for (int iat=0; iatname); + std::string atom_name(at->GetAtomName()); if (atom_name == " N ") { - clipper::Coord_orth pt(at->x, at->y, at->z); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); atom_vec.push_back(pt); } if (atom_name == " CA ") { - clipper::Coord_orth pt(at->x, at->y, at->z); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); atom_vec.push_back(pt); } if (atom_name == " C ") { - clipper::Coord_orth pt(at->x, at->y, at->z); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); atom_vec.push_back(pt); } } @@ -325,11 +325,11 @@ coot::db_strands::apply_rtop_to_strand(int SelHnd, mmdb::Manager *mol, residue_p->GetAtomTable(atoms, n_atoms); for (int iat=0; iatx, at->y, at->z); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); clipper::Coord_orth n = pt.transform(rtop); - at->x = n.x(); - at->y = n.y(); - at->z = n.z(); + at->x() = n.x(); + at->y() = n.y(); + at->z() = n.z(); } } } diff --git a/density-contour/gaussian-surface.cc b/density-contour/gaussian-surface.cc index 2c3a7b04d0..31b8085bf0 100644 --- a/density-contour/gaussian-surface.cc +++ b/density-contour/gaussian-surface.cc @@ -79,7 +79,7 @@ coot::gaussian_surface_t::using_an_xmap(mmdb::Manager *mol, const std::string &c }; auto mmdb_to_clipper = [] (mmdb::Atom *at) { - return clipper::Coord_orth(at->x, at->y, at->z); + return clipper::Coord_orth(at->x(), at->y(), at->z()); }; auto clipper_to_cart = [] (const clipper::Coord_orth &co) { diff --git a/docking/haddock-utils.cc b/docking/haddock-utils.cc index 00c25de740..a5f9f2c177 100644 --- a/docking/haddock-utils.cc +++ b/docking/haddock-utils.cc @@ -120,22 +120,22 @@ compute_residue_sasa(mmdb::Manager *mol, for (int ia=0; iaelement) + probe_radius; + double atom_radius = mmdb::getVdWaalsRadius(atom->GetElementName()) + probe_radius; double point_area = 4.0 * M_PI * atom_radius * atom_radius / n_points; int accessible = 0; for (int ip=0; ipx + atom_radius * sphere_points[ip].x(); - double py = atom->y + atom_radius * sphere_points[ip].y(); - double pz = atom->z + atom_radius * sphere_points[ip].z(); + double px = atom->x() + atom_radius * sphere_points[ip].x(); + double py = atom->y() + atom_radius * sphere_points[ip].y(); + double pz = atom->z() + atom_radius * sphere_points[ip].z(); bool buried = false; for (int j=0; jelement) + probe_radius; - double dx = px - all_atoms[j]->x; - double dy = py - all_atoms[j]->y; - double dz = pz - all_atoms[j]->z; + double nr = mmdb::getVdWaalsRadius(all_atoms[j]->GetElementName()) + probe_radius; + double dx = px - all_atoms[j]->x(); + double dy = py - all_atoms[j]->y(); + double dz = pz - all_atoms[j]->z(); if (dx*dx + dy*dy + dz*dz < nr*nr) { buried = true; break; diff --git a/docking/intermolecular-energy.cc b/docking/intermolecular-energy.cc index ef5873cf8a..e52963fb50 100644 --- a/docking/intermolecular-energy.cc +++ b/docking/intermolecular-energy.cc @@ -62,12 +62,12 @@ coot::haddock::extract_molecule_data(mmdb::Manager *mol, data.atoms.resize(n_atoms); for (int i=0; ix, at->y, at->z); - data.atoms[i].vdw_radius = mmdb::getVdWaalsRadius(at->element); + data.atoms[i].position = clipper::Coord_orth(at->x(), at->y(), at->z()); + data.atoms[i].vdw_radius = mmdb::getVdWaalsRadius(at->GetElementName()); data.atoms[i].charge = charge_table.getCharge( std::string(at->GetResName()), - std::string(at->name)); - data.atoms[i].atom_name = at->name; + std::string(at->GetAtomName())); + data.atoms[i].atom_name = at->GetAtomName(); data.atoms[i].residue_name = at->GetResName(); // Assign residue index @@ -107,9 +107,9 @@ coot::haddock::extract_molecule_data(mmdb::Manager *mol, residue_atoms_t ra; ra.positions.resize(n_res_atoms); for (int j=0; jx, - res_atoms[j]->y, - res_atoms[j]->z); + ra.positions[j] = clipper::Coord_orth(res_atoms[j]->x(), + res_atoms[j]->y(), + res_atoms[j]->z()); } data.active_residue_atoms.push_back(ra); mol->DeleteSelection(res_sel); @@ -132,9 +132,9 @@ coot::haddock::extract_molecule_data(mmdb::Manager *mol, residue_atoms_t ra; ra.positions.resize(n_res_atoms); for (int j=0; jx, - res_atoms[j]->y, - res_atoms[j]->z); + ra.positions[j] = clipper::Coord_orth(res_atoms[j]->x(), + res_atoms[j]->y(), + res_atoms[j]->z()); } data.partner_residue_atoms.push_back(ra); mol->DeleteSelection(res_sel); diff --git a/docking/test-docking.cc b/docking/test-docking.cc index 1268852477..0e396aa6c8 100644 --- a/docking/test-docking.cc +++ b/docking/test-docking.cc @@ -236,9 +236,9 @@ find_interface(mmdb::Manager *mol, for (int i=0; ix - atoms_lig[j]->x; - double dy = atoms_rec[i]->y - atoms_lig[j]->y; - double dz = atoms_rec[i]->z - atoms_lig[j]->z; + double dx = atoms_rec[i]->x() - atoms_lig[j]->x(); + double dy = atoms_rec[i]->y() - atoms_lig[j]->y(); + double dz = atoms_rec[i]->z() - atoms_lig[j]->z(); if (dx*dx + dy*dy + dz*dz < contact_dist_sq) { mmdb::Residue *r_rec = atoms_rec[i]->GetResidue(); mmdb::Residue *r_lig = atoms_lig[j]->GetResidue(); @@ -277,13 +277,13 @@ static void apply_dock_transform(mmdb::Manager *mol, mol->GetSelIndex(sel, atoms, n_atoms); for (int i=0; i(atoms[i]->x - com_B.x()), - static_cast(atoms[i]->y - com_B.y()), - static_cast(atoms[i]->z - com_B.z())); + glm::vec3 p(static_cast(atoms[i]->x() - com_B.x()), + static_cast(atoms[i]->y() - com_B.y()), + static_cast(atoms[i]->z() - com_B.z())); glm::vec3 rp = R * p; - atoms[i]->x = rp.x + result.translation.x(); - atoms[i]->y = rp.y + result.translation.y(); - atoms[i]->z = rp.z + result.translation.z(); + atoms[i]->x() = rp.x + result.translation.x(); + atoms[i]->y() = rp.y + result.translation.y(); + atoms[i]->z() = rp.z + result.translation.z(); } mol->DeleteSelection(sel); @@ -399,9 +399,9 @@ static void test_dock_9v3f_chain_E(const std::string &pdb_file) { mol->GetSelIndex(sel_E_orig, orig_E_atoms, n_orig_E); double ox = 0, oy = 0, oz = 0; for (int i=0; ix; - oy += orig_E_atoms[i]->y; - oz += orig_E_atoms[i]->z; + ox += orig_E_atoms[i]->x(); + oy += orig_E_atoms[i]->y(); + oz += orig_E_atoms[i]->z(); } clipper::Coord_orth original_com_E(ox/n_orig_E, oy/n_orig_E, oz/n_orig_E); mol->DeleteSelection(sel_E_orig); @@ -572,9 +572,9 @@ static clipper::Coord_orth compute_com(mmdb::Manager *mol, double sx = 0, sy = 0, sz = 0; for (int i=0; ix; - sy += atoms[i]->y; - sz += atoms[i]->z; + sx += atoms[i]->x(); + sy += atoms[i]->y(); + sz += atoms[i]->z(); } mol->DeleteSelection(sel); @@ -647,7 +647,7 @@ static void test_dock_e2a_hpr(const std::string &pdb_e2a, mol_e2a->GetSelIndex(sel_f, atoms_f, n_f); for (int i=0; iGetSeqNum()] = - clipper::Coord_orth(atoms_f[i]->x, atoms_f[i]->y, atoms_f[i]->z); + clipper::Coord_orth(atoms_f[i]->x(), atoms_f[i]->y(), atoms_f[i]->z()); mol_e2a->DeleteSelection(sel_f); // Collect matching pairs from 1GGR chain A @@ -662,9 +662,9 @@ static void test_dock_e2a_hpr(const std::string &pdb_e2a, int resno = atoms_r[i]->GetSeqNum(); auto it = f3g_ca_map.find(resno); if (it != f3g_ca_map.end()) { - cas_ref.push_back(clipper::Coord_orth(atoms_r[i]->x, - atoms_r[i]->y, - atoms_r[i]->z)); + cas_ref.push_back(clipper::Coord_orth(atoms_r[i]->x(), + atoms_r[i]->y(), + atoms_r[i]->z())); cas_tgt.push_back(it->second); } } @@ -803,13 +803,13 @@ static void test_dock_e2a_hpr(const std::string &pdb_e2a, int n_ref_atoms = 0; ref_copy->GetSelIndex(sel_all, ref_atoms, n_ref_atoms); for (int i=0; ix, - ref_atoms[i]->y, - ref_atoms[i]->z); + clipper::Coord_orth orig(ref_atoms[i]->x(), + ref_atoms[i]->y(), + ref_atoms[i]->z()); clipper::Coord_orth transformed = rtop * orig; - ref_atoms[i]->x = transformed.x(); - ref_atoms[i]->y = transformed.y(); - ref_atoms[i]->z = transformed.z(); + ref_atoms[i]->x() = transformed.x(); + ref_atoms[i]->y() = transformed.y(); + ref_atoms[i]->z() = transformed.z(); } ref_copy->DeleteSelection(sel_all); ref_copy->WritePDBASCII("e2a-hpr-native.pdb"); @@ -848,8 +848,8 @@ static void test_dock_e2a_hpr(const std::string &pdb_e2a, int n_b = 0; mol_ref->GetSelIndex(sel_b, b_atoms, n_b); for (int i=0; ix, b_atoms[i]->y, - b_atoms[i]->z); + clipper::Coord_orth orig(b_atoms[i]->x(), b_atoms[i]->y(), + b_atoms[i]->z()); clipper::Coord_orth tfm = rtop * orig; int mapped_resno = b_atoms[i]->GetSeqNum() - 300; native_hpr_ca_map[mapped_resno] = tfm; @@ -877,9 +877,9 @@ static void test_dock_e2a_hpr(const std::string &pdb_e2a, for (int i=0; iGetSeqNum(); - e.position = clipper::Coord_orth(ca_atoms[i]->x, - ca_atoms[i]->y, - ca_atoms[i]->z); + e.position = clipper::Coord_orth(ca_atoms[i]->x(), + ca_atoms[i]->y(), + ca_atoms[i]->z()); hpr_ca_entries.push_back(e); } mol_hpr->DeleteSelection(sel_ca); diff --git a/geometry/dict-utils.cc b/geometry/dict-utils.cc index d6743a5e3c..7d09b2be71 100644 --- a/geometry/dict-utils.cc +++ b/geometry/dict-utils.cc @@ -838,7 +838,7 @@ coot::dictionary_residue_restraints_t::change_names(mmdb::Residue *residue_p, residue_p->GetAtomTable(res_selection, num_residue_atoms); for (int iat=0; iatname; + std::string atom_name = at->GetAtomName(); for (unsigned int j=0; jelement); + std::string ele(residue_atoms[iat]->GetElementName()); if (ele != "H" && ele != " H" && ele != "D" && ele != " D") n_non_H++; } @@ -172,9 +172,9 @@ coot::dictionary_residue_restraints_t::init(mmdb::Residue *residue_p) { // also fill atom_info with dict_atom objects for (int iat=0; iatelement); - dict_atom da(at->name, at->name, ele, "", std::pair (false, 0)); - clipper::Coord_orth pos(at->x, at->y, at->z); + std::string ele(residue_atoms[iat]->GetElementName()); + dict_atom da(at->GetAtomName(), at->GetAtomName(), ele, "", std::pair (false, 0)); + clipper::Coord_orth pos(at->x(), at->y(), at->z()); da.model_Cartn = std::make_pair(true, pos); atom_info.push_back(da); } @@ -191,15 +191,15 @@ coot::dictionary_residue_restraints_t::init(mmdb::Residue *residue_p) { mmdb::Atom *at_2 = AtomBonds[ibond].atom; if (at_2) { if (at_1 < at_2) { // pointer comparison - std::string at_name_1(at_1->name); - std::string at_name_2(at_2->name); + std::string at_name_1(at_1->GetAtomName()); + std::string at_name_2(at_2->GetAtomName()); std::string type = "single"; if (AtomBonds[ibond].order == 2) type = "double"; if (AtomBonds[ibond].order == 3) type = "triple"; - clipper::Coord_orth pt_1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth pt_2(at_2->x, at_2->y, at_2->z); + clipper::Coord_orth pt_1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth pt_2(at_2->x(), at_2->y(), at_2->z()); double dist = sqrt((pt_1-pt_2).lengthsq()); double dist_esd = 0.02; dict_bond_restraint_t br(at_name_1, at_name_2, type, dist, dist_esd, 0, 0, false); @@ -234,17 +234,17 @@ coot::dictionary_residue_restraints_t::init(mmdb::Residue *residue_p) { // if (at_1 && at_2 && at_3) { - clipper::Coord_orth pt_1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth pt_2(at_2->x, at_2->y, at_2->z); - clipper::Coord_orth pt_3(at_3->x, at_3->y, at_3->z); + clipper::Coord_orth pt_1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth pt_2(at_2->x(), at_2->y(), at_2->z()); + clipper::Coord_orth pt_3(at_3->x(), at_3->y(), at_3->z()); // doesn't exist (mmdb problem)? // double angle = BondAngle(at_1, at_2, at_3); double angle = clipper::Util::rad2d(clipper::Coord_orth::angle(pt_1, pt_2, pt_3)); // std::cout << "angle: " << angle << std::endl; if (angle > 0.001) { - std::string at_name_1(at_1->name); - std::string at_name_2(at_2->name); - std::string at_name_3(at_3->name); + std::string at_name_1(at_1->GetAtomName()); + std::string at_name_2(at_2->GetAtomName()); + std::string at_name_3(at_3->GetAtomName()); double angle_esd = 3; dict_angle_restraint_t ar(at_name_1, at_name_2, at_name_3, angle, angle_esd); angle_restraint.push_back(ar); @@ -1324,7 +1324,7 @@ coot::dictionary_residue_restraints_t::GetResidue(bool idealised_flag, float b_f mmdb::Atom *at = residue_atoms[iat]; if (! at->isTer()) { std::cout << "debug:: GetResidue() " << iat << " " << at->GetAtomName() - << at->x << " " << at->y << " " << at->z << std::endl; + << at->x() << " " << at->y() << " " << at->z() << std::endl; } } diff --git a/geometry/dreiding.cc b/geometry/dreiding.cc index 2cfa519588..74800d43e6 100644 --- a/geometry/dreiding.cc +++ b/geometry/dreiding.cc @@ -43,10 +43,10 @@ coot::protein_geometry::dreiding_torsion_energy(const std::string &comp_id, std::vector name(4); std::vector energy_type(4); std::vector sp_hybrid(4); - name[0] = atom_0->name; - name[1] = atom_1->name; - name[2] = atom_2->name; - name[3] = atom_3->name; + name[0] = atom_0->GetAtomName(); + name[1] = atom_1->GetAtomName(); + name[2] = atom_2->GetAtomName(); + name[3] = atom_3->GetAtomName(); for (unsigned int i=0; i<4; i++) { energy_type[i] = restraints.type_energy(name[i]); std::map::const_iterator atom_map_it = @@ -58,10 +58,10 @@ coot::protein_geometry::dreiding_torsion_energy(const std::string &comp_id, } sp_hybrid[i] = atom_map_it->second.sp_hybridisation; } - clipper::Coord_orth p0(atom_0->x, atom_0->y, atom_0->z); - clipper::Coord_orth p1(atom_1->x, atom_1->y, atom_1->z); - clipper::Coord_orth p2(atom_2->x, atom_2->y, atom_2->z); - clipper::Coord_orth p3(atom_3->x, atom_3->y, atom_3->z); + clipper::Coord_orth p0(atom_0->x(), atom_0->y(), atom_0->z()); + clipper::Coord_orth p1(atom_1->x(), atom_1->y(), atom_1->z()); + clipper::Coord_orth p2(atom_2->x(), atom_2->y(), atom_2->z()); + clipper::Coord_orth p3(atom_3->x(), atom_3->y(), atom_3->z()); // double phi = clipper::Coord_orth::torsion(p0,p1,p2,p3); // d = dreiding_torsion_energy(phi, sp_hybrid[1], sp_hybrid[2], "dummy", false, false); } @@ -100,10 +100,10 @@ coot::protein_geometry::dreiding_torsion_energy_params(const std::string &comp_i std::vector name(4); std::vector energy_type(4); std::vector sp_hybrid(4); - name[0] = quad.atom_1->name; - name[1] = quad.atom_2->name; - name[2] = quad.atom_3->name; - name[3] = quad.atom_4->name; + name[0] = quad.atom_1->GetAtomName(); + name[1] = quad.atom_2->GetAtomName(); + name[2] = quad.atom_3->GetAtomName(); + name[3] = quad.atom_4->GetAtomName(); for (unsigned int i=0; i<4; i++) { energy_type[i] = restraints.type_energy(name[i]); std::map::const_iterator atom_map_it = diff --git a/geometry/hydrophobic.cc b/geometry/hydrophobic.cc index 93a26ff0c2..4bf28da6db 100644 --- a/geometry/hydrophobic.cc +++ b/geometry/hydrophobic.cc @@ -80,6 +80,6 @@ bool coot::is_hydrophobic_atom(mmdb::Atom *at) { std::string atom_name(at->GetAtomName()); - std::string res_name(at->residue->GetResName()); + std::string res_name(at->GetResidue()->GetResName()); return is_hydrophobic_atom(res_name, atom_name); } diff --git a/geometry/link.cc b/geometry/link.cc index 7da24bff03..8c501aac50 100644 --- a/geometry/link.cc +++ b/geometry/link.cc @@ -493,13 +493,13 @@ coot::protein_geometry::find_glycosidic_linkage_type_by_distance(mmdb::Residue * second->GetAtomTable(res_selection_2, i_no_res_atoms_2); for (int i1=0; i1x, - res_selection_1[i1]->y, - res_selection_1[i1]->z); + clipper::Coord_orth a1(res_selection_1[i1]->x(), + res_selection_1[i1]->y(), + res_selection_1[i1]->z()); for (int i2=0; i2x, - res_selection_2[i2]->y, - res_selection_2[i2]->z); + clipper::Coord_orth a2(res_selection_2[i2]->x(), + res_selection_2[i2]->y(), + res_selection_2[i2]->z()); d = (a1-a2).lengthsq(); if (d < critical_dist*critical_dist) { close.push_back(coot::glycosidic_distance(res_selection_1[i1], @@ -540,8 +540,8 @@ coot::protein_geometry::find_glycosidic_linkage_type_by_distance(mmdb::Residue * float smallest_link_dist = 99999.9; for (unsigned int i=0; iname); - std::string name_2(close[i].at2->name); + std::string name_1(close[i].at1->GetAtomName()); + std::string name_2(close[i].at2->GetAtomName()); // First test the NAG-ASN link (that order - as per dictionary) diff --git a/geometry/main-chain.cc b/geometry/main-chain.cc index 0960eb8cbd..e3e93c1574 100644 --- a/geometry/main-chain.cc +++ b/geometry/main-chain.cc @@ -32,7 +32,7 @@ bool coot::is_main_chain_p(mmdb::Atom *at) { - std::string mol_atom_name(at->name); + std::string mol_atom_name(at->GetAtomName()); if (mol_atom_name == " N " || mol_atom_name == " C " || mol_atom_name == " CA " || @@ -50,7 +50,7 @@ coot::is_main_chain_p(mmdb::Atom *at) { } // Perhaps N-terminal H atom? - mmdb::Residue *res = at->residue; + mmdb::Residue *res = at->GetResidue(); if (res) { if (res->isNTerminus()) { if (mol_atom_name == " H1 ") return true; @@ -66,7 +66,7 @@ coot::is_main_chain_p(mmdb::Atom *at) { bool coot::is_main_chain_or_cb_p(mmdb::Atom *at) { - std::string mol_atom_name(at->name); + std::string mol_atom_name(at->GetAtomName()); return is_main_chain_or_cb_p(mol_atom_name); } @@ -109,7 +109,7 @@ coot::is_main_chain_or_cb_p(const std::string &mol_atom_name) { // return 0 or 1 bool coot::is_hydrogen_p(mmdb::Atom *at) { - std::string mol_atom_ele(at->element); + std::string mol_atom_ele(at->GetElementName()); if (mol_atom_ele == " H" || mol_atom_ele == " D") { return 1; diff --git a/geometry/mol-utils.cc b/geometry/mol-utils.cc index 41bd110ccc..d691595729 100644 --- a/geometry/mol-utils.cc +++ b/geometry/mol-utils.cc @@ -38,13 +38,13 @@ coot::util::get_residue_alt_confs(mmdb::Residue *res) { for (int iat=0; iataltLoc) == v[i]) { + if (std::string(residue_atoms[iat]->altLoc()) == v[i]) { ifound = 1; break; } } if (! ifound) - v.push_back(std::string(residue_atoms[iat]->altLoc)); + v.push_back(std::string(residue_atoms[iat]->altLoc())); } return v; } diff --git a/geometry/protein-geometry.cc b/geometry/protein-geometry.cc index 287aa9961a..df8c32962a 100644 --- a/geometry/protein-geometry.cc +++ b/geometry/protein-geometry.cc @@ -1468,8 +1468,8 @@ coot::protein_geometry::atoms_match_dictionary(mmdb::Residue *residue_p, if (debug) { std::cout << "=== atoms_match_dictionary() with these residue atom names ======= " << std::endl; for (int i=0; iname << ": and ele " - << residue_atoms[i]->element << std::endl; + std::cout << i << " :" << residue_atoms[i]->GetAtomName() << ": and ele " + << residue_atoms[i]->GetElementName() << std::endl; } std::cout << "=== atoms_match_dictionary() with these residue atom names ======= " << std::endl; for (unsigned int irat=0; iratisTer()) { - std::string residue_atom_name(residue_atoms[i]->name); - std::string ele(residue_atoms[i]->element); + std::string residue_atom_name(residue_atoms[i]->GetAtomName()); + std::string ele(residue_atoms[i]->GetElementName()); bool found = 0; // PDBv3 FIXME @@ -1589,17 +1589,17 @@ coot::protein_geometry::atoms_match_dictionary_bond_distance_check(mmdb::Residue for (unsigned int ibond=0; ibondname); + std::string atom_name_1(at_1->GetAtomName()); if (restraints.bond_restraint[ibond].atom_id_1_4c() == atom_name_1) { for (int jat=iat+1; jatname); + std::string atom_name_2(at_2->GetAtomName()); if (restraints.bond_restraint[ibond].atom_id_2_4c() == atom_name_2) { - std::string alt_conf_1(at_1->altLoc); - std::string alt_conf_2(at_2->altLoc); + std::string alt_conf_1(at_1->altLoc()); + std::string alt_conf_2(at_2->altLoc()); if (alt_conf_1 == alt_conf_2) { - clipper::Coord_orth pt1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth pt2(at_2->x, at_2->y, at_2->z); + clipper::Coord_orth pt1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth pt2(at_2->x(), at_2->y(), at_2->z()); double d = (pt1-pt2).lengthsq(); if (d > 10) { status = false; @@ -2525,8 +2525,8 @@ coot::protein_geometry::get_residue(const std::string &comp_id, int imol_enc, for (int iat=0; iatisTer()) { - std::cout << "debug:: in get_residue(): atom " << iat << " " << at-> name - << " at " << at->x << " " << at->y << " " << at->z << std::endl; + std::cout << "debug:: in get_residue(): atom " << iat << " " << at-> GetAtomName() + << " at " << at->x() << " " << at->y() << " " << at->z() << std::endl; } } }; @@ -2587,8 +2587,8 @@ coot::protein_geometry::mol_from_dictionary(const std::string &three_letter_code for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - std::cout << "pg::mol_from_dictionary(): atom " << iat << " " << at->name - << " at " << at->x << " " << at->y << " " << at->z + std::cout << "pg::mol_from_dictionary(): atom " << iat << " " << at->GetAtomName() + << " at " << at->x() << " " << at->y() << " " << at->z() << std::endl; } } diff --git a/geometry/residue-and-atom-specs.cc b/geometry/residue-and-atom-specs.cc index 0a29c09419..d3a7b8da6e 100644 --- a/geometry/residue-and-atom-specs.cc +++ b/geometry/residue-and-atom-specs.cc @@ -261,7 +261,7 @@ coot::atom_spec_t::get_atom(mmdb::Manager *mol) const { mmdb::Atom *this_at = residue_p->GetAtom(iat); if (! this_at->isTer()) { std::string this_atom_name(this_at->GetAtomName()); - std::string this_alt_loc = (this_at->altLoc); + std::string this_alt_loc = (this_at->altLoc()); if (this_atom_name == this->atom_name) { if (this_alt_loc == this->alt_conf) { at = this_at; @@ -288,11 +288,11 @@ coot::atom_spec_t::get_atom(mmdb::Manager *mol) const { bool coot::atom_spec_t::matches_spec(mmdb::Atom *atom) const { - if (atom_name == std::string(atom->name)) { + if (atom_name == std::string(atom->GetAtomName())) { - if (alt_conf == std::string(atom->altLoc)) { + if (alt_conf == std::string(atom->altLoc())) { - mmdb::Residue *residue_p = atom->residue; + mmdb::Residue *residue_p = atom->GetResidue(); if (residue_p) { @@ -336,7 +336,7 @@ coot::atom_spec_t::matches_spec(mmdb::Atom *atom) const { // std::cout << atom_name << "an atom name mismatch :" << atom->name << ":" << std::endl; return 0; } - std::cout << atom_name << " should not happen (matches_spec()) " << atom->name << ":" << std::endl; + std::cout << atom_name << " should not happen (matches_spec()) " << atom->GetAtomName() << ":" << std::endl; return 0; } diff --git a/geometry/residue-and-atom-specs.hh b/geometry/residue-and-atom-specs.hh index edcab040a0..c324cd9673 100644 --- a/geometry/residue-and-atom-specs.hh +++ b/geometry/residue-and-atom-specs.hh @@ -66,8 +66,8 @@ namespace coot { res_no = at->GetSeqNum(); ins_code = at->GetInsCode(); model_number = at->GetModelNum(); - atom_name = at->name; - alt_conf = at->altLoc; + atom_name = at->GetAtomName(); + alt_conf = at->altLoc(); } else { chain_id = "unset"; res_no = mmdb::MinInt4; @@ -83,8 +83,8 @@ namespace coot { chain_id = at->GetChainID(); res_no = at->GetSeqNum(); ins_code = at->GetInsCode(); - atom_name = at->name; - alt_conf = at->altLoc; + atom_name = at->GetAtomName(); + alt_conf = at->altLoc(); string_user_data = user_data_string; float_user_data = -1; int_user_data = -1; diff --git a/high-res/high-res.cc b/high-res/high-res.cc index 24120f2d10..1bc0e06b71 100644 --- a/high-res/high-res.cc +++ b/high-res/high-res.cc @@ -120,7 +120,7 @@ coot::high_res::get_middle_pos(const coot::minimol::molecule &minimol_mol) const } if (most_contacts >= 0) { mmdb::Atom *at = asc.atom_selection[most_contacts_index]; - r.first = clipper::Coord_orth(at->x, at->y, at->z); + r.first = clipper::Coord_orth(at->x(), at->y(), at->z()); } delete [] pscontact; std::cout << "INFO:: get_middle_pos: returns " << r.first.format() << " with " @@ -304,9 +304,9 @@ coot::high_res::make_trees() { std::vector coords; for (int iat=0; iatx, - asc.atom_selection[iat]->y, - asc.atom_selection[iat]->z)); + coords.push_back(clipper::Coord_orth(asc.atom_selection[iat]->x(), + asc.atom_selection[iat]->y(), + asc.atom_selection[iat]->z())); // std::cout << "There are " << contact_indices.size() // << " atoms "<< std::endl; @@ -395,7 +395,7 @@ coot::high_res::buccafilter_neighbours() { ierr = asc.atom_selection[iat]->GetUDData(uddhandle, ic); if (ierr == mmdb::UDDATA_Ok) { if (ic == -1) { - char *at_name = asc.atom_selection[iat]->name; + char *at_name = asc.atom_selection[iat]->GetAtomName(); std::string atom_name(at_name); mark_neighbours(iat, igroup, at_name, neighbours, asc.atom_selection, uddhandle); @@ -643,7 +643,7 @@ coot::high_res::mark_neighbours(int iatom, int igroup, int ig; atom_selection[iatom]->GetUDData(uddhandle, ig); if (ig == -1) { - std::string this_atom_name = atom_selection[iatom]->name; + std::string this_atom_name = atom_selection[iatom]->GetAtomName(); if (this_atom_name == atom_name) { atom_selection[iatom]->PutUDData(uddhandle, igroup); std::vector n = neighbours[iatom]; @@ -684,7 +684,7 @@ coot::high_res::filter_on_groups(const std::vector > &groups, int n_grp_ats = groups[igroup].size(); for (int iat=0; iatx, at->y, at->z); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); sum += pt; } double frac = 1.0/double(n_grp_ats); @@ -694,7 +694,7 @@ coot::high_res::filter_on_groups(const std::vector > &groups, int n_group_within_lim = 0; for (int iat=0; iatx, at->y, at->z); + clipper::Coord_orth pt(at->x(), at->y(), at->z()); // double d = clipper::Coord_orth::length(mean_pt, pt); // if (d < dist_crit) { n_group_within_lim++; @@ -705,9 +705,9 @@ coot::high_res::filter_on_groups(const std::vector > &groups, for (unsigned int iat=0; iatx << " " - << atom_selection[groups[igroup][iat]]->y << " " - << atom_selection[groups[igroup][iat]]->z << ")" << std::endl; + << atom_selection[groups[igroup][iat]]->x() << " " + << atom_selection[groups[igroup][iat]]->y() << " " + << atom_selection[groups[igroup][iat]]->z() << ")" << std::endl; } } @@ -717,8 +717,8 @@ coot::high_res::filter_on_groups(const std::vector > &groups, new_sum.y()*frac, new_sum.z()*frac); mmdb::Atom *speced_at = atom_selection[groups[igroup][0]]; - std::string atom_name(speced_at->name); - std::string atom_element(speced_at->element); + std::string atom_name(speced_at->GetAtomName()); + std::string atom_element(speced_at->GetElementName()); int resno = speced_at->GetSeqNum(); std::string chain_id(speced_at->GetChainID()); int ifrag = m.fragment_for_chain(chain_id); diff --git a/high-res/sequence-assignment.cc b/high-res/sequence-assignment.cc index 6f4fcde767..e5302e77c4 100644 --- a/high-res/sequence-assignment.cc +++ b/high-res/sequence-assignment.cc @@ -627,13 +627,13 @@ coot::sequence_assignment::side_chain_score_t::move_std_res_to_this_res_pos(cons std_residue->GetAtomTable(residue_atoms, nResidueAtoms); for (int iat=0; iatx, - residue_atoms[iat]->y, - residue_atoms[iat]->z); + clipper::Coord_orth co(residue_atoms[iat]->x(), + residue_atoms[iat]->y(), + residue_atoms[iat]->z()); clipper::Coord_orth rotted = co.transform(rtop); - residue_atoms[iat]->x = rotted.x(); - residue_atoms[iat]->y = rotted.y(); - residue_atoms[iat]->z = rotted.z(); + residue_atoms[iat]->x() = rotted.x(); + residue_atoms[iat]->y() = rotted.y(); + residue_atoms[iat]->z() = rotted.z(); } } @@ -716,9 +716,9 @@ coot::sequence_assignment::side_chain_score_t::find_unassigned_regions(float pr_ int start_resno = -1; // unset for (int ires=0; iresGetResidue(ires); - int this_resno = residue_p->seqNum; + int this_resno = residue_p->GetSeqNum(); // - std::string restype = residue_p->name; + std::string restype = residue_p->GetResName(); // istate = residue_p->GetUDData(udd_assigned_handle, iassigned); if (istate == mmdb::UDDATA_Ok) { @@ -740,7 +740,7 @@ coot::sequence_assignment::side_chain_score_t::find_unassigned_regions(float pr_ if (previous_residue) { v.push_back(coot::high_res_residue_range_t(chain_id, start_resno, - previous_residue->seqNum)); + previous_residue->GetSeqNum())); in_ala_range_flag = 0; } } @@ -758,7 +758,7 @@ coot::sequence_assignment::side_chain_score_t::find_unassigned_regions(float pr_ if (previous_residue) v.push_back(coot::high_res_residue_range_t(chain_id, start_resno, - previous_residue->seqNum)); + previous_residue->GetSeqNum())); } } } @@ -806,7 +806,7 @@ coot::sequence_assignment::side_chain_score_t::mark_unassigned_residues() { residue_p = chain_p->GetResidue(ires); // - std::string restype = residue_p->name; + std::string restype = residue_p->GetResName(); if (restype == "ALA") consecutive_ala_count++; else diff --git a/ideal/add-linked-cho.cc b/ideal/add-linked-cho.cc index 4940c04b1d..dfe3701861 100644 --- a/ideal/add-linked-cho.cc +++ b/ideal/add-linked-cho.cc @@ -362,11 +362,11 @@ coot::cho::next_residue_number_in_chain(mmdb::Chain *w, if (nres > 0) { for (int ires=nres-1; ires>=0; ires--) { residue_p = w->GetResidue(ires); - if (residue_p->seqNum > max_res_no) { - max_res_no = residue_p->seqNum; + if (residue_p->GetSeqNum() > max_res_no) { + max_res_no = residue_p->GetSeqNum(); bool is_het_residue_flag = is_het_residue(residue_p); if (is_het_residue_flag) { - p = std::pair(1, residue_p->seqNum+1); + p = std::pair(1, residue_p->GetSeqNum()+1); } else { if (new_res_no_by_hundreds) { if (max_res_no < 9999) { @@ -388,7 +388,7 @@ coot::cho::next_residue_number_in_chain(mmdb::Chain *w, while (! is_clear) { is_clear = true; for (int iser=0; iserGetResidue(iser)->seqNum; + int resno_res = w->GetResidue(iser)->GetSeqNum(); if (resno_res >= test_resno_start) { if (resno_res <= (test_resno_start+10)) { is_clear = false; @@ -446,7 +446,7 @@ coot::cho::copy_and_add_residue_to_chain(mmdb::Manager *mol, int new_res_resno = 9999; if (res_info.first) new_res_resno = res_info.second; - residue_copy->seqNum = new_res_resno; // try changing the seqNum before AddResidue(). + residue_copy->GetSeqNum() = new_res_resno; // try changing the seqNum before AddResidue(). this_model_chain->AddResidue(residue_copy); res_copied = residue_copy; } @@ -492,12 +492,12 @@ coot::cho::asn_hydrogen_position_swap(std::vectorx = co22.x(); - at_hd21->y = co22.y(); - at_hd21->z = co22.z(); - at_hd22->x = co21.x(); // this atom will be deleted. - at_hd22->y = co21.y(); - at_hd22->z = co21.z(); + at_hd21->x() = co22.x(); + at_hd21->y() = co22.y(); + at_hd21->z() = co22.z(); + at_hd22->x() = co21.x(); // this atom will be deleted. + at_hd22->y() = co21.y(); + at_hd22->z() = co21.z(); } } } @@ -542,14 +542,14 @@ coot::cho::make_link(mmdb::Manager *mol, const coot::atom_spec_t &spec_1, mmdb::Link *link = new mmdb::Link; // sym ids default to 1555 1555 strncpy(link->atName1, at_1->GetAtomName(), 20); - strncpy(link->aloc1, at_1->altLoc, 20); + strncpy(link->aloc1, at_1->altLoc(), 20); strncpy(link->resName1, at_1->GetResName(), 19); strncpy(link->chainID1, at_1->GetChainID(), 9); strncpy(link->insCode1, at_1->GetInsCode(), 9); link->seqNum1 = at_1->GetSeqNum(); strncpy(link->atName2, at_2->GetAtomName(), 20); - strncpy(link->aloc2, at_2->altLoc, 20); + strncpy(link->aloc2, at_2->altLoc(), 20); strncpy(link->resName2, at_2->GetResName(), 19); strncpy(link->chainID2, at_2->GetChainID(), 9); strncpy(link->insCode2, at_2->GetInsCode(), 9); @@ -562,8 +562,8 @@ coot::cho::make_link(mmdb::Manager *mol, const coot::atom_spec_t &spec_1, // are defined in the dictionary? // std::vector > residues(2); - residues[0] = std::pair (0, at_1->residue); - residues[1] = std::pair (0, at_2->residue); + residues[0] = std::pair (0, at_1->GetResidue()); + residues[1] = std::pair (0, at_2->GetResidue()); std::vector dummy_fixed_atom_specs; // convert to restraints_container_t interface @@ -671,9 +671,9 @@ coot::cho::replace_coords(mmdb::Manager *fragment_mol, mmdb::Manager *mol) { atom_spec_t spec(at); mmdb::Atom *at_mol = util::get_atom(spec, mol); if (at_mol) { - at_mol->x = at->x; - at_mol->y = at->y; - at_mol->z = at->z; + at_mol->x() = at->x(); + at_mol->y() = at->y(); + at_mol->z() = at->z(); } } } @@ -729,9 +729,9 @@ coot::cho::add_linked_residue(atom_selection_container_t *asc, if (icount < 10) { std::cout << "atom: " << icount << " " << at->GetChainID() << " " - << at->residue->GetSeqNum() << " " + << at->GetResidue()->GetSeqNum() << " " << at->GetAtomName() << " " - << at->x << " " << at->y << " " << at->z << " " + << at->x() << " " << at->y() << " " << at->z() << " " << std::endl; } else { break; diff --git a/ideal/chirals.cc b/ideal/chirals.cc index ff6fbe56db..5cb6499d8b 100644 --- a/ideal/chirals.cc +++ b/ideal/chirals.cc @@ -60,19 +60,19 @@ coot::is_inverted_chiral_atom_p(const coot::dict_chiral_restraint_t &chiral_rest int i_no_res_atoms = res->GetNumberOfAtoms(); for (int iat1=0; iat1GetAtom(iat1)->name); + std::string pdb_atom_name1(res->GetAtom(iat1)->GetAtomName()); if (pdb_atom_name1 == chiral_restraint.atom_id_1_4c()) { for (int iat2=0; iat2GetAtom(iat2)->name); + std::string pdb_atom_name2(res->GetAtom(iat2)->GetAtomName()); if (pdb_atom_name2 == chiral_restraint.atom_id_2_4c()) { for (int iat3=0; iat3GetAtom(iat3)->name); + std::string pdb_atom_name3(res->GetAtom(iat3)->GetAtomName()); if (pdb_atom_name3 == chiral_restraint.atom_id_3_4c()) { for (int iatc=0; iatcGetAtom(iatc)->name); + std::string pdb_atom_namec(res->GetAtom(iatc)->GetAtomName()); if (pdb_atom_namec == chiral_restraint.atom_id_c_4c()) { // Now, do they have corresponding @@ -84,10 +84,10 @@ coot::is_inverted_chiral_atom_p(const coot::dict_chiral_restraint_t &chiral_rest // CA CB OG1,A CG2,A (2) // but not: CA CB OG1,A CG2,B (3) - std::string chiral_alt_conf(res->GetAtom(iatc)->altLoc); - std::string altLoc1(res->GetAtom(iat1)->altLoc); - std::string altLoc2(res->GetAtom(iat2)->altLoc); - std::string altLoc3(res->GetAtom(iat3)->altLoc); + std::string chiral_alt_conf(res->GetAtom(iatc)->altLoc()); + std::string altLoc1(res->GetAtom(iat1)->altLoc()); + std::string altLoc2(res->GetAtom(iat2)->altLoc()); + std::string altLoc3(res->GetAtom(iat3)->altLoc()); short int matching_altlocs = 0; // These should catch most cases, @@ -116,18 +116,18 @@ coot::is_inverted_chiral_atom_p(const coot::dict_chiral_restraint_t &chiral_rest if (matching_altlocs) { - clipper::Coord_orth centre(res->GetAtom(iatc)->x, - res->GetAtom(iatc)->y, - res->GetAtom(iatc)->z); - clipper::Coord_orth a1(res->GetAtom(iat1)->x, - res->GetAtom(iat1)->y, - res->GetAtom(iat1)->z); - clipper::Coord_orth a2(res->GetAtom(iat2)->x, - res->GetAtom(iat2)->y, - res->GetAtom(iat2)->z); - clipper::Coord_orth a3(res->GetAtom(iat3)->x, - res->GetAtom(iat3)->y, - res->GetAtom(iat3)->z); + clipper::Coord_orth centre(res->GetAtom(iatc)->x(), + res->GetAtom(iatc)->y(), + res->GetAtom(iatc)->z()); + clipper::Coord_orth a1(res->GetAtom(iat1)->x(), + res->GetAtom(iat1)->y(), + res->GetAtom(iat1)->z()); + clipper::Coord_orth a2(res->GetAtom(iat2)->x(), + res->GetAtom(iat2)->y(), + res->GetAtom(iat2)->z()); + clipper::Coord_orth a3(res->GetAtom(iat3)->x(), + res->GetAtom(iat3)->y(), + res->GetAtom(iat3)->z()); clipper::Coord_orth a = a1 - centre; clipper::Coord_orth b = a2 - centre; @@ -137,8 +137,8 @@ coot::is_inverted_chiral_atom_p(const coot::dict_chiral_restraint_t &chiral_rest chiral_atom = atom_spec_t(res->GetChainID(), res->GetSeqNum(), res->GetInsCode(), - res->GetAtom(iatc)->name, - res->GetAtom(iatc)->altLoc); + res->GetAtom(iatc)->GetAtomName(), + res->GetAtom(iatc)->altLoc()); if (cv*chiral_restraint.volume_sign < 0) { // std::cout << "DEBUG:: " << res->name << " " @@ -209,7 +209,7 @@ coot::inverted_chiral_volumes(int imol, residue_p = chain_p->GetResidue(ires); int n_atoms = residue_p->GetNumberOfAtoms(); if (n_atoms > 3) { - std::string residue_type(residue_p->name); + std::string residue_type(residue_p->GetResName()); if (residue_type == "UNK") residue_type = "ALA"; if (! geom_p->have_dictionary_for_residue_type(residue_type, @@ -229,7 +229,7 @@ coot::inverted_chiral_volumes(int imol, unknown_types_vec.push_back(residue_type); } else { std::vector chiral_restraints = - geom_p->get_monomer_chiral_volumes(std::string(residue_p->name), imol); + geom_p->get_monomer_chiral_volumes(std::string(residue_p->GetResName()), imol); coot::dict_chiral_restraint_t chiral_restraint; for (unsigned int irestr=0; irestrGetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname; + std::string at_name = at->GetAtomName(); if (at_name == " C ") { // PDBv3 fixme v[0] = at; break; @@ -89,7 +89,7 @@ coot::crankshaft_set::crankshaft_set(mmdb::Residue *res_0, residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname; + std::string at_name = at->GetAtomName(); if (at_name == " N ") { // PDBv3 fixme v[1] = at; } @@ -109,7 +109,7 @@ coot::crankshaft_set::crankshaft_set(mmdb::Residue *res_0, residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname; + std::string at_name = at->GetAtomName(); if (at_name == " N ") { // PDBv3 fixme v[4] = at; } @@ -129,7 +129,7 @@ coot::crankshaft_set::crankshaft_set(mmdb::Residue *res_0, residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname; + std::string at_name = at->GetAtomName(); if (at_name == " N ") { // PDBv3 fixme v[7] = at; } @@ -250,8 +250,8 @@ coot::nmer_crankshaft_set::residues() const { for (std::size_t i=0; iresidue; - mmdb::Residue *r_2 = at_2->residue; + mmdb::Residue *r_1 = at_1->GetResidue(); + mmdb::Residue *r_2 = at_2->GetResidue(); if (std::find(v.begin(), v.end(), r_1) == v.end()) v.push_back(r_1); if (std::find(v.begin(), v.end(), r_2) == v.end()) v.push_back(r_2); } @@ -327,9 +327,9 @@ coot::crankshaft_set::move_the_atoms(float ang) { if (at) { clipper::Coord_orth at_pos = co(v[indices[i]]); clipper::Coord_orth at_pos_new = util::rotate_around_vector(dir, at_pos, p_ca_1, ang); - at->x = at_pos_new.x(); - at->y = at_pos_new.y(); - at->z = at_pos_new.z(); + at->x() = at_pos_new.x(); + at->y() = at_pos_new.y(); + at->z() = at_pos_new.z(); } } } @@ -1186,7 +1186,7 @@ coot::crankshaft::get_atom(mmdb::Residue *res_1, const std::string &atom_name_in res_1->GetAtomTable(residue_atoms_1, n_residue_atoms_1); for (int iat=0; iatname; + std::string atom_name = at->GetAtomName(); if (atom_name == atom_name_in) { r = at; break; diff --git a/ideal/distortion.cc b/ideal/distortion.cc index 7d277d763f..f01784f614 100644 --- a/ideal/distortion.cc +++ b/ideal/distortion.cc @@ -477,8 +477,8 @@ coot::geometry_distortion_info_container_t::distortion() const { mmdb::Atom *at_1 = atom[rest.atom_index_1]; mmdb::Atom *at_2 = atom[rest.atom_index_2]; if (at_1 && at_2) { - clipper::Coord_orth p1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth p2(at_2->x, at_2->y, at_2->z); + clipper::Coord_orth p1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth p2(at_2->x(), at_2->y(), at_2->z()); double d = sqrt((p2-p1).lengthsq()); double distortion = d - rest.target_value; double pen_score = distortion*distortion/(rest.sigma*rest.sigma); @@ -494,9 +494,9 @@ coot::geometry_distortion_info_container_t::distortion() const { mmdb::Atom *at_2 = atom[rest.atom_index_2]; mmdb::Atom *at_3 = atom[rest.atom_index_3]; if (at_1 && at_2 && at_3) { - clipper::Coord_orth p1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth p2(at_2->x, at_2->y, at_2->z); - clipper::Coord_orth p3(at_3->x, at_3->y, at_3->z); + clipper::Coord_orth p1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth p2(at_2->x(), at_2->y(), at_2->z()); + clipper::Coord_orth p3(at_3->x(), at_3->y(), at_3->z()); double angle_rad = clipper::Coord_orth::angle(p1, p2, p3); double angle = clipper::Util::rad2d(angle_rad); double distortion = angle - rest.target_value; @@ -511,10 +511,10 @@ coot::geometry_distortion_info_container_t::distortion() const { mmdb::Atom *at_3 = atom[rest.atom_index_3]; mmdb::Atom *at_4 = atom[rest.atom_index_4]; if (at_1 && at_2 && at_3 && at_4) { - clipper::Coord_orth p1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth p2(at_2->x, at_2->y, at_2->z); - clipper::Coord_orth p3(at_3->x, at_3->y, at_3->z); - clipper::Coord_orth p4(at_4->x, at_4->y, at_4->z); + clipper::Coord_orth p1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth p2(at_2->x(), at_2->y(), at_2->z()); + clipper::Coord_orth p3(at_3->x(), at_3->y(), at_3->z()); + clipper::Coord_orth p4(at_4->x(), at_4->y(), at_4->z()); double torsion_rad = clipper::Coord_orth::torsion(p1, p2, p3, p4); double torsion = clipper::Util::rad2d(torsion_rad); double distortion = rest.torsion_distortion(torsion); @@ -529,10 +529,10 @@ coot::geometry_distortion_info_container_t::distortion() const { mmdb::Atom *at_3 = atom[rest.atom_index_3]; mmdb::Atom *at_4 = atom[rest.atom_index_4]; if (at_1 && at_2 && at_3 && at_4) { - clipper::Coord_orth p1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth p2(at_2->x, at_2->y, at_2->z); - clipper::Coord_orth p3(at_3->x, at_3->y, at_3->z); - clipper::Coord_orth p4(at_4->x, at_4->y, at_4->z); + clipper::Coord_orth p1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth p2(at_2->x(), at_2->y(), at_2->z()); + clipper::Coord_orth p3(at_3->x(), at_3->y(), at_3->z()); + clipper::Coord_orth p4(at_4->x(), at_4->y(), at_4->z()); double torsion_rad = clipper::Coord_orth::torsion(p1, p2, p3, p4); double torsion = clipper::Util::rad2d(torsion_rad); double pen_score = rest.torsion_distortion(torsion); @@ -858,13 +858,13 @@ coot::restraints_container_t::omega_trans_distortions(const coot::protein_geomet if (i_no_res_atoms > 0) { for (int iresatom=0; iresatomname); + std::string atom_name(at->GetAtomName()); if (atom_name == " CA ") { - ca_first = clipper::Coord_orth(at->x, at->y, at->z); + ca_first = clipper::Coord_orth(at->x(), at->y(), at->z()); got_ca_first = 1; } if (atom_name == " C ") { - c_first = clipper::Coord_orth(at->x, at->y, at->z); + c_first = clipper::Coord_orth(at->x(), at->y(), at->z()); got_c_first = 1; } } @@ -873,13 +873,13 @@ coot::restraints_container_t::omega_trans_distortions(const coot::protein_geomet if (i_no_res_atoms > 0) { for (int iresatom=0; iresatomname); + std::string atom_name(at->GetAtomName()); if (atom_name == " CA ") { - ca_next = clipper::Coord_orth(at->x, at->y, at->z); + ca_next = clipper::Coord_orth(at->x(), at->y(), at->z()); got_ca_next = 1; } if (atom_name == " N ") { - n_next = clipper::Coord_orth(at->x, at->y, at->z); + n_next = clipper::Coord_orth(at->x(), at->y(), at->z()); got_n_next = 1; } } @@ -895,7 +895,7 @@ coot::restraints_container_t::omega_trans_distortions(const coot::protein_geomet info += " "; info += coot::util::int_to_string(second->GetSeqNum()); info += " "; - info += second->name; + info += second->GetResName(); info += " Omega: "; info += coot::util::float_to_string(torsion); double distortion = fabs(180.0 - torsion); diff --git a/ideal/extra-restraints-kk.cc b/ideal/extra-restraints-kk.cc index 3fbe5eaab8..2157cc2cb5 100644 --- a/ideal/extra-restraints-kk.cc +++ b/ideal/extra-restraints-kk.cc @@ -72,9 +72,9 @@ coot::restraints_container_t::add_extra_start_pos_restraints(const extra_restrai r_1->GetAtomTable(residue_atoms_1, n_residue_atoms_1); for (int iat=0; iatname); + std::string atom_name_1(residue_atoms_1[iat]->GetAtomName()); if (atom_name_1 == extra_restraints.start_pos_restraints[i].atom_1.atom_name) { - std::string alt_loc_1(residue_atoms_1[iat]->altLoc); + std::string alt_loc_1(residue_atoms_1[iat]->altLoc()); if (alt_loc_1 == extra_restraints.start_pos_restraints[i].atom_1.alt_conf) { at_1 = residue_atoms_1[iat]; break; diff --git a/ideal/extra-restraints.cc b/ideal/extra-restraints.cc index 889a507631..0a3083913c 100644 --- a/ideal/extra-restraints.cc +++ b/ideal/extra-restraints.cc @@ -1235,9 +1235,9 @@ coot::restraints_container_t::add_extra_target_position_restraints(const extra_r int n_residue_atoms; residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); + std::string atom_name(residue_atoms[iat]->GetAtomName()); if (atom_name == extra_restraints.target_position_restraints[i].atom_spec.atom_name) { - std::string alt_loc(residue_atoms[iat]->altLoc); + std::string alt_loc(residue_atoms[iat]->altLoc()); if (alt_loc == extra_restraints.target_position_restraints[i].atom_spec.alt_conf) { at = residue_atoms[iat]; break; @@ -1410,9 +1410,9 @@ coot::restraints_container_t::add_extra_bond_restraints(const extra_restraints_t r_2->GetAtomTable(residue_atoms_2, n_residue_atoms_2); for (int iat=0; iatname); + std::string atom_name_1(residue_atoms_1[iat]->GetAtomName()); if (atom_name_1 == ebr.atom_1.atom_name) { - std::string alt_loc_1(residue_atoms_1[iat]->altLoc); + std::string alt_loc_1(residue_atoms_1[iat]->altLoc()); if (alt_loc_1 == ebr.atom_1.alt_conf) { at_1 = residue_atoms_1[iat]; break; @@ -1420,9 +1420,9 @@ coot::restraints_container_t::add_extra_bond_restraints(const extra_restraints_t } } for (int iat=0; iatname); + std::string atom_name_2(residue_atoms_2[iat]->GetAtomName()); if (atom_name_2 == ebr.atom_2.atom_name) { - std::string alt_loc_2(residue_atoms_2[iat]->altLoc); + std::string alt_loc_2(residue_atoms_2[iat]->altLoc()); if (alt_loc_2 == ebr.atom_2.alt_conf) { at_2 = residue_atoms_2[iat]; break; @@ -1552,9 +1552,9 @@ coot::restraints_container_t::add_extra_geman_mcclure_restraints(const extra_res r_2->GetAtomTable(residue_atoms_2, n_residue_atoms_2); for (int iat=0; iatname); + std::string atom_name_1(residue_atoms_1[iat]->GetAtomName()); if (atom_name_1 == ebr.atom_1.atom_name) { - std::string alt_loc_1(residue_atoms_1[iat]->altLoc); + std::string alt_loc_1(residue_atoms_1[iat]->altLoc()); if (alt_loc_1 == ebr.atom_1.alt_conf) { at_1 = residue_atoms_1[iat]; break; @@ -1562,9 +1562,9 @@ coot::restraints_container_t::add_extra_geman_mcclure_restraints(const extra_res } } for (int iat=0; iatname); + std::string atom_name_2(residue_atoms_2[iat]->GetAtomName()); if (atom_name_2 == ebr.atom_2.atom_name) { - std::string alt_loc_2(residue_atoms_2[iat]->altLoc); + std::string alt_loc_2(residue_atoms_2[iat]->altLoc()); if (alt_loc_2 == ebr.atom_2.alt_conf) { at_2 = residue_atoms_2[iat]; break; @@ -1821,8 +1821,8 @@ coot::restraints_container_t::add_extra_parallel_plane_restraints(int imol, dri_1.second.atom_name_for_tree_4c(r.plane_1_atoms.atom_names[i_rest_at]); for (int iat=0; iatname); - std::string alt_conf(at->altLoc); + std::string atom_name(at->GetAtomName()); + std::string alt_conf(at->altLoc()); if (plane_atom_expanded_name == atom_name) { if (r.plane_1_atoms.alt_conf == alt_conf) { int idx = -1; @@ -1849,8 +1849,8 @@ coot::restraints_container_t::add_extra_parallel_plane_restraints(int imol, dri_2.second.atom_name_for_tree_4c(r.plane_2_atoms.atom_names[i_rest_at]); for (int iat=0; iatname); - std::string alt_conf(at->altLoc); + std::string atom_name(at->GetAtomName()); + std::string alt_conf(at->altLoc()); // std::cout << "testing :" << plane_atom_expanded_name << ": vs :" << atom_name << ":" << std::endl; if (plane_atom_expanded_name == atom_name) { if (r.plane_2_atoms.alt_conf == alt_conf) { @@ -2121,14 +2121,14 @@ coot::extra_restraints_t::position_point_map(mmdb::Manager *mol_running, int n_atoms_1 = residue_1_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - std::string atom_name_1(at_1_p->name); - std::string alt_conf_1(at_1_p->altLoc); + std::string atom_name_1(at_1_p->GetAtomName()); + std::string alt_conf_1(at_1_p->altLoc()); int n_atoms_2 = residue_2_p->GetNumberOfAtoms(); for (int jat=0; jatGetAtom(jat); - std::string atom_name_2(at_2_p->name); - std::string alt_conf_2(at_2_p->altLoc); + std::string atom_name_2(at_2_p->GetAtomName()); + std::string alt_conf_2(at_2_p->altLoc()); if (atom_name_2 == atom_name_1) { if (alt_conf_2 == alt_conf_1) { @@ -2199,9 +2199,9 @@ coot::extra_restraints_t::write_interpolated_models(mmdb::Manager *mol_running, const clipper::Coord_orth &pt_1 = it_1->second; const clipper::Coord_orth &pt_2 = it_2->second; clipper::Coord_orth pt(pt_1 + (pt_2 - pt_1) * frac); - at->x = pt.x(); - at->y = pt.y(); - at->z = pt.z(); + at->x() = pt.x(); + at->y() = pt.y(); + at->z() = pt.z(); } else { std::cout << "failed to find spec for it_2 " << spec << std::endl; } diff --git a/ideal/flanking.cc b/ideal/flanking.cc index e57a03a45d..4a7fb8057d 100644 --- a/ideal/flanking.cc +++ b/ideal/flanking.cc @@ -129,13 +129,13 @@ coot::restraints_container_t::add_fixed_atoms_from_flanking_residues(bool have_f for (int iat=0; iatresidue->GetSeqNum() == iselection_start_res) { + if (at->GetResidue()->GetSeqNum() == iselection_start_res) { // perhaps this should be a set - yes. fixed_atom_indices.insert(iat); } } if (have_flanking_residue_at_end) { - if (at->residue->GetSeqNum() == iselection_end_res) { + if (at->GetResidue()->GetSeqNum() == iselection_end_res) { fixed_atom_indices.insert(iat); } } diff --git a/ideal/gradients.cc b/ideal/gradients.cc index 739ffbb587..d54f5b9bf4 100644 --- a/ideal/gradients.cc +++ b/ideal/gradients.cc @@ -335,7 +335,7 @@ void coot::my_df_bonds(const gsl_vector *v, idx = 3*restraints->at(i).atom_index_1; std::cout << "BOND Fixed atom[0] " << restraints->get_atom((*restraints)[i].atom_index_1)->GetSeqNum() << " " - << restraints->get_atom((*restraints)[i].atom_index_1)->name << " " + << restraints->get_atom((*restraints)[i].atom_index_1)->GetAtomName() << " " << ", Not adding " << x_k_contrib << " " << y_k_contrib << " " << z_k_contrib << " to " << gsl_vector_get(df, idx) << " " @@ -356,7 +356,7 @@ void coot::my_df_bonds(const gsl_vector *v, idx = 3*restraints->at(i).atom_index_2; std::cout << "BOND Fixed atom[1] " << restraints->get_atom((*restraints)[i].atom_index_2)->GetSeqNum() << " " - << restraints->get_atom((*restraints)[i].atom_index_2)->name << " " + << restraints->get_atom((*restraints)[i].atom_index_2)->GetAtomName() << " " << ", Not adding " << x_k_contrib << " " << y_k_contrib << " " << z_k_contrib << " to " diff --git a/ideal/link-restraints.cc b/ideal/link-restraints.cc index be0e953574..496a7f8552 100644 --- a/ideal/link-restraints.cc +++ b/ideal/link-restraints.cc @@ -123,7 +123,7 @@ coot::restraints_container_t::bonded_residues_by_linear(int SelResHnd, // an insertion code, or simply a gap - and we don't want // to make a bond for a gap. // - if (abs(SelResidue[i]->index - SelResidue[i+1]->index) <= 1) { + if (abs(SelResidue[i]->GetIndex() - SelResidue[i+1]->GetIndex()) <= 1) { // link_type = find_link_type(SelResidue[i], SelResidue[i+1], geom); std::cout << "####################### find_link_type_compli() called from bonded_residues_by_linear()" << std::endl; @@ -247,8 +247,8 @@ coot::restraints_container_t::bonded_residues_from_res_vec(const coot::protein_g bool was_straight_forward_trans_link = false; int resno_1 = res_f->GetSeqNum(); int resno_2 = res_s->GetSeqNum(); - int ser_num_1 = res_f->index; - int ser_num_2 = res_s->index; + int ser_num_1 = res_f->GetIndex(); + int ser_num_2 = res_s->GetIndex(); if (resno_2 == (resno_1 + 1)) { if (ser_num_2 == (ser_num_1 + 1)) { std::string rn_1 = res_f->GetResName(); @@ -314,10 +314,10 @@ coot::restraints_container_t::add_link_bond(std::string link_type, std::cout << "INFO:: geom.link_size() is " << geom.link_size() << std::endl; std::cout << "first residue:\n"; for (int i=0; iname << " " << first_sel[i]->GetSeqNum() << "\n"; + std::cout << " " << first_sel[i]->GetAtomName() << " " << first_sel[i]->GetSeqNum() << "\n"; std::cout << "second residue:\n"; for (int i=0; iname << " " << second_sel[i]->GetSeqNum() << "\n"; + std::cout << " " << second_sel[i]->GetAtomName() << " " << second_sel[i]->GetSeqNum() << "\n"; } int nbond = 0; @@ -333,26 +333,26 @@ coot::restraints_container_t::add_link_bond(std::string link_type, std::cout << "bad things will now happen..." << std::endl; } for (int ifat=0; ifatname); + std::string pdb_atom_name_1(first_sel[ifat]->GetAtomName()); if (pdb_atom_name_1 == geom.link(i).link_bond_restraint[j].atom_id_1_4c()) { for (int isat=0; isatname); + std::string pdb_atom_name_2(second_sel[isat]->GetAtomName()); if (pdb_atom_name_2 == geom.link(i).link_bond_restraint[j].atom_id_2_4c()) { if (debug) std::cout << "DEBUG:: adding " << link_type << " bond for " - << first->seqNum - << " -> " << second->seqNum << " atoms " + << first->GetSeqNum() + << " -> " << second->GetSeqNum() << " atoms " << first_sel [ifat]->GetAtomName() << " to " << second_sel[isat]->GetAtomName() << std::endl; // Now, do the alt confs match? // - std::string alt_conf_1 = first_sel[ifat]->altLoc; - std::string alt_conf_2 = second_sel[isat]->altLoc; + std::string alt_conf_1 = first_sel[ifat]->altLoc(); + std::string alt_conf_2 = second_sel[isat]->altLoc(); if ((alt_conf_1 == alt_conf_2) || (alt_conf_1 == "") || (alt_conf_2 == "")) { // 20230110-PE are you here again? Check that udd_atom_index_handle @@ -470,15 +470,15 @@ coot::restraints_container_t::add_link_angle(std::string link_type, } for (int ifat=0; ifatname); + std::string pdb_atom_name_1(atom_1_sel[ifat]->GetAtomName()); if (pdb_atom_name_1 == geom.link(i).link_angle_restraint[j].atom_id_1_4c()) { for (int isat=0; isatname); + std::string pdb_atom_name_2(atom_2_sel[isat]->GetAtomName()); if (pdb_atom_name_2 == geom.link(i).link_angle_restraint[j].atom_id_2_4c()) { for (int itat=0; itatname); + std::string pdb_atom_name_3(atom_3_sel[itat]->GetAtomName()); if (pdb_atom_name_3 == geom.link(i).link_angle_restraint[j].atom_id_3_4c()) { @@ -502,9 +502,9 @@ coot::restraints_container_t::add_link_angle(std::string link_type, // atom_3_sel[itat]->residue->seqNum, // atom_3_sel[itat]->residue->GetChainID()); - std::string alt_conf_1 = atom_1_sel[ifat]->altLoc; - std::string alt_conf_2 = atom_2_sel[isat]->altLoc; - std::string alt_conf_3 = atom_3_sel[itat]->altLoc; + std::string alt_conf_1 = atom_1_sel[ifat]->altLoc(); + std::string alt_conf_2 = atom_2_sel[isat]->altLoc(); + std::string alt_conf_3 = atom_3_sel[itat]->altLoc(); // either they are all the same (including the ususal case of all "") // or at_1 and at_2 are the same and at_3 is blank @@ -809,45 +809,45 @@ coot::restraints_container_t::add_link_torsion_for_phi_psi(std::string link_type fixed_flag[3] = is_fixed_second; } for (int ifat=0; ifatname); + std::string pdb_atom_name_1(atom_1_sel[ifat]->GetAtomName()); if (pdb_atom_name_1 == geom.link(i).link_torsion_restraint[j].atom_id_1_4c()) { for (int isat=0; isatname); + std::string pdb_atom_name_2(atom_2_sel[isat]->GetAtomName()); if (pdb_atom_name_2 == geom.link(i).link_torsion_restraint[j].atom_id_2_4c()) { for (int itat=0; itatname); + std::string pdb_atom_name_3(atom_3_sel[itat]->GetAtomName()); if (pdb_atom_name_3 == geom.link(i).link_torsion_restraint[j].atom_id_3_4c()) { for (int iffat=0; iffatname); + std::string pdb_atom_name_4(atom_4_sel[iffat]->GetAtomName()); if (pdb_atom_name_4 == geom.link(i).link_torsion_restraint[j].atom_id_4_4c()) { - int index1 = get_asc_index(atom_1_sel[ifat]->name, - atom_1_sel[ifat]->altLoc, - atom_1_sel[ifat]->residue->seqNum, + int index1 = get_asc_index(atom_1_sel[ifat]->GetAtomName(), + atom_1_sel[ifat]->altLoc(), + atom_1_sel[ifat]->GetResidue()->GetSeqNum(), atom_1_sel[ifat]->GetInsCode(), atom_1_sel[ifat]->GetChainID()); - int index2 = get_asc_index(atom_2_sel[isat]->name, - atom_2_sel[isat]->altLoc, - atom_2_sel[isat]->residue->seqNum, + int index2 = get_asc_index(atom_2_sel[isat]->GetAtomName(), + atom_2_sel[isat]->altLoc(), + atom_2_sel[isat]->GetResidue()->GetSeqNum(), atom_2_sel[isat]->GetInsCode(), atom_2_sel[isat]->GetChainID()); - int index3 = get_asc_index(atom_3_sel[itat]->name, - atom_3_sel[itat]->altLoc, - atom_3_sel[itat]->residue->seqNum, + int index3 = get_asc_index(atom_3_sel[itat]->GetAtomName(), + atom_3_sel[itat]->altLoc(), + atom_3_sel[itat]->GetResidue()->GetSeqNum(), atom_3_sel[itat]->GetInsCode(), atom_3_sel[itat]->GetChainID()); - int index4 = get_asc_index(atom_4_sel[iffat]->name, - atom_4_sel[iffat]->altLoc, - atom_4_sel[iffat]->residue->seqNum, + int index4 = get_asc_index(atom_4_sel[iffat]->GetAtomName(), + atom_4_sel[iffat]->altLoc(), + atom_4_sel[iffat]->GetResidue()->GetSeqNum(), atom_4_sel[iffat]->GetInsCode(), - atom_4_sel[iffat]->residue->GetChainID()); + atom_4_sel[iffat]->GetResidue()->GetChainID()); // std::cout << "torsion restraint.... " << geom.link(i).link_torsion_restraint[j].id() // << " from atoms \n " @@ -1434,8 +1434,8 @@ coot::restraints_container_t::find_link_type(mmdb::Residue *first, // Should return TRANS, PTRANS (PRO-TRANS), CIS, PCIS, p, BETA1-2, BETA1-4 etc. std::string link_type(""); // unset - std::string residue_type_1 = first->name; - std::string residue_type_2 = second->name; + std::string residue_type_1 = first->GetResName(); + std::string residue_type_2 = second->GetResName(); if (residue_type_1 == "UNK") residue_type_1 = "ALA"; // hack for KDC. if (residue_type_2 == "UNK") residue_type_2 = "ALA"; @@ -1544,8 +1544,8 @@ coot::restraints_container_t::find_link_type_2022(mmdb::Residue *first_residue, auto get_consecutive = [] (mmdb::Residue *first_residue, mmdb::Residue *second_residue) { bool state = false; - int idx_1 = first_residue->index; - int idx_2 = second_residue->index; + int idx_1 = first_residue->GetIndex(); + int idx_2 = second_residue->GetIndex(); int d = idx_2 - idx_1; if (d <= 1) if (d >= -1) @@ -1564,7 +1564,7 @@ coot::restraints_container_t::find_link_type_2022(mmdb::Residue *first_residue, for (int iat=0; iatisTer()) { - std::string name(at->name); + std::string name(at->GetAtomName()); if (name == " SG ") { found = true; break; @@ -1579,7 +1579,7 @@ coot::restraints_container_t::find_link_type_2022(mmdb::Residue *first_residue, for (int iat=0; iatisTer()) { - std::string name(at->name); + std::string name(at->GetAtomName()); if (name == " SG ") { found = true; break; // micro-optimiziation! @@ -1607,10 +1607,10 @@ coot::restraints_container_t::find_link_type_2022(mmdb::Residue *first_residue, for (int iat=0; iatisTer()) { - std::string name(at->name); + std::string name(at->GetAtomName()); if (name == " C ") { found_1 = true; - pt_1 = clipper::Coord_orth(at->x, at->y, at->z); + pt_1 = clipper::Coord_orth(at->x(), at->y(), at->z()); } } } @@ -1620,10 +1620,10 @@ coot::restraints_container_t::find_link_type_2022(mmdb::Residue *first_residue, for (int iat=0; iatisTer()) { - std::string name(at->name); + std::string name(at->GetAtomName()); if (name == " O3'") { found_2 = true; - pt_2 = clipper::Coord_orth(at->x, at->y, at->z); + pt_2 = clipper::Coord_orth(at->x(), at->y(), at->z()); } } } @@ -1653,10 +1653,10 @@ coot::restraints_container_t::find_link_type_2022(mmdb::Residue *first_residue, for (int iat=0; iatisTer()) { - std::string name(at->name); + std::string name(at->GetAtomName()); if (name == " C1 ") { found_1 = true; - pt_1 = clipper::Coord_orth(at->x, at->y, at->z); + pt_1 = clipper::Coord_orth(at->x(), at->y(), at->z()); } } } @@ -1666,10 +1666,10 @@ coot::restraints_container_t::find_link_type_2022(mmdb::Residue *first_residue, for (int iat=0; iatisTer()) { - std::string name(at->name); + std::string name(at->GetAtomName()); if (name == " OG ") { found_2 = true; - pt_2 = clipper::Coord_orth(at->x, at->y, at->z); + pt_2 = clipper::Coord_orth(at->x(), at->y(), at->z()); } } } @@ -1716,10 +1716,10 @@ coot::restraints_container_t::find_link_type_2022(mmdb::Residue *first_residue, for (int iat=0; iatisTer()) { - std::string name(at->name); + std::string name(at->GetAtomName()); if (name == link_atom_1_name) { found_1 = true; - pt_1 = clipper::Coord_orth(at->x, at->y, at->z); + pt_1 = clipper::Coord_orth(at->x(), at->y(), at->z()); } } } @@ -1729,10 +1729,10 @@ coot::restraints_container_t::find_link_type_2022(mmdb::Residue *first_residue, for (int iat=0; iatisTer()) { - std::string name(at->name); + std::string name(at->GetAtomName()); if (name == link_atom_2_name) { found_2 = true; - pt_2 = clipper::Coord_orth(at->x, at->y, at->z); + pt_2 = clipper::Coord_orth(at->x(), at->y(), at->z()); } } } @@ -2043,8 +2043,8 @@ coot::restraints_container_t::general_link_find_close_link_inner(const std::vect mmdb::Atom *at_1 = r1->GetAtom(atom_id_1.c_str()); mmdb::Atom *at_2 = r2->GetAtom(atom_id_2.c_str()); if (at_1 && at_2) { - clipper::Coord_orth p1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth p2(at_2->x, at_2->y, at_2->z); + clipper::Coord_orth p1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth p2(at_2->x(), at_2->y(), at_2->z()); double d = clipper::Coord_orth::length(p1,p2); if (debug) std::cout << " dist check " << " link-bond-number: " @@ -2084,14 +2084,14 @@ coot::restraints_container_t::general_link_find_close_link_inner(const std::vect r1->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; iGetResName() << " " - << i << " :" << residue_atoms[i]->name + << i << " :" << residue_atoms[i]->GetAtomName() << ":" << std::endl; } residue_atoms = 0; r2->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; iGetResName() << " " - << i << " :" << residue_atoms[i]->name + << i << " :" << residue_atoms[i]->GetAtomName() << ":" << std::endl; } } @@ -2152,7 +2152,7 @@ int coot::restraints_container_t::add_link_plane(std::string link_type, // std::map > atom_indices_map; for (int iat=0; iataltLoc); + std::string alt_loc(first_sel[iat]->altLoc()); std::map >::const_iterator it = atom_indices_map.find(alt_loc); if (it == atom_indices_map.end()) { std::vector v; @@ -2160,7 +2160,7 @@ int coot::restraints_container_t::add_link_plane(std::string link_type, } } for (int iat=0; iataltLoc); + std::string alt_loc(second_sel[iat]->altLoc()); std::map >::const_iterator it = atom_indices_map.find(alt_loc); if (it == atom_indices_map.end()) { std::vector v; @@ -2192,14 +2192,14 @@ int coot::restraints_container_t::add_link_plane(std::string link_type, fixed_flags[irest_at] = is_fixed_second_res; } for (int iat=0; iatname); + std::string pdb_atom_name(atom_sel[iat]->GetAtomName()); if (geom.link(i).link_plane_restraint[ip].atom_id(irest_at) == pdb_atom_name) { if (debug) - std::cout << " pushing back to :" << atom_sel[iat]->altLoc << ": vector " + std::cout << " pushing back to :" << atom_sel[iat]->altLoc() << ": vector " << res->GetChainID() << " " - << res->seqNum << " :" - << atom_sel[iat]->name << ": :" - << atom_sel[iat]->altLoc << ":" << std::endl; + << res->GetSeqNum() << " :" + << atom_sel[iat]->GetAtomName() << ": :" + << atom_sel[iat]->altLoc() << ":" << std::endl; // Too slow for ribosomes @@ -2209,7 +2209,7 @@ int coot::restraints_container_t::add_link_plane(std::string link_type, // res->GetInsCode(), // res->GetChainID())); - std::string key(atom_sel[iat]->altLoc); + std::string key(atom_sel[iat]->altLoc()); int idx_t_2 = -1; atom_sel[iat]->GetUDData(udd_atom_index_handle, idx_t_2); atom_indices_map[key].push_back(idx_t_2); @@ -2232,8 +2232,8 @@ int coot::restraints_container_t::add_link_plane(std::string link_type, for (unsigned int ind=0; indsecond.size(); ind++) { std::cout << ind << " " << atom[it->second[ind]]->GetChainID() << " " << atom[it->second[ind]]->GetSeqNum() << " :" - << atom[it->second[ind]]->name << ": :" - << atom[it->second[ind]]->altLoc << ":\n"; + << atom[it->second[ind]]->GetAtomName() << ": :" + << atom[it->second[ind]]->altLoc() << ":\n"; } std::cout << "DEBUG:: add_link_plane() with pos indexes "; for (unsigned int ipos=0; ipossecond.size(); ipos++) diff --git a/ideal/make-restraints.cc b/ideal/make-restraints.cc index 6dec784e8f..826ed11079 100644 --- a/ideal/make-restraints.cc +++ b/ideal/make-restraints.cc @@ -378,23 +378,23 @@ coot::restraints_container_t::make_helix_pseudo_bond_restraints() { // nO -> (n+4)N 2.91 // and backwards directions. SelResidue[i]->GetAtomTable(res_1_atoms, n_res_1_atoms); for (int iat1=0; iat1name); + std::string at_1_name(res_1_atoms[iat1]->GetAtomName()); if (at_1_name == " N ") { mmdb::Residue *contact_res = SelResidue[i-4]; if (SelResidue[i]->GetSeqNum() == (contact_res->GetSeqNum() + 4)) { contact_res->GetAtomTable(res_2_atoms, n_res_2_atoms); for (int iat2=0; iat2name); + std::string at_2_name(res_2_atoms[iat2]->GetAtomName()); if (at_2_name == " O ") { res_1_atoms[iat1]->GetUDData(udd_atom_index_handle, index1); res_2_atoms[iat2]->GetUDData(udd_atom_index_handle, index2); std::vector fixed_flags = make_fixed_flags(index1, index2); add(BOND_RESTRAINT, index1, index2, fixed_flags, 2.91, pseudo_bond_esd, 1.2); - std::cout << "Helix Bond restraint (" << res_1_atoms[iat1]->name << " " + std::cout << "Helix Bond restraint (" << res_1_atoms[iat1]->GetAtomName() << " " << res_1_atoms[iat1]->GetSeqNum() << ") to (" - << res_2_atoms[iat2]->name << " " + << res_2_atoms[iat2]->GetAtomName() << " " << res_2_atoms[iat2]->GetSeqNum() << ") 2.91" << std::endl; } } @@ -404,16 +404,16 @@ coot::restraints_container_t::make_helix_pseudo_bond_restraints() { if (SelResidue[i]->GetSeqNum() == (contact_res->GetSeqNum() + 3)) { contact_res->GetAtomTable(res_2_atoms, n_res_2_atoms); for (int iat2=0; iat2name); + std::string at_2_name(res_2_atoms[iat2]->GetAtomName()); if (at_2_name == " O ") { std::vector fixed_flags = make_fixed_flags(index1, index2); res_1_atoms[iat1]->GetUDData(udd_atom_index_handle, index1); res_2_atoms[iat2]->GetUDData(udd_atom_index_handle, index2); add(BOND_RESTRAINT, index1, index2, fixed_flags, 3.18, pseudo_bond_esd, 1.2); - std::cout << "Helix Bond restraint (" << res_1_atoms[iat1]->name << " " + std::cout << "Helix Bond restraint (" << res_1_atoms[iat1]->GetAtomName() << " " << res_1_atoms[iat1]->GetSeqNum() << ") to (" - << res_2_atoms[iat2]->name << " " + << res_2_atoms[iat2]->GetAtomName() << " " << res_2_atoms[iat2]->GetSeqNum() << ") 3.18" << std::endl; } } @@ -579,13 +579,13 @@ coot::restraints_container_t::make_helix_pseudo_bond_restraints_from_res_vec_aut // std::cout << "INFO:: Alpha Helix Bond restraint (" // << at_1->name << " " << at_1->GetSeqNum() << ") to (" // << at_3->name << " " << at_3->GetSeqNum() << ") " << ideal_dist_i_3 << std::endl; - logger.log(log_t::INFO, "Alpha Helix Bond restraint (" + std::string(at_1->name) + " " + std::to_string(at_1->GetSeqNum()) + - ") to (" + std::string(at_3->name) + " " + std::to_string(at_3->GetSeqNum()) + ") " + std::to_string(ideal_dist_i_3)); + logger.log(log_t::INFO, "Alpha Helix Bond restraint (" + std::string(at_1->GetAtomName()) + " " + std::to_string(at_1->GetSeqNum()) + + ") to (" + std::string(at_3->GetAtomName()) + " " + std::to_string(at_3->GetSeqNum()) + ") " + std::to_string(ideal_dist_i_3)); // std::cout << "INFO:: Alpha Helix Bond restraint (" // << at_1->name << " " << at_1->GetSeqNum() << ") to (" // << at_2->name << " " << at_2->GetSeqNum() << ") " << ideal_dist_i_4 << std::endl; - logger.log(log_t::INFO, "Alpha Helix Bond restraint (" + std::string(at_1->name) + " " + std::to_string(at_1->GetSeqNum()) + - ") to (" + std::string(at_2->name) + " " + std::to_string(at_2->GetSeqNum()) + ") " + std::to_string(ideal_dist_i_4)); + logger.log(log_t::INFO, "Alpha Helix Bond restraint (" + std::string(at_1->GetAtomName()) + " " + std::to_string(at_1->GetSeqNum()) + + ") to (" + std::string(at_2->GetAtomName()) + " " + std::to_string(at_2->GetSeqNum()) + ") " + std::to_string(ideal_dist_i_4)); } n_helical_restraints += 2; } else { @@ -600,8 +600,8 @@ coot::restraints_container_t::make_helix_pseudo_bond_restraints_from_res_vec_aut // std::cout << "INFO:: Alpha Helix Bond restraint (" // << at_1->name << " " << at_1->GetSeqNum() << ") to (" // << at_3->name << " " << at_3->GetSeqNum() << ") " << ideal_dist_i_3 << std::endl; - logger.log(log_t::INFO, "Alpha Helix Bond restraint (" + std::string(at_1->name) + " " + std::to_string(at_1->GetSeqNum()) + - ") to (" + std::string(at_3->name) + " " + std::to_string(at_3->GetSeqNum()) + ") " + std::to_string(ideal_dist_i_3)); + logger.log(log_t::INFO, "Alpha Helix Bond restraint (" + std::string(at_1->GetAtomName()) + " " + std::to_string(at_1->GetSeqNum()) + + ") to (" + std::string(at_3->GetAtomName()) + " " + std::to_string(at_3->GetSeqNum()) + ") " + std::to_string(ideal_dist_i_3)); } n_helical_restraints += 1; } @@ -678,8 +678,8 @@ coot::restraints_container_t::make_helix_pseudo_bond_restraints_from_res_vec() { mmdb::Atom *at_2 = residue_atoms_2[jat]; std::string atom_name_2 = at_2->GetAtomName(); if (atom_name_2 == " N ") { - std::string alt_conf_1 = at_1->altLoc; - std::string alt_conf_2 = at_2->altLoc; + std::string alt_conf_1 = at_1->altLoc(); + std::string alt_conf_2 = at_2->altLoc(); if (alt_conf_1 == alt_conf_2) { int index_1 = -1; @@ -692,13 +692,13 @@ coot::restraints_container_t::make_helix_pseudo_bond_restraints_from_res_vec() { ideal_dist = 3.181; add(BOND_RESTRAINT, index_1, index_2, fixed_flags, ideal_dist, pseudo_bond_esd, 1.2); std::cout << "Helix Bond restraint (" - << at_1->name << " " << at_1->GetSeqNum() << ") to (" - << at_2->name << " " << at_2->GetSeqNum() << ") " << ideal_dist << std::endl; + << at_1->GetAtomName() << " " << at_1->GetSeqNum() << ") to (" + << at_2->GetAtomName() << " " << at_2->GetSeqNum() << ") " << ideal_dist << std::endl; } } if (atom_name_2 == " O ") { - std::string alt_conf_1 = at_1->altLoc; - std::string alt_conf_2 = at_2->altLoc; + std::string alt_conf_1 = at_1->altLoc(); + std::string alt_conf_2 = at_2->altLoc(); if (alt_conf_1 == alt_conf_2) { int index_1 = -1; @@ -712,8 +712,8 @@ coot::restraints_container_t::make_helix_pseudo_bond_restraints_from_res_vec() { double O_O_pseudo_bond_esd = 0.07; // guess add(BOND_RESTRAINT, index_1, index_2, fixed_flags, ideal_dist, O_O_pseudo_bond_esd, 1.2); std::cout << "Helix Bond restraint (" - << at_1->name << " " << at_1->GetSeqNum() << ") to (" - << at_2->name << " " << at_2->GetSeqNum() << ") " << ideal_dist << std::endl; + << at_1->GetAtomName() << " " << at_1->GetSeqNum() << ") to (" + << at_2->GetAtomName() << " " << at_2->GetSeqNum() << ") " << ideal_dist << std::endl; } } } @@ -771,7 +771,7 @@ coot::restraints_container_t::make_strand_pseudo_bond_restraints() { SelResidue[i]->GetAtomTable(res_1_atoms, n_res_1_atoms); if (res_1_atoms) { for (int iat1=0; iat1name); + std::string at_1_name(res_1_atoms[iat1]->GetAtomName()); // O Pseudo bonds and angles if (at_1_name == " O ") { mmdb::Residue *contact_res = SelResidue[i-1]; @@ -779,7 +779,7 @@ coot::restraints_container_t::make_strand_pseudo_bond_restraints() { contact_res->GetAtomTable(res_2_atoms, n_res_2_atoms); if (res_2_atoms) { for (int iat2=0; iat2name); + std::string at_2_name(res_2_atoms[iat2]->GetAtomName()); if (at_2_name == " O ") { std::vector fixed_flags = make_fixed_flags(index1, index2); res_1_atoms[iat1]->GetUDData(udd_atom_index_handle, index1); @@ -787,9 +787,9 @@ coot::restraints_container_t::make_strand_pseudo_bond_restraints() { add(BOND_RESTRAINT, index1, index2, fixed_flags, 4.64, pseudo_bond_esd, 1.2); std::cout << "Strand Bond restraint (" - << res_1_atoms[iat1]->name << " " + << res_1_atoms[iat1]->GetAtomName() << " " << res_1_atoms[iat1]->GetSeqNum() << ") to (" - << res_2_atoms[iat2]->name << " " + << res_2_atoms[iat2]->GetAtomName() << " " << res_2_atoms[iat2]->GetSeqNum() << ") 4.64" << std::endl; // now the pseudo angle @@ -798,7 +798,7 @@ coot::restraints_container_t::make_strand_pseudo_bond_restraints() { if (SelResidue[i]->GetSeqNum() == (contact_res_2->GetSeqNum() - 1)) { contact_res_2->GetAtomTable(res_3_atoms, n_res_3_atoms); for (int iat3=0; iat3name); + std::string at_3_name(res_3_atoms[iat3]->GetAtomName()); if (at_3_name == " O ") { std::vector fixed_flag = make_fixed_flags(index2, index1, index3); @@ -807,12 +807,12 @@ coot::restraints_container_t::make_strand_pseudo_bond_restraints() { add(ANGLE_RESTRAINT, index2, index1, index3, fixed_flag, 98.0, 0.5, false); std::cout << "Strand Angle restraint (" - << res_1_atoms[iat1]->name << " " + << res_1_atoms[iat1]->GetAtomName() << " " << res_1_atoms[iat1]->GetSeqNum() << ") to (" - << res_2_atoms[iat2]->name << " " + << res_2_atoms[iat2]->GetAtomName() << " " << res_2_atoms[iat2]->GetSeqNum() << ") to (" - << res_3_atoms[iat3]->name << " " + << res_3_atoms[iat3]->GetAtomName() << " " << res_3_atoms[iat3]->GetSeqNum() << ") 98.0 " << std::endl; break; @@ -834,14 +834,14 @@ coot::restraints_container_t::make_strand_pseudo_bond_restraints() { contact_res_2->GetAtomTable(res_2_atoms, n_res_2_atoms); if (res_2_atoms) { for (int iat2=0; iat2name); + std::string at_2_name(res_2_atoms[iat2]->GetAtomName()); if (at_2_name == " CA ") { if (i<(nSelResidues-1)) { mmdb::Residue *contact_res_3 = SelResidue[i+1]; if (SelResidue[i]->GetSeqNum() == (contact_res_3->GetSeqNum() - 1)) { contact_res_3->GetAtomTable(res_3_atoms, n_res_3_atoms); for (int iat3=0; iat3name); + std::string at_3_name(res_3_atoms[iat3]->GetAtomName()); if (at_3_name == " CA ") { std::vector fixed_flag = make_fixed_flags(index1, index2, index3); @@ -851,12 +851,12 @@ coot::restraints_container_t::make_strand_pseudo_bond_restraints() { add(ANGLE_RESTRAINT, index2, index1, index3, fixed_flag, 120.0, 0.5, false); std::cout << "Strand Angle restraint (" - << res_1_atoms[iat1]->name << " " + << res_1_atoms[iat1]->GetAtomName() << " " << res_1_atoms[iat1]->GetSeqNum() << ") to (" - << res_2_atoms[iat2]->name << " " + << res_2_atoms[iat2]->GetAtomName() << " " << res_2_atoms[iat2]->GetSeqNum() << ") to (" - << res_3_atoms[iat3]->name << " " + << res_3_atoms[iat3]->GetAtomName() << " " << res_3_atoms[iat3]->GetSeqNum() << ") 120.0 " << std::endl; break; @@ -1065,7 +1065,7 @@ coot::restraints_container_t::make_monomer_restraints_by_residue(int imol, mmdb: return local; } - std::string pdb_resname(residue_p->name); + std::string pdb_resname(residue_p->GetResName()); if (pdb_resname == "UNK") pdb_resname = "ALA"; if (false) @@ -1181,7 +1181,7 @@ coot::restraints_container_t::add_bonds(int idr, mmdb::PPAtom res_selection, for (unsigned int ib=0; ibname); + std::string pdb_atom_name1(res_selection[iat]->GetAtomName()); if (debug) std::cout << "comparing first (pdb) :" << pdb_atom_name1 @@ -1192,7 +1192,7 @@ coot::restraints_container_t::add_bonds(int idr, mmdb::PPAtom res_selection, if (pdb_atom_name1 == dict.bond_restraint[ib].atom_id_1_4c()) { for (int iat2=0; iat2name); + std::string pdb_atom_name2(res_selection[iat2]->GetAtomName()); if (debug) std::cout << "comparing second (pdb) :" << pdb_atom_name2 @@ -1203,8 +1203,8 @@ coot::restraints_container_t::add_bonds(int idr, mmdb::PPAtom res_selection, if (pdb_atom_name2 == dict.bond_restraint[ib].atom_id_2_4c()) { // check that the alt confs aren't different - std::string alt_1(res_selection[iat ]->altLoc); - std::string alt_2(res_selection[iat2]->altLoc); + std::string alt_1(res_selection[iat ]->altLoc()); + std::string alt_2(res_selection[iat2]->altLoc()); if (alt_1 == "" || alt_2 == "" || alt_1 == alt_2) { if (debug) { @@ -1244,19 +1244,19 @@ coot::restraints_container_t::add_bonds(int idr, mmdb::PPAtom res_selection, if (debug) { std::string altconf_1("\""); - altconf_1 += atom[index1]->altLoc; + altconf_1 += atom[index1]->altLoc(); altconf_1 += "\""; std::string altconf_2("\""); - altconf_2 += atom[index2]->altLoc; + altconf_2 += atom[index2]->altLoc(); altconf_2 += "\""; std::cout << "creating (monomer) bond restraint, idr " << idr << " with fixed flags " << fixed_flags[0] << " " << fixed_flags[1] << " " << atom[index1]->GetSeqNum() << " " - << "\"" << atom[index1]->name << "\" " + << "\"" << atom[index1]->GetAtomName() << "\" " << std::setw(3) << altconf_1 << " to " << atom[index2]->GetSeqNum() << " " - << "\"" << atom[index2]->name << "\" " + << "\"" << atom[index2]->GetAtomName() << "\" " << std::setw(3) << altconf_2 << " " << "bond restraint index " << n_bond_restr << "\n"; } @@ -1276,7 +1276,7 @@ coot::restraints_container_t::add_bonds(int idr, mmdb::PPAtom res_selection, if (is_hydrogen(atom[index1])) { mmdb::Atom *H_at = atom[index1]; mmdb::Atom *parent_at = atom[index2]; - std::string atom_name(parent_at->name); + std::string atom_name(parent_at->GetAtomName()); std::string te = dict.type_energy(atom_name); hb_t hbt = geom.get_h_bond_type(te); H_atom_parent_energy_type_atom_map[H_at] = hbt; @@ -1286,7 +1286,7 @@ coot::restraints_container_t::add_bonds(int idr, mmdb::PPAtom res_selection, if (is_hydrogen(atom[index2])) { mmdb::Atom *H_at = atom[index2]; mmdb::Atom *parent_at = atom[index1]; - std::string atom_name(parent_at->name); + std::string atom_name(parent_at->GetAtomName()); std::string te = dict.type_energy(atom_name); hb_t hbt = geom.get_h_bond_type(te); H_atom_parent_energy_type_atom_map[H_at] = hbt; @@ -1298,7 +1298,7 @@ coot::restraints_container_t::add_bonds(int idr, mmdb::PPAtom res_selection, // So kludge that in here if (dict.residue_info.comp_id == "HIS") { mmdb::Atom *parent_at = atom[index1]; - std::string parent_atom_name(parent_at->name); + std::string parent_atom_name(parent_at->GetAtomName()); if (parent_atom_name == "ND1 ") // PDBv3 fixme H_atom_parent_energy_type_atom_map[H_at] = HB_BOTH; if (parent_atom_name == "NE2 ") // PDBv3 fixme @@ -1306,7 +1306,7 @@ coot::restraints_container_t::add_bonds(int idr, mmdb::PPAtom res_selection, } if (dict.residue_info.comp_id == "TRP") { mmdb::Atom *parent_at = atom[index1]; - std::string parent_atom_name(parent_at->name); + std::string parent_atom_name(parent_at->GetAtomName()); if (parent_atom_name == "NE1 ") // PDBv3 fixme H_atom_parent_energy_type_atom_map[H_at] = HB_BOTH; } @@ -1344,7 +1344,7 @@ coot::restraints_container_t::add_angles(int idr, mmdb::PPAtom res_selection, std::vector string_atom_names(i_no_res_atoms); for (int iat=0; iatname; + string_atom_names[iat] = res_selection[iat]->GetAtomName(); // std::cout << "There are " << geom[idr].angle_restraint.size() // << " angle restraints for this residue type" << std::endl; @@ -1372,9 +1372,9 @@ coot::restraints_container_t::add_angles(int idr, mmdb::PPAtom res_selection, const std::string &pdb_atom_name3 = string_atom_names[iat3]; if (pdb_atom_name3 == geom[idr].second.angle_restraint[ib].atom_id_3_4c()) { - std::string alt_1(res_selection[iat ]->altLoc); - std::string alt_2(res_selection[iat2]->altLoc); - std::string alt_3(res_selection[iat3]->altLoc); + std::string alt_1(res_selection[iat ]->altLoc()); + std::string alt_2(res_selection[iat2]->altLoc()); + std::string alt_3(res_selection[iat3]->altLoc()); if (((alt_1 == alt_2) && (alt_1 == alt_3)) || ((alt_1 == "" ) && (alt_2 == alt_3)) || @@ -1441,22 +1441,22 @@ coot::restraints_container_t::add_torsion_internal(const coot::dict_torsion_rest // now find the atoms for (int iat=0; iatname); + std::string pdb_atom_name1(res_selection[iat]->GetAtomName()); if (pdb_atom_name1 == torsion_restraint.atom_id_1_4c()) { for (int iat2=0; iat2name); + std::string pdb_atom_name2(res_selection[iat2]->GetAtomName()); if (pdb_atom_name2 == torsion_restraint.atom_id_2_4c()) { for (int iat3=0; iat3name); + std::string pdb_atom_name3(res_selection[iat3]->GetAtomName()); if (pdb_atom_name3 == torsion_restraint.atom_id_3_4c()) { for (int iat4=0; iat4name); + std::string pdb_atom_name4(res_selection[iat4]->GetAtomName()); if (pdb_atom_name4 == torsion_restraint.atom_id_4_4c()) { // now we need the indices of @@ -1490,10 +1490,10 @@ coot::restraints_container_t::add_torsion_internal(const coot::dict_torsion_rest if (torsion_angle > 360) torsion_angle -= 360; - std::string alt_conf_1(res_selection[iat]->altLoc); - std::string alt_conf_2(res_selection[iat2]->altLoc); - std::string alt_conf_3(res_selection[iat3]->altLoc); - std::string alt_conf_4(res_selection[iat4]->altLoc); + std::string alt_conf_1(res_selection[iat]->altLoc()); + std::string alt_conf_2(res_selection[iat2]->altLoc()); + std::string alt_conf_3(res_selection[iat3]->altLoc()); + std::string alt_conf_4(res_selection[iat4]->altLoc()); bool alt_confs_match = false; if (alt_conf_1 == "" || alt_conf_1 == alt_conf_2) @@ -1574,7 +1574,7 @@ coot::restraints_container_t::add_chirals(int idr, mmdb::PPAtom res_selection, std::vector string_atom_names(i_no_res_atoms); for (int iat=0; iatname; + string_atom_names[iat] = res_selection[iat]->GetAtomName(); for (unsigned int ic=0; icaltLoc; - std::string alt_conf_1 = res_selection[iat1]->altLoc; - std::string alt_conf_2 = res_selection[iat2]->altLoc; - std::string alt_conf_3 = res_selection[iat3]->altLoc; + std::string alt_conf_c = res_selection[iatc]->altLoc(); + std::string alt_conf_1 = res_selection[iat1]->altLoc(); + std::string alt_conf_2 = res_selection[iat2]->altLoc(); + std::string alt_conf_3 = res_selection[iat3]->altLoc(); if (((alt_conf_1 == alt_conf_c) || (alt_conf_1 == "")) && ((alt_conf_2 == alt_conf_c) || (alt_conf_2 == "")) && @@ -1638,7 +1638,7 @@ coot::restraints_container_t::add_chirals(int idr, mmdb::PPAtom res_selection, if (false) // debug std::cout << " Adding chiral restraint for " - << res_selection[iatc]->name + << res_selection[iatc]->GetAtomName() << " " << res_selection[iatc]->GetSeqNum() << " " << res_selection[iatc]->GetChainID() << " with target volume " @@ -1663,7 +1663,7 @@ coot::restraints_container_t::add_chirals(int idr, mmdb::PPAtom res_selection, n_chiral_restr++; } else { std::cout << "WARNING:: Reject chiral restraint for " - << res_selection[iatc]->name + << res_selection[iatc]->GetAtomName() << " " << res_selection[iatc]->GetSeqNum() << " " << res_selection[iatc]->GetChainID() << " with target volume " @@ -1779,7 +1779,7 @@ coot::restraints_container_t::add_planes_multiatom_eigen(int idr, mmdb::PPAtom r if (debug) std::cout << "There are " << geom[idr].second.plane_restraint.size() - << " dictionary plane restraints for " << SelRes->seqNum << " type: " + << " dictionary plane restraints for " << SelRes->GetSeqNum() << " type: " << geom[idr].second.residue_info.comp_id << std::endl; int n_plane_restr = 0; @@ -1795,8 +1795,8 @@ coot::restraints_container_t::add_planes_multiatom_eigen(int idr, mmdb::PPAtom r for (unsigned int ip=0; ip > > idx_and_sigmas; for (int iat=0; iatname); - std::string alt_conf(res_selection[iat]->altLoc); + std::string pdb_atom_name(res_selection[iat]->GetAtomName()); + std::string alt_conf(res_selection[iat]->altLoc()); for (int irest_at=0; irest_at string_atom_names(i_no_res_atoms); for (int iat=0; iatname; + string_atom_names[iat] = res_selection[iat]->GetAtomName(); for (unsigned int ic=0; icaltLoc; - std::string alt_conf_2 = res_selection[iat2]->altLoc; - std::string alt_conf_3 = res_selection[iat3]->altLoc; - std::string alt_conf_4 = res_selection[iat4]->altLoc; + std::string alt_conf_1 = res_selection[iat1]->altLoc(); + std::string alt_conf_2 = res_selection[iat2]->altLoc(); + std::string alt_conf_3 = res_selection[iat3]->altLoc(); + std::string alt_conf_4 = res_selection[iat4]->altLoc(); if (((alt_conf_1 == alt_conf_4) || (alt_conf_1 == "")) && ((alt_conf_2 == alt_conf_4) || (alt_conf_2 == "")) && @@ -2029,12 +2029,12 @@ coot::restraints_container_t::add_rama(std::string link_type, rama_atoms[ir] = 0; for (int i=0; iname); + std::string atom_name(prev_sel[i]->GetAtomName()); if (atom_name == " C ") rama_atoms[0] = prev_sel[i]; } for (int i=0; iname); + std::string atom_name(this_sel[i]->GetAtomName()); if (atom_name == " N ") rama_atoms[1] = this_sel[i]; if (atom_name == " CA ") @@ -2043,7 +2043,7 @@ coot::restraints_container_t::add_rama(std::string link_type, rama_atoms[3] = this_sel[i]; } for (int i=0; iname); + std::string atom_name(post_sel[i]->GetAtomName()); if (atom_name == " N ") rama_atoms[4] = post_sel[i]; } @@ -2205,7 +2205,7 @@ coot::restraints_container_t::construct_non_bonded_contact_list_conventional() { bool matched_oxt = false; if (have_oxt_flag) { - if (std::string(res_selection_local[iat]->name) == " OXT") { // PDBv3 FIXME + if (std::string(res_selection_local[iat]->GetAtomName()) == " OXT") { // PDBv3 FIXME matched_oxt = true; } else { matched_oxt = false; @@ -2243,7 +2243,7 @@ coot::restraints_container_t::construct_non_bonded_contact_list_conventional() { // PDBv3 FIXME if (have_oxt_flag) - if (! strcmp(res_selection_local_inner[jat]->name, " OXT")) // matched + if (! strcmp(res_selection_local_inner[jat]->GetAtomName(), " OXT")) // matched matched_oxt = true; if (! matched_oxt) { @@ -2273,7 +2273,7 @@ coot::restraints_container_t::construct_non_bonded_contact_list_conventional() { std::cout << " conventional non-bonded list (unfiltered by distance):" << std::endl; std::cout << "--------------------------------------------------\n"; for (unsigned int i=0; iGetSeqNum() << " " << atom[i]->name << " : "; + std::cout << i << " " << atom[i]->GetSeqNum() << " " << atom[i]->GetAtomName() << " : "; for (unsigned int j=0; jname) == " OXT") { // PDBv3 FIXME + if (std::string(atom[i]->GetAtomName()) == " OXT") { // PDBv3 FIXME matched_oxt = true; } } @@ -2352,7 +2352,7 @@ coot::restraints_container_t::construct_non_bonded_contact_list_by_res_vec(const if (i != j) { if (have_oxt_flag) { - if (std::string(atom[j]->name) == " OXT") { // PDBv3 FIXME + if (std::string(atom[j]->GetAtomName()) == " OXT") { // PDBv3 FIXME matched_oxt = true; } } @@ -2387,16 +2387,16 @@ coot::restraints_container_t::construct_non_bonded_contact_list_by_res_vec(const // clipper::Coord_orth pt2(atom[j]->x, atom[j]->y, atom[j]->z); // double d = clipper::Coord_orth::length(pt1, pt2); - double xd(atom[i]->x - atom[j]->x); - double yd(atom[i]->y - atom[j]->y); - double zd(atom[i]->z - atom[j]->z); + double xd(atom[i]->x() - atom[j]->x()); + double yd(atom[i]->y() - atom[j]->y()); + double zd(atom[i]->z() - atom[j]->z()); double d_sqrd = xd*xd + yd*yd + zd*zd; if (d_sqrd < dist_crit_sqrd) { - mmdb::Residue *r1 = atom[i]->residue; - mmdb::Residue *r2 = atom[j]->residue; + mmdb::Residue *r1 = atom[i]->GetResidue(); + mmdb::Residue *r2 = atom[j]->GetResidue(); - std::string alt_conf_1 = atom[i]->altLoc; - std::string alt_conf_2 = atom[j]->altLoc; + std::string alt_conf_1 = atom[i]->altLoc(); + std::string alt_conf_2 = atom[j]->altLoc(); if ((alt_conf_1 == alt_conf_2) || (alt_conf_1.length() == 0) || @@ -2426,12 +2426,12 @@ coot::restraints_container_t::construct_non_bonded_contact_list_by_res_vec(const // for (int iat=0; iatresidue; + mmdb::Residue *bonded_atom_residue = atom[iat]->GetResidue(); for (int jat=0; jatresidue; + mmdb::Residue *other_atom_residue = atom[jat]->GetResidue(); if (bonded_atom_residue != other_atom_residue) { if (is_a_moving_residue_p(bonded_atom_residue) && @@ -2439,7 +2439,7 @@ coot::restraints_container_t::construct_non_bonded_contact_list_by_res_vec(const bool matched_oxt = false; if (have_oxt_flag) { - if (std::string(atom[jat]->name) == " OXT") { // PDBv3 FIXME + if (std::string(atom[jat]->GetAtomName()) == " OXT") { // PDBv3 FIXME matched_oxt = true; } else { matched_oxt = false; @@ -2465,8 +2465,8 @@ coot::restraints_container_t::construct_non_bonded_contact_list_by_res_vec(const if (bonded_atom_indices[iat].find(jat) != bonded_atom_indices[iat].end()) { // atom j is not bonded to atom i, is it close? (i.e. within dist_crit?) - clipper::Coord_orth pt1(atom[iat]->x, atom[iat]->y, atom[iat]->z); - clipper::Coord_orth pt2(atom[jat]->x, atom[jat]->y, atom[jat]->z); + clipper::Coord_orth pt1(atom[iat]->x(), atom[iat]->y(), atom[iat]->z()); + clipper::Coord_orth pt2(atom[jat]->x(), atom[jat]->y(), atom[jat]->z()); double d = clipper::Coord_orth::length(pt1, pt2); if (d < dist_crit) { if (false) @@ -2545,14 +2545,14 @@ coot::restraints_container_t::construct_nbc_for_moving_non_moving_bonded(unsigne // know that res_1 and res_2 are in the correct order for the given // link_type link. // - mmdb::Residue *res_1 = atom[iat]->residue; - mmdb::Residue *res_2 = atom[jat]->residue; + mmdb::Residue *res_1 = atom[iat]->GetResidue(); + mmdb::Residue *res_2 = atom[jat]->GetResidue(); dictionary_residue_link_restraints_t link = geom.link(link_type); // std::cout << "link: " << link.link_id << " " << link.link_bond_restraint.size() << std::endl; if (! link.empty()) { - std::string atom_name_1 = atom[iat]->name; - std::string atom_name_2 = atom[jat]->name; + std::string atom_name_1 = atom[iat]->GetAtomName(); + std::string atom_name_2 = atom[jat]->GetAtomName(); bool add_it = true; for (unsigned int i=0; ix, atom[iat]->y, atom[iat]->z); - clipper::Coord_orth pt2(atom[jat]->x, atom[jat]->y, atom[jat]->z); + clipper::Coord_orth pt1(atom[iat]->x(), atom[iat]->y(), atom[iat]->z()); + clipper::Coord_orth pt2(atom[jat]->x(), atom[jat]->y(), atom[jat]->z()); double d = sqrt((pt1-pt2).lengthsq()); std::cout << "moving-non-moving: adding filtered non-bonded atom indices: " @@ -2621,8 +2621,8 @@ coot::restraints_container_t::filter_non_bonded_by_distance(const std::vectorx, atom_1->y, atom_1->z), // clipper::Coord_orth(atom_2->x, atom_2->y, atom_2->z)); - dist2 = (clipper::Coord_orth(atom_1->x, atom_1->y, atom_1->z) - - clipper::Coord_orth(atom_2->x, atom_2->y, atom_2->z)).lengthsq(); + dist2 = (clipper::Coord_orth(atom_1->x(), atom_1->y(), atom_1->z()) - + clipper::Coord_orth(atom_2->x(), atom_2->y(), atom_2->z())).lengthsq(); if (dist2 < dist_lim2) { // std::cout << "accepting non-bonded contact between " << atom_1->GetSeqNum() diff --git a/ideal/mods.cc b/ideal/mods.cc index 52b0dab7c4..c38ebe8b35 100644 --- a/ideal/mods.cc +++ b/ideal/mods.cc @@ -108,16 +108,16 @@ coot::restraints_container_t::mod_bond_add(const coot::chem_mod_bond &mod_bond, int index_1 = -1, index_2 = -1; for (int iat_1=0; iat_1name); + std::string pdb_atom_name_1(residue_atoms[iat_1]->GetAtomName()); // std::cout << "comparing :" << pdb_atom_name_1 << ": with :" << mod_bond.atom_id_1 // << ":" << std::endl; if (pdb_atom_name_1 == mod_bond.atom_id_1) { for (int iat_2=0; iat_2name); + std::string pdb_atom_name_2(residue_atoms[iat_2]->GetAtomName()); if (pdb_atom_name_2 == mod_bond.atom_id_2) { // check that they have the same alt conf - std::string alt_1(residue_atoms[iat_1]->altLoc); - std::string alt_2(residue_atoms[iat_2]->altLoc); + std::string alt_1(residue_atoms[iat_1]->altLoc()); + std::string alt_2(residue_atoms[iat_2]->altLoc()); if (alt_1 == "" || alt_2 == "" || alt_1 == alt_2) { residue_atoms[iat_1]->GetUDData(udd_atom_index_handle, index_1); residue_atoms[iat_2]->GetUDData(udd_atom_index_handle, index_2); @@ -147,10 +147,10 @@ coot::restraints_container_t::mod_bond_change(const coot::chem_mod_bond &mod_bon { simple_restraint &rest = restraints_vec[i]; // rest may be modified if (rest.restraint_type == coot::BOND_RESTRAINT) { - if (atom[rest.atom_index_1]->residue == residue_p) { - if (atom[rest.atom_index_2]->residue == residue_p) { - std::string name_1 = atom[rest.atom_index_1]->name; - std::string name_2 = atom[rest.atom_index_2]->name; + if (atom[rest.atom_index_1]->GetResidue() == residue_p) { + if (atom[rest.atom_index_2]->GetResidue() == residue_p) { + std::string name_1 = atom[rest.atom_index_1]->GetAtomName(); + std::string name_2 = atom[rest.atom_index_2]->GetAtomName(); if (name_1 == mod_bond.atom_id_1) { if (name_2 == mod_bond.atom_id_2) { rest.target_value = mod_bond.new_value_dist; @@ -182,10 +182,10 @@ coot::restraints_container_t::mod_bond_delete(const coot::chem_mod_bond &mod_bon for (it=restraints_vec.begin(); it!=restraints_vec.end(); it++) { if (it->restraint_type == coot::BOND_RESTRAINT) { - if (atom[it->atom_index_1]->residue == residue_p) { - if (atom[it->atom_index_2]->residue == residue_p) { - std::string name_1 = atom[it->atom_index_1]->name; - std::string name_2 = atom[it->atom_index_2]->name; + if (atom[it->atom_index_1]->GetResidue() == residue_p) { + if (atom[it->atom_index_2]->GetResidue() == residue_p) { + std::string name_1 = atom[it->atom_index_1]->GetAtomName(); + std::string name_2 = atom[it->atom_index_2]->GetAtomName(); if (name_1 == mod_bond.atom_id_1) { if (name_2 == mod_bond.atom_id_2) { if (0) @@ -228,19 +228,19 @@ coot::restraints_container_t::mod_angle_add(const coot::chem_mod_angle &mod_angl int index_1 = -1, index_2 = -1, index_3 = -1; for (int iat_1=0; iat_1name); + std::string pdb_atom_name_1(residue_atoms[iat_1]->GetAtomName()); if (pdb_atom_name_1 == mod_angle.atom_id_1) { for (int iat_2=0; iat_2name); + std::string pdb_atom_name_2(residue_atoms[iat_2]->GetAtomName()); if (pdb_atom_name_2 == mod_angle.atom_id_2) { for (int iat_3=0; iat_3name); + std::string pdb_atom_name_3(residue_atoms[iat_3]->GetAtomName()); if (pdb_atom_name_3 == mod_angle.atom_id_3) { // check that they have the same alt conf - std::string alt_1(residue_atoms[iat_1]->altLoc); - std::string alt_2(residue_atoms[iat_2]->altLoc); - std::string alt_3(residue_atoms[iat_3]->altLoc); + std::string alt_1(residue_atoms[iat_1]->altLoc()); + std::string alt_2(residue_atoms[iat_2]->altLoc()); + std::string alt_3(residue_atoms[iat_3]->altLoc()); if (((alt_1 == alt_2) && (alt_1 == alt_3)) || ((alt_1 == "" ) && (alt_2 == alt_3)) || ((alt_2 == "" ) && (alt_1 == alt_3)) || @@ -284,11 +284,11 @@ coot::restraints_container_t::mod_angle_change(const coot::chem_mod_angle &mod_a { simple_restraint &rest = restraints_vec[i]; if (rest.restraint_type == coot::ANGLE_RESTRAINT) { - if (atom[restraints_vec[i].atom_index_1]->residue == residue_p) { - if (atom[restraints_vec[i].atom_index_2]->residue == residue_p) { - std::string name_1 = atom[rest.atom_index_1]->name; - std::string name_2 = atom[rest.atom_index_2]->name; - std::string name_3 = atom[rest.atom_index_3]->name; + if (atom[restraints_vec[i].atom_index_1]->GetResidue() == residue_p) { + if (atom[restraints_vec[i].atom_index_2]->GetResidue() == residue_p) { + std::string name_1 = atom[rest.atom_index_1]->GetAtomName(); + std::string name_2 = atom[rest.atom_index_2]->GetAtomName(); + std::string name_3 = atom[rest.atom_index_3]->GetAtomName(); if (name_1 == mod_angle.atom_id_1) { if (name_2 == mod_angle.atom_id_2) { if (name_3 == mod_angle.atom_id_3) { @@ -325,11 +325,11 @@ coot::restraints_container_t::mod_angle_delete(const coot::chem_mod_angle &mod_a for (it=restraints_vec.begin(); it!=restraints_vec.end(); it++) { if (it->restraint_type == coot::ANGLE_RESTRAINT) { - if (atom[it->atom_index_1]->residue == residue_p) { - if (atom[it->atom_index_2]->residue == residue_p) { - std::string name_1 = atom[it->atom_index_1]->name; - std::string name_2 = atom[it->atom_index_2]->name; - std::string name_3 = atom[it->atom_index_3]->name; + if (atom[it->atom_index_1]->GetResidue() == residue_p) { + if (atom[it->atom_index_2]->GetResidue() == residue_p) { + std::string name_1 = atom[it->atom_index_1]->GetAtomName(); + std::string name_2 = atom[it->atom_index_2]->GetAtomName(); + std::string name_3 = atom[it->atom_index_3]->GetAtomName(); if (name_1 == mod_angle.atom_id_1) { if (name_2 == mod_angle.atom_id_2) { if (name_2 == mod_angle.atom_id_3) { @@ -376,11 +376,11 @@ coot::restraints_container_t::mod_plane_add(const coot::chem_mod_plane &mod_plan for (unsigned int i=0; iname); + std::string atom_name(residue_atoms[iat]->GetAtomName()); if (atom_name == mod_plane.atom_id_esd[i].first) { int atom_index; residue_atoms[iat]->GetUDData(udd_atom_index_handle, atom_index); - std::string altconf = residue_atoms[iat]->altLoc; + std::string altconf = residue_atoms[iat]->altLoc(); pos[altconf].push_back(atom_index); } } @@ -422,7 +422,7 @@ coot::restraints_container_t::mod_plane_delete(const coot::chem_mod_plane &mod_p // do the atoms of the mod_plane match the atoms of the restraint? for (unsigned int iat=0; iatplane_atom_index.size(); iat++) { for (unsigned int iat_mod=0; iat_modplane_atom_index[iat].first]->name; + std::string atom_name = atom[it->plane_atom_index[iat].first]->GetAtomName(); if (atom_name == mod_plane.atom_id_esd[iat_mod].first) { if (atom[it->plane_atom_index[iat].first]->GetResidue() == residue_p) { n_found++; diff --git a/ideal/ng.cc b/ideal/ng.cc index 24afa8af49..942e3a7dd4 100644 --- a/ideal/ng.cc +++ b/ideal/ng.cc @@ -257,9 +257,9 @@ coot::restraints_container_t::make_rama_plot_restraints_ng(const std::mapindex; - int index_t = residue_this_p->index; - int index_n = residue_next_p->index; + int index_p = residue_prev_p->GetIndex(); + int index_t = residue_this_p->GetIndex(); + int index_n = residue_next_p->GetIndex(); if (false) std::cout << "residues " << residue_spec_t(residue_prev_p) << " " @@ -427,12 +427,12 @@ coot::restraints_container_t::make_flanking_atoms_restraints_ng(const coot::prot std::map >::const_iterator it; for (it=fixed_neighbours_set.begin(); it!=fixed_neighbours_set.end(); it++) { mmdb::Residue *residue_p = it->first; - std::cout << "\n\n...fixed-neighbour for residue " << residue_spec_t(residue_p) << " index " << residue_p->index << std::endl; + std::cout << "\n\n...fixed-neighbour for residue " << residue_spec_t(residue_p) << " index " << residue_p->GetIndex() << std::endl; const std::set &s = it->second; std::set::const_iterator its; for (its=s.begin(); its!=s.end(); its++) { mmdb::Residue *neighb = *its; - std::cout << " neighb: " << residue_spec_t(neighb) << " " << neighb << " index " << neighb->index << std::endl; + std::cout << " neighb: " << residue_spec_t(neighb) << " " << neighb << " index " << neighb->GetIndex() << std::endl; } } std::cout << "####### done make_flanking_atoms_restraints_ng() debugging fixed_neighbours_set() " << std::endl; @@ -493,7 +493,7 @@ coot::restraints_container_t::make_flanking_atoms_restraints_ng(const coot::prot if (std::find(itm->second.begin(), itm->second.end(), neighb) != itm->second.end()) continue; - int index_delta = neighb->index - residue_p->index; + int index_delta = neighb->GetIndex() - residue_p->GetIndex(); if (index_delta == -1 || index_delta == 1) { // std::cout << " fixed neigb: " << residue_spec_t(*its) << std::endl; @@ -731,7 +731,7 @@ coot::restraints_container_t::make_non_bonded_contact_restraints_workpackage_ng( if (at_1->isTer()) continue; const std::set &n_set = vcontacts[i]; - std::string alt_conf_1(at_1->altLoc); + std::string alt_conf_1(at_1->altLoc()); // std::cout << "base atom: " << atom_spec_t(at_1) << std::endl; // std::cout << "Here with i " << i << " which has " << n_set.size() << " neighbours " << std::endl; @@ -750,7 +750,7 @@ coot::restraints_container_t::make_non_bonded_contact_restraints_workpackage_ng( continue; mmdb::Atom *at_2 = atom[j]; - std::string alt_conf_2(at_2->altLoc); + std::string alt_conf_2(at_2->altLoc()); { bool at_1_is_fixed_flag = false; @@ -782,8 +782,8 @@ coot::restraints_container_t::make_non_bonded_contact_restraints_workpackage_ng( if (res_name_2 == "PRO") second_is_pro = true; // residues are sorted and j > i if (res_name_2 == "HYP") second_is_pro = true; - std::string element_1 = at_1->element; - std::string element_2 = at_2->element; + std::string element_1 = at_1->GetElementName(); + std::string element_2 = at_2->GetElementName(); const std::string &type_1 = energy_type_for_atom[i]; const std::string &type_2 = energy_type_for_atom[j]; @@ -794,11 +794,11 @@ coot::restraints_container_t::make_non_bonded_contact_restraints_workpackage_ng( double dist_min = 3.4; - bool in_same_residue_flag = (at_1->residue == at_2->residue); + bool in_same_residue_flag = (at_1->GetResidue() == at_2->GetResidue()); bool in_same_ring_flag = true; // part of this test is not needed. - if (at_2->residue != at_1->residue) { + if (at_2->GetResidue() != at_1->GetResidue()) { in_same_ring_flag = false; in_same_residue_flag = false; } @@ -807,7 +807,7 @@ coot::restraints_container_t::make_non_bonded_contact_restraints_workpackage_ng( std::string atom_name_2(at_2->GetAtomName()); if (in_same_ring_flag) - in_same_ring_flag = is_in_same_ring(imol, at_2->residue, residue_ring_map_cache, + in_same_ring_flag = is_in_same_ring(imol, at_2->GetResidue(), residue_ring_map_cache, atom_name_1, atom_name_2, geom); // this doesn't check 1-4 over a moving->non-moving peptide link (see comment above function) @@ -833,13 +833,13 @@ coot::restraints_container_t::make_non_bonded_contact_restraints_workpackage_ng( if (atom_name_1 == " C ") if (atom_name_2 == " C ") - if (at_2->residue->index - at_1->residue->index == 1) { + if (at_2->GetResidue()->GetIndex() - at_1->GetResidue()->GetIndex() == 1) { mc_atoms_tandem = true; mc_CC_atoms_tandem = true; } if (atom_name_1 == " N ") if (atom_name_2 == " N ") - if (at_2->residue->index - at_1->residue->index == -1) + if (at_2->GetResidue()->GetIndex() - at_1->GetResidue()->GetIndex() == -1) mc_atoms_tandem = true; // down-weight CA-CA in cis-peptide bonds if (atom_name_1 == " CA ") @@ -1235,26 +1235,26 @@ coot::restraints_container_t::make_non_bonded_contact_restraints_ng(int imol, double dist_min = 3.4; - bool in_same_residue_flag = (at_1->residue == at_2->residue); + bool in_same_residue_flag = (at_1->GetResidue() == at_2->GetResidue()); bool in_same_ring_flag = true; // part of this test is not needed. - if (at_2->residue != at_1->residue) { + if (at_2->GetResidue() != at_1->GetResidue()) { in_same_ring_flag = false; in_same_residue_flag = false; } std::string atom_name_1 = at_1->GetAtomName(); std::string atom_name_2 = at_2->GetAtomName(); - std::string element_1 = at_1->element; - std::string element_2 = at_2->element; + std::string element_1 = at_1->GetElementName(); + std::string element_2 = at_2->GetElementName(); if (in_same_ring_flag) { // in_same_ring_flag = restraints_map[at_2->residue].second.in_same_ring(atom_name_1, // atom_name_2); - in_same_ring_flag = is_in_same_ring(imol, at_2->residue, + in_same_ring_flag = is_in_same_ring(imol, at_2->GetResidue(), residue_ring_map_cache, atom_name_1, atom_name_2, geom); } @@ -1275,18 +1275,18 @@ coot::restraints_container_t::make_non_bonded_contact_restraints_ng(int imol, if (atom_name_1 == " C ") if (atom_name_2 == " C ") - if (at_2->residue->index - at_1->residue->index == 1) { + if (at_2->GetResidue()->GetIndex() - at_1->GetResidue()->GetIndex() == 1) { if (false) std::cout << "DEBUG:: in make_non_bonded_contact_restraints_ng() C to C neighbs " - << at_1->residue->index << " " << at_2->residue->index + << at_1->GetResidue()->GetIndex() << " " << at_2->GetResidue()->GetIndex() << std::endl; mc_atoms_tandem = true; } if (atom_name_1 == " N ") if (atom_name_2 == " N ") - if (at_2->residue->index - at_1->residue->index == -1) { + if (at_2->GetResidue()->GetIndex() - at_1->GetResidue()->GetIndex() == -1) { mc_atoms_tandem = true; - std::cout << "-------- Here 2 " << at_1->residue->index << " " << at_2->residue->index + std::cout << "-------- Here 2 " << at_1->GetResidue()->GetIndex() << " " << at_2->GetResidue()->GetIndex() << std::endl; } } @@ -1560,8 +1560,8 @@ coot::restraints_container_t::find_peptide_link_type_ng(mmdb::Residue *res_1, std::string t1; std::string t2; - std::string residue_type_1 = res_1->name; - std::string residue_type_2 = res_2->name; + std::string residue_type_1 = res_1->GetResName(); + std::string residue_type_2 = res_2->GetResName(); for (unsigned int idr=0; idrGetAtomName()); if (at_name_1 == " C ") { // PDBv3 FIXE - std::string alt_conf_1(at_1->altLoc); + std::string alt_conf_1(at_1->altLoc()); for (int iat_2=0; iat_2GetAtomName()); if (at_name_2 == " N ") { // PDBv3 FIXE - std::string alt_conf_2(at_2->altLoc); + std::string alt_conf_2(at_2->altLoc()); if (alt_conf_1 == alt_conf_2 || alt_conf_1.empty() || alt_conf_2.empty()) { bool is_fixed_first_residue = res_1_pair.first; @@ -1741,12 +1741,12 @@ coot::restraints_container_t::try_make_phosphodiester_link_ng(const coot::protei mmdb::Atom *at_1 = residue_1_atoms[iat_1]; std::string at_name_1(at_1->GetAtomName()); if (at_name_1 == " O3'") { // PDBv3 FIXME - std::string alt_conf_1(at_1->altLoc); + std::string alt_conf_1(at_1->altLoc()); for (int iat_2=0; iat_2GetAtomName()); if (at_name_2 == " P ") { // PDBv3 FIXE - std::string alt_conf_2(at_2->altLoc); + std::string alt_conf_2(at_2->altLoc()); if (alt_conf_1 == alt_conf_2 || alt_conf_1.empty() || alt_conf_2.empty()) { if (use_distance_cut_off) { @@ -1834,9 +1834,9 @@ coot::restraints_container_t::N_and_C_are_close_ng(mmdb::Residue *res_1, if (at_1) { if (at_2) { float dd = - (at_1->x - at_2->x) * (at_1->x - at_2->x) + - (at_1->y - at_2->y) * (at_1->y - at_2->y) + - (at_1->z - at_2->z) * (at_1->z - at_2->z); + (at_1->x() - at_2->x()) * (at_1->x() - at_2->x()) + + (at_1->y() - at_2->y()) * (at_1->y() - at_2->y()) + + (at_1->z() - at_2->z()) * (at_1->z() - at_2->z()); if (dd < d_crit * d_crit) status = true; } @@ -1869,9 +1869,9 @@ coot::restraints_container_t::O3prime_and_P_are_close_ng(mmdb::Residue *res_1, if (at_1) { if (at_2) { float dd = - (at_1->x - at_2->x) * (at_1->x - at_2->x) + - (at_1->y - at_2->y) * (at_1->y - at_2->y) + - (at_1->z - at_2->z) * (at_1->z - at_2->z); + (at_1->x() - at_2->x()) * (at_1->x() - at_2->x()) + + (at_1->y() - at_2->y()) * (at_1->y() - at_2->y()) + + (at_1->z() - at_2->z()) * (at_1->z() - at_2->z()); if (dd < d_crit * d_crit) status = true; } @@ -1932,11 +1932,11 @@ coot::restraints_container_t::make_polymer_links_ng(const coot::protein_geometry if (res_name_2 == "HOH") continue; if (res_1->chain == res_2->chain) { - int serial_delta = res_2->index - res_1->index; + int serial_delta = res_2->GetIndex() - res_1->GetIndex(); // *this* is the serial_delta we should be checking - int ref_index_1 = residues_vec[i1].second->index; - int ref_index_2 = residues_vec[i2].second->index; + int ref_index_1 = residues_vec[i1].second->GetIndex(); + int ref_index_2 = residues_vec[i2].second->GetIndex(); serial_delta = ref_index_2 - ref_index_1; @@ -2217,17 +2217,17 @@ coot::restraints_container_t::make_other_types_of_link(const coot::protein_geome for (std::size_t i=0; i &n_set = vcontacts[i]; mmdb::Atom *at_1 = atom[i]; - if (strcmp(at_1->element, " H") == 0) continue; + if (strcmp(at_1->GetElementName(), " H") == 0) continue; // if (! is_fully_linked_ng(at_1->residue, residue_link_count_map)) { if (true) { std::set::const_iterator it; for (it=n_set.begin(); it!=n_set.end(); ++it) { mmdb::Atom *at_2 = atom[*it]; - if (strcmp(at_2->element, " H") == 0) continue; + if (strcmp(at_2->GetElementName(), " H") == 0) continue; - mmdb::Residue *res_1 = at_1->residue; - mmdb::Residue *res_2 = at_2->residue; + mmdb::Residue *res_1 = at_1->GetResidue(); + mmdb::Residue *res_2 = at_2->GetResidue(); std::string res_name_1(res_1->GetResName()); std::string res_name_2(res_2->GetResName()); diff --git a/ideal/pepflip.cc b/ideal/pepflip.cc index e3fe98569f..3201bc5c33 100644 --- a/ideal/pepflip.cc +++ b/ideal/pepflip.cc @@ -106,8 +106,8 @@ coot::pepflip_standard(mmdb::Manager *mol, first_res->GetAtomTable(first_residue_atoms, n_first_residue_atoms); second_res->GetAtomTable(second_residue_atoms, n_second_residue_atoms); for (int iat=0; iatname); - std::string alt_conf_atom(first_residue_atoms[iat]->altLoc); + std::string atom_name(first_residue_atoms[iat]->GetAtomName()); + std::string alt_conf_atom(first_residue_atoms[iat]->altLoc()); if (alt_conf_atom == altconf || alt_conf_atom == "") { if (atom_name == " CA " ) { ca1 = first_residue_atoms[iat]; @@ -123,8 +123,8 @@ coot::pepflip_standard(mmdb::Manager *mol, } } for (int iat=0; iatname); - std::string alt_conf_atom(second_residue_atoms[iat]->altLoc); + std::string atom_name(second_residue_atoms[iat]->GetAtomName()); + std::string alt_conf_atom(second_residue_atoms[iat]->altLoc()); if (alt_conf_atom == altconf || alt_conf_atom == "") { if (atom_name == " CA " ) { ca2 = second_residue_atoms[iat]; @@ -157,14 +157,14 @@ coot::pepflip_standard(mmdb::Manager *mol, if (dist < dist_crit) { status = 1; std::vector cas(2); - cas[0] = clipper::Coord_orth(ca1->x, ca1->y, ca1->z); - cas[1] = clipper::Coord_orth(ca2->x, ca2->y, ca2->z); + cas[0] = clipper::Coord_orth(ca1->x(), ca1->y(), ca1->z()); + cas[1] = clipper::Coord_orth(ca2->x(), ca2->y(), ca2->z()); std::vector v = flip_internal(cas, flipping_atoms); for (unsigned int i=0; ix = v[i].x(); - flipping_atoms[i]->y = v[i].y(); - flipping_atoms[i]->z = v[i].z(); + flipping_atoms[i]->x() = v[i].x(); + flipping_atoms[i]->y() = v[i].y(); + flipping_atoms[i]->z() = v[i].z(); } } } @@ -196,8 +196,8 @@ coot::pepflip_internal_to_residue(mmdb::Manager *mol, residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); - std::string atom_alt_conf(at->altLoc); + std::string atom_name(at->GetAtomName()); + std::string atom_alt_conf(at->altLoc()); // PDBv3 FIXME if (atom_alt_conf == altconf) { if (atom_name == " CA ") @@ -209,13 +209,13 @@ coot::pepflip_internal_to_residue(mmdb::Manager *mol, } } if (c_at && o_at && ca_at) { - clipper::Coord_orth p1(ca_at->x, ca_at->y, ca_at->z); - clipper::Coord_orth p2(c_at->x, c_at->y, c_at->z); - clipper::Coord_orth p3(o_at->x, o_at->y, o_at->z); + clipper::Coord_orth p1(ca_at->x(), ca_at->y(), ca_at->z()); + clipper::Coord_orth p2(c_at->x(), c_at->y(), c_at->z()); + clipper::Coord_orth p3(o_at->x(), o_at->y(), o_at->z()); clipper::Coord_orth p3_new = util::rotate_around_vector(p2-p1, p3, p1, M_PI); - o_at->x = p3_new.x(); - o_at->y = p3_new.y(); - o_at->z = p3_new.z(); + o_at->x() = p3_new.x(); + o_at->y() = p3_new.y(); + o_at->z() = p3_new.z(); status = true; } else { std::cout << "not all internal atoms found " << std::endl; @@ -243,7 +243,7 @@ coot::flip_internal(const std::vector &ca_in, cas[1] -= trans; for (unsigned int i=0;ix, atoms[i]->y, atoms[i]->z); + atoms_orth[i] = clipper::Coord_orth(atoms[i]->x(), atoms[i]->y(), atoms[i]->z()); atoms_orth[i] -= trans; } diff --git a/ideal/pull-restraint.cc b/ideal/pull-restraint.cc index 3928a3c78b..14485b43b0 100644 --- a/ideal/pull-restraint.cc +++ b/ideal/pull-restraint.cc @@ -190,9 +190,9 @@ coot::restraints_container_t::pull_restraint_displace_neighbours(mmdb::Atom *pul mmdb::Atom *at = atom[iat]; if (fixed_atom_indices.find(iat) == fixed_atom_indices.end()) { // not fixed float d_squared = - (at->x - pull_atom->x) * (at->x - pull_atom->x) + - (at->y - pull_atom->y) * (at->y - pull_atom->y) + - (at->z - pull_atom->z) * (at->z - pull_atom->z); + (at->x() - pull_atom->x()) * (at->x() - pull_atom->x()) + + (at->y() - pull_atom->y()) * (at->y() - pull_atom->y()) + + (at->z() - pull_atom->z()) * (at->z() - pull_atom->z()); if (d_squared < r_squared) { float d = sqrt(d_squared); float ff = 1.0f - d/radius; @@ -200,9 +200,9 @@ coot::restraints_container_t::pull_restraint_displace_neighbours(mmdb::Atom *pul float sf = sqrt(ff); if (use_top_hat_function) sf = 1.0; - at->x += sf * f * delta.x(); - at->y += sf * f * delta.y(); - at->z += sf * f * delta.z(); + at->x() += sf * f * delta.x(); + at->y() += sf * f * delta.y(); + at->z() += sf * f * delta.z(); } } } @@ -358,7 +358,7 @@ coot::restraints_container_t::turn_off_when_close_target_position_restraint() { if (it->restraint_type == restraint_type_t(TARGET_POS_RESTRAINT)) { if (it->is_closed) { mmdb::Atom *at = atom[it->atom_index_1]; - clipper::Coord_orth pos(at->x, at->y, at->z); + clipper::Coord_orth pos(at->x(), at->y(), at->z()); double d = sqrt((pos - it->atom_pull_target_pos).lengthsq()); if (d < close_dist) { it->close(); @@ -405,7 +405,7 @@ coot::restraints_container_t::turn_off_atom_pull_restraints_when_close_to_target } else { mmdb::Atom *at = atom[it->atom_index_1]; if (atom_spec_t(at) != dragged_atom_spec) { - clipper::Coord_orth pos(at->x, at->y, at->z); + clipper::Coord_orth pos(at->x(), at->y(), at->z()); double d = sqrt((pos - it->atom_pull_target_pos).lengthsq()); if (d < close_dist) { it->close(); diff --git a/ideal/simple-restraint.cc b/ideal/simple-restraint.cc index 449fbfdd83..897531aa67 100644 --- a/ideal/simple-restraint.cc +++ b/ideal/simple-restraint.cc @@ -236,9 +236,9 @@ coot::restraints_container_t::restraints_container_t(atom_selection_container_t initial_position_params_vec.resize(3*n_atoms); for (int i=0; ix; - initial_position_params_vec[3*i+1] = atom[i]->y; - initial_position_params_vec[3*i+2] = atom[i]->z; + initial_position_params_vec[3*i ] = atom[i]->x(); + initial_position_params_vec[3*i+1] = atom[i]->y(); + initial_position_params_vec[3*i+2] = atom[i]->z(); // std::cout << " " << i << " " << coot::atom_spec_t(atom[i]) << "\n"; } } @@ -257,7 +257,7 @@ coot::restraints_container_t::restraints_container_t(mmdb::PResidue *SelResidues int resno; for (int i=0; iseqNum; + resno = SelResidues[i]->GetSeqNum(); if (resno < istart_res_l) istart_res_l = resno; if (resno > iend_res_l) @@ -328,10 +328,10 @@ coot::residue_sorter(const std::pair &r1, if (chain_id_1 > chain_id_2) { return false; } else { - if (r1.second->index < r2.second->index) { + if (r1.second->GetIndex() < r2.second->GetIndex()) { return true; } else { - if (r1.second->index > r2.second->index) { + if (r1.second->GetIndex() > r2.second->GetIndex()) { return false; } else { if (r1.second->GetSeqNum() < r2.second->GetSeqNum()) { @@ -398,7 +398,7 @@ coot::restraints_container_t::restraints_container_t(const std::vectorindex << std::endl; + << " has index " << residues_local[i].second->GetIndex() << std::endl; residues_vec = residues_local; init_from_residue_vec(residues_local, geom, mol_in, fixed_atom_specs); @@ -521,7 +521,7 @@ coot::restraints_container_t::init_from_mol(int istart_res_in, int iend_res_in, std::cout << "DEBUG:: Selecting residues in chain \"" << chain_id << "\" gives " << n_atoms << " atoms " << std::endl; for (int iat=0; iatname << " " << atom[iat]->GetSeqNum() + std::cout << " " << iat << " " << atom[iat]->GetAtomName() << " " << atom[iat]->GetSeqNum() << " " << atom[iat]->GetChainID() << std::endl; } } @@ -643,10 +643,10 @@ coot::restraints_container_t::set_z_occ_weights() { for (int i=0; iisTer()) { - std::string element = at->element; - double z = coot::util::atomic_number(at->element, atom_list); + std::string element = at->GetElementName(); + double z = coot::util::atomic_number(at->GetElementName(), atom_list); double weight = 1.0; - double occupancy = atom[i]->occupancy; + double occupancy = atom[i]->occupancy(); if (occupancy > 1.0) occupancy = 1.0; if (do_neutron_refinement) { int formal_charge = 0; @@ -658,7 +658,7 @@ coot::restraints_container_t::set_z_occ_weights() { // std::cout << "downweighting atom " << coot::atom_spec_t(atom[i]) << std::endl; weight = 0.2; } - std::string at_name = atom[i]->name; + std::string at_name = atom[i]->GetAtomName(); if (at_name == " O ") { weight = 0.4; } @@ -666,7 +666,7 @@ coot::restraints_container_t::set_z_occ_weights() { if (z < 0.0) { std::cout << "WARNING:: init_shared_post() atom " << i << " " << atom_spec_t(atom[i]) - << " Unknown element \"" << atom[i]->element << "\"" << std::endl; + << " Unknown element \"" << atom[i]->GetElementName() << "\"" << std::endl; z = 6.0; // as for carbon } atom_z_occ_weight[i] = weight * z * occupancy; @@ -688,9 +688,9 @@ coot::restraints_container_t::init_shared_post(const std::vector &f initial_position_params_vec.resize(3*n_atoms); for (int i=0; ix; - initial_position_params_vec[3*i+1] = atom[i]->y; - initial_position_params_vec[3*i+2] = atom[i]->z; + initial_position_params_vec[3*i ] = atom[i]->x(); + initial_position_params_vec[3*i+1] = atom[i]->y(); + initial_position_params_vec[3*i+2] = atom[i]->z(); } // Set the UDD have_bond_or_angle to initally all "not". They get @@ -733,8 +733,8 @@ coot::restraints_container_t::init_shared_post(const std::vector &f if (! from_residue_vector) { // convential way for (int i=0; iresidue->seqNum >= istart_res && - atom[i]->residue->seqNum <= iend_res) { + if (atom[i]->GetResidue()->GetSeqNum() >= istart_res && + atom[i]->GetResidue()->GetSeqNum() <= iend_res) { if (! is_hydrogen(atom[i])) use_map_gradient_for_atom[i] = true; } else { @@ -744,7 +744,7 @@ coot::restraints_container_t::init_shared_post(const std::vector &f } else { // blank out the non moving atoms (i.e. flanking residues) for (int i=0; iresidue; + mmdb::Residue *res_p = atom[i]->GetResidue(); if (is_a_moving_residue_p(res_p)) { if (! is_hydrogen(atom[i]) || do_hydrogen_atom_refinement) use_map_gradient_for_atom[i] = true; @@ -770,7 +770,7 @@ coot::restraints_container_t::init_shared_post(const std::vector &f if (verbose_geometry_reporting == VERBOSE) for (int i=0; iname << " " << atom[i]->residue->seqNum << " " + std::cout << atom[i]->GetAtomName() << " " << atom[i]->GetResidue()->GetSeqNum() << " " << use_map_gradient_for_atom[i] << std::endl; } @@ -876,7 +876,7 @@ coot::restraints_container_t::init_from_residue_vec(const std::vectorname << "\" \"" << at->altLoc << "\" " + << at->GetAtomName() << "\" \"" << at->altLoc() << "\" " << at->GetSeqNum() << " \"" << at->GetInsCode() << "\" \"" << at->GetChainID() << "\"" << std::endl; } @@ -1159,7 +1159,7 @@ coot::restraints_container_t::init_from_residue_vec(const std::vectorname << " " + std::cout << " " << std::setw(3) << iat << " " << atom[iat]->GetAtomName() << " " << atom[iat]->GetSeqNum() << " " << atom[iat]->GetChainID() << " " << atom[iat]->GetResName() << " fixed: " << fixed_flag << std::endl; } @@ -1215,9 +1215,9 @@ coot::restraints_container_t::debug_atoms() const { bool is_fixed = false; if (fixed_atom_indices.find(iat) != fixed_atom_indices.end()) is_fixed = true; std::cout << std::setw(3) << iat << " " << atom_spec_t(atom[iat]) << " " - << std::right << std::setw(10) << std::fixed << std::setprecision(3) << atom[iat]->x << " " - << std::right << std::setw(10) << std::fixed << std::setprecision(3) << atom[iat]->y << " " - << std::right << std::setw(10) << std::fixed << std::setprecision(3) << atom[iat]->z + << std::right << std::setw(10) << std::fixed << std::setprecision(3) << atom[iat]->x() << " " + << std::right << std::setw(10) << std::fixed << std::setprecision(3) << atom[iat]->y() << " " + << std::right << std::setw(10) << std::fixed << std::setprecision(3) << atom[iat]->z() << " fixed: " << is_fixed << std::endl; } } @@ -1724,9 +1724,9 @@ coot::refinement_results_for_rama_t::refinement_results_for_rama_t(mmdb::Atom *a atom_spec_CA = atom_spec_t(at_3); ball_pos_x = 0; ball_pos_y = 0; ball_pos_z = 0; if (at_3) { - ball_pos_x = at_3->x + 0.5; - ball_pos_y = at_3->y; - ball_pos_z = at_3->z; + ball_pos_x = at_3->x() + 0.5; + ball_pos_y = at_3->y(); + ball_pos_z = at_3->z(); } if (at_1 && at_2 && at_3 && at_4 && at_5) { clipper::Coord_orth p2 = co(at_2); @@ -1742,9 +1742,9 @@ coot::refinement_results_for_rama_t::refinement_results_for_rama_t(mmdb::Atom *a clipper::Coord_orth p2p24_mid_point(0.5 * (p4+p2)); clipper::Coord_orth mid_point_to_CA(p3 - p2p24_mid_point); clipper::Coord_orth delta = 0.2 * mid_point_to_CA + 0.4 * v4; - ball_pos_x = delta.x() + at_3->x; - ball_pos_y = delta.y() + at_3->y; - ball_pos_z = delta.z() + at_3->z; + ball_pos_x = delta.x() + at_3->x(); + ball_pos_y = delta.y() + at_3->y(); + ball_pos_z = delta.z() + at_3->z(); } } @@ -1893,7 +1893,7 @@ coot::restraints_container_t::add_details_to_refinement_results(coot::refinement double chiral_volume_distortion_limit = 6.0; // c.f. limiit in dynamic-valiation.cc make_chiral_volume_buttons() if (dist > chiral_volume_distortion_limit) { mmdb:: Atom *at = atom[restraint.atom_index_centre]; - clipper::Coord_orth pos(at->x, at->y, at->z); + clipper::Coord_orth pos(at->x(), at->y(), at->z()); refinement_results_for_chiral_t cb(atom_spec_t(at), pos, dist); chiral_baddies.push_back(cb); } @@ -1957,7 +1957,7 @@ coot::restraints_container_t::add_details_to_refinement_results(coot::refinement // if (dd > -200.0) { // GLY have naturally lower probabilities densities, hence higher -logPr - std::string rn(atom[restraint.atom_index_3]->residue->GetResName()); + std::string rn(atom[restraint.atom_index_3]->GetResidue()->GetResName()); if (rn == "GLY") { dd -= 50.0; // utter guess } @@ -1970,7 +1970,7 @@ coot::restraints_container_t::add_details_to_refinement_results(coot::refinement // --- non-bonded contacts --- - auto atom_to_coord_orth = [] (mmdb::Atom *at) { return clipper::Coord_orth(at->x, at->y, at->z); }; + auto atom_to_coord_orth = [] (mmdb::Atom *at) { return clipper::Coord_orth(at->x(), at->y(), at->z()); }; std::map::const_iterator it; unsigned int idx = 0; @@ -2781,9 +2781,9 @@ coot::restraints_container_t::mark_OXT(const coot::protein_geometry &geom) { std::string oxt(" OXT"); for (int i=0; iname) == oxt) { + if (std::string(atom[i]->GetAtomName()) == oxt) { - mmdb::Residue *residue = atom[i]->residue; + mmdb::Residue *residue = atom[i]->GetResidue(); mmdb::Atom *res_atom = NULL; std::string res_name = residue->GetResName(); @@ -2848,7 +2848,7 @@ coot::restraints_container_t::make_non_bonded_fixed_flags(int index1, int index2 } if (! set_0) { - mmdb::Residue *res = atom[index1]->residue; + mmdb::Residue *res = atom[index1]->GetResidue(); if (std::find(non_bonded_neighbour_residues.begin(), non_bonded_neighbour_residues.end(), res) != non_bonded_neighbour_residues.end()) @@ -2856,7 +2856,7 @@ coot::restraints_container_t::make_non_bonded_fixed_flags(int index1, int index2 // then that atom of that residue is fixed } if (! set_1) { - mmdb::Residue *res = atom[index2]->residue; + mmdb::Residue *res = atom[index2]->GetResidue(); if (std::find(non_bonded_neighbour_residues.begin(), non_bonded_neighbour_residues.end(), res) != non_bonded_neighbour_residues.end()) @@ -2913,7 +2913,7 @@ coot::restraints_container_t::peptide_C_and_N_are_in_order_p(mmdb::Residue *r1, bool debug = false; if (r1->chain == r2->chain) { - int serial_delta = r2->index - r1->index; + int serial_delta = r2->GetIndex() - r1->GetIndex(); if (debug) std::cout << " serial_delta " << serial_delta << std::endl; if ((serial_delta == -1) || (serial_delta == 1)) { @@ -3004,7 +3004,7 @@ coot::restraints_container_t::peptide_C_and_N_are_close_p(mmdb::Residue *r1, mmd r2->GetAtomTable(residue_atoms_2, n_residue_atoms_2); for (int iat=0; iatname); + std::string atom_name(residue_atoms_1[iat]->GetAtomName()); if (atom_name == C_atom_name) { at_c_1 = residue_atoms_1[iat]; } @@ -3014,7 +3014,7 @@ coot::restraints_container_t::peptide_C_and_N_are_close_p(mmdb::Residue *r1, mmd } for (int iat=0; iatname); + std::string atom_name(residue_atoms_2[iat]->GetAtomName()); if (atom_name == C_atom_name) { at_c_2 = residue_atoms_2[iat]; } @@ -3024,8 +3024,8 @@ coot::restraints_container_t::peptide_C_and_N_are_close_p(mmdb::Residue *r1, mmd } if (at_c_1 && at_n_2) { - clipper::Coord_orth c1(at_c_1->x, at_c_1->y, at_c_1->z); - clipper::Coord_orth n2(at_n_2->x, at_n_2->y, at_n_2->z); + clipper::Coord_orth c1(at_c_1->x(), at_c_1->y(), at_c_1->z()); + clipper::Coord_orth n2(at_n_2->x(), at_n_2->y(), at_n_2->z()); float d = clipper::Coord_orth::length(c1, n2); // std::cout << " C1->N2 dist " << d << std::endl; if (d < dist_crit) @@ -3033,8 +3033,8 @@ coot::restraints_container_t::peptide_C_and_N_are_close_p(mmdb::Residue *r1, mmd } if (at_n_1 && at_c_2) { - clipper::Coord_orth n1(at_n_1->x, at_n_1->y, at_n_1->z); - clipper::Coord_orth c2(at_c_2->x, at_c_2->y, at_c_2->z); + clipper::Coord_orth n1(at_n_1->x(), at_n_1->y(), at_n_1->z()); + clipper::Coord_orth c2(at_c_2->x(), at_c_2->y(), at_c_2->z()); float d = clipper::Coord_orth::length(n1, c2); // std::cout << " N1->C2 dist " << d << std::endl; if (d < dist_crit) @@ -3265,7 +3265,7 @@ coot::restraints_container_t::make_non_bonded_contact_restraints(int imol, const std::cout << " non-bonded list:" << std::endl; std::cout << "--------------------------------------------------\n"; for (unsigned int i=0; iGetSeqNum() << " " << atom[i]->name << " : "; + std::cout << i << " " << atom[i]->GetSeqNum() << " " << atom[i]->GetAtomName() << " : "; for (unsigned int j=0; jGetResName(); std::map >::const_iterator it; - it = restraints_map.find(at->residue); + it = restraints_map.find(at->GetResidue()); if (it == restraints_map.end()) { // have_restraints_for() is faster? std::pair p = geom.get_monomer_restraints(res_type, imol); // p.first is false if this is not a filled dictionary - restraints_map[at->residue] = p; + restraints_map[at->GetResidue()] = p; } } @@ -3323,7 +3323,7 @@ coot::restraints_container_t::make_non_bonded_contact_restraints(int imol, const // it is not clear to me what it is now]. This needs to // be investigated/fixed. // - if (at_2->residue == at_1->residue) + if (at_2->GetResidue() == at_1->GetResidue()) if (is_hydrogen(at_1)) if (is_hydrogen(at_2)) add_it = false; @@ -3353,7 +3353,7 @@ coot::restraints_container_t::make_non_bonded_contact_restraints(int imol, const int res_no_pro = res_no_1; int res_no_other = res_no_2; if (res_no_pro == (res_no_other + 1)) { - std::string atom_name = at_1->name; + std::string atom_name = at_1->GetAtomName(); if (atom_name == " CD ") { // PDBv3 FIXME add_it = false; } @@ -3363,7 +3363,7 @@ coot::restraints_container_t::make_non_bonded_contact_restraints(int imol, const int res_no_pro = res_no_2; int res_no_other = res_no_1; if (res_no_pro == (res_no_other + 1)) { - std::string atom_name = at_2->name; + std::string atom_name = at_2->GetAtomName(); if (atom_name == " CD ") { // PDBv3 FIXME add_it = false; } @@ -3374,8 +3374,8 @@ coot::restraints_container_t::make_non_bonded_contact_restraints(int imol, const // hack to remove C1-OD1 NBC on N-linked glycosylation // if (res_name_1 == "ASN" || res_name_2 == "NAG") { - std::string atom_name_1(at_1->name); - std::string atom_name_2(at_2->name); + std::string atom_name_1(at_1->GetAtomName()); + std::string atom_name_2(at_2->GetAtomName()); if (atom_name_1 == " OD1") if (atom_name_2 == " C1 ") add_it = false; @@ -3385,8 +3385,8 @@ coot::restraints_container_t::make_non_bonded_contact_restraints(int imol, const } if (res_name_1 == "NAG" || res_name_2 == "ASN") { - std::string atom_name_1(at_1->name); - std::string atom_name_2(at_2->name); + std::string atom_name_1(at_1->GetAtomName()); + std::string atom_name_2(at_2->GetAtomName()); if (atom_name_1 == " C1 ") if (atom_name_2 == " OD1") add_it = false; @@ -3405,7 +3405,7 @@ coot::restraints_container_t::make_non_bonded_contact_restraints(int imol, const bool in_same_ring_flag = true; bool in_same_residue_flag = true; - if (at_2->residue != at_1->residue) { + if (at_2->GetResidue() != at_1->GetResidue()) { in_same_ring_flag = false; in_same_residue_flag = false; } @@ -3417,7 +3417,7 @@ coot::restraints_container_t::make_non_bonded_contact_restraints(int imol, const // in_same_ring_flag = restraints_map[at_2->residue].second.in_same_ring(atom_name_1, // atom_name_2); - in_same_ring_flag = is_in_same_ring(imol, at_2->residue, + in_same_ring_flag = is_in_same_ring(imol, at_2->GetResidue(), residue_ring_map_cache, atom_name_1, atom_name_2, geom); } @@ -3562,8 +3562,8 @@ coot::restraints_container_t::make_non_bonded_contact_restraints(int imol, const } if (false) { // debug. - clipper::Coord_orth pt1(atom[i]->x, atom[i]->y, atom[i]->z); - clipper::Coord_orth pt2(at_2->x, at_2->y, at_2->z); + clipper::Coord_orth pt1(atom[i]->x(), atom[i]->y(), atom[i]->z()); + clipper::Coord_orth pt2(at_2->x(), at_2->y(), at_2->z()); double dd = sqrt((pt1-pt2).lengthsq()); std::pair nbc_dist = geom.get_nbc_dist(type_1, type_2, @@ -3997,7 +3997,7 @@ coot::restraints_container_t::check_for_O_C_1_5_relation(mmdb::Atom *at_1, mmdb: // PDBv3 FIXME. bool match = false; - if (at_2->residue != at_1->residue) { + if (at_2->GetResidue() != at_1->GetResidue()) { // std::cout << "debug check_for_O_C_1_5_relation " << atom_spec_t(at_1) << " " << atom_spec_t(at_2) << std::endl; @@ -4391,17 +4391,17 @@ coot::restraints_container_t::add_N_terminal_residue_bonds_and_angles_to_hydroge if (atom_name == " H1 ") { int ai; at->GetUDData(udd_atom_index_handle, ai); - h1s[at->altLoc] = ai; + h1s[at->altLoc()] = ai; } if (atom_name == " H2 ") { int ai; at->GetUDData(udd_atom_index_handle, ai); - h2s[at->altLoc] = ai; + h2s[at->altLoc()] = ai; } if (atom_name == " H3 ") { int ai; at->GetUDData(udd_atom_index_handle, ai); - h3s[at->altLoc] = ai; + h3s[at->altLoc()] = ai; } } } @@ -4514,7 +4514,7 @@ coot::restraints_container_t::get_atom_index_for_restraint_using_alt_conf(const mmdb::Atom *at = res_selection[i]; std::string n(at->GetAtomName()); if (n == atom_name) { - std::string a(at->altLoc); + std::string a(at->altLoc()); if (a.empty() || a == alt_conf) { at->GetUDData(udd_atom_index_handle, idx); } @@ -4779,9 +4779,9 @@ coot::restraints_container_t::setup_gsl_vector_variables() { for (int i=0; ix); - gsl_vector_set(x, idx+1, atom[i]->y); - gsl_vector_set(x, idx+2, atom[i]->z); + gsl_vector_set(x, idx, atom[i]->x()); + gsl_vector_set(x, idx+1, atom[i]->y()); + gsl_vector_set(x, idx+2, atom[i]->z()); } } @@ -4794,7 +4794,7 @@ coot::restraints_container_t::update_atoms(gsl_vector *s) { int idx; if (false) { - std::cout << "update_atom(0): from " << atom[0]->x << " " << atom[0]->y << " " << atom[0]->z + std::cout << "update_atom(0): from " << atom[0]->x() << " " << atom[0]->y() << " " << atom[0]->z() << std::endl; double xx = gsl_vector_get(s, 0); double yy = gsl_vector_get(s, 1); @@ -4807,9 +4807,9 @@ coot::restraints_container_t::update_atoms(gsl_vector *s) { } else { for (int i=0; ix = gsl_vector_get(s,idx); - atom[i]->y = gsl_vector_get(s,idx+1); - atom[i]->z = gsl_vector_get(s,idx+2); + atom[i]->x() = gsl_vector_get(s,idx); + atom[i]->y() = gsl_vector_get(s,idx+1); + atom[i]->z() = gsl_vector_get(s,idx+2); } } } @@ -4830,9 +4830,9 @@ coot::restraints_container_t::position_OXT() { oxt_reference_atom_pos[1], oxt_reference_atom_pos[2], 1.231, angl_o, tors_o + M_PI); - atom[oxt_index]->x = oxt_pos.x(); - atom[oxt_index]->y = oxt_pos.y(); - atom[oxt_index]->z = oxt_pos.z(); + atom[oxt_index]->x() = oxt_pos.x(); + atom[oxt_index]->y() = oxt_pos.y(); + atom[oxt_index]->z() = oxt_pos.z(); } } diff --git a/ideal/simple-restraint.hh b/ideal/simple-restraint.hh index d868ce8602..df36573492 100644 --- a/ideal/simple-restraint.hh +++ b/ideal/simple-restraint.hh @@ -2192,7 +2192,7 @@ namespace coot { const gsl_vector *v) const; bool is_hydrogen(mmdb::Atom *at_p) const { - std::string ele = at_p->element; + std::string ele = at_p->GetElementName(); if ((ele == "H") || (ele == " H")) return true; else @@ -2203,7 +2203,7 @@ namespace coot { std::string get_type_energy(int imol, mmdb::Atom *at, const protein_geometry &geom) const { std::string r; if (at) { - std::string atom_name = at->name; + std::string atom_name = at->GetAtomName(); const char *rn = at->GetResName(); if (rn) { std::string residue_name = rn; @@ -2293,9 +2293,9 @@ namespace coot { dist_crit_for_bonded_pairs = 3.0; for (int i=0; ix; - initial_position_params_vec[3*i+1] = asc_in.atom_selection[i]->y; - initial_position_params_vec[3*i+2] = asc_in.atom_selection[i]->z; + initial_position_params_vec[3*i ] = asc_in.atom_selection[i]->x(); + initial_position_params_vec[3*i+1] = asc_in.atom_selection[i]->y(); + initial_position_params_vec[3*i+2] = asc_in.atom_selection[i]->z(); } } diff --git a/ideal/torsion-bonds.cc b/ideal/torsion-bonds.cc index c119e02f26..71015fc58f 100644 --- a/ideal/torsion-bonds.cc +++ b/ideal/torsion-bonds.cc @@ -53,7 +53,7 @@ coot::torsionable_bonds(int imol, mmdb::Manager *mol, mmdb::PPAtom atom_selectio std::map > atoms_in_residue; // fill residues and atoms_in_residue for (int i=0; iresidue; + mmdb::Residue *r = atom_selection[i]->GetResidue(); if (std::find(residues.begin(), residues.end(), r) == residues.end()) residues.push_back(r); atoms_in_residue[r].push_back(i); @@ -209,7 +209,7 @@ coot::torsionable_quads(int imol, mmdb::Manager *mol, mmdb::PPAtom atom_selectio std::vector quads; std::vector residues; for (int i=0; iresidue; + mmdb::Residue *r = atom_selection[i]->GetResidue(); if (std::find(residues.begin(), residues.end(), r) == residues.end()) residues.push_back(r); } @@ -397,12 +397,12 @@ coot::torsionable_link_quads(int imol, // What are the neightbours of link_atom_1 (and link_atom_2)? // Try to find a non-hydrogen atom to which it is bonded. bool H_flag = false; - std::string atom_name_1 = link_atom_1->name; - std::string atom_name_2 = link_atom_2->name; + std::string atom_name_1 = link_atom_1->GetAtomName(); + std::string atom_name_2 = link_atom_2->GetAtomName(); std::vector n1; std::vector n2; - n1 = res_restraints[link_atom_1->residue].neighbours(atom_name_1, H_flag); - n2 = res_restraints[link_atom_2->residue].neighbours(atom_name_2, H_flag); + n1 = res_restraints[link_atom_1->GetResidue()].neighbours(atom_name_1, H_flag); + n2 = res_restraints[link_atom_2->GetResidue()].neighbours(atom_name_2, H_flag); if (n1.size() && n2.size()) { std::string neigbhour_1_name = n1[0]; std::string neigbhour_2_name = n2[0]; @@ -418,7 +418,7 @@ coot::torsionable_link_quads(int imol, // also we need psi, CB, CG, ND2, C1 (of NAG) // std::vector n3; - n3 = res_restraints[link_atom_2->residue].neighbours(atom_name_2, H_flag); + n3 = res_restraints[link_atom_2->GetResidue()].neighbours(atom_name_2, H_flag); if (n3.size()) { mmdb::Atom *n_at_3 = bpc[i].res_2->GetAtom(n3[0].c_str()); if (n_at_3) { @@ -487,7 +487,7 @@ coot::multi_residue_torsion_fit_map(int imol, mol->GetSelIndex(selhnd, atom_selection, n_selected_atoms); std::vector > atoms(n_selected_atoms); // for density fitting for (int iat=0; iatelement, atom_numbers); + int atomic_number = util::atomic_number(atom_selection[iat]->GetElementName(), atom_numbers); float z = atomic_number; if (atomic_number == -1) z = 6.0f; @@ -654,8 +654,8 @@ coot::multi_residue_torsion_fit_map(int imol, int n_atoms = residue_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - at->tempFactor = this_score * 0.4; - at->tempFactor = self_clash_score; + at->tempFactor() = this_score * 0.4; + at->tempFactor() = self_clash_score; } } } @@ -759,19 +759,19 @@ coot::get_self_clash_score(mmdb::Manager *mol, if (pscontact[i].id1 < pscontact[i].id2) { mmdb::Atom *at_1 = atom_selection[pscontact[i].id1]; mmdb::Atom *at_2 = atom_selection[pscontact[i].id2]; - if (at_1->residue != at_2->residue) { - std::string e1 = at_1->element; - std::string e2 = at_2->element; + if (at_1->GetResidue() != at_2->GetResidue()) { + std::string e1 = at_1->GetElementName(); + std::string e2 = at_2->GetElementName(); if ((e1 != " H") && (e2 != " H")) { // PDB vs 3 FIXME // ignore bumps to O5 (e.g. O4(prev)-O5(new)) on newly added residue - std::string atom_name_2 = at_2->name; + std::string atom_name_2 = at_2->GetAtomName(); if (atom_name_2 != " O5 ") { double d_sqd = - (at_1->x-at_2->x) * (at_1->x-at_2->x) + - (at_1->y-at_2->y) * (at_1->y-at_2->y) + - (at_1->z-at_2->z) * (at_1->z-at_2->z); + (at_1->x()-at_2->x()) * (at_1->x()-at_2->x()) + + (at_1->y()-at_2->y()) * (at_1->y()-at_2->y()) + + (at_1->z()-at_2->z()) * (at_1->z()-at_2->z()); // are they either in a bond, angle or torsion of any of quads? // diff --git a/ideal/trans-peptide.cc b/ideal/trans-peptide.cc index 1b00d4b2a5..3f07708cb4 100644 --- a/ideal/trans-peptide.cc +++ b/ideal/trans-peptide.cc @@ -70,19 +70,19 @@ coot::restraints_container_t::add_link_trans_peptide(mmdb::Residue *first, fixed_flags[3] = is_fixed_second; for (int ifat=0; ifatname); + std::string pdb_atom_name_1(atom_1_sel[ifat]->GetAtomName()); if (pdb_atom_name_1 == " CA ") { for (int isat=0; isatname); + std::string pdb_atom_name_2(atom_2_sel[isat]->GetAtomName()); if (pdb_atom_name_2 == " C ") { for (int itat=0; itatname); + std::string pdb_atom_name_3(atom_3_sel[itat]->GetAtomName()); if (pdb_atom_name_3 == " N ") { for (int iffat=0; iffatname); + std::string pdb_atom_name_4(atom_4_sel[iffat]->GetAtomName()); if (pdb_atom_name_4 == " CA ") { @@ -94,13 +94,13 @@ coot::restraints_container_t::add_link_trans_peptide(mmdb::Residue *first, if (false) std::cout << "trans-peptide restraint.... " << " from atoms \n " - << atom_1_sel[ifat]->name << " " + << atom_1_sel[ifat]->GetAtomName() << " " << atom_1_sel[ifat]->GetSeqNum() << "\n " - << atom_2_sel[isat]->name << " " + << atom_2_sel[isat]->GetAtomName() << " " << atom_2_sel[isat]->GetSeqNum() << "\n " - << atom_3_sel[itat]->name << " " + << atom_3_sel[itat]->GetAtomName() << " " << atom_3_sel[itat]->GetSeqNum() << "\n " - << atom_4_sel[iffat]->name << " " + << atom_4_sel[iffat]->GetAtomName() << " " << atom_4_sel[iffat]->GetSeqNum() << "\n"; // if the angle is currently trans, the we should add a @@ -388,10 +388,10 @@ coot::restraints_container_t::add_trans_peptide_restraint(mmdb::Residue *first, for (unsigned int i=0; i<=n_rest; i++) { simple_restraint &restraint = restraints_vec[i]; if (restraint.restraint_type == coot::TRANS_PEPTIDE_RESTRAINT) { - mmdb::Residue *r_11 = atom[restraint.atom_index_1]->residue; - mmdb::Residue *r_12 = atom[restraint.atom_index_2]->residue; - mmdb::Residue *r_21 = atom[restraint.atom_index_3]->residue; - mmdb::Residue *r_22 = atom[restraint.atom_index_4]->residue; + mmdb::Residue *r_11 = atom[restraint.atom_index_1]->GetResidue(); + mmdb::Residue *r_12 = atom[restraint.atom_index_2]->GetResidue(); + mmdb::Residue *r_21 = atom[restraint.atom_index_3]->GetResidue(); + mmdb::Residue *r_22 = atom[restraint.atom_index_4]->GetResidue(); if (r_11 == first) { if (r_12 == first) { if (r_21 == second) { @@ -422,10 +422,10 @@ coot::restraints_container_t::remove_trans_peptide_restraint(mmdb::Residue *firs for (unsigned int i=0; i<=n_rest; i++) { simple_restraint &restraint = restraints_vec[i]; if (restraint.restraint_type == coot::TRANS_PEPTIDE_RESTRAINT) { - mmdb::Residue *r_11 = atom[restraint.atom_index_1]->residue; - mmdb::Residue *r_12 = atom[restraint.atom_index_2]->residue; - mmdb::Residue *r_21 = atom[restraint.atom_index_3]->residue; - mmdb::Residue *r_22 = atom[restraint.atom_index_4]->residue; + mmdb::Residue *r_11 = atom[restraint.atom_index_1]->GetResidue(); + mmdb::Residue *r_12 = atom[restraint.atom_index_2]->GetResidue(); + mmdb::Residue *r_21 = atom[restraint.atom_index_3]->GetResidue(); + mmdb::Residue *r_22 = atom[restraint.atom_index_4]->GetResidue(); if (r_11 == first) { if (r_12 == first) { if (r_21 == second) { diff --git a/lidia-core/bond-record-container-t.hh b/lidia-core/bond-record-container-t.hh index c41b6b7b01..64e64c9ff3 100644 --- a/lidia-core/bond-record-container-t.hh +++ b/lidia-core/bond-record-container-t.hh @@ -99,7 +99,7 @@ namespace cod { bool db_add_level_4_types(sqlite3 *db); #endif // USE_SQLITE3 - clipper::Coord_orth co(mmdb::Atom *at) const { return clipper::Coord_orth(at->x, at->y, at->z); } + clipper::Coord_orth co(mmdb::Atom *at) const { return clipper::Coord_orth(at->x(), at->y(), at->z()); } public: bond_record_container_t() {} diff --git a/lidia-core/chemical-feature-clusters.hh b/lidia-core/chemical-feature-clusters.hh index fb42cc947b..01b4d0b065 100644 --- a/lidia-core/chemical-feature-clusters.hh +++ b/lidia-core/chemical-feature-clusters.hh @@ -111,7 +111,7 @@ namespace coot { unsigned int water_spec_idx; mmdb::Atom *atom_p; clipper::Coord_orth pos; - residue_spec_t residue_spec() const { return residue_spec_t(atom_p->residue) ; } + residue_spec_t residue_spec() const { return residue_spec_t(atom_p->GetResidue()) ; } }; private: diff --git a/lidia-core/get-residue.cc b/lidia-core/get-residue.cc index 82402fe98e..e28c8add29 100644 --- a/lidia-core/get-residue.cc +++ b/lidia-core/get-residue.cc @@ -68,5 +68,5 @@ coot::lidia_utils::get_residue(const coot::residue_spec_t &res_spec, mmdb::Manag clipper::Coord_orth coot::lidia_utils::co(mmdb::Atom *at) { - return clipper::Coord_orth(at->x, at->y, at->z); + return clipper::Coord_orth(at->x(), at->y(), at->z()); } diff --git a/lidia-core/lbg-molfile.cc b/lidia-core/lbg-molfile.cc index ff0b8756d7..3d4e70a3c5 100644 --- a/lidia-core/lbg-molfile.cc +++ b/lidia-core/lbg-molfile.cc @@ -290,12 +290,12 @@ lig_build::molfile_molecule_t::molfile_molecule_t(mmdb::Residue *residue_p, atoms.push_back(blank_atom); // blank atom for 0-index. // make the atoms for (int iat=0; iatx, - residue_atoms[iat]->y, - residue_atoms[iat]->z); + clipper::Coord_orth pos(residue_atoms[iat]->x(), + residue_atoms[iat]->y(), + residue_atoms[iat]->z()); molfile_atom_t atom(pos, - residue_atoms[iat]->element, - residue_atoms[iat]->name); + residue_atoms[iat]->GetElementName(), + residue_atoms[iat]->GetAtomName()); atoms.push_back(atom); } @@ -305,7 +305,7 @@ lig_build::molfile_molecule_t::molfile_molecule_t(mmdb::Residue *residue_p, std::map >::const_iterator it_2_atom_map; std::map atom_index_map; for (int iat=0; iatname].push_back(residue_atoms[iat]); + atom_map[residue_atoms[iat]->GetAtomName()].push_back(residue_atoms[iat]); atom_index_map[residue_atoms[iat]] = iat; } @@ -321,10 +321,10 @@ lig_build::molfile_molecule_t::molfile_molecule_t(mmdb::Residue *residue_p, const std::vector &v_1 = it_1_atom_map->second; const std::vector &v_2 = it_2_atom_map->second; for (unsigned int iat_1=0; iat_1altLoc; + std::string alt_conf_1 = v_1[iat_1]->altLoc(); if (alt_conf_1 == "") { for (unsigned int iat_2=0; iat_2altLoc; + std::string alt_conf_2 = v_2[iat_2]->altLoc(); if (alt_conf_2 == "") { // OK, so we have a bond, these are indices diff --git a/lidia-core/rdkit-interface.cc b/lidia-core/rdkit-interface.cc index 77d0f608bd..4daa8f52ac 100644 --- a/lidia-core/rdkit-interface.cc +++ b/lidia-core/rdkit-interface.cc @@ -99,7 +99,7 @@ coot::rdkit_mol(mmdb::Residue *residue_p, for (int iat=0; iatisTer()) { - std::string alt_conf = at->altLoc; + std::string alt_conf = at->altLoc(); if (std::find(v.begin(), v.end(), alt_conf) == v.end()) { v.push_back(alt_conf); } @@ -160,8 +160,8 @@ coot::rdkit_mol(mmdb::Residue *residue_p, for (int iat_1=0; iat_1Ter) { - std::string atom_name_1(at_1->name); - std::string atom_alt_conf(at_1->altLoc); + std::string atom_name_1(at_1->GetAtomName()); + std::string atom_alt_conf(at_1->altLoc()); if (debug) std::cout << "rdkit_mol() handling atom " << iat_1 << " of " << n_residue_atoms << " with mmdb::Residue atom name " << atom_name_1 @@ -174,7 +174,7 @@ coot::rdkit_mol(mmdb::Residue *residue_p, // atoms of the residue? for (int iat_2=0; iat_2name; + std::string atom_name_2 = at_2->GetAtomName(); if (atom_name_2 == restraints.bond_restraint[ib].atom_id_2_4c()) { found_a_bonded_atom = true; break; @@ -186,7 +186,7 @@ coot::rdkit_mol(mmdb::Residue *residue_p, // atoms of the residue? for (int iat_2=0; iat_2name; + std::string atom_name_2 = at_2->GetAtomName(); if (atom_name_2 == restraints.bond_restraint[ib].atom_id_1_4c()) { found_a_bonded_atom = true; break; @@ -236,7 +236,7 @@ coot::rdkit_mol(mmdb::Residue *residue_p, for (unsigned int iat=0; iatname); + std::string atom_name(at->GetAtomName()); if (debug) std::cout << " handling atom " << iat << " of " << n_residue_atoms << " bonded_atoms " << atom_name << " "; @@ -251,7 +251,7 @@ coot::rdkit_mol(mmdb::Residue *residue_p, RDKit::Atom *rdkit_at = new RDKit::Atom; try { std::string ele_capped = - coot::util::capitalise(coot::util::remove_leading_spaces(at->element)); + coot::util::capitalise(coot::util::remove_leading_spaces(at->GetElementName())); int atomic_number = tbl->getAtomicNumber(ele_capped); rdkit_at->setAtomicNum(atomic_number); // rdkit_at->setMass(tbl->getAtomicWeight(atomic_number)); @@ -268,7 +268,7 @@ coot::rdkit_mol(mmdb::Residue *residue_p, // set the valence from they type energy. Abstract? // - std::string type_energy = restraints.type_energy(at->name); + std::string type_energy = restraints.type_energy(at->GetAtomName()); if (type_energy != "") { if (type_energy == "NT") { bool charge_it = true; @@ -892,14 +892,14 @@ coot::rdkit_mol(mmdb::Residue *residue_p, // atom with a particular atom name). // for (int iat=0; iatname); - std::string atom_alt_conf(residue_atoms[iat]->altLoc); + std::string atom_name(residue_atoms[iat]->GetAtomName()); + std::string atom_alt_conf(residue_atoms[iat]->altLoc()); if (true) { // was alt-conf test std::map::const_iterator it = atom_index.find(atom_name); if (it != atom_index.end()) { - RDGeom::Point3D pos(residue_atoms[iat]->x, - residue_atoms[iat]->y, - residue_atoms[iat]->z); + RDGeom::Point3D pos(residue_atoms[iat]->x(), + residue_atoms[iat]->y(), + residue_atoms[iat]->z()); conf->setAtomPos(it->second, pos); if (debug) std::cout << "in construction of rdkit mol: making a conformer atom " @@ -979,7 +979,7 @@ coot::set_atom_chirality(RDKit::Atom *rdkit_at, // bool done_chiral = false; - std::string atom_name = at->name; + std::string atom_name = at->GetAtomName(); for (unsigned int ichi=0; ichiGetAtomTable(residue_atoms, n_residue_atoms); - std::string atom_name = atom_p->name; + std::string atom_name = atom_p->GetAtomName(); bool debug = false; // To make RDKit/SMILES chiral tags, we consider the order of the 3 @@ -1567,7 +1567,7 @@ coot::get_chiral_tag(mmdb::Residue *residue_p, bool atom_orders_match = false; for (int iat=0; iatname; + std::string atom_name_local = residue_atoms[iat]->GetAtomName(); if (atom_name_local == chiral_restraint.atom_id_1_4c()) { ni[1] = iat; n_neigbours_found++; @@ -1662,7 +1662,7 @@ coot::get_chiral_tag_v2(mmdb::Residue *residue_p, mmdb::PPAtom residue_atoms = 0; int n_residue_atoms; residue_p->GetAtomTable(residue_atoms, n_residue_atoms); - std::string atom_name = atom_p->name; + std::string atom_name = atom_p->GetAtomName(); std::cout << "Called get_chiral_tag_v2() whti atom name " << atom_name << std::endl; @@ -1680,7 +1680,7 @@ coot::get_chiral_tag_v2(mmdb::Residue *residue_p, mmdb::Atom *at = residue_atoms[iat]; if (! at->isTer()) { mmdb::Atom *chiral_atom = 0; - std::string atom_name_local(at->name); + std::string atom_name_local(at->GetAtomName()); if (atom_name_local == cr.atom_id_c_4c()) { chiral_atom = at; } @@ -1709,7 +1709,7 @@ coot::get_chiral_tag_v2(mmdb::Residue *residue_p, if (! other_atom.empty()) { for (int iat=0; iatname); + std::string atom_name_local(at->GetAtomName()); if (0) std::cout << iat << " comparing :" << atom_name_local << ": :" << other_atom << ":" << std::endl; @@ -2146,7 +2146,7 @@ coot::make_residue(const RDKit::ROMol &rdkm, int iconf, const std::string &res_n // if (mol.atoms.size()) { residue_p = new mmdb::Residue; - residue_p->seqNum = 1; + residue_p->GetSeqNum() = 1; residue_p->SetResName(res_name.c_str()); mmdb::Chain *chain_p = new mmdb::Chain; chain_p->SetChainID(""); @@ -2405,9 +2405,9 @@ coot::add_hydrogens_with_rdkit(mmdb::Residue *residue_p, residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatisTer()) { - std::string ele = residue_atoms[iat]->element; + std::string ele = residue_atoms[iat]->GetElementName(); if (ele == " H") - existing_H_names.push_back(residue_atoms[iat]->name); + existing_H_names.push_back(residue_atoms[iat]->GetAtomName()); } } @@ -2476,9 +2476,9 @@ coot::add_hydrogens_with_rdkit(mmdb::Residue *residue_p, if (res_atom) { std::cout << "setting heavy atom " << name << " to " << r_pos << std::endl; - res_atom->x = r_pos.x; - res_atom->y = r_pos.y; - res_atom->z = r_pos.z; + res_atom->x() = r_pos.x; + res_atom->y() = r_pos.y; + res_atom->z() = r_pos.z; } } @@ -2511,7 +2511,7 @@ coot::add_hydrogens_with_rdkit(mmdb::Residue *residue_p, at->SetCoordinates(r_pos.x, r_pos.y, r_pos.z, 1.0, 30.0); at->Het = 1; if (alt_conf != "") { - strncpy(at->altLoc, alt_conf.c_str(), alt_conf.length()+1); + strncpy(at->altLoc(), alt_conf.c_str(), alt_conf.length()+1); } residue_p->AddAtom(at); r = 1; @@ -3697,7 +3697,7 @@ void coot::update_coords(RDKit::RWMol *mol_p, int iconf, mmdb::Residue *residue_ residue_p->GetAtomTable(residue_atoms, n_atoms); RDKit::Conformer &conf = mol_p->getConformer(iconf); for (int iat=0; iatname); + std::string residue_atom_name(residue_atoms[iat]->GetAtomName()); mmdb::Atom *r_at = residue_atoms[iat]; for (int jat=0; jatgetProp("name", rdkit_atom_name); if (rdkit_atom_name == residue_atom_name) { - RDGeom::Point3D r_pos(r_at->x, r_at->y, r_at->z); + RDGeom::Point3D r_pos(r_at->x(), r_at->y(), r_at->z()); conf.setAtomPos(jat, r_pos); } } diff --git a/ligand/backrub-rotamer.cc b/ligand/backrub-rotamer.cc index b4223665b9..3fc3579747 100644 --- a/ligand/backrub-rotamer.cc +++ b/ligand/backrub-rotamer.cc @@ -208,9 +208,9 @@ coot::backrub::rotamer_residue_centre() const { orig_this_residue->GetAtomTable(residue_atoms, n_residue_atoms); float sum_x=0, sum_y=0, sum_z=0; for (int iat=0; iatx; - sum_y += residue_atoms[iat]->y; - sum_z += residue_atoms[iat]->z; + sum_x += residue_atoms[iat]->x(); + sum_y += residue_atoms[iat]->y(); + sum_z += residue_atoms[iat]->z(); } if (n_residue_atoms > 0) { float inv = 1.0/float(n_residue_atoms); @@ -231,9 +231,9 @@ coot::backrub::residue_radius(const clipper::Coord_orth &rc) { orig_this_residue->GetAtomTable(residue_atoms, n_residue_atoms); float longest_length = 0.0; for (int iat=0; iatx - rc.x(), - residue_atoms[iat]->y - rc.y(), - residue_atoms[iat]->z - rc.z()); + clipper::Coord_orth pt(residue_atoms[iat]->x() - rc.x(), + residue_atoms[iat]->y() - rc.y(), + residue_atoms[iat]->z() - rc.z()); float this_length_sq = pt.lengthsq(); if (this_length_sq > longest_length) { longest_length = this_length_sq; @@ -303,14 +303,14 @@ coot::backrub::setup_this_and_prev_next_ca_positions() { orig_this_residue->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); - std::string atom_alt_conf(residue_atoms[iat]->altLoc); + std::string atom_name(residue_atoms[iat]->GetAtomName()); + std::string atom_alt_conf(residue_atoms[iat]->altLoc()); if (atom_name == " CA " ) { if (atom_alt_conf == alt_conf) { found = 1; - ca_this = clipper::Coord_orth(residue_atoms[iat]->x, - residue_atoms[iat]->y, - residue_atoms[iat]->z); + ca_this = clipper::Coord_orth(residue_atoms[iat]->x(), + residue_atoms[iat]->y(), + residue_atoms[iat]->z()); } } } @@ -324,14 +324,14 @@ coot::backrub::setup_this_and_prev_next_ca_positions() { orig_prev_residue->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); - std::string atom_alt_conf(residue_atoms[iat]->altLoc); + std::string atom_name(residue_atoms[iat]->GetAtomName()); + std::string atom_alt_conf(residue_atoms[iat]->altLoc()); if (atom_name == " CA " ) { if (atom_alt_conf == alt_conf) { found = 1; - ca_prev = clipper::Coord_orth(residue_atoms[iat]->x, - residue_atoms[iat]->y, - residue_atoms[iat]->z); + ca_prev = clipper::Coord_orth(residue_atoms[iat]->x(), + residue_atoms[iat]->y(), + residue_atoms[iat]->z()); } } } @@ -347,14 +347,14 @@ coot::backrub::setup_this_and_prev_next_ca_positions() { residue_atoms = 0; orig_next_residue->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); - std::string atom_alt_conf(residue_atoms[iat]->altLoc); + std::string atom_name(residue_atoms[iat]->GetAtomName()); + std::string atom_alt_conf(residue_atoms[iat]->altLoc()); if (atom_name == " CA " ) { if (atom_alt_conf == alt_conf) { found = 1; - ca_next = clipper::Coord_orth(residue_atoms[iat]->x, - residue_atoms[iat]->y, - residue_atoms[iat]->z); + ca_next = clipper::Coord_orth(residue_atoms[iat]->x(), + residue_atoms[iat]->y(), + residue_atoms[iat]->z()); } } } @@ -419,12 +419,12 @@ coot::backrub::sample_individual_peptide(mmdb::Residue *r, double rotation_angle residue_front->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); - std::string atom_alt_conf(residue_atoms[iat]->altLoc); + std::string atom_name(residue_atoms[iat]->GetAtomName()); + std::string atom_alt_conf(residue_atoms[iat]->altLoc()); if (atom_name == " O " ) { - O_pos = clipper::Coord_orth(residue_atoms[iat]->x, - residue_atoms[iat]->y, - residue_atoms[iat]->z); + O_pos = clipper::Coord_orth(residue_atoms[iat]->x(), + residue_atoms[iat]->y(), + residue_atoms[iat]->z()); found_O_pos = 1; } } @@ -617,9 +617,9 @@ coot::get_clash_score(const coot::minimol::molecule &a_rotamer, float badness; for (int i=0; ix, - asc.atom_selection[i]->y, - asc.atom_selection[i]->z); + clipper::Coord_orth atom_sel_atom(asc.atom_selection[i]->x(), + asc.atom_selection[i]->y(), + asc.atom_selection[i]->z()); d = clipper::Coord_orth::length(atom_sel_atom, mean_residue_pos); if (d < (max_dev_residue_pos + dist_crit)) { for (unsigned int ifrag=0; ifragx, - atom_selection[i]->y, - atom_selection[i]->z); + clipper::Coord_orth atom_sel_atom_pos(atom_selection[i]->x(), + atom_selection[i]->y(), + atom_selection[i]->z()); int atom_sel_resno = atom_selection[i]->GetSeqNum(); std::string atom_sel_atom_chain(atom_selection[i]->GetChainID()); - std::string atom_sel_ele = atom_selection[i]->element; + std::string atom_sel_ele = atom_selection[i]->GetElementName(); bool count_it = 1; if (chain_id == atom_sel_atom_chain) { if (atom_sel_resno==resno_1 || atom_sel_resno==resno_2 || atom_sel_resno==resno_3) { @@ -783,12 +783,12 @@ coot::backrub_molecule(mmdb::Manager *mol, const clipper::Xmap *xmap_p, c if (false) std::cout << "--------------- replacing coords for atom " << atom_spec_t(at) << " " - << at_mol->x << " " << at_mol->y << " " << at_mol->z << " " - << at->x << " " << at->y << " " << at->z << " " + << at_mol->x() << " " << at_mol->y() << " " << at_mol->z() << " " + << at->x() << " " << at->y() << " " << at->z() << " " << std::endl; - at_mol->x = at->x; - at_mol->y = at->y; - at_mol->z = at->z; + at_mol->x() = at->x(); + at_mol->y() = at->y(); + at_mol->z() = at->z(); } } } @@ -802,7 +802,7 @@ coot::backrub_molecule(mmdb::Manager *mol, const clipper::Xmap *xmap_p, c for (const auto &baddie_spec : baddie_waters) { mmdb::Atom *at = util::get_atom(baddie_spec, mol); if (at) { - mmdb::Residue *residue = at->residue; + mmdb::Residue *residue = at->GetResidue(); delete at; residue->TrimAtomTable(); } diff --git a/ligand/base-pairing.cc b/ligand/base-pairing.cc index 643c29da08..3d86bfa9ea 100644 --- a/ligand/base-pairing.cc +++ b/ligand/base-pairing.cc @@ -243,22 +243,22 @@ coot::base_pair_match_matix(mmdb::Residue *res_ref, mmdb::Residue *res_mov) { mmdb::Atom *at_ref = NULL; mmdb::Atom *at_mov = NULL; for (int iref=0; irefname; + std::string ref_atom_name = ref_atoms[iref]->GetAtomName(); if (ref_atom_name == base_atom_names[i]) { at_ref = ref_atoms[iref]; break; } } for (int imov=0; imovname; + std::string mov_atom_name = mov_atoms[imov]->GetAtomName(); if (mov_atom_name == base_atom_names[i]) { at_mov = mov_atoms[imov]; break; } } if (at_ref && at_mov) { - ref_pts.push_back(clipper::Coord_orth(at_ref->x, at_ref->y, at_ref->z)); - mov_pts.push_back(clipper::Coord_orth(at_mov->x, at_mov->y, at_mov->z)); + ref_pts.push_back(clipper::Coord_orth(at_ref->x(), at_ref->y(), at_ref->z())); + mov_pts.push_back(clipper::Coord_orth(at_mov->x(), at_mov->y(), at_mov->z())); } } diff --git a/ligand/chi-angles.cc b/ligand/chi-angles.cc index 251e0c45ee..93ffcdee89 100644 --- a/ligand/chi-angles.cc +++ b/ligand/chi-angles.cc @@ -456,15 +456,15 @@ coot::chi_angles::change_by(int ichi, double diff, coot::protein_geometry* geom_ mmdb::Atom *cd = 0; if (nResidueAtoms > 2) { for (int i=0; iname) == " N ") + if (std::string(residue_atoms[i]->GetAtomName()) == " N ") n = residue_atoms[i]; - if (std::string(residue_atoms[i]->name) == " CA ") + if (std::string(residue_atoms[i]->GetAtomName()) == " CA ") ca = residue_atoms[i]; - if (std::string(residue_atoms[i]->name) == " CB ") + if (std::string(residue_atoms[i]->GetAtomName()) == " CB ") cb = residue_atoms[i]; - if (std::string(residue_atoms[i]->name) == " CG ") + if (std::string(residue_atoms[i]->GetAtomName()) == " CG ") cg = residue_atoms[i]; - if (std::string(residue_atoms[i]->name) == " CD ") + if (std::string(residue_atoms[i]->GetAtomName()) == " CD ") cd = residue_atoms[i]; } @@ -478,11 +478,11 @@ coot::chi_angles::change_by(int ichi, double diff, coot::protein_geometry* geom_ ordered_residue_atoms[4] = cd; int atom_count = 5; for (int i=0; iname) == " N " || - std::string(residue_atoms[i]->name) == " CA " || - std::string(residue_atoms[i]->name) == " CB " || - std::string(residue_atoms[i]->name) == " CG " || - std::string(residue_atoms[i]->name) == " CD " ) { + if (std::string(residue_atoms[i]->GetAtomName()) == " N " || + std::string(residue_atoms[i]->GetAtomName()) == " CA " || + std::string(residue_atoms[i]->GetAtomName()) == " CB " || + std::string(residue_atoms[i]->GetAtomName()) == " CG " || + std::string(residue_atoms[i]->GetAtomName()) == " CD " ) { } else { ordered_residue_atoms[atom_count] = residue_atoms[i]; atom_count++; @@ -661,14 +661,14 @@ coot::chi_angles::change_by(int imol, mmdb::PPAtom residue_atoms; int nResidueAtoms; residue->GetAtomTable(residue_atoms, nResidueAtoms); - std::string residue_name = residue->name; + std::string residue_name = residue->GetResName(); // filter out CONST torsions when making atom_name_pairs std::vector atom_name_pairs = get_torsion_bonds_atom_pairs(residue_name, imol, pg_p, include_hydrogen_torsions_flag); if (atom_name_pairs.size() == 0) { std::cout << " Sorry, can't find atom rotatable bonds for residue type "; - std::cout << residue->name << "\n"; + std::cout << residue->GetResName() << "\n"; } else { if (nResidueAtoms == 0) { std::cout << " something broken in atom residue selection in "; @@ -704,9 +704,9 @@ coot::chi_angles::change_by_internal(int ichi, // std::vector< ::Cartesian > coords; for(int i=0; ix, - residue_atoms_in[i]->y, - residue_atoms_in[i]->z); + ::Cartesian c(residue_atoms_in[i]->x(), + residue_atoms_in[i]->y(), + residue_atoms_in[i]->z()); coords.push_back(c); } mmdb::PPAtom residue_atoms = residue_atoms_in; @@ -745,7 +745,7 @@ coot::chi_angles::change_by_internal(int ichi, // atom spec to find // the base atom for(int i=0; iname) { + if (tree_base_atom.atom_name == residue_atoms[i]->GetAtomName()) { base_index = i; // std::cout << "DEBUG:: Using tree based on atom: " // << tree_base_atom.atom_name << " index: " << base_index << std::endl; @@ -804,17 +804,17 @@ coot::chi_angles::change_by_internal(int ichi, for (int iat=0; iatx << ", " - << residue_atoms[iat]->y << ", " - << residue_atoms[iat]->z << ") to (" + << residue_atoms[iat]->x() << ", " + << residue_atoms[iat]->y() << ", " + << residue_atoms[iat]->z() << ") to (" << coords_rotatated[iat].get_x() << ", " << coords_rotatated[iat].get_y() << ", " << coords_rotatated[iat].get_z() << ")" << std::endl; } - residue_atoms[iat]->x = coords_rotatated[iat].get_x(); - residue_atoms[iat]->y = coords_rotatated[iat].get_y(); - residue_atoms[iat]->z = coords_rotatated[iat].get_z(); + residue_atoms[iat]->x() = coords_rotatated[iat].get_x(); + residue_atoms[iat]->y() = coords_rotatated[iat].get_y(); + residue_atoms[iat]->z() = coords_rotatated[iat].get_z(); } } } else { @@ -919,14 +919,14 @@ coot::chi_angles::get_atom_index_pairs(const std::vector & for (unsigned int ipair=0; ipairname; + std::string atomname = atoms[i]->GetAtomName(); if (atomname == atom_name_pairs[ipair].atom1) { i_store_index = i; } } if (i_store_index > -1) { // i.e. we found the first atom for(int i2=0; i2name; + std::string atomname = atoms[i2]->GetAtomName(); if (atomname == atom_name_pairs[ipair].atom2) { index_pairs.push_back(coot::atom_index_pair(i_store_index, i2)); } @@ -955,7 +955,7 @@ coot::chi_angles::get_atom_index_quads(const std::vector & int index_3 = -1; int index_4 = -1; for (int iat=0; iatname; + std::string atomname = atoms[iat]->GetAtomName(); if (atomname == atom_name_quads[iquad].atom_name(0)) index_1 = iat; if (atomname == atom_name_quads[iquad].atom_name(1)) diff --git a/ligand/dipole.cc b/ligand/dipole.cc index 397e151aab..df54d0165e 100644 --- a/ligand/dipole.cc +++ b/ligand/dipole.cc @@ -71,9 +71,9 @@ coot::dipole::init(std::vectorGetAtomTable(SelAtoms, nSelAtoms); for (int i_res_at=0; i_res_atx; - sum_y += SelAtoms[i_res_at]->y; - sum_z += SelAtoms[i_res_at]->z; + sum_x += SelAtoms[i_res_at]->x(); + sum_y += SelAtoms[i_res_at]->y(); + sum_z += SelAtoms[i_res_at]->z(); n_points++; } } @@ -106,9 +106,9 @@ coot::dipole::init(std::vector > charged_ats = charged_atoms(dict_res_pairs); std::vector > charged_points(charged_ats.size()); for (unsigned int i=0; ix, - charged_ats[i].first->y, - charged_ats[i].first->z); + clipper::Coord_orth p(charged_ats[i].first->x(), + charged_ats[i].first->y(), + charged_ats[i].first->z()); charged_points[i] = std::pair(charged_ats[i].second, p); } @@ -149,7 +149,7 @@ coot::dipole::fill_charged_atoms(mmdb::Residue *residue_p, std::vector > v = charged_atoms(residue_p, rest); for (unsigned int i=0; icharge = v[i].second; + v[i].first->charge() = v[i].second; } } @@ -166,7 +166,7 @@ coot::dipole::charged_atoms(mmdb::Residue *residue_p, for (int i_res_at=0; i_res_atname; + std::string atom_name = at->GetAtomName(); for (int j=0; jseqNum = 1 + iseq ; + res->GetSeqNum() = 1 + iseq ; clipper::RTop_orth o = n_turns(iseq, seq.length(), form_flag); coot::util::transform_atoms(res, o); int success = mutate_res(res, seq[iseq], is_dna_flag); @@ -127,7 +127,7 @@ coot::ideal_rna::make_molecule() { // antisense residue mmdb::Residue *res = coot::util::deep_copy_this_residue(antisense_ref); - res->seqNum = seq.length() - iseq; + res->GetSeqNum() = seq.length() - iseq; // antisense_chain_p->AddResidue(res); "backwards in pdb" clipper::RTop_orth o = n_turns(iseq, seq.length(), form_flag); coot::util::transform_atoms(res, o); @@ -177,7 +177,7 @@ coot::ideal_rna::fix_up_residue_and_atom_names(mmdb::Residue *residue_p, bool is residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname; + std::string atom_name = at->GetAtomName(); if (atom_name.length() > 3) { if (atom_name[3] == '*') { atom_name[3] = '\''; @@ -193,7 +193,7 @@ coot::ideal_rna::fix_up_residue_and_atom_names(mmdb::Residue *residue_p, bool is if (new_name == "DT") { for (int iat=0; iatname; + std::string atom_name = at->GetAtomName(); if (atom_name == " C5M") { at->SetAtomName(" C7 "); } @@ -448,7 +448,7 @@ coot::ideal_rna::delete_o2_prime(mmdb::Residue *res) const { if (res) { res->GetAtomTable(residue_atoms, natoms); for (int i=0; iname); + std::string atname(residue_atoms[i]->GetAtomName()); if (atname == " O2*") { res->DeleteAtom(i); deleted=1; @@ -486,7 +486,7 @@ coot::ideal_rna::add_o2_prime(mmdb::Residue *res) const { mmdb::Atom *c3p = NULL; res->GetAtomTable(residue_atoms, natoms); for (int i=0; iname); + std::string atname(residue_atoms[i]->GetAtomName()); if (atname == " C1'" || atname == " C1*") c1p = residue_atoms[i]; if (atname == " C2'" || atname == " C2*") @@ -497,9 +497,9 @@ coot::ideal_rna::add_o2_prime(mmdb::Residue *res) const { if (c1p && c2p && c3p) { // add o std::vector ref_pts; - ref_pts.push_back(clipper::Coord_orth(c1p->x, c1p->y, c1p->z)); - ref_pts.push_back(clipper::Coord_orth(c2p->x, c2p->y, c2p->z)); - ref_pts.push_back(clipper::Coord_orth(c3p->x, c3p->y, c3p->z)); + ref_pts.push_back(clipper::Coord_orth(c1p->x(), c1p->y(), c1p->z())); + ref_pts.push_back(clipper::Coord_orth(c2p->x(), c2p->y(), c2p->z())); + ref_pts.push_back(clipper::Coord_orth(c3p->x(), c3p->y(), c3p->z())); clipper::RTop_orth rtop(mov_pts, ref_pts); clipper::Coord_orth pos = o2p.transform(rtop); diff --git a/ligand/libres-tracer.cc b/ligand/libres-tracer.cc index d033ec628d..390a1dd302 100644 --- a/ligand/libres-tracer.cc +++ b/ligand/libres-tracer.cc @@ -168,7 +168,7 @@ spin_score(unsigned int idx_1, unsigned int idx_2, mmdb::Atom **atom_selection, auto index_to_pos = [atom_selection] (unsigned int idx) { mmdb::Atom *at = atom_selection[idx]; - return clipper::Coord_orth(at->x, at->y, at->z); + return clipper::Coord_orth(at->x(), at->y(), at->z()); }; float inv_rmsd = 1.0f/map_rmsd; @@ -463,8 +463,8 @@ spin_score(unsigned int idx_1, unsigned int idx_2, mmdb::Atom **atom_selection, bool using_test_model = false; // for testing if (using_test_model) { - std::string atom_name_1(at_1->name); - std::string atom_name_2(at_2->name); + std::string atom_name_1(at_1->GetAtomName()); + std::string atom_name_2(at_2->GetAtomName()); if (atom_name_1 == " CA ") { if (atom_name_2 == " CA ") { if ((at_1->GetSeqNum() + 1) == at_2->GetSeqNum()) @@ -563,7 +563,7 @@ make_spin_scored_pairs(const std::vector > auto index_to_pos = [atom_selection] (unsigned int idx) { mmdb::Atom *at = atom_selection[idx]; - return clipper::Coord_orth(at->x, at->y, at->z); + return clipper::Coord_orth(at->x(), at->y(), at->z()); }; auto index_to_name = [atom_selection] (unsigned int idx) { mmdb::Atom *at = atom_selection[idx]; @@ -737,8 +737,8 @@ find_chains_that_overlap_other_chains(mmdb::Manager *mol, float big_overlap_frac res_no_delta_stats_t() : sum(0), sum_sq(0), count(0) {} void add(mmdb::Atom *at_1, mmdb::Atom *at_2) { // It is usually the case that the residue numbers are the same - int res_no_1 = at_1->residue->GetSeqNum(); - int res_no_2 = at_2->residue->GetSeqNum(); + int res_no_1 = at_1->GetResidue()->GetSeqNum(); + int res_no_2 = at_2->GetResidue()->GetSeqNum(); int d = abs(res_no_2-res_no_1); // std::cout << "debug:: add() " << res_no_1 << " " << res_no_2 << " d " << d << std::endl; sum += d; @@ -1325,7 +1325,7 @@ make_fragments(std::vector > &score auto index_to_pos = [atom_selection] (unsigned int idx) { mmdb::Atom *at = atom_selection[idx]; - return clipper::Coord_orth(at->x, at->y, at->z); + return clipper::Coord_orth(at->x(), at->y(), at->z()); }; auto distance_check_min = [atom_selection] (int atom_index_1, int atom_index_2, double dist_min) { @@ -1867,7 +1867,7 @@ make_fragments(std::vector > &score auto index_to_pos = [atom_selection] (unsigned int idx) { mmdb::Atom *at = atom_selection[idx]; - return clipper::Coord_orth(at->x, at->y, at->z); + return clipper::Coord_orth(at->x(), at->y(), at->z()); }; std::ofstream f("debug-trace.points"); if (f) { @@ -2066,7 +2066,7 @@ make_fragments(std::vector > &score auto index_to_pos = [atom_selection] (int idx) { mmdb::Atom *at = atom_selection[idx]; - return clipper::Coord_orth(at->x, at->y, at->z); + return clipper::Coord_orth(at->x(), at->y(), at->z()); }; unsigned int n_top_traces = 800; @@ -2373,9 +2373,9 @@ globularize(mmdb::Manager *mol, const clipper::Xmap &xmap, const clipper: } } if (updated) { - at->x = pos_best.x(); - at->y = pos_best.y(); - at->z = pos_best.z(); + at->x() = pos_best.x(); + at->y() = pos_best.y(); + at->z() = pos_best.z(); } } } @@ -2583,9 +2583,9 @@ bring_together_consecutive_C_and_N_by_symmetry_transformation(mmdb::Manager *mol clipper::Coord_orth p(cfs.coord_orth(cell)); if (false) std::cout << "Moving (symm) " << coot::atom_spec_t(at_res) << " from " - << at_res->x << " " << at_res->y << " " << at_res->z << " to " + << at_res->x() << " " << at_res->y() << " " << at_res->z() << " to " << p.x() << " " << p.y() << " " << p.z() << std::endl; - at_res->x = p.x(); at_res->y = p.y(); at_res->z = p.z(); + at_res->x() = p.x(); at_res->y() = p.y(); at_res->z() = p.z(); } } } @@ -2720,7 +2720,7 @@ find_connected_fragments(const coot::minimol::molecule &flood_mol, for (int i=0; iisTer()) { - f << i << " " << at->x << " " << at->y << " " << at->z << "\n"; + f << i << " " << at->x() << " " << at->y() << " " << at->z() << "\n"; } } f.close(); @@ -3019,7 +3019,7 @@ apply_sequence_to_fragments(mmdb::Manager *mol_in, const clipper::Xmap &x n_res = chain_p->GetNumberOfResidues(); for (int ires=0; iresGetResidue(ires); - residue_p->seqNum = seq_pos + ires + 1; + residue_p->GetSeqNum() = seq_pos + ires + 1; // std::cout << "new seqnum for residue with index " << ires << " " << residue_p->seqNum << std::endl; } mol_in->FinishStructEdit(); @@ -3566,9 +3566,9 @@ void res_tracer_proc(const clipper::Xmap &xmap, float xmap_rmsd, const co std::string atom_name_to(at_to->GetAtomName()); if (atom_name_to == atom_name_from) { std::cout << "moving atom " << coot::atom_spec_t(at_to) << std::endl; - at_to->x = at->x; - at_to->y = at->y; - at_to->z = at->z; + at_to->x() = at->x(); + at_to->y() = at->y(); + at_to->z() = at->z(); break; } } @@ -4080,9 +4080,9 @@ void res_tracer_proc(const clipper::Xmap &xmap, float xmap_rmsd, const co float d_spun = score_atom_positions(atom_positions, pos_CA_this, pos_CA_next, xmap); if (d_spun > d_current) { - at_C_this->x = pos_C_this.x(); at_C_this->y = pos_C_this.y(); at_C_this->z = pos_C_this.z(); - at_O_this->x = pos_O_this.x(); at_O_this->y = pos_O_this.y(); at_O_this->z = pos_O_this.z(); - at_N_next->x = pos_N_next.x(); at_N_next->y = pos_N_next.y(); at_N_next->z = pos_N_next.z(); + at_C_this->x() = pos_C_this.x(); at_C_this->y() = pos_C_this.y(); at_C_this->z() = pos_C_this.z(); + at_O_this->x() = pos_O_this.x(); at_O_this->y() = pos_O_this.y(); at_O_this->z() = pos_O_this.z(); + at_N_next->x() = pos_N_next.x(); at_N_next->y() = pos_N_next.y(); at_N_next->z() = pos_N_next.z(); } } } @@ -4456,11 +4456,11 @@ void res_tracer_learn(const clipper::Xmap &xmap, float weight, float xmap for (int i=0; iisTer()) { - float dx = ref_mol_at->x - at->x; + float dx = ref_mol_at->x() - at->x(); if (fabsf(dx) < dist_crit) { - float dy = ref_mol_at->y - at->y; + float dy = ref_mol_at->y() - at->y(); if (fabsf(dy) < dist_crit) { - float dz = ref_mol_at->z - at->z; + float dz = ref_mol_at->z() - at->z(); if (fabsf(dz) < dist_crit) { float dd = dx * dx + dy * dy + dz * dz; float d = sqrtf(dd); diff --git a/ligand/ligand-extras.cc b/ligand/ligand-extras.cc index d96d62dd2b..f777e8f74b 100644 --- a/ligand/ligand-extras.cc +++ b/ligand/ligand-extras.cc @@ -196,7 +196,7 @@ coot::ligand::mean_and_variance_where_the_atoms_are(mmdb::Manager *mol) const { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - std::string ele = at->element; + std::string ele = at->GetElementName(); if (ele != " H") n_molecule_atoms++; } @@ -219,11 +219,11 @@ coot::ligand::mean_and_variance_where_the_atoms_are(mmdb::Manager *mol) const { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - std::string ele = at->element; + std::string ele = at->GetElementName(); if (ele != " H") { float f = coot::util::random() * rmi; if (f < crit_val) { - clipper::Coord_orth c(at->x, at->y, at->z); + clipper::Coord_orth c(at->x(), at->y(), at->z()); test_points.push_back(c); } } @@ -244,9 +244,9 @@ coot::ligand::mean_and_variance_where_the_atoms_are(mmdb::Manager *mol) const { for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - std::string ele = at->element; + std::string ele = at->GetElementName(); if (ele != " H") { - clipper::Coord_orth c(at->x, at->y, at->z); + clipper::Coord_orth c(at->x(), at->y(), at->z()); test_points.push_back(c); } } diff --git a/ligand/ligand.cc b/ligand/ligand.cc index cf7d15d59a..13c14e9c65 100644 --- a/ligand/ligand.cc +++ b/ligand/ligand.cc @@ -340,9 +340,9 @@ coot::ligand::mask_map(mmdb::Manager *mol, short int mask_waters_flag) { // std::cout << "masking...."; for(int i=0; ix, atoms[i]->y, atoms[i]->z); + clipper::Coord_orth co(atoms[i]->x(), atoms[i]->y(), atoms[i]->z()); - std::string res_name (atoms[i]->residue->name); + std::string res_name (atoms[i]->GetResidue()->GetResName()); if (mask_waters_flag) { mask_around_coord(co, atom_radius); // mask xmap_masked } else { @@ -375,9 +375,9 @@ coot::ligand::mask_map(mmdb::Manager *mol, if (invert_flag == 0) { for (int i=0; ix, - atom_selection[i]->y, - atom_selection[i]->z); + clipper::Coord_orth co(atom_selection[i]->x(), + atom_selection[i]->y(), + atom_selection[i]->z()); mask_around_coord(co, map_atom_mask_radius); // mask xmap_cluster } diff --git a/ligand/molecular-replacement.cc b/ligand/molecular-replacement.cc index 903b6eaea3..1b1ad41870 100644 --- a/ligand/molecular-replacement.cc +++ b/ligand/molecular-replacement.cc @@ -213,9 +213,9 @@ coot::molecular_replacement_search(const clipper::Xmap &xmap_obs, << std::endl; for (int i=0; ix += shift.x(); - sel_atoms[i]->y += shift.y(); - sel_atoms[i]->z += shift.z(); + sel_atoms[i]->x() += shift.x(); + sel_atoms[i]->y() += shift.y(); + sel_atoms[i]->z() += shift.z(); } clipper::Xmap model_map = coot::util::calc_atom_map(mol, SelHnd, cell_model, spacegroup, gs_model); @@ -406,16 +406,16 @@ coot::molecular_replacement_search(const clipper::Xmap &xmap_obs, mol_rot->GetSelIndex(sel_rot, atoms_rot, na_rot); for (int i=0; ix -= mol_centre.second.x(); - atoms_rot[i]->y -= mol_centre.second.y(); - atoms_rot[i]->z -= mol_centre.second.z(); + atoms_rot[i]->x() -= mol_centre.second.x(); + atoms_rot[i]->y() -= mol_centre.second.y(); + atoms_rot[i]->z() -= mol_centre.second.z(); } for (int i=0; ix, atoms_rot[i]->y, atoms_rot[i]->z); + glm::vec3 pos(atoms_rot[i]->x(), atoms_rot[i]->y(), atoms_rot[i]->z()); glm::vec3 rotated = rot_mat * pos; - atoms_rot[i]->x = rotated.x; - atoms_rot[i]->y = rotated.y; - atoms_rot[i]->z = rotated.z; + atoms_rot[i]->x() = rotated.x; + atoms_rot[i]->y() = rotated.y; + atoms_rot[i]->z() = rotated.z; } // Compute atom map on the local box cell/grid (optimisation 1) @@ -473,9 +473,9 @@ coot::molecular_replacement_search(const clipper::Xmap &xmap_obs, mol_placed->GetSelIndex(sel_placed, atoms_placed, na_placed); for (int i=0; ix += trans_pos.x(); - atoms_placed[i]->y += trans_pos.y(); - atoms_placed[i]->z += trans_pos.z(); + atoms_placed[i]->x() += trans_pos.x(); + atoms_placed[i]->y() += trans_pos.y(); + atoms_placed[i]->z() += trans_pos.z(); } mol_placed->DeleteSelection(sel_placed); @@ -576,11 +576,11 @@ coot::molecular_replacement_search(const clipper::Xmap &xmap_obs, for (int j=0; jisTer()) { std::string name(res_atoms[j]->GetAtomName()); - std::string altloc(res_atoms[j]->altLoc); + std::string altloc(res_atoms[j]->altLoc()); if (name == moved_at.name && altloc == moved_at.altLoc) { - res_atoms[j]->x = moved_at.pos.x(); - res_atoms[j]->y = moved_at.pos.y(); - res_atoms[j]->z = moved_at.pos.z(); + res_atoms[j]->x() = moved_at.pos.x(); + res_atoms[j]->y() = moved_at.pos.y(); + res_atoms[j]->z() = moved_at.pos.z(); } } } diff --git a/ligand/monomer-utils.cc b/ligand/monomer-utils.cc index 56e728c6b2..a0354ee9d0 100644 --- a/ligand/monomer-utils.cc +++ b/ligand/monomer-utils.cc @@ -112,14 +112,14 @@ coot::monomer_utils::get_atom_index_pairs(const std::vectorname; + std::string atomname = atoms[i]->GetAtomName(); if (atomname == atom_name_pairs_in[ipair].atom1) { i_store_index = i; } } if (i_store_index > -1) { // i.e. we found the first atom for(int i2=0; i2name; + std::string atomname = atoms[i2]->GetAtomName(); if (atomname == atom_name_pairs_in[ipair].atom2) { index_pairs.push_back(coot::atom_index_pair(i_store_index, i2)); } @@ -147,16 +147,16 @@ coot::monomer_utils::get_atom_index_quads(const std::vectorname; + std::string atom_name = atoms[i1]->GetAtomName(); if (atom_name == atom_name_quads_in[iquad].atom_name(0)) { for (int i2=0; i2name; + std::string atom_name = atoms[i2]->GetAtomName(); if (atom_name == atom_name_quads_in[iquad].atom_name(1)) { for (int i3=0; i3name; + std::string atom_name = atoms[i3]->GetAtomName(); if (atom_name == atom_name_quads_in[iquad].atom_name(2)) { for (int i4=0; i4name; + std::string atom_name = atoms[i4]->GetAtomName(); if (atom_name == atom_name_quads_in[iquad].atom_name(3)) { v.push_back(coot::atom_index_quad(i1, i2, i3, i4)); } @@ -237,5 +237,5 @@ coot::monomer_utils::get_quads(const std::vector &atom_nam clipper::Coord_orth coot::monomer_utils::atom_to_co(mmdb::Atom *at) const { - return clipper::Coord_orth(at->x, at->y, at->z); + return clipper::Coord_orth(at->x(), at->y(), at->z()); } diff --git a/ligand/new-residue-by-3-phi-psi.cc b/ligand/new-residue-by-3-phi-psi.cc index ded6f84149..385470ec01 100644 --- a/ligand/new-residue-by-3-phi-psi.cc +++ b/ligand/new-residue-by-3-phi-psi.cc @@ -114,7 +114,7 @@ coot::new_residue_by_3_phi_psi::get_connecting_residue_atoms() const { residue_p->GetAtomTable(residue_atoms, nResidueAtoms); for (int i=0; iname); + std::string atom_name(at->GetAtomName()); if (atom_name == " N ") N_at = at; if (atom_name == " C ") C_at = at; if (atom_name == " CA ") CA_at = at; diff --git a/ligand/primitive-chi-angles.cc b/ligand/primitive-chi-angles.cc index fbd4451db8..07db01449c 100644 --- a/ligand/primitive-chi-angles.cc +++ b/ligand/primitive-chi-angles.cc @@ -44,7 +44,7 @@ coot::primitive_chi_angles::get_chi_angles() { bool residue_has_alt_confs = 0; for (int i=0; ialtLoc); + std::string alt_conf(residue_atoms[i]->altLoc()); if (alt_conf != "") { residue_has_alt_confs = 1; break; @@ -275,16 +275,16 @@ coot::primitive_chi_angles::get_atom_index_quads(const std::vectorname; + std::string atom_name = atoms[i1]->GetAtomName(); if (atom_name == atom_name_quads_in[iquad].atom_name(0)) { for (int i2=0; i2name; + std::string atom_name = atoms[i2]->GetAtomName(); if (atom_name == atom_name_quads_in[iquad].atom_name(1)) { for (int i3=0; i3name; + std::string atom_name = atoms[i3]->GetAtomName(); if (atom_name == atom_name_quads_in[iquad].atom_name(2)) { for (int i4=0; i4name; + std::string atom_name = atoms[i4]->GetAtomName(); if (atom_name == atom_name_quads_in[iquad].atom_name(3)) { v.push_back(coot::atom_index_quad(i1, i2, i3, i4)); } @@ -357,20 +357,20 @@ coot::primitive_chi_angles::get_quads_using_altconfs(const std::vector v; for (unsigned int iquad=0; iquadname; - std::string alt_conf_1 = atoms[i1]->altLoc; + std::string atom_name = atoms[i1]->GetAtomName(); + std::string alt_conf_1 = atoms[i1]->altLoc(); if (atom_name == atom_name_quads[iquad].atom_name(0)) { for (int i2=0; i2name; - std::string alt_conf_2 = atoms[i2]->altLoc; + std::string atom_name = atoms[i2]->GetAtomName(); + std::string alt_conf_2 = atoms[i2]->altLoc(); if (atom_name == atom_name_quads[iquad].atom_name(1)) { for (int i3=0; i3name; - std::string alt_conf_3 = atoms[i3]->altLoc; + std::string atom_name = atoms[i3]->GetAtomName(); + std::string alt_conf_3 = atoms[i3]->altLoc(); if (atom_name == atom_name_quads[iquad].atom_name(2)) { for (int i4=0; i4name; - std::string alt_conf_4 = atoms[i4]->altLoc; + std::string atom_name = atoms[i4]->GetAtomName(); + std::string alt_conf_4 = atoms[i4]->altLoc(); if (atom_name == atom_name_quads[iquad].atom_name(3)) { if (alt_conf_4 == residue_alt_confs[i_alt_conf] || alt_conf_4 == "") { if (alt_conf_3 == residue_alt_confs[i_alt_conf] || alt_conf_3 == "") { @@ -418,5 +418,5 @@ coot::primitive_chi_angles::get_quads_using_altconfs(const std::vectorx, at->y, at->z); + return clipper::Coord_orth(at->x(), at->y(), at->z()); } diff --git a/ligand/rama-rsr-extend-fragments.cc b/ligand/rama-rsr-extend-fragments.cc index eaf7774793..1f6fceaf08 100644 --- a/ligand/rama-rsr-extend-fragments.cc +++ b/ligand/rama-rsr-extend-fragments.cc @@ -474,14 +474,14 @@ rama_rsr_extend_fragments(mmdb::Manager *mol, const clipper::Xmap &xmap, double dd = (at_2_pos - at_1_pos).lengthsq(); double d = std::sqrt(dd); std::cout << "moving atom " << coot::atom_spec_t(atom_o) << " from " - << std::setw(9) << atom_o->x << " " << std::setw(9) << atom_o->y << " " << std::setw(9) << atom_o->z << " to " - << std::setw(9) << atom_r->x << " " << std::setw(9) << atom_r->y << " " << std::setw(9) << atom_r->z + << std::setw(9) << atom_o->x() << " " << std::setw(9) << atom_o->y() << " " << std::setw(9) << atom_o->z() << " to " + << std::setw(9) << atom_r->x() << " " << std::setw(9) << atom_r->y() << " " << std::setw(9) << atom_r->z() << " d " << std::setw(9) << d << "\n"; } - atom_o->x = atom_r->x; - atom_o->y = atom_r->y; - atom_o->z = atom_r->z; + atom_o->x() = atom_r->x(); + atom_o->y() = atom_r->y(); + atom_o->z() = atom_r->z(); } } } diff --git a/ligand/residue_by_phi_psi.cc b/ligand/residue_by_phi_psi.cc index 7ff2c51550..0d7c873a8d 100644 --- a/ligand/residue_by_phi_psi.cc +++ b/ligand/residue_by_phi_psi.cc @@ -667,7 +667,7 @@ coot::residue_by_phi_psi::get_connecting_residue_atoms() const { residue_p->GetAtomTable(residue_atoms, nResidueAtoms); for (int i=0; iname); + std::string atom_name(at->GetAtomName()); if (atom_name == " N ") N_at = at; if (atom_name == " C ") C_at = at; if (atom_name == " CA ") CA_at = at; diff --git a/ligand/rotamer.cc b/ligand/rotamer.cc index d72388bf5c..eaa60694cb 100644 --- a/ligand/rotamer.cc +++ b/ligand/rotamer.cc @@ -502,7 +502,7 @@ coot::rotamer::rotamer_atom_names_to_indices(const std::vector 0) { for (int iat=0; iatname); + atom_indices[iat] = std::string(residue_atoms[iat]->GetAtomName()); } int ithis_atom; @@ -530,9 +530,9 @@ coot::rotamer::rotamer_atom_names_to_indices(const std::vectorresidue->name << " " - << residue_atoms[0]->residue->GetSeqNum() << " " - << residue_atoms[0]->residue->GetChainID() << std::endl; + << residue_atoms[0]->GetResidue()->GetResName() << " " + << residue_atoms[0]->GetResidue()->GetSeqNum() << " " + << residue_atoms[0]->GetResidue()->GetChainID() << std::endl; } } return r; @@ -554,7 +554,7 @@ coot::rotamer::chi_torsion(const std::vector &chi_angle_atoms_indices, for (unsigned int ich_at=0; ich_atx, at->y, at->z)); + a.push_back(clipper::Coord_orth(at->x(), at->y(), at->z())); } double ctorsion = clipper::Coord_orth::torsion(a[0], a[1], a[2], a[3]); @@ -721,9 +721,9 @@ coot::rotamer::GetResidue_old(int i_rot) const { // smn_Cartesian c(residue_atoms[i]->x, // residue_atoms[i]->y, // residue_atoms[i]->z); - ::Cartesian d(ordered_atoms[i]->x, - ordered_atoms[i]->y, - ordered_atoms[i]->z); + ::Cartesian d(ordered_atoms[i]->x(), + ordered_atoms[i]->y(), + ordered_atoms[i]->z()); // std::cout << residue_atoms[i]->name << " " << c // << ordered_atoms[i]->name << " " << d << std::endl; // std::cout << ordered_atoms[i]->name << " " << d << std::endl; @@ -736,9 +736,9 @@ coot::rotamer::GetResidue_old(int i_rot) const { std::vector< ::Cartesian > coords; for(int i=0; ix, - ordered_atoms[i]->y, - ordered_atoms[i]->z); + ::Cartesian c(ordered_atoms[i]->x(), + ordered_atoms[i]->y(), + ordered_atoms[i]->z()); coords.push_back(c); } @@ -908,9 +908,9 @@ coot::rotamer::GetResidue_old(int i_rot) const { std::cout << "disaster in atom selection, trees, dunbrack\n"; } else { for (int iat=0; iatx = coords_rotated[iat].get_x(); - ordered_residue_atoms_ppcatom[iat]->y = coords_rotated[iat].get_y(); - ordered_residue_atoms_ppcatom[iat]->z = coords_rotated[iat].get_z(); + ordered_residue_atoms_ppcatom[iat]->x() = coords_rotated[iat].get_x(); + ordered_residue_atoms_ppcatom[iat]->y() = coords_rotated[iat].get_y(); + ordered_residue_atoms_ppcatom[iat]->z() = coords_rotated[iat].get_z(); } } delete [] ordered_residue_atoms_ppcatom; diff --git a/ligand/side-chain-densities.cc b/ligand/side-chain-densities.cc index 5606da7838..6316a38a76 100644 --- a/ligand/side-chain-densities.cc +++ b/ligand/side-chain-densities.cc @@ -951,7 +951,7 @@ coot::side_chain_densities::sample_map(mmdb::Residue *residue_this_p, if (! at->isTer()) { clipper::Coord_orth pos = co(at); residue_atom_positions.push_back(pos); - std::string atom_name(at->name); + std::string atom_name(at->GetAtomName()); if (atom_name == " N " || atom_name == " C " || atom_name == " O " || atom_name == " H " || atom_name == " CA ") { double r = 2.8; @@ -969,7 +969,7 @@ coot::side_chain_densities::sample_map(mmdb::Residue *residue_this_p, for (int i=0; iGetAtom(i); if (! at->isTer()) { - std::string atom_name(at->name); + std::string atom_name(at->GetAtomName()); if (atom_name == " N ") { clipper::Coord_orth pos = co(at); std::pair p(3.0, pos); @@ -1411,8 +1411,8 @@ coot::side_chain_densities::get_residue_axes_type_GLY(mmdb::Residue *this_residu int n_atoms = this_residue->GetNumberOfAtoms(); for (int i=0; iGetAtom(i); - std::string atom_name = at->name; - std::string alt_loc = at->altLoc; + std::string atom_name = at->GetAtomName(); + std::string alt_loc = at->altLoc(); if (! at->isTer()) { if (alt_loc.empty()) { if (atom_name == " CA ") CA_at = at; @@ -1490,8 +1490,8 @@ coot::side_chain_densities::get_residue_axes(mmdb::Residue *residue_p) const { int n_atoms = residue_p->GetNumberOfAtoms(); for (int i=0; iGetAtom(i); - std::string atom_name = at->name; - std::string alt_loc = at->altLoc; + std::string atom_name = at->GetAtomName(); + std::string alt_loc = at->altLoc(); if (! at->isTer()) { if (alt_loc.empty()) { if (atom_name == " CA ") CA_at = at; diff --git a/ligand/side-chain.cc b/ligand/side-chain.cc index 12dfa5b257..faff7bc367 100644 --- a/ligand/side-chain.cc +++ b/ligand/side-chain.cc @@ -141,20 +141,20 @@ coot::do_180_degree_side_chain_flip(const coot::residue_spec_t &spec, // for (int iatc=0; iatcaltLoc; + std::string atom_copy_altconf = residue_atoms_copy[iatc]->altLoc(); if (atom_copy_altconf == alt_conf) { // we need to find this atom in residue - std::string atom_copy_name = residue_atoms_copy[iatc]->name; + std::string atom_copy_name = residue_atoms_copy[iatc]->GetAtomName(); for (int iato=0; iatoaltLoc; - std::string orig_atom_name = residue_atoms[iato]->name; + std::string orig_atom_altconf = residue_atoms[iato]->altLoc(); + std::string orig_atom_name = residue_atoms[iato]->GetAtomName(); if (orig_atom_name == atom_copy_name) { if (atom_copy_altconf == orig_atom_altconf) { // std::cout << "DEBUG:: copying coords from " // << residue_atoms_copy[iatc] << std::endl; - residue_atoms[iato]->x = residue_atoms_copy[iatc]->x; - residue_atoms[iato]->y = residue_atoms_copy[iatc]->y; - residue_atoms[iato]->z = residue_atoms_copy[iatc]->z; + residue_atoms[iato]->x() = residue_atoms_copy[iatc]->x(); + residue_atoms[iato]->y() = residue_atoms_copy[iatc]->y(); + residue_atoms[iato]->z() = residue_atoms_copy[iatc]->z(); } } } diff --git a/ligand/torsion-general.cc b/ligand/torsion-general.cc index 4dc773294a..0025491559 100644 --- a/ligand/torsion-general.cc +++ b/ligand/torsion-general.cc @@ -73,9 +73,9 @@ coot::torsion_general::GetTree_0_based() const { residue_p->GetAtomTable(residue_atoms, n_residue_atoms); std::vector< ::Cartesian > coords; for(int i=0; ix, - residue_atoms[i]->y, - residue_atoms[i]->z); + ::Cartesian c(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z()); coords.push_back(c); } int base_index = 0; @@ -95,9 +95,9 @@ coot::torsion_general::GetTree() const { residue_p->GetAtomTable(residue_atoms, n_residue_atoms); std::vector< ::Cartesian > coords; for(int i=0; ix, - residue_atoms[i]->y, - residue_atoms[i]->z); + ::Cartesian c(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z()); coords.push_back(c); } int base_index = clicked_atom_indices[0]; @@ -124,9 +124,9 @@ coot::torsion_general::change_by(double diff, Tree *tree) { residue_p->GetAtomTable(residue_atoms, n_residue_atoms); std::vector< ::Cartesian > coords; for(int i=0; ix, - residue_atoms[i]->y, - residue_atoms[i]->z); + ::Cartesian c(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z()); coords.push_back(c); } @@ -163,22 +163,22 @@ coot::torsion_general::change_by(double diff, Tree *tree) { for (int iat=0; iatx - coords_rotatated[iat].get_x(); - float dy = residue_atoms[iat]->x - coords_rotatated[iat].get_x(); - float dz = residue_atoms[iat]->x - coords_rotatated[iat].get_x(); + float dx = residue_atoms[iat]->x() - coords_rotatated[iat].get_x(); + float dy = residue_atoms[iat]->x() - coords_rotatated[iat].get_x(); + float dz = residue_atoms[iat]->x() - coords_rotatated[iat].get_x(); float dd = dx * dx + dy * dy + dz * dz; float d = sqrt(dd); - std::cout << residue_atoms[iat]->name << "debug:: change_by(): " - << residue_atoms[iat]->x << " " - << residue_atoms[iat]->y << " " - << residue_atoms[iat]->z << " to " + std::cout << residue_atoms[iat]->GetAtomName() << "debug:: change_by(): " + << residue_atoms[iat]->x() << " " + << residue_atoms[iat]->y() << " " + << residue_atoms[iat]->z() << " to " << coords_rotatated[iat] << " moved by " << d << std::endl; } - residue_atoms[iat]->x = coords_rotatated[iat].get_x(); - residue_atoms[iat]->y = coords_rotatated[iat].get_y(); - residue_atoms[iat]->z = coords_rotatated[iat].get_z(); + residue_atoms[iat]->x() = coords_rotatated[iat].get_x(); + residue_atoms[iat]->y() = coords_rotatated[iat].get_y(); + residue_atoms[iat]->z() = coords_rotatated[iat].get_z(); } r = 0; // return good status } @@ -188,9 +188,9 @@ coot::torsion_general::change_by(double diff, Tree *tree) { } if (debug) { for(int i=0; ix, - residue_atoms[i]->y, - residue_atoms[i]->z); + ::Cartesian c(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z()); } } } else { @@ -262,7 +262,7 @@ coot::torsion_general::get_contact_indices() const { // we keep a mapping from local indexing to residue indexing. // for (int i=0; ielement); + std::string element(residue_atoms[i]->GetElementName()); if (element == " H" || element == " D") { n_H_residue_atoms++; } else { @@ -276,7 +276,7 @@ coot::torsion_general::get_contact_indices() const { int iH=0; int inH=0; for (int i=0; ielement); + std::string element(residue_atoms[i]->GetElementName()); if (element == " H" || element == " D") { H_residue_atoms[iH] = residue_atoms[i]; H_atom_orig_indcies[iH]=i; diff --git a/mini-mol/atom-quads.cc b/mini-mol/atom-quads.cc index 320f1b91d1..cae6453f2a 100644 --- a/mini-mol/atom-quads.cc +++ b/mini-mol/atom-quads.cc @@ -150,7 +150,7 @@ coot::atom_quad::setup_chiral_quad(mmdb::Residue *residue_with_O, mmdb::Residue int n_residue_atoms; residue_with_O->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); + std::string atom_name(residue_atoms[iat]->GetAtomName()); if (atom_name == O_name) { // the O atom name comes from the residue_with_O if (!quad.atom_1) { @@ -164,7 +164,7 @@ coot::atom_quad::setup_chiral_quad(mmdb::Residue *residue_with_O, mmdb::Residue residue_with_chiral_centre->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); + std::string atom_name(at->GetAtomName()); if (atom_name == atom_4_name) { if (! quad.atom_4) quad.atom_4 = at; // chiral centre atom @@ -244,18 +244,18 @@ coot::atom_index_quad::torsion(mmdb::PPAtom atom_selection, int n_selected_atoms std::string mess = "bad atom indexing in atom_index_quad::torsion()"; throw std::runtime_error(mess); } - clipper::Coord_orth pt_1(atom_selection[index1]->x, - atom_selection[index1]->y, - atom_selection[index1]->z); - clipper::Coord_orth pt_2(atom_selection[index2]->x, - atom_selection[index2]->y, - atom_selection[index2]->z); - clipper::Coord_orth pt_3(atom_selection[index3]->x, - atom_selection[index3]->y, - atom_selection[index3]->z); - clipper::Coord_orth pt_4(atom_selection[index4]->x, - atom_selection[index4]->y, - atom_selection[index4]->z); + clipper::Coord_orth pt_1(atom_selection[index1]->x(), + atom_selection[index1]->y(), + atom_selection[index1]->z()); + clipper::Coord_orth pt_2(atom_selection[index2]->x(), + atom_selection[index2]->y(), + atom_selection[index2]->z()); + clipper::Coord_orth pt_3(atom_selection[index3]->x(), + atom_selection[index3]->y(), + atom_selection[index3]->z()); + clipper::Coord_orth pt_4(atom_selection[index4]->x(), + atom_selection[index4]->y(), + atom_selection[index4]->z()); angle = clipper::Util::rad2d(clipper::Coord_orth::torsion(pt_1, pt_2, pt_3, pt_4)); } @@ -268,9 +268,9 @@ double coot::atom_quad::angle_2() const { // angle 1-2-3 in degrees if (atom_1 && atom_2 && atom_3) { - clipper::Coord_orth pt_1(atom_1->x, atom_1->y, atom_1->z); - clipper::Coord_orth pt_2(atom_2->x, atom_2->y, atom_2->z); - clipper::Coord_orth pt_3(atom_3->x, atom_3->y, atom_3->z); + clipper::Coord_orth pt_1(atom_1->x(), atom_1->y(), atom_1->z()); + clipper::Coord_orth pt_2(atom_2->x(), atom_2->y(), atom_2->z()); + clipper::Coord_orth pt_3(atom_3->x(), atom_3->y(), atom_3->z()); double angle = clipper::Util::rad2d(clipper::Coord_orth::angle(pt_1, pt_2, pt_3)); return angle; } else { @@ -283,9 +283,9 @@ double coot::atom_quad::angle_3() const { // angle 2-3-4 in degrees if (atom_2 && atom_3 && atom_4) { - clipper::Coord_orth pt_2(atom_2->x, atom_2->y, atom_2->z); - clipper::Coord_orth pt_3(atom_3->x, atom_3->y, atom_3->z); - clipper::Coord_orth pt_4(atom_4->x, atom_4->y, atom_4->z); + clipper::Coord_orth pt_2(atom_2->x(), atom_2->y(), atom_2->z()); + clipper::Coord_orth pt_3(atom_3->x(), atom_3->y(), atom_3->z()); + clipper::Coord_orth pt_4(atom_4->x(), atom_4->y(), atom_4->z()); double angle = clipper::Util::rad2d(clipper::Coord_orth::angle(pt_2, pt_3, pt_4)); return angle; } else { @@ -297,10 +297,10 @@ coot::atom_name_quad coot::atom_quad::get_atom_name_quad() const { if (atom_1 && atom_2 && atom_3 && atom_4) { - return coot::atom_name_quad(atom_1->name, - atom_2->name, - atom_3->name, - atom_4->name); + return coot::atom_name_quad(atom_1->GetAtomName(), + atom_2->GetAtomName(), + atom_3->GetAtomName(), + atom_4->GetAtomName()); } else { throw std::runtime_error("atom_quad::atom_name_quad() Null atom(s)"); } @@ -318,10 +318,10 @@ coot::atom_name_quad::torsion(mmdb::Residue *residue) const { mmdb::Atom *at_3 = residue->GetAtom(atom_name_[3].c_str()); if (at_0 && at_1 && at_2 && at_3) { - clipper::Coord_orth pt_0(at_0->x, at_0->y, at_0->z); - clipper::Coord_orth pt_1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth pt_2(at_2->x, at_2->y, at_2->z); - clipper::Coord_orth pt_3(at_3->x, at_3->y, at_3->z); + clipper::Coord_orth pt_0(at_0->x(), at_0->y(), at_0->z()); + clipper::Coord_orth pt_1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth pt_2(at_2->x(), at_2->y(), at_2->z()); + clipper::Coord_orth pt_3(at_3->x(), at_3->y(), at_3->z()); double angle = clipper::Util::rad2d(clipper::Coord_orth::torsion(pt_0, pt_1, pt_2, pt_3)); return angle; } @@ -334,10 +334,10 @@ double coot::atom_quad::torsion() const { if (atom_1 && atom_2 && atom_3 && atom_4) { - clipper::Coord_orth pt_1(atom_1->x, atom_1->y, atom_1->z); - clipper::Coord_orth pt_2(atom_2->x, atom_2->y, atom_2->z); - clipper::Coord_orth pt_3(atom_3->x, atom_3->y, atom_3->z); - clipper::Coord_orth pt_4(atom_4->x, atom_4->y, atom_4->z); + clipper::Coord_orth pt_1(atom_1->x(), atom_1->y(), atom_1->z()); + clipper::Coord_orth pt_2(atom_2->x(), atom_2->y(), atom_2->z()); + clipper::Coord_orth pt_3(atom_3->x(), atom_3->y(), atom_3->z()); + clipper::Coord_orth pt_4(atom_4->x(), atom_4->y(), atom_4->z()); double angle = clipper::Util::rad2d(clipper::Coord_orth::torsion(pt_1, pt_2, pt_3, pt_4)); return angle; } else { @@ -354,10 +354,10 @@ coot::atom_quad::chiral_volume() const { throw std::runtime_error("Null atoms in quad for chiral volume"); } else { - clipper::Coord_orth centre(atom_4->x, atom_4->y, atom_4->z); - clipper::Coord_orth at_1(atom_1->x, atom_1->y, atom_1->z); - clipper::Coord_orth at_2(atom_2->x, atom_2->y, atom_2->z); - clipper::Coord_orth at_3(atom_3->x, atom_3->y, atom_3->z); + clipper::Coord_orth centre(atom_4->x(), atom_4->y(), atom_4->z()); + clipper::Coord_orth at_1(atom_1->x(), atom_1->y(), atom_1->z()); + clipper::Coord_orth at_2(atom_2->x(), atom_2->y(), atom_2->z()); + clipper::Coord_orth at_3(atom_3->x(), atom_3->y(), atom_3->z()); clipper::Coord_orth a = at_1 - centre; clipper::Coord_orth b = at_2 - centre; diff --git a/mini-mol/mini-mol.cc b/mini-mol/mini-mol.cc index 3af4733a31..9620adf6f5 100644 --- a/mini-mol/mini-mol.cc +++ b/mini-mol/mini-mol.cc @@ -124,7 +124,7 @@ coot::minimol::molecule::molecule(mmdb::PPAtom atom_selection, for (int iat=0; iatresidue; + mmdb::Residue *residue_p = at->GetResidue(); mmdb::Chain *chain_p = at->GetChain(); int resno = residue_p->GetSeqNum(); std::string res_name = residue_p->GetResName(); @@ -161,7 +161,7 @@ coot::minimol::molecule::molecule(mmdb::PPAtom atom_selection, coot::minimol::residue res(resno); res.name = res_name; coot::minimol::atom minimol_atom(at); - minimol_atom.pos = clipper::Coord_orth(atoms[iat].x, atoms[iat].y, atoms[iat].z); + minimol_atom.pos = clipper::Coord_orth(atoms[iat].x(), atoms[iat].y(), atoms[iat].z()); res.addatom(minimol_atom); try { fragments[ifrag_for_atom].addresidue(res,1); @@ -171,7 +171,7 @@ coot::minimol::molecule::molecule(mmdb::PPAtom atom_selection, } } else { coot::minimol::atom minimol_atom(at); - minimol_atom.pos = clipper::Coord_orth(atoms[iat].x, atoms[iat].y, atoms[iat].z); + minimol_atom.pos = clipper::Coord_orth(atoms[iat].x(), atoms[iat].y(), atoms[iat].z()); fragments[ifrag_for_atom][resno].addatom(minimol_atom); } } @@ -215,7 +215,7 @@ coot::minimol::molecule::min_resno_in_chain(mmdb::Chain *chain_p) const { int resno; for (int ires=0; iresGetResidue(ires); - resno = residue_p->seqNum; + resno = residue_p->GetSeqNum(); if (resno < min_resno) { min_resno = resno; found_residues = 1; @@ -289,20 +289,20 @@ coot::minimol::molecule::setup(mmdb::Manager *mol, bool udd_atom_index_to_user_d mmdb::Atom *at; for (int ires=0; iresGetResidue(ires); - coot::minimol::residue r(residue_p->seqNum); + coot::minimol::residue r(residue_p->GetSeqNum()); int n_atoms = residue_p->GetNumberOfAtoms(); - r.name = residue_p->name; + r.name = residue_p->GetResName(); for (int iat=0; iatGetAtom(iat); if (! at->isTer()) { - clipper::Coord_orth p(at->x, at->y, at->z); - coot::minimol::atom mat(std::string(at->name), - std::string(at->element), + clipper::Coord_orth p(at->x(), at->y(), at->z()); + coot::minimol::atom mat(std::string(at->GetAtomName()), + std::string(at->GetElementName()), p, - std::string(at->altLoc), - at->occupancy, - at->tempFactor); + std::string(at->altLoc()), + at->occupancy(), + at->tempFactor()); if (do_atom_index_transfer) { int atom_udd_atom_index = -1; if (at->GetUDData(udd_atom_index_handle, atom_udd_atom_index) == mmdb::UDDATA_Ok) { @@ -585,22 +585,22 @@ coot::minimol::molecule::fragment_for_chain(const std::string &chain_id) { // coot::minimol::residue::residue(mmdb::Residue* residue_p) { - seqnum = residue_p->seqNum; + seqnum = residue_p->GetSeqNum(); ins_code = residue_p->GetInsCode(); - name = residue_p->name; + name = residue_p->GetResName(); int nResidueAtoms; mmdb::PPAtom residue_atoms; residue_p->GetAtomTable(residue_atoms, nResidueAtoms); for (int i=0; iisTer()) - addatom(std::string(residue_atoms[i]->name), - std::string(residue_atoms[i]->element), - residue_atoms[i]->x, - residue_atoms[i]->y, - residue_atoms[i]->z, - std::string(residue_atoms[i]->altLoc), - residue_atoms[i]->occupancy, - residue_atoms[i]->tempFactor); + addatom(std::string(residue_atoms[i]->GetAtomName()), + std::string(residue_atoms[i]->GetElementName()), + residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z(), + std::string(residue_atoms[i]->altLoc()), + residue_atoms[i]->occupancy(), + residue_atoms[i]->tempFactor()); } } @@ -608,14 +608,14 @@ coot::minimol::residue::residue(mmdb::Residue* residue_p) { coot::minimol::residue::residue(mmdb::Residue *residue_p, const std::vector &keep_only_these_atoms) { - seqnum = residue_p->seqNum; + seqnum = residue_p->GetSeqNum(); ins_code = residue_p->GetInsCode(); - name = residue_p->name; + name = residue_p->GetResName(); int nResidueAtoms; mmdb::PPAtom residue_atoms; residue_p->GetAtomTable(residue_atoms, nResidueAtoms); for (int i=0; iname; + std::string atom_name = residue_atoms[i]->GetAtomName(); bool add_it = 0; for (unsigned int ikeep=0; ikeepelement), - residue_atoms[i]->x, - residue_atoms[i]->y, - residue_atoms[i]->z, - std::string(residue_atoms[i]->altLoc), - residue_atoms[i]->occupancy, - residue_atoms[i]->tempFactor); + std::string(residue_atoms[i]->GetElementName()), + residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z(), + std::string(residue_atoms[i]->altLoc()), + residue_atoms[i]->occupancy(), + residue_atoms[i]->tempFactor()); } } } @@ -661,8 +661,8 @@ coot::minimol::residue::make_residue() const { // cif bits if (atoms[iat].name.length() < 20) strcpy(atom_p->label_atom_id, atoms[iat].name.c_str()); - strncpy(atom_p->element, atoms[iat].element.c_str(),3); - strncpy(atom_p->altLoc, atoms[iat].altLoc.c_str(), 2); + atom_p->SetElementName(atoms[iat].element.c_str()); + strncpy(atom_p->altLoc(), atoms[iat].altLoc.c_str(), 2); int i_add = residue_p->AddAtom(atom_p); if (i_add < 0) std::cout << "addatom addition error" << std::endl; @@ -683,7 +683,7 @@ coot::minimol::residue::update_positions_from(mmdb::Residue *residue_p) { residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatx, at->y, at->z); + clipper::Coord_orth p(at->x(), at->y(), at->z()); atoms[iat].pos = p; } } @@ -1003,12 +1003,12 @@ coot::minimol::atom::atom(std::string atom_name, } coot::minimol::atom::atom(mmdb::Atom *at) { - name = at->name; - element = at->element; - pos = clipper::Coord_orth(at->x, at->y, at->z); - altLoc = at->altLoc; - occupancy = at->occupancy; - temperature_factor = at->tempFactor; + name = at->GetAtomName(); + element = at->GetElementName(); + pos = clipper::Coord_orth(at->x(), at->y(), at->z()); + altLoc = at->altLoc(); + occupancy = at->occupancy(); + temperature_factor = at->tempFactor(); int_user_data = -1; } @@ -1085,8 +1085,8 @@ coot::minimol::molecule::pcmmdbmanager() const { (*this)[ifrag][ires][iatom].occupancy, (*this)[ifrag][ires][iatom].temperature_factor); atom_p->SetAtomName(this_atom.name.c_str()); - strncpy(atom_p->element,(*this)[ifrag][ires][iatom].element.c_str(),3); - strncpy(atom_p->altLoc, (*this)[ifrag][ires][iatom].altLoc.c_str(), 2); + atom_p->SetElementName((*this)[ifrag][ires][iatom].element.c_str()); + strncpy(atom_p->altLoc(), (*this)[ifrag][ires][iatom].altLoc.c_str(), 2); if (udd_atom_index_handle >= 0) if (this_atom.int_user_data >= 0) atom_p->PutUDData(udd_atom_index_handle, this_atom.int_user_data); diff --git a/mmdb-shim/ARCHITECTURE.md b/mmdb-shim/ARCHITECTURE.md new file mode 100644 index 0000000000..13f821689c --- /dev/null +++ b/mmdb-shim/ARCHITECTURE.md @@ -0,0 +1,329 @@ +# mmdb-shim architecture + +A drop-in replacement for the MMDB2 C++ API (`mmdb::*`) backed by +[gemmi](https://gemmi.readthedocs.io). Coot is built against this +shim instead of libmmdb2: the public headers under `include/mmdb2/` present +MMDB's classes, but every object is a thin wrapper over a live +`gemmi::Structure`. The goal is to remove the MMDB2 dependency while reproducing +MMDB's observable behaviour exactly. + + +--- + +## 1. Why a wrapper tree, not a live proxy + +A live proxy over `gemmi::Structure` (translate every call on demand) is not +possible, because Coot: + +- **writes MMDB public data members directly** — `atom->x`, `->occupancy`, + `residue->seqNum`, etc. (hundreds of sites); +- relies on **UDData** (`GetUDData`/`PutUDData`, hundreds of call sites) and the + **handle-based selection engine** — neither of which gemmi has; +- keys ~1000 containers on raw `mmdb::T*` and assumes **pointer identity and + stability** across edits (`AddAtom`, mid-list insert, `delete atom`). + +So the shim **owns an MMDB-shaped wrapper hierarchy** over the gemmi structure +and **reimplements selection + UDData**. gemmi is used only where it does the +real work well (I/O, symmetry, neighbour search, chemistry) — see §6. + +Field access is handled by making every MMDB public scalar an **accessor**: +`atom->x` was mechanically rewritten to `atom->x()` — this was a **one-time, +in-place edit of the Coot source tree** (§2), not a header trick. `x()` returns +`gemmi::Atom::pos.x` by reference so both reads and writes flow through to gemmi. +Narrower gemmi types (float `occ`/`b_iso`, `signed char charge`, single-char +`altloc`) use value-get + `set_*`. + +--- + +## 2. The one-time Coot source rewrite (`->x` → `->x()`) + +MMDB exposes atom/residue state as **public data members**; gemmi does not, and a +member cannot transparently become a method. So before Coot could build against +the shim, its source tree was rewritten once: every access to a rewritten MMDB +field was turned into a call, e.g. + +``` +atom->x -> atom->x() +atom->x = 1.2 -> atom->x() = 1.2 // ref-returning accessor: write still works +strcpy(at->name,s) -> at->SetAtomName(s) // char[] fields go through a setter +``` + +**This is a real, committed change to the Coot `.cc`/`.hh` sources** — not +something the headers do at compile time. The shim then defines the matching +accessors (§1). + +**The tool.** `mmdb-recon/ast/mmdb_tool.cpp` is a clang **libTooling / +AST-matcher** program (the same Phase-0 recon tool that emitted +`mmdb-recon/ast/mmdb_surface.json`; run with `--rewrite-fields` it becomes a +`RefactoringTool`). Build it with `mmdb-recon/ast/build.sh` (needs +`brew install llvm` — Apple clang lacks the libTooling dev headers). It is +**class-aware**: a config table (`kRules` / `kSetters` in `mmdb_tool.cpp`) lists +exactly which fields on which classes to rewrite — + +- `mmdb::Atom`: `x y z occupancy tempFactor charge altLoc serNum`, the ESD + fields `sigX…sigTemp`, the aniso tensor `u11…u23` (all ref-returning); + `name`→`GetAtomName`, `element`→`GetElementName`, `residue`→`GetResidue`; + `strcpy(name…)`→`SetAtomName`, `strcpy(element…)`→`SetElementName`. +- `mmdb::Residue`: `name`→`GetResName`, `seqNum`→`GetSeqNum`, + `insCode`→`GetInsCode`, `index`→`GetIndex`; `strcpy(name…)`→`SetResName`. + +Fields not in the table are left untouched — they surface as compile errors when +building Coot against the shim and are added to the table (or the shim) as they +appear. + +**Driver + guardrails** (`rewrite.sh` at the repo root): + +- **Rewrite against *real* MMDB, build against the shim.** The tool matches + `atom->x` as a real-mmdb *field*; if the compile DB pointed at the shim, `->x` + would already be a method and nothing would match. `rewrite.sh` aborts if the + `compile_commands.json` contains `mmdb-shim/include`. +- **Dedup across TUs.** A header is parsed once per includer; point-insertions of + `()` don't conflict in clang's `Replacements`, so without a guard they *stack* + (`x()()()…`). `firstRewriteAt(file,offset)` records each site so only the first + wins; `rewrite.sh` also greps the diff for `()()` as a safety net. +- **Do it on a dedicated branch** — it touches hundreds of files; the tool writes + all edits at the end of the run (after parsing every TU), and it is reversible + with `git checkout`. + +The synthetic fixture in `mmdb-shim/test/rewrite/` exercises the Atom+Residue +rules in the standalone suite. + +--- + +## 3. File layout + +Public API headers (what Coot includes) are macro-guarded veneers: + +``` +include/mmdb2/mmdb_manager.h, mmdb_atom.h, … (14 headers) + #ifdef COOT_USE_MMDB_SHIM -> #include "_shim_impl.hh" (this shim) + #else -> #include_next (real MMDB) +``` + +`#include_next` lets the same tree fall through to real MMDB with the macro off, +for A/B comparison. The implementation is header-only (so the accessor rewrite +and inline hot paths cross TU boundaries) and split into four dependency-ordered +layers, each opening its own `namespace mmdb`: + +| Header | Contents | +|---|---| +| `_shim_types.hh` | typedefs, enums, `UDStore` base, forward decls, leaf record classes (LINK/CisPep/Cryst/Helix/Sheet/SymOps/Title), free helpers | +| `_shim_hierarchy.hh` | `Atom` / `Residue` / `Chain` / `Model` class definitions | +| `_shim_manager.hh` | `Manager` (MMDB Root + CoorManager + SelManager) and nested `Selection` / `UDReg` | +| `_shim_inline.hh` | `g()` resolvers, UDData helpers, all out-of-line method bodies, the `detail::` selection matchers, free functions | +| `_shim_impl.hh` | umbrella: includes the four layers in order, then the two subsystems below | + +Two subsystems have their own headers, included last (they need a complete +`Atom`/`Residue`): + +- `_mmcif_impl.hh` — `mmdb::mmcif::*` over `gemmi::cif`. +- `_graph_impl.hh` — `mmdb::math::{Vertex,Edge,Graph,GraphMatch}` graph matching. + +Two heavyweight operations are compiled once in `src/*.cc` (built into +`lib/libmmdbshim.a`) rather than inlined, to keep gemmi's large read/write and +neighbour-search headers out of the ~230 Coot TUs that include +``: + +- `src/io.cc` — `Manager::Read*/Write*` via gemmi. +- `src/contacts.cc` — `Manager::SeekContacts` / `SelectNeighbours` via gemmi + `NeighborSearch`. + +--- + +## 4. The wrapper node and `g()` resolution + +Each hierarchy class (`Atom`/`Residue`/`Chain`/`Model`) is a stable node holding: + +- `Manager* mgr` — owning manager; +- a **parent pointer** (`res` / `chain` / `model` / — ; null ⇒ *detached*); +- a **cached sibling index** (`ai` / `ri` / `ci` / `mi`); +- a canonical `std::vector` — this doubles as the **identity cache** and + as the `PPAtom`/`PPResidue` table MMDB hands back; +- a `gemmi::T _local` used only while detached. + +`g()` resolves a wrapper to its live gemmi object **by index through the parent +chain**: + +```cpp +gemmi::Atom& Atom::g() { return res->chain->model->mgr->st + .models[mi].chains[ci].residues[ri].atoms[ai]; } +``` + +Index-based (not pointer-based) resolution is the key trick: when a +`std::vector` push reallocates, sibling wrappers stay valid — only the affected +container's indices are patched. This is what gives Coot the pointer stability it +assumes while gemmi's vectors move underneath. + +**Detached construction.** Coot's ubiquitous idiom is `new mmdb::Atom; set +fields…; residue->AddAtom(at)`. A wrapper with no parent stores its data in +`_local`; `g()` returns `_local`. `Add*()` copies `_local` into the parent's +gemmi vector, sets the parent pointer + index, and cascades `mgr` down the +subtree that was built while detached. + +--- + +## 5. Memory management + +MMDB owns hierarchy nodes with `new`/`delete` and Coot exploits this directly +(`delete atom;`, `delete residue_p;`). The shim matches that contract: + +**Ownership.** +- The `Manager` owns the one `gemmi::Structure st` — the single source of truth. +- **Atoms and residues are individually heap-allocated** (`Manager::newAtom` / + `newRes`) and tracked in `std::set _atom_allocs` / `_res_allocs`, so a + single `delete atom;` frees exactly one node. +- Chains and models are pooled in `std::deque/` (stable addresses, + never individually deleted by Coot). +- gemmi-derived metadata records (LINK/CISPEP/HELIX/SHEET/author) live in + per-`Manager` `std::deque` pools; the `Model` containers hold bare pointers + into them. + +**Deletion of a live atom** (`~Atom`, i.e. Coot's `delete atom;`): detach from +the parent residue's wrapper+gemmi vectors (kept in lockstep), remove from the +manager/model flat atom lists and any selections, reindex trailing siblings, then +drop from `_atom_allocs`. No dangling pointer survives. + +**Deferred residue deletion.** MMDB's `DeleteResidue` (and `delete residue_p;`) +is *deferred*: it frees the residue's atoms and **tombstones** the slot (nulls +the wrapper pointer, keeps a gemmi placeholder residue) without changing +`nResidues`, until `FinishStructEdit`/`TrimResidueTable`. Coot depends on this +(e.g. `change_chain_id` iterates to the original count while deleting). The +placeholder keeps surviving siblings' `ri` valid; `_compact_residues()` later +drops the null wrapper slot and its gemmi placeholder in lockstep and reindexes. + +**Teardown.** `~Manager` sets `_bulk_free = true` and frees the alloc sets +wholesale; `~Atom`/`~Residue` see the flag and skip all the detach bookkeeping +(memory is going away anyway), avoiding O(n²) teardown. + +**Returned arrays.** `SeekContacts` returns `Contact*` allocated with `new[]`; +the caller `delete[]`s it — the MMDB contract. Borrowed C-strings from accessors +(`GetAtomName`, UDData strings) are backed by per-object buffers / `deque` +and are never freed by Coot. + +--- + +## 6. How gemmi is used (the boundaries) + +The rule is **prefer gemmi**: never reimplement what gemmi provides. Mapping: + +| MMDB surface | gemmi backing | +|---|---| +| PDB / mmCIF read + write | `read_pdb_file` / `read_structure_file` / `write_pdb` / `make_mmcif_document`; `merge_chain_parts()` on read for MMDB one-chain-per-ID parity | +| coordinates, occ, B, aniso, altLoc, element, serial | `gemmi::Atom` fields via `g()` | +| cell / fractionalisation | `gemmi::UnitCell` (`fractionalize`/`orthogonalize`) | +| symmetry (`GetTMatrix`, sym ops) | `SpaceGroup::operations()` composed with the cell frac↔orth transforms | +| neighbour / contact search | `gemmi::NeighborSearch` (grid-accelerated) | +| element data (`getVdWaalsRadius`, `isMetal`) | `gemmi::Element` | +| residue classification (`isAminoacid`/`isSolvent`/`isSugar`/`Get1LetterCode`) | `gemmi::find_tabulated_residue` | +| LINK / CISPEP / HELIX / SHEET / authors | `Structure::{connections,cispeps,helices,sheets}`, `meta.authors` | +| `mmdb::mmcif::*` | `gemmi::cif` (Document/Block/Loop/Table) | + +`Manager::_load_metadata()` reshapes gemmi's structure-level metadata into the +MMDB per-`Model` record containers on load. + +--- + +## 7. What the shim implements itself (no gemmi equivalent) + +These are hand-written because gemmi has nothing to map onto. They are kept +minimal. + +- **UDData slots.** Each object derives from `UDStore` (contiguous + `int`/`double`/`string` vectors + selection-membership bits). `Manager` holds a + 1-based handle registry (`ud_regs`); registering a handle assigns a per-(type, + kind) slot; `PutUDData`/`GetUDData` index into the object's vectors. + Handle `0` means "not registered" — Coot relies on `if (h==0) Register…`. + +- **Selection engine.** `Manager` owns a vector of `Selection`s (1-based + handles). `Select` walks the wrapper tree filtering on model/chain/(seqNum, + insCode)-range/resname/atom-name/element/altLoc, supporting `SKEY_*` set + combinators and MMDB's `"!X"` negation and `"*"` wildcard. Membership is + mirrored in each object's `_inSel` bits so deletion can scrub stale pointers. + CID strings (`"/1/A/10-20/CA"`) are parsed by a pragmatic tokeniser into that + same filter call. + +- **Pointer-stable wrapper identity.** The whole `vector` + + index-locator scheme in §4 exists because gemmi's containers move and have no + spare identity field; MMDB code cannot tolerate that. + +- **Contacts (illustrative).** The common path *does* use gemmi + `NeighborSearch` — but where gemmi doesn't fit, the shim fills the gap + in-house. `SeekContacts` with an MMDB `TMatrix` needs contacts against an + arbitrarily **symmetry-transformed** copy of the second atom set; gemmi's + search indexes the model's own atoms, not a caller-supplied transformed set. So + that path (`contacts_transformed` in `src/contacts.cc`) transforms the set and + runs a small hand-rolled **uniform-grid** neighbour search. The + `NeighborSearch::Mark`→wrapper mapping goes back through the parallel tree + (`chains[chain_idx].residues[residue_idx].atoms[atom_idx]`). + +- **Graph / subgraph matching** (`_graph_impl.hh`). `mmdb::math::Graph`/ + `GraphMatch` is a branch-and-bound maximum-common-**induced**-subgraph matcher + (element + bond-type constrained). gemmi has no subgraph isomorphism, so this + is genuinely shim-owned (design: `../mmdb-graph-matching-for-gemmi.md`). + +- **Sequence alignment** (`math::Alignment`). A faithful re-creation of MMDB's + Needleman-Wunsch with **identity scoring** (match=1/mismatch=0/linear gap). + gemmi *has* an aligner, but only with substitution-matrix scoring, which would + change which residues Coot calls mutations vs indels — so matching the MMDB + baseline requires MMDB's specific scoring, which gemmi does not offer. + +- **PDB-column name alignment.** MMDB returns 4-char aligned atom names + (`" CA "`) and 2-char right-justified upper-case elements (`" C"`, `"NA"`); + gemmi stores trimmed/mixed-case. `GetAtomName`/`GetElementName` re-pad, and + matchers trim both sides, because Coot's specs and colour/element tests depend + on the padded form. + +--- + +## 8. External dependency walls + +MMDB is also used by libraries Coot links that are **precompiled against real +MMDB 2.0.22** (different ABI). Passing shim objects across those boundaries is +UB. Handled by shadowing headers (the shim include dir precedes theirs on `-I`): + +- **`include/gemmi/mmdb.hpp`** shadows gemmi's own MMDB bridge. The real one + copies field-by-field through real-mmdb public fields (incompatible with + accessors). The shim's `copy_to_mmdb`/`copy_from_mmdb` are trivial because + `Manager` already owns a `gemmi::Structure`. + +- **`include/ssm/ssm_align.h`** shadows libssm (structural superposition) with a + self-contained **no-op `ssm::Align`** — `align()` returns `RC_NoHits` with an + identity matrix, so callers take their no-superposition path. SSM is being + removed; its real headers pull the full real-mmdb binary-serialization API. + +- **clipper `MMDBAtom_list`**: clipper's prebuilt dylib reads `mmdb::Atom` x/y/z/ + occ/B as *data fields* → garbage on shim atoms. The fix lives in Coot + (`coot-utils/mmdb-to-clipper-atom-list.hh`): build the `clipper::Atom_list` + through the shim's *method* accessors. `clipper::Atom_list` is pure clipper with + no mmdb ABI dependency. + +--- + +## 9. Intentionally inert / mocked + +Documented in-source; each is a deliberate decision, not an omission: + +- **Secondary-structure assignment** (`CalcSecStructure`) returns the non-OK code + — gemmi's DSSP has SS prediction disabled upstream, so there is no gemmi SS to + forward and residues keep `SSE_None`. +- **`MakeBonds`** is a no-op — Coot's only caller recomputes bonds from geometry + and ignores the MMDB bond table. +- **`Cryst::GetTMatrix`** on a bare `Cryst` is identity (no structure ref); + `Manager::GetTMatrix` is the live symmetry path. +- `PutPDBString`, `InitMatType`, `SetFlag` are no-ops (behaviour is fixed by the + gemmi reader/writer). + +--- + +## 10. Build and test + +- **Standalone suite** (seconds): `bash mmdb-shim/build.sh` — compiles the + `test/*.cc` against the shim (core, hierarchy, UDData, selection, contacts, + I/O, audit, leaf integration, rewriter) plus a macro-off real-MMDB coexistence + check. +- **Static lib**: `bash mmdb-shim/build-shimlib.sh` → `lib/libmmdbshim.a` + (rebuild only when `src/*.cc` change; header-only edits don't need it). +- **Full Coot** (the real integration test): `cd ~/lmb/build-coot-mmdb-shim && + cmake --build . -j6` (never bare `-j`). Reaches 100% building libcootapi, the + CLI tools, `test-molecules-container`, and the `coot_headless_api` python + module. diff --git a/mmdb-shim/build-shimlib.sh b/mmdb-shim/build-shimlib.sh new file mode 100755 index 0000000000..fcb2655e8b --- /dev/null +++ b/mmdb-shim/build-shimlib.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Build the shim's compiled units (io.cc + contacts.cc) into a static lib that +# the real Coot build links against. Header-only parts come via -Iinclude. +# -> mmdb-shim/lib/libmmdbshim.a +set -euo pipefail +HERE="$(cd "$(dirname "$0")" && pwd)" +GEMMI="${GEMMI_INC:-$(brew --prefix gemmi)/include}" +CXX="${CXX:-/usr/bin/clang++}" +mkdir -p "$HERE/lib" "$HERE/obj" + +for u in io contacts; do + "$CXX" -std=c++17 -O2 -fPIC -DCOOT_USE_MMDB_SHIM -I"$HERE/include" -I"$GEMMI" \ + -c "$HERE/src/$u.cc" -o "$HERE/obj/$u.o" +done +ar rcs "$HERE/lib/libmmdbshim.a" "$HERE/obj/io.o" "$HERE/obj/contacts.o" +echo "built $HERE/lib/libmmdbshim.a" +echo +echo "To wire into the autotools build (before ./configure), e.g.:" +echo " export CPPFLAGS=\"-I$HERE/include -DCOOT_USE_MMDB_SHIM \$CPPFLAGS\"" +echo " export LDFLAGS=\"-L$HERE/lib -L\$(brew --prefix gemmi)/lib \$LDFLAGS\"" +echo " export LIBS=\"-lmmdbshim -lgemmi_cpp \$LIBS\"" +echo " # (apply the field rewrite on a branch first; note clipper/ssm still" +echo " # see the shim headers in THIS version — expected, per project notes)" diff --git a/mmdb-shim/build.sh b/mmdb-shim/build.sh new file mode 100755 index 0000000000..cf7bf0217b --- /dev/null +++ b/mmdb-shim/build.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +# Build + run the mmdb-shim tests. +# macro ON -> gemmi-backed shim (mmdb-shim/include/mmdb2 + _shim_impl.hh) +# macro OFF -> falls through to real MMDB via #include_next (coexistence check) +set -euo pipefail +HERE="$(cd "$(dirname "$0")" && pwd)" +GEMMI="${GEMMI_INC:-$(brew --prefix gemmi)/include}" +MMDB="${MMDB_INC:-/opt/homebrew/Cellar/mmdb2/2.0.22/include}" +CXX=/usr/bin/clang++ +STD="-std=c++17 -O0 -g -Wall" + +echo "=== core unit test ===" +$CXX $STD -I"$GEMMI" "$HERE/core/test_core.cc" -o "$HERE/core/test_core" && "$HERE/core/test_core" | tail -1 + +echo "=== shim test (COOT_USE_MMDB_SHIM) ===" +$CXX $STD -DCOOT_USE_MMDB_SHIM -I"$HERE/include" -I"$GEMMI" \ + "$HERE/test/test_shim.cc" -o "$HERE/test/test_shim" && "$HERE/test/test_shim" | tail -1 + +echo "=== UDData engine test ===" +$CXX $STD -DCOOT_USE_MMDB_SHIM -I"$HERE/include" -I"$GEMMI" \ + "$HERE/test/test_udd.cc" -o "$HERE/test/test_udd" && "$HERE/test/test_udd" | tail -1 + +echo "=== selection engine test ===" +$CXX $STD -DCOOT_USE_MMDB_SHIM -I"$HERE/include" -I"$GEMMI" \ + "$HERE/test/test_sel.cc" -o "$HERE/test/test_sel" && "$HERE/test/test_sel" | tail -1 + +echo "=== contacts test (SelectSphere + SeekContacts via gemmi NeighborSearch) ===" +$CXX $STD -DCOOT_USE_MMDB_SHIM -I"$HERE/include" -I"$GEMMI" \ + "$HERE/src/contacts.cc" "$HERE/test/test_contacts.cc" \ + -L"$(brew --prefix gemmi)/lib" -lgemmi_cpp -lz -o "$HERE/test/test_contacts" \ + && "$HERE/test/test_contacts" | tail -1 + +echo "=== I/O round-trip test (gemmi read/write; links libgemmi_cpp) ===" +PDB="${PDB:-$HERE/../1hr2_final.pdb}" +$CXX $STD -DCOOT_USE_MMDB_SHIM -I"$HERE/include" -I"$GEMMI" \ + "$HERE/src/io.cc" "$HERE/test/test_io.cc" \ + -L"$(brew --prefix gemmi)/lib" -lgemmi_cpp -lz -o "$HERE/test/test_io" \ + && "$HERE/test/test_io" "$PDB" | tail -1 + +echo "=== audit test (symmetry / LINK / PutAtom / Sort / terminus / contacts via gemmi) ===" +$CXX $STD -DCOOT_USE_MMDB_SHIM -I"$HERE/include" -I"$GEMMI" \ + "$HERE/src/io.cc" "$HERE/src/contacts.cc" "$HERE/test/test_audit.cc" \ + -L"$(brew --prefix gemmi)/lib" -lgemmi_cpp -lz -o "$HERE/test/test_audit" \ + && "$HERE/test/test_audit" "$HERE/../1hr2_final.pdb" | tail -1 + +echo "=== leaf integration test (real Coot mmdb idioms vs gemmi ground truth) ===" +$CXX $STD -DCOOT_USE_MMDB_SHIM -I"$HERE/include" -I"$GEMMI" \ + "$HERE/src/io.cc" "$HERE/test/test_leaf.cc" \ + -L"$(brew --prefix gemmi)/lib" -lgemmi_cpp -lz -o "$HERE/test/test_leaf" \ + && "$HERE/test/test_leaf" | tail -1 + +if [ -x "$HERE/../mmdb-recon/ast/build2/mmdb_tool" ]; then + echo "=== field-access rewriter test (synthetic) ===" + bash "$HERE/test/rewrite/run_rewrite_test.sh" | tail -1 +fi + +echo "=== coexistence: macro OFF must compile against real MMDB ===" +printf '#include \nint main(){mmdb::Manager*m=new mmdb::Manager();int n=m->GetNumberOfModels();delete m;return n;}\n' > /tmp/mmdb_fallback.cc +$CXX $STD -I"$HERE/include" -I"$MMDB" -c /tmp/mmdb_fallback.cc -o /tmp/mmdb_fallback.o \ + && echo " ok: fallback compiles against real MMDB" diff --git a/mmdb-shim/include/gemmi/mmdb.hpp b/mmdb-shim/include/gemmi/mmdb.hpp new file mode 100644 index 0000000000..2f6e22657d --- /dev/null +++ b/mmdb-shim/include/gemmi/mmdb.hpp @@ -0,0 +1,43 @@ +// -*- mode: c++; -*- +// +// mmdb-shim: replacement for gemmi's own bridge. +// +// The real gemmi/mmdb.hpp converts gemmi::Structure <-> mmdb::Manager by copying +// field-by-field through real-mmdb PUBLIC FIELDS (atom->x = ..., chain->seqRes, +// mmdb::newAtom(), Cryst::Z, ...). That is fundamentally incompatible with the +// accessor-based shim (x/y/z are methods, not fields). +// +// But it is also unnecessary: the shim's mmdb::Manager already OWNS a live +// gemmi::Structure (Manager::st), so the conversions are near-trivial. This header +// is picked up instead of gemmi's because the shim include dir precedes gemmi's on +// the -I path. Only the functions Coot actually calls are provided. +// +// Copyright 2026 by Medical Research Council Laboratory of Molecular Biology +#ifndef COOT_MMDB_SHIM_GEMMI_MMDB_HPP +#define COOT_MMDB_SHIM_GEMMI_MMDB_HPP + +#include // shim mmdb::Manager (wraps gemmi::Structure) +#include // gemmi::Structure + +namespace gemmi { + +// gemmi::Structure -> mmdb::Manager: the shim Manager IS a gemmi::Structure +// wrapper, so adopt the structure and (re)build the wrapper hierarchy. +inline void copy_to_mmdb(const Structure& st, mmdb::Manager* manager) { + if (!manager) return; + manager->st = st; + manager->build_from_gemmi(); +} + +// mmdb::Manager -> gemmi::Structure: st is the source of truth (all wrappers +// resolve into it), so just return it. +inline Structure copy_from_mmdb(mmdb::Manager* manager) { + return manager ? manager->st : Structure(); +} + +// SEQRES already travels inside Manager::st, so this is a no-op in the shim. +inline void transfer_seqres_to_mmdb(const Structure&, mmdb::Manager*) {} + +} // namespace gemmi + +#endif // COOT_MMDB_SHIM_GEMMI_MMDB_HPP diff --git a/mmdb-shim/include/mmdb2/_graph_impl.hh b/mmdb-shim/include/mmdb2/_graph_impl.hh new file mode 100644 index 0000000000..9f53df25cf --- /dev/null +++ b/mmdb-shim/include/mmdb2/_graph_impl.hh @@ -0,0 +1,466 @@ +// -*- mode: c++; -*- +// +// mmdb-shim: mmdb::math::{Vertex,Edge,Graph,GraphMatch} — molecular graph + +// subgraph matching. gemmi has NO subgraph-isomorphism facility (see +// mmdb-graph-matching-for-gemmi.md §3), so per coot-shim-prefer-gemmi this is one +// of the few pieces genuinely hand-written: a branch-and-bound maximum-common- +// (induced-)subgraph matcher. Element typing uses gemmi::Element. +// +// Copyright 2026 by Medical Research Council Laboratory of Molecular Biology +// +// Included at the end of _shim_impl.hh (Residue/Atom complete; pstr/cpstr/ +// realtype/ivector/word already in namespace mmdb). +#ifndef COOT_MMDB_SHIM_GRAPH_IMPL_HH +#define COOT_MMDB_SHIM_GRAPH_IMPL_HH + +#include + +#include +#include +#include +#include +#include +#include + +namespace mmdb { + namespace math { + + // ---- constants (mmdb_math_graph.h) -------------------------------------- + enum GRAPH_BOND { BOND_SINGLE = 1, + BOND_DOUBLE = 2, + BOND_AROMATIC = 3, + BOND_TRIPLE = 4 }; + enum GRAPH_RC { MKGRAPH_Ok = 0, + MKGRAPH_NoAtoms = -1, + MKGRAPH_ChangedAltLoc = 1, + MKGRAPH_MaxOccupancy = 2 }; + enum GRAPH_MATCH_FLAG { GMF_UniqueMatch = 0x00000001, + GMF_NoCombinations = 0x00000002 }; + enum VERTEX_EXT_TYPE { EXTTYPE_Ignore = 0, + EXTTYPE_Equal = 1, + EXTTYPE_AND = 2, + EXTTYPE_OR = 3, + EXTTYPE_XOR = 4, + EXTTYPE_NotEqual = 5, + EXTTYPE_NotAND = 6, + EXTTYPE_NotOR = 7 }; + + namespace gdetail { + inline std::string trim(cpstr s) { + std::string t(s ? s : ""); + size_t a = t.find_first_not_of(" \t"), b = t.find_last_not_of(" \t"); + return a == std::string::npos ? std::string() : t.substr(a, b - a + 1); + } + inline int bond_from_string(cpstr s) { + std::string t = trim(s); + for (auto &c : t) c = (char)std::tolower((unsigned char)c); + if (t == "single" || t == "sing" || t == "1") return BOND_SINGLE; + if (t == "double" || t == "doub" || t == "2") return BOND_DOUBLE; + if (t == "aromatic" || t == "arom" || t == "ar") return BOND_AROMATIC; + if (t == "triple" || t == "trip" || t == "3") return BOND_TRIPLE; + return BOND_SINGLE; + } + } // namespace gdetail + + // ========================================================================= + // Vertex — a graph node (atom). `type` encodes element (atomic number) so + // GetType() equality means "same element". + // ========================================================================= + class Vertex { + public: + int type = 0, type_ext = 0, property = 0, nBonds = 0, id = 0, user_id = 0; + std::string name; + + Vertex() {} + Vertex(cpstr chem_elem) { SetVertex(chem_elem); } + Vertex(cpstr chem_elem, cpstr vname) { + SetVertex(chem_elem); + name = vname ? vname : ""; + } + Vertex(int vtype, cpstr vname) { + type = vtype; + name = vname ? vname : ""; + } + explicit Vertex(int vtype) { type = vtype; } + + void SetVertex(cpstr chem_elem) { + type = (int)gemmi::Element(gdetail::trim(chem_elem).c_str()).atomic_number(); + } + void SetVertex(int vtype, cpstr vname) { + type = vtype; + name = vname ? vname : ""; + } + void SetVertex(int vtype) { type = vtype; } + void SetName(cpstr vname) { name = vname ? vname : ""; } + void SetType(int t) { type = t; } + void SetTypeExt(int t) { type_ext = t; } + void SaveType() { property = type; } + void RestoreType() { type = property; } + void SetUserID(int u) { user_id = u; } + cpstr GetName() { return name.c_str(); } + int GetType() { return type; } + int GetTypeExt() { return type_ext; } + int GetNBonds() { return nBonds; } + int GetUserID() { return user_id; } // 0-based atom index (see MakeVertexIDs/MakeGraph) + void Print(int /*PKey*/ = 0) {} + }; + typedef Vertex *PVertex; + typedef Vertex **PPVertex; + + // ========================================================================= + // Edge — a graph connection (bond). v1/v2 are 1-indexed vertex numbers. + // ========================================================================= + class Edge { + public: + int v1 = 0, v2 = 0, type = 0, property = 0; + + Edge() {} + Edge(int vx1, int vx2, int btype) { + v1 = vx1; + v2 = vx2; + type = btype; + } + Edge(int vx1, int vx2, cpstr btype) { + v1 = vx1; + v2 = vx2; + type = gdetail::bond_from_string(btype); + } + + void SetEdge(int vx1, int vx2, int btype) { + v1 = vx1; + v2 = vx2; + type = btype; + } + void SetEdge(int vx1, int vx2, cpstr btype) { + v1 = vx1; + v2 = vx2; + type = gdetail::bond_from_string(btype); + } + void SetType(int t) { type = t; } + int GetVertex1() { return v1; } + int GetVertex2() { return v2; } + int GetType() { return type; } + void Print(int /*PKey*/ = 0) {} + }; + typedef Edge *PEdge; + typedef Edge **PPEdge; + + // ========================================================================= + // Graph — vertices + edges + adjacency matrix (built by Build()). + // Owns the Vertex/Edge objects handed to AddVertex/AddEdge (mmdb semantics). + // ========================================================================= + class Graph { + public: + std::string gname; + std::vector V; // owned; 1-indexed via GetVertex + std::vector E; // owned + std::vector> adj; // (n+1)x(n+1), 1-indexed; adj[i][j]=bond type or 0 + + Graph() {} + ~Graph() { + for (auto *p : V) delete p; + for (auto *e : E) delete e; + } + Graph(const Graph &) = delete; + Graph &operator=(const Graph &) = delete; + + void SetName(cpstr n) { gname = n ? n : ""; } + pstr GetName() { return (pstr)gname.c_str(); } + void AddVertex(PVertex v) { + if (v) V.push_back(v); + } + void AddEdge(PEdge e) { + if (e) E.push_back(e); + } + int GetNofVertices() { return (int)V.size(); } + int GetNofEdges() { return (int)E.size(); } + PVertex GetVertex(int i) { return (i >= 1 && i <= (int)V.size()) ? V[i - 1] : nullptr; } + PEdge GetEdge(int i) { return (i >= 1 && i <= (int)E.size()) ? E[i - 1] : nullptr; } + void GetVertices(PPVertex &v, int &n) { + v = V.data(); + n = (int)V.size(); + } + void GetEdges(PPEdge &e, int &n) { + e = E.data(); + n = (int)E.size(); + } + // number vertices; user_id = 0-based position so `residue->atom[V->GetUserID()]` + // (Coot's manual make_graph path) indexes the residue's 0-based atom table. + void MakeVertexIDs() { + for (int i = 0; i < (int)V.size(); ++i) { + V[i]->id = i + 1; + V[i]->user_id = i; + } + } + void Print() {} + void Print1() {} + void MakeSymmetryRelief(bool /*noCO2*/) {} // type_ext modifiers — low priority, no-op + void IdentifyRings() {} // " " + void IdentifyConnectedComponents() {} + + // adjacency matrix; bondOrder=false collapses all bonds to 1 (connectivity only) + int Build(bool bondOrder) { + int n = (int)V.size(); + adj.assign(n + 1, std::vector(n + 1, 0)); + for (Edge *e : E) + if (e->v1 >= 1 && e->v1 <= n && e->v2 >= 1 && e->v2 <= n) { + int t = bondOrder ? (e->type > 0 ? e->type : 1) : 1; + adj[e->v1][e->v2] = t; + adj[e->v2][e->v1] = t; + } + for (int i = 1; i <= n; ++i) { + int b = 0; + for (int j = 1; j <= n; ++j) + if (adj[i][j]) ++b; + V[i - 1]->nBonds = b; + } + return 0; + } + + int MakeGraph(PPAtom atom, int nAtoms); // build from atoms (distance bonds) + int MakeGraph(PResidue R, cpstr altLoc = nullptr); + }; + typedef Graph *PGraph; + + // ========================================================================= + // GraphMatch — maximum common (induced) subgraph via branch-and-bound. + // ========================================================================= + class GraphMatch { + public: + struct Match { + std::vector f1, f2; + }; // 1-indexed vertex numbers + std::vector matches; + int maxMatch = 0; + int maxNofMatches = 1000000; + bool stopOnMax = false; + int timeLimit = 0; // seconds; 0 = no limit + word flags = 0; + bool Stop = false; + // stable 1-indexed ivector storage for GetMatch (freed with this object) + std::vector> fv1, fv2; + + void SetFlag(word f) { flags |= f; } + void RemoveFlag(word f) { flags &= ~f; } + void SetMaxNofMatches(int m, bool stopOnMaxN) { + maxNofMatches = m > 0 ? m : 1; + stopOnMax = stopOnMaxN; + } + void SetTimeLimit(int t = 0) { timeLimit = t; } + int GetNofMatches() { return (int)matches.size(); } + int GetMaxMatchSize() { return maxMatch; } + bool GetStopSignal() { return Stop; } + void Reset() { + matches.clear(); + fv1.clear(); + fv2.clear(); + maxMatch = 0; + } + void PrintMatches() {} + + void MatchGraphs(PGraph Gh1, PGraph Gh2, int minMatch, bool vertexType = true, + VERTEX_EXT_TYPE vertexExt = EXTTYPE_Ignore); + void GetMatch(int MatchNo, ivector &FV1, ivector &FV2, int &nv, realtype &p1, realtype &p2); + }; + typedef GraphMatch *PGraphMatch; + + // ---- MatchGraphs: branch-and-bound maximum common induced subgraph ------- + inline void GraphMatch::MatchGraphs(PGraph g1, PGraph g2, int minMatch, + bool vertexType, VERTEX_EXT_TYPE vertexExt) { + Reset(); + Stop = false; + int n1 = g1->GetNofVertices(), n2 = g2->GetNofVertices(); + if (n1 == 0 || n2 == 0) return; + if ((int)g1->adj.size() != n1 + 1) g1->Build(false); + if ((int)g2->adj.size() != n2 + 1) g2->Build(false); + const std::vector> &A1 = g1->adj, &A2 = g2->adj; + + auto t0 = std::chrono::steady_clock::now(); + auto timed_out = [&]() -> bool { + if (timeLimit <= 0) return false; + if (std::chrono::duration_cast( + std::chrono::steady_clock::now() - t0) + .count() >= timeLimit) { + Stop = true; + return true; + } + return false; + }; + + std::vector> cur; // matched (g1,g2) 1-indexed pairs + std::vector used2(n2 + 1, 0); + std::vector>> best; + + auto compatible = [&](int i1, int i2) -> bool { + if (vertexType && g1->V[i1 - 1]->type != g2->V[i2 - 1]->type) return false; + if (vertexExt == EXTTYPE_Equal && g1->V[i1 - 1]->type_ext != g2->V[i2 - 1]->type_ext) return false; + for (const auto &pr : cur) // preserve edges (incl. absence) + bond type + if (A1[i1][pr.first] != A2[i2][pr.second]) return false; + return true; + }; + + std::function rec = [&](int idx) { + if (Stop || timed_out()) return; + // bound: best achievable from here can't exceed cur + remaining g1 vertices + if ((int)cur.size() + (n1 - idx + 1) < maxMatch) return; + if (idx > n1) { + int sz = (int)cur.size(); + if (sz >= minMatch && sz >= maxMatch) { + if (sz > maxMatch) { + maxMatch = sz; + best.clear(); + } + if ((int)best.size() < maxNofMatches) + best.push_back(cur); + else if (stopOnMax) + Stop = true; + } + return; + } + for (int i2 = 1; i2 <= n2 && !Stop; ++i2) { // Option A: map g1[idx] + if (used2[i2] || !compatible(idx, i2)) continue; + cur.push_back({idx, i2}); + used2[i2] = 1; + rec(idx + 1); + used2[i2] = 0; + cur.pop_back(); + } + if (!Stop) rec(idx + 1); // Option B: skip g1[idx] + }; + rec(1); + + for (auto &m : best) { + Match mm; + for (auto &pr : m) { + mm.f1.push_back(pr.first); + mm.f2.push_back(pr.second); + } + matches.push_back(std::move(mm)); + } + } + + inline void GraphMatch::GetMatch(int MatchNo, ivector &FV1, ivector &FV2, + int &nv, realtype &p1, realtype &p2) { + if (MatchNo < 0 || MatchNo >= (int)matches.size()) { + FV1 = FV2 = nullptr; + nv = 0; + p1 = p2 = 0; + return; + } + if ((int)fv1.size() != (int)matches.size()) { + fv1.resize(matches.size()); + fv2.resize(matches.size()); + } + Match &m = matches[MatchNo]; + nv = (int)m.f1.size(); + std::vector &a = fv1[MatchNo]; + std::vector &b = fv2[MatchNo]; + a.assign(nv + 1, 0); + b.assign(nv + 1, 0); // 1-indexed: [1..nv] valid + for (int i = 0; i < nv; ++i) { + a[i + 1] = m.f1[i]; + b[i + 1] = m.f2[i]; + } + FV1 = a.data(); + FV2 = b.data(); + p1 = p2 = (realtype)nv; + } + + // ---- MakeGraph from atoms (distance-based bonds) ------------------------- + inline int Graph::MakeGraph(PPAtom atom, int nAtoms) { + for (auto *p : V) delete p; + for (auto *e : E) delete e; + V.clear(); + E.clear(); + adj.clear(); + if (nAtoms <= 0) return MKGRAPH_NoAtoms; + for (int i = 0; i < nAtoms; ++i) { + Vertex *v = new Vertex(atom[i]->GetElementName(), atom[i]->GetAtomName()); + v->user_id = i; // 0-based atom index for atom-table lookup + V.push_back(v); + } + // covalent-ish bonds by distance (< 1.9 A) — gemmi has no residue bond table + for (int i = 0; i < nAtoms; ++i) + for (int j = i + 1; j < nAtoms; ++j) { + double dx = atom[i]->x() - atom[j]->x(); + double dy = atom[i]->y() - atom[j]->y(); + double dz = atom[i]->z() - atom[j]->z(); + if (dx * dx + dy * dy + dz * dz < 1.9 * 1.9) + E.push_back(new Edge(i + 1, j + 1, BOND_SINGLE)); + } + return MKGRAPH_Ok; + } + inline int Graph::MakeGraph(PResidue R, cpstr /*altLoc*/) { + if (!R) return MKGRAPH_NoAtoms; + PPAtom a = nullptr; + int n = 0; + R->GetAtomTable(a, n); + return MakeGraph(a, n); + } + + // ========================================================================= + // Alignment — global (Needleman-Wunsch) sequence alignment (mmdb_math_align.h). + // Coot uses it to align a model sequence to a target and read back the gapped + // strings + score (for mutation/indel detection, api/coot-molecule.cc). + // + // NOTE on prefer-gemmi: gemmi DOES provide sequence alignment (align.hpp / + // seqalign.hpp), but only over a substitution-scoring matrix. MMDB's aligner — + // which Coot's mutation detection was tuned against — uses simple identity + // scoring (match=1 / mismatch=0 / linear gap). Swapping in gemmi's scorer would + // change which residues are called mutations vs. indels, i.e. it would NOT + // reproduce the MMDB baseline this shim exists to preserve. So this stays a + // faithful re-creation of MMDB's *specific* simple-scoring global aligner — + // the exact form gemmi does not offer — rather than a gratuitous reimplementation. + // ========================================================================= + class Alignment { + public: + std::string _s, _t; // aligned (gapped) sequences + realtype VAchieved = 0; // alignment score + + void Align(cpstr S, cpstr T, realtype /*VGap*/ = 0.0, realtype VSpace = -1.0) { + std::string a(S ? S : ""), b(T ? T : ""); + int n = (int)a.size(), m = (int)b.size(); + const realtype MATCH = 1.0, MIS = 0.0, GAP = VSpace != 0.0 ? VSpace : -1.0; + std::vector> D(n + 1, std::vector(m + 1, 0.0)); + for (int i = 1; i <= n; ++i) D[i][0] = D[i - 1][0] + GAP; + for (int j = 1; j <= m; ++j) D[0][j] = D[0][j - 1] + GAP; + for (int i = 1; i <= n; ++i) + for (int j = 1; j <= m; ++j) { + realtype diag = D[i - 1][j - 1] + (a[i - 1] == b[j - 1] ? MATCH : MIS); + realtype up = D[i - 1][j] + GAP, left = D[i][j - 1] + GAP; + D[i][j] = std::max(diag, std::max(up, left)); + } + VAchieved = D[n][m]; + std::string as, bs; // traceback + int i = n, j = m; + while (i > 0 || j > 0) { + if (i > 0 && j > 0 && + D[i][j] == D[i - 1][j - 1] + (a[i - 1] == b[j - 1] ? MATCH : MIS)) { + as += a[i - 1]; + bs += b[j - 1]; + --i; + --j; + } else if (i > 0 && D[i][j] == D[i - 1][j] + GAP) { + as += a[i - 1]; + bs += '-'; + --i; + } else { + as += '-'; + bs += b[j - 1]; + --j; + } + } + std::reverse(as.begin(), as.end()); + std::reverse(bs.begin(), bs.end()); + _s = as; + _t = bs; + } + pstr GetAlignedS() { return (pstr)_s.c_str(); } + pstr GetAlignedT() { return (pstr)_t.c_str(); } + realtype GetScore() { return VAchieved; } + }; + + } // namespace math +} // namespace mmdb + +#endif // COOT_MMDB_SHIM_GRAPH_IMPL_HH diff --git a/mmdb-shim/include/mmdb2/_mmcif_impl.hh b/mmdb-shim/include/mmdb2/_mmcif_impl.hh new file mode 100644 index 0000000000..8da7f7514c --- /dev/null +++ b/mmdb-shim/include/mmdb2/_mmcif_impl.hh @@ -0,0 +1,721 @@ +// -*- mode: c++; -*- +// +// mmdb-shim: mmdb::mmcif::* implemented as a thin veneer over gemmi::cif. +// See coot-shim-prefer-gemmi memory: NEVER hand-write CIF parsing — gemmi does +// the real work; this only presents the MMDB-shaped API Coot's geometry/ uses. +// +// Copyright 2026 by Medical Research Council Laboratory of Molecular Biology +// +// Included at the end of _shim_impl.hh (so pstr/cpstr/realtype already exist). +#ifndef COOT_MMDB_SHIM_MMCIF_IMPL_HH +#define COOT_MMDB_SHIM_MMCIF_IMPL_HH + +#include +#include // gemmi::cif::read_file +#include // gemmi::cif::write_cif_to_stream + +#include +#include +#include +#include +#include +#include + +namespace mmdb { + namespace mmcif { + + // ---- return codes (mirror mmdb_mmcif_.h) -------------------------------- + enum { + CIFRC_Loop = 2, + CIFRC_Structure = 1, + CIFRC_Ok = 0, + CIFRC_StructureNoTag = -1, + CIFRC_LoopNoTag = -2, + CIFRC_NoCategory = -3, + CIFRC_WrongFormat = -4, + CIFRC_NoTag = -5, + CIFRC_NotAStructure = -6, + CIFRC_NotALoop = -7, + CIFRC_WrongIndex = -8, + CIFRC_NoField = -9, + CIFRC_Created = -12, + CIFRC_CantOpenFile = -13, + CIFRC_NoDataLine = -14, + CIFRC_NoData = -15 + }; + + // ---- file flags ---------------------------------------------------------- + enum { + CIFFL_PrintWarnings = 0x00000001, + CIFFL_StopOnWarnings = 0x00000002, + CIFFL_SuggestCategories = 0x00000004, + CIFFL_SuggestTags = 0x00000008 + }; + + enum MMCIF_ITEM { + MMCIF_None = 0, + MMCIF_Struct = 1, + MMCIF_Loop = 2, + MMCIF_Data = 3, + MMCIF_Category = 4 + }; + + class Loop; + class Struct; + class Category; + class Data; + class File; + typedef Loop *PLoop; + typedef Struct *PStruct; + typedef Category *PCategory; + typedef Data *PData; + typedef File *PFile; + + namespace detail { + // MMDB category names have no trailing dot; gemmi wants "_cat." — normalise + // to WITH-dot internally so full tag = cat + subtag. + inline std::string with_dot(const char *cat) { + std::string s(cat ? cat : ""); + if (s.empty() || s.back() != '.') s += '.'; + return s; + } + inline std::string strip_dot(const std::string &s) { + if (!s.empty() && s.back() == '.') return s.substr(0, s.size() - 1); + return s; + } + } // namespace detail + + // ========================================================================= + // Category — just a named handle (Coot uses GetCategoryName / GetCategoryID) + // ========================================================================= + class Category { + public: + std::string cat; // WITH trailing dot + MMCIF_ITEM kind = MMCIF_Category; + std::deque sret; + Category() {} + pstr GetCategoryName() { + sret.push_back(detail::strip_dot(cat)); + return (pstr)sret.back().c_str(); + } + MMCIF_ITEM GetCategoryID() { return kind; } + }; + + // ========================================================================= + // Loop + // ========================================================================= + class Loop { + public: + Data *owner = nullptr; // null for a bare `new Loop` + std::string cat; // WITH trailing dot + gemmi::cif::Loop *direct = nullptr; // FindLoop binds the gemmi loop directly + bool write_mode = false; + // write buffer (row-major); sub-tags only (no category prefix) + std::vector wtags; + std::vector> wrows; + // storage for borrowed pstr returns (Coot never frees these) + std::deque sret; + + Loop() {} + + gemmi::cif::Loop *gloop() const; // read loop, or nullptr (defined after Data) + + int GetLoopLength(); + int GetNofTags(); + pstr GetTag(int tagNo); + pstr GetField(int rowNo, int tagNo); + + pstr GetString(cpstr TName, int nrow, int &RC); + int GetReal(realtype &R, cpstr TName, int nrow, bool Remove = false); + int GetInteger(int &I, cpstr TName, int nrow, bool Remove = false); + + void AddLoopTag(cpstr T, bool Remove = true) { + (void)Remove; + wcol(T, true); + } + void PutString(cpstr S, cpstr T, int nrow) { wput(T, nrow, S ? S : "."); } + void PutInteger(int I, cpstr T, int nrow) { wput(T, nrow, std::to_string(I)); } + void PutReal(realtype R, cpstr T, int nrow, int prec = 8) { + char b[64]; + std::snprintf(b, sizeof b, "%.*f", prec, (double)R); + wput(T, nrow, b); + } + void PutReal(realtype R, cpstr T, int nrow, cpstr /*format*/) { PutReal(R, T, nrow, 8); } + + // write helpers + int wcol(cpstr T, bool create); + void wput(cpstr T, int nrow, const std::string &val); + void flush(gemmi::cif::Block &b); + }; + + inline int Loop::wcol(cpstr T, bool create) { + for (size_t i = 0; i < wtags.size(); ++i) + if (wtags[i] == T) return (int)i; + if (!create) return -1; + wtags.push_back(T); + for (auto &row : wrows) row.resize(wtags.size()); + return (int)wtags.size() - 1; + } + + inline void Loop::wput(cpstr T, int nrow, const std::string &val) { + write_mode = true; + int col = wcol(T, true); + if (nrow < 0) nrow = 0; + while ((int)wrows.size() <= nrow) wrows.emplace_back(wtags.size()); + wrows[nrow][col] = val; + } + + inline void Loop::flush(gemmi::cif::Block &b) { + if (wtags.empty()) return; + gemmi::cif::Loop &gl = b.init_mmcif_loop(cat, wtags); // tags become cat+subtag + gl.values.clear(); + gl.values.reserve(wrows.size() * wtags.size()); + for (auto &row : wrows) + for (size_t c = 0; c < wtags.size(); ++c) { + const std::string &v = c < row.size() ? row[c] : std::string(); + gl.values.push_back(v.empty() ? "." : gemmi::cif::quote(v)); + } + } + + inline int Loop::GetLoopLength() { + gemmi::cif::Loop *g = gloop(); + return g ? (int)g->length() : (int)wrows.size(); + } + inline int Loop::GetNofTags() { + gemmi::cif::Loop *g = gloop(); + return g ? (int)g->width() : (int)wtags.size(); + } + + // ========================================================================= + // Struct (single-value category = a set of tag/value pairs) + // ========================================================================= + class Struct { + public: + Data *owner = nullptr; + std::string cat; // WITH trailing dot + bool write_mode = false; + std::vector> wpairs; + std::deque sret; + + Struct() {} + + pstr GetCategoryName() { + sret.push_back(detail::strip_dot(cat)); + return (pstr)sret.back().c_str(); + } + + int GetNofTags(); + pstr GetTag(int tagNo); + pstr GetField(int tagNo); + pstr GetString(cpstr TName, int &RC); + int GetReal(realtype &R, cpstr TName, bool Remove = false); + int GetInteger(int &I, cpstr TName, bool Remove = false); + + void PutString(cpstr S, cpstr TName, bool /*Concatenate*/ = false) { + write_mode = true; + wpairs.emplace_back(TName, S ? S : "."); + } + void PutReal(realtype R, cpstr TName, int prec = 8) { + char b[64]; + std::snprintf(b, sizeof b, "%.*f", prec, (double)R); + write_mode = true; + wpairs.emplace_back(TName, b); + } + void PutReal(realtype R, cpstr TName, cpstr /*format*/) { PutReal(R, TName, 8); } + void PutInteger(int I, cpstr TName) { + write_mode = true; + wpairs.emplace_back(TName, std::to_string(I)); + } + + std::vector collect_tags(); // read: sub-tags present in block + void flush(gemmi::cif::Block &b); + }; + + // ========================================================================= + // Data (a data_ block) + // ========================================================================= + class Data { + public: + gemmi::cif::Document *doc = nullptr; // resolve block by INDEX (blocks vector reallocs) + size_t idx = 0; + std::unique_ptr owned_doc; // for a standalone `new Data()` + + std::deque loops; + std::deque structs; + std::deque cats_pool; + std::unordered_map loop_by_cat; + std::unordered_map struct_by_cat; + std::vector cat_names; // WITH dot + bool cats_built = false; + std::deque sret; + + Data() {} + + gemmi::cif::Block &blk() { return doc->blocks[idx]; } + + // standalone read (Coot: `Data d; d.ReadMMCIFData(fname)`) — own a Document and + // point at its first block. Used for small-molecule CIFs. + int SetFlag(int /*flag*/) { return 0; } // parse flags are gemmi-internal — no-op + int ReadMMCIFData(cpstr fname) { + try { + owned_doc.reset(new gemmi::cif::Document(gemmi::cif::read_file(fname ? fname : ""))); + } catch (const std::exception &) { + return CIFRC_CantOpenFile; + } + if (owned_doc->blocks.empty()) return CIFRC_NoDataLine; + doc = owned_doc.get(); + idx = 0; + cats_built = false; + return CIFRC_Ok; + } + // find the loop containing tags[0] (a null-terminated tag array; core-CIF flat + // tags). Binds the gemmi loop directly (cat="" so GetString uses full tags). + // Coot passes both `pstr[]` and `const char*[]`, so accept cpstr. + PLoop FindLoop(cpstr *tags) { + if (!tags || !tags[0]) return nullptr; + gemmi::cif::Loop *gl = blk().find_loop(tags[0]).get_loop(); + if (!gl) return nullptr; + loops.emplace_back(); + Loop &l = loops.back(); + l.owner = this; + l.cat = ""; + l.direct = gl; + return &l; + } + PLoop FindLoop(pstr *tags) { return FindLoop((cpstr *)tags); } + + void build_cats() { + if (cats_built) return; + cat_names = blk().get_mmcif_category_names(); // returns WITH trailing dot + cats_built = true; + } + + pstr GetDataName() { + sret.push_back(blk().name); + return (pstr)sret.back().c_str(); + } + void GetDataName(pstr &dname, bool /*Remove*/ = false) { + sret.push_back(blk().name); + dname = (pstr)sret.back().c_str(); + } + void PutDataName(cpstr dname) { blk().name = dname ? dname : ""; } + + int GetNumberOfCategories() { + build_cats(); + return (int)cat_names.size(); + } + + PCategory GetCategory(int categoryNo) { + build_cats(); + if (categoryNo < 0 || (size_t)categoryNo >= cat_names.size()) return nullptr; + cats_pool.emplace_back(); + Category &c = cats_pool.back(); + c.cat = cat_names[categoryNo]; + gemmi::cif::Table t = blk().find_mmcif_category(c.cat); + c.kind = t.get_loop() ? MMCIF_Loop : MMCIF_Struct; + return &c; + } + + PLoop GetLoop(cpstr CName) { + std::string key = detail::with_dot(CName); + auto it = loop_by_cat.find(key); + if (it != loop_by_cat.end()) return it->second; + if (!blk().find_mmcif_category(key).get_loop()) return nullptr; // absent or a struct + loops.emplace_back(); + Loop &l = loops.back(); + l.owner = this; + l.cat = key; + l.write_mode = false; + loop_by_cat[key] = &l; + return &l; + } + + PStruct GetStructure(cpstr CName) { + std::string key = detail::with_dot(CName); + auto it = struct_by_cat.find(key); + if (it != struct_by_cat.end()) return it->second; + if (!blk().has_mmcif_category(key)) return nullptr; + if (blk().find_mmcif_category(key).get_loop()) return nullptr; // it's a loop + structs.emplace_back(); + Struct &s = structs.back(); + s.owner = this; + s.cat = key; + s.write_mode = false; + struct_by_cat[key] = &s; + return &s; + } + + int GetLoopLength(cpstr CName) { + PLoop l = GetLoop(CName); + return l ? l->GetLoopLength() : CIFRC_NoCategory; + } + + // full mmCIF tag from (CName, TName): if CName is empty, TName is already the + // full tag (small-molecule CIFs pass "" + "_cell_length_a"). + std::string full_tag(cpstr CName, cpstr TName) { + std::string t = TName ? TName : ""; + return (CName && CName[0]) ? detail::with_dot(CName) + t : t; + } + // struct-style direct access (Data::GetString(CName, TName, RC) etc.) + pstr GetString(cpstr CName, cpstr TName, int &RC) { + const std::string *v = blk().find_value(full_tag(CName, TName)); + if (!v) { + RC = CIFRC_NoTag; + return nullptr; + } + RC = CIFRC_Ok; + if (gemmi::cif::is_null(*v)) return nullptr; + sret.push_back(gemmi::cif::as_string(*v)); + return (pstr)sret.back().c_str(); + } + // pstr& form: sets S to the value, returns a CIFRC code (Coot: ierr += ...) + int GetString(pstr &S, cpstr CName, cpstr TName, bool /*Remove*/ = false) { + int rc = 0; + S = GetString(CName, TName, rc); + return rc; + } + int GetReal(realtype &R, cpstr CName, cpstr TName, bool /*Remove*/ = false) { + R = 0; + const std::string *v = blk().find_value(full_tag(CName, TName)); + if (!v) return CIFRC_NoTag; + if (gemmi::cif::is_null(*v)) return CIFRC_NoData; + try { + R = std::stod(gemmi::cif::as_string(*v)); + } catch (...) { + return CIFRC_WrongFormat; + } + return CIFRC_Ok; + } + int GetInteger(int &I, cpstr CName, cpstr TName, bool /*Remove*/ = false) { + I = 0; + const std::string *v = blk().find_value(full_tag(CName, TName)); + if (!v) return CIFRC_NoTag; + if (gemmi::cif::is_null(*v)) return CIFRC_NoData; + try { + I = std::stoi(gemmi::cif::as_string(*v)); + } catch (...) { + return CIFRC_WrongFormat; + } + return CIFRC_Ok; + } + + int AddLoop(cpstr CName, PLoop &cifLoop) { + std::string key = detail::with_dot(CName); + auto it = loop_by_cat.find(key); + if (it != loop_by_cat.end()) { + cifLoop = it->second; + return CIFRC_Ok; + } + loops.emplace_back(); + Loop &l = loops.back(); + l.owner = this; + l.cat = key; + l.write_mode = true; + loop_by_cat[key] = &l; + cifLoop = &l; + return CIFRC_Created; + } + int AddStructure(cpstr CName, PStruct &cifStruct) { + std::string key = detail::with_dot(CName); + auto it = struct_by_cat.find(key); + if (it != struct_by_cat.end()) { + cifStruct = it->second; + return CIFRC_Ok; + } + structs.emplace_back(); + Struct &s = structs.back(); + s.owner = this; + s.cat = key; + s.write_mode = true; + struct_by_cat[key] = &s; + cifStruct = &s; + return CIFRC_Created; + } + + void flush() { + for (auto &l : loops) + if (l.write_mode) l.flush(blk()); + for (auto &s : structs) + if (s.write_mode) s.flush(blk()); + } + }; + + // ---- Loop methods that need a complete Data ----------------------------- + inline gemmi::cif::Loop *Loop::gloop() const { + if (direct) return direct; // FindLoop-bound (core CIF) + if (write_mode || !owner) return nullptr; + return owner->blk().find_mmcif_category(cat).get_loop(); + } + + inline pstr Loop::GetString(cpstr TName, int nrow, int &RC) { + gemmi::cif::Loop *g = gloop(); + if (!g) { + RC = CIFRC_NotALoop; + return nullptr; + } + int col = g->find_tag(cat + TName); + if (col < 0) { + RC = CIFRC_NoTag; + return nullptr; + } + if (nrow < 0 || (size_t)nrow >= g->length()) { + RC = CIFRC_WrongIndex; + return nullptr; + } + const std::string &raw = g->val(nrow, col); + RC = CIFRC_Ok; + if (gemmi::cif::is_null(raw)) return nullptr; + sret.push_back(gemmi::cif::as_string(raw)); + return (pstr)sret.back().c_str(); + } + inline int Loop::GetReal(realtype &R, cpstr TName, int nrow, bool /*Remove*/) { + R = 0; + gemmi::cif::Loop *g = gloop(); + if (!g) return CIFRC_NotALoop; + int col = g->find_tag(cat + TName); + if (col < 0) return CIFRC_NoTag; + if (nrow < 0 || (size_t)nrow >= g->length()) return CIFRC_WrongIndex; + const std::string &raw = g->val(nrow, col); + if (gemmi::cif::is_null(raw)) return CIFRC_NoData; + try { + R = std::stod(gemmi::cif::as_string(raw)); + } catch (...) { + return CIFRC_WrongFormat; + } + return CIFRC_Ok; + } + inline int Loop::GetInteger(int &I, cpstr TName, int nrow, bool /*Remove*/) { + I = 0; + gemmi::cif::Loop *g = gloop(); + if (!g) return CIFRC_NotALoop; + int col = g->find_tag(cat + TName); + if (col < 0) return CIFRC_NoTag; + if (nrow < 0 || (size_t)nrow >= g->length()) return CIFRC_WrongIndex; + const std::string &raw = g->val(nrow, col); + if (gemmi::cif::is_null(raw)) return CIFRC_NoData; + try { + I = std::stoi(gemmi::cif::as_string(raw)); + } catch (...) { + return CIFRC_WrongFormat; + } + return CIFRC_Ok; + } + inline pstr Loop::GetTag(int tagNo) { + gemmi::cif::Loop *g = gloop(); + if (!g) { + if (tagNo < 0 || (size_t)tagNo >= wtags.size()) return nullptr; + sret.push_back(wtags[tagNo]); + return (pstr)sret.back().c_str(); + } + if (tagNo < 0 || (size_t)tagNo >= g->tags.size()) return nullptr; + std::string t = g->tags[tagNo]; + if (t.size() > cat.size() && t.compare(0, cat.size(), cat) == 0) t = t.substr(cat.size()); + sret.push_back(t); + return (pstr)sret.back().c_str(); + } + inline pstr Loop::GetField(int rowNo, int tagNo) { + gemmi::cif::Loop *g = gloop(); + if (!g) return nullptr; + if (tagNo < 0 || (size_t)tagNo >= g->width()) return nullptr; + if (rowNo < 0 || (size_t)rowNo >= g->length()) return nullptr; + const std::string &raw = g->val(rowNo, tagNo); + if (gemmi::cif::is_null(raw)) return nullptr; + sret.push_back(gemmi::cif::as_string(raw)); + return (pstr)sret.back().c_str(); + } + + // ---- Struct methods that need a complete Data --------------------------- + inline std::vector Struct::collect_tags() { + std::vector out; + if (!owner) return out; + for (const gemmi::cif::Item &it : owner->blk().items) + if (it.type == gemmi::cif::ItemType::Pair && + it.pair[0].compare(0, cat.size(), cat) == 0) + out.push_back(it.pair[0].substr(cat.size())); + return out; + } + inline int Struct::GetNofTags() { return (int)collect_tags().size(); } + inline pstr Struct::GetTag(int tagNo) { + std::vector t = collect_tags(); + if (tagNo < 0 || (size_t)tagNo >= t.size()) return nullptr; + sret.push_back(t[tagNo]); + return (pstr)sret.back().c_str(); + } + inline pstr Struct::GetField(int tagNo) { + std::vector t = collect_tags(); + if (tagNo < 0 || (size_t)tagNo >= t.size()) return nullptr; + int rc = 0; + pstr s = GetString(t[tagNo].c_str(), rc); + // The tag is enumerated (exists), but its value may be a CIF null (`?`/`.`), + // for which GetString returns null. MMDB's GetField never returns null for an + // in-range tag, and callers (e.g. gphl_chem_comp_info) wrap it straight into + // std::string — so hand back an empty (non-null) field instead of crashing. + if (!s) { + sret.emplace_back(); + s = (pstr)sret.back().c_str(); + } + return s; + } + inline pstr Struct::GetString(cpstr TName, int &RC) { + if (!owner) { + RC = CIFRC_NoTag; + return nullptr; + } + const std::string *v = owner->blk().find_value(cat + TName); + if (!v) { + RC = CIFRC_NoTag; + return nullptr; + } + RC = CIFRC_Ok; + if (gemmi::cif::is_null(*v)) return nullptr; + sret.push_back(gemmi::cif::as_string(*v)); + return (pstr)sret.back().c_str(); + } + inline int Struct::GetReal(realtype &R, cpstr TName, bool /*Remove*/) { + R = 0; + if (!owner) return CIFRC_NoTag; + const std::string *v = owner->blk().find_value(cat + TName); + if (!v) return CIFRC_NoTag; + if (gemmi::cif::is_null(*v)) return CIFRC_NoData; + try { + R = std::stod(gemmi::cif::as_string(*v)); + } catch (...) { + return CIFRC_WrongFormat; + } + return CIFRC_Ok; + } + inline int Struct::GetInteger(int &I, cpstr TName, bool /*Remove*/) { + I = 0; + if (!owner) return CIFRC_NoTag; + const std::string *v = owner->blk().find_value(cat + TName); + if (!v) return CIFRC_NoTag; + if (gemmi::cif::is_null(*v)) return CIFRC_NoData; + try { + I = std::stoi(gemmi::cif::as_string(*v)); + } catch (...) { + return CIFRC_WrongFormat; + } + return CIFRC_Ok; + } + inline void Struct::flush(gemmi::cif::Block &b) { + for (auto &tv : wpairs) + b.set_pair(cat + tv.first, gemmi::cif::quote(tv.second)); + } + + // ========================================================================= + // File (a whole CIF document) + // ========================================================================= + class File { + public: + gemmi::cif::Document doc; + std::deque datas; + std::deque sret; + + File() {} + + void rebuild() { + datas.clear(); + for (size_t i = 0; i < doc.blocks.size(); ++i) { + datas.emplace_back(); + datas.back().doc = &doc; + datas.back().idx = i; + } + } + + int ReadMMCIFFile(cpstr FName, int /*flags*/ = 0) { + try { + doc = gemmi::cif::read_file(FName ? FName : ""); + } catch (const std::exception &) { + return CIFRC_CantOpenFile; + } + rebuild(); + return CIFRC_Ok; + } + + int WriteMMCIFFile(cpstr FName, int /*flags*/ = 0) { + for (auto &d : datas) d.flush(); + std::ofstream os(FName ? FName : ""); + if (!os) return CIFRC_CantOpenFile; + gemmi::cif::write_cif_to_stream(os, doc, gemmi::cif::WriteOptions()); + return 0; + } + + int GetNofData() { return (int)datas.size(); } + int GetNumberOfData() { return (int)datas.size(); } + + PData GetCIFData(int dataNo) { + if (dataNo < 0 || (size_t)dataNo >= datas.size()) return nullptr; + return &datas[dataNo]; + } + PData GetCIFData(cpstr name) { + std::string n(name ? name : ""); + for (auto &d : datas) + if (d.blk().name == n) return &d; + return nullptr; + } + + int AddCIFData(cpstr name) { + std::string n(name ? name : ""); + if (doc.find_block(n)) return CIFRC_Ok; + doc.add_new_block(n); + // index-based Data wrappers survive blocks-vector reallocation, so just + // append one for the new block (do NOT rebuild — that would drop buffered + // write state of earlier Data objects). + datas.emplace_back(); + datas.back().doc = &doc; + datas.back().idx = doc.blocks.size() - 1; + return CIFRC_Created; + } + }; + + // ---- free helpers -------------------------------------------------------- + inline pstr GetCIFMessage(pstr buffer, int rc) { + const char *m = "unknown mmCIF return code"; + switch (rc) { + case CIFRC_Ok: + m = "no errors"; + break; + case CIFRC_NoCategory: + m = "category not found"; + break; + case CIFRC_NoTag: + m = "tag not found"; + break; + case CIFRC_NoField: + m = "field not found"; + break; + case CIFRC_WrongFormat: + m = "wrong value format"; + break; + case CIFRC_WrongIndex: + m = "row index out of range"; + break; + case CIFRC_NotALoop: + m = "category is not a loop"; + break; + case CIFRC_NotAStructure: + m = "category is not a structure"; + break; + case CIFRC_NoData: + m = "no data"; + break; + case CIFRC_CantOpenFile: + m = "cannot open file"; + break; + case CIFRC_NoDataLine: + m = "no data_ line"; + break; + case CIFRC_Created: + m = "category created"; + break; + default: + break; + } + std::strcpy(buffer, m); + return buffer; + } + + } // namespace mmcif +} // namespace mmdb + +#endif // COOT_MMDB_SHIM_MMCIF_IMPL_HH diff --git a/mmdb-shim/include/mmdb2/_shim_hierarchy.hh b/mmdb-shim/include/mmdb2/_shim_hierarchy.hh new file mode 100644 index 0000000000..27ccf45dd2 --- /dev/null +++ b/mmdb-shim/include/mmdb2/_shim_hierarchy.hh @@ -0,0 +1,612 @@ +// mmdb-shim — layer 2 of 4: the coordinate hierarchy (Atom / Residue / Chain / +// Model). +// +// These classes ARE the stable wrapper nodes: each holds Manager* + parent* + a +// cached sibling index, resolves to the live gemmi object via g(), and exposes its +// children as a canonical vector that doubles as the identity cache AND the +// PPAtom/PPResidue table MMDB hands back. A wrapper with no parent is "detached" +// and backs onto a wrapper-owned _local gemmi object until Add*() adopts it. +// +// Only class definitions live here; method bodies that need a complete Manager (or +// sibling class) are declared here and defined out-of-line in _shim_inline.hh. +#pragma once + +#include "_shim_types.hh" + +namespace mmdb { + + // =========================================================================== + class Atom : public UDStore { + public: + Manager *mgr = nullptr; + Residue *res = nullptr; // parent; null => detached (use _local) + int ai = 0; // cached index within parent residue's atoms + bool alive = true; + gemmi::Atom _local; // backing store while detached (see g() resolvers) + int Het = 0; // heteroatom flag (MMDB public field; Coot sets it) + int Ter = 0; // chain-terminator flag (gemmi has none -> always 0) + word WhatIsSet = 0; // ASET_* mask; ASET_Anis_tFac set on load if aniso present + AtomName label_atom_id{}; // mmcif label_atom_id (shim-owned; Coot sets on build) + + Atom() = default; + explicit Atom(Residue *r); // construct + add to residue (out-of-line) + // MMDB owns atoms via `new`/`delete`: Coot writes `delete atom;` to remove an + // atom from the hierarchy (coot-molecule.cc et al.). So atoms are individually + // heap-allocated (Manager::newAtom) and tracked in Manager::_atom_allocs; this + // destructor detaches from the parent residue + flat lists + selections when a + // live atom is deleted, and is a no-op during Manager teardown (_bulk_free). + ~Atom(); // out-of-line (needs complete Manager/Residue) + + gemmi::Atom &g() const; // resolve to live gemmi (defined after Manager) + + // --- rewritten field accessors (pure B) --- + // Scalar fields -> reference-returning accessors, so a uniform `->field`-> + // `->field()` rewrite covers both reads and writes. (occ/b_iso/charge are + // narrower than realtype in gemmi, so those refs are float/schar-typed — the + // rare take-address-of-realtype sites surface at Coot build time.) + // non-const (writable ref) + const (by value) overloads, so reads work on a + // `const mmdb::Atom` and writes work through `->x() = v` on a non-const one. + realtype &x() { return g().pos.x; } + realtype x() const { return g().pos.x; } + realtype &y() { return g().pos.y; } + realtype y() const { return g().pos.y; } + realtype &z() { return g().pos.z; } + realtype z() const { return g().pos.z; } + float &occupancy() { return g().occ; } + float occupancy() const { return g().occ; } + float &tempFactor() { return g().b_iso; } + float tempFactor() const { return g().b_iso; } + signed char &charge() { return g().charge; } + signed char charge() const { return g().charge; } + int &serNum() { return g().serial; } + int serNum() const { return g().serial; } + // altLoc is a char[] (C-string) in MMDB; gemmi stores a single char. Return a + // buffer-backed C-string ("" when unset) so strcmp/strcpy-style code works. + // The non-const overload returns a WRITABLE buffer so `strncpy(at->altLoc(),..)` + // compiles; the buffer's first char is pushed back into gemmi by Residue::AddAtom + // (the buffer is refreshed from gemmi on entry, so reads stay correct). + pstr altLoc() { + _altloc_buf[0] = g().altloc; + _altloc_buf[1] = '\0'; + return _altloc_buf; + } + const char *altLoc() const { + _altloc_buf[0] = g().altloc; + _altloc_buf[1] = '\0'; + return _altloc_buf; + } + void set_occupancy(realtype v) { g().occ = (float)v; } + void set_tempFactor(realtype v) { g().b_iso = (float)v; } + void set_altLoc(char c) { g().altloc = c; } + void SetCharge(realtype ch) { g().charge = (signed char)ch; } + // coordinate/occupancy/B ESDs (MMDB public fields) — gemmi has none, so shim- + // owned; reference-returning so the rewritten `->sigX` covers reads and writes. + float &sigX() { return _sigx; } + float &sigY() { return _sigy; } + float &sigZ() { return _sigz; } + float &sigOcc() { return _sigocc; } + float &sigTemp() { return _sigtemp; } + bool isMetal() const { return gemmi::Element(g().element).is_metal(); } + // anisotropic B tensor — gemmi's SMat33 aniso. Reference-returning so the + // rewritten `->u11` covers both reads and writes. The mutable accessor marks the + // tensor present (ASET_Anis_tFac) so a write (e.g. SHELX import) sets the flag as + // real MMDB does. Const reads never set it; a non-const read over-approximates, + // which is harmless — the PDB/mmCIF writer emits ANISOU on the actual values. + float &u11() { + WhatIsSet |= ASET_Anis_tFac; + return g().aniso.u11; + } + float &u22() { + WhatIsSet |= ASET_Anis_tFac; + return g().aniso.u22; + } + float &u33() { + WhatIsSet |= ASET_Anis_tFac; + return g().aniso.u33; + } + float &u12() { + WhatIsSet |= ASET_Anis_tFac; + return g().aniso.u12; + } + float &u13() { + WhatIsSet |= ASET_Anis_tFac; + return g().aniso.u13; + } + float &u23() { + WhatIsSet |= ASET_Anis_tFac; + return g().aniso.u23; + } + float u11() const { return g().aniso.u11; } + float u22() const { return g().aniso.u22; } + float u33() const { return g().aniso.u33; } + float u12() const { return g().aniso.u12; } + float u13() const { return g().aniso.u13; } + float u23() const { return g().aniso.u23; } + // bonds — not modelled yet (gemmi connections); report none. + int GetNBonds() { return 0; } + void GetBonds(PAtomBond &atomBond, int &n) { + atomBond = nullptr; + n = 0; + } + int AddBond(PAtom /*a*/, int /*order*/, int /*nAdd*/ = 1) { return 0; } + SegID segID{}; // shim-owned (gemmi has no segID); MMDB public char[] field + + // --- method surface (hot subset; rest stubbed) --- + pstr GetAtomName() const; // aligned name, MMDB semantics (const: called on const Atom) + void SetAtomName(const AtomName aName); + pstr GetElementName(); + void SetElementName(const Element elName); + pstr GetChainID(); + int GetSeqNum(); + pstr GetInsCode(); + pstr GetResName(); + Residue *&GetResidue() { return res; } // ref: rewritten `->residue` is assignable + void SetResidue(Residue *r) { res = r; } + Chain *GetChain(); // out-of-line (needs complete Residue/Chain) + Model *GetModel(); // out-of-line + int GetModelNum(); + // residue-delegating accessors (bound by the Python API); out-of-line. + pstr GetLabelCompID(); + pstr GetLabelAsymID(); + int GetLabelSeqID(); + int GetLabelEntityID(); + int GetResidueNo(); + int GetSSEType(); + bool isSolvent(); + bool isNTerminus(); + bool isCTerminus(); + bool isTer() const { return false; } // gemmi has no TER atoms; see notes + void SetCoordinates(realtype xx, realtype yy, realtype zz, + realtype occ, realtype tF); + int GetIndex(); + void MakeTer() { Ter = 1; } // mark as chain terminator + pstr GetAtomID(pstr S); // "/mdl/chain/seq(res).ins/name[elem]:alt" (out-of-line) + int GetUDData(int h, pstr &v) { return ud_get(mgr, UDR_ATOM, *this, h, v); } + // copy another atom's data into this one (mmdb Atom::Copy — no hierarchy refs) + void Copy(PAtom a) { + g() = a->g(); + Het = a->Het; + WhatIsSet = a->WhatIsSet; + std::memcpy(segID, a->segID, sizeof segID); + } + // apply a 4x4 (rot+trans) or 3x3+vec to the coordinates (mmdb Atom::Transform) + void Transform(const mat44 &tm) { + gemmi::Position &p = g().pos; + double x = p.x, y = p.y, z = p.z; + p.x = tm[0][0] * x + tm[0][1] * y + tm[0][2] * z + tm[0][3]; + p.y = tm[1][0] * x + tm[1][1] * y + tm[1][2] * z + tm[1][3]; + p.z = tm[2][0] * x + tm[2][1] * y + tm[2][2] * z + tm[2][3]; + } + void Transform(const mat33 &tm, vect3 &v) { + gemmi::Position &p = g().pos; + double x = p.x, y = p.y, z = p.z; + p.x = tm[0][0] * x + tm[0][1] * y + tm[0][2] * z + v[0]; + p.y = tm[1][0] * x + tm[1][1] * y + tm[1][2] * z + v[1]; + p.z = tm[2][0] * x + tm[2][1] * y + tm[2][2] * z + v[2]; + } + // UDData + int PutUDData(int h, int v) { return ud_put(mgr, UDR_ATOM, *this, h, v); } + int PutUDData(int h, realtype v) { return ud_put(mgr, UDR_ATOM, *this, h, v); } + int PutUDData(int h, cpstr v) { return ud_put(mgr, UDR_ATOM, *this, h, v); } + int GetUDData(int h, int &v) { return ud_get(mgr, UDR_ATOM, *this, h, v); } + int GetUDData(int h, realtype &v) { return ud_get(mgr, UDR_ATOM, *this, h, v); } + + private: + friend class Residue; // AddAtom pushes the strncpy'd altLoc buffer to gemmi + mutable AtomName _name_buf{}; + Element _elem_buf{}; + mutable char _altloc_buf[4]{}; + float _sigx = 0, _sigy = 0, _sigz = 0, _sigocc = 0, _sigtemp = 0; + }; + + // =========================================================================== + class Residue : public UDStore { + public: + Manager *mgr = nullptr; + Chain *chain = nullptr; // parent; null => detached (use _local) + int ri = 0; + bool alive = true; + gemmi::Residue _local; // backing store while detached + std::vector atoms; // canonical child wrappers == PPAtom table + PPAtom atom = nullptr; // MMDB public atom-table field; kept = atoms.data() + int nAtoms = 0; // MMDB public field; kept = atoms.size() + void _sync_atom() { + atom = atoms.data(); + nAtoms = (int)atoms.size(); + } + // mmcif label_* (shim-owned; Coot sets when building dictionary residues) + ResName label_comp_id{}; + ChainID label_asym_id{}; + int label_seq_id = 0, label_entity_id = 0; + pstr GetLabelCompID() { return label_comp_id; } + pstr GetLabelAsymID() { return label_asym_id; } + int GetLabelSeqID() { return label_seq_id; } + int GetLabelEntityID() { return label_entity_id; } + int GetResidueNo() { return ri; } // 0-based index within its chain + int GetNofAltLocations() { // distinct non-blank altLocs + std::set a; + for (Atom *at : atoms) { + char c = at->g().altloc; + if (c && c != ' ') a.insert(c); + } + return a.empty() ? 1 : (int)a.size(); + } + // sugar / modified-residue classification via gemmi's tabulated residues. + bool isSugar() { + gemmi::ResidueKind k = gemmi::find_tabulated_residue(g().name).kind; + return k == gemmi::ResidueKind::PYR || k == gemmi::ResidueKind::KET; + } + // MMDB isModRes reflects PDB MODRES records (a non-standard, modified form of a + // standard residue). gemmi has no per-residue MODRES flag on the model tree, so + // approximate: an amino/nucleic residue whose one-letter code is lower-case + // (gemmi marks non-standard monomers that way). Water/ligands are excluded. + bool isModRes() { + const gemmi::ResidueInfo ri = gemmi::find_tabulated_residue(g().name); + return ri.found() && !ri.is_standard() && + (ri.is_amino_acid() || ri.is_nucleic_acid()); + } + + Residue() = default; + explicit Residue(Chain *c); // construct + add to chain (out-of-line) + // MMDB owns residues via `new`/`delete` (Coot writes `delete residue_p;`). Like + // ~Atom, this frees the residue's atoms, then DEFERS structural removal: it nulls + // this residue's slot in the parent chain (a tombstone) but leaves the gemmi + // placeholder residue in place so siblings' `ri` stays valid — _compact_residues + // drops both later. No-op during Manager teardown (_bulk_free). + ~Residue(); // out-of-line (needs complete Manager/Chain) + + // MMDB public char-array fields. Coot reads `residue->name` and writes + // `strncpy(residue->insCode,..)`. Kept as the interface: synced gemmi->buffer on + // load (_load_id, in build_from_gemmi) and buffer->gemmi at the adopt point + // (_store_id, in Chain::Add/InsResidue). SetResName/SetResID keep both in step. + ResName name{}; + InsCode insCode{}; + void _load_id() { + std::snprintf(name, sizeof name, "%s", g().name.c_str()); + insCode[0] = g().seqid.icode && g().seqid.icode != ' ' ? g().seqid.icode : '\0'; + insCode[1] = '\0'; + } + void _store_id() { + g().name = name; + g().seqid.icode = insCode[0] ? insCode[0] : ' '; + } + + gemmi::Residue &g() const; + + int GetNumberOfAtoms() { return (int)atoms.size(); } + int GetNumberOfAtoms(bool /*countTers*/) { return (int)atoms.size(); } + PAtom GetAtom(int atomNo) { + return (atomNo >= 0 && atomNo < (int)atoms.size()) ? atoms[atomNo] : nullptr; + } + PAtom GetAtom(const AtomName aname, const Element elname = nullptr, + const AltLoc aloc = nullptr); + void GetAtomTable(PPAtom &atomTable, int &n) { + atomTable = atoms.data(); + n = (int)atoms.size(); + } + PAtom AddAtom(Manager &m, gemmi::Atom a); // append: O(1) + // Adopt a detached atom (Coot's `new mmdb::Atom` idiom). Copies the atom's + // local gemmi into this residue's gemmi (detached or bound, via g()) and + // rebinds the wrapper. Pushes the strncpy'd altLoc buffer back into gemmi. + int AddAtom(PAtom atm); // out-of-line: needs complete Manager (_atom_allocs) + void DeleteAtom(int pos); + void _detach_atom(Atom *a); // unlink (no free); used by ~Atom on Coot `delete atom` + void TrimAtomTable() {} // compact after deletions — shim keeps them in sync + + pstr GetResName(); + void SetResName(const ResName n) { + g().name = n ? n : ""; + std::snprintf(name, sizeof name, "%s", n ? n : ""); + } + void SetResID(const ResName resName, int seqNo, const InsCode ic) { + g().name = resName ? resName : ""; + g().seqid.num.value = seqNo; + g().seqid.icode = (ic && ic[0]) ? ic[0] : ' '; + std::snprintf(name, sizeof name, "%s", resName ? resName : ""); + insCode[0] = (ic && ic[0]) ? ic[0] : '\0'; + insCode[1] = '\0'; + } + int &GetSeqNum(); // writable (rewrite maps `->seqNum` reads and writes) + pstr GetInsCode(); + pstr GetChainID(); + int GetModelNum(); + int &GetIndex() { return ri; } // ref: rewritten `->index` is assignable + Chain *GetChain() { return chain; } + Model *GetModel(); // out-of-line (Chain incomplete here) + // terminus tests — peptide-bond-aware: N-terminus if no preceding residue's C is + // within bonding distance of this N, C-terminus if this C bonds no following N + // (out-of-line: need Chain + backbone atom geometry). + bool isNTerminus(); + bool isCTerminus(); + pstr GetResidueID(pstr S) { // "seqnum(name):inscode" + if (S) std::snprintf(S, 100, "%d(%s):%s", GetSeqNum(), name, insCode); + return S; + } + Residue *next = nullptr; // MMDB has this; wired lazily if needed + int SSE = SSE_None; // secondary-structure element (shim-owned public field) + bool isAminoacid() { return gemmi::find_tabulated_residue(g().name).is_amino_acid(); } + bool isNucleotide() { return gemmi::find_tabulated_residue(g().name).is_nucleic_acid(); } + bool isDNARNA() { return isNucleotide(); } + bool isSolvent() { return gemmi::find_tabulated_residue(g().name).is_water(); } + // UDData + int PutUDData(int h, int v) { return ud_put(mgr, UDR_RESIDUE, *this, h, v); } + int PutUDData(int h, realtype v) { return ud_put(mgr, UDR_RESIDUE, *this, h, v); } + int PutUDData(int h, cpstr v) { return ud_put(mgr, UDR_RESIDUE, *this, h, v); } + int GetUDData(int h, int &v) { return ud_get(mgr, UDR_RESIDUE, *this, h, v); } + int GetUDData(int h, realtype &v) { return ud_get(mgr, UDR_RESIDUE, *this, h, v); } + + private: + ResName _resname_buf{}; + InsCode _inscode_buf{}; + }; + + // =========================================================================== + class Chain : public UDStore { + public: + Manager *mgr = nullptr; + Model *model = nullptr; // parent; null => detached (use _local) + int ci = 0; + bool alive = true; + gemmi::Chain _local; // backing store while detached + std::vector residues; + + gemmi::Chain &g() const; + + int GetNumberOfResidues() { return (int)residues.size(); } + PResidue GetResidue(int resNo) { + return (resNo >= 0 && resNo < (int)residues.size()) ? residues[resNo] : nullptr; + } + // find by (seqNum, insCode) — MMDB's 2-arg overload. Skips deferred-delete + // tombstone (null) slots. + PResidue GetResidue(int seqNum, const InsCode insCode) { + char ic = (insCode && insCode[0]) ? insCode[0] : ' '; + for (Residue *r : residues) { + if (!r) continue; // tombstone + gemmi::Residue &gr = r->g(); + char ric = gr.seqid.icode ? gr.seqid.icode : ' '; + if (gr.seqid.num.value == seqNum && ric == ic) return r; + } + return nullptr; + } + void GetResidueTable(PPResidue &t, int &n) { + t = residues.data(); + n = (int)residues.size(); + } + // MMDB DeleteResidue is DEFERRED: it frees the residue and leaves a NULL slot + // (nResidues unchanged) until TrimResidueTable/FinishStructEdit. `delete residue` + // (via ~Residue) does the same. Coot relies on this (e.g. change_chain_id iterates + // to the original count while deleting). We keep the gemmi placeholder residue too + // so surviving residues' `ri` stays aligned; _compact_residues() drops both later. + void DeleteResidue(int resNo) { + if (resNo < 0 || resNo >= (int)residues.size()) return; + if (residues[resNo]) delete residues[resNo]; // ~Residue nulls the slot + } + void DeleteResidue(int seqNum, const InsCode ic) { // by (seqNum, insCode) + PResidue r = GetResidue(seqNum, ic); + if (r) delete r; // ~Residue nulls its slot; keeps the gemmi placeholder + } + void TrimResidueTable() { _compact_residues(); } + // Drop tombstoned (null) residue slots and their gemmi placeholder residues in + // lock-step, then reindex ri. Out-of-line: needs a complete Residue. + void _compact_residues(); + pstr GetChainID(); + pstr GetChainID(pstr buf) { + if (buf) std::snprintf(buf, sizeof(ChainID), "%s", g().name.c_str()); + return buf; + } + Manager *GetCoordHierarchy() { return mgr; } // parent manager + void SetChainID(const ChainID id) { g().name = id ? id : ""; } + Chain() = default; + Chain(Model *m, const ChainID id); // construct + add to model (out-of-line) + void Copy(PChain src); // deep-copy subtree (out-of-line: needs Manager) + // Reorder residues (and their gemmi backing) ascending by (seqNum, insCode), + // MMDB's default. Keeps the wrapper vector and gemmi vector in lock-step and + // re-indexes ri. sortKey variants beyond ascending-by-number are uncommon in + // Coot and treated as the default. + void SortResidues(int /*sortKey*/ = 0) { + _compact_residues(); // never sort across deferred-delete tombstones + int n = (int)residues.size(); + if (n < 2) return; + std::vector ord(n); + for (int i = 0; i < n; ++i) ord[i] = i; + gemmi::Chain &gc = g(); + std::stable_sort(ord.begin(), ord.end(), [&](int a, int b) { + const gemmi::Residue &ra = gc.residues[a], &rb = gc.residues[b]; + if (ra.seqid.num.value != rb.seqid.num.value) return ra.seqid.num.value < rb.seqid.num.value; + char ia = ra.seqid.icode ? ra.seqid.icode : ' ', ib = rb.seqid.icode ? rb.seqid.icode : ' '; + return ia < ib; + }); + std::vector gnew; + gnew.reserve(n); + std::vector wnew; + wnew.reserve(n); + for (int k = 0; k < n; ++k) { + gnew.push_back(std::move(gc.residues[ord[k]])); + wnew.push_back(residues[ord[k]]); + } + gc.residues = std::move(gnew); + residues = std::move(wnew); + for (int k = 0; k < n; ++k) residues[k]->ri = k; + } + bool isAminoacidChain(); // defined out-of-line (needs Residue predicates) + bool isNucleotideChain(); + bool isSolventChain(); + PResidue AddResidue(Manager &m, gemmi::Residue r); // append + PResidue InsResidue(Manager &m, int pos, gemmi::Residue r); + // Adopt a detached residue (its atom wrappers already point at it, so they + // ride along once its gemmi is copied in and the wrapper is rebound). + int AddResidue(PResidue res) { + res->_store_id(); // push name/insCode buffers into gemmi + g().residues.push_back(res->g()); // res detached -> its _local (with atoms) + res->chain = this; + res->mgr = mgr; + res->ri = (int)residues.size(); + residues.push_back(res); + return 0; + } + int InsResidue(PResidue res, int pos) { + _compact_residues(); // don't insert/reindex across tombstones + if (pos < 0) pos = 0; + if (pos > (int)residues.size()) pos = (int)residues.size(); + res->_store_id(); + g().residues.insert(g().residues.begin() + pos, res->g()); + res->chain = this; + res->mgr = mgr; + res->ri = pos; + residues.insert(residues.begin() + pos, res); + for (int k = pos + 1; k < (int)residues.size(); ++k) residues[k]->ri = k; + return 0; + } + + private: + ChainID _chainid_buf{}; + }; + + // =========================================================================== + class Model : public UDStore { + public: + Manager *mgr = nullptr; // null => detached (use _local) + int mi = 0; // 0-based internal; GetModel is 1-based externally + gemmi::Model _local{1}; // backing store while detached (gemmi Model num is int) + std::vector chains; + + gemmi::Model &g() const; + + int GetNumberOfChains() { return (int)chains.size(); } + PChain GetChain(int chainNo) { + return (chainNo >= 0 && chainNo < (int)chains.size()) ? chains[chainNo] : nullptr; + } + PChain GetChain(const ChainID chID); + // Adopt a detached chain (Coot's `new mmdb::Chain` idiom): copy its local + // gemmi (with any residues/atoms) into this model and rebind, cascading mgr + // to the sub-tree that was built while detached (mgr was null). + int AddChain(PChain chn) { + g().chains.push_back(chn->g()); + chn->model = this; + chn->mgr = mgr; + chn->ci = (int)chains.size(); + chains.push_back(chn); + for (Residue *r : chn->residues) { + r->mgr = mgr; + for (Atom *a : r->atoms) a->mgr = mgr; + } + return 0; + } + int GetSerNum() { return mi + 1; } + // delete chain at index: erase gemmi + wrapper, reindex the tail + void DeleteChain(int chainNo) { + if (chainNo < 0 || chainNo >= (int)chains.size()) return; + g().chains.erase(g().chains.begin() + chainNo); + chains.erase(chains.begin() + chainNo); + for (int k = chainNo; k < (int)chains.size(); ++k) chains[k]->ci = k; + } + void DeleteChain(const ChainID chainID) { + for (int i = 0; i < (int)chains.size(); ++i) + if (chains[i]->g().name == (chainID ? chainID : "")) { + DeleteChain(i); + return; + } + } + void GetChainTable(PPChain &t, int &n) { + t = chains.data(); + n = (int)chains.size(); + } + std::vector all_atoms; // flat, filled by build_from_gemmi + PPAtom GetAllAtoms() { return all_atoms.data(); } + int GetNumberOfAtoms() { return (int)all_atoms.size(); } + int GetNumberOfAtoms(bool /*countTers*/) { return (int)all_atoms.size(); } + // Secondary-structure assignment: mocked. gemmi's DSSP has its SS prediction + // disabled upstream ("commented out ... wasn't correct anyway"), so there is no + // gemmi-backed SS to forward to. Return the non-OK code so callers treat SS as + // unavailable rather than trusting a bogus assignment. (residue SSE stays None.) + int CalcSecStructure(bool /*flag*/) { return SSERC_noResidues; } + // LINK records — gemmi-loaded (Manager::_load_metadata) plus Coot-created ones + // (AddLink) stored here; GetLink is 1-based like MMDB. + std::vector _links; + int GetNumberOfLinks() { return (int)_links.size(); } + PLink GetLink(int i) { return (i >= 1 && i <= (int)_links.size()) ? _links[i - 1] : nullptr; } + void AddLink(PLink link) { + if (link) _links.push_back(link); + } + // Refmac LINKR records — gemmi Connections that carry a link_id (_load_metadata). + std::vector _linkrs; + int GetNumberOfLinkRs() { return (int)_linkrs.size(); } + PLinkR GetLinkR(int i) { return (i >= 1 && i <= (int)_linkrs.size()) ? _linkrs[i - 1] : nullptr; } + void AddLinkR(PLinkR lr) { + if (lr) _linkrs.push_back(lr); + } + std::vector _cispeps; + int GetNumberOfCisPeps() { return (int)_cispeps.size(); } + PCisPep GetCisPep(int i) { return (i >= 1 && i <= (int)_cispeps.size()) ? _cispeps[i - 1] : nullptr; } + void AddCisPep(PCisPep cp) { + if (cp) _cispeps.push_back(cp); + } + void RemoveCisPeps() { _cispeps.clear(); } + // secondary structure. Records live in `helices`/`sheets` below, populated + // either from gemmi on load (build_from_gemmi) or by Coot's own SS computation + // via the access_model subclass (which reaches these public members directly). + // 1-based indexing to match MMDB. + int GetNumberOfHelices() { return (int)helices.data.size(); } + PHelix GetHelix(int i) { return (i >= 1 && i <= (int)helices.data.size()) ? helices.data[i - 1] : nullptr; } + int GetNumberOfSheets() { return sheets.nSheets; } + PSheet GetSheet(int i) { return (i >= 1 && i <= sheets.nSheets && sheets.sheet) ? sheets.sheet[i - 1] : nullptr; } + Sheets sheets; // SS records (gemmi-backed on load; access_model fills) + Helices helices; // " " " + std::vector _sheet_ptrs; // backing array for sheets.sheet (gemmi load) + PSheets GetSheets() { return &sheets; } + int GetModelID() { return mi + 1; } + pstr GetModelID(pstr buf) { + if (buf) std::snprintf(buf, 16, "%d", mi + 1); + return buf; + } + int CalcSecStructure(int /*flag*/, int /*selHnd*/) { return SSERC_noResidues; } // mocked; see bool overload + void Copy(PModel src); // deep-copy subtree (out-of-line) + Manager *GetCoordHierarchy() { return mgr; } // parent manager + int GetNumberOfResidues() { + int n = 0; + for (Chain *c : chains) n += c->GetNumberOfResidues(); + return n; + } + LinkContainer _linkc; + PLinkContainer GetLinks() { + _linkc.data.assign(_links.begin(), _links.end()); + return &_linkc; + } + void RemoveLinks() { _links.clear(); } + // Reorder chains (and gemmi backing) by chain ID. sortKey selects ascending + // (default) or descending; other MMDB sort keys collapse to ID order. + void SortChains(int sortKey = 0) { + int n = (int)chains.size(); + if (n < 2) return; + bool desc = (sortKey == SORT_CHAIN_ChainID_Desc); + std::vector ord(n); + for (int i = 0; i < n; ++i) ord[i] = i; + gemmi::Model &gm = g(); + std::stable_sort(ord.begin(), ord.end(), [&](int a, int b) { + return desc ? (gm.chains[a].name > gm.chains[b].name) + : (gm.chains[a].name < gm.chains[b].name); + }); + std::vector gnew; + gnew.reserve(n); + std::vector wnew; + wnew.reserve(n); + for (int k = 0; k < n; ++k) { + gnew.push_back(std::move(gm.chains[ord[k]])); + wnew.push_back(chains[ord[k]]); + } + gm.chains = std::move(gnew); + chains = std::move(wnew); + for (int k = 0; k < n; ++k) chains[k]->ci = k; + } + PChain CreateChain(const ChainID id); // add empty chain (out-of-line: needs Manager) + int GetNumberOfStrands(int sheetNo) { + PSheet s = GetSheet(sheetNo); + return s ? s->nStrands : 0; + } + PStrand GetStrand(int sheetNo, int strandNo) { + PSheet s = GetSheet(sheetNo); + return (s && strandNo >= 1 && strandNo <= s->nStrands && s->strand) ? s->strand[strandNo - 1] : nullptr; + } + }; + +} // namespace mmdb diff --git a/mmdb-shim/include/mmdb2/_shim_impl.hh b/mmdb-shim/include/mmdb2/_shim_impl.hh new file mode 100644 index 0000000000..789877652c --- /dev/null +++ b/mmdb-shim/include/mmdb2/_shim_impl.hh @@ -0,0 +1,36 @@ +// mmdb-shim — architecture B implementation umbrella. Every public mmdb2/*.h +// wrapper resolves here (when COOT_USE_MMDB_SHIM is defined); this file just +// stitches the implementation layers together. See MMDB_SHIM_Recon_and_Plan.md. +// +// The shim presents MMDB's API but is backed by a live gemmi::Structure. The +// mmdb:: hierarchy classes are stable wrapper nodes over that structure (each holds +// Manager* + parent* + a cached sibling index, resolves to gemmi via g(), and +// exposes children as a vector that is both the identity cache and the +// PPAtom/PPResidue table). Field access is via accessors: numeric -> +// reference-returning x()/…; float occ/b_iso -> value get + set_*; char[] -> pstr +// getter + set_*. gemmi is used at the boundaries (I/O, symmetry, neighbour search) +// and the shim hand-implements only what gemmi lacks (UDData slots, the +// selection-handle engine, the stable-pointer wrapper tree, subgraph matching). +// +// The implementation is split into four dependency-ordered layers (each opens its +// own `namespace mmdb`); this file must include them in order: +// 1. _shim_types.hh — typedefs, enums, UDStore, forward decls, record classes +// 2. _shim_hierarchy.hh — Atom / Residue / Chain / Model class definitions +// 3. _shim_manager.hh — Manager (+ nested Selection / UDReg) +// 4. _shim_inline.hh — g() resolvers, UDData helpers, out-of-line method bodies, +// the detail:: selection matchers, and free functions +// then the two sibling subsystems that build on the completed hierarchy. +#pragma once + +#include "_shim_types.hh" +#include "_shim_hierarchy.hh" +#include "_shim_manager.hh" +#include "_shim_inline.hh" + +// mmdb::mmcif::* (thin veneer over gemmi::cif) — re-opens mmdb{mmcif{...}}. +// pstr/cpstr/realtype are already in scope from the layers above. +#include "_mmcif_impl.hh" + +// mmdb::math::{Vertex,Edge,Graph,GraphMatch} — molecular graph + subgraph match. +// Included last so Atom/Residue are complete (MakeGraph). +#include "_graph_impl.hh" diff --git a/mmdb-shim/include/mmdb2/_shim_inline.hh b/mmdb-shim/include/mmdb2/_shim_inline.hh new file mode 100644 index 0000000000..fd19356ccb --- /dev/null +++ b/mmdb-shim/include/mmdb2/_shim_inline.hh @@ -0,0 +1,1061 @@ +// mmdb-shim — layer 4 of 4: out-of-line definitions. +// +// Everything here needs one or more complete classes from the layers above: the +// g() resolvers (detached wrapper -> _local, else parent's gemmi vector), the +// UDData put/get helpers, the Atom/Residue/Chain/Model/Manager methods that touch +// siblings or the Manager, the detached-construction constructors, the CID/atom +// selection matchers (namespace detail), and the free helper functions. +#pragma once + +#include "_shim_manager.hh" + +namespace mmdb { + + // ---- g() resolvers ---- + // A wrapper with no parent is "detached" (Coot's `new mmdb::Atom` idiom: build + // standalone, set fields, then Add*() into a parent). While detached, g() + // resolves to a wrapper-owned local gemmi object; Add*() copies that local into + // the parent's gemmi vector and rebinds (sets parent + index). Index-based + // resolution makes the vector push/reallocation harmless for siblings. + inline gemmi::Model &Model::g() const { return mgr ? mgr->st.models[mi] : const_cast(this)->_local; } + inline gemmi::Chain &Chain::g() const { return model ? model->g().chains[ci] : const_cast(this)->_local; } + inline gemmi::Residue &Residue::g() const { return chain ? chain->g().residues[ri] : const_cast(this)->_local; } + inline gemmi::Atom &Atom::g() const { + if (res && res->chain && res->chain->model && res->chain->model->mgr) { + auto &mgr = *res->chain->model->mgr; + int mi = res->chain->model->mi; + if (mi >= 0 && mi < (int)mgr.st.models.size()) { + return res->g().atoms[ai]; + } + } + return const_cast(this)->_local; + } + + // ---- UDData helpers ---- + inline Manager::UDReg *_ud_desc(Manager *mgr, UDR_TYPE myType, int handle, int kind, + int &err) { + if (!mgr || handle < 1 || handle > (int)mgr->ud_regs.size()) { + err = UDDATA_WrongHandle; + return nullptr; + } + Manager::UDReg &d = mgr->ud_regs[handle - 1]; // handles are 1-based (see _regUD) + if (d.type != myType || d.kind != kind) { + err = UDDATA_WrongUDRType; + return nullptr; + } + err = UDDATA_Ok; + return &d; + } + inline int ud_put(Manager *mgr, UDR_TYPE t, UDStore &s, int h, int v) { + int e; + auto *d = _ud_desc(mgr, t, h, 0, e); + if (!d) return e; + if ((int)s._udi.size() <= d->slot) s._udi.resize(d->slot + 1, 0); + s._udi[d->slot] = v; + return UDDATA_Ok; + } + inline int ud_put(Manager *mgr, UDR_TYPE t, UDStore &s, int h, realtype v) { + int e; + auto *d = _ud_desc(mgr, t, h, 1, e); + if (!d) return e; + if ((int)s._udr.size() <= d->slot) s._udr.resize(d->slot + 1, 0.0); + s._udr[d->slot] = v; + return UDDATA_Ok; + } + inline int ud_put(Manager *mgr, UDR_TYPE t, UDStore &s, int h, cpstr v) { + int e; + auto *d = _ud_desc(mgr, t, h, 2, e); + if (!d) return e; + if ((int)s._uds.size() <= d->slot) s._uds.resize(d->slot + 1); + s._uds[d->slot] = v ? v : ""; + return UDDATA_Ok; + } + inline int ud_get(Manager *mgr, UDR_TYPE t, UDStore &s, int h, int &v) { + int e; + auto *d = _ud_desc(mgr, t, h, 0, e); + if (!d) return e; + if ((int)s._udi.size() <= d->slot) return UDDATA_NoData; + v = s._udi[d->slot]; + return UDDATA_Ok; + } + inline int ud_get(Manager *mgr, UDR_TYPE t, UDStore &s, int h, realtype &v) { + int e; + auto *d = _ud_desc(mgr, t, h, 1, e); + if (!d) return e; + if ((int)s._udr.size() <= d->slot) return UDDATA_NoData; + v = s._udr[d->slot]; + return UDDATA_Ok; + } + inline int ud_get(Manager *mgr, UDR_TYPE t, UDStore &s, int h, pstr &v) { + int e; + auto *d = _ud_desc(mgr, t, h, 2, e); + if (!d) return e; + if ((int)s._uds.size() <= d->slot) return UDDATA_NoData; + v = (pstr)s._uds[d->slot].c_str(); + return UDDATA_Ok; // borrowed + } + + // ---- Atom out-of-line ---- + inline pstr Atom::GetAtomName() const { + // MMDB returns the PDB-column-aligned 4-char atom name (e.g. " N ", " CA ", + // " CG2"); gemmi stores the trimmed name ("N"/"CA"/"CG2"). Reproduce MMDB + // alignment via gemmi's padded_name() (left-pad by element) + right-pad to 4 + // — the exact rule gemmi's own mmdb.hpp bridge uses. Coot's atom_spec_t names + // are these 4-char strings, so returning the trimmed name breaks every lookup. + std::string padded = g().padded_name(); + if (padded.size() < 4) padded.resize(4, ' '); + std::snprintf(_name_buf, sizeof(_name_buf), "%s", padded.c_str()); + return _name_buf; + } + // Coot passes MMDB-aligned 4-char names (" CA "); gemmi stores trimmed names + // ("CA") and re-pads on output (GetAtomName / PDB write) — store trimmed so + // gemmi's own formatting stays correct. + inline void Atom::SetAtomName(const AtomName aName) { g().name = aName ? gemmi::trim_str(aName) : ""; } + inline pstr Atom::GetElementName() { + // MMDB returns the PDB-column-aligned element: 2 chars, right-justified, + // UPPERCASE (" H", " C", "NA", "FE"). gemmi's Element::name() is unpadded and + // mixed-case ("H"/"C"/"Na"/"Fe"), so Coot's element tests — e.g. + // get_number_of_hydrogen_atoms() comparing `ele == " H"` — never match. Align + // to MMDB: uppercase then right-pad into a 2-wide field. + std::string e = g().element.name(); + for (char &c : e) c = std::toupper((unsigned char)c); + if (e.size() < 2) e.insert(e.begin(), 2 - e.size(), ' '); + std::snprintf(_elem_buf, sizeof(_elem_buf), "%s", e.c_str()); + return _elem_buf; + } + inline void Atom::SetElementName(const Element elName) { g().element = gemmi::Element(elName); } + inline pstr Atom::GetChainID() { return res ? res->GetChainID() : mmdb_empty_pstr(); } + inline int Atom::GetSeqNum() { return res ? res->GetSeqNum() : 0; } + inline Chain *Atom::GetChain() { return res ? res->GetChain() : nullptr; } + inline Model *Atom::GetModel() { return (res && res->chain) ? res->chain->model : nullptr; } + inline pstr Atom::GetLabelCompID() { return res ? res->GetLabelCompID() : nullptr; } + inline pstr Atom::GetLabelAsymID() { return res ? res->GetLabelAsymID() : nullptr; } + inline int Atom::GetLabelSeqID() { return res ? res->GetLabelSeqID() : 0; } + inline int Atom::GetLabelEntityID() { return res ? res->GetLabelEntityID() : 0; } + inline int Atom::GetResidueNo() { return res ? res->GetResidueNo() : 0; } + inline int Atom::GetSSEType() { return res ? res->SSE : SSE_None; } + inline bool Atom::isSolvent() { return res ? res->isSolvent() : false; } + inline bool Atom::isNTerminus() { return res ? res->isNTerminus() : false; } + inline bool Atom::isCTerminus() { return res ? res->isCTerminus() : false; } + inline pstr Atom::GetInsCode() { return res ? res->GetInsCode() : mmdb_empty_pstr(); } + inline pstr Atom::GetResName() { return res ? res->GetResName() : mmdb_empty_pstr(); } + inline int Atom::GetModelNum() { return res ? res->GetModelNum() : 0; } + inline int Atom::GetIndex() { return ai; } + inline void Atom::SetCoordinates(realtype xx, realtype yy, realtype zz, + realtype occ, realtype tF) { + auto &a = g(); + a.pos = gemmi::Position(xx, yy, zz); + a.occ = (float)occ; + a.b_iso = (float)tF; + } + + // ---- Residue out-of-line ---- + inline pstr Residue::GetResName() { + std::snprintf(_resname_buf, sizeof(_resname_buf), "%s", g().name.c_str()); + return _resname_buf; + } + inline int &Residue::GetSeqNum() { return g().seqid.num.value; } + inline pstr Residue::GetInsCode() { + _inscode_buf[0] = g().seqid.icode == ' ' ? '\0' : g().seqid.icode; + _inscode_buf[1] = '\0'; + return _inscode_buf; + } + inline pstr Residue::GetChainID() { return chain ? chain->GetChainID() : mmdb_empty_pstr(); } + inline int Residue::GetModelNum() { return (chain && chain->model) ? chain->model->GetSerNum() : 0; } + inline PAtom Residue::GetAtom(const AtomName aname, const Element elname, const AltLoc aloc) { + // MMDB matches the PDB-column-aligned 4-char name (real Coot calls + // `GetAtom(" CA ")`), but gemmi stores names trimmed ("CA"). Trim the query so + // both padded and unpadded lookups resolve — mirrors the selection matchers + // (detail::inList / SelectAtoms), which already trim both sides. Element/altLoc + // still disambiguate when supplied (e.g. carbon-alpha " CA " vs calcium "CA ", + // which share a trimmed name). + const std::string want = aname ? gemmi::trim_str(aname) : std::string(); + for (Atom *a : atoms) { + if (std::string(a->g().name) != want) continue; + if (elname && *elname && a->g().element.name() != std::string(elname)) continue; + if (aloc && *aloc && a->g().altloc != aloc[0]) continue; + return a; + } + return nullptr; + } + inline PAtom Residue::AddAtom(Manager &m, gemmi::Atom a) { + g().atoms.push_back(std::move(a)); + Atom *aw = m.newAtom(); + aw->mgr = &m; + aw->res = this; + aw->ai = (int)atoms.size(); + atoms.push_back(aw); + return aw; + } + // Adopt a Coot-`new`d detached atom (the `new mmdb::Atom; …; res->AddAtom(at)` + // idiom). Copy its local gemmi into this residue, rebind the wrapper, and — when + // this residue is manager-bound — transfer ownership to the manager so `~Manager` + // frees it (MMDB semantics); `~Atom` drops it back out on an early Coot `delete`. + inline int Residue::AddAtom(PAtom atm) { + g().atoms.push_back(atm->_local); + atm->res = this; + atm->mgr = mgr; + atm->ai = (int)atoms.size(); + if (atm->_altloc_buf[0]) g().atoms[atm->ai].altloc = atm->_altloc_buf[0]; + atoms.push_back(atm); + if (mgr) mgr->_atom_allocs.insert(atm); + _sync_atom(); + return 0; + } + inline void Residue::DeleteAtom(int pos) { + if (pos < 0 || pos >= (int)atoms.size()) return; + g().atoms.erase(g().atoms.begin() + pos); + atoms[pos]->alive = false; + atoms[pos]->ai = -1; + atoms.erase(atoms.begin() + pos); + for (int k = pos; k < (int)atoms.size(); ++k) atoms[k]->ai = k; + } + + // Unlink one atom wrapper from this residue without freeing it: erase from the + // wrapper table AND the parallel gemmi atom vector (kept in lockstep), then + // reindex trailing atoms. Used by ~Atom when Coot `delete`s a live atom. + inline void Residue::_detach_atom(Atom *a) { + auto it = std::find(atoms.begin(), atoms.end(), a); + if (it == atoms.end()) return; + int pos = (int)(it - atoms.begin()); + if (pos < (int)g().atoms.size()) g().atoms.erase(g().atoms.begin() + pos); + atoms.erase(atoms.begin() + pos); + for (int k = pos; k < (int)atoms.size(); ++k) atoms[k]->ai = k; + } + + // Coot's `delete atom;` removes an atom from the hierarchy. Detach it from the + // parent residue, the manager/model flat lists, and any selections so no stale + // pointer survives; then drop it from the ownership set. A no-op during teardown + // (memory is freed wholesale by ~Manager) and for never-adopted detached atoms. + inline Atom::~Atom() { + if (!mgr || mgr->_bulk_free) return; + Manager *m = mgr; + if (res) { + Model *mod = (res->chain ? res->chain->model : nullptr); + res->_detach_atom(this); + if (mod) { + auto &ma = mod->all_atoms; + ma.erase(std::remove(ma.begin(), ma.end(), this), ma.end()); + } + } + auto &aa = m->all_atoms; + aa.erase(std::remove(aa.begin(), aa.end(), this), aa.end()); + for (int h = 1; h <= (int)m->selections.size(); ++h) { + if (isInSelection(h)) { + auto &sa = m->selections[h - 1].atoms; + sa.erase(std::remove(sa.begin(), sa.end(), this), sa.end()); + } + } + m->_atom_allocs.erase(this); + } + + // Coot's `delete residue_p;` (and Chain::DeleteResidue) removes a residue. Free its + // atoms (MMDB: deleting a residue deletes its atoms), then DEFER the structural + // removal: null this residue's slot in the parent chain but keep the gemmi + // placeholder so siblings' `ri` stays valid; _compact_residues drops both. A no-op + // during Manager teardown (memory is freed wholesale by ~Manager). + inline Residue::~Residue() { + if (!mgr || mgr->_bulk_free) return; + Manager *m = mgr; + // free my atoms: null each atom's res first so ~Atom doesn't mutate this->atoms + // mid-iteration (~Atom still cleans all_atoms/model/selections/registry). + std::vector ats = atoms; + atoms.clear(); + for (Atom *a : ats) { + a->res = nullptr; + delete a; + } + // tombstone my slot in the parent chain (keep the gemmi placeholder residue) + if (chain) { + auto &rv = chain->residues; + for (size_t i = 0; i < rv.size(); ++i) + if (rv[i] == this) { + rv[i] = nullptr; + break; + } + } + m->_res_allocs.erase(this); + } + + inline void Chain::_compact_residues() { + // Drop tombstoned (null) wrapper slots and their gemmi placeholder residues in + // lock-step (wrapper[i] <-> g().residues[i]); then reindex ri to the new order. + bool any_null = false; + for (Residue *r : residues) + if (!r) { + any_null = true; + break; + } + if (!any_null) return; + std::vector keptw; + std::vector keptg; + gemmi::Chain &gc = g(); + keptw.reserve(residues.size()); + keptg.reserve(gc.residues.size()); + for (size_t i = 0; i < residues.size(); ++i) { + if (residues[i]) { + keptw.push_back(residues[i]); + if (i < gc.residues.size()) keptg.push_back(std::move(gc.residues[i])); + } + } + residues.swap(keptw); + gc.residues.swap(keptg); + for (int k = 0; k < (int)residues.size(); ++k) residues[k]->ri = k; + } + + // ---- Chain out-of-line ---- + inline bool Chain::isAminoacidChain() { + for (Residue *r : residues) + if (r && r->isAminoacid()) return true; + return false; + } + inline bool Chain::isNucleotideChain() { + for (Residue *r : residues) + if (r && r->isNucleotide()) return true; + return false; + } + inline bool Chain::isSolventChain() { + if (residues.empty()) return false; + for (Residue *r : residues) + if (r && !r->isSolvent()) return false; + return true; + } + inline pstr Chain::GetChainID() { + std::snprintf(_chainid_buf, sizeof(_chainid_buf), "%s", g().name.c_str()); + return _chainid_buf; + } + inline PResidue Chain::AddResidue(Manager &m, gemmi::Residue r) { + g().residues.push_back(std::move(r)); + Residue *rw = m.newRes(); + rw->mgr = &m; + rw->chain = this; + rw->ri = (int)residues.size(); + for (int ai = 0; ai < (int)rw->g().atoms.size(); ++ai) { + Atom *aw = m.newAtom(); + aw->mgr = &m; + aw->res = rw; + aw->ai = ai; + rw->atoms.push_back(aw); + } + residues.push_back(rw); + return rw; + } + inline PResidue Chain::InsResidue(Manager &m, int pos, gemmi::Residue r) { + _compact_residues(); // don't insert/reindex across deferred-delete tombstones + g().residues.insert(g().residues.begin() + pos, std::move(r)); + Residue *rw = m.newRes(); + rw->mgr = &m; + rw->chain = this; + rw->ri = pos; + residues.insert(residues.begin() + pos, rw); + for (int k = pos + 1; k < (int)residues.size(); ++k) residues[k]->ri = k; + for (int ai = 0; ai < (int)rw->g().atoms.size(); ++ai) { + Atom *aw = m.newAtom(); + aw->mgr = &m; + aw->res = rw; + aw->ai = ai; + rw->atoms.push_back(aw); + } + return rw; + } + + // ---- Model out-of-line ---- + inline PChain Model::GetChain(const ChainID chID) { + for (Chain *c : chains) + if (c->g().name == chID) return c; + return nullptr; + } + + // ---- Manager out-of-line ---- + inline void Manager::build_from_gemmi() { + models.clear(); + all_atoms.clear(); + for (int mi = 0; mi < (int)st.models.size(); ++mi) { + Model *mw = newModel(); + mw->mgr = this; + mw->mi = mi; + auto &gm = st.models[mi]; + for (int ci = 0; ci < (int)gm.chains.size(); ++ci) { + Chain *cw = newChain(); + cw->mgr = this; + cw->model = mw; + cw->ci = ci; + auto &gc = gm.chains[ci]; + for (int ri = 0; ri < (int)gc.residues.size(); ++ri) { + Residue *rw = newRes(); + rw->mgr = this; + rw->chain = cw; + rw->ri = ri; + auto &gr = gc.residues[ri]; + for (int ai = 0; ai < (int)gr.atoms.size(); ++ai) { + Atom *aw = newAtom(); + aw->mgr = this; + aw->res = rw; + aw->ai = ai; + aw->WhatIsSet = ASET_Coordinates | ASET_Occupancy | ASET_tempFactor; + const gemmi::SMat33 &an = gr.atoms[ai].aniso; + if (an.u11 != 0.f || an.u22 != 0.f || an.u33 != 0.f) aw->WhatIsSet |= ASET_Anis_tFac; + rw->atoms.push_back(aw); + all_atoms.push_back(aw); + mw->all_atoms.push_back(aw); + } + rw->_sync_atom(); + rw->_load_id(); + cw->residues.push_back(rw); + } + mw->chains.push_back(cw); + } + models.push_back(mw); + } + _load_metadata(); + } + + // Map gemmi's structure-level metadata (connections / cispeps / helices / + // sheets) onto the MMDB per-Model record containers. gemmi is the reader; the + // shim just re-shapes. Connections/helices/sheets are not model-scoped in gemmi, + // so they go on model 1 (MMDB's usual home); cispeps honour their model_num. + inline void Manager::_load_metadata() { + link_pool.clear(); + linkr_pool.clear(); + cispep_pool.clear(); + helix_pool.clear(); + sheet_pool.clear(); + strand_pool.clear(); + strandarr_pool.clear(); + author_pool.clear(); + + // PDB title AUTHOR records (gemmi meta.authors) + title.author.data.clear(); + for (const std::string &au : st.meta.authors) { + author_pool.emplace_back(); + std::snprintf(author_pool.back().Line, sizeof(author_pool.back().Line), "%s", au.c_str()); + title.author.data.push_back(&author_pool.back()); + } + if (models.empty()) return; + + auto fill_ends = [](const gemmi::AtomAddress &a, ChainID &cid, ResName &rn, + int &seq, InsCode &ic, AtomName *an, AltLoc *al) { + std::snprintf(cid, sizeof(ChainID), "%s", a.chain_name.c_str()); + std::snprintf(rn, sizeof(ResName), "%s", a.res_id.name.c_str()); + seq = a.res_id.seqid.num.value; + ic[0] = (a.res_id.seqid.icode && a.res_id.seqid.icode != ' ') ? a.res_id.seqid.icode : '\0'; + ic[1] = '\0'; + if (an) std::snprintf(*an, sizeof(AtomName), "%s", a.atom_name.c_str()); + if (al) { + (*al)[0] = a.altloc ? a.altloc : '\0'; + (*al)[1] = '\0'; + } + }; + + // --- LINK records (gemmi Connection) -> model 1 --- + Model *m1 = models[0]; + for (const gemmi::Connection &cn : st.connections) { + link_pool.emplace_back(); + Link &l = link_pool.back(); + fill_ends(cn.partner1, l.chainID1, l.resName1, l.seqNum1, l.insCode1, &l.atName1, &l.aloc1); + fill_ends(cn.partner2, l.chainID2, l.resName2, l.seqNum2, l.insCode2, &l.atName2, &l.aloc2); + l.dist = cn.reported_distance; + m1->_links.push_back(&l); + // a connection carrying a Refmac link id is also a LINKR record + if (!cn.link_id.empty()) { + linkr_pool.emplace_back(); + LinkR &lr = linkr_pool.back(); + std::snprintf(lr.linkRID, sizeof(lr.linkRID), "%s", cn.link_id.c_str()); + AtomName an; + AltLoc al; + fill_ends(cn.partner1, lr.chainID1, lr.resName1, lr.seqNum1, lr.insCode1, &an, &al); + std::snprintf(lr.atName1, sizeof(AtomName), "%s", an); + std::snprintf(lr.aloc1, sizeof(AltLoc), "%s", al); + fill_ends(cn.partner2, lr.chainID2, lr.resName2, lr.seqNum2, lr.insCode2, &an, &al); + std::snprintf(lr.atName2, sizeof(AtomName), "%s", an); + std::snprintf(lr.aloc2, sizeof(AltLoc), "%s", al); + lr.dist = cn.reported_distance; + m1->_linkrs.push_back(&lr); + } + } + + // --- CISPEP records (gemmi CisPep) -> model by model_num (default 1) --- + for (const gemmi::CisPep &cp : st.cispeps) { + int mnum = cp.model_num > 0 ? cp.model_num : 1; + Model *mw = GetModel(mnum); + if (!mw) mw = m1; + cispep_pool.emplace_back(); + CisPep &c = cispep_pool.back(); + InsCode ic1, ic2; + int s1, s2; + fill_ends(cp.partner_c, c.chainID1, c.pep1, s1, ic1, nullptr, nullptr); + fill_ends(cp.partner_n, c.chainID2, c.pep2, s2, ic2, nullptr, nullptr); + c.seqNum1 = s1; + std::snprintf(c.icode1, sizeof(InsCode), "%s", ic1); + c.seqNum2 = s2; + std::snprintf(c.icode2, sizeof(InsCode), "%s", ic2); + c.modNum = mnum; + if (!std::isnan(cp.reported_angle)) c.measure = cp.reported_angle; + mw->_cispeps.push_back(&c); + } + + // --- HELIX records (gemmi Helix) -> model 1 --- + for (const gemmi::Helix &gh : st.helices) { + helix_pool.emplace_back(); + Helix &h = helix_pool.back(); + AtomName an; + AltLoc al; + fill_ends(gh.start, h.initChainID, h.initResName, h.initSeqNum, h.initICode, &an, &al); + fill_ends(gh.end, h.endChainID, h.endResName, h.endSeqNum, h.endICode, &an, &al); + h.helixClass = (int)gh.pdb_helix_class; + h.length = gh.length; + h.serNum = (int)helix_pool.size(); + m1->helices.AddData(&h); + } + + // --- SHEET / STRAND records (gemmi Sheet) -> model 1 --- + if (!st.sheets.empty()) { + m1->sheets.nSheets = (int)st.sheets.size(); + m1->_sheet_ptrs.assign(st.sheets.size(), nullptr); // backs Sheets::sheet (Sheet**) + for (size_t is = 0; is < st.sheets.size(); ++is) { + const gemmi::Sheet &gs = st.sheets[is]; + sheet_pool.emplace_back(); + Sheet &sh = sheet_pool.back(); + std::snprintf(sh.sheetID, sizeof(sh.sheetID), "%s", gs.name.c_str()); + sh.nStrands = (int)gs.strands.size(); + strandarr_pool.emplace_back(); + std::vector &sarr = strandarr_pool.back(); + sarr.reserve(gs.strands.size()); + for (const gemmi::Sheet::Strand &gst : gs.strands) { + strand_pool.emplace_back(); + Strand &str = strand_pool.back(); + AtomName an; + AltLoc al; + fill_ends(gst.start, str.initChainID, str.initResName, str.initSeqNum, str.initICode, &an, &al); + fill_ends(gst.end, str.endChainID, str.endResName, str.endSeqNum, str.endICode, &an, &al); + std::snprintf(str.sheetID, sizeof(str.sheetID), "%s", gs.name.c_str()); + str.strandNo = (int)sarr.size() + 1; + str.sense = gst.sense; + sarr.push_back(&str); + } + sh.strand = sarr.data(); + m1->_sheet_ptrs[is] = &sh; + } + m1->sheets.sheet = m1->_sheet_ptrs.data(); + } + } + + // ---- Manager::PutAtom (hierarchy insertion) ---- + inline int Manager::PutAtom(int index, PAtom A, int serNum) { + if (!A) return 0; + Residue *src = A->res; + // ensure a model exists (Coot calls PutAtom on a fresh, empty Manager) + Model *mw = models.empty() ? nullptr : models[0]; + if (!mw) { + st.models.emplace_back(1); + mw = newModel(); + mw->mgr = this; + mw->mi = 0; + models.push_back(mw); + } + // find or create the chain implied by the source atom's chain + std::string cid = (src && src->chain) ? src->chain->g().name : std::string("A"); + Chain *cw = mw->GetChain(cid.c_str()); + if (!cw) cw = mw->CreateChain(cid.c_str()); + // find or create the residue implied by (seqNum, insCode) + int seq = src ? src->g().seqid.num.value : 0; + char ic = src ? src->g().seqid.icode : ' '; + char icn = ic ? ic : ' '; + Residue *rw = nullptr; + for (Residue *r : cw->residues) { + gemmi::Residue &gr = r->g(); + if (gr.seqid.num.value == seq && (gr.seqid.icode ? gr.seqid.icode : ' ') == icn) { + rw = r; + break; + } + } + if (!rw) { + gemmi::Residue gr; + gr.name = src ? src->g().name : std::string("UNK"); + gr.seqid.num = seq; + gr.seqid.icode = icn; + rw = cw->AddResidue(*this, gr); + rw->_load_id(); + } + // append a copy of the atom's gemmi backing + register it in the flat tables + Atom *aw = rw->AddAtom(*this, A->g()); + aw->WhatIsSet = A->WhatIsSet; + aw->Het = A->Het; + std::memcpy(aw->segID, A->segID, sizeof aw->segID); + aw->g().serial = serNum ? serNum : (index > 0 ? index : (int)all_atoms.size() + 1); + rw->_sync_atom(); + all_atoms.push_back(aw); + mw->all_atoms.push_back(aw); + return (int)all_atoms.size(); // 1-based position (GetAtomI(pos) returns aw) + } + + // ---- selection matching ---- + namespace detail { + inline std::string trimws(const std::string &s) { + size_t a = s.find_first_not_of(' '), b = s.find_last_not_of(' '); + return a == std::string::npos ? std::string() : s.substr(a, b - a + 1); + } + // Whitespace-insensitive membership test. MMDB atom names are stored space- + // padded ("_CA_", "_O__"), while CID/selection queries are unpadded ("CA", + // "O"); real MMDB matches them regardless of padding, so trim both sides. + // Harmless for chain IDs / residue / element names (already unpadded). + inline bool inList(cpstr list, const std::string &v) { + if (!list || !*list || std::strcmp(list, "*") == 0) return true; + // MMDB negation: a leading '!' inverts the match (e.g. "!HOH" = any residue + // that is not water). Coot's Select() uses this for chain/residue/element/ + // atom-name filters; without it every residue is (wrongly) excluded. + if (list[0] == '!') return !inList(list + 1, v); + std::string vt = trimws(v); + const char *p = list; + while (*p) { + const char *c = std::strchr(p, ','); + std::string tok(p, c ? (size_t)(c - p) : std::strlen(p)); + if (trimws(tok) == vt) return true; + if (!c) break; + p = c + 1; + } + return false; + } + inline bool altMatch(cpstr list, char alt) { + if (!list || std::strcmp(list, "*") == 0) return true; + std::string a = alt ? std::string(1, alt) : std::string(); + if (!*list) return a.empty(); // "" -> only blank altLoc + return inList(list, a); + } + } // namespace detail + + inline void Manager::Select(int selHnd, SELECTION_TYPE sType, int iModel, + cpstr Chains, int ResNo1, cpstr Ins1, int ResNo2, cpstr Ins2, cpstr RNames, + cpstr ANames, cpstr Elements, cpstr altLocs, SELECTION_KEY selKey) { + Selection &sel = selections[selHnd - 1]; + if (sel.type == STYPE_UNDEFINED) sel.type = sType; + std::vector oldA = sel.atoms; + std::vector oldR = sel.residues; + std::vector oldC = sel.chains; + + std::vector mAtoms; + std::vector mResidues; + std::vector mChains; + for (Model *mw : models) { + if (iModel > 0 && mw->GetSerNum() != iModel) continue; + for (Chain *cw : mw->chains) { + if (!detail::inList(Chains, cw->g().name)) continue; + bool anyResidue = false; + for (Residue *rw : cw->residues) { + int sn = rw->g().seqid.num.value; + char ric = rw->g().seqid.icode ? rw->g().seqid.icode : ' '; + // (seqNum, insCode) range: an explicit insCode only constrains the + // boundary residue; blank/"*" includes every insCode at that seqNum. + if (ResNo1 != ANY_RES) { + if (sn < ResNo1) continue; + if (sn == ResNo1 && Ins1 && Ins1[0] && std::strcmp(Ins1, "*") && ric < Ins1[0]) continue; + } + if (ResNo2 != ANY_RES) { + if (sn > ResNo2) continue; + if (sn == ResNo2 && Ins2 && Ins2[0] && std::strcmp(Ins2, "*") && ric > Ins2[0]) continue; + } + if (!detail::inList(RNames, rw->g().name)) continue; + bool anyAtom = false; + for (Atom *aw : rw->atoms) { + if (!detail::inList(ANames, aw->g().name)) continue; + if (!detail::inList(Elements, aw->g().element.name())) continue; + if (!detail::altMatch(altLocs, aw->g().altloc)) continue; + anyAtom = true; + if (sType == STYPE_ATOM) mAtoms.push_back(aw); + } + if (anyAtom) anyResidue = true; + if (anyAtom && sType == STYPE_RESIDUE) mResidues.push_back(rw); + } + // STYPE_CHAIN: a chain matching the chain filter (and, if given, having a + // residue that passes the residue/atom filters) is selected whole. + if (sType == STYPE_CHAIN && anyResidue) mChains.push_back(cw); + } + } + auto combine = [&](auto &cur, auto &matched) { + using Vec = typename std::decay::type; + std::set curset(cur.begin(), cur.end()); + std::set mset(matched.begin(), matched.end()); + if (selKey == SKEY_NEW) { + cur = matched; + } else if (selKey == SKEY_OR) { + for (auto *x : matched) + if (!curset.count(x)) cur.push_back(x); + } else if (selKey == SKEY_AND) { + Vec o; + for (auto *x : cur) + if (mset.count(x)) o.push_back(x); + cur = o; + } else if (selKey == SKEY_XOR) { + Vec o; + for (auto *x : cur) + if (!mset.count(x)) o.push_back(x); + for (auto *x : matched) + if (!curset.count(x)) o.push_back(x); + cur = o; + } else if (selKey == SKEY_CLR) { + Vec o; + for (auto *x : cur) + if (!mset.count(x)) o.push_back(x); + cur = o; + } + }; + if (sType == STYPE_ATOM) + combine(sel.atoms, mAtoms); + else if (sType == STYPE_RESIDUE) + combine(sel.residues, mResidues); + else if (sType == STYPE_CHAIN) + combine(sel.chains, mChains); + for (Atom *a : oldA) a->_setInSel(selHnd, false); + for (Atom *a : sel.atoms) a->_setInSel(selHnd, true); + for (Residue *r : oldR) r->_setInSel(selHnd, false); + for (Residue *r : sel.residues) r->_setInSel(selHnd, true); + for (Chain *c : oldC) c->_setInSel(selHnd, false); + for (Chain *c : sel.chains) c->_setInSel(selHnd, true); + } + + // select-from-selection: combine selHnd2's contents into selHnd1 + inline void Manager::Select(int selHnd1, SELECTION_TYPE sType, int selHnd2, + SELECTION_KEY sKey) { + Selection &s1 = selections[selHnd1 - 1]; + Selection &s2 = selections[selHnd2 - 1]; + if (s1.type == STYPE_UNDEFINED) s1.type = sType; + std::vector oldA = s1.atoms; + std::vector oldR = s1.residues; + auto combine = [&](auto &cur, auto &m) { + using Vec = typename std::decay::type; + std::set curset(cur.begin(), cur.end()); + std::set mset(m.begin(), m.end()); + if (sKey == SKEY_NEW) + cur = m; + else if (sKey == SKEY_OR) { + for (auto *x : m) + if (!curset.count(x)) cur.push_back(x); + } else if (sKey == SKEY_AND) { + Vec o; + for (auto *x : cur) + if (mset.count(x)) o.push_back(x); + cur = o; + } else if (sKey == SKEY_XOR) { + Vec o; + for (auto *x : cur) + if (!mset.count(x)) o.push_back(x); + for (auto *x : m) + if (!curset.count(x)) o.push_back(x); + cur = o; + } else if (sKey == SKEY_CLR) { + Vec o; + for (auto *x : cur) + if (!mset.count(x)) o.push_back(x); + cur = o; + } + }; + if (sType == STYPE_ATOM) + combine(s1.atoms, s2.atoms); + else if (sType == STYPE_RESIDUE) + combine(s1.residues, s2.residues); + for (Atom *a : oldA) a->_setInSel(selHnd1, false); + for (Atom *a : s1.atoms) a->_setInSel(selHnd1, true); + for (Residue *r : oldR) r->_setInSel(selHnd1, false); + for (Residue *r : s1.residues) r->_setInSel(selHnd1, true); + } + + inline void Manager::SelectAtom(int selHnd, PAtom atom, SELECTION_KEY sKey, bool) { + Selection &sel = selections[selHnd - 1]; + if (sel.type == STYPE_UNDEFINED) sel.type = STYPE_ATOM; + if (sKey == SKEY_NEW) { + for (Atom *a : sel.atoms) a->_setInSel(selHnd, false); + sel.atoms.clear(); + } + if (atom && !atom->isInSelection(selHnd)) { + sel.atoms.push_back(atom); + atom->_setInSel(selHnd, true); + } + } + + // Pragmatic CID parser: "/model/chain/seqNum1[.ins1]-seqNum2[.ins2]/atom" + // (best-effort; strips (resname)/[element]/:altloc suffixes; parses insertion + // codes after '.'). Not the full MMDB CID grammar but covers Coot's usage. + inline void Manager::Select(int selHnd, SELECTION_TYPE sType, cpstr CID, + SELECTION_KEY sKey) { + std::string s = CID ? CID : ""; + std::vector t; + size_t p = (!s.empty() && s[0] == '/') ? 1 : 0; + while (p <= s.size()) { + size_t q = s.find('/', p); + t.push_back(s.substr(p, q == std::string::npos ? std::string::npos : q - p)); + if (q == std::string::npos) break; + p = q + 1; + } + auto tok = [&](size_t i) { return i < t.size() ? t[i] : std::string(); }; + auto strip = [](std::string v, const char *seps) { + size_t c = v.find_first_of(seps); + return c == std::string::npos ? v : v.substr(0, c); + }; + // Assign tokens to model/chain/residue/atom. A leading '/' (or any '/') means + // the model field is present at tok(0). A slash-less CID has NO model/chain + // prefix: MMDB reads a bare numeric token as a residue seqNum ("262" = residue + // 262 in every chain), and a bare non-numeric token as a chain id ("A"). + std::string model_s, chain_s, res_s, atom_s; + if (s.find('/') != std::string::npos) { + model_s = tok(0); + chain_s = tok(1); + res_s = tok(2); + atom_s = tok(3); + } else { + const std::string only = tok(0); + if (!only.empty() && (std::isdigit((unsigned char)only[0]) || only[0] == '-')) + res_s = only; + else + chain_s = only; + } + int iModel = 0; + if (!model_s.empty() && model_s != "*" && model_s != "0") iModel = atoi(model_s.c_str()); + std::string chains = chain_s.empty() ? "*" : chain_s; + int r1 = ANY_RES, r2 = ANY_RES; + std::string ins1 = "*", ins2 = "*"; + // split "num[.ins]" into number + insertion code + auto parse_resid = [](const std::string &v, int &num, std::string &ins) { + size_t dot = v.find('.'); + num = atoi(v.substr(0, dot).c_str()); + ins = (dot == std::string::npos) ? std::string() : v.substr(dot + 1); + }; + std::string rr = strip(res_s, "("); // drop (resname) + if (!rr.empty() && rr != "*") { + size_t dash = rr.find('-', rr[0] == '-' ? 1 : 0); + if (dash == std::string::npos) { + parse_resid(rr, r1, ins1); + r2 = r1; + ins2 = ins1; + } else { + parse_resid(rr.substr(0, dash), r1, ins1); + parse_resid(rr.substr(dash + 1), r2, ins2); + } + } + std::string anames = strip(strip(atom_s, "["), ":"); // drop [element]/:altloc + if (anames.empty()) anames = "*"; + Select(selHnd, sType, iModel, chains.c_str(), r1, ins1.c_str(), r2, ins2.c_str(), "*", + anames.c_str(), "*", "*", sKey); + } + + inline int Manager::GetNumberOfAtoms(cpstr CID) { + int h = NewSelection(); + Select(h, STYPE_ATOM, CID, SKEY_NEW); + int n = (int)selections[h - 1].atoms.size(); + DeleteSelection(h); + return n; + } + + inline void Manager::GetAtomStatistics(int selHnd, RAtomStat AS) { + AS = AtomStat(); + std::vector &atoms = selections[selHnd - 1].atoms; + AS.nAtoms = (int)atoms.size(); + if (atoms.empty()) return; + double sx = 0, sy = 0, sz = 0; + AS.xmin = AS.xmax = atoms[0]->x(); + AS.ymin = AS.ymax = atoms[0]->y(); + AS.zmin = AS.zmax = atoms[0]->z(); + for (Atom *a : atoms) { + double X = a->x(), Y = a->y(), Z = a->z(); + sx += X; + sy += Y; + sz += Z; + AS.xmin = X < AS.xmin ? X : AS.xmin; + AS.xmax = X > AS.xmax ? X : AS.xmax; + AS.ymin = Y < AS.ymin ? Y : AS.ymin; + AS.ymax = Y > AS.ymax ? Y : AS.ymax; + AS.zmin = Z < AS.zmin ? Z : AS.zmin; + AS.zmax = Z > AS.zmax ? Z : AS.zmax; + } + AS.xm = sx / atoms.size(); + AS.ym = sy / atoms.size(); + AS.zm = sz / atoms.size(); + } + + inline void Manager::SelectSphere(int selHnd, SELECTION_TYPE sType, realtype x, + realtype y, realtype z, realtype r, SELECTION_KEY sKey) { + Selection &sel = selections[selHnd - 1]; + if (sel.type == STYPE_UNDEFINED) sel.type = sType; + std::vector oldA = sel.atoms; + std::vector oldR = sel.residues; + gemmi::Position c(x, y, z); + double r2 = r * r; + std::vector mAtoms; + std::vector mResidues; + for (Model *mw : models) + for (Chain *cw : mw->chains) + for (Residue *rw : cw->residues) { + bool any = false; + for (Atom *aw : rw->atoms) + if (aw->g().pos.dist_sq(c) <= r2) { + any = true; + if (sType == STYPE_ATOM) mAtoms.push_back(aw); + } + if (any && sType == STYPE_RESIDUE) mResidues.push_back(rw); + } + auto combine = [&](auto &cur, auto &m) { + std::set::type::value_type> cs(cur.begin(), cur.end()); + if (sKey == SKEY_NEW) + cur = m; + else if (sKey == SKEY_OR) { + for (auto *p : m) + if (!cs.count(p)) cur.push_back(p); + } + }; + if (sType == STYPE_ATOM) + combine(sel.atoms, mAtoms); + else if (sType == STYPE_RESIDUE) + combine(sel.residues, mResidues); + for (Atom *a : oldA) a->_setInSel(selHnd, false); + for (Atom *a : sel.atoms) a->_setInSel(selHnd, true); + for (Residue *r : oldR) r->_setInSel(selHnd, false); + for (Residue *r : sel.residues) r->_setInSel(selHnd, true); + } + + // SeekContacts (both overloads) is defined in mmdb-shim/src/contacts.cc using + // gemmi::NeighborSearch — keeps the heavy neighbor.hpp out of Coot's many TUs. + + // ---- detached-construction constructors + subtree ops (need complete types) ---- + inline Atom::Atom(Residue *r) { + if (r) r->AddAtom(this); + } + inline Residue::Residue(Chain *c) { + if (c) c->AddResidue(this); + } + inline Chain::Chain(Model *m, const ChainID id) { + if (m) m->AddChain(this); + SetChainID(id); + } + + // peptide-bond distance threshold for backbone C-N (a real bond is ~1.33 A). + inline bool Residue::isNTerminus() { + if (!chain || ri <= 0) return true; // first (or detached) residue + Residue *prev = chain->residues[ri - 1]; + if (!prev) return true; // previous slot is a deferred-delete tombstone + const gemmi::Atom *N = g().get_n(); + const gemmi::Atom *prevC = prev->g().get_c(); + if (!N || !prevC) return true; // missing backbone -> terminus + return N->pos.dist(prevC->pos) > 1.7; // not bonded to previous C + } + inline bool Residue::isCTerminus() { + if (!chain || ri < 0 || ri >= (int)chain->residues.size() - 1) return true; // last/detached + Residue *next = chain->residues[ri + 1]; + if (!next) return true; // next slot is a deferred-delete tombstone + const gemmi::Atom *C = g().get_c(); + const gemmi::Atom *nextN = next->g().get_n(); + if (!C || !nextN) return true; + return C->pos.dist(nextN->pos) > 1.7; // not bonded to next N + } + inline Model *Residue::GetModel() { return chain ? chain->model : nullptr; } + + inline void Chain::Copy(PChain src) { + Manager *pool = mgr ? mgr : src->mgr; + g() = src->g(); // deep gemmi copy (residues + atoms) + residues.clear(); + if (!pool) return; + gemmi::Chain &gc = g(); + for (int r = 0; r < (int)gc.residues.size(); ++r) { + Residue *rw = pool->newRes(); + rw->mgr = mgr; + rw->chain = this; + rw->ri = r; + for (int a = 0; a < (int)gc.residues[r].atoms.size(); ++a) { + Atom *aw = pool->newAtom(); + aw->mgr = mgr; + aw->res = rw; + aw->ai = a; + rw->atoms.push_back(aw); + } + rw->_sync_atom(); + rw->_load_id(); + residues.push_back(rw); + } + } + + inline void Model::Copy(PModel src) { + Manager *pool = mgr ? mgr : src->mgr; + g() = src->g(); + chains.clear(); + if (!pool) return; + gemmi::Model &gm = g(); + for (int c = 0; c < (int)gm.chains.size(); ++c) { + Chain *cw = pool->newChain(); + cw->mgr = mgr; + cw->model = this; + cw->ci = c; + for (int r = 0; r < (int)gm.chains[c].residues.size(); ++r) { + Residue *rw = pool->newRes(); + rw->mgr = mgr; + rw->chain = cw; + rw->ri = r; + for (int a = 0; a < (int)gm.chains[c].residues[r].atoms.size(); ++a) { + Atom *aw = pool->newAtom(); + aw->mgr = mgr; + aw->res = rw; + aw->ai = a; + rw->atoms.push_back(aw); + } + rw->_sync_atom(); + rw->_load_id(); + cw->residues.push_back(rw); + } + chains.push_back(cw); + } + } + + inline PChain Model::CreateChain(const ChainID id) { + Chain *c = mgr ? mgr->newChain() : new Chain(); + c->mgr = mgr; + c->model = this; + c->ci = (int)chains.size(); + g().chains.emplace_back(id ? id : ""); + chains.push_back(c); + return c; + } + + inline pstr Atom::GetAtomID(pstr S) { + if (S) std::snprintf(S, 100, "/%d/%s/%d(%s)/%s", GetModelNum(), GetChainID(), + res ? res->GetSeqNum() : 0, GetResName(), GetAtomName()); + return S; + } + + // one-letter residue code (mmdb_tables.h) via gemmi's tabulated residues + inline void Get1LetterCode(cpstr res3, pstr res1) { + if (!res1) return; + char c = gemmi::find_tabulated_residue(res3 ? res3 : "").one_letter_code; + res1[0] = c ? (char)std::toupper((unsigned char)c) : 'X'; + res1[1] = '\0'; + } + inline void Get1LetterCode(cpstr res3, char &res1) { + char b[2]; + Get1LetterCode(res3, b); + res1 = b[0]; + } + + // sort a contact array by distance (mmdb_coormngr.h SortContacts) — sortkey ignored + inline void SortContacts(PContact contacts, int nContacts, int /*sortkey*/) { + if (contacts && nContacts > 1) + std::sort(contacts, contacts + nContacts, + [](const Contact &a, const Contact &b) { return a.dist < b.dist; }); + } + + // centroid of an atom array (mmdb_coormngr.h GetMassCenter) + inline void GetMassCenter(PPAtom A, int nA, realtype &xc, realtype &yc, realtype &zc) { + double sx = 0, sy = 0, sz = 0; + int n = 0; + for (int i = 0; i < nA; ++i) + if (A[i]) { + sx += A[i]->x(); + sy += A[i]->y(); + sz += A[i]->z(); + ++n; + } + if (n) { + xc = sx / n; + yc = sy / n; + zc = sz / n; + } else { + xc = yc = zc = 0; + } + } + +} // namespace mmdb diff --git a/mmdb-shim/include/mmdb2/_shim_manager.hh b/mmdb-shim/include/mmdb2/_shim_manager.hh new file mode 100644 index 0000000000..1c30de914f --- /dev/null +++ b/mmdb-shim/include/mmdb2/_shim_manager.hh @@ -0,0 +1,533 @@ +// mmdb-shim — layer 3 of 4: the Manager (MMDB Root/CoorManager/SelManager rolled +// into one). +// +// Manager owns the live gemmi::Structure plus the wrapper trees built over it, the +// individually heap-allocated Atom/Residue nodes (so Coot's `delete atom;` idiom +// works), the stable-address pools for gemmi-derived metadata records, the +// handle-based selection engine, and the UDData registry. I/O, selection matching, +// PutAtom and the gemmi metadata mapping are declared here and defined out-of-line +// in _shim_inline.hh / src/*.cc. +#pragma once + +#include "_shim_hierarchy.hh" + +namespace mmdb { + + // =========================================================================== + class Manager { + public: + gemmi::Structure st; + // Atoms are heap-allocated individually (not pooled) so Coot's MMDB idiom + // `delete atom;` frees exactly one node. The manager owns every atom it hands + // out and frees the survivors at teardown; `~Atom` removes itself from this set + // when Coot deletes it early. `_bulk_free` tells `~Atom` to skip detach work + // while the manager is tearing everything down. + std::set _atom_allocs; + std::set _res_allocs; // residues heap-allocated too (Coot `delete residue_p`) + bool _bulk_free = false; + ~Manager() { + _bulk_free = true; + for (Atom *a : _atom_allocs) delete a; + _atom_allocs.clear(); + for (Residue *r : _res_allocs) delete r; + _res_allocs.clear(); + } + // stable-address pools (Chain/Model still pooled — see _atom_allocs / _res_allocs note) + std::deque chain_pool; + std::deque model_pool; + std::vector models; + // stable-address pools for gemmi-derived metadata records (LINK / CISPEP / + // HELIX / SHEET). Filled by build_from_gemmi -> _load_metadata(); owned here so + // the Model containers can hold bare pointers into them. + std::deque link_pool; + std::deque linkr_pool; + std::deque cispep_pool; + std::deque helix_pool; + std::deque sheet_pool; + std::deque strand_pool; + std::deque> strandarr_pool; // backing for Sheet::strand (Strand**) + std::deque author_pool; // backing for title.author records + void _load_metadata(); // out-of-line: needs complete gemmi metadata types + + Atom *newAtom() { + Atom *a = new Atom(); + a->mgr = this; + _atom_allocs.insert(a); + return a; + } + Residue *newRes() { + Residue *r = new Residue(); + r->mgr = this; + _res_allocs.insert(r); + return r; + } + Chain *newChain() { + chain_pool.emplace_back(); + return &chain_pool.back(); + } + Model *newModel() { + model_pool.emplace_back(); + return &model_pool.back(); + } + + int GetNumberOfModels() { return (int)models.size(); } + PModel GetModel(int modelNo) { // MMDB: 1 <= modelNo <= nModels + int i = modelNo - 1; + return (i >= 0 && i < (int)models.size()) ? models[i] : nullptr; + } + // per-model chain access (modelNo is 1-based, chainNo 0-based) — mmdb_coormngr.h + int GetNumberOfChains(int modelNo) { + PModel m = GetModel(modelNo); + return m ? m->GetNumberOfChains() : 0; + } + PChain GetChain(int modelNo, int chainNo) { + PModel m = GetModel(modelNo); + return m ? m->GetChain(chainNo) : nullptr; + } + // Re-index/renumber after edits. Sibling indices are kept in sync as the shim + // mutates (so PDBCLEAN_INDEX is implicit); PDBCLEAN_SERIAL renumbers atom serials + // 1..N in hierarchy order. Other clean flags are not needed by the shim. + word PDBCleanup(word CleanKey) { + // INDEX cleanup compacts deferred residue deletions (drops tombstones) — do it + // before renumbering so serials/indices count only surviving atoms. + if (CleanKey & PDBCLEAN_INDEX) { + for (Model *mw : models) + for (Chain *cw : mw->chains) cw->_compact_residues(); + _rebuild_all_atoms(); + } + if (CleanKey & (PDBCLEAN_SERIAL | PDBCLEAN_INDEX)) { + int s = 1; + for (Atom *a : all_atoms) a->g().serial = s++; + } + return 0; + } + + // PDB title records — Coot reaches `title` via an access_mol subclass; the + // TITLE string comes from gemmi (_struct.title), authors are filled on load. + Title title; + pstr GetStructureTitle(pstr T) { + if (T) std::strcpy(T, st.get_info("_struct.title").c_str()); // caller allocates (MMDB contract) + return T; + } + + // Orthogonal symmetry transformation for operator Nop (0-based) + cell shifts, + // via gemmi's space group + unit cell (shared helper). Returns 0 on success, + // nonzero if there is no usable space group / the operator is out of range. + int GetTMatrix(mat44 &TMatrix, int Nop, int cellshift_a, int cellshift_b, int cellshift_c) { + return gemmi_sym_tmatrix(st.cell, st.spacegroup_hm, TMatrix, Nop, + cellshift_a, cellshift_b, cellshift_c); + } + + void build_from_gemmi(); + + // adopt a detached model (Coot: `new mmdb::Model` -> AddChain… -> AddModel). + // Copy its local gemmi into st, rebind, cascade mgr through the sub-tree. + int AddModel(PModel mw) { + st.models.push_back(mw->g()); + mw->mgr = this; + mw->mi = (int)models.size(); + models.push_back(mw); + for (Chain *cw : mw->chains) { + cw->mgr = this; + for (Residue *rw : cw->residues) { + rw->mgr = this; + for (Atom *aw : rw->atoms) { + aw->mgr = this; + all_atoms.push_back(aw); + mw->all_atoms.push_back(aw); + } + } + } + return 0; + } + + // clone another manager's structure (mmdb Manager::Copy(PManager, COPY_MASK)). + // Copies the whole gemmi Structure and rebuilds all wrappers — clean & correct. + void Copy(PManager m, int /*CopyMask*/) { + if (m) { + st = m->st; + build_from_gemmi(); + } + } + + // ---- crystal cell & symmetry (gemmi UnitCell / SpaceGroup) ---- + std::string _sg_buf, _symop_buf; + void GetCell(realtype &a, realtype &b, realtype &c, realtype &al, realtype &be, + realtype &ga, realtype &vol, int &orthcode) { + const gemmi::UnitCell &u = st.cell; + a = u.a; + b = u.b; + c = u.c; + al = u.alpha; + be = u.beta; + ga = u.gamma; + vol = u.volume; + orthcode = 1; + } + void GetCell(realtype &a, realtype &b, realtype &c, realtype &al, realtype &be, + realtype &ga, realtype &vol) { + int oc; + GetCell(a, b, c, al, be, ga, vol, oc); + } + void SetCell(realtype a, realtype b, realtype c, realtype al, realtype be, + realtype ga, int /*OrthCode*/ = 1) { st.cell.set(a, b, c, al, be, ga); } + void Orth2Frac(realtype x, realtype y, realtype z, realtype &u, realtype &v, realtype &w) { + gemmi::Fractional f = st.cell.fractionalize(gemmi::Position(x, y, z)); + u = f.x; + v = f.y; + w = f.z; + } + void Frac2Orth(realtype u, realtype v, realtype w, realtype &x, realtype &y, realtype &z) { + gemmi::Position p = st.cell.orthogonalize(gemmi::Fractional(u, v, w)); + x = p.x; + y = p.y; + z = p.z; + } + pstr GetSpaceGroup() { + _sg_buf = st.spacegroup_hm; + return (pstr)_sg_buf.c_str(); + } + pstr GetSpaceGroupFix() { return GetSpaceGroup(); } + int SetSpaceGroup(cpstr sg) { + st.spacegroup_hm = sg ? sg : ""; + return 0; + } + int GetNumberOfSymOps() { + const gemmi::SpaceGroup *sg = gemmi::find_spacegroup_by_name(st.spacegroup_hm); + return sg ? (int)sg->operations().order() : 0; + } + pstr GetSymOp(int Nop) { + const gemmi::SpaceGroup *sg = gemmi::find_spacegroup_by_name(st.spacegroup_hm); + if (!sg) return nullptr; + int i = 0; + for (gemmi::Op op : sg->operations()) { + if (i++ == Nop) { + _symop_buf = op.triplet(); + return (pstr)_symop_buf.c_str(); + } + } + return nullptr; + } + + // ---- selection ---- + struct Selection { + SELECTION_TYPE type = STYPE_UNDEFINED; + std::vector atoms; + std::vector residues; + std::vector chains; + }; + std::vector selections; // handle is 1-based index + + int NewSelection() { + selections.emplace_back(); + return (int)selections.size(); + } + void DeleteSelection(int selHnd) { + if (selHnd < 1 || selHnd > (int)selections.size()) return; + Selection &s = selections[selHnd - 1]; + for (Atom *a : s.atoms) a->_setInSel(selHnd, false); + for (Residue *r : s.residues) r->_setInSel(selHnd, false); + for (Chain *c : s.chains) c->_setInSel(selHnd, false); + s = Selection(); + } + void GetSelIndex(int selHnd, PPAtom &SelAtom, int &n) { + Selection &s = selections[selHnd - 1]; + SelAtom = s.atoms.data(); + n = (int)s.atoms.size(); + } + void GetSelIndex(int selHnd, PPResidue &SelRes, int &n) { + Selection &s = selections[selHnd - 1]; + SelRes = s.residues.data(); + n = (int)s.residues.size(); + } + void GetSelIndex(int selHnd, PPChain &SelChain, int &n) { + Selection &s = selections[selHnd - 1]; + SelChain = s.chains.data(); + n = (int)s.chains.size(); + } + // select atoms by serial-number range (iSer1..iSer2; 0,0 => all). + void SelectAtoms(int selHnd, int iSer1, int iSer2, SELECTION_KEY key) { + if (selHnd < 1 || selHnd > (int)selections.size()) return; + Selection &s = selections[selHnd - 1]; + std::vector pick; + for (Atom *a : all_atoms) { + int sn = a->g().serial; + if ((iSer1 == 0 && iSer2 == 0) || (sn >= iSer1 && sn <= iSer2)) pick.push_back(a); + } + if (key == SKEY_OR) { + for (Atom *a : pick) + if (!a->isInSelection(selHnd)) s.atoms.push_back(a); + } else { + for (Atom *a : s.atoms) a->_setInSel(selHnd, false); + s.atoms = pick; + } + s.type = STYPE_ATOM; + for (Atom *a : s.atoms) a->_setInSel(selHnd, true); + } + + // full spatial+CID atom selection (mmdb_selmngr.h) — sphere around (x,y,z) with + // chain/resname/atomname/element filters ("!X" = exclusion, "*" = any). + void SelectAtoms(int selHnd, int /*iModel*/, cpstr Chains, int ResNo1, cpstr /*Ins1*/, + int ResNo2, cpstr /*Ins2*/, cpstr RNames, cpstr ANames, cpstr Elements, + cpstr /*altLocs*/, cpstr /*segIDs*/, cpstr /*charges*/, + realtype /*occ1*/, realtype /*occ2*/, realtype x, realtype y, realtype z, + realtype radius, SELECTION_KEY key) { + if (selHnd < 1 || selHnd > (int)selections.size()) return; + Selection &s = selections[selHnd - 1]; + // self-contained comma-list matcher ("*"=any, "!X"=exclude); `detail::` is + // declared after Manager, so don't depend on it in this inline body. + auto trimws = [](const std::string &s) -> std::string { + size_t a = s.find_first_not_of(' '), b = s.find_last_not_of(' '); + return a == std::string::npos ? std::string() : s.substr(a, b - a + 1); + }; + auto inlist = [&trimws](cpstr list, const std::string &v) -> bool { + if (!list || !*list || std::strcmp(list, "*") == 0) return true; + std::string vt = trimws(v); + for (const char *p = list; *p;) { + const char *c = std::strchr(p, ','); + std::string tok(p, c ? (size_t)(c - p) : std::strlen(p)); + if (trimws(tok) == vt) return true; + if (!c) break; + p = c + 1; + } + return false; + }; + auto match = [&](cpstr list, const std::string &v) -> bool { + if (!list || !*list || std::strcmp(list, "*") == 0) return true; + if (list[0] == '!') return !inlist(list + 1, v); + return inlist(list, v); + }; + gemmi::Position pt(x, y, z); + double r2 = radius * radius; + std::vector pick; + for (Atom *a : all_atoms) { + if (radius > 0 && a->g().pos.dist_sq(pt) > r2) continue; + Residue *r = a->res; + int sn = r->GetSeqNum(); + if (ResNo1 != ANY_RES && sn < ResNo1) continue; + if (ResNo2 != ANY_RES && sn > ResNo2) continue; + if (!match(Chains, r->chain->g().name)) continue; + if (!match(RNames, std::string(r->GetResName()))) continue; + if (!match(ANames, std::string(a->GetAtomName()))) continue; + if (!match(Elements, gemmi::Element(a->g().element).name())) continue; + pick.push_back(a); + } + if (key == SKEY_OR) { + for (Atom *a : pick) + if (!a->isInSelection(selHnd)) s.atoms.push_back(a); + } else { + for (Atom *a : s.atoms) a->_setInSel(selHnd, false); + s.atoms = pick; + } + s.type = STYPE_ATOM; + for (Atom *a : s.atoms) a->_setInSel(selHnd, true); + } + + // --- misc hierarchy/bond/UDData ops used by Coot --- + void RemoveBonds() {} // gemmi has no persistent bond table + // Partial-hierarchy delete (mmdb Manager::Delete). Coot's use is + // Delete(MMDBFCM_SC) to drop secondary-structure/connectivity records before + // writing; also honour Coord (atoms) and Cryst (cell/SG) for completeness. + void Delete(int DelKey) { + bool all = DelKey == MMDBFCM_All; + if (all || (DelKey & MMDBFCM_SC)) { + for (Model *m : models) { + m->_links.clear(); + m->_linkrs.clear(); + m->_cispeps.clear(); + m->helices.data.clear(); + m->sheets.nSheets = 0; + m->sheets.sheet = nullptr; + m->_sheet_ptrs.clear(); + } + link_pool.clear(); + linkr_pool.clear(); + cispep_pool.clear(); + helix_pool.clear(); + sheet_pool.clear(); + strand_pool.clear(); + strandarr_pool.clear(); + } + if (all || (DelKey & MMDBFCM_Cryst)) { + st.cell = gemmi::UnitCell(); + st.spacegroup_hm.clear(); + } + if (all || (DelKey & MMDBFCM_Coord)) { + st.models.clear(); + build_from_gemmi(); + } + } + void DeleteAllModels() { + st.models.clear(); + build_from_gemmi(); + } // clears the hierarchy + void DeleteModel(int modelNo) { // 1-based; erase model + rebuild wrappers + int i = modelNo - 1; + if (i >= 0 && i < (int)st.models.size()) { + st.models.erase(st.models.begin() + i); + build_from_gemmi(); + } + } + pstr GetInputBuffer(pstr buf, int &count) { + count = 0; + if (buf) buf[0] = '\0'; + return buf; + } + // Insert (a copy of) an atom into the hierarchy (mmdb Manager::PutAtom). MMDB + // keeps a flat atom array with a parallel hierarchy rebuilt by FinishStructEdit; + // the shim's storage IS the hierarchy, so PutAtom finds/creates the chain and + // residue implied by the atom's source residue and appends a copy there. Only + // append (index<=0 or top) is supported — the semantics Coot relies on + // (create_mmdbmanager_from_atom_selection_straight). Returns the atom's 1-based + // position (so GetAtomI(pos) returns it). Defined out-of-line (needs Add*). + int PutAtom(int index, PAtom atom, int serNum = 0); + // hierarchy-level UDData (UDR_HIERARCHY) — Manager owns its own UDStore. + UDStore _ud; + int PutUDData(int h, int v) { return ud_put(this, UDR_HIERARCHY, _ud, h, v); } + int PutUDData(int h, realtype v) { return ud_put(this, UDR_HIERARCHY, _ud, h, v); } + int PutUDData(int h, cpstr v) { return ud_put(this, UDR_HIERARCHY, _ud, h, v); } + int GetUDData(int h, int &v) { return ud_get(this, UDR_HIERARCHY, _ud, h, v); } + int GetUDData(int h, realtype &v) { return ud_get(this, UDR_HIERARCHY, _ud, h, v); } + int GetUDData(int h, pstr &v) { return ud_get(this, UDR_HIERARCHY, _ud, h, v); } + // primary CID-range selection (STYPE via Select; SelectAtoms forwards as STYPE_ATOM) + void Select(int selHnd, SELECTION_TYPE sType, int iModel, cpstr Chains, + int ResNo1, cpstr Ins1, int ResNo2, cpstr Ins2, cpstr RNames, + cpstr ANames, cpstr Elements, cpstr altLocs, SELECTION_KEY selKey = SKEY_OR); + void SelectAtoms(int selHnd, int iModel, cpstr Chains, int ResNo1, cpstr Ins1, + int ResNo2, cpstr Ins2, cpstr RNames, cpstr ANames, + cpstr Elements, cpstr altLocs, SELECTION_KEY selKey = SKEY_OR) { + Select(selHnd, STYPE_ATOM, iModel, Chains, ResNo1, Ins1, ResNo2, Ins2, + RNames, ANames, Elements, altLocs, selKey); + } + void SelectSphere(int selHnd, SELECTION_TYPE sType, realtype x, realtype y, + realtype z, realtype r, SELECTION_KEY sKey = SKEY_OR); + // select-from-selection: combine selHnd2's contents into selHnd1 per sKey + void Select(int selHnd1, SELECTION_TYPE sType, int selHnd2, SELECTION_KEY sKey); + // atoms within [d1,d2] of any atom in the given set (defined in contacts.cc) + void SelectNeighbours(int selHnd, SELECTION_TYPE sType, PPAtom atoms, int nAtoms, + realtype d1, realtype d2, SELECTION_KEY sKey = SKEY_OR); + void SetFlag(int /*flags*/) {} // no-op: read/write behaviour is fixed + void SetFlag(cpstr /*flags*/) {} + int PutPDBString(cpstr /*card*/) { return Error_NoError; } // no-op + // No persistent bond table. Verified safe: Coot's only caller (make_bonds in + // coot-utils/bonded-atoms.cc) ignores the mmdb bond table and recomputes bonds + // itself from geometry, so a no-op here matches observed Coot behaviour. + int MakeBonds(bool /*calc*/) { return 0; } + + // flat atom access (across the whole hierarchy) + std::vector all_atoms; + int GetNumberOfAtoms() { return (int)all_atoms.size(); } + int GetNumberOfAtoms(bool /*countTers*/) { return (int)all_atoms.size(); } + int GetNumberOfAtoms(cpstr CID); // count atoms matching CID (defined below) + // MMDB GetAtomI is 1-based: returns Atom[index-1]. + PAtom GetAtomI(int i) { return (i >= 1 && i <= (int)all_atoms.size()) ? all_atoms[i - 1] : nullptr; } + void GetAtomTable(PPAtom &t, int &n) { + t = all_atoms.data(); + n = (int)all_atoms.size(); + } + void GetModelTable(PPModel &t, int &n) { + t = models.data(); + n = (int)models.size(); + } + void GetAtomStatistics(int selHnd, RAtomStat AS); // defined below + int MakeSelIndex(int selHnd) { + return (selHnd >= 1 && selHnd <= (int)selections.size()) + ? (int)selections[selHnd - 1].atoms.size() + : 0; + } + void SelectAtom(int selHnd, PAtom atom, SELECTION_KEY sKey, bool makeIndex = true); + // CID-string selection, e.g. "/1/A/10-20/CA" + void Select(int selHnd, SELECTION_TYPE sType, cpstr CID, SELECTION_KEY sKey); + + // ---- contacts (gemmi NeighborSearch; TMatrix path uses a uniform grid) ---- + // TMatrix is MMDB's optional symmetry transform applied to the 2nd set: when + // given, contacts.cc transforms that set and searches against it (symmetry + // mates); when null, gemmi NeighborSearch over the untransformed model is used. + void SeekContacts(PPAtom A1, int n1, PPAtom A2, int n2, realtype d1, + realtype d2, int seqDist, PContact &contact, int &ncontacts, + int maxlen = 0, pmat44 TMatrix = nullptr, long group = 0); + void SeekContacts(PPAtom A, int n, realtype d1, realtype d2, int seqDist, + PContact &contact, int &ncontacts, int maxlen = 0, + pmat44 TMatrix = nullptr, long group = 0); + // single-atom vs selection (forwards to the array overload with a 1-elem array) + void SeekContacts(PAtom a, PPAtom A2, int n2, realtype d1, realtype d2, int seqDist, + PContact &contact, int &ncontacts, int maxlen = 0, + pmat44 TMatrix = nullptr, long group = 0) { + PAtom a1[1] = {a}; + SeekContacts(a1, 1, A2, n2, d1, d2, seqDist, contact, ncontacts, maxlen, TMatrix, group); + } + + // Compact deferred residue deletions across the whole hierarchy: MMDB defers + // DeleteResidue (tombstone the slot, keep the count) until FinishStructEdit, so + // here we drop the null tombstone slots + their gemmi placeholder residues and + // rebuild the flat atom lists. (Atoms already stay in sync eagerly.) + void _rebuild_all_atoms() { + all_atoms.clear(); + for (Model *mw : models) { + mw->mgr = this; + mw->all_atoms.clear(); + for (Chain *cw : mw->chains) { + cw->mgr = this; + for (Residue *rw : cw->residues) + if (rw) { + rw->mgr = this; + for (Atom *aw : rw->atoms) { + // Rebind ownership pointers: residues added via AddResidue/ + // InsResidue (e.g. add_terminal_residue) carry atoms whose mgr + // still points at the deep-copy temporary (or is null). Atom + // UDData routes through Atom::mgr, so without this the new atoms + // fail Put/GetUDData with WrongHandle — which drops their bonds + // (the atom-index UDD never lands) and any UD colouring. + aw->mgr = this; + aw->res = rw; + all_atoms.push_back(aw); + mw->all_atoms.push_back(aw); + } + } + } + } + } + int FinishStructEdit() { + for (Model *mw : models) + for (Chain *cw : mw->chains) cw->_compact_residues(); + _rebuild_all_atoms(); + return 0; + } + + // ---- UDData registry ---- + struct UDReg { + UDR_TYPE type; + int kind; + std::string name; + int slot; + }; // kind:0=int,1=real,2=str + std::vector ud_regs; + int ud_counts[5][3] = {{0}}; // [UDR_TYPE][kind] -> next slot + + int RegisterUDInteger(UDR_TYPE t, cpstr name) { return _regUD(t, 0, name); } + int RegisterUDReal(UDR_TYPE t, cpstr name) { return _regUD(t, 1, name); } + int RegisterUDString(UDR_TYPE t, cpstr name) { return _regUD(t, 2, name); } + int GetUDDHandle(UDR_TYPE t, cpstr name) { + for (int i = 0; i < (int)ud_regs.size(); ++i) + if (ud_regs[i].type == t && ud_regs[i].name == name) return i + 1; + return 0; // MMDB: 0 == "not registered" — Coot relies on `if (handle == 0) Register…` + } + + private: + // MMDB UDData handles are 1-based (0 is reserved for "not registered", see + // GetUDDHandle). Return a 1-based handle; _ud_desc maps back with handle-1. + int _regUD(UDR_TYPE t, int kind, cpstr name) { + ud_regs.push_back({t, kind, name ? name : "", ud_counts[t][kind]++}); + return (int)ud_regs.size(); + } + + public: + // ---- I/O (defined in mmdb-shim/src/io.cc; keeps heavy gemmi write/read + // headers out of the ~229 Coot TUs that include mmdb_manager.h) ---- + ERROR_CODE ReadPDBASCII(cpstr fname); + ERROR_CODE ReadCoorFile(cpstr fname); // auto-detects PDB / mmCIF + ERROR_CODE WritePDBASCII(cpstr fname); + ERROR_CODE WriteCIFASCII(cpstr fname); + }; + +} // namespace mmdb diff --git a/mmdb-shim/include/mmdb2/_shim_types.hh b/mmdb-shim/include/mmdb2/_shim_types.hh new file mode 100644 index 0000000000..4000f95628 --- /dev/null +++ b/mmdb-shim/include/mmdb2/_shim_types.hh @@ -0,0 +1,513 @@ +// mmdb-shim — layer 1 of 4: scalar types, enums, and small record classes. +// +// This is the base layer of the gemmi-backed MMDB API shim (architecture B; see +// MMDB_SHIM_Recon_and_Plan.md). It provides MMDB's typedefs/enums, the per-object +// UDData+selection base (UDStore), forward declarations of the hierarchy classes, +// and the leaf "record" classes that carry no hierarchy (LINK / CISPEP / Cryst / +// Helix / Sheet / SymOps / Title …). Included first by the layers below. +#pragma once + +#include +#include // trim_str — normalise MMDB-padded names to gemmi's trimmed form +#include +#include // space-group / symmetry operators + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace mmdb { + + // ---- basic MMDB scalar/typedefs (real MMDB: mmdb_mattype.h / mmdb_defs.h) ---- + typedef double realtype; + typedef char *pstr; + typedef const char *cpstr; + typedef unsigned short word; + typedef char AtomName[20]; + typedef char ResName[20]; + typedef char InsCode[10]; + typedef char ChainID[10]; + typedef char Element[10]; + typedef char AltLoc[20]; + typedef char SegID[10]; + typedef char LinkRID[20]; // Refmac link ID + typedef unsigned char byte; // mmdb_mattype.h + typedef int *ivector; // mmdb_mattype.h 1-based vectors/matrices + typedef realtype *rvector; + typedef ivector *imatrix; + typedef rvector *rmatrix; + typedef char maxMMDBName[40]; + + // WhatIsSet mask flags (mmdb_atom.h ASET_FLAG) + enum ASET_FLAG { + ASET_Coordinates = 0x00000001, + ASET_Occupancy = 0x00000002, + ASET_tempFactor = 0x00000004, + ASET_CoordSigma = 0x00000010, + ASET_OccSigma = 0x00000020, + ASET_tFacSigma = 0x00000040, + ASET_Charge = 0x00000080, + ASET_Anis_tFac = 0x00000100, + ASET_Anis_tFSigma = 0x00001000, + ASET_All = 0x000FFFFF + }; + + // vector/matrix types (mmdb_defs.h) — plain fixed-size arrays of realtype + typedef realtype vect3[3]; + typedef realtype vect4[4]; + typedef vect3 mat33[3]; // realtype[3][3] + typedef vect4 mat44[4]; // realtype[4][4] + typedef mat44 *pmat44; + typedef mat44 &rmat44; + + enum ERROR_CODE { + Error_NoError = 0, + Error_CantOpenFile = 12, // matches real MMDB's value + Error_GeneralError1 = 1 + }; + + // ---- UDData (user-defined data) — real MMDB values (mmdb_uddata.h) ---- + enum UDR_TYPE { UDR_ATOM = 0, + UDR_RESIDUE = 1, + UDR_CHAIN = 2, + UDR_MODEL = 3, + UDR_HIERARCHY = 4 }; + enum UDDATA_CODE { UDDATA_Ok = 0, + UDDATA_WrongHandle = -1, + UDDATA_WrongUDRType = -2, + UDDATA_NoData = -3 }; + + // ---- Selection (real MMDB values: mmdb_selmngr.h) ---- + enum SELECTION_TYPE { STYPE_INVALID = -1, + STYPE_UNDEFINED = 0, + STYPE_ATOM = 1, + STYPE_RESIDUE = 2, + STYPE_CHAIN = 3, + STYPE_MODEL = 4 }; + enum SELECTION_KEY { SKEY_NEW = 0, + SKEY_OR = 1, + SKEY_AND = 2, + SKEY_XOR = 3, + SKEY_CLR = 4, + SKEY_XAND = 100 }; + inline const long int MinInt4 = -2147483647; + inline const long int MaxInt4 = 2147483647; + inline const int ANY_RES = -2147483647; // real MMDB: extern const == MinInt4 + inline const double Pi = 3.14159265358979323846; + + // PDB/CIF read flags (mmdb_io_file.h). Values are arbitrary distinct bits — the + // shim's SetFlag is a no-op, so only distinctness matters for Coot's bit ops. + enum MMDB_READ_FLAG { + MMDBF_AutoSerials = 0x00000001, + MMDBF_IgnoreDuplSeqNum = 0x00000002, + MMDBF_IgnoreBlankLines = 0x00000004, + MMDBF_IgnoreRemarks = 0x00000008, + MMDBF_IgnoreHash = 0x00000010, + MMDBF_IgnoreNonCoorPDBErrors = 0x00000020, + MMDBF_PrintCIFWarnings = 0x00000040, + MMDBF_All = 0x0000FFFF + }; + enum MMDB_FCM { MMDBFCM_None = 0, + MMDBFCM_All = 1, + MMDBFCM_Coord = 2, + MMDBFCM_Cryst = 4, + MMDBFCM_SC = 8 }; + typedef int COPY_MASK; // Coot uses `COPY_MASK cm = MMDBFCM_All` + bit arithmetic + + // Per-object UDData slots + selection membership bits. Each registered UDData + // handle maps to a (type,kind,slot); the object stores contiguous vectors + // indexed by slot. `_inSel[selHnd-1]` = is this object in selection selHnd + // (maintained by Manager::Select/SelectSphere/DeleteSelection). + struct UDStore { + std::vector _udi; + std::vector _udr; + std::vector _uds; + std::vector _inSel; + bool isInSelection(int selHnd) const { + return selHnd >= 1 && selHnd <= (int)_inSel.size() && _inSel[selHnd - 1]; + } + void _setInSel(int selHnd, bool v) { + if ((int)_inSel.size() < selHnd) _inSel.resize(selHnd, false); + _inSel[selHnd - 1] = v; + } + }; + + class Atom; + class Residue; + class Chain; + class Model; + class Manager; + typedef Atom *PAtom; + typedef Atom **PPAtom; + typedef Residue *PResidue; + typedef Residue **PPResidue; + typedef Chain *PChain; + typedef Chain **PPChain; + typedef Model *PModel; + typedef Model **PPModel; + typedef Manager *PManager; + typedef Manager **PPManager; + + struct Contact { + int id1, id2; + long group; + realtype dist; + }; + typedef Contact *PContact; + + // base for records held in MMDB containers (Title compound/author, LINK, …) + class ContainerClass { + public: + virtual ~ContainerClass() {} + }; + typedef ContainerClass *PContainerClass; + + // LINK record. Public data members mirror real MMDB (Coot reads them directly). + // Populated from gemmi Structure::connections on load (Manager::_load_metadata); + // Coot-created links are appended via Model::AddLink. + class Link : public ContainerClass { + public: + AtomName atName1{}, atName2{}; + AltLoc aloc1{}, aloc2{}; + ResName resName1{}, resName2{}; + ChainID chainID1{}, chainID2{}; + InsCode insCode1{}, insCode2{}; + int seqNum1 = 0, seqNum2 = 0; + int s1 = 1, i1 = 0, j1 = 0, k1 = 0; // symmetry id of 1st atom + int s2 = 1, i2 = 0, j2 = 0, k2 = 0; // symmetry id of 2nd atom + realtype dist = 0; + void Copy(PContainerClass o) { + if (auto *l = dynamic_cast(o)) *this = *l; + } + }; + typedef Link *PLink; + typedef Link **PPLink; + + // Refmac LINK record (mmdb_model.h LinkR). Public members mirror real MMDB; + // populated from gemmi Connections carrying a link_id (Manager::_load_metadata). + class LinkR { + public: + LinkRID linkRID{}; + AtomName atName1{}, atName2{}; + AltLoc aloc1{}, aloc2{}; + ResName resName1{}, resName2{}; + ChainID chainID1{}, chainID2{}; + int seqNum1 = 0, seqNum2 = 0; + InsCode insCode1{}, insCode2{}; + realtype dist = 0; + }; + typedef LinkR *PLinkR; + typedef LinkR **PPLinkR; + + // CIS-peptide record (mmdb_model.h CisPep). Public members mirror real MMDB; + // populated from gemmi Structure::cispeps on load (Manager::_load_metadata). + class CisPep { + public: + int serNum = 0; + ResName pep1{}; + ChainID chainID1{}; + int seqNum1 = 0; + InsCode icode1{}; + ResName pep2{}; + ChainID chainID2{}; + int seqNum2 = 0; + InsCode icode2{}; + int modNum = 0; + realtype measure = 0; + }; + typedef CisPep *PCisPep; + + // Container of LINK records (mmdb_model.h LinkContainer). Minimal: Coot only + // declares `empty_links_container()` returning one by value; never dereferenced. + class LinkContainer { + public: + std::vector data; + int Length() { return (int)data.size(); } + PContainerClass GetContainerClass(int i) { return (i >= 0 && i < (int)data.size()) ? data[i] : nullptr; } + }; + typedef LinkContainer *PLinkContainer; + + // PDB title records (mmdb_title.h). Coot subclasses Manager & Title to reach the + // COMPND/AUTHOR line containers. The AUTHOR container is filled from gemmi + // meta.authors on load and the TITLE string comes from Structure::get_info + // ("_struct.title"); COMPND/JRNL have no structured gemmi home, so those + // containers stay empty. + class Compound : public ContainerClass { + public: + char Line[256] = {0}; + }; + typedef Compound *PCompound; + class Author : public ContainerClass { + public: + char Line[256] = {0}; + }; + typedef Author *PAuthor; + class Journal : public ContainerClass { + public: + char Line[256] = {0}; + }; + typedef Journal *PJournal; + class TitleContainer { + public: + std::vector data; + int Length() { return (int)data.size(); } + PContainerClass GetContainerClass(int i) { + return (i >= 0 && i < (int)data.size()) ? data[i] : nullptr; + } + }; + class Title { + public: + TitleContainer compound, author, journal; // public so Coot's access_title can reach them + TitleContainer *GetCompound() { return &compound; } // real Title exposes these + TitleContainer *GetAuthor() { return &author; } // publicly; access_title + TitleContainer *GetJournal() { return &journal; } // inherits GetJournal() + }; + + // gzip mode flag (mmdb_io_file.h). Minimal mmdb::io — the shim does I/O via gemmi, + // so only this compression-mode enum is provided (Coot passes it to write calls). + namespace io { + enum GZ_MODE { GZM_NONE = 0, + GZM_CHECK = 1, + GZM_ENFORCE = 2 }; + } + + // initialise a 4x4 matrix to identity (mmdb_mattype.h Mat4Init) + inline void Mat4Init(mat44 &A) { + for (int i = 0; i < 4; ++i) + for (int j = 0; j < 4; ++j) A[i][j] = (i == j) ? 1.0 : 0.0; + } + + // Orthogonal symmetry transformation for operator Nop (0-based) + integer cell + // shifts, from a gemmi cell + space group. The op acts in fractional space; we + // conjugate it with the cell frac<->orth transforms so TMatrix maps orthogonal + // coordinates directly (MMDB semantics). Returns 0 on success, 1 if there is no + // usable space group / the operator is out of range. Shared by Manager and Cryst. + inline int gemmi_sym_tmatrix(const gemmi::UnitCell &cell, const std::string &sg_name, + mat44 &TMatrix, int Nop, int a, int b, int c) { + Mat4Init(TMatrix); + const gemmi::SpaceGroup *sg = gemmi::find_spacegroup_by_name(sg_name); + if (!sg || !cell.is_crystal()) return 1; + gemmi::GroupOps gops = sg->operations(); + if (Nop < 0 || Nop >= (int)gops.order()) return 1; + int i = 0; + gemmi::Op op; + for (gemmi::Op o : gops) { + if (i++ == Nop) { + op = o; + break; + } + } + gemmi::Transform sym{gemmi::rot_as_mat33(op), + gemmi::tran_as_vec3(op) + gemmi::Vec3(a, b, c)}; + gemmi::Transform t = cell.orth.combine(sym).combine(cell.frac); + for (int r = 0; r < 3; ++r) { + for (int cc = 0; cc < 3; ++cc) TMatrix[r][cc] = t.mat.a[r][cc]; + TMatrix[r][3] = t.vec.at(r); + } + return 0; + } + + // Crystal/symmetry record (mmdb_cryst.h). Holds a gemmi cell + space-group name + // and computes symmetry through the shared helper — same result as Manager for a + // populated Cryst (Manager is the usual live symmetry path). + class Cryst { + public: + gemmi::UnitCell cell; + std::string spaceGroup; + virtual ~Cryst() {} + int GetTMatrix(mat44 &T, int Nop, int a, int b, int c) { + return gemmi_sym_tmatrix(cell, spaceGroup, T, Nop, a, b, c); + } + int GetNumberOfSymOps() { + const gemmi::SpaceGroup *sg = gemmi::find_spacegroup_by_name(spaceGroup); + return sg ? (int)sg->operations().order() : 0; + } + pstr GetSymOp(int Nop) { + const gemmi::SpaceGroup *sg = gemmi::find_spacegroup_by_name(spaceGroup); + if (!sg) return nullptr; + int i = 0; + for (gemmi::Op op : sg->operations()) + if (i++ == Nop) { + _symop_buf = op.triplet(); + return (pstr)_symop_buf.c_str(); + } + return nullptr; + } + + private: + std::string _symop_buf; + }; + typedef Cryst *PCryst; + + // mmdb::math graph-matching subsystem — full classes defined in _graph_impl.hh + // (included at end of this file, after Atom/Residue are complete). Only the + // Alignment class (unused by the cootapi build) stays a forward decl. + namespace math { + class Alignment; + } + + struct AtomBond { + PAtom atom = nullptr; + int order = 0; + }; + typedef AtomBond *PAtomBond; + typedef AtomBond **PPAtomBond; + + struct AtomStat { // selection coordinate statistics (mmdb_atom.h) + int nAtoms = 0; + realtype xmin = 0, ymin = 0, zmin = 0, xmax = 0, ymax = 0, zmax = 0; + realtype xm = 0, ym = 0, zm = 0; // coordinate means (centroid) + realtype GetMaxSize() { + realtype dx = xmax - xmin, dy = ymax - ymin, dz = zmax - zmin; + return dx > dy ? (dx > dz ? dx : dz) : (dy > dz ? dy : dz); + } + }; + typedef AtomStat &RAtomStat; + + // secondary-structure element codes (mmdb_tables.h) + enum SSE_CODE { SSE_None = 0, + SSE_Strand = 1, + SSE_Bulge = 2, + SSE_3Turn = 3, + SSE_4Turn = 4, + SSE_5Turn = 5, + SSE_Helix = 6 }; + + // PDBCleanup flags (mmdb_root.h) — bit flags OR'd into PDBCleanup(word) + // misc return-code / sort-key enums (mmdb_cryst.h / mmdb_selmngr.h / mmdb_tables.h) + enum { SYMOP_Ok = 0, + SYMOP_NoLibFile = -1, + SYMOP_UnknownSpaceGroup = -2 }; + enum { SSERC_Ok = 0, + SSERC_noResidues = 1 }; + enum { SORT_CHAIN_ChainID_Asc = 0, + SORT_CHAIN_ChainID_Desc = 1 }; + enum { CNSORT_OFF = 0, + CNSORT_1INC = 1, + CNSORT_1DEC = 2, + CNSORT_2INC = 3, + CNSORT_2DEC = 4 }; + + enum PDB_CLEAN_FLAG { + PDBCLEAN_ATNAME = 0x00000001, + PDBCLEAN_TER = 0x00000002, + PDBCLEAN_CHAIN = 0x00000004, + PDBCLEAN_CHAIN_STRONG = 0x00000008, + PDBCLEAN_ALTCODE = 0x00000010, + PDBCLEAN_ALTCODE_STRONG = 0x00000020, + PDBCLEAN_SERIAL = 0x00000040, + PDBCLEAN_SEQNUM = 0x00000080, + PDBCLEAN_INDEX = 0x00000800, + PDBCLEAN_ELEMENT = 0x00001000, + PDBCLEAN_ELEMENT_STRONG = 0x00002000 + }; + + // SS records — public-member structs. Model::GetNumberOf{Helices,Sheets} are + // populated from gemmi Structure::{helices,sheets} on load (_load_metadata) and + // also fillable by Coot's own SS computation via the access_model subclass. + class Helix { + public: + ChainID initChainID{}, endChainID{}; + int initSeqNum = 0, endSeqNum = 0, serNum = 0, helixClass = 0, length = 0; + ResName initResName{}, endResName{}; + InsCode initICode{}, endICode{}; + char helixID[20]{}, comment[80]{}; + }; + class Strand { + public: + ChainID initChainID{}, endChainID{}; + int initSeqNum = 0, endSeqNum = 0, strandNo = 0, sense = 0; + ResName initResName{}, endResName{}; + InsCode initICode{}, endICode{}; + char sheetID[20]{}; + }; + class Sheet { + public: + int nStrands = 0; + Strand **strand = nullptr; + char sheetID[20]{}; + }; + class Sheets { + public: + int nSheets = 0; + Sheet **sheet = nullptr; + }; // filled from gemmi in _load_metadata + typedef Helix *PHelix; + typedef Strand *PStrand; + typedef Sheet *PSheet; + typedef Sheets *PSheets; + // container of helices (Model.helices); Coot's access_model subclass fills it. + class Helices { + public: + std::vector data; + void AddData(PHelix h) { + if (h) data.push_back(h); + } + int nHelices = 0; + }; + + // container of symmetry operators (mmdb_symop.h SymOps). Coot fills it from a + // space group; ops are xyz-triplet strings. + class SymOps { + std::vector ops; + std::deque buf; + + public: + int AddSymOp(cpstr xyz) { + ops.push_back(xyz ? xyz : ""); + return 0; + } + int GetNofSymOps() { return (int)ops.size(); } + pstr GetSymOp(int n) { + if (n < 0 || n >= (int)ops.size()) return nullptr; + buf.push_back(ops[n]); + return (pstr)buf.back().c_str(); + } + void FreeMemory() { ops.clear(); } + }; + + [[noreturn]] inline void unimpl(const char *w) { + throw std::logic_error(std::string("mmdb-shim: unimplemented: ") + w); + } + + // ---- free functions (mmdb_tables.h / mmdb_mattype.h) ---- + inline void InitMatType() {} // real MMDB inits static matrix-type tables; no-op here + inline cpstr GetErrorDescription(ERROR_CODE ec) { + switch (ec) { + case Error_NoError: + return "no error"; + case Error_CantOpenFile: + return "cannot open file"; + default: + return "MMDB error"; + } + } + inline realtype getVdWaalsRadius(cpstr element) { + return gemmi::Element(element ? element : "X").vdw_r(); + } + + // Borrowed empty C-string, returned by the delegating accessors when an object + // is detached (no parent) — real MMDB yields safe defaults, not a crash. + inline pstr mmdb_empty_pstr() { + static char e[1] = {0}; + return e; + } + + // UDData helpers (defined after Manager); each class forwards with its UDR type. + int ud_put(Manager *mgr, UDR_TYPE myType, UDStore &s, int handle, int v); + int ud_put(Manager *mgr, UDR_TYPE myType, UDStore &s, int handle, realtype v); + int ud_put(Manager *mgr, UDR_TYPE myType, UDStore &s, int handle, cpstr v); + int ud_get(Manager *mgr, UDR_TYPE myType, UDStore &s, int handle, int &v); + int ud_get(Manager *mgr, UDR_TYPE myType, UDStore &s, int handle, realtype &v); + int ud_get(Manager *mgr, UDR_TYPE myType, UDStore &s, int handle, pstr &v); + +} // namespace mmdb diff --git a/mmdb-shim/include/mmdb2/mmdb_atom.h b/mmdb-shim/include/mmdb2/mmdb_atom.h new file mode 100644 index 0000000000..1c85475ad5 --- /dev/null +++ b/mmdb-shim/include/mmdb2/mmdb_atom.h @@ -0,0 +1,11 @@ +// mmdb-shim public header. When COOT_USE_MMDB_SHIM is defined, resolves to the +// gemmi-backed shim; otherwise falls through to the real MMDB header via +// #include_next (requires this dir to precede real mmdb2 on the include path). +#ifndef COOT_MMDB_SHIM_mmdb_atom_H +#define COOT_MMDB_SHIM_mmdb_atom_H +# ifdef COOT_USE_MMDB_SHIM +# include "_shim_impl.hh" +# else +# include_next +# endif +#endif diff --git a/mmdb-shim/include/mmdb2/mmdb_chain.h b/mmdb-shim/include/mmdb2/mmdb_chain.h new file mode 100644 index 0000000000..2b8a0940de --- /dev/null +++ b/mmdb-shim/include/mmdb2/mmdb_chain.h @@ -0,0 +1,11 @@ +// mmdb-shim public header. When COOT_USE_MMDB_SHIM is defined, resolves to the +// gemmi-backed shim; otherwise falls through to the real MMDB header via +// #include_next (requires this dir to precede real mmdb2 on the include path). +#ifndef COOT_MMDB_SHIM_mmdb_chain_H +#define COOT_MMDB_SHIM_mmdb_chain_H +# ifdef COOT_USE_MMDB_SHIM +# include "_shim_impl.hh" +# else +# include_next +# endif +#endif diff --git a/mmdb-shim/include/mmdb2/mmdb_coormngr.h b/mmdb-shim/include/mmdb2/mmdb_coormngr.h new file mode 100644 index 0000000000..36f8af4efc --- /dev/null +++ b/mmdb-shim/include/mmdb2/mmdb_coormngr.h @@ -0,0 +1,11 @@ +// mmdb-shim public header. When COOT_USE_MMDB_SHIM is defined, resolves to the +// gemmi-backed shim; otherwise falls through to the real MMDB header via +// #include_next (requires this dir to precede real mmdb2 on the include path). +#ifndef COOT_MMDB_SHIM_mmdb_coormngr_H +#define COOT_MMDB_SHIM_mmdb_coormngr_H +# ifdef COOT_USE_MMDB_SHIM +# include "_shim_impl.hh" +# else +# include_next +# endif +#endif diff --git a/mmdb-shim/include/mmdb2/mmdb_defs.h b/mmdb-shim/include/mmdb2/mmdb_defs.h new file mode 100644 index 0000000000..3765f7795f --- /dev/null +++ b/mmdb-shim/include/mmdb2/mmdb_defs.h @@ -0,0 +1,11 @@ +// mmdb-shim public header. When COOT_USE_MMDB_SHIM is defined, resolves to the +// gemmi-backed shim; otherwise falls through to the real MMDB header via +// #include_next (requires this dir to precede real mmdb2 on the include path). +#ifndef COOT_MMDB_SHIM_mmdb_defs_H +#define COOT_MMDB_SHIM_mmdb_defs_H +# ifdef COOT_USE_MMDB_SHIM +# include "_shim_impl.hh" +# else +# include_next +# endif +#endif diff --git a/mmdb-shim/include/mmdb2/mmdb_manager.h b/mmdb-shim/include/mmdb2/mmdb_manager.h new file mode 100644 index 0000000000..be05d71526 --- /dev/null +++ b/mmdb-shim/include/mmdb2/mmdb_manager.h @@ -0,0 +1,11 @@ +// mmdb-shim public header. When COOT_USE_MMDB_SHIM is defined, resolves to the +// gemmi-backed shim; otherwise falls through to the real MMDB header via +// #include_next (requires this dir to precede real mmdb2 on the include path). +#ifndef COOT_MMDB_SHIM_mmdb_manager_H +#define COOT_MMDB_SHIM_mmdb_manager_H +# ifdef COOT_USE_MMDB_SHIM +# include "_shim_impl.hh" +# else +# include_next +# endif +#endif diff --git a/mmdb-shim/include/mmdb2/mmdb_math_align.h b/mmdb-shim/include/mmdb2/mmdb_math_align.h new file mode 100644 index 0000000000..e3ed007f1e --- /dev/null +++ b/mmdb-shim/include/mmdb2/mmdb_math_align.h @@ -0,0 +1,11 @@ +// mmdb-shim public header. When COOT_USE_MMDB_SHIM is defined, resolves to the +// gemmi-backed shim; otherwise falls through to the real MMDB header via +// #include_next (requires this dir to precede real mmdb2 on the include path). +#ifndef COOT_MMDB_SHIM_mmdb_math_align_H +#define COOT_MMDB_SHIM_mmdb_math_align_H +# ifdef COOT_USE_MMDB_SHIM +# include "_shim_impl.hh" +# else +# include_next +# endif +#endif diff --git a/mmdb-shim/include/mmdb2/mmdb_math_graph.h b/mmdb-shim/include/mmdb2/mmdb_math_graph.h new file mode 100644 index 0000000000..0e40f6721b --- /dev/null +++ b/mmdb-shim/include/mmdb2/mmdb_math_graph.h @@ -0,0 +1,11 @@ +// mmdb-shim public header. When COOT_USE_MMDB_SHIM is defined, resolves to the +// gemmi-backed shim; otherwise falls through to the real MMDB header via +// #include_next (requires this dir to precede real mmdb2 on the include path). +#ifndef COOT_MMDB_SHIM_mmdb_math_graph_H +#define COOT_MMDB_SHIM_mmdb_math_graph_H +# ifdef COOT_USE_MMDB_SHIM +# include "_shim_impl.hh" +# else +# include_next +# endif +#endif diff --git a/mmdb-shim/include/mmdb2/mmdb_mattype.h b/mmdb-shim/include/mmdb2/mmdb_mattype.h new file mode 100644 index 0000000000..fc9a94a271 --- /dev/null +++ b/mmdb-shim/include/mmdb2/mmdb_mattype.h @@ -0,0 +1,11 @@ +// mmdb-shim public header. When COOT_USE_MMDB_SHIM is defined, resolves to the +// gemmi-backed shim; otherwise falls through to the real MMDB header via +// #include_next (requires this dir to precede real mmdb2 on the include path). +#ifndef COOT_MMDB_SHIM_mmdb_mattype_H +#define COOT_MMDB_SHIM_mmdb_mattype_H +# ifdef COOT_USE_MMDB_SHIM +# include "_shim_impl.hh" +# else +# include_next +# endif +#endif diff --git a/mmdb-shim/include/mmdb2/mmdb_model.h b/mmdb-shim/include/mmdb2/mmdb_model.h new file mode 100644 index 0000000000..070e0f1a40 --- /dev/null +++ b/mmdb-shim/include/mmdb2/mmdb_model.h @@ -0,0 +1,11 @@ +// mmdb-shim public header. When COOT_USE_MMDB_SHIM is defined, resolves to the +// gemmi-backed shim; otherwise falls through to the real MMDB header via +// #include_next (requires this dir to precede real mmdb2 on the include path). +#ifndef COOT_MMDB_SHIM_mmdb_model_H +#define COOT_MMDB_SHIM_mmdb_model_H +# ifdef COOT_USE_MMDB_SHIM +# include "_shim_impl.hh" +# else +# include_next +# endif +#endif diff --git a/mmdb-shim/include/mmdb2/mmdb_selmngr.h b/mmdb-shim/include/mmdb2/mmdb_selmngr.h new file mode 100644 index 0000000000..1028c48ecb --- /dev/null +++ b/mmdb-shim/include/mmdb2/mmdb_selmngr.h @@ -0,0 +1,11 @@ +// mmdb-shim public header. When COOT_USE_MMDB_SHIM is defined, resolves to the +// gemmi-backed shim; otherwise falls through to the real MMDB header via +// #include_next (requires this dir to precede real mmdb2 on the include path). +#ifndef COOT_MMDB_SHIM_mmdb_selmngr_H +#define COOT_MMDB_SHIM_mmdb_selmngr_H +# ifdef COOT_USE_MMDB_SHIM +# include "_shim_impl.hh" +# else +# include_next +# endif +#endif diff --git a/mmdb-shim/include/mmdb2/mmdb_tables.h b/mmdb-shim/include/mmdb2/mmdb_tables.h new file mode 100644 index 0000000000..aeee5d9dcd --- /dev/null +++ b/mmdb-shim/include/mmdb2/mmdb_tables.h @@ -0,0 +1,11 @@ +// mmdb-shim public header. When COOT_USE_MMDB_SHIM is defined, resolves to the +// gemmi-backed shim; otherwise falls through to the real MMDB header via +// #include_next (requires this dir to precede real mmdb2 on the include path). +#ifndef COOT_MMDB_SHIM_mmdb_tables_H +#define COOT_MMDB_SHIM_mmdb_tables_H +# ifdef COOT_USE_MMDB_SHIM +# include "_shim_impl.hh" +# else +# include_next +# endif +#endif diff --git a/mmdb-shim/include/mmdb2/mmdb_uddata.h b/mmdb-shim/include/mmdb2/mmdb_uddata.h new file mode 100644 index 0000000000..36444b2760 --- /dev/null +++ b/mmdb-shim/include/mmdb2/mmdb_uddata.h @@ -0,0 +1,11 @@ +// mmdb-shim public header. When COOT_USE_MMDB_SHIM is defined, resolves to the +// gemmi-backed shim; otherwise falls through to the real MMDB header via +// #include_next (requires this dir to precede real mmdb2 on the include path). +#ifndef COOT_MMDB_SHIM_mmdb_uddata_H +#define COOT_MMDB_SHIM_mmdb_uddata_H +# ifdef COOT_USE_MMDB_SHIM +# include "_shim_impl.hh" +# else +# include_next +# endif +#endif diff --git a/mmdb-shim/include/mmdb2/mmdb_utils.h b/mmdb-shim/include/mmdb2/mmdb_utils.h new file mode 100644 index 0000000000..c60636697e --- /dev/null +++ b/mmdb-shim/include/mmdb2/mmdb_utils.h @@ -0,0 +1,11 @@ +// mmdb-shim public header. When COOT_USE_MMDB_SHIM is defined, resolves to the +// gemmi-backed shim; otherwise falls through to the real MMDB header via +// #include_next (requires this dir to precede real mmdb2 on the include path). +#ifndef COOT_MMDB_SHIM_mmdb_utils_H +#define COOT_MMDB_SHIM_mmdb_utils_H +# ifdef COOT_USE_MMDB_SHIM +# include "_shim_impl.hh" +# else +# include_next +# endif +#endif diff --git a/mmdb-shim/include/ssm/ssm_align.h b/mmdb-shim/include/ssm/ssm_align.h new file mode 100644 index 0000000000..eda5542195 --- /dev/null +++ b/mmdb-shim/include/ssm/ssm_align.h @@ -0,0 +1,72 @@ +// -*- mode: c++; -*- +// +// mmdb-shim: no-op replacement for . +// +// The real SSM library (libssm) is a precompiled binary built against REAL MMDB +// 2.0.22, and its headers derive from mmdb::io::Stream / use mmdb binary +// serialization (DefineClass, io::RFile) that the gemmi-backed shim does not +// provide. Worse, even if the headers parsed, passing shim mmdb objects (thin +// gemmi wrappers) into precompiled ssm would be an ABI mismatch -> crash. +// +// Per the project decision to NOT build SSM code against the shim (SSM is being +// removed/replaced), this header shadows the real ssm/ssm_align.h (the shim +// include dir precedes ssm's on the -I path) with a self-contained, header-only, +// no-op ssm::Align. Everything compiles and links (no real libssm symbols are +// referenced); SSM structural superposition simply reports "no match" (identity +// transform), so callers take their no-alignment path. +// +// Copyright 2026 by Medical Research Council Laboratory of Molecular Biology +#ifndef COOT_MMDB_SHIM_SSM_ALIGN_H +#define COOT_MMDB_SHIM_SSM_ALIGN_H + +#include // mmdb::mat44/realtype/ivector/rvector/PManager (shim) + +namespace ssm { + +// return codes (ssm_defs.h RETURN_CODE) +enum RETURN_CODE { RC_Ok, RC_NoHits, RC_NoSuperposition, RC_NoGraph, + RC_NoVertices, RC_NoGraph2, RC_NoVertices2, RC_TooFewMatches }; +// precision levels (ssm_defs.h PRECISION) +enum PRECISION { PREC_Highest, PREC_High, PREC_Normal, PREC_Low, PREC_Lowest }; +// connectivity check modes (ssm_defs.h CONNECTIVITY) +enum CONNECTIVITY { CONNECT_None, CONNECT_Flexible, CONNECT_Strict }; + +// global tuning knobs (ssm_vxedge.h) — no-ops in the shim +inline void SetMatchPrecision(PRECISION) {} +inline void SetConnectivityCheck(CONNECTIVITY) {} + +// SSM structure alignment result + driver. Public fields mirror ssm::Align so +// Coot's superpose code compiles; all methods are inert. +class Align { + public: + mmdb::mat44 TMatrix; // superposition matrix (identity => no move) + mmdb::realtype rmsd = 0, Qscore = 0, ncombs = 0, seqIdentity = 0; + int cnCheck = 0; + int nres1 = 0, nres2 = 0; // residues in each structure + int nsel1 = 0, nsel2 = 0; // residues in aligned selections + int nalgn = 0, ngaps = 0, nmd = 0; + int selHndCa1 = 0, selHndCa2 = 0; + mmdb::ivector Ca1 = nullptr, Ca2 = nullptr; // C-alpha correspondence vectors + mmdb::rvector dist1 = nullptr; // optimised C-alpha distances + + Align() { + for (int i = 0; i < 4; ++i) + for (int j = 0; j < 4; ++j) TMatrix[i][j] = (i == j) ? 1.0 : 0.0; + } + ~Align() {} + + // no-op alignment: report "no hits" with an identity transform and zero counts, + // so callers skip the Ca1/Ca2 correspondence loops (bounded by nsel*/nalgn == 0). + int align(mmdb::PManager, mmdb::PManager, PRECISION, CONNECTIVITY, + int /*selHnd1*/ = 0, int /*selHnd2*/ = 0) { return RC_NoHits; } + int AlignSelectedMatch(mmdb::PManager, mmdb::PManager, PRECISION, CONNECTIVITY, + int /*selHnd1*/ = 0, int /*selHnd2*/ = 0, int /*nselect*/ = 0) { + return RC_NoHits; + } + int GetNMatches() const { return 0; } +}; +typedef Align *PAlign; + +} // namespace ssm + +#endif // COOT_MMDB_SHIM_SSM_ALIGN_H diff --git a/mmdb-shim/src/contacts.cc b/mmdb-shim/src/contacts.cc new file mode 100644 index 0000000000..a087d6f232 --- /dev/null +++ b/mmdb-shim/src/contacts.cc @@ -0,0 +1,211 @@ +// mmdb-shim contact search — Manager::SeekContacts via gemmi::NeighborSearch +// (grid-accelerated; handles crystallographic PBC and non-crystal bounding box). +// Compiled separately so gemmi/neighbor.hpp stays out of Coot's many TUs. +#define COOT_USE_MMDB_SHIM 1 +#include + +#include + +#include +#include +#include +#include +#include + +namespace mmdb { + namespace { + + bool seqNeglect(Atom *a, Atom *b, int seqDist); // defined below + + // apply an MMDB 4x4 (rot+trans) to a position (symmetry transform of a contact set) + gemmi::Position xform(pmat44 T, const gemmi::Position &p) { + const mat44 &m = *T; + return gemmi::Position(m[0][0] * p.x + m[0][1] * p.y + m[0][2] * p.z + m[0][3], + m[1][0] * p.x + m[1][1] * p.y + m[1][2] * p.z + m[1][3], + m[2][0] * p.x + m[2][1] * p.y + m[2][2] * p.z + m[2][3]); + } + + // Contacts between A1 and a TMatrix-transformed second set (positions tp) via a + // uniform grid — used when SeekContacts is given a symmetry operator. selfSkip + // suppresses an atom pairing with its own untransformed self at ~zero distance. + void contacts_transformed(PPAtom A1, int n1, PPAtom A2, const std::vector &tp, + realtype d1, realtype d2, int seqDist, long group, + bool selfSkip, std::vector &found) { + double bin = d2 > 0 ? d2 : 1.0, d1s = d1 * d1, d2s = d2 * d2; + auto cellof = [&](const gemmi::Position &p) { + return std::make_tuple((int)std::floor(p.x / bin), (int)std::floor(p.y / bin), + (int)std::floor(p.z / bin)); + }; + std::map, std::vector> grid; + for (int j = 0; j < (int)tp.size(); ++j) grid[cellof(tp[j])].push_back(j); + for (int i = 0; i < n1; ++i) { + const gemmi::Position &pi = A1[i]->g().pos; + int cx, cy, cz; + std::tie(cx, cy, cz) = cellof(pi); + for (int dx = -1; dx <= 1; ++dx) + for (int dy = -1; dy <= 1; ++dy) + for (int dz = -1; dz <= 1; ++dz) { + auto it = grid.find(std::make_tuple(cx + dx, cy + dy, cz + dz)); + if (it == grid.end()) continue; + for (int j : it->second) { + if (selfSkip && A1[i] == A2[j]) continue; + double ds = pi.dist_sq(tp[j]); + if (ds < d1s || ds > d2s) continue; + if (seqNeglect(A1[i], A2[j], seqDist)) continue; + found.push_back({i, j, group, std::sqrt(ds)}); + } + } + } + } + + bool seqNeglect(Atom *a, Atom *b, int seqDist) { + if (seqDist <= 0) return false; + if (a->res->chain != b->res->chain) return false; + return std::abs(a->GetSeqNum() - b->GetSeqNum()) < seqDist; + } + void alloc_contacts(std::vector &v, PContact &out, int &n) { + n = (int)v.size(); + out = n ? new Contact[n] : nullptr; // caller delete[]s (MMDB semantics) + for (int i = 0; i < n; ++i) out[i] = v[i]; + } + // Map a NeighborSearch Mark back to the shim wrapper via the parallel tree. + inline Atom *mark_to_atom(Model *mw, const gemmi::NeighborSearch::Mark *m) { + return mw->chains[m->chain_idx]->residues[m->residue_idx]->atoms[m->atom_idx]; + } + + template + void skcombine(Vec &cur, Vec &m, SELECTION_KEY k) { + std::set cs(cur.begin(), cur.end()), ms(m.begin(), m.end()); + if (k == SKEY_NEW) + cur = m; + else if (k == SKEY_OR) { + for (auto *x : m) + if (!cs.count(x)) cur.push_back(x); + } else if (k == SKEY_AND) { + Vec o; + for (auto *x : cur) + if (ms.count(x)) o.push_back(x); + cur = o; + } else if (k == SKEY_XOR) { + Vec o; + for (auto *x : cur) + if (!ms.count(x)) o.push_back(x); + for (auto *x : m) + if (!cs.count(x)) o.push_back(x); + cur = o; + } else if (k == SKEY_CLR) { + Vec o; + for (auto *x : cur) + if (!ms.count(x)) o.push_back(x); + cur = o; + } + } + + } // namespace + + // atoms within [d1,d2] of any atom in the given set. + void Manager::SelectNeighbours(int selHnd, SELECTION_TYPE sType, PPAtom atoms, + int nAtoms, realtype d1, realtype d2, SELECTION_KEY sKey) { + std::vector mAtoms; + std::vector mResidues; + if (nAtoms > 0) { + Model *mw = atoms[0]->res->chain->model; + gemmi::NeighborSearch ns(mw->g(), st.cell, d2); + ns.populate(true); + std::set seenA; + std::set seenR; + for (int i = 0; i < nAtoms; ++i) + for (auto *m : ns.find_atoms(atoms[i]->g().pos, '\0', d1, d2)) { + if (m->image_idx != 0) continue; + Atom *b = mark_to_atom(mw, m); + if (sType == STYPE_ATOM) { + if (seenA.insert(b).second) mAtoms.push_back(b); + } else if (sType == STYPE_RESIDUE) { + if (seenR.insert(b->res).second) mResidues.push_back(b->res); + } + } + } + Selection &sel = selections[selHnd - 1]; + if (sel.type == STYPE_UNDEFINED) sel.type = sType; + std::vector oldA = sel.atoms; + std::vector oldR = sel.residues; + if (sType == STYPE_ATOM) + skcombine(sel.atoms, mAtoms, sKey); + else if (sType == STYPE_RESIDUE) + skcombine(sel.residues, mResidues, sKey); + for (Atom *a : oldA) a->_setInSel(selHnd, false); + for (Atom *a : sel.atoms) a->_setInSel(selHnd, true); + for (Residue *r : oldR) r->_setInSel(selHnd, false); + for (Residue *r : sel.residues) r->_setInSel(selHnd, true); + } + + void Manager::SeekContacts(PPAtom A1, int n1, PPAtom A2, int n2, realtype d1, + realtype d2, int seqDist, PContact &contact, int &ncontacts, int /*maxlen*/, + pmat44 TMatrix, long group) { + std::vector found; + if (TMatrix && n1 > 0 && n2 > 0) { // contacts against a symmetry-transformed A2 + std::vector tp(n2); + for (int j = 0; j < n2; ++j) tp[j] = xform(TMatrix, A2[j]->g().pos); + contacts_transformed(A1, n1, A2, tp, d1, d2, seqDist, group, /*selfSkip=*/false, found); + alloc_contacts(found, contact, ncontacts); + return; + } + if (n1 > 0 && n2 > 0) { + Model *mw = A1[0]->res->chain->model; // NeighborSearch is per-model + gemmi::NeighborSearch ns(mw->g(), st.cell, d2); + ns.populate(true); + std::unordered_map a2idx; + a2idx.reserve(n2 * 2); + for (int j = 0; j < n2; ++j) a2idx.emplace(A2[j], j); + + for (int i = 0; i < n1; ++i) { + if (A1[i]->res->chain->model != mw) continue; // single-model contact search + for (auto *m : ns.find_atoms(A1[i]->g().pos, '\0', d1, d2)) { + if (m->image_idx != 0) continue; // exclude symmetry mates + Atom *b = mark_to_atom(mw, m); + if (A1[i] == b) continue; + auto it = a2idx.find(b); + if (it == a2idx.end()) continue; + if (seqNeglect(A1[i], b, seqDist)) continue; + found.push_back({i, it->second, group, A1[i]->g().pos.dist(b->g().pos)}); + } + } + } + alloc_contacts(found, contact, ncontacts); + } + + void Manager::SeekContacts(PPAtom A, int n, realtype d1, realtype d2, + int seqDist, PContact &contact, int &ncontacts, int /*maxlen*/, + pmat44 TMatrix, long group) { + std::vector found; + if (TMatrix && n > 0) { // self-contacts against the symmetry-transformed set + std::vector tp(n); + for (int i = 0; i < n; ++i) tp[i] = xform(TMatrix, A[i]->g().pos); + contacts_transformed(A, n, A, tp, d1, d2, seqDist, group, /*selfSkip=*/true, found); + alloc_contacts(found, contact, ncontacts); + return; + } + if (n > 0) { + Model *mw = A[0]->res->chain->model; + gemmi::NeighborSearch ns(mw->g(), st.cell, d2); + ns.populate(true); + std::unordered_map idx; + idx.reserve(n * 2); + for (int i = 0; i < n; ++i) idx.emplace(A[i], i); + + for (int i = 0; i < n; ++i) { + if (A[i]->res->chain->model != mw) continue; + for (auto *m : ns.find_atoms(A[i]->g().pos, '\0', d1, d2)) { + if (m->image_idx != 0) continue; + Atom *b = mark_to_atom(mw, m); + auto it = idx.find(b); + if (it == idx.end() || it->second <= i) continue; // unordered pairs, once + if (seqNeglect(A[i], b, seqDist)) continue; + found.push_back({i, it->second, group, A[i]->g().pos.dist(b->g().pos)}); + } + } + } + alloc_contacts(found, contact, ncontacts); + } + +} // namespace mmdb diff --git a/mmdb-shim/src/io.cc b/mmdb-shim/src/io.cc new file mode 100644 index 0000000000..a8b6545b1f --- /dev/null +++ b/mmdb-shim/src/io.cc @@ -0,0 +1,60 @@ +// mmdb-shim I/O — Manager read/write via gemmi (architecture B: gemmi is the +// live store, so read = parse + build wrapper tree; write = serialize st). +// Compiled once (links libgemmi_cpp) so the heavy gemmi write/read headers stay +// out of the many Coot TUs that include . +#define COOT_USE_MMDB_SHIM 1 +#include + +#include // read_structure_file (auto-detect) +#include // read_pdb_file +#include // write_pdb +#include // make_mmcif_document +#include // write_cif_to_stream + +#include + +namespace mmdb { + + // Rebuild the wrapper tree from a freshly loaded gemmi::Structure. gemmi's PDB/ + // mmCIF readers split a single author chain into polymer/ligand/water parts that + // share the chain name; MMDB keeps one chain per chain ID. For MMDB chain-count + // parity we merge those parts back (Structure::merge_chain_parts), so Coot sees + // one mmdb::Chain per chain ID, as it does with real MMDB. + ERROR_CODE Manager::ReadPDBASCII(cpstr fname) { + try { + st = gemmi::read_pdb_file(fname); + } catch (const std::exception &) { + return Error_CantOpenFile; + } + st.merge_chain_parts(); + build_from_gemmi(); + return Error_NoError; + } + + ERROR_CODE Manager::ReadCoorFile(cpstr fname) { + try { + st = gemmi::read_structure_file(fname); + } catch (const std::exception &) { + return Error_CantOpenFile; + } + st.merge_chain_parts(); + build_from_gemmi(); + return Error_NoError; + } + + ERROR_CODE Manager::WritePDBASCII(cpstr fname) { + std::ofstream os(fname); + if (!os) return Error_CantOpenFile; + gemmi::write_pdb(st, os); + return Error_NoError; + } + + ERROR_CODE Manager::WriteCIFASCII(cpstr fname) { + std::ofstream os(fname); + if (!os) return Error_CantOpenFile; + gemmi::cif::Document doc = gemmi::make_mmcif_document(st); + gemmi::cif::write_cif_to_stream(os, doc); + return Error_NoError; + } + +} // namespace mmdb diff --git a/pli/dots-representation-info.cc b/pli/dots-representation-info.cc index 38fc63f562..6a04eece0c 100644 --- a/pli/dots-representation-info.cc +++ b/pli/dots-representation-info.cc @@ -185,7 +185,7 @@ pli::dots_representation_info_t::pure_points(mmdb::Manager *mol) { for (int iat=0; iatGetAtom(iat); - local_points.push_back(clipper::Coord_orth(at->x, at->y, at->z)); + local_points.push_back(clipper::Coord_orth(at->x(), at->y(), at->z())); } } } @@ -218,7 +218,7 @@ pli::dots_representation_info_t::solvent_exposure(int SelHnd_in, mmdb::Manager * std::vector radius(n_atoms); for (int iat=0; iatelement); + std::string ele(atoms[iat]->GetElementName()); radius[iat] = get_radius(ele); } @@ -230,9 +230,9 @@ pli::dots_representation_info_t::solvent_exposure(int SelHnd_in, mmdb::Manager * for (int iatom=0; iatomisTer()) { - clipper::Coord_orth centre(atoms[iatom]->x, - atoms[iatom]->y, - atoms[iatom]->z); + clipper::Coord_orth centre(atoms[iatom]->x(), + atoms[iatom]->y(), + atoms[iatom]->z()); bool even = 1; int n_points = 0; int n_sa = 0; @@ -257,11 +257,11 @@ pli::dots_representation_info_t::solvent_exposure(int SelHnd_in, mmdb::Manager * std::string other_res_name = other_at->GetResName(); if (other_res_name != "HOH") { if (atoms[iatom] != other_at) { - std::string other_ele = other_at->element; + std::string other_ele = other_at->GetElementName(); if (other_ele != " H") { double other_atom_r = fudge * (get_radius(other_ele) + water_radius); double other_atom_r_sq = other_atom_r * other_atom_r; - clipper::Coord_orth pt_other(other_at->x, other_at->y, other_at->z); + clipper::Coord_orth pt_other(other_at->x(), other_at->y(), other_at->z()); if ((pt-pt_other).lengthsq() < other_atom_r_sq) { is_solvent_accessible = 0; break; @@ -279,7 +279,7 @@ pli::dots_representation_info_t::solvent_exposure(int SelHnd_in, mmdb::Manager * double exposure_frac = double(n_sa)/double(n_points); if (0) - std::cout << "Atom " << atoms[iatom]->name << " has exposure " << n_sa << "/" << n_points + std::cout << "Atom " << atoms[iatom]->GetAtomName() << " has exposure " << n_sa << "/" << n_points << " = " << exposure_frac << std::endl; std::pair p(atoms[iatom], exposure_frac); v.push_back(p); @@ -406,7 +406,7 @@ pli::dots_representation_info_t::add_dots(int SelHnd, mmdb::Manager *mol, std::vector radius_exclude; std::vector colour(n_atoms); for (int iat=0; iatelement); + std::string ele(atoms[iat]->GetElementName()); radius[iat] = get_radius(ele); if (use_single_colour) colour[iat] = single_colour; @@ -423,7 +423,7 @@ pli::dots_representation_info_t::add_dots(int SelHnd, mmdb::Manager *mol, mol_exclude->GetSelIndex(SelHnd_exclude, atoms_exclude, n_atoms_exclude); radius_exclude.resize(n_atoms_exclude); for (int iat=0; iatelement); + std::string ele(atoms_exclude[iat]->GetElementName()); radius_exclude[iat] = get_radius(ele); } } @@ -432,9 +432,9 @@ pli::dots_representation_info_t::add_dots(int SelHnd, mmdb::Manager *mol, std::vector local_points; coot::colour_t col = colour[iatom]; if (! atoms[iatom]->isTer()) { - clipper::Coord_orth centre(atoms[iatom]->x, - atoms[iatom]->y, - atoms[iatom]->z); + clipper::Coord_orth centre(atoms[iatom]->x(), + atoms[iatom]->y(), + atoms[iatom]->z()); bool even = true; for (double theta=0; thetaisTer()) { double radius_j = radius[jatom]; double radius_j_squared = radius_j * radius_j; - clipper::Coord_orth pt_j(atoms[jatom]->x, atoms[jatom]->y, atoms[jatom]->z); + clipper::Coord_orth pt_j(atoms[jatom]->x(), atoms[jatom]->y(), atoms[jatom]->z()); if ((pt-pt_j).lengthsq() < radius_j_squared) { draw_it = false; break; @@ -482,9 +482,9 @@ pli::dots_representation_info_t::add_dots(int SelHnd, mmdb::Manager *mol, double dist_j_squared = dist_j * dist_j; for (int jatom=0; jatomisTer()) { - clipper::Coord_orth pt_j(atoms_exclude[jatom]->x, - atoms_exclude[jatom]->y, - atoms_exclude[jatom]->z); + clipper::Coord_orth pt_j(atoms_exclude[jatom]->x(), + atoms_exclude[jatom]->y(), + atoms_exclude[jatom]->z()); if ((pt-pt_j).lengthsq() < dist_j_squared) { draw_it = true; break; diff --git a/pli/flev-annotations.hh b/pli/flev-annotations.hh index 435754a806..07a8c338ee 100644 --- a/pli/flev-annotations.hh +++ b/pli/flev-annotations.hh @@ -204,7 +204,7 @@ namespace pli { if (! ligand_atom_is_donor_flag) std::swap(ligand_atom, residue_atom); - if (is_a_metal(residue_atom->residue)) { + if (is_a_metal(residue_atom->GetResidue())) { r_bond_type = METAL_CONTACT_BOND; } else { diff --git a/pli/flev-attached-hydrogens.cc b/pli/flev-attached-hydrogens.cc index b95dbe3efd..76bbc654a7 100644 --- a/pli/flev-attached-hydrogens.cc +++ b/pli/flev-attached-hydrogens.cc @@ -161,7 +161,7 @@ pli::flev_attached_hydrogens_t::cannonballs(mmdb::Residue *ligand_residue_3d, if (n_contacts > 0) { for (int i=0; i< n_contacts; i++) { mmdb::Atom *at = non_hydrogen_selection[pscontact[i].id2]; - std::string atom_name_bonded_to_H(at->name); + std::string atom_name_bonded_to_H(at->GetAtomName()); bool found_torsion_for_this_H = 0; @@ -227,7 +227,7 @@ pli::flev_attached_hydrogens_t::distances_to_protein_using_correct_Hs(mmdb::Resi mmdb::Atom *lig_at = NULL; mmdb::Atom *H_at = NULL; for (int iat=0; iatname); + std::string atom_name(residue_atoms[iat]->GetAtomName()); if (atom_name == atoms_with_riding_hydrogens[irh].first) lig_at = residue_atoms[iat]; if (atom_name == atoms_with_riding_hydrogens[irh].second) @@ -237,8 +237,8 @@ pli::flev_attached_hydrogens_t::distances_to_protein_using_correct_Hs(mmdb::Resi } if (lig_at && H_at) { - clipper::Coord_orth H_pt(H_at->x, H_at->y, H_at->z); - clipper::Coord_orth lig_atom_pt(lig_at->x, lig_at->y, lig_at->z); + clipper::Coord_orth H_pt(H_at->x(), H_at->y(), H_at->z()); + clipper::Coord_orth lig_atom_pt(lig_at->x(), lig_at->y(), lig_at->z()); std::vector atoms = close_atoms(H_pt, env_residues); coot::bash_distance_t bash = find_bash_distance(lig_atom_pt, H_pt, atoms); @@ -258,7 +258,7 @@ pli::flev_attached_hydrogens_t::distances_to_protein_using_correct_Hs(mmdb::Resi mmdb::Atom *lig_at = NULL; mmdb::Atom *H_at = NULL; for (int iat=0; iatname); + std::string atom_name(residue_atoms[iat]->GetAtomName()); if (atom_name == atoms_with_rotating_hydrogens[irh].first) lig_at = residue_atoms[iat]; if (atom_name == atoms_with_rotating_hydrogens[irh].second) @@ -267,8 +267,8 @@ pli::flev_attached_hydrogens_t::distances_to_protein_using_correct_Hs(mmdb::Resi break; } if (lig_at && H_at) { - clipper::Coord_orth H_pt(H_at->x, H_at->y, H_at->z); - clipper::Coord_orth lig_atom_pt(lig_at->x, lig_at->y, lig_at->z); + clipper::Coord_orth H_pt(H_at->x(), H_at->y(), H_at->z()); + clipper::Coord_orth lig_atom_pt(lig_at->x(), lig_at->y(), lig_at->z()); std::vector atoms = close_atoms(H_pt, env_residues); @@ -424,7 +424,7 @@ pli::flev_attached_hydrogens_t::find_bash_distance(const clipper::Coord_orth &li // std::vector radius(close_residue_atoms.size()); for (unsigned int iat=0; iatelement); + std::string ele(close_residue_atoms[iat]->GetElementName()); radius[iat] = get_radius(ele); } @@ -433,9 +433,9 @@ pli::flev_attached_hydrogens_t::find_bash_distance(const clipper::Coord_orth &li std::vector atom_positions(close_residue_atoms.size()); // likewise set the atom positions so that we don't have to keep doing it. for (unsigned int i=0; ix, - close_residue_atoms[i]->y, - close_residue_atoms[i]->z); + atom_positions[i] = clipper::Coord_orth(close_residue_atoms[i]->x(), + close_residue_atoms[i]->y(), + close_residue_atoms[i]->z()); for (double slide=0; slide<=max_dist; slide+=0.04) { clipper::Coord_orth test_pt = ligand_atom_pos + slide * h_vector; @@ -486,7 +486,7 @@ pli::flev_attached_hydrogens_t::close_atoms(const clipper::Coord_orth &pt, int n_residue_atoms; residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatx, residue_atoms[iat]->y, residue_atoms[iat]->z); + clipper::Coord_orth atom_pos(residue_atoms[iat]->x(), residue_atoms[iat]->y(), residue_atoms[iat]->z()); double d_squared = (pt - atom_pos).lengthsq(); if (d_squared < dist_crit_squared) { std::string rn(residue_atoms[iat]->GetResName()); @@ -524,7 +524,7 @@ pli::flev_attached_hydrogens_t::get_atom_pos_bonded_to_atom(mmdb::Atom *lig_at, mmdb::Residue *ligand_residue, const coot::protein_geometry &geom) const { int imol = 0; // FIXME needs checking - std::string res_name(lig_at->residue->GetResName()); + std::string res_name(lig_at->GetResidue()->GetResName()); std::pair p = geom.get_monomer_restraints_at_least_minimal(res_name, imol); @@ -536,8 +536,8 @@ pli::flev_attached_hydrogens_t::get_atom_pos_bonded_to_atom(mmdb::Atom *lig_at, } else { mmdb::Atom *bonded_atom = NULL; std::string bonded_atom_name; - std::string lig_at_name = lig_at->name; - std::string H_at_name = H_at->name; + std::string lig_at_name = lig_at->GetAtomName(); + std::string H_at_name = H_at->GetAtomName(); for (unsigned int ibond=0; ibondGetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname; + std::string atom_name = residue_atoms[iat]->GetAtomName(); if (atom_name == bonded_atom_name) { bonded_atom = residue_atoms[iat]; break; @@ -575,7 +575,7 @@ pli::flev_attached_hydrogens_t::get_atom_pos_bonded_to_atom(mmdb::Atom *lig_at, throw std::runtime_error(m); } else { // good - return clipper::Coord_orth(bonded_atom->x, bonded_atom->y, bonded_atom->z); + return clipper::Coord_orth(bonded_atom->x(), bonded_atom->y(), bonded_atom->z()); } } @@ -602,7 +602,7 @@ pli::flev_attached_hydrogens_t::named_hydrogens_to_reference_ligand(mmdb::Residu int n_residue_atoms; ligand_residue_3d->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatname); + std::string atom_name(residue_atoms[iat]->GetAtomName()); if (atom_name == named_torsions[i].base_atom_name) { atom_base = residue_atoms[iat]; } @@ -615,9 +615,9 @@ pli::flev_attached_hydrogens_t::named_hydrogens_to_reference_ligand(mmdb::Residu } if (atom_base && atom_2 && atom_bonded_to_H) { - clipper::Coord_orth pos_atom_base(atom_base->x, atom_base->y, atom_base->z); - clipper::Coord_orth pos_atom_2(atom_2->x, atom_2->y, atom_2->z); - clipper::Coord_orth pos_atom_bonded_to_H(atom_bonded_to_H->x, atom_bonded_to_H->y, atom_bonded_to_H->z); + clipper::Coord_orth pos_atom_base(atom_base->x(), atom_base->y(), atom_base->z()); + clipper::Coord_orth pos_atom_2(atom_2->x(), atom_2->y(), atom_2->z()); + clipper::Coord_orth pos_atom_bonded_to_H(atom_bonded_to_H->x(), atom_bonded_to_H->y(), atom_bonded_to_H->z()); clipper::Coord_orth new_pt(pos_atom_base, pos_atom_2, pos_atom_bonded_to_H, 1.0, // unit vector @@ -665,7 +665,7 @@ pli::flev_attached_hydrogens_t::hydrogen_pos(const pli::named_torsion_t &named_t int n_residue_atoms; residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; iname); + std::string atom_name(residue_atoms[i]->GetAtomName()); if (atom_name == named_tor.base_atom_name) at_1 = residue_atoms[i]; if (atom_name == named_tor.atom_name_2) @@ -677,9 +677,9 @@ pli::flev_attached_hydrogens_t::hydrogen_pos(const pli::named_torsion_t &named_t if (! (at_1 && at_2 && at_3)) { throw(std::runtime_error("missing atoms in residue")); } else { - clipper::Coord_orth pt_1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth pt_2(at_2->x, at_2->y, at_2->z); - clipper::Coord_orth pt_3(at_3->x, at_3->y, at_3->z); + clipper::Coord_orth pt_1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth pt_2(at_2->x(), at_2->y(), at_2->z()); + clipper::Coord_orth pt_3(at_3->x(), at_3->y(), at_3->z()); clipper::Coord_orth p4_h(pt_1, pt_2, pt_3, named_tor.dist, clipper::Util::d2rad(named_tor.angle), @@ -707,9 +707,9 @@ pli::flev_attached_hydrogens_t::add_named_torsion(mmdb::Atom *h_at, mmdb::Atom * int hydrogen_type) { bool found_torsion_for_this_H = 0; - std::string atom_name_bonded_to_H(at->name); - clipper::Coord_orth p_h(h_at->x, h_at->y, h_at->z); - clipper::Coord_orth p_1(at->x, at->y, at->z); + std::string atom_name_bonded_to_H(at->GetAtomName()); + clipper::Coord_orth p_h(h_at->x(), h_at->y(), h_at->z()); + clipper::Coord_orth p_1(at->x(), at->y(), at->z()); // now we work back through the restraints, finding // an atom that bonds to at/atom_name_bonded_to_H, @@ -761,7 +761,7 @@ pli::flev_attached_hydrogens_t::add_named_torsion(mmdb::Atom *h_at, mmdb::Atom * int n_atoms = residue_p->GetNumberOfAtoms(); for (int iat=0; iatGetAtom(iat); - std::string res_atom_name(residue_at->name); + std::string res_atom_name(residue_at->GetAtomName()); if (res_atom_name == At_name_2) At_2 = residue_at; if (res_atom_name == base_atom_name) @@ -780,8 +780,8 @@ pli::flev_attached_hydrogens_t::add_named_torsion(mmdb::Atom *h_at, mmdb::Atom * << At_name_2 << std::endl; } else { try { - clipper::Coord_orth p_2(At_2->x, At_2->y, At_2->z); - clipper::Coord_orth p_base(base_atom->x, base_atom->y, base_atom->z); + clipper::Coord_orth p_2(At_2->x(), At_2->y(), At_2->z()); + clipper::Coord_orth p_base(base_atom->x(), base_atom->y(), base_atom->z()); double tors_r = clipper::Coord_orth::torsion(p_base, p_2, p_1, p_h); double tors = clipper::Util::rad2d(tors_r); diff --git a/pli/flev.cc b/pli/flev.cc index 805b13e990..00ffedd4f7 100644 --- a/pli/flev.cc +++ b/pli/flev.cc @@ -49,17 +49,17 @@ pli::make_flat_ligand_name_map(mmdb::Residue *flat_res) { flat_res->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatelement; - clipper::Coord_orth pt_i(at_i->x, at_i->y, at_i->z); + std::string ele_i = at_i->GetElementName(); + clipper::Coord_orth pt_i(at_i->x(), at_i->y(), at_i->z()); if (ele_i == " H") { for (int jat=0; jatelement; + std::string ele_j = at_j->GetElementName(); if (ele_j != " H") { - clipper::Coord_orth pt_j(at_j->x, at_j->y, at_j->z); + clipper::Coord_orth pt_j(at_j->x(), at_j->y(), at_j->z()); if ((pt_i - pt_j).lengthsq() < b2Hd2) { - map[at_j->name] = at_i->name; + map[at_j->GetAtomName()] = at_i->GetAtomName(); break; } } diff --git a/pli/pi-stacking.cc b/pli/pi-stacking.cc index 695f939d4c..483557b19b 100644 --- a/pli/pi-stacking.cc +++ b/pli/pi-stacking.cc @@ -293,11 +293,11 @@ pli::pi_stacking_container_t::get_ligand_cations(mmdb::Residue *res_ref, mmdb::PPAtom residue_atoms = NULL; res_ref->GetAtomTable(residue_atoms, n_residue_atoms); for (int iat=0; iatelement); + std::string ele(residue_atoms[iat]->GetElementName()); if (ele == " N") { // how many bonds does this N have? int n_bonds = 0; - std::string atom_name(residue_atoms[iat]->name); + std::string atom_name(residue_atoms[iat]->GetAtomName()); for (unsigned int ibond=0; ibond 3) { // i.e. 4 - clipper::Coord_orth pt(residue_atoms[iat]->x, - residue_atoms[iat]->y, - residue_atoms[iat]->z); + clipper::Coord_orth pt(residue_atoms[iat]->x(), + residue_atoms[iat]->y(), + residue_atoms[iat]->z()); std::pair p(atom_name, pt); v.push_back(p); } @@ -488,11 +488,11 @@ pli::pi_stacking_container_t::get_ring_pi_centre_points(const std::vector aromatic_plane_points; for (unsigned int iring_at=0; iring_atname); + std::string atom_name(residue_atoms[iat]->GetAtomName()); if (atom_name == ring_atom_names[iring_at]) { - clipper::Coord_orth at_pt(residue_atoms[iat]->x, - residue_atoms[iat]->y, - residue_atoms[iat]->z); + clipper::Coord_orth at_pt(residue_atoms[iat]->x(), + residue_atoms[iat]->y(), + residue_atoms[iat]->z()); aromatic_plane_points.push_back(at_pt); break; } @@ -731,11 +731,11 @@ pli::pi_stacking_container_t::get_cation_atom_positions(mmdb::Residue *res) cons int n_residue_atoms; res->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; iname); + std::string atom_name(residue_atoms[i]->GetAtomName()); if (atom_name == " NZ ") { - clipper::Coord_orth pt(residue_atoms[i]->x, - residue_atoms[i]->y, - residue_atoms[i]->z); + clipper::Coord_orth pt(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z()); v.push_back(pt); } } @@ -746,12 +746,12 @@ pli::pi_stacking_container_t::get_cation_atom_positions(mmdb::Residue *res) cons int n_residue_atoms; res->GetAtomTable(residue_atoms, n_residue_atoms); for (int i=0; iname); + std::string atom_name(residue_atoms[i]->GetAtomName()); if ((atom_name == " NH1") || (atom_name == " NH2")) { - clipper::Coord_orth pt(residue_atoms[i]->x, - residue_atoms[i]->y, - residue_atoms[i]->z); + clipper::Coord_orth pt(residue_atoms[i]->x(), + residue_atoms[i]->y(), + residue_atoms[i]->z()); v.push_back(pt); } } diff --git a/pli/protein-ligand-interactions.cc b/pli/protein-ligand-interactions.cc index ff3507d762..839d997364 100644 --- a/pli/protein-ligand-interactions.cc +++ b/pli/protein-ligand-interactions.cc @@ -144,7 +144,7 @@ pli::get_fle_ligand_bonds(mmdb::Residue *ligand_res, // } if (debug) - std::cout << "constructing fle ligand bond " << ligand_atom->name + std::cout << "constructing fle ligand bond " << ligand_atom->GetAtomName() << " " << bond_type << " " << hbonds[i].dist << " " << coot::atom_spec_t(env_residue_atom) << " " << env_residue_atom->GetResName() @@ -172,7 +172,7 @@ pli::get_fle_ligand_bonds(mmdb::Residue *ligand_res, std::string residue_name = ligand_atom->GetResName(); if (residue_name == "HOH") - bond.water_protein_length = find_water_protein_length(ligand_atom->residue, mol); + bond.water_protein_length = find_water_protein_length(ligand_atom->GetResidue(), mol); v.push_back(bond); } @@ -297,8 +297,8 @@ pli::get_covalent_bonds_by_distance(mmdb::Manager *mol, mmdb::Atom *at_2 = other_atom_selection[pscontact[i].id2]; // move on if these are interacting atoms - std::string alt_conf_1 = at_1->altLoc; - std::string alt_conf_2 = at_2->altLoc; + std::string alt_conf_1 = at_1->altLoc(); + std::string alt_conf_2 = at_2->altLoc(); if (!alt_conf_1.empty() && ! alt_conf_2.empty()) if (alt_conf_1 != alt_conf_2) continue; @@ -309,12 +309,12 @@ pli::get_covalent_bonds_by_distance(mmdb::Manager *mol, std::pair pair(at_1->GetResidue(), at_2->GetResidue()); - std::string ele_1 = at_1->element; - std::string ele_2 = at_2->element; + std::string ele_1 = at_1->GetElementName(); + std::string ele_2 = at_2->GetElementName(); if (ele_1 != " H") { if (ele_2 != " H") { - clipper::Coord_orth pt_1(at_1->x, at_1->y, at_1->z); - clipper::Coord_orth pt_2(at_2->x, at_2->y, at_2->z); + clipper::Coord_orth pt_1(at_1->x(), at_1->y(), at_1->z()); + clipper::Coord_orth pt_2(at_2->x(), at_2->y(), at_2->z()); double d = (pt_1-pt_2).lengthsq(); double dist_for_bond = max_dist; @@ -379,8 +379,8 @@ pli::get_covalent_bonds_by_links(mmdb::Residue *residue_ligand_p, if (at_1 && at_2) { // move on if these are interacting atoms - std::string alt_conf_1 = at_1->altLoc; - std::string alt_conf_2 = at_2->altLoc; + std::string alt_conf_1 = at_1->altLoc(); + std::string alt_conf_2 = at_2->altLoc(); if (!alt_conf_1.empty() && ! alt_conf_2.empty()) if (alt_conf_1 != alt_conf_2) continue; @@ -405,8 +405,8 @@ pli::get_covalent_bonds_by_links(mmdb::Residue *residue_ligand_p, if (at_1 && at_2) { // move on if these are interacting atoms - std::string alt_conf_1 = at_1->altLoc; - std::string alt_conf_2 = at_2->altLoc; + std::string alt_conf_1 = at_1->altLoc(); + std::string alt_conf_2 = at_2->altLoc(); if (!alt_conf_1.empty() && ! alt_conf_2.empty()) if (alt_conf_1 != alt_conf_2) continue; @@ -454,20 +454,20 @@ pli::get_metal_bonds(mmdb::Residue *ligand_residue, const std::vectoraltLoc; - std::string alt_conf_2 = at_2->altLoc; + std::string alt_conf_1 = at_1->altLoc(); + std::string alt_conf_2 = at_2->altLoc(); if (!alt_conf_1.empty() && ! alt_conf_2.empty()) if (alt_conf_1 != alt_conf_2) continue; - std::string ele(residue_atoms[irat]->element); + std::string ele(residue_atoms[irat]->GetElementName()); if ((ele == " H") || (ele == " C")) { - clipper::Coord_orth pt_1(ligand_residue_atoms[ilat]->x, - ligand_residue_atoms[ilat]->y, - ligand_residue_atoms[ilat]->z); - clipper::Coord_orth pt_2(residue_atoms[irat]->x, - residue_atoms[irat]->y, - residue_atoms[irat]->z); + clipper::Coord_orth pt_1(ligand_residue_atoms[ilat]->x(), + ligand_residue_atoms[ilat]->y(), + ligand_residue_atoms[ilat]->z()); + clipper::Coord_orth pt_2(residue_atoms[irat]->x(), + residue_atoms[irat]->y(), + residue_atoms[irat]->z()); double d2 = (pt_1-pt_2).clipper::Coord_orth::lengthsq(); if (d2 < best_dist_sqrd) { best_dist_sqrd = d2; @@ -627,14 +627,14 @@ pli::find_water_protein_length(mmdb::Residue *ligand_residue, mmdb::Manager *mol residue_p->GetAtomTable(residue_atoms, n_residue_atoms); for (int il=0; ilelement); + std::string ele(residue_atoms[irat]->GetElementName()); if ((ele == " O") || (ele == " N")) { - clipper::Coord_orth pt_1(ligand_residue_atoms[il]->x, - ligand_residue_atoms[il]->y, - ligand_residue_atoms[il]->z); - clipper::Coord_orth pt_2(residue_atoms[irat]->x, - residue_atoms[irat]->y, - residue_atoms[irat]->z); + clipper::Coord_orth pt_1(ligand_residue_atoms[il]->x(), + ligand_residue_atoms[il]->y(), + ligand_residue_atoms[il]->z()); + clipper::Coord_orth pt_2(residue_atoms[irat]->x(), + residue_atoms[irat]->y(), + residue_atoms[irat]->z()); double d2 = (pt_1-pt_2).clipper::Coord_orth::lengthsq(); if (d2 < dist_sqrd) { dist_sqrd = d2; diff --git a/python/coot_commands/commands/model_edit.py b/python/coot_commands/commands/model_edit.py index 30a920d83d..c87342111b 100644 --- a/python/coot_commands/commands/model_edit.py +++ b/python/coot_commands/commands/model_edit.py @@ -27,7 +27,8 @@ from coot_commands.registry import command from coot_commands.types import (RES_SPEC, OPT_RES_SPEC, resolve_residue, - ArgType, CommandError, ACTIVE_RESIDUE_NOTE) + ArgType, CommandError, centre_on_residue, + ACTIVE_RESIDUE_NOTE) try: import coot @@ -191,5 +192,6 @@ def pepflip_residue(chain: Optional[str] = None, resno: Optional[str] = None, """Flip the peptide following a residue.""" imol, chain_id, res, ins = resolve_residue(chain, resno, model) if coot is not None: + centre_on_residue(imol, chain_id, res, ins) # show it before flipping coot.pepflip(imol, chain_id, res, ins, "") return f"Flipped the peptide at {chain_id}/{res} of model {imol}" diff --git a/python/coot_commands/commands/refine.py b/python/coot_commands/commands/refine.py index 557eb6ba81..b72bfa3595 100644 --- a/python/coot_commands/commands/refine.py +++ b/python/coot_commands/commands/refine.py @@ -22,7 +22,7 @@ from coot_commands.registry import command from coot_commands.types import (RES_SPEC, resolve_model, resolve_residue, - as_int, ArgType, CommandError, + as_int, ArgType, CommandError, centre_on_residue, ACTIVE_MODEL_NOTE, ACTIVE_RESIDUE_NOTE) try: @@ -44,9 +44,11 @@ def _refine_zone(imol: int, chain_id: str, res1: int, res2: int) -> str: """ if coot is None: return f"Refined {chain_id}/{res1}-{res2} of model {imol}" + lo, hi = (res1, res2) if res1 <= res2 else (res2, res1) + # Bring the target on screen first, so the user sees what is being refined. + centre_on_residue(imol, chain_id, lo) if coot.imol_refinement_map() < 0: raise CommandError("no map set for refinement - open a map first") - lo, hi = (res1, res2) if res1 <= res2 else (res2, res1) replacement_state = coot.refinement_immediate_replacement_state() coot.set_refinement_immediate_replacement(1) try: diff --git a/python/coot_commands/types.py b/python/coot_commands/types.py index 2f3a8178ea..2d9585d8ee 100644 --- a/python/coot_commands/types.py +++ b/python/coot_commands/types.py @@ -234,6 +234,25 @@ def resolve_residue(chain: Optional[str] = None, resno: Optional[str] = None, return active_residue() +def centre_on_residue(imol: int, chain_id: str, resno: int, + ins_code: str = "") -> bool: + """Centre the view on a residue, best-effort, so edits are visible. + + Residue-targeting *action* commands (refine, pepflip, ...) call this before + acting, so operating on a named residue - whether typed or issued by the + assistant - first brings it on screen ("go to A 45, then refine it"). It + never raises and returns ``True`` if the residue was found, so it can wrap + an edit without changing its error behaviour. + """ + if coot is None: + return False + try: + coot.set_go_to_atom_molecule(imol) + return coot.set_go_to_atom_from_res_spec_py([chain_id, resno, ins_code]) > 0 + except Exception: + return False + + # Named colours -> (r, g, b) floats in 0..1, for map/background colour commands. COLOURS: dict[str, tuple[float, float, float]] = { "black": (0.0, 0.0, 0.0), diff --git a/python/test_coot_commands.py b/python/test_coot_commands.py index 2f44057b17..c510d88765 100644 --- a/python/test_coot_commands.py +++ b/python/test_coot_commands.py @@ -698,6 +698,24 @@ def test_refine_b_factors_runs_shiftfield(): assert calls["bf"] == 1 +def test_refine_residue_centres_on_the_target_first(): + fake = _FakeCootFull() + calls = {} + fake.imol_refinement_map = lambda: 3 + fake.set_go_to_atom_molecule = lambda imol: calls.__setitem__("goto_mol", imol) + fake.set_go_to_atom_from_res_spec_py = lambda spec: calls.setdefault("goto_spec", spec) or 1 + fake.refinement_immediate_replacement_state = lambda: 0 + fake.set_refinement_immediate_replacement = lambda s: None + fake.refine_zone = lambda imol, ch, lo, hi, ins: calls.__setitem__("zone", (imol, ch, lo, hi)) + fake.accept_regularizement = lambda: None + with _use_coot(fake, refine_mod): + out = cli.run_command("refine A 45") + # The view was centred on A/45 before the refinement ran. + assert calls["goto_spec"] == ["A", 45, ""] + assert calls["zone"] == (0, "A", 45, 45) + assert "Refined A/45" in out + + def test_refine_b_factors_needs_a_map(): fake = _FakeCootFull() fake.imol_refinement_map = lambda: -1 # no refinement map set diff --git a/skeleton/BuildCas.cc b/skeleton/BuildCas.cc index 0a8add14f7..d75effe845 100644 --- a/skeleton/BuildCas.cc +++ b/skeleton/BuildCas.cc @@ -204,8 +204,8 @@ BuildCas::convert_to_atoms_internal(clipper::Spacegroup spg, if (i_atom_loop_count == 0 || diff_residue_flag == 1) { res_p = new mmdb::Residue; - res_p->seqNum = 1 + i_res_add; // set the residue number to 1 + ... - strcpy(res_p->name, molecule_name.c_str()); + res_p->GetSeqNum() = 1 + i_res_add; // set the residue number to 1 + ... + res_p->SetResName(molecule_name.c_str()); chain_p->AddResidue ( res_p ); } @@ -431,9 +431,9 @@ BuildCas::point_list_by_symmetry(atom_selection_container_t AtomSel, // consider pushing back contact[ii].id2, with // std::vector big_ball; // - coot::Cartesian a(trans_selection [ contact[ii].id2 ]->x, - trans_selection [ contact[ii].id2 ]->y, - trans_selection [ contact[ii].id2 ]->z); + coot::Cartesian a(trans_selection [ contact[ii].id2 ]->x(), + trans_selection [ contact[ii].id2 ]->y(), + trans_selection [ contact[ii].id2 ]->z()); // coot::Cartesian_and_Grid cag(a, grids[ii]); // big_ball_l.push_back(cag); @@ -1231,11 +1231,11 @@ BuildCas::check_angle_torsion(atom_selection_container_t asc) const { for (int i=0; i< asc.n_selected_atoms; i++) { - if (std::string(asc.atom_selection[i]->name) == " CA " ) { + if (std::string(asc.atom_selection[i]->GetAtomName()) == " CA " ) { - coot::Cartesian pos(asc.atom_selection[i]->x, - asc.atom_selection[i]->y, - asc.atom_selection[i]->z); + coot::Cartesian pos(asc.atom_selection[i]->x(), + asc.atom_selection[i]->y(), + asc.atom_selection[i]->z()); std::cout << "Got a CA at " << pos << std::endl; @@ -1557,8 +1557,8 @@ BuildCas::move_by_symmetry(coot::Cartesian middle_mol, atom->SetCoordinates(middle_mol.x(), middle_mol.y(), middle_mol.z(), 1.0, 99); // - std::cout << "atom from middle_mol: " << atom->x << " " - << atom->y << " " << atom->z << std::endl; + std::cout << "atom from middle_mol: " << atom->x() << " " + << atom->y() << " " << atom->z() << std::endl; short int moved_it_flag = TRUE; @@ -1577,9 +1577,9 @@ BuildCas::move_by_symmetry(coot::Cartesian middle_mol, trans_atom->Copy(atom); trans_atom->Transform(my_matt); - coot::Cartesian cart_atom(trans_atom->x, - trans_atom->y, - trans_atom->z); + coot::Cartesian cart_atom(trans_atom->x(), + trans_atom->y(), + trans_atom->z()); std::cout << "testing atom at: " << cart_atom << std::endl; @@ -1598,7 +1598,7 @@ BuildCas::move_by_symmetry(coot::Cartesian middle_mol, } } - coot::Cartesian a(atom->x, atom->y, atom->z); + coot::Cartesian a(atom->x(), atom->y(), atom->z()); delete atom; delete trans_atom; diff --git a/src/coot-nomenclature.cc b/src/coot-nomenclature.cc index 17cf64edac..48d9e2782c 100644 --- a/src/coot-nomenclature.cc +++ b/src/coot-nomenclature.cc @@ -125,7 +125,7 @@ coot::nomenclature::fix_and_swap_maybe(const coot::protein_geometry *Geom_p, boo int imol = 0; // dummy std::vector chiral_restraints = - Geom_p->get_monomer_chiral_volumes(std::string(residue_p->name), imol); + Geom_p->get_monomer_chiral_volumes(std::string(residue_p->GetResName()), imol); coot::dict_chiral_restraint_t chiral_restraint; for (unsigned int irestr=0; irestraltLoc; - std::string atom_name = residue_atoms[iat]->name; + std::string alt_conf = residue_atoms[iat]->altLoc(); + std::string atom_name = residue_atoms[iat]->GetAtomName(); if (atom_name == " OG1" ) if (alt_conf == alt_conf_bad) og1 = residue_atoms[iat]; @@ -243,8 +243,8 @@ coot::nomenclature::fix_and_swap_maybe(const coot::protein_geometry *Geom_p, boo mmdb::Atom *cg1 = 0; // cd1 and cd2 for LEU of course mmdb::Atom *cg2 = 0; for (int iat=0; iataltLoc; - std::string atom_name = residue_atoms[iat]->name; + std::string alt_conf = residue_atoms[iat]->altLoc(); + std::string atom_name = residue_atoms[iat]->GetAtomName(); if (atom_name == target_atom_1 ) if (alt_conf == alt_conf_bad) cg1 = residue_atoms[iat]; @@ -304,9 +304,9 @@ coot::nomenclature::test_and_fix_PHE_TYR_nomenclature_errors(mmdb::Residue *resi std::vector alt_conf_list; // first get the altconfs in the residue: for (int i=0; iname; + std::string atom_name = residue_atoms[i]->GetAtomName(); if(atom_name == " CD1") { - alt_conf_list.push_back(residue_atoms[i]->altLoc); + alt_conf_list.push_back(residue_atoms[i]->altLoc()); } } @@ -323,8 +323,8 @@ coot::nomenclature::test_and_fix_PHE_TYR_nomenclature_errors(mmdb::Residue *resi mmdb::Atom *CD1 = 0; mmdb::Atom *CD2 = 0; for (int i=0; iname; - std::string atom_altconf = residue_atoms[i]->altLoc; + std::string atom_name = residue_atoms[i]->GetAtomName(); + std::string atom_altconf = residue_atoms[i]->altLoc(); if (atom_altconf == alt_conf_list[ialtconf]) { if (atom_name == " CA ") CA = residue_atoms[i]; @@ -340,8 +340,8 @@ coot::nomenclature::test_and_fix_PHE_TYR_nomenclature_errors(mmdb::Residue *resi } if (CA==0 || CB==0 || CG==0) { // no need for CD1, it will be set for (int i=0; iname; - std::string atom_altconf = residue_atoms[i]->altLoc; + std::string atom_name = residue_atoms[i]->GetAtomName(); + std::string atom_altconf = residue_atoms[i]->altLoc(); if (atom_altconf == "") { if (atom_name == " CA ") CA = residue_atoms[i]; @@ -359,10 +359,10 @@ coot::nomenclature::test_and_fix_PHE_TYR_nomenclature_errors(mmdb::Residue *resi if (CA && CB && CG && CD1) { - clipper::Coord_orth a1(CA->x, CA->y, CA->z); - clipper::Coord_orth a2(CB->x, CB->y, CB->z); - clipper::Coord_orth a3(CG->x, CG->y, CG->z); - clipper::Coord_orth a4(CD1->x, CD1->y, CD1->z); + clipper::Coord_orth a1(CA->x(), CA->y(), CA->z()); + clipper::Coord_orth a2(CB->x(), CB->y(), CB->z()); + clipper::Coord_orth a3(CG->x(), CG->y(), CG->z()); + clipper::Coord_orth a4(CD1->x(), CD1->y(), CD1->z()); double tors = clipper::Util::rad2d(clipper::Coord_orth::torsion(a1, a2, a3, a4)); @@ -371,7 +371,7 @@ coot::nomenclature::test_and_fix_PHE_TYR_nomenclature_errors(mmdb::Residue *resi // ooops, there was a problem with this torsion. if (CD2) { - clipper::Coord_orth a4_o(CD2->x, CD2->y, CD2->z); + clipper::Coord_orth a4_o(CD2->x(), CD2->y(), CD2->z()); double cg2_tors = clipper::Util::rad2d(clipper::Coord_orth::torsion(a1, a2, a3, a4_o)); // if cg2_tors is in range, then we swap atom names @@ -384,8 +384,8 @@ coot::nomenclature::test_and_fix_PHE_TYR_nomenclature_errors(mmdb::Residue *resi mmdb::Atom *HE1 = 0; mmdb::Atom *HE2 = 0; for (int ie=0; iename; - std::string e_atom_altconf = residue_atoms[ie]->altLoc; + std::string e_atom_name = residue_atoms[ie]->GetAtomName(); + std::string e_atom_altconf = residue_atoms[ie]->altLoc(); if (e_atom_altconf == alt_conf_list[ialtconf]) { if (e_atom_name == " CE1") CE1 = residue_atoms[ie]; @@ -410,15 +410,15 @@ coot::nomenclature::test_and_fix_PHE_TYR_nomenclature_errors(mmdb::Residue *resi CE1->SetAtomName(" CE2"); CE2->SetAtomName(" CE1"); #endif - mmdb::realtype pos_cd1[3] = {CD1->x, CD1->y, CD1->z}; - mmdb::realtype pos_cd2[3] = {CD2->x, CD2->y, CD2->z}; - mmdb::realtype pos_ce1[3] = {CE1->x, CE1->y, CE1->z}; - mmdb::realtype pos_ce2[3] = {CE2->x, CE2->y, CE2->z}; - - CD1->x = pos_cd2[0]; CD1->y = pos_cd2[1]; CD1->z = pos_cd2[2]; - CD2->x = pos_cd1[0]; CD2->y = pos_cd1[1]; CD2->z = pos_cd1[2]; - CE1->x = pos_ce2[0]; CE1->y = pos_ce2[1]; CE1->z = pos_ce2[2]; - CE2->x = pos_ce1[0]; CE2->y = pos_ce1[1]; CE2->z = pos_ce1[2]; + mmdb::realtype pos_cd1[3] = {CD1->x(), CD1->y(), CD1->z()}; + mmdb::realtype pos_cd2[3] = {CD2->x(), CD2->y(), CD2->z()}; + mmdb::realtype pos_ce1[3] = {CE1->x(), CE1->y(), CE1->z()}; + mmdb::realtype pos_ce2[3] = {CE2->x(), CE2->y(), CE2->z()}; + + CD1->x() = pos_cd2[0]; CD1->y() = pos_cd2[1]; CD1->z() = pos_cd2[2]; + CD2->x() = pos_cd1[0]; CD2->y() = pos_cd1[1]; CD2->z() = pos_cd1[2]; + CE1->x() = pos_ce2[0]; CE1->y() = pos_ce2[1]; CE1->z() = pos_ce2[2]; + CE2->x() = pos_ce1[0]; CE2->y() = pos_ce1[1]; CE2->z() = pos_ce1[2]; } if (false) std::cout << "DEBUG:: swapped in test_and_fix_PHE_TYR_nomenclature_errors()" @@ -477,9 +477,9 @@ coot::nomenclature::test_and_fix_ASP_GLU_nomenclature_errors(mmdb::Residue *resi std::vector alt_conf_list; // first get the altconfs in the residue: for (int i=0; iname; + std::string atom_name = residue_atoms[i]->GetAtomName(); if(atom_name == test_atom_name) { - alt_conf_list.push_back(residue_atoms[i]->altLoc); + alt_conf_list.push_back(residue_atoms[i]->altLoc()); } } @@ -490,8 +490,8 @@ coot::nomenclature::test_and_fix_ASP_GLU_nomenclature_errors(mmdb::Residue *resi coot::atom_index_quad quad; for (int i=0; iname; - std::string atom_altconf = residue_atoms[i]->altLoc; + std::string atom_name = residue_atoms[i]->GetAtomName(); + std::string atom_altconf = residue_atoms[i]->altLoc(); if (atom_altconf == alt_conf_list[ialtconf]) { if (residue_name == "ASP") { @@ -540,8 +540,8 @@ coot::nomenclature::test_and_fix_ASP_GLU_nomenclature_errors(mmdb::Residue *resi mmdb::Atom *at_1 = 0; mmdb::Atom *at_2 = 0; for (int i=0; iname; - std::string atom_altconf = residue_atoms[i]->altLoc; + std::string atom_name = residue_atoms[i]->GetAtomName(); + std::string atom_altconf = residue_atoms[i]->altLoc(); if (atom_altconf == alt_conf_list[ialtconf]) { if (atom_name == swap_name_1) at_1 = residue_atoms[i]; diff --git a/src/molecule-class-info-maps.cc b/src/molecule-class-info-maps.cc index 83677829fa..3a9004f9a1 100644 --- a/src/molecule-class-info-maps.cc +++ b/src/molecule-class-info-maps.cc @@ -58,6 +58,7 @@ #include "coords/mmdb-crystal.hh" #include "coot-utils/coot-coord-utils.hh" #include "coot-utils/xmap-stats.hh" +#include "coot-utils/mmdb-to-clipper-atom-list.hh" #include "density-contour/CIsoSurface.h" #include "molecule-class-info.h" @@ -3130,7 +3131,7 @@ molecule_class_info_t::calculate_sfs_and_make_map(int imol_no_in, clipper::HKL_data< clipper::datatypes::F_phi > map_fphidata(myfsigf.spacegroup(),myfsigf.cell(), myfsigf.hkl_sampling()); // get a list of all the atoms - clipper::MMDBAtom_list atoms(SelAtom.atom_selection, SelAtom.n_selected_atoms); + coot::MMDBAtom_list atoms(SelAtom.atom_selection, SelAtom.n_selected_atoms); std::cout << "isotropic fft of " << SelAtom.n_selected_atoms << " atoms..." << std::endl; @@ -3247,7 +3248,7 @@ molecule_class_info_t::calculate_sfs_and_make_map(int imol_no_in, hndl = mmdb->NewSelection(); mmdb->SelectAtoms( hndl, 0, 0, mmdb::SKEY_NEW ); mmdb->GetSelIndex( hndl, psel, nsel ); - clipper::MMDBAtom_list atoms( psel, nsel ); + coot::MMDBAtom_list atoms( psel, nsel ); mmdb->DeleteSelection( hndl ); // calculate structure factors