Skip to content

Commit

Permalink
in need to modify MGlycanTorsionSummary
Browse files Browse the repository at this point in the history
  • Loading branch information
GABRAH committed Mar 1, 2023
1 parent 69b3f0a commit 53e2ee8
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 54 deletions.
38 changes: 20 additions & 18 deletions src/privateer/cpp/clipper-glyco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3520,7 +3520,7 @@ bool MGlycan::link_sugars ( int link, clipper::MSugar& first_sugar, clipper::MSu
DBG << "Torsions for link = " << link << ", phi = " << torsions[0] << "\t\tphi_c1c2o8c8 = " << torsions[5] << "\t\tpsi = " << torsions[1] << "\t\tomega_seven = " << torsions[2] << "\t\tomega_eight = " << torsions[3] << "\t\tomega_nine = " << torsions[4] << std::endl;
}
new_connection.set_linkage_atoms(donorAtom, acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom, first_sugar.seqnum(), next_sugar.seqnum());
if(!torsions_zscore_database.database_array.empty())
{
float Phi = clipper::Util::rad2d(phi);
Expand Down Expand Up @@ -3627,7 +3627,7 @@ bool MGlycan::link_sugars ( int link, clipper::MSugar& first_sugar, clipper::MSu
DBG << "Torsions for link = " << link << ", phi = " << torsions[0] << "\t\tphi_c1c2o8c8 = " << torsions[5] << "\t\tpsi = " << torsions[1] << "\t\tomega_seven = " << torsions[2] << "\t\tomega_eight = " << torsions[3] << "\t\tomega_nine = " << torsions[4] << std::endl;
}
new_connection.set_linkage_atoms(donorAtom, acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom, first_sugar.seqnum(), next_sugar.seqnum());
if(!torsions_zscore_database.database_array.empty())
{
float Phi = clipper::Util::rad2d(phi);
Expand Down Expand Up @@ -3716,7 +3716,7 @@ bool MGlycan::link_sugars ( int link, clipper::MSugar& first_sugar, clipper::MSu
DBG << "Torsions for link = " << link << ", phi = " << torsions[0] << "\t\tpsi = " << torsions[1] << "\t\tomega_six = " << torsions[2] << "\t\tomega_seven = " << torsions[3] << std::endl;
}
new_connection.set_linkage_atoms(donorAtom, acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom, first_sugar.seqnum(), next_sugar.seqnum());
if(!torsions_zscore_database.database_array.empty())
{
float Phi = clipper::Util::rad2d(phi);
Expand Down Expand Up @@ -3789,7 +3789,7 @@ bool MGlycan::link_sugars ( int link, clipper::MSugar& first_sugar, clipper::MSu
DBG << "Torsions for link = " << link << ", phi = " << torsions[0] << "\t\tpsi = " << torsions[1] << "\t\tomega = " << torsions[2] << std::endl;
}
new_connection.set_linkage_atoms(donorAtom, acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom, first_sugar.seqnum(), next_sugar.seqnum());
if(!torsions_zscore_database.database_array.empty())
{
float Phi = clipper::Util::rad2d(phi);
Expand Down Expand Up @@ -3857,7 +3857,7 @@ bool MGlycan::link_sugars ( int link, clipper::MSugar& first_sugar, clipper::MSu
DBG << "Torsions for link = " << link << ", phi = " << torsions[0] << "\t\tpsi = " << torsions[1] << std::endl;
}
new_connection.set_linkage_atoms(donorAtom, acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom, first_sugar.seqnum(), next_sugar.seqnum());
if(!torsions_zscore_database.database_array.empty())
{
float Phi = clipper::Util::rad2d(phi);
Expand Down Expand Up @@ -3923,7 +3923,7 @@ bool MGlycan::link_sugars ( int link, clipper::MSugar& first_sugar, clipper::MSu
DBG << "Torsions for link = " << link << ", phi = " << torsions[0] << "\t\tpsi = " << torsions[1] << std::endl;
}
new_connection.set_linkage_atoms(donorAtom, acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom, first_sugar.seqnum(), next_sugar.seqnum());
if(!torsions_zscore_database.database_array.empty())
{
float Phi = clipper::Util::rad2d(phi);
Expand Down Expand Up @@ -3990,7 +3990,7 @@ bool MGlycan::link_sugars ( int link, clipper::MSugar& first_sugar, clipper::MSu
DBG << "Torsions for link = " << link << ", phi = " << torsions[0] << "\t\tpsi = " << torsions[1] << std::endl;
}
new_connection.set_linkage_atoms(donorAtom, acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom, first_sugar.seqnum(), next_sugar.seqnum());
if(!torsions_zscore_database.database_array.empty())
{
float Phi = clipper::Util::rad2d(phi);
Expand Down Expand Up @@ -4055,7 +4055,7 @@ bool MGlycan::link_sugars ( int link, clipper::MSugar& first_sugar, clipper::MSu
DBG << "Torsions for link = " << link << ", phi = " << torsions[0] << "\t\tpsi = " << torsions[1] << std::endl;
}
new_connection.set_linkage_atoms(donorAtom, acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom, first_sugar.seqnum(), next_sugar.seqnum());
if(!torsions_zscore_database.database_array.empty())
{
float Phi = clipper::Util::rad2d(phi);
Expand Down Expand Up @@ -4140,7 +4140,7 @@ bool MGlycan::link_sugars ( int link, clipper::MSugar& first_sugar, clipper::MSu
DBG << "Torsions for when next_sugar has 6 members, link = " << link << ", phi = " << torsions[0] << "\t\tpsi = " << torsions[1] << std::endl;
}
new_connection.set_linkage_atoms(donorAtom, acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom, first_sugar.seqnum(), next_sugar.seqnum());
if(!torsions_zscore_database.database_array.empty())
{
float Phi = clipper::Util::rad2d(phi);
Expand Down Expand Up @@ -4189,7 +4189,7 @@ bool MGlycan::link_sugars ( int link, clipper::MSugar& first_sugar, clipper::MSu
DBG << "Torsions for when next_sugar has 5 members, link = " << link << ", phi = " << torsions[0] << "\t\tpsi = " << torsions[1] << "\t\tomega = " << torsions[2] << std::endl;
}
new_connection.set_linkage_atoms(donorAtom, acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom);
add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), first_sugar.type().trim(), donorAtom, next_sugar.type().trim(), acceptorAtom, first_sugar.seqnum(), next_sugar.seqnum());
if(!torsions_zscore_database.database_array.empty())
{
float Phi = clipper::Util::rad2d(phi);
Expand All @@ -4212,7 +4212,7 @@ bool MGlycan::link_sugars ( int link, clipper::MSugar& first_sugar, clipper::MSu
return false;
}

void MGlycan::add_torsions_for_detected_linkages(float Phi, float Psi, clipper::String first_residue_name, clipper::MAtom first_atom, clipper::String second_residue_name, clipper::MAtom second_atom)
void MGlycan::add_torsions_for_detected_linkages(float Phi, float Psi, clipper::String first_residue_name, clipper::MAtom first_atom, clipper::String second_residue_name, clipper::MAtom second_atom, int first_residue_seqnum, int second_residue_seqnum)
{
if(!all_torsions_within_mglycan.empty())
{
Expand All @@ -4236,13 +4236,11 @@ void MGlycan::add_torsions_for_detected_linkages(float Phi, float Psi, clipper::

auto torsion_seach_result = std::find_if(found_torsion_description.combined_torsions.begin(), found_torsion_description.combined_torsions.end(), [donorPosition, acceptorPosition](std::pair<std::pair<std::string, std::string>, std::vector<std::pair<float,float>>>& element)
{
std::cout << donorPosition << " " << element.first.first << " " << acceptorPosition << " " << element.first.second << std::endl;
return donorPosition == element.first.first &&
acceptorPosition == element.first.second;
});

if (torsion_seach_result != std::end(found_torsion_description.combined_torsions)) {
std::cout << "4262 reached here" << std::endl;
found_torsion_description.combined_torsions[torsion_seach_result-found_torsion_description.combined_torsions.begin()].second.push_back(std::make_pair(Phi, Psi));
}
else {
Expand Down Expand Up @@ -4296,6 +4294,10 @@ void MGlycan::add_torsions_for_detected_linkages(float Phi, float Psi, clipper::
first_torsion.first_residue_name = first_residue_name;
first_torsion.second_residue_name = second_residue_name;
first_torsion.atoms.push_back(std::make_pair(first_atom, second_atom));

std::vector<std::pair<float,float>> tmp_vector = {std::make_pair(Phi, Psi)};
first_torsion.combined_torsions.push_back(std::make_pair(std::make_pair(donorPosition, acceptorPosition), tmp_vector));

first_torsion.linkage_descriptors.push_back(std::make_pair(donorPosition, acceptorPosition));
first_torsion.torsions.push_back(std::make_pair(Phi, Psi));

Expand Down Expand Up @@ -5189,7 +5191,7 @@ void MGlycology::init ( const clipper::MiniMol& mmol, const clipper::MAtomNonBon
psi = clipper::Util::twopi() + psi;

mg.set_glycosylation_torsions ( clipper::Util::rad2d(phi), clipper::Util::rad2d(psi) );
mg.add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), potential_n_roots[i].first.type().trim(), nd2, sugar.type().trim(), c1);
mg.add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), potential_n_roots[i].first.type().trim(), nd2, sugar.type().trim(), c1, potential_n_roots[i].first.seqnum(), sugar.seqnum());

// This is hella cursed. A really cursed hacky implementation just to support linkage highlights in SNFG diagrams for ASN-NAG linkage.
// Ideally clipper::MGlycan::Linkage should have been reimplemented, but that would have taken too much time.
Expand Down Expand Up @@ -5346,7 +5348,7 @@ void MGlycology::init ( const clipper::MiniMol& mmol, const clipper::MAtomNonBon
psi = clipper::Util::twopi() + psi;

mg.set_glycosylation_torsions ( clipper::Util::rad2d(phi), clipper::Util::rad2d(psi) );
mg.add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), potential_o_roots[i].first.type().trim(), og1, sugar.type().trim(), c1);
mg.add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), potential_o_roots[i].first.type().trim(), og1, sugar.type().trim(), c1, potential_o_roots[i].first.seqnum(), sugar.seqnum());


list_of_glycans_modelled_as_glycosylation.push_back ( mg );
Expand Down Expand Up @@ -5430,7 +5432,7 @@ void MGlycology::init ( const clipper::MiniMol& mmol, const clipper::MAtomNonBon
psi = clipper::Util::twopi() + psi;

mg.set_glycosylation_torsions ( clipper::Util::rad2d(phi), clipper::Util::rad2d(psi) );
mg.add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), potential_s_roots[i].first.type().trim(), sg, sugar.type().trim(), c1);
mg.add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), potential_s_roots[i].first.type().trim(), sg, sugar.type().trim(), c1, potential_s_roots[i].first.seqnum(), sugar.seqnum());


list_of_glycans_modelled_as_glycosylation.push_back ( mg );
Expand Down Expand Up @@ -5518,7 +5520,7 @@ void MGlycology::init ( const clipper::MiniMol& mmol, const clipper::MAtomNonBon


mg.set_glycosylation_torsions ( clipper::Util::rad2d(phi), clipper::Util::rad2d(psi) );
mg.add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), potential_c_roots[i].first.type().trim(), cd1, sugar.type().trim(), c1);
mg.add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), potential_c_roots[i].first.type().trim(), cd1, sugar.type().trim(), c1, potential_c_roots[i].first.seqnum(), sugar.seqnum());

if ( linked[j].second.monomer()+3 < mmol[linked[j].second.polymer()].size() )
// Make sure that checks for consensus sequence do not occur outside the array, therefore causing segfaults.
Expand Down Expand Up @@ -5614,7 +5616,7 @@ void MGlycology::init ( const clipper::MiniMol& mmol, const clipper::MAtomNonBon
psi = clipper::Util::twopi() + psi;

mg.set_glycosylation_torsions ( clipper::Util::rad2d(phi), clipper::Util::rad2d(psi) );
mg.add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), potential_p_roots[i].first.type().trim(), op, sugar.type().trim(), c1);
mg.add_torsions_for_detected_linkages(clipper::Util::rad2d(phi), clipper::Util::rad2d(psi), potential_p_roots[i].first.type().trim(), op, sugar.type().trim(), c1, potential_p_roots[i].first.seqnum(), sugar.seqnum());

