align_vectors
#
- biotite.structure.align_vectors(atoms, origin_direction, target_direction, origin_position=None, target_position=None)[source]#
Apply a transformation to atoms or coordinates, that would transfer a origin vector to a target vector.
At first the transformation (translation and rotation), that is necessary to align the origin vector to the target vector is calculated. This means, that the application of the transformation on the origin vector would give the target vector. Then the same transformation is applied to the given atoms/coordinates.
- Parameters:
- atomsAtom or AtomArray or AtomArrayStack or ndarray, shape=(3,) or shape=(n,3) or shape=(m,n,3)
The atoms of which the coordinates are transformed. The coordinates can be directly provided as
ndarray
.- origin_direction, target_directionarray-like, length=3
The vectors representing the direction of the origin or target, respectively. The length of the vectors is irrelevant.
- origin_position, target_positionarray-like, length=3, optional
Optional support vectors for the origin or target, respectively. By default, origin and target start at (0,0,0).
- Returns:
- transformedAtom or AtomArray or AtomArrayStack or ndarray, shape=(3,) or shape=(n,3) or shape=(m,n,3)
A copy of the input atoms or coordinates with the applied transformation.
See also
Examples
Align two different residues at their CA-CB bond, i.e. the CA and CB position of both residues should be equal:
>>> first_residue = atom_array[atom_array.res_id == 1] >>> second_residue = atom_array[atom_array.res_id == 2] >>> first_residue_ca = first_residue[first_residue.atom_name == "CA"] >>> first_residue_cb = first_residue[first_residue.atom_name == "CB"] >>> second_residue_ca = second_residue[second_residue.atom_name == "CA"] >>> second_residue_cb = second_residue[second_residue.atom_name == "CB"] >>> first_residue = align_vectors( ... first_residue, ... origin_direction = first_residue_cb.coord - first_residue_ca.coord, ... target_direction = second_residue_cb.coord - second_residue_ca.coord, ... origin_position = first_residue_ca.coord, ... target_position = second_residue_ca.coord ... ) >>> # The CA and CB coordinates of both residues are now almost equal >>> print(first_residue) A 1 ASN N N -5.549 3.788 -1.125 A 1 ASN CA C -4.923 4.002 -2.452 A 1 ASN C C -3.877 2.949 -2.808 A 1 ASN O O -4.051 2.292 -3.825 A 1 ASN CB C -4.413 5.445 -2.618 A 1 ASN CG C -5.593 6.413 -2.670 A 1 ASN OD1 O -6.738 5.988 -2.651 A 1 ASN ND2 N -5.362 7.711 -2.695 A 1 ASN H1 H -5.854 2.830 -1.023 A 1 ASN H2 H -4.902 4.017 -0.382 A 1 ASN H3 H -6.357 4.397 -1.047 A 1 ASN HA H -5.711 3.870 -3.198 A 1 ASN HB2 H -3.781 5.697 -1.788 A 1 ASN HB3 H -3.860 5.526 -3.556 A 1 ASN HD21 H -4.440 8.115 -2.680 A 1 ASN HD22 H -6.190 8.284 -2.750 >>> print(second_residue) A 2 LEU N N -6.379 4.031 -2.228 A 2 LEU CA C -4.923 4.002 -2.452 A 2 LEU C C -4.136 3.187 -1.404 A 2 LEU O O -3.391 2.274 -1.760 A 2 LEU CB C -4.411 5.450 -2.619 A 2 LEU CG C -4.795 6.450 -1.495 A 2 LEU CD1 C -3.612 6.803 -0.599 A 2 LEU CD2 C -5.351 7.748 -2.084 A 2 LEU H H -6.821 4.923 -2.394 A 2 LEU HA H -4.750 3.494 -3.403 A 2 LEU HB2 H -3.340 5.414 -2.672 A 2 LEU HB3 H -4.813 5.817 -3.564 A 2 LEU HG H -5.568 6.022 -0.858 A 2 LEU HD11 H -3.207 5.905 -0.146 A 2 LEU HD12 H -2.841 7.304 -1.183 A 2 LEU HD13 H -3.929 7.477 0.197 A 2 LEU HD21 H -4.607 8.209 -2.736 A 2 LEU HD22 H -6.255 7.544 -2.657 A 2 LEU HD23 H -5.592 8.445 -1.281
Gallery#
Visualization of Watson-Crick base pairs
Molecular visualization of a small molecule using Matplotlib