nglviewer / ngl

WebGL protein viewer
http://nglviewer.org/ngl/
MIT License
657 stars 168 forks source link

Selecting list of residues involved in any type of contact between chains :A & :B #961

Closed pguillem closed 1 year ago

pguillem commented 1 year ago

Hello, I'm trying to build a selector that returns a list of residues in chain :A making any type of contact with atoms from chain :B.

I tried creating a 'contacts' representation with selector 'sele A or :B', but I failed to extract useful information from the representation object (I don't have a clue on how to iterate contact by contact, or if this is possible).

With such an iterator I'd just do a list of residues of contacts where chains are different.

Any pointers would be appreciated. Is there an iterator (ie. eachContact() ) in the representation object? Thanks in advance Pedro

ppillot commented 1 year ago

I did something similar in my project Libmol a few years back. I don't remember the details exactly, but you might find ideas to show you how I tackled this here: https://github.com/ppillot/libmol/blob/4b6e0e72e873dfe25e453149a9eba55b778378be/src/utils/contacts.ts#L312

pguillem commented 1 year ago

You sir, are a life saver! Came in extremely handy. Worked like a charm!!!. Most appreciated.

Thanks Pedro

ppillot commented 1 year ago

You're welcome. You might also have a look at the filterSele parameter of the contact representation which allows to exclude further a set of atoms to define contact that are established only between 2 entities (in other words, "inter" contacts, not "intra" contacts)