spyrmsd.utils module

spyrmsd.utils.center(coordinates: ndarray) ndarray[source]

Center coordinates.

Parameters:

coordinates (np.ndarray) – Coordinates

Returns:

Centred coordinates

Return type:

np.ndarray

spyrmsd.utils.center_of_geometry(coordinates: ndarray) ndarray[source]

Center of geometry.

Parameters:

coordinates (np.ndarray) – Coordinates

Returns:

Center of geometry

Return type:

np.ndarray

spyrmsd.utils.deg_to_rad(angle: float) float[source]

Convert angle in degrees to angle in radians.

Parameters:

angle (float) – Angle (in degrees)

Returns:

Angle (in radians)

Return type:

float

spyrmsd.utils.format(fname: str) str[source]

Extract format extension from file name.

Parameters:

fname (str) – File name

Returns:

File extension

Return type:

str

Notes

The file extension is returned without the . character, i.e. for the file path/filename.ext the string ext is returned.

If a file is compressed, the .gz extension is ignored.

spyrmsd.utils.molformat(fname: str) str[source]

Extract an OpenBabel-friendly format from file name.

Parameters:

fname (str) – File name

Returns:

File extension in an OpenBabel-friendly format

Return type:

str

Notes

File types in OpenBabel do not always correspond to the file extension. This function converts the file extension to an OpenBabel file type.

The following table shows the different conversions performed by this function:

Extension

File Type

xyz

XYZ

spyrmsd.utils.rotate(v: ndarray, angle: float, axis: ndarray, units: str = 'rad') ndarray[source]

Rotate vector.

Parameters:
  • v (numpy.array) – 3D vector to be rotated

  • angle (float) – Angle of rotation (in units)

  • axis (numpy.array) – 3D axis of rotation

  • units ({“rad”, “deg”}) – Units of angle (in radians rad or degrees deg)

Returns:

Rotated vector

Return type:

numpy.array

Raises:
  • AssertionError – If the axis of rotation is not a 3D vector

  • ValueError – If units is not rad or deg