Skip to content

Commit

Permalink
halogen-bond detection and display (PYMOL-3466)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonschrodin authored and JarrettSJohnson committed Jan 30, 2024
1 parent 9c82294 commit ce1fb16
Show file tree
Hide file tree
Showing 11 changed files with 1,948 additions and 18 deletions.
874 changes: 874 additions & 0 deletions data/setting_help.csv

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion layer1/SettingInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,12 @@ enum {
REC_i( 786, cartoon_smooth_cylinder_window , global , 2 ),
REC_i( 787, isosurface_algorithm , global , 0, 0, 2 ),
REC_b( 788, cell_centered , global , false ),

REC_f( 789, halogen_bond_distance , global , 3.5f ),
REC_f( 790, halogen_bond_as_donor_min_donor_angle , global , 140.0f ),
REC_f( 791, halogen_bond_as_donor_min_acceptor_angle , global , 90.0f ),
REC_f( 792, halogen_bond_as_acceptor_min_donor_angle , global , 120.0f ),
REC_f( 793, halogen_bond_as_acceptor_min_acceptor_angle , global , 90.0f ),
REC_f( 794, halogen_bond_as_acceptor_max_acceptor_angle , global , 170.0f ),

#ifdef SETTINGINFO_IMPLEMENTATION
#undef SETTINGINFO_IMPLEMENTATION
Expand Down
4 changes: 4 additions & 0 deletions layer2/ObjectDist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Z* -------------------------------------------------------------------
#include"Feedback.h"
#include"DistSet.h"
#include"ListMacros.h"
#include "Interactions.h"
#ifdef _PYMOL_INCENTIVE
#endif

Expand Down Expand Up @@ -449,6 +450,9 @@ ObjectDist *ObjectDistNewFromSele(PyMOLGlobals * G, ObjectDist * oldObj,
ENDFB(G);
I->DSet[a] = nullptr;
#endif
} else if (mode == 9) { // 9: halogen-bond interaction
I->DSet[a].reset(pymol::FindHalogenBondInteractions(G,
I->DSet[a].release(), sele1, state1, sele2, state2, cutoff, &dist));
} else {
I->DSet[a].reset(SelectorGetDistSet(
G, I->DSet[a].release(), sele1, state1, sele2, state2, mode, cutoff, &dist));
Expand Down
27 changes: 27 additions & 0 deletions layer2/ObjectMolecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,33 @@ void ObjectMoleculeOpRecInit(ObjectMoleculeOpRec * op)
UtilZeroMem((char *) op, sizeof(ObjectMoleculeOpRec));
}

bool ObjectMoleculeGetNeighborVector(
ObjectMolecule* I, int atom, int state, float* v_result)
{
float v_atom[3] = {0.0, 0.0, 0.0};

auto const* cs = I->getCoordSet(state);
if (cs == nullptr) {
return false;
}

if (!CoordSetGetAtomVertex(cs, atom, v_atom)) {
return false;
}

for (auto const& neighbor : AtomNeighbors(I, atom)) {
auto const a2 = neighbor.atm;

// ignore hydrogens
if (I->AtomInfo[a2].protons != cAN_H &&
CoordSetGetAtomVertex(cs, a2, v_result)) {
return true;
}
}

return false;
}

/**
* Returns the most proton-rich element with the lowest priority value (OG1
* before OG2, CG, HB1)
Expand Down
14 changes: 14 additions & 0 deletions layer2/ObjectMolecule.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,20 @@ typedef struct {
void ObjMolPairwiseInit(ObjMolPairwise * pairwise);
void ObjMolPairwisePurge(ObjMolPairwise * pairwise);

/**
* Get neighbor vector
*
* @param I - ObjectMolecule
* @param atom - atom index
* @param state - state index
* @param v_result - vector result
*
* @return true if there is a neighbor
* @return false if there is no neighbor
*/
bool ObjectMoleculeGetNeighborVector(
ObjectMolecule* I, int atom, int state, float* v_result);

int ObjectMoleculeGetTopNeighbor(PyMOLGlobals * G,
ObjectMolecule * I, int start, int excluded);

Expand Down
3 changes: 3 additions & 0 deletions layer3/Executive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9538,6 +9538,9 @@ pymol::Result<float> ExecutiveDistance(PyMOLGlobals* G, const char* nam,
case 8: // "clashes"
SettingSet(cSetting_dash_color, "0xff8800" /* light red */, obj);
break;
case 9: // "halogen-bonds"
SettingSet(cSetting_dash_color, "0xff00ff" /* magenta */, obj);
break;
}

ObjectSetName(obj, nam);
Expand Down
Loading

0 comments on commit ce1fb16

Please sign in to comment.