Discussion:
[PyMOL] Is there a way to "count" hydrogen bond interactions?
Ahmad Abdelzaher
2017-05-05 03:08:53 UTC
Permalink
I know I can can find the hydrogen bond interactions between a
selection and surrounding residues within a certain radius. I would
like to find a way to retrieve the actual count of those interactions
per residue. How can I do it in the API?

Regards.
Thomas Holder
2017-05-19 11:16:30 UTC
Permalink
Hi Ahmad,

Unfortunately there is no proper API for this. But I can think of two approaches. Note that the results can differ because the two method do slightly different h-bond detection!

1) Use "cmd.find_pairs" with mode=1 on "donors" and "acceptors" selection. Example:

sele1 = "chain A & (donors | acceptors)"
sele2 = "chain B & (donors | acceptors)"
radius = 3.5
D = cmd.find_pairs(sele1, sele2, mode=1, cutoff=radius)
print("number of h-bonds:", len(D))

1) Use "cmd.distance" and the "get_raw_distances" script. Example:

run https://raw.githubusercontent.com/Pymol-Scripts/Pymol-script-repo/master/get_raw_distances.py

sele1 = "chain A"
sele2 = "chain B"
radius = 3.5
cmd.distance("distname", sele1, sele2, mode=2, cutoff=radius)
D = get_raw_distances("distname")
print("number of h-bonds:", len(D))

See also:
https://pymolwiki.org/index.php/Get_raw_distances
https://pymolwiki.org/index.php/Distance
https://pymolwiki.org/index.php/Find_pairs

Hope that helps.

Cheers,
Thomas
Post by Ahmad Abdelzaher
I know I can can find the hydrogen bond interactions between a
selection and surrounding residues within a certain radius. I would
like to find a way to retrieve the actual count of those interactions
per residue. How can I do it in the API?
Regards.
--
Thomas Holder
PyMOL Principal Developer
Schrödinger, Inc.
Chi Celestine
2017-05-19 12:26:50 UTC
Permalink
Hi Thomas,
I am also interesting in getting bond distances between two pairs of molecule. I tried running the commands to suggested but I get an error message e.g
When I tried the following (see below) the fist command was well executed but the second gave an error message “ SyntaxError: invalid syntax”

I got a similar error message when I tried to execute this command D = get_raw_distances("distname”) as well


Sincerely,
Celestine

Example

fetch 2xwu, async=0

# interface polar contacts
distance iface_hbonds, chain A, chain B, mode=2

# dump (model,index) information
get_raw_distances iface_hbonds


-------------------------------------------------
Celestine Chi, PhD
ETH ZÃŒrich
Laboratory for Physical Chemistry
Vladimir-Prelog-Weg 2 HCI F 222
CH-8093 ZÃŒrich
Email: ***@phys.chem.ethz.ch<mailto:***@phys.chem.ethz.ch>
tele: 004144 63 37510

On May 19, 2017, at 1:16 PM, Thomas Holder <***@schrodinger.com<mailto:***@schrodinger.com>> wrote:

Hi Ahmad,

Unfortunately there is no proper API for this. But I can think of two approaches. Note that the results can differ because the two method do slightly different h-bond detection!

1) Use "cmd.find_pairs" with mode=1 on "donors" and "acceptors" selection. Example:

sele1 = "chain A & (donors | acceptors)"
sele2 = "chain B & (donors | acceptors)"
radius = 3.5
D = cmd.find_pairs(sele1, sele2, mode=1, cutoff=radius)
print("number of h-bonds:", len(D))

1) Use "cmd.distance" and the "get_raw_distances" script. Example:

run https://raw.githubusercontent.com/Pymol-Scripts/Pymol-script-repo/master/get_raw_distances.py

sele1 = "chain A"
sele2 = "chain B"
radius = 3.5
cmd.distance("distname", sele1, sele2, mode=2, cutoff=radius)
D = get_raw_distances("distname")
print("number of h-bonds:", len(D))

See also:
https://pymolwiki.org/index.php/Get_raw_distances
https://pymolwiki.org/index.php/Distance
https://pymolwiki.org/index.php/Find_pairs

Hope that helps.

Cheers,
Thomas

On May 5, 2017, at 5:08 AM, Ahmad Abdelzaher <***@gmail.com> wrote:

I know I can can find the hydrogen bond interactions between a
selection and surrounding residues within a certain radius. I would
like to find a way to retrieve the actual count of those interactions
per residue. How can I do it in the API?

