Commit 9a39b566 by Maarten L. Hekkelman

dssp werk

parent 46cc7b24
...@@ -15,3 +15,4 @@ config.status ...@@ -15,3 +15,4 @@ config.status
config.log config.log
aclocal.m4 aclocal.m4
dssp dssp
*.dssp
...@@ -39,116 +39,114 @@ void print_what (const std::exception& e) ...@@ -39,116 +39,114 @@ void print_what (const std::exception& e)
// -------------------------------------------------------------------- // --------------------------------------------------------------------
#if 0 std::string ResidueToDSSPLine(const mmcif::DSSP::ResidueInfo& info)
std::string ResidueToDSSPLine(const MResidue& residue)
{ {
/* /*
This is the header line for the residue lines in a DSSP file: This is the header line for the residue lines in a DSSP file:
# RESIDUE AA STRUCTURE BP1 BP2 ACC N-H-->O O-->H-N N-H-->O O-->H-N TCO KAPPA ALPHA PHI PSI X-CA Y-CA Z-CA CHAIN # RESIDUE AA STRUCTURE BP1 BP2 ACC N-H-->O O-->H-N N-H-->O O-->H-N TCO KAPPA ALPHA PHI PSI X-CA Y-CA Z-CA
*/ */
boost::format kDSSPResidueLine( boost::format kDSSPResidueLine(
"%5.5d%5.5d%1.1s%1.1s %c %c %c%c%c%c%c%c%c%4.4d%4.4d%c%4.4d %11s%11s%11s%11s %6.3f%6.1f%6.1f%6.1f%6.1f %6.1f %6.1f %6.1f %4.4s"); "%5.5d%5.5d%1.1s%1.1s %c %c %c%c%c%c%c%c%c%4.4d%4.4d%c%4.4d %11s%11s%11s%11s %6.3f%6.1f%6.1f%6.1f%6.1f %6.1f %6.1f %6.1f");
const MAtom& ca = residue.GetCAlpha(); auto& residue = info.residue();
char code = kResidueInfo[residue.GetType()].code; if (residue.asymID().length() > 1)
if (residue.GetType() == kCysteine and residue.GetSSBridgeNr() != 0) throw std::runtime_error("This file contains data that won't fit in the original DSSP format");
code = 'a' + ((residue.GetSSBridgeNr() - 1) % 26);
auto ca = residue.atomByID("CA");
char code = 'X';
if (mmcif::kAAMap.find(residue.compoundID()) != mmcif::kAAMap.end())
code = mmcif::kAAMap.at(residue.compoundID());
if (code == 'C') // a cysteine
{
auto ssbridgenr = info.ssBridgeNr();
if (ssbridgenr)
code = 'a' + ((ssbridgenr - 1) % 26);
}
char ss; char ss;
switch (residue.GetSecondaryStructure()) switch (info.ss())
{ {
case alphahelix: ss = 'H'; break; case mmcif::ssAlphahelix: ss = 'H'; break;
case betabridge: ss = 'B'; break; case mmcif::ssBetabridge: ss = 'B'; break;
case strand: ss = 'E'; break; case mmcif::ssStrand: ss = 'E'; break;
case helix_3: ss = 'G'; break; case mmcif::ssHelix_3: ss = 'G'; break;
case helix_5: ss = 'I'; break; case mmcif::ssHelix_5: ss = 'I'; break;
case turn: ss = 'T'; break; case mmcif::ssTurn: ss = 'T'; break;
case bend: ss = 'S'; break; case mmcif::ssBend: ss = 'S'; break;
case loop: ss = ' '; break; case mmcif::ssLoop: ss = ' '; break;
} }
char helix[3]; char helix[3] = { ' ', ' ', ' ' };
for (uint32_t stride = 3; stride <= 5; ++stride) for (auto stride: { 3, 4, 5})
{ {
switch (residue.GetHelixFlag(stride)) switch (info.helix(stride))
{ {
case helixNone: helix[stride - 3] = ' '; break; case mmcif::Helix::None: helix[stride - 3] = ' '; break;
case helixStart: helix[stride - 3] = '>'; break; case mmcif::Helix::Start: helix[stride - 3] = '>'; break;
case helixEnd: helix[stride - 3] = '<'; break; case mmcif::Helix::End: helix[stride - 3] = '<'; break;
case helixStartAndEnd: helix[stride - 3] = 'X'; break; case mmcif::Helix::StartAndEnd: helix[stride - 3] = 'X'; break;
case helixMiddle: helix[stride - 3] = '0' + stride; break; case mmcif::Helix::Middle: helix[stride - 3] = '0' + stride; break;
} }
} }
char bend = ' '; char bend = ' ';
if (residue.IsBend()) if (info.bend())
bend = 'S'; bend = 'S';
double alpha; double alpha = residue.alpha();
char chirality; char chirality = alpha == 360 ? ' ' : (alpha < 0 ? '-' : '+');
std::tr1::tie(alpha,chirality) = residue.Alpha();
uint32_t bp[2] = {}; uint32_t bp[2] = {};
char bridgelabel[2] = { ' ', ' ' }; char bridgelabel[2] = { ' ', ' ' };
for (uint32_t i = 0; i < 2; ++i) for (uint32_t i: { 0, 1 })
{
MBridgeParner p = residue.GetBetaPartner(i);
if (p.residue != nullptr)
{ {
bp[i] = p.residue->GetNumber(); const auto& [p, ladder, parallel] = info.bridgePartner(i);
bp[i] %= 10000; // won't fit otherwise... if (not p)
bridgelabel[i] = 'A' + p.ladder % 26; continue;
if (p.parallel)
bridgelabel[i] = tolower(bridgelabel[i]); bp[i] = p.nr() % 10000; // won't fit otherwise...
} bridgelabel[i] = (parallel ? 'a' : 'A') + ladder % 26;
} }
char sheet = ' '; char sheet = ' ';
if (residue.GetSheet() != 0) if (info.sheet() != 0)
sheet = 'A' + (residue.GetSheet() - 1) % 26; sheet = 'A' + (info.sheet() - 1) % 26;
std::string NHO[2], ONH[2]; std::string NHO[2], ONH[2];
const HBond* acceptors = residue.Acceptor(); for (int i: { 0, 1 })
const HBond* donors = residue.Donor();
for (uint32_t i = 0; i < 2; ++i)
{ {
const auto& [donor, donorE] = info.donor(i);
const auto& [acceptor, acceptorE] = info.acceptor(i);
NHO[i] = ONH[i] = "0, 0.0"; NHO[i] = ONH[i] = "0, 0.0";
if (acceptors[i].residue != nullptr) if (acceptor)
{ {
int32 d = acceptors[i].residue->GetNumber() - residue.GetNumber(); auto d = acceptor.nr() - info.nr();
NHO[i] = (boost::format("%d,%3.1f") % d % acceptors[i].energy).str(); NHO[i] = (boost::format("%d,%3.1f") % d % acceptorE).str();
} }
if (donors[i].residue != nullptr) if (donor)
{ {
int32 d = donors[i].residue->GetNumber() - residue.GetNumber(); auto d = donor.nr() - info.nr();
ONH[i] = (boost::format("%d,%3.1f") % d % donors[i].energy).str(); ONH[i] = (boost::format("%d,%3.1f") % d % donorE).str();
} }
} }
std::string chainChar = ca.mChainID, auto const& [cax, cay, caz] = ca.location();
long_ChainID = "";
if (ca.mChainID.length () > 1)
{
// For mmCIF compatibility
chainChar = ">";
long_ChainID = ca.mChainID;
}
return (kDSSPResidueLine % residue.GetNumber() % ca.mResSeq % ca.mICode % chainChar % code % return (kDSSPResidueLine % info.nr() % ca.authSeqId() % ca.pdbxAuthInsCode() % ca.authAsymId() % code %
ss % helix[0] % helix[1] % helix[2] % bend % chirality % bridgelabel[0] % bridgelabel[1] % ss % helix[0] % helix[1] % helix[2] % bend % chirality % bridgelabel[0] % bridgelabel[1] %
bp[0] % bp[1] % sheet % floor(residue.Accessibility() + 0.5) % bp[0] % bp[1] % sheet % floor(info.accessibility() + 0.5) %
NHO[0] % ONH[0] % NHO[1] % ONH[1] % NHO[0] % ONH[0] % NHO[1] % ONH[1] %
residue.TCO() % residue.Kappa() % alpha % residue.Phi() % residue.Psi() % residue.tco() % residue.kappa() % alpha % residue.phi() % residue.psi() %
ca.mLoc.mX % ca.mLoc.mY % ca.mLoc.mZ % long_ChainID).str(); cax % cay % caz).str();
} }
#endif
void writeDSSP(const mmcif::Structure& structure, const mmcif::DSSP& dssp, std::ostream& os) void writeDSSP(const mmcif::Structure& structure, const mmcif::DSSP& dssp, std::ostream& os)
{ {
const std::string kFirstLine("==== Secondary Structure Definition by the program DSSP, NKI version 3.0 ==== "); const std::string kFirstLine("==== Secondary Structure Definition by the program DSSP, NKI version 3.0 ==== ");
...@@ -156,10 +154,7 @@ void writeDSSP(const mmcif::Structure& structure, const mmcif::DSSP& dssp, std:: ...@@ -156,10 +154,7 @@ void writeDSSP(const mmcif::Structure& structure, const mmcif::DSSP& dssp, std::
using namespace boost::gregorian; using namespace boost::gregorian;
// uint32_t nrOfResidues, nrOfChains, nrOfSSBridges, nrOfIntraChainSSBridges, nrOfHBonds; auto stats = dssp.GetStatistics();
// uint32_t nrOfHBondsPerDistance[11] = {};
// dssp.GetStatistics(nrOfResidues, nrOfChains, nrOfSSBridges, nrOfIntraChainSSBridges, nrOfHBonds, nrOfHBondsPerDistance);
date today = day_clock::local_day(); date today = day_clock::local_day();
...@@ -172,69 +167,66 @@ void writeDSSP(const mmcif::Structure& structure, const mmcif::DSSP& dssp, std:: ...@@ -172,69 +167,66 @@ void writeDSSP(const mmcif::Structure& structure, const mmcif::DSSP& dssp, std::
<< GetPDBSOURCELine(cf, 127) << '.' << std::endl << GetPDBSOURCELine(cf, 127) << '.' << std::endl
<< GetPDBAUTHORLine(cf, 127) << '.' << std::endl; << GetPDBAUTHORLine(cf, 127) << '.' << std::endl;
// double accessibleSurface = 0; // calculate accessibility as os << boost::format("%5.5d%3.3d%3.3d%3.3d%3.3d TOTAL NUMBER OF RESIDUES, NUMBER OF CHAINS, NUMBER OF SS-BRIDGES(TOTAL,INTRACHAIN,INTERCHAIN) %|127t|%c") %
// foreach (const MChain* chain, protein.GetChains()) stats.nrOfResidues % stats.nrOfChains % stats.nrOfSSBridges % stats.nrOfIntraChainSSBridges % (stats.nrOfSSBridges - stats.nrOfIntraChainSSBridges) % '.' << std::endl;
// { os << kHeaderLine % (boost::format("%8.1f ACCESSIBLE SURFACE OF PROTEIN (ANGSTROM**2)") % stats.accessibleSurface) % '.' << std::endl;
// foreach (const MResidue* residue, chain->GetResidues())
// accessibleSurface += residue->Accessibility();
// }
// os << boost::format("%5.5d%3.3d%3.3d%3.3d%3.3d TOTAL NUMBER OF RESIDUES, NUMBER OF CHAINS, NUMBER OF SS-BRIDGES(TOTAL,INTRACHAIN,INTERCHAIN) %|127t|%c") % // hydrogenbond summary
// nrOfResidues % nrOfChains % nrOfSSBridges % nrOfIntraChainSSBridges % (nrOfSSBridges - nrOfIntraChainSSBridges) % '.' << std::endl;
// os << kHeaderLine % (boost::format("%8.1f ACCESSIBLE SURFACE OF PROTEIN (ANGSTROM**2)") % accessibleSurface) % '.' << std::endl;
// // hydrogenbond summary os << kHeaderLine % (
boost::format("%5.5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS OF TYPE O(I)-->H-N(J) , SAME NUMBER PER 100 RESIDUES")
% stats.nrOfHBonds % (stats.nrOfHBonds * 100.0 / stats.nrOfResidues)) % '.' << std::endl;
// os << kHeaderLine % ( os << kHeaderLine % (
// boost::format("%5.5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS OF TYPE O(I)-->H-N(J) , SAME NUMBER PER 100 RESIDUES") boost::format("%5.5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS IN PARALLEL BRIDGES, SAME NUMBER PER 100 RESIDUES")
// % nrOfHBonds % (nrOfHBonds * 100.0 / nrOfResidues)) % '.' << std::endl; % stats.nrOfHBondsInParallelBridges % (stats.nrOfHBondsInParallelBridges * 100.0 / stats.nrOfResidues)) % '.' << std::endl;
// uint32_t nrOfHBondsInParallelBridges = protein.GetNrOfHBondsInParallelBridges(); os << kHeaderLine % (
// os << kHeaderLine % ( boost::format("%5.5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS IN ANTIPARALLEL BRIDGES, SAME NUMBER PER 100 RESIDUES")
// boost::format("%5.5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS IN PARALLEL BRIDGES, SAME NUMBER PER 100 RESIDUES") % stats.nrOfHBondsInAntiparallelBridges % (stats.nrOfHBondsInAntiparallelBridges * 100.0 / stats.nrOfResidues)) % '.' << std::endl;
// % nrOfHBondsInParallelBridges % (nrOfHBondsInParallelBridges * 100.0 / nrOfResidues)) % '.' << std::endl;
// uint32_t nrOfHBondsInAntiparallelBridges = protein.GetNrOfHBondsInAntiparallelBridges(); boost::format kHBondsLine("%5.5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS OF TYPE O(I)-->H-N(I%c%1.1d), SAME NUMBER PER 100 RESIDUES");
// os << kHeaderLine % ( for (int k = 0; k < 11; ++k)
// boost::format("%5.5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS IN ANTIPARALLEL BRIDGES, SAME NUMBER PER 100 RESIDUES") os << kHeaderLine % (kHBondsLine % stats.nrOfHBondsPerDistance[k] % (stats.nrOfHBondsPerDistance[k] * 100.0 / stats.nrOfResidues) % (k - 5 < 0 ? '-' : '+') % abs(k - 5)) % '.' << std::endl;
// % nrOfHBondsInAntiparallelBridges % (nrOfHBondsInAntiparallelBridges * 100.0 / nrOfResidues)) % '.' << std::endl;
// boost::format kHBondsLine("%5.5d%5.1f TOTAL NUMBER OF HYDROGEN BONDS OF TYPE O(I)-->H-N(I%c%1.1d), SAME NUMBER PER 100 RESIDUES"); // histograms...
// for (int32 k = 0; k < 11; ++k) os << " 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 *** HISTOGRAMS OF *** ." << std::endl;
// {
// os << kHeaderLine % (kHBondsLine % nrOfHBondsPerDistance[k] % (nrOfHBondsPerDistance[k] * 100.0 / nrOfResidues) % (k - 5 < 0 ? '-' : '+') % abs(k - 5)) % '.' << std::endl; for (auto hi: stats.residuesPerAlphaHelixHistogram)
// } os << boost::format("%3.3d") % hi;
os << " RESIDUES PER ALPHA HELIX ." << std::endl;
// // histograms... for (auto hi: stats.parallelBridgesPerLadderHistogram)
os << boost::format("%3.3d") % hi;
os << " PARALLEL BRIDGES PER LADDER ." << std::endl;
// uint32_t histogram[kHistogramSize]; for (auto hi: stats.antiparallelBridgesPerLadderHistogram)
// os << " 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 *** HISTOGRAMS OF *** ." << std::endl; os << boost::format("%3.3d") % hi;
os << " ANTIPARALLEL BRIDGES PER LADDER ." << std::endl;
// protein.GetResiduesPerAlphaHelixHistogram(histogram); for (auto hi: stats.laddersPerSheetHistogram)
// for (uint32_t i = 0; i < kHistogramSize; ++i) os << boost::format("%3.3d") % hi;
// os << boost::format("%3.3d") % histogram[i]; os << " LADDERS PER SHEET ." << std::endl;
// os << " RESIDUES PER ALPHA HELIX ." << std::endl;
// protein.GetParallelBridgesPerLadderHistogram(histogram); // per residue information
// for (uint32_t i = 0; i < kHistogramSize; ++i)
// os << boost::format("%3.3d") % histogram[i];
// os << " PARALLEL BRIDGES PER LADDER ." << std::endl;
// protein.GetAntiparallelBridgesPerLadderHistogram(histogram); os << " # RESIDUE AA STRUCTURE BP1 BP2 ACC N-H-->O O-->H-N N-H-->O O-->H-N TCO KAPPA ALPHA PHI PSI X-CA Y-CA Z-CA CHAIN" << std::endl;
// for (uint32_t i = 0; i < kHistogramSize; ++i) boost::format kDSSPResidueLine(
// os << boost::format("%3.3d") % histogram[i]; "%5.5d !%c 0 0 0 0, 0.0 0, 0.0 0, 0.0 0, 0.0 0.000 360.0 360.0 360.0 360.0 0.0 0.0 0.0");
// os << " ANTIPARALLEL BRIDGES PER LADDER ." << std::endl;
// protein.GetLaddersPerSheetHistogram(histogram); int last = 0;
// for (uint32_t i = 0; i < kHistogramSize; ++i) for (auto ri: dssp)
// os << boost::format("%3.3d") % histogram[i]; {
// os << " LADDERS PER SHEET ." << std::endl; // insert a break line whenever we detect missing residues
// can be the transition to a different chain, or missing residues in the current chain
// // per residue information auto b = ri.chainBreak();
if (b != mmcif::ChainBreak::None)
os << (kDSSPResidueLine % (last + 1) % (b == mmcif::ChainBreak::Gap ? '*' : ' ')) << std::endl;
// os << " # RESIDUE AA STRUCTURE BP1 BP2 ACC N-H-->O O-->H-N N-H-->O O-->H-N TCO KAPPA ALPHA PHI PSI X-CA Y-CA Z-CA CHAIN" << std::endl; os << ResidueToDSSPLine(ri) << std::endl;
// boost::format kDSSPResidueLine( last = ri.nr();
// "%5.5d !%c 0 0 0 0, 0.0 0, 0.0 0, 0.0 0, 0.0 0.000 360.0 360.0 360.0 360.0 0.0 0.0 0.0"); }
// std::vector<const MResidue*> residues; // std::vector<const MResidue*> residues;
......
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