Commit 5fb6af0d by Maarten L. Hekkelman

writing sheet info

parent 0cedf7b1
......@@ -350,8 +350,8 @@ void writeSheets(cif::datablock &db, const dssp &dssp)
// write out the struct_sheet, since all info is available now
auto &struct_sheet = db["struct_sheet"];
auto &struct_sheet_range = db["struct_sheet_range"];
auto &struct_sheet_order = db["struct_sheet_order"];
auto &struct_sheet_hbond = db["struct_sheet_hbond"];
// auto &struct_sheet_order = db["struct_sheet_order"];
// auto &struct_sheet_hbond = db["struct_sheet_hbond"];
// auto &pdbx_struct_sheet_hbond = db["pdbx_struct_sheet_hbond"];
// auto &pdbx_poly_seq_scheme = db["pdbx_poly_seq_scheme"];
......@@ -359,7 +359,7 @@ void writeSheets(cif::datablock &db, const dssp &dssp)
{
auto sheetID = cif::cif_id_for_number(sheetNr - 1);
std::map<std::tuple<int,int>,int> sheetOrder;
// std::map<std::tuple<int,int>,int> sheetOrder;
struct_sheet.emplace({
{ "id", sheetID },
......@@ -403,344 +403,344 @@ void writeSheets(cif::datablock &db, const dssp &dssp)
{ "end_auth_asym_id", end.auth_asym_id() },
{ "end_auth_seq_id", end.auth_seq_id() } });
// loop over the ladders for this strand and write out the struct_sheet_order
for (auto &res : strand)
{
for (int i : { 0, 1 })
{
const auto &[bp, ladder, parallel] = res.bridge_partner(i);
// if (not bp or bp.type() != dssp::structure_type::Strand)
if (not bp)
continue;
// // loop over the ladders for this strand and write out the struct_sheet_order
// for (auto &res : strand)
// {
// for (int i : { 0, 1 })
// {
// const auto &[bp, ladder, parallel] = res.bridge_partner(i);
// // if (not bp or bp.type() != dssp::structure_type::Strand)
// if (not bp)
// continue;
auto s1 = res.strand();
auto s2 = bp.strand();
if (s1 > s2)
std::swap(s1, s2);
// auto s1 = res.strand();
// auto s2 = bp.strand();
// if (s1 > s2)
// std::swap(s1, s2);
sheetOrder[{ s1, s2 }] += parallel ? 1 : -1;
}
}
// sheetOrder[{ s1, s2 }] += parallel ? 1 : -1;
// }
// }
}
for (const auto &[k, parallel_test] : sheetOrder)
{
const auto &[s1, s2] = k;
// for (const auto &[k, parallel_test] : sheetOrder)
// {
// const auto &[s1, s2] = k;
if (parallel_test == 0)
continue;
// if (parallel_test == 0)
// continue;
bool parallel = parallel_test > 0;
// bool parallel = parallel_test > 0;
std::string strandID_1 = cif::cif_id_for_number(s1 - 1);
std::string strandID_2 = cif::cif_id_for_number(s2 - 1);
// std::string strandID_1 = cif::cif_id_for_number(s1 - 1);
// std::string strandID_2 = cif::cif_id_for_number(s2 - 1);
struct_sheet_order.emplace({
{ "sheet_id", sheetID },
{ "range_id_1", strandID_1 },
{ "range_id_2", strandID_2 },
{ "sense", parallel > 0 ? "parallel" : "anti-parallel" }
});
// struct_sheet_order.emplace({
// { "sheet_id", sheetID },
// { "range_id_1", strandID_1 },
// { "range_id_2", strandID_2 },
// { "sense", parallel > 0 ? "parallel" : "anti-parallel" }
// });
res_list strand1, strand2;
// res_list strand1, strand2;
for (auto &&[strandTuple, strand] : strands)
{
const auto &[sheet_nr, strand_nr] = strandTuple;
if (sheet_nr != sheetNr)
continue;
// for (auto &&[strandTuple, strand] : strands)
// {
// const auto &[sheet_nr, strand_nr] = strandTuple;
// if (sheet_nr != sheetNr)
// continue;
if (strand_nr == s1)
strand1 = strand;
else if (strand_nr == s2)
{
strand2 = strand;
break;
}
}
// if (strand_nr == s1)
// strand1 = strand;
// else if (strand_nr == s2)
// {
// strand2 = strand;
// break;
// }
// }
assert(not(strand1.empty() or strand2.empty()));
// assert(not(strand1.empty() or strand2.empty()));
int beg1SeqID = 0, beg2SeqID = 0, end1SeqID = 0, end2SeqID = 0;
std::string beg1AtomID, beg2AtomID, end1AtomID, end2AtomID;
// int beg1SeqID = 0, beg2SeqID = 0, end1SeqID = 0, end2SeqID = 0;
// std::string beg1AtomID, beg2AtomID, end1AtomID, end2AtomID;
if (parallel)
{
// I. a d II. a d parallel
// \ /
// b e b e <= the residues forming the bridge
// / \ ..
// c f c f
// if (parallel)
// {
// // I. a d II. a d parallel
// // \ /
// // b e b e <= the residues forming the bridge
// // / \ ..
// // c f c f
for (auto b : strand1)
{
for (int i : { 0, 1 })
{
const auto &[e, ladder1, parallel1] = b.bridge_partner(i);
auto esi = std::find(strand2.begin(), strand2.end(), e);
// for (auto b : strand1)
// {
// for (int i : { 0, 1 })
// {
// const auto &[e, ladder1, parallel1] = b.bridge_partner(i);
// auto esi = std::find(strand2.begin(), strand2.end(), e);
if (esi == strand2.end())
continue;
// if (esi == strand2.end())
// continue;
auto bi = std::find(dssp.begin(), dssp.end(), b);
assert(bi != dssp.end() and bi != dssp.begin());
// auto bi = std::find(dssp.begin(), dssp.end(), b);
// assert(bi != dssp.end() and bi != dssp.begin());
auto a = *std::prev(bi);
auto c = *std::next(bi);
// auto a = *std::prev(bi);
// auto c = *std::next(bi);
auto ei = std::find(dssp.begin(), dssp.end(), e);
assert(ei != dssp.end() and ei != dssp.begin());
auto d = *std::prev(ei);
auto f = *std::next(ei);
// auto ei = std::find(dssp.begin(), dssp.end(), e);
// assert(ei != dssp.end() and ei != dssp.begin());
// auto d = *std::prev(ei);
// auto f = *std::next(ei);
if (test_bond(e, a) and test_bond(c, e)) // case I.
{
beg1SeqID = a.seq_id();
beg2SeqID = e.seq_id();
// if (test_bond(e, a) and test_bond(c, e)) // case I.
// {
// beg1SeqID = a.seq_id();
// beg2SeqID = e.seq_id();
beg1AtomID = "O";
beg2AtomID = "N";
}
else if (test_bond(b, d) and test_bond(f, b)) // case II.
{
beg1SeqID = b.seq_id();
beg2SeqID = d.seq_id();
// beg1AtomID = "O";
// beg2AtomID = "N";
// }
// else if (test_bond(b, d) and test_bond(f, b)) // case II.
// {
// beg1SeqID = b.seq_id();
// beg2SeqID = d.seq_id();
beg1AtomID = "N";
beg2AtomID = "O";
}
// beg1AtomID = "N";
// beg2AtomID = "O";
// }
break;
}
// break;
// }
if (beg1SeqID)
break;
}
// if (beg1SeqID)
// break;
// }
std::reverse(strand1.begin(), strand1.end());
std::reverse(strand2.begin(), strand2.end());
// std::reverse(strand1.begin(), strand1.end());
// std::reverse(strand2.begin(), strand2.end());
for (auto b : strand1)
{
for (int i : { 0, 1 })
{
const auto &[e, ladder1, parallel1] = b.bridge_partner(i);
auto esi = std::find(strand2.begin(), strand2.end(), e);
// for (auto b : strand1)
// {
// for (int i : { 0, 1 })
// {
// const auto &[e, ladder1, parallel1] = b.bridge_partner(i);
// auto esi = std::find(strand2.begin(), strand2.end(), e);
if (esi == strand2.end())
continue;
// if (esi == strand2.end())
// continue;
auto bi = std::find(dssp.begin(), dssp.end(), b);
assert(bi != dssp.end() and bi != dssp.begin());
// auto bi = std::find(dssp.begin(), dssp.end(), b);
// assert(bi != dssp.end() and bi != dssp.begin());
auto a = *std::next(bi);
auto c = *std::prev(bi);
// auto a = *std::next(bi);
// auto c = *std::prev(bi);
auto ei = std::find(dssp.begin(), dssp.end(), e);
assert(ei != dssp.end() and ei != dssp.begin());
auto d = *std::next(ei);
auto f = *std::prev(ei);
// auto ei = std::find(dssp.begin(), dssp.end(), e);
// assert(ei != dssp.end() and ei != dssp.begin());
// auto d = *std::next(ei);
// auto f = *std::prev(ei);
if (test_bond(a, e) and test_bond(e, c)) // case I.
{
end1SeqID = a.seq_id();
end2SeqID = e.seq_id();
// if (test_bond(a, e) and test_bond(e, c)) // case I.
// {
// end1SeqID = a.seq_id();
// end2SeqID = e.seq_id();
end1AtomID = "N";
end2AtomID = "O";
}
else if (test_bond(d, b) and test_bond(b, f)) // case II.
{
end1SeqID = b.seq_id();
end2SeqID = d.seq_id();
// end1AtomID = "N";
// end2AtomID = "O";
// }
// else if (test_bond(d, b) and test_bond(b, f)) // case II.
// {
// end1SeqID = b.seq_id();
// end2SeqID = d.seq_id();
end1AtomID = "O";
end2AtomID = "N";
}
// end1AtomID = "O";
// end2AtomID = "N";
// }
break;
}
// break;
// }
if (end1SeqID)
break;
}
}
else
{
// III. a <- f IV. a f antiparallel
//
// b e b <-> e <= the residues forming the bridge
//
// c -> d c d
// if (end1SeqID)
// break;
// }
// }
// else
// {
// // III. a <- f IV. a f antiparallel
// //
// // b e b <-> e <= the residues forming the bridge
// //
// // c -> d c d
std::reverse(strand2.begin(), strand2.end());
// std::reverse(strand2.begin(), strand2.end());
for (auto b : strand1)
{
for (int i : { 0, 1 })
{
const auto &[e, ladder1, parallel1] = b.bridge_partner(i);
auto esi = std::find(strand2.begin(), strand2.end(), e);
// for (auto b : strand1)
// {
// for (int i : { 0, 1 })
// {
// const auto &[e, ladder1, parallel1] = b.bridge_partner(i);
// auto esi = std::find(strand2.begin(), strand2.end(), e);
if (esi == strand2.end())
continue;
// if (esi == strand2.end())
// continue;
auto bi = std::find(dssp.begin(), dssp.end(), b);
assert(bi != dssp.end() and bi != dssp.begin());
// auto bi = std::find(dssp.begin(), dssp.end(), b);
// assert(bi != dssp.end() and bi != dssp.begin());
auto a = *std::prev(bi);
auto c = *std::next(bi);
// auto a = *std::prev(bi);
// auto c = *std::next(bi);
auto ei = std::find(dssp.begin(), dssp.end(), e);
assert(ei != dssp.end() and ei != dssp.begin());
auto d = *std::prev(ei);
auto f = *std::next(ei);
// auto ei = std::find(dssp.begin(), dssp.end(), e);
// assert(ei != dssp.end() and ei != dssp.begin());
// auto d = *std::prev(ei);
// auto f = *std::next(ei);
if (test_bond(f, a) and test_bond(c, d)) // case III.
{
beg1SeqID = a.seq_id();
beg2SeqID = f.seq_id();
// if (test_bond(f, a) and test_bond(c, d)) // case III.
// {
// beg1SeqID = a.seq_id();
// beg2SeqID = f.seq_id();
beg1AtomID = "O";
beg2AtomID = "N";
}
else if (test_bond(b, e) and test_bond(e, b)) // case IV.
{
beg1SeqID = b.seq_id();
beg2SeqID = e.seq_id();
// beg1AtomID = "O";
// beg2AtomID = "N";
// }
// else if (test_bond(b, e) and test_bond(e, b)) // case IV.
// {
// beg1SeqID = b.seq_id();
// beg2SeqID = e.seq_id();
beg1AtomID = "N";
beg2AtomID = "O";
}
// beg1AtomID = "N";
// beg2AtomID = "O";
// }
break;
}
// break;
// }
if (beg1SeqID)
break;
}
// if (beg1SeqID)
// break;
// }
std::reverse(strand1.begin(), strand1.end());
std::reverse(strand2.begin(), strand2.end());
// std::reverse(strand1.begin(), strand1.end());
// std::reverse(strand2.begin(), strand2.end());
for (auto b : strand1)
{
for (int i : { 0, 1 })
{
const auto &[e, ladder1, parallel1] = b.bridge_partner(i);
auto esi = std::find(strand2.begin(), strand2.end(), e);
// for (auto b : strand1)
// {
// for (int i : { 0, 1 })
// {
// const auto &[e, ladder1, parallel1] = b.bridge_partner(i);
// auto esi = std::find(strand2.begin(), strand2.end(), e);
if (esi == strand2.end())
continue;
// if (esi == strand2.end())
// continue;
auto bi = std::find(dssp.begin(), dssp.end(), b);
assert(bi != dssp.end() and bi != dssp.begin());
// auto bi = std::find(dssp.begin(), dssp.end(), b);
// assert(bi != dssp.end() and bi != dssp.begin());
auto a = *std::next(bi);
auto c = *std::prev(bi);
// auto a = *std::next(bi);
// auto c = *std::prev(bi);
auto ei = std::find(dssp.begin(), dssp.end(), e);
assert(ei != dssp.end() and ei != dssp.begin());
auto d = *std::next(ei);
auto f = *std::prev(ei);
// auto ei = std::find(dssp.begin(), dssp.end(), e);
// assert(ei != dssp.end() and ei != dssp.begin());
// auto d = *std::next(ei);
// auto f = *std::prev(ei);
if (test_bond(a, f) and test_bond(d, c)) // case III.
{
end1SeqID = a.seq_id();
end2SeqID = f.seq_id();
// if (test_bond(a, f) and test_bond(d, c)) // case III.
// {
// end1SeqID = a.seq_id();
// end2SeqID = f.seq_id();
end1AtomID = "N";
end2AtomID = "O";
}
else if (test_bond(b, e) and test_bond(e, b)) // case IV.
{
end1SeqID = b.seq_id();
end2SeqID = e.seq_id();
// end1AtomID = "N";
// end2AtomID = "O";
// }
// else if (test_bond(b, e) and test_bond(e, b)) // case IV.
// {
// end1SeqID = b.seq_id();
// end2SeqID = e.seq_id();
end1AtomID = "N";
end2AtomID = "O";
}
// end1AtomID = "N";
// end2AtomID = "O";
// }
break;
}
// break;
// }
if (end1SeqID)
break;
}
}
// if (end1SeqID)
// break;
// }
// }
struct_sheet_hbond.emplace({
{ "sheet_id", sheetID },
{ "range_id_1", strandID_1 },
{ "range_id_2", strandID_2 },
{ "range_1_beg_label_seq_id", beg1SeqID },
{ "range_1_beg_label_atom_id", beg1AtomID },
{ "range_2_beg_label_seq_id", beg2SeqID },
{ "range_2_beg_label_atom_id", beg2AtomID },
{ "range_1_end_label_seq_id", end1SeqID },
{ "range_1_end_label_atom_id", end1AtomID },
{ "range_2_end_label_seq_id", end2SeqID },
{ "range_2_end_label_atom_id", end2AtomID } });
}
// struct_sheet_hbond.emplace({
// { "sheet_id", sheetID },
// { "range_id_1", strandID_1 },
// { "range_id_2", strandID_2 },
// { "range_1_beg_label_seq_id", beg1SeqID },
// { "range_1_beg_label_atom_id", beg1AtomID },
// { "range_2_beg_label_seq_id", beg2SeqID },
// { "range_2_beg_label_atom_id", beg2AtomID },
// { "range_1_end_label_seq_id", end1SeqID },
// { "range_1_end_label_atom_id", end1AtomID },
// { "range_2_end_label_seq_id", end2SeqID },
// { "range_2_end_label_atom_id", end2AtomID } });
// }
// Data items in the PDBX_STRUCT_SHEET_HBOND category record details
// about the hydrogen bonding between residue ranges in a beta sheet.
// This category is provided for cases where only a single hydrogen
// bond is used to register the two residue ranges. Category
// STRUCT_SHEET_HBOND should be used when the initial and terminal
// hydrogen bonds for strand pair are known.
// // Data items in the PDBX_STRUCT_SHEET_HBOND category record details
// // about the hydrogen bonding between residue ranges in a beta sheet.
// // This category is provided for cases where only a single hydrogen
// // bond is used to register the two residue ranges. Category
// // STRUCT_SHEET_HBOND should be used when the initial and terminal
// // hydrogen bonds for strand pair are known.
// // Okay, so that means we should write entries in that category only
// // when the ladder is size 1. Right? But those are called BetaBridges
// // in
// // // Okay, so that means we should write entries in that category only
// // // when the ladder is size 1. Right? But those are called BetaBridges
// // // in
// {
// // {
// auto b1 = pdbx_poly_seq_scheme.find_first("asym_id"_key == strand1.front().asym_id() and "seq_id"_key == beg1SeqID);
// auto e1 = pdbx_poly_seq_scheme.find_first("asym_id"_key == strand1.front().asym_id() and "seq_id"_key == end1SeqID);
// auto b2 = pdbx_poly_seq_scheme.find_first("asym_id"_key == strand2.front().asym_id() and "seq_id"_key == beg2SeqID);
// auto e2 = pdbx_poly_seq_scheme.find_first("asym_id"_key == strand2.front().asym_id() and "seq_id"_key == end2SeqID);
// // auto b1 = pdbx_poly_seq_scheme.find_first("asym_id"_key == strand1.front().asym_id() and "seq_id"_key == beg1SeqID);
// // auto e1 = pdbx_poly_seq_scheme.find_first("asym_id"_key == strand1.front().asym_id() and "seq_id"_key == end1SeqID);
// // auto b2 = pdbx_poly_seq_scheme.find_first("asym_id"_key == strand2.front().asym_id() and "seq_id"_key == beg2SeqID);
// // auto e2 = pdbx_poly_seq_scheme.find_first("asym_id"_key == strand2.front().asym_id() and "seq_id"_key == end2SeqID);
// if (not(b1 and e1 and b2 and e2))
// {
// if (cif::VERBOSE > 0)
// std::cerr << "error looking up strand ends" << std::endl;
// continue;
// }
// // if (not(b1 and e1 and b2 and e2))
// // {
// // if (cif::VERBOSE > 0)
// // std::cerr << "error looking up strand ends" << std::endl;
// // continue;
// // }
// pdbx_struct_sheet_hbond.emplace({
// { "sheet_id", sheetID },
// { "range_id_1", strandID_1 },
// { "range_id_2", strandID_2 },
// // pdbx_struct_sheet_hbond.emplace({
// // { "sheet_id", sheetID },
// // { "range_id_1", strandID_1 },
// // { "range_id_2", strandID_2 },
// { "range_1_label_atom_id", beg1AtomID },
// { "range_1_label_comp_id", b1["mon_id"].as<std::string>() },
// { "range_1_label_asym_id", b1["asym_id"].as<std::string>() },
// { "range_1_label_seq_id", b1["seq_id"].as<std::string>() },
// { "range_1_PDB_ins_code", b1["pdb_ins_code"].as<std::string>() },
// { "range_1_auth_atom_id", beg1AtomID },
// { "range_1_auth_comp_id", b1["auth_mon_id"].as<std::string>() },
// { "range_1_auth_asym_id", b1["pdb_strand_id"].as<std::string>() },
// { "range_1_auth_seq_id", b1["auth_seq_num"].as<std::string>() },
// { "range_2_label_atom_id", beg2AtomID },
// { "range_2_label_comp_id", b2["mon_id"].as<std::string>() },
// { "range_2_label_asym_id", b2["asym_id"].as<std::string>() },
// { "range_2_label_seq_id", b2["seq_id"].as<std::string>() },
// { "range_2_PDB_ins_code", b2["pdb_ins_code"].as<std::string>() },
// { "range_2_auth_atom_id", beg2AtomID },
// { "range_2_auth_comp_id", b2["auth_mon_id"].as<std::string>() },
// { "range_2_auth_asym_id", b2["pdb_strand_id"].as<std::string>() },
// { "range_2_auth_seq_id", b2["auth_seq_num"].as<std::string>() },
// });
// }
// // { "range_1_label_atom_id", beg1AtomID },
// // { "range_1_label_comp_id", b1["mon_id"].as<std::string>() },
// // { "range_1_label_asym_id", b1["asym_id"].as<std::string>() },
// // { "range_1_label_seq_id", b1["seq_id"].as<std::string>() },
// // { "range_1_PDB_ins_code", b1["pdb_ins_code"].as<std::string>() },
// // { "range_1_auth_atom_id", beg1AtomID },
// // { "range_1_auth_comp_id", b1["auth_mon_id"].as<std::string>() },
// // { "range_1_auth_asym_id", b1["pdb_strand_id"].as<std::string>() },
// // { "range_1_auth_seq_id", b1["auth_seq_num"].as<std::string>() },
// // { "range_2_label_atom_id", beg2AtomID },
// // { "range_2_label_comp_id", b2["mon_id"].as<std::string>() },
// // { "range_2_label_asym_id", b2["asym_id"].as<std::string>() },
// // { "range_2_label_seq_id", b2["seq_id"].as<std::string>() },
// // { "range_2_PDB_ins_code", b2["pdb_ins_code"].as<std::string>() },
// // { "range_2_auth_atom_id", beg2AtomID },
// // { "range_2_auth_comp_id", b2["auth_mon_id"].as<std::string>() },
// // { "range_2_auth_asym_id", b2["pdb_strand_id"].as<std::string>() },
// // { "range_2_auth_seq_id", b2["auth_seq_num"].as<std::string>() },
// // });
// // }
}
}
......
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