opi.input.structures¶
Modules that hold Python objects representing chemical structures (i.e. atom types and coordinates) and structure files supported by ORCA.
Submodules¶
Classes¶
Class to model singular atom in a structure. |
|
Class to model dummy atom. |
|
Class to model embedding potential |
|
Class to model ghost atom. |
|
Class to model point charge. |
|
Coordinates of an atom in Cartesian space. |
|
Class to model internal structure for ORCA calculations. |
|
Class to model structure file. |
|
Class to model .gzmt structure file. |
|
Class to model .pdb structure file. |
|
Class to model .xyz structure file. |
Package Contents¶
- class opi.input.structures.Atom(element, *args, **kwargs)¶
Bases:
_CoordLineWithElementBase
Class to model singular atom in a structure.
- Parameters:
element (opi.utils.element.Element | str)
args (Any)
kwargs (Any)
- element¶
Specify what element the atom is
- Type:
Element
- Return type:
- coordinates¶
Define coordinates in Cartesian space
- Type:
Coordinates
- Return type:
- fragment_id¶
Define id of fragment
- Type:
int
- Return type:
int | None
- nuclear_charge¶
Define nuclear charge of atom
- Type:
float | int
- Return type:
float | None
- mass¶
Define mass of atom
- Type:
float | int
- Return type:
float | None
- append_str¶
Append an arbitrary string to coordinate line if needed
- Type:
str
- _element: opi.utils.element.Element¶
- property element: opi.utils.element.Element¶
- Return type:
- class opi.input.structures.DummyAtom(*args, **kwargs)¶
Bases:
_CoordLineWithElementBase
Class to model dummy atom.
- Parameters:
args (Any)
kwargs (Any)
- _element: Any | None = 'DA'¶
- class opi.input.structures.EmbeddingPotential(charge, *args, **kwargs)¶
Bases:
_CoordLineWithSymbolAndChargeBase
Class to model embedding potential
- Parameters:
charge (float | int)
args (Any)
kwargs (Any)
- _fmt_element()¶
- Return type:
str
- class opi.input.structures.GhostAtom(element, *args, **kwargs)¶
Bases:
Atom
Class to model ghost atom.
- Parameters:
element (opi.utils.element.Element | str)
args (Any)
kwargs (Any)
- _fmt_element()¶
- Return type:
str
- class opi.input.structures.PointCharge(*args, **kwargs)¶
Bases:
_CoordLineWithSymbolAndChargeBase
Class to model point charge.
- Parameters:
args (Any)
kwargs (Any)
- _element = 'Q'¶
- class opi.input.structures.Coordinates(coordinates)¶
Coordinates of an atom in Cartesian space.
Can be initialized using a tuple, numpy arrays or another instance of Coordinates.
- Parameters:
coordinates (Coordinates | tuple[int | float, int | float, int | float] | npt.NDArray[np.float64])
- coordinates¶
- Type:
Column vector with three rows.
- Return type:
numpy.typing.NDArray[numpy.float64]
- _coordinates: numpy.typing.NDArray[numpy.float64]¶
- property coordinates: numpy.typing.NDArray[numpy.float64]¶
- Return type:
numpy.typing.NDArray[numpy.float64]
- to_list()¶
Returns coordinates as list
- Return type:
list[float] | tuple[]
- property x: numpy.float64¶
x-coordinate
- Return type:
numpy.float64
- property y: numpy.float64¶
y-coordinate
- Return type:
numpy.float64
- property z: numpy.float64¶
z-coordinate
- Return type:
numpy.float64
- class opi.input.structures.Structure(atoms, charge=0, multiplicity=1, origin=None)¶
Class to model internal structure for ORCA calculations.
- Parameters:
atoms (opi.input.structures.atom.Atom | opi.input.structures.atom.DummyAtom | opi.input.structures.atom.EmbeddingPotential | opi.input.structures.atom.GhostAtom | opi.input.structures.atom.PointCharge | Sequence[opi.input.structures.atom.Atom | opi.input.structures.atom.DummyAtom | opi.input.structures.atom.EmbeddingPotential | opi.input.structures.atom.GhostAtom | opi.input.structures.atom.PointCharge] | Iterable[opi.input.structures.atom.Atom | opi.input.structures.atom.DummyAtom | opi.input.structures.atom.EmbeddingPotential | opi.input.structures.atom.GhostAtom | opi.input.structures.atom.PointCharge])
charge (int)
multiplicity (int)
origin (pathlib.Path | str | None)
- atoms¶
Atoms in the molecule
- charge¶
Charge of structure
- Type:
int
- Return type:
int
- multiplicity¶
Multiplicity of structure
- Type:
int
- Return type:
int
- origin¶
Origin of the molecule, usually path to a file or some identifier
- Type:
Path | str
- _atoms: list[opi.input.structures.atom.Atom | opi.input.structures.atom.DummyAtom | opi.input.structures.atom.EmbeddingPotential | opi.input.structures.atom.GhostAtom | opi.input.structures.atom.PointCharge] = []¶
- property atoms: list[opi.input.structures.atom.Atom | opi.input.structures.atom.DummyAtom | opi.input.structures.atom.EmbeddingPotential | opi.input.structures.atom.GhostAtom | opi.input.structures.atom.PointCharge]¶
- _charge: int¶
- property charge: int¶
- Return type:
int
- _multiplicity: int¶
- property multiplicity: int¶
- Return type:
int
- origin: Any | None = None¶
- classmethod combine_molecules(structure1, structure2)¶
function to combine two objects of Molecule class
- format_orca()¶
Returns string representation of Molecule Iteratively calls Atom.format_orca() and compiles it all together to create string representation of Molecule
- Returns:
String representation of Molecule
- Return type:
str
- add_atom(new_atom, position=None)¶
Adds Atom object at specified index. If index is None, Atom object appended to end of list
- Parameters:
new_atom (Atom) -- Atom model to be added to self.atoms
position (int | None, default = None) -- position at which Atom is supposed to be added , default value None
- Raises:
ValueError -- if index is an invalid value
- Return type:
None
- delete_atom(index)¶
Deletes Atom at specified index
- Parameters:
index (int) -- specifies index of Atom to be deleted
- Raises:
ValueError -- if index is invalid value
- Return type:
None
- replace_atom(new_atom, index)¶
replaces Atom at index with a new Atom object
- Parameters:
new_atom (Atom | DummyAtom | EmbeddingPotential | GhostAtom | PointCharge) -- new Atom object to replace the old Atom object
index (int) -- index of Atom to be replaced
- Raises:
ValueError -- if index is invalid value
- Return type:
None
- extract_substructure(indexes)¶
returns Molecule object that is a sub-molecule specified by indexes.
- Parameters:
indexes (list[int]) -- specifies indexes of Atom objects to be extracted
- Returns:
Molecule
- Return type:
new Molecule object
- update_coordinates(array)¶
Validates dimensions of array first replace all coordinates of all atoms in Molecule object. Calls Atom.update_coordinates() iteratively , replacing the Atom.coordinates with rows from array argument
- Parameters:
array (npt.NDArray[np.float64]) -- new coordinates
- Raises:
ValueError -- in the case of wrong dimensions
- Return type:
None
- to_xyz_block()¶
Function to generate XYZ block
- Return type:
str
- classmethod from_xyz(xyzfile, /, *, charge=0, multiplicity=1)¶
Function for reading a xyz file and converting it to a molecular Structure
- Parameters:
xyzfile (Path | str | PathLike[str]) -- Name or path to xyz file
charge (int, default: 0) -- Charge of the molecule
multiplicity (int, default: 1) -- Electron spin multiplicity of the molecule
- Returns:
`Structure`
- Return type:
`Structure object extracted from file
- classmethod from_smiles(smiles, /, *, charge=None, multiplicity=None)¶
Function to read SMILES string and convert string to 3D coordinate structure and create Molecule object with it to store in self.molecule.
- Parameters:
smiles (str) -- SMILES string to be converted
charge (int | None) -- Charge of the molecule, will overwrite charge obtained from SMILES string
multiplicity (int | None) -- Electron spin multiplicity of the molecule, will overwrite multiplicity obtained from SMILES (which is always 1 by default)
- Returns:
`Structure`
- Return type:
`Structure object extracted from file
- Raises:
RuntimeError -- If EmbedMolecule() is unsuccessful
- classmethod from_rdkitmol(mol, /, *, charge=None, multiplicity=None)¶
Function to convert a RDKit Mol object to Structure object
- Parameters:
mol (RdkitMol) -- RDKit Mol object to be converted
charge (int | None) -- Charge of the molecule, will overwrite charge obtained from RDKit Mol
multiplicity (int | None) -- Electron spin multiplicity of the molecule, will overwrite multiplicity obtained from RDKit Mol
- Returns:
`Structure`
- Return type:
Structure object created from information given by RDKit Mol object
- to_rdkitmol(structure, /)¶
Function to convert Molecule object to RDKit Mol object The Structure is converted into XYZ file format, which is then read by RDKit.
- Parameters:
structure (Structure) -- Molecule object to be converted
- Returns:
RdkitMol
- Return type:
RDKit Mol object generated from Structure object
- __len__()¶
- Return type:
int
- class opi.input.structures.BaseStructureFile(file, /, *, charge=0, multiplicity=1)¶
Bases:
abc.ABC
Class to model structure file. The structure file is directly passed to ORCA. This interface not read or modify the contents of the file.
- Parameters:
file (pathlib.Path | str | os.PathLike[str])
charge (int)
multiplicity (int)
- _type¶
Type of the structure file. Use as prefix for ORCA input: *<_type>file
- Type:
str
- _type: str¶
- _file: pathlib.Path¶
- property file: pathlib.Path¶
- Return type:
pathlib.Path
- charge = 0¶
- multiplicity = 1¶
- format_orca(*, full_path=False)¶
Format respectively line in ORCA input.
- Parameters:
full_path (bool, default: False) -- True: Print full path to the structure in the ORCA input file. False: Print only the filename. This is usually the preferred way!
- Return type:
str
- copy_to(dest, /)¶
Copy the structure file to the destination.
- Parameters:
dest (Path) -- Copy the self.file to dest. dest can point to a file or a folder. For details see documentation of shutil.copy().
- Raises:
OSError -- If structure file cannot be copied.
- Returns:
True if the file was copied, False otherwise.
- Return type:
bool
- class opi.input.structures.GzmtFile(file, /, *, charge=0, multiplicity=1)¶
Bases:
BaseStructureFile
Class to model .gzmt structure file.
- Parameters:
file (pathlib.Path | str | os.PathLike[str])
charge (int)
multiplicity (int)
- _type = 'gzmt'¶
- class opi.input.structures.PdbFile(file, /, *, charge=0, multiplicity=1)¶
Bases:
BaseStructureFile
Class to model .pdb structure file.
- Parameters:
file (pathlib.Path | str | os.PathLike[str])
charge (int)
multiplicity (int)
- _type = 'pdb'¶
- class opi.input.structures.XyzFile(file, /, *, charge=0, multiplicity=1)¶
Bases:
BaseStructureFile
Class to model .xyz structure file.
- Parameters:
file (pathlib.Path | str | os.PathLike[str])
charge (int)
multiplicity (int)
- _type = 'xyz'¶