API Reference
Geometry
The model at the center of the package, and selecting or combining its atoms
- Geometry
-
Molecular geometry.
- select_atoms()
-
Select a subset of atoms.
- remove_atoms()
-
Remove a subset of atoms.
- join()
-
Join geometries into one.
Geometry Methods
Methods for the Geometry class
- Geometry.__eq__()
-
Compare geometries field by field, including exact coordinates.
- Geometry.__repr__()
-
Render the geometry as an xyz block.
- Geometry.atom_count
-
Number of atoms.
- Geometry.masses
-
Atomic masses.
- Geometry.atomic_numbers
-
Atomic numbers.
- Geometry.covalent_radii
-
Pyykko covalent radii, in Angstroms.
- Geometry.valences
-
Numbers of valence electrons.
- Geometry.xyz_block()
-
Format the geometry as an xyz block (see
xyz_block). - Geometry.xyz_file()
-
Write the geometry to an xyz file (see
xyz_file). - Geometry.from_xyz_block()
-
Parse a geometry from an xyz block (see
from_xyz_block). - Geometry.from_xyz_file()
-
Read a geometry from an xyz file (see
from_xyz_file). - Geometry.relabel_atoms()
-
Reorder the atoms.
XYZ files
Reading and writing single- and multi-frame xyz
- xyz_block()
-
Format a geometry as an xyz block.
- from_xyz_block()
-
Parse a geometry from a single-frame xyz block.
- xyz_file()
-
Write a geometry to an xyz file.
- from_xyz_file()
-
Read a geometry from an xyz file (see
from_xyz_block). - xyz_trajectory_block()
-
Format geometries as a multi-frame xyz block, one frame per geometry.
- from_xyz_trajectory_block()
-
Parse geometries from a multi-frame xyz block, e.g. a list of conformers.
- xyz_trajectory_file()
-
Write geometries to a multi-frame xyz file (see
xyz_trajectory_block). - from_xyz_trajectory_file()
-
Read geometries from a multi-frame xyz file (see
from_xyz_trajectory_block). - xyz_trajectory_comments()
-
Get the comment line of each frame of a multi-frame xyz block.
Properties and measurements
Quantities computed from the coordinates
- center_of_mass()
-
Calculate the center of mass.
- inertia_tensor()
-
Calculate the inertia tensor about the center of mass.
- principal_axes()
-
Calculate the principal moments and axes of inertia.
- distance_matrix()
-
Calculate the interatomic distance matrix.
- adjacency_matrix()
-
Determine connectivity from covalent radii.
- distance_keys()
-
Build a sorted distance descriptor.
- distance()
-
Measure the distance between two atoms.
- angle()
-
Measure the angle between three atoms.
- dihedral()
-
Measure the dihedral angle between four atoms.
- bonds()
-
List bond distances.
- angles()
-
List bond angles.
- dihedrals()
-
List dihedral angles.
Transformations
Moving atoms, and the rotations that align geometries
- translate()
-
Translate a geometry.
- rotate()
-
Rotate a geometry about a point.
- reflect()
-
Reflect a geometry across a plane.
- center()
-
Translate a geometry so that its center of mass is at the origin.
- twist()
-
Rotate a group about a bond, e.g. a methyl or amine group.
- twist_angle()
-
Find the twist about a bond that turns one direction onto another.
- alignment_rotation()
-
Find the rotation that best aligns a reference geometry onto a geometry.
- axis_alignment_rotation()
-
Find the smallest rotation pointing the vector between two atoms along an axis.
- inertial_frame_rotation()
-
Find the rotation into the principal axis frame.
Conversions
InChI, SMILES, formulas, and RDKit molecules
- inchi()
-
Generate the standard InChI string of a geometry with RDKit.
- from_inchi()
-
Embed a geometry for an InChI string with RDKit.
- smiles()
-
Generate the canonical SMILES string of a geometry with RDKit.
- from_smiles()
-
Embed a geometry for a SMILES string with RDKit.
- formula()
-
Generate the molecular formula of a geometry in Hill order.
- rdkit_mol()
-
Convert a geometry to an RDKit molecule.
- from_rdkit_mol()
-
Convert an RDKit molecule to a geometry, embedding coordinates if missing.
Visualization
Interactive views and rendered images
- View
-
A
py3Dmol.viewwith helpers for geometries and arrows. - view()
-
Display a geometry with py3Dmol.
- render_svg()
-
Render a geometry as an SVG image with xyzrender.
- render_gif()
-
Render a geometry rotating about an axis as a GIF with xyzrender.
Exceptions and units
Errors raised by the package, and its unit registry
- GeometryConversionError
-
A geometry could not be converted to or from another representation.
- XYZFormatError
-
An xyz block could not be parsed.
- ElementNotFoundError
-
No element matches the given atomic number or symbol.
- ureg
-
Shared
pintunit registry, e.g. for coordinates with units (ureg.bohr).
RDKit molecules
autogeom.rd: functions on RDKit Mol objects, which never see a Geometry
- rd.from_smiles()
-
Parse a SMILES string.
- rd.smiles()
-
Write a canonical, non-isomeric SMILES string.
- rd.from_inchi()
-
Parse an InChI string.
- rd.inchi()
-
Write a standard InChI string.
- rd.from_xyz_block()
-
Parse an xyz block, determining connectivity (but not bond orders).
- rd.xyz_block()
-
Write an xyz block.
- rd.symbols()
-
Get the atomic symbols.
- rd.coordinates()
-
Get the atomic coordinates.
- rd.charge()
-
Get the total formal charge.
- rd.spin()
-
Get the number of unpaired electrons.
- rd.has_coordinates()
-
Check whether the molecule has a conformer.
- rd.set_coordinates()
-
Set the atomic coordinates, replacing any existing conformers.
- rd.add_coordinates()
-
Embed 3D coordinates if the molecule has none.
- rd.add_atom_numbers()
-
Label atoms for drawing as
f"{symbol}{number}". - rd.canonical_ranks()
-
Rank atoms canonically.
- rd.assign_stereochemistry()
-
Assign stereochemistry from the 3D coordinates.
- rd.chiral_centers()
-
Find chiral centers and their R/S labels.
- rd.max_bond_count()
-
Get the maximum number of bonds to an atom.
- rd.from_connectivity()
-
Build a molecule from connectivity, perceiving its Lewis structure.
- rd.EMBED_SEED
-
Default random seed for coordinate embedding, for reproducible geometries.
Elements
autogeom.element: periodic table data, looked up by atomic number or symbol
- element.Element
-
Chemical element.
- element.from_key()
-
Look up an element.
- element.number()
-
Get the atomic number.
- element.mass_number()
-
Get the mass number.
- element.symbol()
-
Get the canonical symbol, e.g.
"Cl"for"cl"or17. - element.mass()
-
Get the atomic mass.
- element.covalent_radius()
-
Get the Pyykko covalent radius.
- element.group()
-
Get the group number.
- element.period()
-
Get the period number.
- element.electronegativity()
-
Get the Pauling electronegativity.
- element.is_metal()
-
Check whether an element is a metal.
- element.shell_capacity()
-
Get the valence shell capacity of the element’s period.
- element.valence()
-
Get the number of valence electrons.
- element.bonding_capacity()
-
Get the bonding capacity,
min(valence, shell_capacity - valence).
Types
autogeom.types: array types and Pydantic fields
- types.FloatArray
- types.FloatArrayField
-
Float array field, serialized as nested lists.
- types.CoordinatesField
-
(N, 3)coordinates field in Angstroms;pintquantities are converted.