morfeus.geometry module¶
Help classes and functions related to geometry.
- class morfeus.geometry.Angle(atom_1, atom_2, atom_3)[source]¶
- Bases: - object- Bond internal coordinate. - Code adapted from pyberny: https://github.com/jhrmnn/pyberny. - Parameters:
- atom_1 (int) – Index of atom 1 (1-indexed) 
- atom_2 (int) – Index of atom 2 (1-indexed) 
- atom_3 (int) – Index of atom 3 (1-indexed) 
 
 - i¶
- Index of atom 1 (1-indexed) - Type:
- int 
 
 - j¶
- Index of atom 2 (1-indexed) - Type:
- int 
 
 - k¶
- Index of atom 3 (1-indexed) - Type:
- int 
 
 - get_b_vector(coordinates)[source]¶
- Calculate vector of B matrix for internal coordinate. - Code adapted from pyberny: https://github.com/jhrmnn/pyberny. - Parameters:
- coordinates (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Coordinates (Å) 
- Returns:
- Vector of B matrix (a.u.) 
- Return type:
- b_vector 
 
 
- class morfeus.geometry.Atom(element, coordinates, radius, index)[source]¶
- Bases: - object- Atom common for morfeus calculations. - Parameters:
- element (int) – Atomic number (starting from 1) 
- coordinates (Any) – Coordinates (Å) 
- radius (float) – vdW radius (Å) 
- index (int) – Atom index (starting from 1) 
 
 - accessible_mask¶
- Boolean mask for accessible points - Type:
- Any 
 
 - accessible_points¶
- Points accessible to solvent (Å) - Type:
- Any 
 
 - area¶
- Solvent-accessible surface area (Ų) - Type:
- float 
 
 - cone¶
- Cone tangent to atom - Type:
 
 - coordinates¶
- Coordinates (Å) - Type:
- Any 
 
 - coordination_number¶
- Coordination number - Type:
- float 
 
 - element¶
- Atomic number (1-indexed) - Type:
- int 
 
 - index¶
- Atom index (1-indexed) - Type:
- int 
 
 - invisible_mask¶
- Boolean mask for invisible points - Type:
- Any 
 
 - occluded_mask¶
- Boolean mask for occluded points - Type:
- Any 
 
 - occluded_points¶
- Points occluded by other atoms (Å) - Type:
- Any 
 
 - p_values¶
- P values - Type:
- Any 
 
 - point_areas¶
- Point areas (Ų) - Type:
- Any 
 
 - point_volumes¶
- Point volumes (ų) - Type:
- Any 
 
 - point¶
- Points (Å) 
 - proximal_mask¶
- Boolean mask for proximal points - Type:
- Any 
 
 - radius¶
- vdW radius (Å) - Type:
- float 
 
 - volume¶
- Volume inside solvent-accessible surface area (ų) - Type:
- float 
 
 
- class morfeus.geometry.Bond(atom_1, atom_2)[source]¶
- Bases: - object- Bond internal coordinate. - Parameters:
- atom_1 (int) – Index of atom 1 (1-indexed) 
- atom_2 (int) – Index of atom 2 (1-indexed) 
 
 - i¶
- Index of atom 1 (1-indexed) - Type:
- int 
 
 - j¶
- Index of atom 2 (1-indexed) - Type:
- int 
 
 - get_b_vector(coordinates)[source]¶
- Calculate vector of B matrix for internal coordinate. - Code adapted from pyberny: https://github.com/jhrmnn/pyberny. - Parameters:
- coordinates (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Coordinates (Å) 
- Returns:
- Vector of B matrix (a.u.) 
- Return type:
- b_vector 
 
 
- class morfeus.geometry.Cone(angle, atoms, normal)[source]¶
- Bases: - object- Cone used in cone angle calculations. - Parameters:
- angle (float) – Cone angle (rad) 
- atoms (list[Atom]) – Atoms that are tangent to cone (1-indexed) 
- normal (Any) – Normal vector of cone 
 
 - angle¶
- Cone angle (rad) - Type:
- float 
 
 - atoms¶
- Atoms that are tangent to cone (1-indexed) - Type:
- list[morfeus.geometry.Atom] 
 
 - normal¶
- Normal vector of cone - Type:
- Any 
 
 - is_inside(atom)[source]¶
- Tests if atom lies inside the cone. - Parameters:
- atom (Atom) – Atom to test. 
- Returns:
- True if inside, False if outside. 
- Return type:
- bool 
 
 - is_inside_points(points, method='cross')[source]¶
- Test if points are inside cone of atom. - Parameters:
- points (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Points to check (Å) 
- method (str) – Method for testing: ‘angle’, ‘cross’ or ‘dot’ 
 
- Returns:
- Boolean array with points marked as inside 
- Return type:
- is_inside 
- Raises:
- ValueError – When method not supported 
 
 
- class morfeus.geometry.Dihedral(atom_1, atom_2, atom_3, atom_4)[source]¶
- Bases: - object- Bond internal coordinate. - Code adapted from pyberny: https://github.com/jhrmnn/pyberny. - Parameters:
- atom_1 (int) – Index of atom 1 (1-indexed) 
- atom_2 (int) – Index of atom 2 (1-indexed) 
- atom_3 (int) – Index of atom 3 (1-indexed) 
- atom_4 (int) – Index of atom 4 (1-indexed) 
 
 - i¶
- Index of atom 1 (1-indexed) - Type:
- int 
 
 - j¶
- Index of atom 2 (1-indexed) - Type:
- int 
 
 - k¶
- Index of atom 3 (1-indexed) - Type:
- int 
 
 - l¶
- Index of atom 4 (1-indexed) - Type:
- int 
 
 - get_b_vector(coordinates)[source]¶
- Calculate vector of B matrix for internal coordinate. - Code adapted from pyberny: https://github.com/jhrmnn/pyberny. - Parameters:
- coordinates (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Coordinates (Å) 
- Returns:
- Vector of B matrix (a.u.) 
- Return type:
- b_vector 
 
 
- class morfeus.geometry.InternalCoordinates[source]¶
- Bases: - object- Internal coordinates. - add_angle(atom_1, atom_2, atom_3)[source]¶
- Add angle to internal coordinates. - Parameters:
- atom_1 (int) – Index of atom 1 (1-indexed) 
- atom_2 (int) – Index of atom 2 (1-indexed) 
- atom_3 (int) – Index of atom 3 (1-indexed) 
 
- Return type:
- None 
 
 - add_bond(atom_1, atom_2)[source]¶
- Add bonds to internal coordinates. - Parameters:
- atom_1 (int) – Index of atom 1 (1-indexed) 
- atom_2 (int) – Index of atom 2 (1-indexed) 
 
- Return type:
- None 
 
 - add_dihedral(atom_1, atom_2, atom_3, atom_4)[source]¶
- Add dihedral angle to internal coordinates. - Parameters:
- atom_1 (int) – Index of atom 1 (1-indexed) 
- atom_2 (int) – Index of atom 2 (1-indexed) 
- atom_3 (int) – Index of atom 3 (1-indexed) 
- atom_4 (int) – Index of atom 4 (1-indexed) 
 
- Return type:
- None 
 
 - add_internal_coordinate(atoms)[source]¶
- Add internal coordinate automatically depending on number of atoms. - Parameters:
- atoms (Sequence[int]) – Sequence of atom indices (1-index). 
- Return type:
- None 
 
 - detect_bonds(coordinates, elements, radii=None, radii_type='pyykko', scale_factor=1.2)[source]¶
- Detect bonds based on covalent radii cutoffs. - Parameters:
- coordinates (ArrayLike2D) 
- elements (Iterable[int] | Iterable[str] | None) 
- radii (ArrayLike1D | None) 
- radii_type (str) 
- scale_factor (float) 
 
- Return type:
- None 
 
 - get_B_matrix(coordinates)[source]¶
- Calculate B matrix for coordinates. - Parameters:
- coordinates (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Coordinates (Å) 
- Returns:
- B matrix 
- Return type:
- B_matrix 
 
 
- class morfeus.geometry.Sphere(center, radius, density=0.005, method='fibonacci', filled=False)[source]¶
- Bases: - object- Sphere class for creating and holding points on vdW surface. - Parameters:
- center (Any) – Coordinates for center (Å) 
- density (float) – Area per point (Ų) for empty sphere and volume per point (ų) for filled sphere. 
- filled (bool) – Whether a sphere with internal points should be constructed (works only with method=’projection’) 
- method (str) – Method for generating points: ‘fibonacci’, ‘polar’ or ‘projection’ 
- radius (float) – Radius (Å) 
 
 - area¶
- Area (Ų) - Type:
- float 
 
 - center¶
- Coordinates for sphere center (Å) - Type:
- Any 
 
 - circumference¶
- Circumference (Å) - Type:
- float 
 
 - density¶
- Density of points (Ų or ų) - Type:
- float 
 
 - points¶
- Points in/on sphere (Å) - Type:
- Any 
 
 - radius¶
- Radius (Å) - Type:
- float 
 
 - volume¶
- Volume (ų) - Type:
- float 
 
 
- morfeus.geometry.kabsch_rotation_matrix(P, Q, center=True)[source]¶
- Construct Kabsch rotation matrix. - Constructs the rotation matrix that overlays the points in P with the points in Q with minimum RMSD. https://en.wikipedia.org/wiki/Kabsch_algorithm - Parameters:
- P (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Coordinates to be rotated 
- Q (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Reference coordinates 
- center (bool) – Whether to center P and Q at origin. 
 
- Returns:
- Rotation matrix 
- Return type:
- R 
 
- morfeus.geometry.rotate_coordinates(coordinates, vector, axis)[source]¶
- Rotates coordinates by the rotation that aligns vector with axis. - Parameters:
- axis (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Reference vector to align input vector with 
- coordinates (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Coordinates to rotate 
- vector (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Vector to align 
 
- Returns:
- Rotated coordinates. 
- Return type:
- rotated_coordinates 
 
- morfeus.geometry.sphere_line_intersection(vector, center, radius)[source]¶
- Get points of intersection between line and sphere. - Follows the procedure outlined here: http://paulbourke.net/geometry/circlesphere/. - Parameters:
- vector (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Vector giving direction of line 
- center (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – Center of sphere 
- radius (float) – Radius of sphere 
 
- Returns:
- Intersection points 
- Return type:
- intersection_points