How to get the distance between two atoms ?

Posted by: small_z

How to get the distance between two atoms ? - 04/07/19 12:10 PM

For example:
I have 2 special atoms in my protein, one is O, the other is N, and I want to calculate the distance (get the value) between O and N, so what kind of command or keyword should I use in my script ?

Thank you very much !
Posted by: rmv

Re: How to get the distance between two atoms ? - 04/07/19 12:21 PM

For a single coordinate set, either COOR DIST (corman.doc) or the QUICK command (miscom.doc) would work.

For a time series of the distance from a simulation, the DISTance time series (correl.doc) is probably the best choice.

The key is often figuring how to identify the atoms, i.e. what is the syntax implied by atom-spec
Posted by: small_z

Re: How to get the distance between two atoms ? - 04/07/19 12:28 PM

I write the script as the following, but it does not work.
----------------------------------------------------
coor dist sele resid @Sresi .and. type @Stype end -
sele resid @ires .and. type HN end
set ROHN ?dist

coor dist sele ires @Sires .and. type OH2 end -
sele resid @ires .and. type HN end
set RO2HN ?dist

if @RO2HN .LT. @ROHN then

-----------------------------------------------
Can you tell me what is wrong ?
Posted by: small_z

Re: How to get the distance between two atoms ? - 04/07/19 12:32 PM

How can I get the value of 'dist' ?
Posted by: lennart

Re: How to get the distance between two atoms ? - 04/07/19 01:08 PM

Not really; we don't even know what you mean when you say "it does not work". How about posting the output so that we can see what the error is, and when it occurs?
It is also a good idea to avoid using variables (@Sresi etc) when submitting questions since it is very difficult to know what the variable contains.

You may also want to consult doc/subst.doc to find out about "?dist"
Posted by: rmv

Re: How to get the distance between two atoms ? - 04/07/19 01:35 PM

Since COOR DIST can return a long list of distances depending on the atom selections, there is no provision to store the result as a scalar ? variable.

When given two atoms, the QUICK command does set the ?DIST variable, as noted in subst.doc
Posted by: small_z

Re: How to get the distance between two atoms ? - 04/07/19 07:02 PM

Thank you. I got it.