Commit 41b2231e by maarten

pepflip werk (met ramachandran scores)

git-svn-id: svn+ssh://gitlab/srv/svn-repos/pdb-redo/trunk@283 a1961a4f-ab94-4bcc-80e8-33b5a54de466
parent 4a81e814
...@@ -178,6 +178,9 @@ class Residue ...@@ -178,6 +178,9 @@ class Residue
int seqID() const { return mSeqID; } int seqID() const { return mSeqID; }
const std::string& altID() const { return mAltID; } const std::string& altID() const { return mAltID; }
// return a human readable PDB-like auth id (chain+seqnr+iCode)
std::string authID() const;
// Is this residue a single entity? // Is this residue a single entity?
bool isEntity() const; bool isEntity() const;
...@@ -185,6 +188,8 @@ class Residue ...@@ -185,6 +188,8 @@ class Residue
const Structure& structure() const { return *mStructure; } const Structure& structure() const { return *mStructure; }
bool empty() const { return mStructure == nullptr; }
protected: protected:
const Structure* mStructure; const Structure* mStructure;
...@@ -226,6 +231,7 @@ class Monomer : public Residue ...@@ -226,6 +231,7 @@ class Monomer : public Residue
} }
static bool areBonded(const Monomer& a, const Monomer& b, float errorMargin = 0.5f); static bool areBonded(const Monomer& a, const Monomer& b, float errorMargin = 0.5f);
static bool isCis(const Monomer& a, const Monomer& b);
private: private:
Polymer* mPolymer; Polymer* mPolymer;
...@@ -370,13 +376,13 @@ class Structure ...@@ -370,13 +376,13 @@ class Structure
std::tuple<std::string,std::string,std::string,std::string> MapLabelToAuth( std::tuple<std::string,std::string,std::string,std::string> MapLabelToAuth(
const std::string& asymId, int seqId, const std::string& compId); const std::string& asymId, int seqId, const std::string& compId);
// returns chain, seqnr // returns chain, seqnr, icode
std::tuple<std::string,std::string> MapLabelToAuth( std::tuple<char,int,char> MapLabelToAuth(
const std::string& asymId, int seqId); const std::string& asymId, int seqId) const;
// returns chain,seqnr,comp,iCode // returns chain,seqnr,comp,iCode
std::tuple<std::string,int,std::string,std::string> MapLabelToPDB( std::tuple<std::string,int,std::string,std::string> MapLabelToPDB(
const std::string& asymId, int seqId, const std::string& compId); const std::string& asymId, int seqId, const std::string& compId) const;
std::tuple<std::string,int,std::string,std::string> MapPDBToLabel( std::tuple<std::string,int,std::string,std::string> MapPDBToLabel(
const std::string& asymId, int seqId, const std::string& compId, const std::string& iCode); const std::string& asymId, int seqId, const std::string& compId, const std::string& iCode);
......
...@@ -1221,7 +1221,7 @@ Compound* CompoundFactoryImpl::create(std::string id) ...@@ -1221,7 +1221,7 @@ Compound* CompoundFactoryImpl::create(std::string id)
{ {
auto clibd_mon = fs::path(getenv("CLIBD_MON")); auto clibd_mon = fs::path(getenv("CLIBD_MON"));
fs::path resFile = clibd_mon / ba::to_lower_copy(name.substr(0, 1)) / (id + ".cif"); fs::path resFile = clibd_mon / ba::to_lower_copy(id.substr(0, 1)) / (id + ".cif");
if (not fs::exists(resFile) and (id == "COM" or id == "CON" or "PRN")) // seriously... if (not fs::exists(resFile) and (id == "COM" or id == "CON" or "PRN")) // seriously...
resFile = clibd_mon / ba::to_lower_copy(id.substr(0, 1)) / (id + '_' + id + ".cif"); resFile = clibd_mon / ba::to_lower_copy(id.substr(0, 1)) / (id + '_' + id + ".cif");
......
...@@ -624,6 +624,29 @@ bool Residue::isEntity() const ...@@ -624,6 +624,29 @@ bool Residue::isEntity() const
return a1.size() == a2.size(); return a1.size() == a2.size();
} }
string Residue::authID() const
{
string result;
try
{
char chainID, iCode;
int seqNum;
tie(chainID, seqNum, iCode) = mStructure->MapLabelToAuth(mAsymID, mSeqID);
result = chainID + to_string(seqNum);
if (iCode != ' ' and iCode != 0)
result += iCode;
}
catch (...)
{
result = mAsymID + to_string(mSeqID);
}
return result;
}
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// monomer // monomer
...@@ -710,18 +733,26 @@ float Monomer::kappa() const ...@@ -710,18 +733,26 @@ float Monomer::kappa() const
{ {
double result = 360; double result = 360;
if (mIndex > 2 and mIndex + 2 < mPolymer->size()) try
{ {
Monomer prevPrev = mPolymer->operator[](mIndex - 2); if (mIndex > 2 and mIndex + 2 < mPolymer->size())
Monomer nextNext = mPolymer->operator[](mIndex + 2);
if (prevPrev.mSeqID + 4 == nextNext.mSeqID)
{ {
double ckap = CosinusAngle(CAlpha().location(), prevPrev.CAlpha().location(), nextNext.CAlpha().location(), CAlpha().location()); Monomer prevPrev = mPolymer->operator[](mIndex - 2);
double skap = sqrt(1 - ckap * ckap); Monomer nextNext = mPolymer->operator[](mIndex + 2);
result = atan2(skap, ckap) * 180 / kPI;
if (prevPrev.mSeqID + 4 == nextNext.mSeqID)
{
double ckap = CosinusAngle(CAlpha().location(), prevPrev.CAlpha().location(), nextNext.CAlpha().location(), CAlpha().location());
double skap = sqrt(1 - ckap * ckap);
result = atan2(skap, ckap) * 180 / kPI;
}
} }
} }
catch (const exception& ex)
{
if (VERBOSE)
cerr << ex.what() << endl;
}
return result; return result;
} }
...@@ -752,6 +783,24 @@ bool Monomer::areBonded(const Monomer& a, const Monomer& b, float errorMargin) ...@@ -752,6 +783,24 @@ bool Monomer::areBonded(const Monomer& a, const Monomer& b, float errorMargin)
return result; return result;
} }
bool Monomer::isCis(const mmcif::Monomer& a, const mmcif::Monomer& b)
{
bool result = false;
try
{
double omega = DihedralAngle(
a.atomByID("CA").location(),
a.atomByID("C").location(),
b.atomByID("N").location(),
b.atomByID("CA").location());
result = abs(omega) <= 30.0;
}
catch (...) {}
return result;
}
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// polymer // polymer
...@@ -1237,52 +1286,56 @@ cif::Category& Structure::category(const char* name) const ...@@ -1237,52 +1286,56 @@ cif::Category& Structure::category(const char* name) const
return db[name]; return db[name];
} }
//tuple<string,string> Structure::MapLabelToAuth( tuple<char,int,char> Structure::MapLabelToAuth(
// const string& asymId, int seqId) const string& asymId, int seqId) const
//{ {
// auto& db = *getFile().impl().mDb; auto& db = *getFile().impl().mDb;
//
// tuple<string,int,string,string> result; tuple<char,int,char> result;
// 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") == asymId and
// cif::Key("seq_id") == seq_id)) cif::Key("seq_id") == seqId))
// { {
// string auth_asym_id, pdb_mon_id, pdb_ins_code; string auth_asym_id, pdb_ins_code;
// int pdb_seq_num; int pdb_seq_num;
//
// cif::tie(pdb_strand_id, pdb_seq_num, pdb_mon_id, pdb_ins_code) = cif::tie(auth_asym_id, pdb_seq_num, pdb_ins_code) =
// r.get("pdb_strand_id", "pdb_seq_num", "pdb_mon_id", "pdb_ins_code"); r.get("pdb_strand_id", "pdb_seq_num", "pdb_ins_code");
//
// result = make_tuple(pdb_strand_id, pdb_seq_num, pdb_mon_id, pdb_ins_code); result = make_tuple(auth_asym_id.front(), pdb_seq_num,
// pdb_ins_code.empty() ? ' ' : pdb_ins_code.front());
// found = true;
// break; found = true;
// } break;
// }
// for (auto r: db["pdbx_nonpoly_scheme"].find(
// cif::Key("asym_id") == asym_id and if (not found)
// cif::Key("seq_id") == seq_id and {
// cif::Key("mon_id") == mon_id)) for (auto r: db["pdbx_nonpoly_scheme"].find(
// { cif::Key("asym_id") == asymId and
// string pdb_strand_id, pdb_mon_id, pdb_ins_code; cif::Key("seq_id") == seqId))
// int pdb_seq_num; {
// string pdb_strand_id, pdb_ins_code;
// cif::tie(pdb_strand_id, pdb_seq_num, pdb_mon_id, pdb_ins_code) = int pdb_seq_num;
// r.get("pdb_strand_id", "pdb_seq_num", "pdb_mon_id", "pdb_ins_code");
// cif::tie(pdb_strand_id, pdb_seq_num, pdb_ins_code) =
// result = make_tuple(pdb_strand_id, pdb_seq_num, pdb_mon_id, pdb_ins_code); r.get("pdb_strand_id", "pdb_seq_num", "pdb_ins_code");
//
// found = true; result = make_tuple(pdb_strand_id.front(), pdb_seq_num,
// break; pdb_ins_code.empty() ? ' ' : pdb_ins_code.front());
// }
// found = true;
// return result; break;
//} }
}
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) const
{ {
auto& db = datablock(); auto& db = datablock();
......
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