list_of_glycans_modelled_as_glycosylation.push_back ( mg );
break;
Expand Down
2 changes: 1 addition & 1 deletion src/privateer/cpp/clipper-glyco.h
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ namespace clipper
}; // class Node

bool link_sugars ( int link, clipper::MSugar& first_sugar, clipper::MSugar& next_sugar, clipper::MAtom& donorAtom, clipper::MAtom& acceptorAtom, bool noncircular, privateer::json::GlobalTorsionZScore& torsions_zscore_database ); // true if there's been any problem
void add_torsions_for_detected_linkages(float Phi, float Psi, clipper::String first_residue_name, clipper::MAtom first_atom, clipper::String second_residue_name, clipper::MAtom second_atom);
void add_torsions_for_detected_linkages(float Phi, float Psi, clipper::String first_residue_name, clipper::MAtom first_atom, clipper::String second_residue_name, clipper::MAtom second_atom, int first_residue_seqnum, int second_residue_seqnum);
std::vector<MGlycanTorsionSummary> return_torsion_summary_within_glycan() { return all_torsions_within_mglycan; };
const std::pair < clipper::MMonomer, clipper::MSugar >& get_root () const { return this->root; }
const clipper::String& get_type () const { return kind_of_glycan; } // n-glycan, o-glycan, s-glycan, c-glycan, p-glycan or ligand
Expand Down
Loading

0 comments on commit 53e2ee8

Please sign in to comment.