Difference between revisions of "Distance"

From PyMOLWiki
Jump to navigation Jump to search
 
(mode=4)
 
(20 intermediate revisions by 8 users not shown)
Line 1: Line 1:
===DESCRIPTION===
+
=Distance=
 +
{|-
 +
||
 +
'''distance''' creates a new distance object between two selections.  It will display all distances within the cutoff.  [[Distance]] is also used to make hydrogen bonds.
 +
Calling [[distance]] without arguments will show distances between selections (pk1) and (pk1), which can be set in editing mode or using the PkAt mouse action (usually CTRL-middle-click).<br><br>
 +
Note: For interactive use, the '''measurement''' [[wizard]] (from the PyMOL menu) makes measuring distances easier than using the [[distance]] command.<br>
 +
If you want to measure distance and avoid creating a distance object, use [[Get Distance]] or [[Distancetoatom]].<br>
 +
|
 +
[[Image:Dist ex1.png|300px|Example of distance.  See example #1.]]
 +
|
 +
[[Image:Dist ex2.png|300px|Example of distance.  See example #2.]]
 +
||
 +
|}
 
   
 
   
"distance" creates a new distance object between two
+
=Usage=
selections.  It will display all distances within the cutoff.
+
<source lang="python">
+
distance [ name [, selection1 [, selection2 [, cutoff [, mode ]]]]]
===USAGE===
+
</source>
+
'''name'''
  distance
+
::string: name of the distance object to create
  distance (selection1), (selection2)
+
'''selection1'''
  distance name = (selection1), (selection1) [,cutoff [,mode] ]
+
::string: first atom selection
+
'''selection2'''
  name = name of distance object  
+
::string: second atom selection
  selection1, selection2 = atom selections
+
'''cutoff'''
  cutoff = maximum distance to display
+
::float: longest distance to show   
  mode = 0 (default)
+
'''mode'''
+
::0: all interatomic distances
===PYMOL API===
+
::1: only bond distances
<source lang="python">  
+
::2: only show polar contact distances
  cmd.distance( string name, string selection1, string selection2,
+
::3: like mode=0, but use [[distance_exclusion]] setting
          string cutoff, string mode )
+
::4: distance between centroids (''new in 1.8.2'')
   returns the average distance between all atoms/frames
+
 
 +
 
 +
=PYMOL API=
 +
<source lang="python">
 +
cmd.distance( string name, string selection1, string selection2,
 +
              float cutoff, int mode )
 +
   # returns the average distance between all atoms/frames
 +
</source>
 +
 
 +
===EXAMPLES===
 +
* Get and show the distance from residue 10's alpha carbon to residue 40's alpha carbon in 1ESR:
 +
<source lang="python">
 +
# make the first residue 0.
 +
zero_residues 1esr, 0
 +
distance i. 10 and n . CA, i. 40 and n. CA
 +
</source>
 +
 
 +
* Get and show the distance from residue 10's alpha carbon to residue 35-42's alpha carbon in 1ESR:
 +
<source lang="python">
 +
# make the first residue 0.
 +
zero_residues 1esr, 0
 +
distance i. 10 and n . CA, i. 35-42 and n. CA
 +
</source>
 +
 
 +
* This neat example shows how to create distance measurements from an atom in a molecule to all other atoms in the molecule (since PyMol supports wildcards).
 +
<source lang="python">
 +
cmd.distance("(/mol1///1/C)","(/mol1///2/C*)")
 +
</source>
 +
or written without the PyMolScript code,
 +
dist /mol1///1/C, /mol1///2/C*
 +
* Create multiple distance objects
 +
<source lang="python">
 +
for at1 in cmd.index("resi 10"): \
 +
  for at2 in cmd.index("resi 11"): \
 +
      cmd.distance(None, "%s`%d"%at1, "%s`%d"%at2)
 +
</source>
 +
 
 +
<source lang="python">
 +
distance (selection1), (selection2)
 +
 
 +
# example
 +
dist i. 158 and n. CA, i. 160 and n. CA
 +
 
 +
distance mydist, 14/CA, 29/CA
 +
distance hbonds, all, all, 3.2, mode=2
 
</source>
 
</source>
  
===NOTES===
+
=See Also=
The distance wizard makes measuring distances easier than using
+
* [[Get Distance]] # Avoid creating an object
the "dist" command for real-time operations.
+
* [[Distancetoatom]] # Automated script for distances to a point
+
* [[Measure_Distance]] # basic script
"dist" alone will show distances between selections (pk1) and (pk1),
+
* [[Lines]]
which can be set using the PkAt mouse action (usually CTRL-middle-click).
 
 
  
[[Category:Commands|distance]]
+
[[Category:Commands|Distance]]

Latest revision as of 15:37, 10 March 2016

Distance

distance creates a new distance object between two selections. It will display all distances within the cutoff. Distance is also used to make hydrogen bonds. Calling distance without arguments will show distances between selections (pk1) and (pk1), which can be set in editing mode or using the PkAt mouse action (usually CTRL-middle-click).

Note: For interactive use, the measurement wizard (from the PyMOL menu) makes measuring distances easier than using the distance command.
If you want to measure distance and avoid creating a distance object, use Get Distance or Distancetoatom.

Example of distance. See example #1.

Example of distance. See example #2.

Usage

distance [ name [, selection1 [, selection2 [, cutoff [, mode ]]]]]

name

string: name of the distance object to create

selection1

string: first atom selection

selection2

string: second atom selection

cutoff

float: longest distance to show

mode

0: all interatomic distances
1: only bond distances
2: only show polar contact distances
3: like mode=0, but use distance_exclusion setting
4: distance between centroids (new in 1.8.2)


PYMOL API

cmd.distance( string name, string selection1, string selection2,
              float cutoff, int mode )
   # returns the average distance between all atoms/frames

EXAMPLES

  • Get and show the distance from residue 10's alpha carbon to residue 40's alpha carbon in 1ESR:
# make the first residue 0.
zero_residues 1esr, 0
distance i. 10 and n . CA, i. 40 and n. CA
  • Get and show the distance from residue 10's alpha carbon to residue 35-42's alpha carbon in 1ESR:
# make the first residue 0.
zero_residues 1esr, 0
distance i. 10 and n . CA, i. 35-42 and n. CA
  • This neat example shows how to create distance measurements from an atom in a molecule to all other atoms in the molecule (since PyMol supports wildcards).
 cmd.distance("(/mol1///1/C)","(/mol1///2/C*)")

or written without the PyMolScript code,

dist /mol1///1/C, /mol1///2/C*
  • Create multiple distance objects
for at1 in cmd.index("resi 10"): \
   for at2 in cmd.index("resi 11"): \
       cmd.distance(None, "%s`%d"%at1, "%s`%d"%at2)
distance (selection1), (selection2)

# example
dist i. 158 and n. CA, i. 160 and n. CA 

distance mydist, 14/CA, 29/CA
distance hbonds, all, all, 3.2, mode=2

See Also