ngl icon indicating copy to clipboard operation
ngl copied to clipboard

does ngl have a function to decide whether two pdb files have overlapping conformation?

Open yekaizhou opened this issue 3 years ago • 3 comments

Hi,

I am writing a script that decide when two ligands interact with a receptor, whether they are competitive to each other, i.e. have overlapping conformation.

I am wondering if ngl already has a function to decide if two pdb files have overlapping atoms? if not, how can i possibily build my own function based on ngl's existing methods?

Thanks!

yekaizhou avatar May 02 '21 09:05 yekaizhou

This is untested and there's plenty of room for optimization but the basic idea could be:

var component1 = stage.compList[0] // (Or however you get the compound)
var component2 = stage.compList[2] //

var overlaps = false

component1.structure.eachAtom(function(ap) {
  var atomSet = component2.structure.getAtomSetWithinPoint(ap, 2.0 /* within 2.0 Angstroms */);
  if (atomSet.getSize() > 0) { overlaps = true }
})

If you need to compare only a subset of atoms in both structures, something like:

var overlaps = false

var comp2Ligand = component2.structure.getAtomSet('ligand') // get atom indices for 'ligand' atoms


component1.structure.eachAtom(function(ap) {
  // Atom indices from component2 that are near the atom from comp1
  var atomSet = component2.structure.getAtomSetWithinPoint(ap, 2.0 /* within 2.0 Angstroms */);

  // Only care about ones near our subset:
  if (atomSet.intersection(comp2Ligand).getSize() > 0) {
   overlaps = true 
  }
}, new NGL.Selection('ligand') /* Limits the eachAtom loop to only look at ligand atoms */)

fredludlow avatar May 12 '21 13:05 fredludlow

Thanks a lot.

Besides, what if I gonna visualize/highlight the overlap part between the two ligands? Do something with the atomSet? If so, what command should I assign to it? E.g. how to visualize the surface structure of a atom set, rather than a whole .pdb file?

yekaizhou avatar May 12 '21 13:05 yekaizhou

AtomSet has a toSeleString method which will return a selection to apply to (e.g.) a surface representation

fredludlow avatar May 12 '21 15:05 fredludlow