Commit b7330c07 by Maarten L. Hekkelman

Fixed Structure::changeResidue to actually change the residue itself as well.

parent e8f41230
...@@ -236,6 +236,8 @@ class Residue ...@@ -236,6 +236,8 @@ class Residue
Atom atomByID(const std::string &atomID) const; Atom atomByID(const std::string &atomID) const;
const std::string &compoundID() const { return mCompoundID; } const std::string &compoundID() const { return mCompoundID; }
void setCompoundID(const std::string &id) { mCompoundID = id; }
const std::string &asymID() const { return mAsymID; } const std::string &asymID() const { return mAsymID; }
int seqID() const { return mSeqID; } int seqID() const { return mSeqID; }
std::string entityID() const; std::string entityID() const;
...@@ -470,9 +472,15 @@ class Structure ...@@ -470,9 +472,15 @@ class Structure
/// \brief Get a residue, if \a seqID is zero, the non-polymers are searched /// \brief Get a residue, if \a seqID is zero, the non-polymers are searched
const Residue &getResidue(const std::string &asymID, const std::string &compID, int seqID = 0) const; const Residue &getResidue(const std::string &asymID, const std::string &compID, int seqID = 0) const;
/// \brief Get a residue, if \a seqID is zero, the non-polymers are searched
Residue &getResidue(const std::string &asymID, const std::string &compID, int seqID = 0);
/// \brief Get a the single residue for an asym with id \a asymID /// \brief Get a the single residue for an asym with id \a asymID
const Residue &getResidue(const std::string &asymID) const; const Residue &getResidue(const std::string &asymID) const;
/// \brief Get a the single residue for an asym with id \a asymID
Residue &getResidue(const std::string &asymID);
// map between auth and label locations // map between auth and label locations
std::tuple<std::string, int, std::string> MapAuthToLabel(const std::string &asymID, std::tuple<std::string, int, std::string> MapAuthToLabel(const std::string &asymID,
...@@ -497,7 +505,7 @@ class Structure ...@@ -497,7 +505,7 @@ class Structure
void removeAtom(Atom &a); void removeAtom(Atom &a);
void swapAtoms(Atom &a1, Atom &a2); // swap the labels for these atoms void swapAtoms(Atom &a1, Atom &a2); // swap the labels for these atoms
void moveAtom(Atom &a, Point p); // move atom to a new location void moveAtom(Atom &a, Point p); // move atom to a new location
void changeResidue(const Residue &res, const std::string &newCompound, void changeResidue(Residue &res, const std::string &newCompound,
const std::vector<std::tuple<std::string, std::string>> &remappedAtoms); const std::vector<std::tuple<std::string, std::string>> &remappedAtoms);
/// \brief Create a new non-polymer entity, returns new ID /// \brief Create a new non-polymer entity, returns new ID
......
...@@ -2075,6 +2075,11 @@ const Residue &Structure::getResidue(const std::string &asymID, const std::strin ...@@ -2075,6 +2075,11 @@ const Residue &Structure::getResidue(const std::string &asymID, const std::strin
throw std::out_of_range("Could not find residue " + asymID + '/' + std::to_string(seqID)); throw std::out_of_range("Could not find residue " + asymID + '/' + std::to_string(seqID));
} }
Residue &Structure::getResidue(const std::string &asymID, const std::string &compID, int seqID)
{
return const_cast<Residue&>(const_cast<Structure const&>(*this).getResidue(asymID, compID, seqID));
}
const Residue &Structure::getResidue(const std::string &asymID) const const Residue &Structure::getResidue(const std::string &asymID) const
{ {
for (auto &res : mNonPolymers) for (auto &res : mNonPolymers)
...@@ -2088,6 +2093,11 @@ const Residue &Structure::getResidue(const std::string &asymID) const ...@@ -2088,6 +2093,11 @@ const Residue &Structure::getResidue(const std::string &asymID) const
throw std::out_of_range("Could not find residue " + asymID); throw std::out_of_range("Could not find residue " + asymID);
} }
Residue &Structure::getResidue(const std::string &asymID)
{
return const_cast<Residue&>(const_cast<Structure const&>(*this).getResidue(asymID));
}
File &Structure::getFile() const File &Structure::getFile() const
{ {
return mFile; return mFile;
...@@ -2426,7 +2436,7 @@ void Structure::moveAtom(Atom &a, Point p) ...@@ -2426,7 +2436,7 @@ void Structure::moveAtom(Atom &a, Point p)
a.location(p); a.location(p);
} }
void Structure::changeResidue(const Residue &res, const std::string &newCompound, void Structure::changeResidue(Residue &res, const std::string &newCompound,
const std::vector<std::tuple<std::string, std::string>> &remappedAtoms) const std::vector<std::tuple<std::string, std::string>> &remappedAtoms)
{ {
using namespace cif::literals; using namespace cif::literals;
...@@ -2490,6 +2500,8 @@ void Structure::changeResidue(const Residue &res, const std::string &newCompound ...@@ -2490,6 +2500,8 @@ void Structure::changeResidue(const Residue &res, const std::string &newCompound
else else
insertCompound(newCompound, false); insertCompound(newCompound, false);
res.setCompoundID(newCompound);
auto &atomSites = db["atom_site"]; auto &atomSites = db["atom_site"];
auto atoms = res.atoms(); auto atoms = res.atoms();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment