Commit 59a7ff68 by Maarten L. Hekkelman

- renaming header files

- atomByID now returns an empty atom
- operator bool for Atom
parent 80bb24f3
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#pragma once #pragma once
#include "cif++/Structure.h" #include "cif++/Structure.hpp"
namespace mmcif namespace mmcif
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#pragma once #pragma once
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include <boost/math/quaternion.hpp> #include <boost/math/quaternion.hpp>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <unordered_map> #include <unordered_map>
#include "cif++/Structure.h" #include "cif++/Structure.hpp"
namespace mmcif namespace mmcif
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#pragma once #pragma once
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include <regex> #include <regex>
#include <iostream> #include <iostream>
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/any.hpp> #include <boost/any.hpp>
#include "cif++/CifUtils.h" #include "cif++/CifUtils.hpp"
/* /*
Simple C++ interface to CIF files. Simple C++ interface to CIF files.
......
#pragma once #pragma once
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
void WritePDBFile(std::ostream& pdbFile, cif::File& cifFile); void WritePDBFile(std::ostream& pdbFile, cif::File& cifFile);
......
// CIF Parser // CIF Parser
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
#include <stack> #include <stack>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <set> #include <set>
#include <cassert> #include <cassert>
#include "cif++/Config.h" #include "cif++/Config.hpp"
struct rsrc_imp struct rsrc_imp
{ {
......
// cif parsing library // cif parsing library
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
//// the std regex of gcc is crashing.... //// the std regex of gcc is crashing....
// #include <boost/regex.hpp> // #include <boost/regex.hpp>
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include <vector> #include <vector>
#include <map> #include <map>
#include "cif++/AtomType.h" #include "cif++/AtomType.hpp"
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
namespace mmcif namespace mmcif
{ {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <clipper/clipper.h> #include <clipper/clipper.h>
#include "cif++/Structure.h" #include "cif++/Structure.hpp"
namespace mmcif namespace mmcif
{ {
......
// --------------------------------------------------------------------
#pragma once
namespace mmcif
{
class Structure;
/// \brief Add missing backbone atoms
///
/// \param structure The structure that should be fixed
/// \param simplified Use a simplified algorithm
void CreateMissingBackboneAtoms(Structure& structure, bool simplified);
}
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <clipper/clipper.h> #include <clipper/clipper.h>
#include "cif++/Structure.h" #include "cif++/Structure.hpp"
namespace mmcif namespace mmcif
{ {
......
#pragma once #pragma once
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
// -------------------------------------------------------------------- // --------------------------------------------------------------------
......
#pragma once #pragma once
#include "cif++/PDB2Cif.h" #include "cif++/PDB2Cif.hpp"
// -------------------------------------------------------------------- // --------------------------------------------------------------------
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#pragma once #pragma once
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include <boost/math/quaternion.hpp> #include <boost/math/quaternion.hpp>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#pragma once #pragma once
#include "cif++/ResolutionCalculator.h" #include "cif++/ResolutionCalculator.hpp"
#include <clipper/clipper.h> #include <clipper/clipper.h>
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
#pragma once #pragma once
#include "cif++/MapMaker.h" #include "cif++/MapMaker.hpp"
#include "cif++/DistanceMap.h" #include "cif++/DistanceMap.hpp"
#include "cif++/BondMap.h" #include "cif++/BondMap.hpp"
namespace mmcif namespace mmcif
{ {
......
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
#include <clipper/core/coords.h> #include <clipper/core/coords.h>
#include "cif++/AtomType.h" #include "cif++/AtomType.hpp"
#include "cif++/Point.h" #include "cif++/Point.hpp"
#include "cif++/Compound.h" #include "cif++/Compound.hpp"
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
/* /*
To modify a structure, you will have to use actions. To modify a structure, you will have to use actions.
...@@ -44,11 +44,14 @@ class Atom ...@@ -44,11 +44,14 @@ class Atom
{ {
public: public:
// Atom(const structure& s, const std::string& id); // Atom(const structure& s, const std::string& id);
Atom();
Atom(struct AtomImpl* impl); Atom(struct AtomImpl* impl);
Atom(const Atom& rhs); Atom(const Atom& rhs);
~Atom(); ~Atom();
explicit operator bool() const { return mImpl_ != nullptr; }
// return a copy of this atom, with data copied instead of referenced // return a copy of this atom, with data copied instead of referenced
Atom clone() const; Atom clone() const;
...@@ -85,6 +88,7 @@ class Atom ...@@ -85,6 +88,7 @@ class Atom
std::string labelAsymID() const; std::string labelAsymID() const;
int labelSeqID() const; int labelSeqID() const;
std::string labelAltID() const; std::string labelAltID() const;
bool isAlternate() const;
std::string authAtomID() const; std::string authAtomID() const;
std::string authCompID() const; std::string authCompID() const;
...@@ -113,13 +117,13 @@ class Atom ...@@ -113,13 +117,13 @@ class Atom
// convenience routine // convenience routine
bool isBackBone() const bool isBackBone() const
{ {
return labelAtomID() == "N" or labelAtomID() == "O" or auto atomID = labelAtomID();
labelAtomID() == "C" or labelAtomID() == "CA"; return atomID == "N" or atomID == "O" or atomID == "C" or atomID == "CA";
} }
void swap(Atom& b) void swap(Atom& b)
{ {
std::swap(mImpl, b.mImpl); std::swap(mImpl_, b.mImpl_);
} }
int compare(const Atom& b) const; int compare(const Atom& b) const;
...@@ -128,7 +132,10 @@ class Atom ...@@ -128,7 +132,10 @@ class Atom
friend class Structure; friend class Structure;
void setID(int id); void setID(int id);
struct AtomImpl* mImpl; AtomImpl* impl();
const AtomImpl* impl() const;
struct AtomImpl* mImpl_;
}; };
inline void swap(mmcif::Atom& a, mmcif::Atom& b) inline void swap(mmcif::Atom& a, mmcif::Atom& b)
...@@ -196,7 +203,9 @@ class Residue ...@@ -196,7 +203,9 @@ class Residue
const Structure& structure() const { return *mStructure; } const Structure& structure() const { return *mStructure; }
bool empty() const { return mStructure == nullptr; } bool empty() const { return mStructure == nullptr; }
bool hasAlternateAtoms() const;
// some routines for 3d work // some routines for 3d work
std::tuple<Point,float> centerAndRadius() const; std::tuple<Point,float> centerAndRadius() const;
...@@ -247,6 +256,9 @@ class Monomer : public Residue ...@@ -247,6 +256,9 @@ class Monomer : public Residue
/// \brief Returns true if the four atoms C, CA, N and O are present /// \brief Returns true if the four atoms C, CA, N and O are present
bool isComplete() const; bool isComplete() const;
/// \brief Returns true if any of the backbone atoms has an alternate
bool hasAlternateBackboneAtoms() const;
Atom CAlpha() const { return atomByID("CA"); } Atom CAlpha() const { return atomByID("CA"); }
Atom C() const { return atomByID("C"); } Atom C() const { return atomByID("C"); }
Atom N() const { return atomByID("N"); } Atom N() const { return atomByID("N"); }
...@@ -364,6 +376,8 @@ class Structure ...@@ -364,6 +376,8 @@ class Structure
AtomView waters() const; AtomView waters() const;
const std::list<Polymer>& polymers() const { return mPolymers; } const std::list<Polymer>& polymers() const { return mPolymers; }
std::list<Polymer>& polymers() { return mPolymers; }
const std::vector<Residue>& nonPolymers() const { return mNonPolymers; } const std::vector<Residue>& nonPolymers() const { return mNonPolymers; }
Atom getAtomByID(std::string id) const; Atom getAtomByID(std::string id) const;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#pragma once #pragma once
#include "cif++/Structure.h" #include "cif++/Structure.hpp"
namespace mmcif namespace mmcif
{ {
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <string> #include <string>
#include <tuple> #include <tuple>
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
namespace cif namespace cif
{ {
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
#include <thread> #include <thread>
#include <mutex> #include <mutex>
#include "cif++/Structure.h" #include "cif++/Structure.hpp"
#include "cif++/AtomShape.h" #include "cif++/AtomShape.hpp"
#include "cif++/Point.h" #include "cif++/Point.hpp"
#include <newuoa.h> #include <newuoa.h>
......
// Lib for working with structures as contained in mmCIF and PDB files // Lib for working with structures as contained in mmCIF and PDB files
#include "cif++/AtomType.h" #include "cif++/AtomType.hpp"
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
using namespace std; using namespace std;
......
// copyright // copyright
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
#include "cif++/BondMap.h" #include "cif++/BondMap.hpp"
#include "cif++/Compound.h" #include "cif++/Compound.hpp"
#include "cif++/CifUtils.h" #include "cif++/CifUtils.hpp"
using namespace std; using namespace std;
......
...@@ -24,10 +24,10 @@ namespace fs = boost::filesystem; ...@@ -24,10 +24,10 @@ namespace fs = boost::filesystem;
#include <boost/iostreams/filter/gzip.hpp> #include <boost/iostreams/filter/gzip.hpp>
#include <boost/logic/tribool.hpp> #include <boost/logic/tribool.hpp>
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
#include "cif++/CifParser.h" #include "cif++/CifParser.hpp"
#include "cif++/CifValidator.h" #include "cif++/CifValidator.hpp"
#include "cif++/CifUtils.h" #include "cif++/CifUtils.hpp"
using namespace std; using namespace std;
namespace ba = boost::algorithm; namespace ba = boost::algorithm;
......
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include <map> #include <map>
#include <set> #include <set>
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
#include <boost/iostreams/concepts.hpp> // output_filter #include <boost/iostreams/concepts.hpp> // output_filter
#include <boost/iostreams/operations.hpp> // put #include <boost/iostreams/operations.hpp> // put
#include "cif++/Cif2PDB.h" #include "cif++/Cif2PDB.hpp"
#include "cif++/AtomType.h" #include "cif++/AtomType.hpp"
#include "cif++/Compound.h" #include "cif++/Compound.hpp"
using namespace std; using namespace std;
namespace ba = boost::algorithm; namespace ba = boost::algorithm;
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
#include "cif++/CifParser.h" #include "cif++/CifParser.hpp"
#include "cif++/CifValidator.h" #include "cif++/CifValidator.hpp"
using namespace std; using namespace std;
namespace ba = boost::algorithm; namespace ba = boost::algorithm;
......
// CIF parser // CIF parser
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include <tuple> #include <tuple>
#include <iostream> #include <iostream>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <boost/timer/timer.hpp> #include <boost/timer/timer.hpp>
#endif #endif
#include "cif++/CifUtils.h" #include "cif++/CifUtils.hpp"
using namespace std; using namespace std;
namespace ba = boost::algorithm; namespace ba = boost::algorithm;
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
#include <boost/regex.hpp> #include <boost/regex.hpp>
// #include <regex> // #include <regex>
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
#include "cif++/CifParser.h" #include "cif++/CifParser.hpp"
#include "cif++/CifValidator.h" #include "cif++/CifValidator.hpp"
using namespace std; using namespace std;
namespace ba = boost::algorithm; namespace ba = boost::algorithm;
......
// Lib for working with structures as contained in mmCIF and PDB files // Lib for working with structures as contained in mmCIF and PDB files
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include <map> #include <map>
#include <numeric> #include <numeric>
...@@ -16,10 +16,10 @@ namespace fs = std::filesystem; ...@@ -16,10 +16,10 @@ namespace fs = std::filesystem;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
#endif #endif
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
#include "cif++/Point.h" #include "cif++/Point.hpp"
#include "cif++/Compound.h" #include "cif++/Compound.hpp"
#include "cif++/CifUtils.h" #include "cif++/CifUtils.hpp"
using namespace std; using namespace std;
namespace ba = boost::algorithm; namespace ba = boost::algorithm;
......
// copyright // copyright
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include <atomic> #include <atomic>
#include <mutex> #include <mutex>
#include "cif++/DistanceMap.h" #include "cif++/DistanceMap.hpp"
#include "cif++/CifUtils.h" #include "cif++/CifUtils.hpp"
using namespace std; using namespace std;
......
// --------------------------------------------------------------------
#include <set>
#include <cif++/Structure.h>
namespace mmcif
{
void addC(Monomer& mon)
{
}
void addCA(Monomer& mon)
{
}
void addN(Monomer& mon)
{
}
void addO(Monomer& mon)
{
}
void CreateMissingBackboneAtoms(Structure& structure, bool simplified)
{
for (auto& poly: structure.polymers())
{
for (auto& mon: poly)
{
if (mon.isComplete() or mon.hasAlternateBackboneAtoms())
continue;
std::set<std::string> missing;
if (not mon.hasAtomWithID("C")) missing.insert("C");
if (not mon.hasAtomWithID("CA")) missing.insert("CA");
if (not mon.hasAtomWithID("N")) missing.insert("N");
if (not mon.hasAtomWithID("O")) missing.insert("O");
switch (missing.size())
{
case 1:
if (missing.count("O"))
addO(mon);
else if (missing.count("N"))
addN(mon);
else if (missing.count("CA"))
addCA(mon);
else if (missing.count("C"))
addC(mon);
break;
}
}
}
}
}
\ No newline at end of file
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include <iomanip> #include <iomanip>
#include <fstream> #include <fstream>
...@@ -21,9 +21,9 @@ namespace fs = boost::filesystem; ...@@ -21,9 +21,9 @@ namespace fs = boost::filesystem;
#include <clipper/clipper-contrib.h> #include <clipper/clipper-contrib.h>
#include <clipper/clipper-ccp4.h> #include <clipper/clipper-ccp4.h>
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
#include "cif++/MapMaker.h" #include "cif++/MapMaker.hpp"
#include "cif++/ResolutionCalculator.h" #include "cif++/ResolutionCalculator.hpp"
using namespace std; using namespace std;
namespace io = boost::iostreams; namespace io = boost::iostreams;
......
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include <map> #include <map>
#include <set> #include <set>
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
#include <clipper/core/spacegroup.h> #include <clipper/core/spacegroup.h>
#include "cif++/PDB2Cif.h" #include "cif++/PDB2Cif.hpp"
#include "cif++/AtomType.h" #include "cif++/AtomType.hpp"
#include "cif++/Compound.h" #include "cif++/Compound.hpp"
#include "cif++/PDB2CifRemark3.h" #include "cif++/PDB2CifRemark3.hpp"
#include "cif++/CifUtils.h" #include "cif++/CifUtils.hpp"
using namespace std; using namespace std;
namespace ba = boost::algorithm; namespace ba = boost::algorithm;
......
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include "cif++/Cif++.h" #include "cif++/Cif++.hpp"
#include <map> #include <map>
#include <set> #include <set>
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
#include <boost/format.hpp> #include <boost/format.hpp>
// #include <boost/numeric/ublas/matrix.hpp> // #include <boost/numeric/ublas/matrix.hpp>
#include "cif++/AtomType.h" #include "cif++/AtomType.hpp"
#include "cif++/Compound.h" #include "cif++/Compound.hpp"
#include "cif++/PDB2CifRemark3.h" #include "cif++/PDB2CifRemark3.hpp"
#include "cif++/CifUtils.h" #include "cif++/CifUtils.hpp"
using namespace std; using namespace std;
namespace ba = boost::algorithm; namespace ba = boost::algorithm;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <random> #include <random>
#include <valarray> #include <valarray>
#include "cif++/Point.h" #include "cif++/Point.hpp"
using namespace std; using namespace std;
......
// -------------------------------------------------------------------- // --------------------------------------------------------------------
#include "cif++/ResolutionCalculator.h" #include "cif++/ResolutionCalculator.hpp"
#include "cif++/Point.h" #include "cif++/Point.hpp"
using namespace std; using namespace std;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// Calculate DSSP-like secondary structure information // Calculate DSSP-like secondary structure information
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include <numeric> #include <numeric>
#include <iomanip> #include <iomanip>
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include "cif++/Structure.h" #include "cif++/Structure.hpp"
#include "cif++/Secondary.h" #include "cif++/Secondary.hpp"
namespace ba = boost::algorithm; namespace ba = boost::algorithm;
......
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
Date: maandag 04 juni, 2018 Date: maandag 04 juni, 2018
*/ */
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include <fstream> #include <fstream>
#include <numeric> #include <numeric>
#include "cif++/Structure.h" #include "cif++/Structure.hpp"
#include "cif++/AtomShape.h" #include "cif++/AtomShape.hpp"
#include "cif++/Statistics.h" #include "cif++/Statistics.hpp"
using namespace std; using namespace std;
......
// Lib for working with structures as contained in file and PDB files // Lib for working with structures as contained in file and PDB files
#include "cif++/Structure.h" #include "cif++/Structure.hpp"
#include <numeric> #include <numeric>
#include <fstream> #include <fstream>
...@@ -19,10 +19,10 @@ namespace fs = boost::filesystem; ...@@ -19,10 +19,10 @@ namespace fs = boost::filesystem;
#include <boost/iostreams/filter/gzip.hpp> #include <boost/iostreams/filter/gzip.hpp>
#include <boost/format.hpp> #include <boost/format.hpp>
#include "cif++/PDB2Cif.h" #include "cif++/PDB2Cif.hpp"
#include "cif++/CifParser.h" #include "cif++/CifParser.hpp"
#include "cif++/Cif2PDB.h" #include "cif++/Cif2PDB.hpp"
#include "cif++/AtomShape.h" #include "cif++/AtomShape.hpp"
using namespace std; using namespace std;
...@@ -317,7 +317,7 @@ struct AtomImpl ...@@ -317,7 +317,7 @@ struct AtomImpl
mLocation = p; mLocation = p;
} }
const Compound& comp() const Compound& comp() const
{ {
if (mCompound == nullptr) if (mCompound == nullptr)
{ {
...@@ -346,7 +346,7 @@ struct AtomImpl ...@@ -346,7 +346,7 @@ struct AtomImpl
return mRadius; return mRadius;
} }
const string& property(const string& name) const string& property(const string& name) const
{ {
static string kEmptyString; static string kEmptyString;
...@@ -391,9 +391,9 @@ struct AtomImpl ...@@ -391,9 +391,9 @@ struct AtomImpl
Point mLocation; Point mLocation;
int mRefcount; int mRefcount;
cif::Row mRow; cif::Row mRow;
const Compound* mCompound; mutable const Compound* mCompound;
float mRadius = nan("4"); float mRadius = nan("4");
map<string,string> mCachedProperties; mutable map<string,string> mCachedProperties;
bool mSymmetryCopy = false; bool mSymmetryCopy = false;
bool mClone = false; bool mClone = false;
...@@ -408,38 +408,58 @@ struct AtomImpl ...@@ -408,38 +408,58 @@ struct AtomImpl
//{ //{
//} //}
// //
Atom::Atom()
: mImpl_(nullptr)
{
}
Atom::Atom(AtomImpl* impl) Atom::Atom(AtomImpl* impl)
: mImpl(impl) : mImpl_(impl)
{
}
AtomImpl* Atom::impl()
{
if (mImpl_ == nullptr)
throw std::runtime_error("atom is not set");
return mImpl_;
}
const AtomImpl* Atom::impl() const
{ {
if (mImpl_ == nullptr)
throw std::runtime_error("atom is not set");
return mImpl_;
} }
Atom Atom::clone() const Atom Atom::clone() const
{ {
return Atom(new AtomImpl(*mImpl)); return Atom(mImpl_ ? new AtomImpl(*mImpl_) : nullptr);
} }
Atom::Atom(const Atom& rhs) Atom::Atom(const Atom& rhs)
: mImpl(rhs.mImpl) : mImpl_(rhs.mImpl_)
{ {
if (mImpl) if (mImpl_)
mImpl->reference(); mImpl_->reference();
} }
Atom::~Atom() Atom::~Atom()
{ {
if (mImpl) if (mImpl_)
mImpl->release(); mImpl_->release();
} }
Atom& Atom::operator=(const Atom& rhs) Atom& Atom::operator=(const Atom& rhs)
{ {
if (this != &rhs) if (this != &rhs)
{ {
if (mImpl) if (mImpl_)
mImpl->release(); mImpl_->release();
mImpl = rhs.mImpl; mImpl_ = rhs.mImpl_;
if (mImpl) if (mImpl_)
mImpl->reference(); mImpl_->reference();
} }
return *this; return *this;
...@@ -448,30 +468,30 @@ Atom& Atom::operator=(const Atom& rhs) ...@@ -448,30 +468,30 @@ Atom& Atom::operator=(const Atom& rhs)
template<> template<>
string Atom::property<string>(const string& name) const string Atom::property<string>(const string& name) const
{ {
return mImpl->property(name); return impl()->property(name);
} }
template<> template<>
int Atom::property<int>(const string& name) const int Atom::property<int>(const string& name) const
{ {
auto v = mImpl->property(name); auto v = impl()->property(name);
return v.empty() ? 0 : stoi(v); return v.empty() ? 0 : stoi(v);
} }
template<> template<>
float Atom::property<float>(const string& name) const float Atom::property<float>(const string& name) const
{ {
return stof(mImpl->property(name)); return stof(impl()->property(name));
} }
const string& Atom::id() const const string& Atom::id() const
{ {
return mImpl->mID; return impl()->mID;
} }
AtomType Atom::type() const AtomType Atom::type() const
{ {
return mImpl->mType; return impl()->mType;
} }
int Atom::charge() const int Atom::charge() const
...@@ -483,8 +503,8 @@ string Atom::energyType() const ...@@ -483,8 +503,8 @@ string Atom::energyType() const
{ {
string result; string result;
if (mImpl and mImpl->mCompound) if (impl() and impl()->mCompound)
result = mImpl->mCompound->getAtomByID(mImpl->mAtomID).typeEnergy; result = impl()->mCompound->getAtomByID(impl()->mAtomID).typeEnergy;
return result; return result;
} }
...@@ -505,7 +525,7 @@ float Atom::uIso() const ...@@ -505,7 +525,7 @@ float Atom::uIso() const
bool Atom::getAnisoU(float anisou[6]) const bool Atom::getAnisoU(float anisou[6]) const
{ {
return mImpl->getAnisoU(anisou); return impl()->getAnisoU(anisou);
} }
float Atom::occupancy() const float Atom::occupancy() const
...@@ -515,27 +535,32 @@ float Atom::occupancy() const ...@@ -515,27 +535,32 @@ float Atom::occupancy() const
string Atom::labelAtomID() const string Atom::labelAtomID() const
{ {
return mImpl->mAtomID; return impl()->mAtomID;
} }
string Atom::labelCompID() const string Atom::labelCompID() const
{ {
return mImpl->mCompID; return impl()->mCompID;
} }
string Atom::labelAsymID() const string Atom::labelAsymID() const
{ {
return mImpl->mAsymID; return impl()->mAsymID;
} }
string Atom::labelAltID() const string Atom::labelAltID() const
{ {
return mImpl->mAltID; return impl()->mAltID;
}
bool Atom::isAlternate() const
{
return not impl()->mAltID.empty();
} }
int Atom::labelSeqID() const int Atom::labelSeqID() const
{ {
return mImpl->mSeqID; return impl()->mSeqID;
} }
string Atom::authAsymID() const string Atom::authAsymID() const
...@@ -570,7 +595,7 @@ string Atom::authSeqID() const ...@@ -570,7 +595,7 @@ string Atom::authSeqID() const
string Atom::labelID() const string Atom::labelID() const
{ {
return property<string>("label_comp_id") + '_' + mImpl->mAsymID + '_' + to_string(mImpl->mSeqID) + ':' + mImpl->mAtomID; return property<string>("label_comp_id") + '_' + impl()->mAsymID + '_' + to_string(impl()->mSeqID) + ':' + impl()->mAtomID;
} }
string Atom::pdbID() const string Atom::pdbID() const
...@@ -584,78 +609,78 @@ string Atom::pdbID() const ...@@ -584,78 +609,78 @@ string Atom::pdbID() const
Point Atom::location() const Point Atom::location() const
{ {
return mImpl->mLocation; return impl()->mLocation;
} }
void Atom::location(Point p) void Atom::location(Point p)
{ {
mImpl->moveTo(p); impl()->moveTo(p);
} }
Atom Atom::symmetryCopy(const Point& d, const clipper::RTop_orth& rt) Atom Atom::symmetryCopy(const Point& d, const clipper::RTop_orth& rt)
{ {
return Atom(new AtomImpl(*mImpl, d, rt)); return Atom(new AtomImpl(*impl(), d, rt));
} }
bool Atom::isSymmetryCopy() const bool Atom::isSymmetryCopy() const
{ {
return mImpl->mSymmetryCopy; return impl()->mSymmetryCopy;
} }
string Atom::symmetry() const string Atom::symmetry() const
{ {
return clipper::Symop(mImpl->mRTop).format() + "\n" + mImpl->mRTop.format(); return clipper::Symop(impl()->mRTop).format() + "\n" + impl()->mRTop.format();
} }
const clipper::RTop_orth& Atom::symop() const const clipper::RTop_orth& Atom::symop() const
{ {
return mImpl->mRTop; return impl()->mRTop;
} }
const Compound& Atom::comp() const const Compound& Atom::comp() const
{ {
return mImpl->comp(); return impl()->comp();
} }
bool Atom::isWater() const bool Atom::isWater() const
{ {
return mImpl->isWater(); return impl()->isWater();
} }
bool Atom::operator==(const Atom& rhs) const bool Atom::operator==(const Atom& rhs) const
{ {
return mImpl == rhs.mImpl or return impl() == rhs.impl() or
(&mImpl->mFile == &rhs.mImpl->mFile and mImpl->mID == rhs.mImpl->mID); (&impl()->mFile == &rhs.impl()->mFile and impl()->mID == rhs.impl()->mID);
} }
clipper::Atom Atom::toClipper() const clipper::Atom Atom::toClipper() const
{ {
return mImpl->toClipper(); return impl()->toClipper();
} }
void Atom::calculateRadius(float resHigh, float resLow, float perc) void Atom::calculateRadius(float resHigh, float resLow, float perc)
{ {
AtomShape shape(*this, resHigh, resLow, false); AtomShape shape(*this, resHigh, resLow, false);
mImpl->mRadius = shape.radius(); impl()->mRadius = shape.radius();
// verbose // verbose
if (cif::VERBOSE > 1) if (cif::VERBOSE > 1)
cout << "Calculated radius for " << AtomTypeTraits(mImpl->mType).name() << " with charge " << charge() << " is " << mImpl->mRadius << endl; cout << "Calculated radius for " << AtomTypeTraits(impl()->mType).name() << " with charge " << charge() << " is " << impl()->mRadius << endl;
} }
float Atom::radius() const float Atom::radius() const
{ {
return mImpl->mRadius; return impl()->mRadius;
} }
int Atom::compare(const Atom& b) const int Atom::compare(const Atom& b) const
{ {
return mImpl == b.mImpl ? 0 : mImpl->compare(*b.mImpl); return impl() == b.impl() ? 0 : impl()->compare(*b.impl());
} }
void Atom::setID(int id) void Atom::setID(int id)
{ {
mImpl->mID = to_string(id); impl()->mID = to_string(id);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -805,13 +830,21 @@ const AtomView& Residue::atoms() const ...@@ -805,13 +830,21 @@ const AtomView& Residue::atoms() const
Atom Residue::atomByID(const string& atomID) const Atom Residue::atomByID(const string& atomID) const
{ {
Atom result;
for (auto& a: mAtoms) for (auto& a: mAtoms)
{ {
if (a.labelAtomID() == atomID) if (a.labelAtomID() == atomID)
return a; {
result = a;
break;
}
} }
throw runtime_error("Atom with atom_id " + atomID + " not found in residue " + mAsymID + ':' + to_string(mSeqID)); if (not result and cif::VERBOSE)
std::cerr << "Atom with atom_id " << atomID << " not found in residue " << mAsymID << ':' << mSeqID << std::endl;
return result;
} }
// Residue is a single entity if the atoms for the asym with mAsymID is equal // Residue is a single entity if the atoms for the asym with mAsymID is equal
...@@ -877,6 +910,11 @@ tuple<Point,float> Residue::centerAndRadius() const ...@@ -877,6 +910,11 @@ tuple<Point,float> Residue::centerAndRadius() const
return make_tuple(center, radius); return make_tuple(center, radius);
} }
bool Residue::hasAlternateAtoms() const
{
return std::find_if(mAtoms.begin(), mAtoms.end(), [](const Atom& atom) { return atom.isAlternate(); }) != mAtoms.end();
}
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// monomer // monomer
...@@ -1137,6 +1175,24 @@ bool Monomer::isComplete() const ...@@ -1137,6 +1175,24 @@ bool Monomer::isComplete() const
return seen == 15; return seen == 15;
} }
bool Monomer::hasAlternateBackboneAtoms() const
{
bool result;
for (auto& a: mAtoms)
{
if (not a.isAlternate())
continue;
auto atomID = a.labelAtomID();
if (atomID == "CA" or atomID == "C" or atomID == "N" or atomID == "O")
{
result = true;
break;
}
}
return result;
}
float Monomer::chiralVolume() const float Monomer::chiralVolume() const
{ {
float result = 0; float result = 0;
...@@ -1939,7 +1995,7 @@ void Structure::swapAtoms(Atom& a1, Atom& a2) ...@@ -1939,7 +1995,7 @@ void Structure::swapAtoms(Atom& a1, Atom& a2)
auto l2 = r2.front()["label_atom_id"]; auto l2 = r2.front()["label_atom_id"];
l1.swap(l2); l1.swap(l2);
a1.mImpl->swapAtomLabels(*a2.mImpl); a1.impl()->swapAtomLabels(*a2.impl());
auto l3 = r1.front()["auth_atom_id"]; auto l3 = r1.front()["auth_atom_id"];
auto l4 = r2.front()["auth_atom_id"]; auto l4 = r2.front()["auth_atom_id"];
......
// copyright // copyright
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include <atomic> #include <atomic>
#include <mutex> #include <mutex>
#include "cif++/Symmetry.h" #include "cif++/Symmetry.hpp"
#include "cif++/CifUtils.h" #include "cif++/CifUtils.hpp"
using namespace std; using namespace std;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "cif++/Config.h" #include "cif++/Config.hpp"
#include <termios.h> #include <termios.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include "cif++/CifUtils.h" #include "cif++/CifUtils.hpp"
#include "cif++/Structure.h" #include "cif++/Structure.hpp"
#include "cif++/TlsParser.h" #include "cif++/TlsParser.hpp"
using namespace std; using namespace std;
namespace po = boost::program_options; namespace po = boost::program_options;
......
#define BOOST_TEST_MODULE LibCifPP_Test #define BOOST_TEST_MODULE LibCifPP_Test
#include <boost/test/included/unit_test.hpp> #include <boost/test/included/unit_test.hpp>
#include "cif++/DistanceMap.h" #include "cif++/DistanceMap.hpp"
// -------------------------------------------------------------------- // --------------------------------------------------------------------
......
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