Regards.
--
Thomas Holder
PyMOL Principal Developer
Schrödinger, Inc.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
PyMOL-users mailing list (PyMOL-***@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-***@lists.sourceforge.net
Thomas Holder
2017-05-19 15:33:57 UTC
Permalink
Hi Celestine,

Did you run the "get_raw_distances.py" script first? You can do that by:

run https://raw.githubusercontent.com/Pymol-Scripts/Pymol-script-repo/master/get_raw_distances.py

Or better: Download it to your computer and run it from there ("run" command or "File > Run Script..." from the menu).

After running the script, you can use the "get_raw_distances" command.

Cheers,
Thomas
Post by Chi Celestine
Hi Thomas,
I am also interesting in getting bond distances between two pairs of molecule. I tried running the commands to suggested but I get an error message e.g
When I tried the following (see below) the fist command was well executed but the second gave an error message “ SyntaxError: invalid syntax”
I got a similar error message when I tried to execute this command D = get_raw_distances("distname”) as well
Sincerely,
Celestine
Example
fetch 2xwu, async=0
# interface polar contacts
distance iface_hbonds, chain A, chain B, mode=2
# dump (model,index) information
get_raw_distances iface_hbonds
-------------------------------------------------
Celestine Chi, PhD
ETH Zürich
Laboratory for Physical Chemistry
Vladimir-Prelog-Weg 2 HCI F 222
CH-8093 Zürich
tele: 004144 63 37510
Post by Thomas Holder
Hi Ahmad,
Unfortunately there is no proper API for this. But I can think of two approaches. Note that the results can differ because the two method do slightly different h-bond detection!
sele1 = "chain A & (donors | acceptors)"
sele2 = "chain B & (donors | acceptors)"
radius = 3.5
D = cmd.find_pairs(sele1, sele2, mode=1, cutoff=radius)
print("number of h-bonds:", len(D))
run https://raw.githubusercontent.com/Pymol-Scripts/Pymol-script-repo/master/get_raw_distances.py
sele1 = "chain A"
sele2 = "chain B"
radius = 3.5
cmd.distance("distname", sele1, sele2, mode=2, cutoff=radius)
D = get_raw_distances("distname")
print("number of h-bonds:", len(D))
https://pymolwiki.org/index.php/Get_raw_distances
https://pymolwiki.org/index.php/Distance
https://pymolwiki.org/index.php/Find_pairs
Hope that helps.
Cheers,
Thomas
Post by Ahmad Abdelzaher
I know I can can find the hydrogen bond interactions between a
selection and surrounding residues within a certain radius. I would
like to find a way to retrieve the actual count of those interactions
per residue. How can I do it in the API?
Regards.
--
Thomas Holder
PyMOL Principal Developer
Schrödinger, Inc.
Chi Celestine
2017-05-19 19:41:37 UTC
Permalink
Dear Thomas,
Many thanks! I copied and saved the script as a dot txt but can not run it from file> run on pymol. Do I need yo save the file in a special folder? I am actually really new with pymol and not vey good in scripting

Thanks for your understanding

Sincerely
Chi
-------------------------------------------------
Celestine Chi, PhD
ETH ZÃŒrich
Laboratory for Physical Chemistry
Vladimir-Prelog-Weg 2 HCI F 222
CH-8093 ZÃŒrich
Email: ***@phys.chem.ethz.ch<mailto:***@phys.chem.ethz.ch>
tele: 004144 63 37510

On May 19, 2017, at 5:33 PM, Thomas Holder <***@schrodinger.com<mailto:***@schrodinger.com>> wrote:

Hi Celestine,

Did you run the "get_raw_distances.py" script first? You can do that by:

run https://raw.githubusercontent.com/Pymol-Scripts/Pymol-script-repo/master/get_raw_distances.py

Or better: Download it to your computer and run it from there ("run" command or "File > Run Script..." from the menu).

After running the script, you can use the "get_raw_distances" command.

Cheers,
Thomas

On May 19, 2017, at 2:26 PM, Chi Celestine <***@phys.chem.ethz.ch<mailto:***@phys.chem.ethz.ch>> wrote:

Hi Thomas,
I am also interesting in getting bond distances between two pairs of molecule. I tried running the commands to suggested but I get an error message e.g
When I tried the following (see below) the fist command was well executed but the second gave an error message “ SyntaxError: invalid syntax”

I got a similar error message when I tried to execute this command D = get_raw_distances("distname”) as well


Sincerely,
Celestine

Example
fetch 2xwu, async=0



# interface polar contacts
distance iface_hbonds, chain A, chain B, mode=2



# dump (model,index) information
get_raw_distances iface_hbonds


-------------------------------------------------
Celestine Chi, PhD
ETH ZÃŒrich
Laboratory for Physical Chemistry
Vladimir-Prelog-Weg 2 HCI F 222
CH-8093 ZÃŒrich
Email: ***@phys.chem.ethz.ch<mailto:***@phys.chem.ethz.ch>
tele: 004144 63 37510

On May 19, 2017, at 1:16 PM, Thomas Holder <***@schrodinger.com<mailto:***@schrodinger.com>> wrote:

Hi Ahmad,

Unfortunately there is no proper API for this. But I can think of two approaches. Note that the results can differ because the two method do slightly different h-bond detection!

1) Use "cmd.find_pairs" with mode=1 on "donors" and "acceptors" selection. Example:

sele1 = "chain A & (donors | acceptors)"
sele2 = "chain B & (donors | acceptors)"
radius = 3.5
D = cmd.find_pairs(sele1, sele2, mode=1, cutoff=radius)
print("number of h-bonds:", len(D))

1) Use "cmd.distance" and the "get_raw_distances" script. Example:

run https://raw.githubusercontent.com/Pymol-Scripts/Pymol-script-repo/master/get_raw_distances.py

sele1 = "chain A"
sele2 = "chain B"
radius = 3.5
cmd.distance("distname", sele1, sele2, mode=2, cutoff=radius)
D = get_raw_distances("distname")
print("number of h-bonds:", len(D))

See also:
https://pymolwiki.org/index.php/Get_raw_distances
https://pymolwiki.org/index.php/Distance
https://pymolwiki.org/index.php/Find_pairs

Hope that helps.

Cheers,
Thomas

On May 5, 2017, at 5:08 AM, Ahmad Abdelzaher <***@gmail.com> wrote:

I know I can can find the hydrogen bond interactions between a
selection and surrounding residues within a certain radius. I would
like to find a way to retrieve the actual count of those interactions
per residue. How can I do it in the API?

Regards.
--
Thomas Holder
PyMOL Principal Developer
Schrödinger, Inc.
Thomas Holder
2017-05-22 09:35:43 UTC
Permalink
Hi Chi,

The file needs a .py extension to be recognized as a Python script. Microsoft Windows can be tricky when it comes to changing a file extension. I recommend to follow these steps when downloading a Python file from the PyMOLWiki:

1) Visit https://pymolwiki.org/index.php/Get_raw_distances
2) Box on the right side, right click on "Download get_raw_distances.py"
3) "Save Link As..." or "Save target as..." (depends on browser)
File name: get_raw_distances.py
Save as type: PY File

