Commit 6768a501 by Maarten L. Hekkelman

access to atoms

parent 879e15c7
...@@ -551,6 +551,8 @@ class Structure ...@@ -551,6 +551,8 @@ class Structure
~Structure(); ~Structure();
const AtomView &atoms() const { return mAtoms; } const AtomView &atoms() const { return mAtoms; }
AtomView &atoms() { return mAtoms; }
AtomView waters() const; AtomView waters() const;
const std::list<Polymer> &polymers() const { return mPolymers; } const std::list<Polymer> &polymers() const { return mPolymers; }
...@@ -580,6 +582,9 @@ class Structure ...@@ -580,6 +582,9 @@ class Structure
/// \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 and seq id \a seqID
const Residue &getResidue(const std::string &asymID, int seqID) const;
/// \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
Residue &getResidue(const std::string &asymID); Residue &getResidue(const std::string &asymID);
......
...@@ -302,7 +302,8 @@ Quaternion ConstructFromAngleAxis(float angle, Point axis) ...@@ -302,7 +302,8 @@ Quaternion ConstructFromAngleAxis(float angle, Point axis)
axis.normalize(); axis.normalize();
return Normalize(Quaternion{q, return Normalize(Quaternion{
static_cast<float>(q),
static_cast<float>(s * axis.mX), static_cast<float>(s * axis.mX),
static_cast<float>(s * axis.mY), static_cast<float>(s * axis.mY),
static_cast<float>(s * axis.mZ)}); static_cast<float>(s * axis.mZ)});
......
...@@ -1429,10 +1429,21 @@ Atom Structure::getAtomByID(std::string id) const ...@@ -1429,10 +1429,21 @@ Atom Structure::getAtomByID(std::string id) const
// auto i = find_if(mAtoms.begin(), mAtoms.end(), // auto i = find_if(mAtoms.begin(), mAtoms.end(),
// [&id](auto& a) { return a.id() == id; }); // [&id](auto& a) { return a.id() == id; });
Atom result;
if (i == mAtomIndex.end() or mAtoms[*i].id() != id) if (i == mAtomIndex.end() or mAtoms[*i].id() != id)
{
auto j = std::find_if(mAtoms.begin(), mAtoms.end(), [id](const Atom &a) { return a.id() == id; });
if (j == mAtoms.end())
throw std::out_of_range("Could not find atom with id " + id); throw std::out_of_range("Could not find atom with id " + id);
return mAtoms[*i]; result = *j;
}
else
result = mAtoms[*i];
return result;
} }
Atom Structure::getAtomByLabel(const std::string &atomID, const std::string &asymID, const std::string &compID, int seqID, const std::string &altID) Atom Structure::getAtomByLabel(const std::string &atomID, const std::string &asymID, const std::string &compID, int seqID, const std::string &altID)
...@@ -1558,6 +1569,42 @@ const Residue &Structure::getResidue(const std::string &asymID) const ...@@ -1558,6 +1569,42 @@ 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);
} }
const Residue &Structure::getResidue(const std::string &asymID, int seqID) const
{
if (seqID == 0)
{
for (auto &res : mNonPolymers)
{
if (res.asymID() != asymID)
continue;
return res;
}
}
for (auto &poly : mPolymers)
{
if (poly.asymID() != asymID)
continue;
for (auto &res : poly)
{
if (res.seqID() == seqID)
return res;
}
}
for (auto &res : mBranchResidues)
{
if (res.asymID() != asymID or res.seqID() != seqID)
continue;
return res;
}
throw std::out_of_range("Could not find residue " + asymID + '/' + std::to_string(seqID));
}
Residue &Structure::getResidue(const std::string &asymID) Residue &Structure::getResidue(const std::string &asymID)
{ {
return const_cast<Residue &>(const_cast<Structure const &>(*this).getResidue(asymID)); return const_cast<Residue &>(const_cast<Structure const &>(*this).getResidue(asymID));
......
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