Commit caf80a0e by maarten

cif2map toegevoegd

git-svn-id: svn+ssh://gitlab/srv/svn-repos/pdb-redo/trunk@183 a1961a4f-ab94-4bcc-80e8-33b5a54de466
parent 032138c4
......@@ -978,6 +978,7 @@ class Category
// return index for known column, or the next available column index
size_t getColumnIndex(const string& name) const;
const string& getColumnName(size_t columnIndex) const;
vector<string> getColumnNames() const;
void reorderByIndex();
......
......@@ -7,6 +7,8 @@
#include <boost/any.hpp>
#include <clipper/core/coords.h>
#include "cif++/AtomType.h"
#include "cif++/Point.h"
#include "cif++/Compound.h"
......@@ -114,6 +116,9 @@ class Atom
const File& getFile() const;
// get clipper format Atom
clipper::Atom toClipper() const;
private:
struct AtomImpl* mImpl;
};
......
......@@ -1078,6 +1078,14 @@ const string& Category::getColumnName(size_t columnIx) const
return mColumns.at(columnIx).mName;
}
vector<string> Category::getColumnNames() const
{
vector<string> result;
for (auto& c: mColumns)
result.push_back(c.mName);
return result;
}
size_t Category::addColumn(const string& name)
{
size_t result = getColumnIndex(name);
......
......@@ -179,6 +179,53 @@ struct AtomImpl
catch (...) {}
}
clipper::Atom toClipper() const
{
clipper::Atom result;
result.set_coord_orth(mLocation);
if (mRow["occupancy"].empty())
result.set_occupancy(1.0);
else
result.set_occupancy(mRow["occupancy"].as<float>());
string element = mRow["type_symbol"].as<string>();
if (not mRow["pdbx_formal_charge"].empty())
{
int charge = mRow["pdbx_formal_charge"].as<int>();
if (abs(charge > 1))
element += to_string(charge);
if (charge < 0)
element += '-';
else
element += '+';
}
result.set_element(element);
if (not mRow["U_iso_or_equiv"].empty())
result.set_u_iso(mRow["U_iso_or_equiv"].as<float>());
else if (not mRow["B_iso_or_equiv"].empty())
result.set_u_iso(mRow["B_iso_or_equiv"].as<float>() / (8 * kPI * kPI));
else
throw runtime_error("Missing B_iso or U_iso");
auto& db = *mFile.impl().mDb;
auto& cat = db["atom_site_anisotrop"];
auto r = cat[cif::Key("id") == mId];
if (r.empty())
result.set_u_aniso_orth(clipper::U_aniso_orth(nan("0"), 0, 0, 0, 0, 0));
else
{
float u11, u12, u13, u22, u23, u33;
cif::tie(u11, u12, u13, u22, u23, u33) =
r.get("U[1][1]", "U[1][2]", "U[1][3]", "U[2][2]", "U[2][3]", "U[3][3]");
result.set_u_aniso_orth(clipper::U_aniso_orth(u11, u12, u13, u22, u23, u33));
}
return result;
}
void reference()
{
++mRefcount;
......@@ -360,6 +407,11 @@ const File& Atom::getFile() const
return mImpl->mFile;
}
clipper::Atom Atom::toClipper() const
{
return mImpl->toClipper();
}
// --------------------------------------------------------------------
// residue
......
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