Hope that helps.

Cheers,
Thomas
Post by Chi Celestine
Dear Thomas,
Many thanks! I copied and saved the script as a dot txt but can not run it from file> run on pymol. Do I need yo save the file in a special folder? I am actually really new with pymol and not vey good in scripting
Thanks for your understanding
Sincerely
Chi
-------------------------------------------------
Celestine Chi, PhD
ETH Zürich
Laboratory for Physical Chemistry
Vladimir-Prelog-Weg 2 HCI F 222
CH-8093 Zürich
tele: 004144 63 37510
Post by Thomas Holder
Hi Celestine,
run https://raw.githubusercontent.com/Pymol-Scripts/Pymol-script-repo/master/get_raw_distances.py
Or better: Download it to your computer and run it from there ("run" command or "File > Run Script..." from the menu).
After running the script, you can use the "get_raw_distances" command.
Cheers,
Thomas
Post by Chi Celestine
Hi Thomas,
I am also interesting in getting bond distances between two pairs of molecule. I tried running the commands to suggested but I get an error message e.g
When I tried the following (see below) the fist command was well executed but the second gave an error message “ SyntaxError: invalid syntax”
I got a similar error message when I tried to execute this command D = get_raw_distances("distname”) as well
Sincerely,
Celestine
Example
fetch 2xwu, async=0
# interface polar contacts
distance iface_hbonds, chain A, chain B, mode=2
# dump (model,index) information
get_raw_distances iface_hbonds
-------------------------------------------------
Celestine Chi, PhD
ETH Zürich
Laboratory for Physical Chemistry
Vladimir-Prelog-Weg 2 HCI F 222
CH-8093 Zürich
tele: 004144 63 37510
Post by Thomas Holder
Hi Ahmad,
Unfortunately there is no proper API for this. But I can think of two approaches. Note that the results can differ because the two method do slightly different h-bond detection!
sele1 = "chain A & (donors | acceptors)"
sele2 = "chain B & (donors | acceptors)"
radius = 3.5
D = cmd.find_pairs(sele1, sele2, mode=1, cutoff=radius)
print("number of h-bonds:", len(D))
run https://raw.githubusercontent.com/Pymol-Scripts/Pymol-script-repo/master/get_raw_distances.py
sele1 = "chain A"
sele2 = "chain B"
radius = 3.5
cmd.distance("distname", sele1, sele2, mode=2, cutoff=radius)
D = get_raw_distances("distname")
print("number of h-bonds:", len(D))
https://pymolwiki.org/index.php/Get_raw_distances
https://pymolwiki.org/index.php/Distance
https://pymolwiki.org/index.php/Find_pairs
Hope that helps.
Cheers,
Thomas
Post by Ahmad Abdelzaher
I know I can can find the hydrogen bond interactions between a
selection and surrounding residues within a certain radius. I would
like to find a way to retrieve the actual count of those interactions
per residue. How can I do it in the API?
Regards.
--
Thomas Holder
PyMOL Principal Developer
Schrödinger, Inc.

Loading...