Biopython Pdb: Calculate Distance Between An Atom And A Point
Using a typical pdb file, I am able to calculate the distance between two atoms in a structure using a method similar to that presented in the Biopython documentation. Shown here:
Solution 1:
Your atom1 object stores the coordinates in the coord
attribute (it's a NumPy array), e.g.
>>>print(atom1.coord)
[ 26.26600075 25.41300011 2.84200001]
If you want to calculate the distance to another point in space you need to define it in a similar format.
import numpy
x = 1
y = 1
y = 1
v = numpy.array((x, y, z), dtype=float)
and you can then calculate the distance with NumPy.
distance = numpy.linalg.norm(atom1.coord - v)
Post a Comment for "Biopython Pdb: Calculate Distance Between An Atom And A Point"