Commit f3878b37 by maarten

backup

git-svn-id: svn+ssh://gitlab/srv/svn-repos/pdb-redo/trunk@171 a1961a4f-ab94-4bcc-80e8-33b5a54de466
parent 6c935996
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <vector> #include <vector>
#include <map> #include <map>
#include "libcif++/AtomType.h" #include "cif++/AtomType.h"
namespace libcif namespace libcif
{ {
......
#pragma once #pragma once
#include "libcif++/cif++.h" #include "cif++/Cif++.h"
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -30,4 +30,4 @@ struct PDBRecord ...@@ -30,4 +30,4 @@ struct PDBRecord
// -------------------------------------------------------------------- // --------------------------------------------------------------------
void ReadPDBFile(std::istream& pdbFile, cif::file& cifFile); void ReadPDBFile(std::istream& pdbFile, cif::File& cifFile);
...@@ -86,10 +86,10 @@ class Atom ...@@ -86,10 +86,10 @@ class Atom
std::string id() const; std::string id() const;
AtomType type() const; AtomType type() const;
point location() const; Point location() const;
const compound& comp() const; const Compound& comp() const;
const entity& ent() const; const Entity& ent() const;
bool isWater() const; bool isWater() const;
int charge() const; int charge() const;
...@@ -125,13 +125,13 @@ typedef std::vector<Atom> AtomView; ...@@ -125,13 +125,13 @@ typedef std::vector<Atom> AtomView;
class Residue : public std::enable_shared_from_this<Residue> class Residue : public std::enable_shared_from_this<Residue>
{ {
public: public:
Residue(const compound& cmp) : mCompound(cmp) {} Residue(const Compound& cmp) : mCompound(cmp) {}
const compound& comp() const { return mCompound; } const Compound& comp() const { return mCompound; }
virtual AtomView atoms(); virtual AtomView atoms();
private: private:
const compound& mCompound; const Compound& mCompound;
}; };
//// -------------------------------------------------------------------- //// --------------------------------------------------------------------
...@@ -211,13 +211,13 @@ class File : public std::enable_shared_from_this<File> ...@@ -211,13 +211,13 @@ class File : public std::enable_shared_from_this<File>
void load(boost::filesystem::path p); void load(boost::filesystem::path p);
void save(boost::filesystem::path p); void save(boost::filesystem::path p);
structure* model(size_t nr = 1); Structure* model(size_t nr = 1);
struct FileImpl& impl() const { return *mImpl; } struct FileImpl& impl() const { return *mImpl; }
std::vector<const entity*> entities(); std::vector<const Entity*> entities();
cif::datablock& data(); cif::Datablock& data();
private: private:
...@@ -226,13 +226,13 @@ class File : public std::enable_shared_from_this<File> ...@@ -226,13 +226,13 @@ class File : public std::enable_shared_from_this<File>
// -------------------------------------------------------------------- // --------------------------------------------------------------------
class structure class Structure
{ {
public: public:
structure(File& p, uint32 modelNr = 1); Structure(File& p, uint32 modelNr = 1);
structure(const structure&); Structure(const Structure&);
structure& operator=(const structure&); Structure& operator=(const Structure&);
~structure(); ~Structure();
File& getFile() const; File& getFile() const;
...@@ -240,7 +240,7 @@ class structure ...@@ -240,7 +240,7 @@ class structure
AtomView waters() const; AtomView waters() const;
Atom getAtomById(std::string id) const; Atom getAtomById(std::string id) const;
Atom getAtomByLocation(point pt, float maxDistance) const; Atom getAtomByLocation(Point pt, float maxDistance) const;
Atom getAtomForLabel(const std::string& atomId, const std::string& asymId, Atom getAtomForLabel(const std::string& atomId, const std::string& asymId,
const std::string& compId, int seqId, const std::string& altId = ""); const std::string& compId, int seqId, const std::string& altId = "");
......
// 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 "libcif/config.h" #include "cif++/Config.h"
#include <map> #include <map>
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include <boost/filesystem/operations.hpp> #include <boost/filesystem/operations.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include "libcif/compound.h" #include "cif++/Cif++.h"
#include "libcif/cif++.h" #include "cif++/Compound.h"
using namespace std; using namespace std;
namespace ba = boost::algorithm; namespace ba = boost::algorithm;
...@@ -18,38 +18,38 @@ namespace fs = boost::filesystem; ...@@ -18,38 +18,38 @@ namespace fs = boost::filesystem;
namespace libcif namespace libcif
{ {
class compound_factory class CompoundFactory
{ {
public: public:
static compound_factory& instance(); static CompoundFactory& instance();
const compound* create(string id); const Compound* create(string id);
private: private:
compound_factory(); CompoundFactory();
~compound_factory(); ~CompoundFactory();
static compound_factory* sInstance; static CompoundFactory* sInstance;
fs::path m_clibd_mon; fs::path mClibdMon;
vector<compound*> m_compounds; vector<Compound*> mCompounds;
}; };
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// compound // Compound
string compound::formula() const string Compound::formula() const
{ {
string result; string result;
map<string,uint32> atoms; map<string,uint32> atoms;
float charge_sum = 0; float chargeSum = 0;
for (auto r: m_atoms) for (auto r: mAtoms)
{ {
atoms[atom_type_traits(r.type_symbol).symbol()] += 1; atoms[AtomTypeTraits(r.typeSymbol).symbol()] += 1;
charge_sum += r.partial_charge; chargeSum += r.partialCharge;
} }
auto c = atoms.find("C"); auto c = atoms.find("C");
...@@ -83,24 +83,24 @@ string compound::formula() const ...@@ -83,24 +83,24 @@ string compound::formula() const
result += to_string(a.second); result += to_string(a.second);
} }
int charge = lrint(charge_sum); int charge = lrint(chargeSum);
if (charge != 0) if (charge != 0)
result += ' ' + to_string(charge); result += ' ' + to_string(charge);
return result; return result;
} }
int compound::charge() const int Compound::charge() const
{ {
float result = 0; float result = 0;
for (auto r: m_atoms) for (auto r: mAtoms)
result += r.partial_charge; result += r.partialCharge;
return lrint(result); return lrint(result);
} }
string compound::type() const string Compound::type() const
{ {
string result; string result;
...@@ -123,78 +123,78 @@ string compound::type() const ...@@ -123,78 +123,78 @@ string compound::type() const
// pyranose // pyranose
// saccharide // saccharide
if (cif::iequals(m_id, "gly")) if (cif::iequals(mId, "gly"))
result = "peptide linking"; result = "peptide linking";
else if (cif::iequals(m_group, "l-peptide") or cif::iequals(m_group, "L-peptide linking") or cif::iequals(m_group, "peptide")) else if (cif::iequals(mGroup, "l-peptide") or cif::iequals(mGroup, "L-peptide linking") or cif::iequals(mGroup, "peptide"))
result = "L-peptide linking"; result = "L-peptide linking";
else if (cif::iequals(m_group, "DNA")) else if (cif::iequals(mGroup, "DNA"))
result = "DNA linking"; result = "DNA linking";
else if (cif::iequals(m_group, "RNA")) else if (cif::iequals(mGroup, "RNA"))
result = "RNA linking"; result = "RNA linking";
return result; return result;
} }
bool compound::is_water() const bool Compound::isWater() const
{ {
return m_id == "HOH" or m_id == "H2O"; return mId == "HOH" or mId == "H2O";
} }
comp_atom compound::get_atom_by_id(const string& atom_id) const CompoundAtom Compound::getAtomById(const string& atomId) const
{ {
comp_atom result; CompoundAtom result;
for (auto& a: m_atoms) for (auto& a: mAtoms)
{ {
if (a.id == atom_id) if (a.id == atomId)
{ {
result = a; result = a;
break; break;
} }
} }
if (result.id != atom_id) if (result.id != atomId)
throw out_of_range("No atom " + atom_id + " in compound " + m_id); throw out_of_range("No atom " + atomId + " in Compound " + mId);
return result; return result;
} }
const compound* compound::create(const string& id) const Compound* Compound::create(const string& id)
{ {
return compound_factory::instance().create(id); return CompoundFactory::instance().create(id);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// a factory class to generate compounds // a factory class to generate compounds
compound_factory* compound_factory::sInstance = nullptr; CompoundFactory* CompoundFactory::sInstance = nullptr;
compound_factory::compound_factory() CompoundFactory::CompoundFactory()
{ {
const char* clibd_mon = getenv("CLIBD_MON"); const char* clibdMon = getenv("CLIBD_MON");
if (clibd_mon == nullptr) if (clibdMon == nullptr)
throw runtime_error("Cannot locate peptide list, please souce the CCP4 environment"); throw runtime_error("Cannot locate peptide list, please souce the CCP4 environment");
m_clibd_mon = clibd_mon; mClibdMon = clibdMon;
} }
compound_factory::~compound_factory() CompoundFactory::~CompoundFactory()
{ {
} }
compound_factory& compound_factory::instance() CompoundFactory& CompoundFactory::instance()
{ {
if (sInstance == nullptr) if (sInstance == nullptr)
sInstance = new compound_factory(); sInstance = new CompoundFactory();
return *sInstance; return *sInstance;
} }
// id is the three letter code // id is the three letter code
const compound* compound_factory::create(std::string id) const Compound* CompoundFactory::create(std::string id)
{ {
ba::to_upper(id); ba::to_upper(id);
compound* result = nullptr; Compound* result = nullptr;
for (auto cmp: m_compounds) for (auto cmp: mCompounds)
{ {
if (cmp->id() == id) if (cmp->id() == id)
{ {
...@@ -205,11 +205,11 @@ const compound* compound_factory::create(std::string id) ...@@ -205,11 +205,11 @@ const compound* compound_factory::create(std::string id)
if (result == nullptr) if (result == nullptr)
{ {
fs::path resFile = m_clibd_mon / ba::to_lower_copy(id.substr(0, 1)) / (id + ".cif"); fs::path resFile = mClibdMon / ba::to_lower_copy(id.substr(0, 1)) / (id + ".cif");
fs::ifstream file(resFile); fs::ifstream file(resFile);
if (file.is_open()) if (file.is_open())
{ {
cif::file cf; cif::File cf;
try try
{ {
...@@ -222,20 +222,20 @@ const compound* compound_factory::create(std::string id) ...@@ -222,20 +222,20 @@ const compound* compound_factory::create(std::string id)
} }
auto& list = cf["comp_list"]; auto& list = cf["comp_list"];
auto row = list["chem_comp"][cif::key("id") == id]; auto row = list["chem_comp"][cif::Key("id") == id];
string name, group; string name, group;
uint32 number_atoms_all, number_atoms_nh; uint32 numberAtomsAll, numberAtomsNh;
cif::tie(name, group, number_atoms_all, number_atoms_nh) = cif::tie(name, group, numberAtomsAll, numberAtomsNh) =
row.get("name", "group", "number_atoms_all", "number_atoms_nh"); row.get("name", "group", "number_atoms_all", "number_atoms_nh");
ba::trim(name); ba::trim(name);
ba::trim(group); ba::trim(group);
auto& comp_atoms = cf["comp_" + id]["chem_comp_atom"]; auto& compoundAtoms = cf["comp_" + id]["chem_comp_atom"];
vector<comp_atom> atoms; vector<CompoundAtom> atoms;
for (auto row: comp_atoms) for (auto row: compoundAtoms)
{ {
string id, symbol, energy; string id, symbol, energy;
float charge; float charge;
...@@ -243,18 +243,18 @@ const compound* compound_factory::create(std::string id) ...@@ -243,18 +243,18 @@ const compound* compound_factory::create(std::string id)
cif::tie(id, symbol, energy, charge) = row.get("atom_id", "type_symbol", "type_energy", "partial_charge"); cif::tie(id, symbol, energy, charge) = row.get("atom_id", "type_symbol", "type_energy", "partial_charge");
atoms.push_back({ atoms.push_back({
id, atom_type_traits(symbol).type(), energy, charge id, AtomTypeTraits(symbol).type(), energy, charge
}); });
} }
auto& comp_bonds = cf["comp_" + id]["chem_comp_bond"]; auto& compBonds = cf["comp_" + id]["chem_comp_bond"];
map<tuple<string,string>,float> bonds; map<tuple<string,string>,float> bonds;
for (auto row: comp_bonds) for (auto row: compBonds)
{ {
string atom_id_1, atom_id_2, type; string atomId_1, atomId_2, type;
cif::tie(atom_id_1, atom_id_2, type) = row.get("atom_id_1", "atom_id_2", "type"); cif::tie(atomId_1, atomId_2, type) = row.get("atom_id_1", "atom_id_2", "type");
float value = 0; float value = 0;
if (type == "single") value = 1; if (type == "single") value = 1;
...@@ -268,29 +268,29 @@ const compound* compound_factory::create(std::string id) ...@@ -268,29 +268,29 @@ const compound* compound_factory::create(std::string id)
value = 1.0; value = 1.0;
} }
bonds[make_tuple(atom_id_1, atom_id_2)] = value; bonds[make_tuple(atomId_1, atomId_2)] = value;
} }
result = new compound(id, name, group, move(atoms), move(bonds)); result = new Compound(id, name, group, move(atoms), move(bonds));
m_compounds.push_back(result); mCompounds.push_back(result);
} }
} }
return result; return result;
} }
bool compound::atoms_bonded(const string& atom_id_1, const string& atom_id_2) const bool Compound::atomsBonded(const string& atomId_1, const string& atomId_2) const
{ {
return m_bonds.count(make_tuple(atom_id_1, atom_id_2)) or m_bonds.count(make_tuple(atom_id_2, atom_id_1)); return mBonds.count(make_tuple(atomId_1, atomId_2)) or mBonds.count(make_tuple(atomId_2, atomId_1));
} }
float compound::atom_bond_value(const string& atom_id_1, const string& atom_id_2) const float Compound::atomBondValue(const string& atomId_1, const string& atomId_2) const
{ {
auto i = m_bonds.find(make_tuple(atom_id_1, atom_id_2)); auto i = mBonds.find(make_tuple(atomId_1, atomId_2));
if (i == m_bonds.end()) if (i == mBonds.end())
i = m_bonds.find(make_tuple(atom_id_2, atom_id_1)); i = mBonds.find(make_tuple(atomId_2, atomId_1));
return i == m_bonds.end() ? 0 : i->second; return i == mBonds.end() ? 0 : i->second;
} }
} }
...@@ -29,7 +29,7 @@ namespace libcif ...@@ -29,7 +29,7 @@ namespace libcif
struct FileImpl struct FileImpl
{ {
cif::File mData; cif::File mData;
cif::datablock* mDb = nullptr; cif::Datablock* mDb = nullptr;
void load(fs::path p); void load(fs::path p);
void save(fs::path p); void save(fs::path p);
...@@ -71,7 +71,7 @@ void FileImpl::load(fs::path p) ...@@ -71,7 +71,7 @@ void FileImpl::load(fs::path p)
mData.load(in); mData.load(in);
} }
catch (const cif::cifParserError& e) catch (const cif::CifParserError& e)
{ {
if (VERBOSE) if (VERBOSE)
cerr << "Not cif, trying plain old PDB" << endl; cerr << "Not cif, trying plain old PDB" << endl;
...@@ -130,22 +130,22 @@ void FileImpl::save(fs::path p) ...@@ -130,22 +130,22 @@ void FileImpl::save(fs::path p)
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// atom // Atom
struct atomImpl struct AtomImpl
{ {
atomImpl(const File& f, const string& id) AtomImpl(const File& f, const string& id)
: mFile(f), mId(id), mRefcount(1), mCompound(nullptr) : mFile(f), mId(id), mRefcount(1), mCompound(nullptr)
{ {
auto& db = *mFile.impl().mDb; auto& db = *mFile.impl().mDb;
auto& cat = db["atom_site"]; auto& cat = db["atom_site"];
mRow = cat[cif::key("id") == mId]; mRow = cat[cif::Key("id") == mId];
prefetch(); prefetch();
} }
atomImpl(const file& f, const string& id, cif::row row) AtomImpl(const File& f, const string& id, cif::Row row)
: mFile(f), mId(id), mRefcount(1), mRow(row), mCompound(nullptr) : mFile(f), mId(id), mRefcount(1), mRow(row), mCompound(nullptr)
{ {
prefetch(); prefetch();
...@@ -157,12 +157,12 @@ struct atomImpl ...@@ -157,12 +157,12 @@ struct atomImpl
string symbol; string symbol;
cif::tie(symbol) = mRow.get("type_symbol"); cif::tie(symbol) = mRow.get("type_symbol");
mType = atomTypeTraits(symbol).type(); mType = AtomTypeTraits(symbol).type();
float x, y, z; float x, y, z;
cif::tie(x, y, z) = mRow.get("Cartn_x", "Cartn_y", "Cartn_z"); cif::tie(x, y, z) = mRow.get("Cartn_x", "Cartn_y", "Cartn_z");
mLocation = point(x, y, z); mLocation = Point(x, y, z);
try try
{ {
...@@ -182,14 +182,14 @@ struct atomImpl ...@@ -182,14 +182,14 @@ struct atomImpl
delete this; delete this;
} }
const compound& comp() const Compound& comp()
{ {
if (mCompound == nullptr) if (mCompound == nullptr)
{ {
string compId; string compId;
cif::tie(compId) = mRow.get("label_comp_id"); cif::tie(compId) = mRow.get("label_comp_id");
mCompound = compound::create(compId); mCompound = Compound::create(compId);
} }
if (mCompound == nullptr) if (mCompound == nullptr)
...@@ -203,44 +203,44 @@ struct atomImpl ...@@ -203,44 +203,44 @@ struct atomImpl
return mCompound != nullptr and mCompound->isWater(); return mCompound != nullptr and mCompound->isWater();
} }
const file& mFile; const File& mFile;
string mId; string mId;
int mRefcount; int mRefcount;
cif::row mRow; cif::Row mRow;
const compound* mCompound; const Compound* mCompound;
point mLocation; Point mLocation;
atomType mType; AtomType mType;
// const entity& mEntity; // const entity& mEntity;
// std::string mAsymId; // std::string mAsymId;
// std::string mAtomId; // std::string mAtomId;
// point mLoc; // Point mLoc;
// propertyList mProperties; // propertyList mProperties;
}; };
atom::atom(const file& f, const string& id) Atom::Atom(const File& f, const string& id)
: mImpl(new atomImpl(f, id)) : mImpl(new AtomImpl(f, id))
{ {
} }
atom::atom(atomImpl* impl) Atom::Atom(AtomImpl* impl)
: mImpl(impl) : mImpl(impl)
{ {
} }
atom::atom(const atom& rhs) Atom::Atom(const Atom& rhs)
: mImpl(rhs.mImpl) : mImpl(rhs.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)
{ {
...@@ -252,17 +252,17 @@ atom& atom::operator=(const atom& rhs) ...@@ -252,17 +252,17 @@ atom& atom::operator=(const atom& rhs)
return *this; return *this;
} }
string atom::id() const string Atom::id() const
{ {
return mImpl->mId; return mImpl->mId;
} }
atomType atom::type() const AtomType Atom::type() const
{ {
return mImpl->mType; return mImpl->mType;
} }
int atom::charge() const int Atom::charge() const
{ {
int charge; int charge;
cif::tie(charge) = mImpl->mRow.get("pdbx_formal_charge"); cif::tie(charge) = mImpl->mRow.get("pdbx_formal_charge");
...@@ -270,7 +270,7 @@ int atom::charge() const ...@@ -270,7 +270,7 @@ int atom::charge() const
return charge; return charge;
} }
string atom::labelAtomId() const string Atom::labelAtomId() const
{ {
string atomId; string atomId;
cif::tie(atomId) = mImpl->mRow.get("label_atom_id"); cif::tie(atomId) = mImpl->mRow.get("label_atom_id");
...@@ -278,7 +278,7 @@ string atom::labelAtomId() const ...@@ -278,7 +278,7 @@ string atom::labelAtomId() const
return atomId; return atomId;
} }
string atom::labelCompId() const string Atom::labelCompId() const
{ {
string compId; string compId;
cif::tie(compId) = mImpl->mRow.get("label_comp_id"); cif::tie(compId) = mImpl->mRow.get("label_comp_id");
...@@ -286,7 +286,7 @@ string atom::labelCompId() const ...@@ -286,7 +286,7 @@ string atom::labelCompId() const
return compId; return compId;
} }
string atom::labelAsymId() const string Atom::labelAsymId() const
{ {
string asymId; string asymId;
cif::tie(asymId) = mImpl->mRow.get("label_asym_id"); cif::tie(asymId) = mImpl->mRow.get("label_asym_id");
...@@ -294,7 +294,7 @@ string atom::labelAsymId() const ...@@ -294,7 +294,7 @@ string atom::labelAsymId() const
return asymId; return asymId;
} }
int atom::labelSeqId() const int Atom::labelSeqId() const
{ {
int seqId; int seqId;
cif::tie(seqId) = mImpl->mRow.get("label_seq_id"); cif::tie(seqId) = mImpl->mRow.get("label_seq_id");
...@@ -302,7 +302,7 @@ int atom::labelSeqId() const ...@@ -302,7 +302,7 @@ int atom::labelSeqId() const
return seqId; return seqId;
} }
string atom::authAsymId() const string Atom::authAsymId() const
{ {
string asymId; string asymId;
cif::tie(asymId) = mImpl->mRow.get("auth_asym_id"); cif::tie(asymId) = mImpl->mRow.get("auth_asym_id");
...@@ -310,7 +310,7 @@ string atom::authAsymId() const ...@@ -310,7 +310,7 @@ string atom::authAsymId() const
return asymId; return asymId;
} }
int atom::authSeqId() const int Atom::authSeqId() const
{ {
int seqId; int seqId;
cif::tie(seqId) = mImpl->mRow.get("auth_seq_id"); cif::tie(seqId) = mImpl->mRow.get("auth_seq_id");
...@@ -318,35 +318,35 @@ int atom::authSeqId() const ...@@ -318,35 +318,35 @@ int atom::authSeqId() const
return seqId; return seqId;
} }
point atom::location() const Point Atom::location() const
{ {
return mImpl->mLocation; return mImpl->mLocation;
} }
const compound& atom::comp() const const Compound& Atom::comp() const
{ {
return mImpl->comp(); return mImpl->comp();
} }
bool atom::isWater() const bool Atom::isWater() const
{ {
return mImpl->isWater(); return mImpl->isWater();
} }
boost::any atom::property(const std::string& name) const boost::any Atom::property(const std::string& name) const
{ {
string s = mImpl->mRow[name].as<string>(); string s = mImpl->mRow[name].as<string>();
return boost::any(s); return boost::any(s);
} }
bool atom::operator==(const atom& rhs) const bool Atom::operator==(const Atom& rhs) const
{ {
return mImpl == rhs.mImpl or return mImpl == rhs.mImpl or
(&mImpl->mFile == &rhs.mImpl->mFile and mImpl->mId == rhs.mImpl->mId); (&mImpl->mFile == &rhs.mImpl->mFile and mImpl->mId == rhs.mImpl->mId);
} }
const file& atom::getFile() const const File& Atom::getFile() const
{ {
assert(mImpl); assert(mImpl);
return mImpl->mFile; return mImpl->mFile;
...@@ -355,7 +355,7 @@ const file& atom::getFile() const ...@@ -355,7 +355,7 @@ const file& atom::getFile() const
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// residue // residue
//atomView residue::atoms() //AtomView residue::Atoms()
//{ //{
// assert(false); // assert(false);
//} //}
...@@ -367,25 +367,25 @@ const file& atom::getFile() const ...@@ -367,25 +367,25 @@ const file& atom::getFile() const
// polymer // polymer
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// file // File
file::file() File::File()
: mImpl(new FileImpl) : mImpl(new FileImpl)
{ {
} }
File::file(fs::path file) File::File(fs::path File)
: mImpl(new FileImpl) : mImpl(new FileImpl)
{ {
load(file); load(File);
} }
file::~file() File::~File()
{ {
delete mImpl; delete mImpl;
} }
void file::load(fs::path p) void File::load(fs::path p)
{ {
mImpl->load(p); mImpl->load(p);
...@@ -412,7 +412,7 @@ void file::load(fs::path p) ...@@ -412,7 +412,7 @@ void file::load(fs::path p)
// auto& atomSites = db["atom_site"]; // auto& atomSites = db["atom_site"];
// for (auto& atomSite: atomSites) // for (auto& atomSite: atomSites)
// { // {
// atomPtr ap(new atom(this, atom_site)); // AtomPtr ap(new Atom(this, atom_site));
// //
// string entity_id = atom_site["entity_id"]; // string entity_id = atom_site["entity_id"];
// //
...@@ -441,12 +441,12 @@ void file::load(fs::path p) ...@@ -441,12 +441,12 @@ void file::load(fs::path p)
} }
void file::save(boost::filesystem::path file) void File::save(boost::filesystem::path File)
{ {
mImpl->save(file); mImpl->save(File);
} }
cif::datablock& file::data() cif::Datablock& File::data()
{ {
assert(mImpl); assert(mImpl);
assert(mImpl->mDb); assert(mImpl->mDb);
...@@ -458,11 +458,11 @@ cif::datablock& file::data() ...@@ -458,11 +458,11 @@ cif::datablock& file::data()
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// structure // Structure
struct structureImpl struct StructureImpl
{ {
structureImpl(structure& s, file& f, uint32 modelNr) StructureImpl(Structure& s, File& f, uint32 modelNr)
: mFile(&f), mModelNr(modelNr) : mFile(&f), mModelNr(modelNr)
{ {
auto& db = *mFile->impl().mDb; auto& db = *mFile->impl().mDb;
...@@ -473,20 +473,20 @@ struct structureImpl ...@@ -473,20 +473,20 @@ struct structureImpl
auto modelNr = a["pdbx_PDB_model_num"]; auto modelNr = a["pdbx_PDB_model_num"];
if (modelNr.empty() or modelNr.as<uint32>() == mModelNr) if (modelNr.empty() or modelNr.as<uint32>() == mModelNr)
mAtoms.emplace_back(new atomImpl(f, a["id"].as<string>(), a)); mAtoms.emplace_back(new AtomImpl(f, a["id"].as<string>(), a));
} }
} }
void removeAtom(atom& a); void removeAtom(Atom& a);
file* mFile; File* mFile;
uint32 mModelNr; uint32 mModelNr;
atomView mAtoms; AtomView mAtoms;
}; };
void structureImpl::removeAtom(atom& a) void StructureImpl::removeAtom(Atom& a)
{ {
cif::datablock& db = *mFile->impl().mDb; cif::Datablock& db = *mFile->impl().mDb;
auto& atomSites = db["atom_site"]; auto& atomSites = db["atom_site"];
...@@ -505,24 +505,24 @@ void structureImpl::removeAtom(atom& a) ...@@ -505,24 +505,24 @@ void structureImpl::removeAtom(atom& a)
mAtoms.erase(remove(mAtoms.begin(), mAtoms.end(), a), mAtoms.end()); mAtoms.erase(remove(mAtoms.begin(), mAtoms.end(), a), mAtoms.end());
} }
structure::structure(file& f, uint32 modelNr) Structure::Structure(File& f, uint32 modelNr)
: mImpl(new structureImpl(*this, f, modelNr)) : mImpl(new StructureImpl(*this, f, modelNr))
{ {
} }
structure::~structure() Structure::~Structure()
{ {
delete mImpl; delete mImpl;
} }
atomView structure::atoms() const AtomView Structure::atoms() const
{ {
return mImpl->mAtoms; return mImpl->mAtoms;
} }
atomView structure::waters() const AtomView Structure::waters() const
{ {
atomView result; AtomView result;
auto& db = *getFile().impl().mDb; auto& db = *getFile().impl().mDb;
...@@ -549,7 +549,7 @@ atomView structure::waters() const ...@@ -549,7 +549,7 @@ atomView structure::waters() const
return result; return result;
} }
atom structure::getAtomById(string id) const Atom Structure::getAtomById(string id) const
{ {
for (auto& a: mImpl->mAtoms) for (auto& a: mImpl->mAtoms)
{ {
...@@ -560,12 +560,12 @@ atom structure::getAtomById(string id) const ...@@ -560,12 +560,12 @@ atom structure::getAtomById(string id) const
throw out_of_range("Could not find atom with id " + id); throw out_of_range("Could not find atom with id " + id);
} }
file& structure::getFile() const File& Structure::getFile() const
{ {
return *mImpl->mFile; return *mImpl->mFile;
} }
//tuple<string,string> structure::MapLabelToAuth( //tuple<string,string> Structure::MapLabelToAuth(
// const string& asymId, int seqId) // const string& asymId, int seqId)
//{ //{
// auto& db = *getFile().impl().mDb; // auto& db = *getFile().impl().mDb;
...@@ -574,8 +574,8 @@ file& structure::getFile() const ...@@ -574,8 +574,8 @@ file& structure::getFile() const
// bool found = false; // bool found = false;
// //
// for (auto r: db["pdbx_poly_seq_scheme"].find( // for (auto r: db["pdbx_poly_seq_scheme"].find(
// cif::key("asym_id") == asym_id and // cif::Key("asym_id") == asym_id and
// cif::key("seq_id") == seq_id)) // cif::Key("seq_id") == seq_id))
// { // {
// string auth_asym_id, pdb_mon_id, pdb_ins_code; // string auth_asym_id, pdb_mon_id, pdb_ins_code;
// int pdb_seq_num; // int pdb_seq_num;
...@@ -590,9 +590,9 @@ file& structure::getFile() const ...@@ -590,9 +590,9 @@ file& structure::getFile() const
// } // }
// //
// for (auto r: db["pdbx_nonpoly_scheme"].find( // for (auto r: db["pdbx_nonpoly_scheme"].find(
// cif::key("asym_id") == asym_id and // cif::Key("asym_id") == asym_id and
// cif::key("seq_id") == seq_id and // cif::Key("seq_id") == seq_id and
// cif::key("mon_id") == mon_id)) // cif::Key("mon_id") == mon_id))
// { // {
// string pdb_strand_id, pdb_mon_id, pdb_ins_code; // string pdb_strand_id, pdb_mon_id, pdb_ins_code;
// int pdb_seq_num; // int pdb_seq_num;
...@@ -609,7 +609,7 @@ file& structure::getFile() const ...@@ -609,7 +609,7 @@ file& structure::getFile() const
// return result; // return result;
//} //}
tuple<string,int,string,string> structure::MapLabelToPDB( tuple<string,int,string,string> Structure::MapLabelToPDB(
const string& asymId, int seqId, const string& monId) const string& asymId, int seqId, const string& monId)
{ {
auto& db = *getFile().impl().mDb; auto& db = *getFile().impl().mDb;
...@@ -617,9 +617,9 @@ tuple<string,int,string,string> structure::MapLabelToPDB( ...@@ -617,9 +617,9 @@ tuple<string,int,string,string> structure::MapLabelToPDB(
tuple<string,int,string,string> result; tuple<string,int,string,string> result;
for (auto r: db["pdbx_poly_seq_scheme"].find( for (auto r: db["pdbx_poly_seq_scheme"].find(
cif::key("asym_id") == asymId and cif::Key("asym_id") == asymId and
cif::key("seq_id") == seqId and cif::Key("seq_id") == seqId and
cif::key("mon_id") == monId)) cif::Key("mon_id") == monId))
{ {
string pdbStrandId, pdbMonId, pdbInsCode; string pdbStrandId, pdbMonId, pdbInsCode;
int pdbSeqNum; int pdbSeqNum;
...@@ -633,9 +633,9 @@ tuple<string,int,string,string> structure::MapLabelToPDB( ...@@ -633,9 +633,9 @@ tuple<string,int,string,string> structure::MapLabelToPDB(
} }
for (auto r: db["pdbx_nonpoly_scheme"].find( for (auto r: db["pdbx_nonpoly_scheme"].find(
cif::key("asym_id") == asymId and cif::Key("asym_id") == asymId and
cif::key("seq_id") == seqId and cif::Key("seq_id") == seqId and
cif::key("mon_id") == monId)) cif::Key("mon_id") == monId))
{ {
string pdbStrandId, pdbMonId, pdbInsCode; string pdbStrandId, pdbMonId, pdbInsCode;
int pdbSeqNum; int pdbSeqNum;
...@@ -654,7 +654,7 @@ tuple<string,int,string,string> structure::MapLabelToPDB( ...@@ -654,7 +654,7 @@ tuple<string,int,string,string> structure::MapLabelToPDB(
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// actions // actions
void structure::removeAtom(atom& a) void Structure::removeAtom(Atom& a)
{ {
mImpl->removeAtom(a); mImpl->removeAtom(a);
} }
......
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