Commit 25dfdd2f by Maarten L. Hekkelman

- alternates handling

- getResidue in structure
parent 88879a5d
...@@ -244,6 +244,15 @@ class Residue ...@@ -244,6 +244,15 @@ class Residue
bool hasAlternateAtoms() const; bool hasAlternateAtoms() const;
/// \brief Return the list of unique alt ID's present in this residue
std::set<std::string> getAlternateIDs() const;
/// \brief Return the list of unique atom ID's
std::set<std::string> getAtomIDs() const;
/// \brief Return the list of atoms having ID \a atomID
AtomView getAtomsByID(const std::string& atomID) const;
// some routines for 3d work // some routines for 3d work
std::tuple<Point,float> centerAndRadius() const; std::tuple<Point,float> centerAndRadius() const;
...@@ -436,6 +445,8 @@ class Structure ...@@ -436,6 +445,8 @@ class Structure
// const std::string& compID, int seqID, const std::string& altID = "", // const std::string& compID, int seqID, const std::string& altID = "",
// const std::string& pdbxAuthInsCode = ""); // const std::string& pdbxAuthInsCode = "");
const Residue& getResidue(const std::string& asymID, const std::string& compID, int seqID) const;
// 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,
...@@ -536,7 +547,7 @@ class Structure ...@@ -536,7 +547,7 @@ class Structure
void updateAtomIndex(); void updateAtomIndex();
File& mFile; File& mFile;
uint32_t mModelNr; uint32_t mModelNr;
AtomView mAtoms; AtomView mAtoms;
std::vector<size_t> mAtomIndex; std::vector<size_t> mAtomIndex;
std::list<Polymer> mPolymers; std::list<Polymer> mPolymers;
......
...@@ -879,6 +879,20 @@ AtomView Residue::unique_atoms() const ...@@ -879,6 +879,20 @@ AtomView Residue::unique_atoms() const
return result; return result;
} }
std::set<std::string> Residue::getAlternateIDs() const
{
std::set<std::string> result;
for (auto a: mAtoms)
{
auto alt = a.labelAltID();
if (not alt.empty())
result.insert(alt);
}
return result;
}
Atom Residue::atomByID(const std::string& atomID) const Atom Residue::atomByID(const std::string& atomID) const
{ {
Atom result; Atom result;
...@@ -966,6 +980,26 @@ bool Residue::hasAlternateAtoms() const ...@@ -966,6 +980,26 @@ bool Residue::hasAlternateAtoms() const
return std::find_if(mAtoms.begin(), mAtoms.end(), [](const Atom& atom) { return atom.isAlternate(); }) != mAtoms.end(); return std::find_if(mAtoms.begin(), mAtoms.end(), [](const Atom& atom) { return atom.isAlternate(); }) != mAtoms.end();
} }
std::set<std::string> Residue::getAtomIDs() const
{
std::set<std::string> ids;
for (auto a: mAtoms)
ids.insert(a.labelAtomID());
return ids;
}
AtomView Residue::getAtomsByID(const std::string& atomID) const
{
AtomView atoms;
for (auto a: mAtoms)
{
if (a.labelAtomID() == atomID)
atoms.push_back(a);
}
return atoms;
}
std::ostream& operator<<(std::ostream& os, const Residue& res) std::ostream& operator<<(std::ostream& os, const Residue& res)
{ {
os << res.compoundID() << ' ' << res.asymID() << ':' << res.seqID(); os << res.compoundID() << ' ' << res.asymID() << ':' << res.seqID();
...@@ -1747,6 +1781,23 @@ Atom Structure::getAtomByLabel(const std::string& atomID, const std::string& asy ...@@ -1747,6 +1781,23 @@ Atom Structure::getAtomByLabel(const std::string& atomID, const std::string& asy
throw std::out_of_range("Could not find atom with specified label"); throw std::out_of_range("Could not find atom with specified label");
} }
const Residue& Structure::getResidue(const std::string& asymID, const std::string& compID, int seqID) const
{
for (auto& poly: mPolymers)
{
if (poly.asymID() != asymID)
continue;
for (auto& res: poly)
{
if (res.seqID() == seqID and res.compoundID() == compID)
return res;
}
}
throw std::out_of_range("Could not find residue " + asymID + '/' + std::to_string(seqID));
}
File& Structure::getFile() const File& Structure::getFile() const
{ {
return mFile; return mFile;
......
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