Commit 90ddceac by Maarten L. Hekkelman

Better output format

Added dictionary extension
parent dd0d3539
......@@ -135,15 +135,15 @@ class dssp
int pdb_seq_num() const;
std::string pdb_ins_code() const;
float alpha() const;
float kappa() const;
float phi() const;
float psi() const;
float tco() const;
float omega() const;
std::optional<float> alpha() const;
std::optional<float> kappa() const;
std::optional<float> phi() const;
std::optional<float> psi() const;
std::optional<float> tco() const;
std::optional<float> omega() const;
bool is_pre_pro() const;
bool is_cis() const { return std::abs(omega()) < 30.0f; }
bool is_cis() const { return std::abs(omega().value_or(360)) < 30.0f; }
float chiral_volume() const;
std::size_t nr_of_chis() const;
......
......@@ -91,7 +91,7 @@ std::string ResidueToDSSPLine(const dssp::residue_info &info)
if (info.bend())
bend = 'S';
double alpha = residue.alpha();
double alpha = residue.alpha().value_or(360);
char chirality = alpha == 360 ? ' ' : (alpha < 0 ? '-' : '+');
uint32_t bp[2] = {};
......@@ -882,7 +882,7 @@ void writeStatistics(cif::datablock &db, const dssp &dssp)
using histogram_data_type = std::tuple<const char *, const uint32_t *>;
for (const auto &[type, values] : std::vector<histogram_data_type>{
{ "parallel_bridges_per_ladder", stats.histogram.residues_per_alpha_helix },
{ "residues_per_alpha_helix", stats.histogram.residues_per_alpha_helix },
{ "parallel_bridges_per_ladder", stats.histogram.parallel_bridges_per_ladder },
{ "antiparallel_bridges_per_ladder", stats.histogram.antiparallel_bridges_per_ladder },
{ "ladders_per_sheet", stats.histogram.ladders_per_sheet } })
......@@ -930,6 +930,11 @@ void writeSummary(cif::datablock &db, const dssp &dssp)
auto &dssp_struct_summary = db["dssp_struct_summary"];
// prime the category with the field labels we need, this is to ensure proper order in writing out the data.
for (auto label : { "entry_id", "label_comp_id", "label_asym_id", "label_seq_id", "secondary_structure", "ss_bridge", "helix_3_10", "helix_alpha", "helix_pi", "helix_pp", "bend", "chirality", "ladder_1", "ladder_2", "sheet", "accessibility", "TCO", "kappa", "alpha", "phi", "psi", "x_ca", "y_ca", "z_ca"})
dssp_struct_summary.add_column(label);
for (auto res : dssp)
{
......@@ -979,10 +984,9 @@ void writeSummary(cif::datablock &db, const dssp &dssp)
if (res.bend())
bend = "S";
double alpha = res.alpha();
std::string chirality = ".";
if (alpha != 360)
chirality = alpha < 0 ? "-" : "+";
if (res.alpha().has_value())
chirality = *res.alpha() < 0 ? "-" : "+";
std::string ladders[2] = { ".", "." };
......@@ -997,7 +1001,7 @@ void writeSummary(cif::datablock &db, const dssp &dssp)
auto const &[cax, cay, caz] = res.ca_location();
dssp_struct_summary.emplace({
cif::row_initializer data{
{ "entry_id", db.name() },
{ "label_comp_id", res.compound_id() },
{ "label_asym_id", res.asym_id() },
......@@ -1020,18 +1024,39 @@ void writeSummary(cif::datablock &db, const dssp &dssp)
{ "sheet", res.sheet() ? cif::cif_id_for_number(res.sheet() - 1) : "." },
{ "accesssibility", res.accessibility(), 1 },
{ "TCO", res.tco(), 3 },
{ "kappa", res.kappa(), 1 },
{ "alpha", res.alpha(), 1 },
{ "phi", res.phi(), 1 },
{ "psi", res.psi(), 1 },
{ "accessibility", res.accessibility(), 1 },
{ "x_ca", cax, 1 },
{ "y_ca", cay, 1 },
{ "z_ca", caz, 1 },
});
};
if (res.tco().has_value())
data.emplace_back("TCO", *res.tco(), 3);
else
data.emplace_back("TCO", ".");
if (res.kappa().has_value())
data.emplace_back("kappa", *res.kappa(), 1);
else
data.emplace_back("kappa", ".");
if (res.alpha().has_value())
data.emplace_back("alpha", *res.alpha(), 1);
else
data.emplace_back("alpha", ".");
if (res.phi().has_value())
data.emplace_back("phi", *res.phi(), 1);
else
data.emplace_back("phi", ".");
if (res.psi().has_value())
data.emplace_back("psi", *res.psi(), 1);
else
data.emplace_back("psi", ".");
dssp_struct_summary.emplace(std::move(data));
}
}
......
......@@ -531,7 +531,8 @@ struct dssp::residue
float mAccessibility = 0;
float mChiralVolume = 0;
float mAlpha = 360, mKappa = 360, mPhi = 360, mPsi = 360, mTCO = 0, mOmega = 360;
// float mAlpha = 360, mKappa = 360, mPhi = 360, mPsi = 360, mTCO = 0, mOmega = 360;
std::optional<float> mAlpha, mKappa, mPhi, mPsi, mTCO, mOmega;
residue_type mType;
uint8_t mSSBridgeNr = 0;
......@@ -1114,8 +1115,8 @@ void CalculateAlphaHelices(std::vector<residue> &inResidues, statistics &stats,
for (auto &r : inResidues)
{
double kappa = r.mKappa;
r.SetBend(kappa != 360 and kappa > 70);
if (r.mKappa.has_value())
r.SetBend(*r.mKappa > 70);
}
for (uint32_t i = 1; i + 4 < inResidues.size(); ++i)
......@@ -1216,8 +1217,8 @@ void CalculatePPHelices(std::vector<residue> &inResidues, statistics &stats, int
for (uint32_t i = 1; i + 1 < inResidues.size(); ++i)
{
phi[i] = static_cast<float>(inResidues[i].mPhi);
psi[i] = static_cast<float>(inResidues[i].mPsi);
phi[i] = static_cast<float>(inResidues[i].mPhi.value_or(360));
psi[i] = static_cast<float>(inResidues[i].mPsi.value_or(360));
}
for (uint32_t i = 1; i + 3 < inResidues.size(); ++i)
......@@ -1888,32 +1889,32 @@ std::string dssp::residue_info::pdb_ins_code() const
return m_impl->mPDBInsCode;
}
float dssp::residue_info::alpha() const
std::optional<float> dssp::residue_info::alpha() const
{
return m_impl->mAlpha;
}
float dssp::residue_info::kappa() const
std::optional<float> dssp::residue_info::kappa() const
{
return m_impl->mKappa;
}
float dssp::residue_info::omega() const
std::optional<float> dssp::residue_info::omega() const
{
return m_impl->mOmega;
}
float dssp::residue_info::phi() const
std::optional<float> dssp::residue_info::phi() const
{
return m_impl->mPhi;
}
float dssp::residue_info::psi() const
std::optional<float> dssp::residue_info::psi() const
{
return m_impl->mPsi;
}
float dssp::residue_info::tco() const
std::optional<float> dssp::residue_info::tco() const
{
return m_impl->mTCO;
}
......
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