ipsuite.configuration_generation package

Submodules

ipsuite.configuration_generation.packmol module

Use packmole to create a periodic box

class ipsuite.configuration_generation.packmol.MultiPackmol(*args, **kwargs)[source]

Bases: Packmol

Create multiple configurations with packmol.

This Node generates multiple configurations with packmol. This is best used in conjunction with Smiles2Conformers:

Attributes

n_configurationsint

Number of configurations to create.

seedint

Seed for the random number generator.

Notes

Output structures should be relaxed before further use.

Example

>>> import ipsuite as ips
>>> project = ips.Project()
>>> with project:
...     bf4 = ips.Smiles2Conformers(
...         smiles='[B-](F)(F)(F)F', numConfs=10
...     )
...     bmim = ips.Smiles2Conformers(
...         smiles='CCCCN1C=C[N+](=C1)C',
...         numConfs=10
...     )
...     molecules = ips.MultiPackmol(
...         data=[bf4.frames, bmim.frames],
...         count=[1, 1], density=1210, n_configurations=10
...     )
...     box = ips.MultiPackmol(
...         data=[molecules.frames], count=[10], density=1210, n_configurations=1
...     )
>>> project.build()
count: list
data: list[list[ase.Atoms]]
density: float
n_configurations: int
run()[source]
seed: int = 42
class ipsuite.configuration_generation.packmol.Packmol(*args, **kwargs)[source]

Bases: IPSNode

Create a box with packmol.

Attributes

data: list[list[ase.Atoms]]

For each entry in the list the last ase.Atoms object is used to create the new structure.

data_ids: list[int]

The id of the data to use for each entry in data. If None the last entry. Has to be the same length as data. data: [[A], [B]], [-1, 3] -> [A[-1], B[3]]

count: list[int]

Number of molecules to add for each entry in data.

tolerancefloat

Tolerance for the distance of atoms in angstrom.

densityfloat

Density of the system in kg/m^3. Either density or box is required.

pbcbool

If True the periodic boundary conditions are set for the generated structure and the box used by packmol is scaled by the tolerance, to avoid overlapping atoms with periodic boundary conditions.

Notes

Output structures should be relaxed before further use.

count: list
data: list[list[Atoms]]
data_ids: list[int] = None
density: float
property frames: list[Atoms]
frames_path: Path = PosixPath('$nwd$/frames.h5')
pbc: bool = True
run()[source]
tolerance: float = 2.0

ipsuite.configuration_generation.smiles_to_atoms module

class ipsuite.configuration_generation.smiles_to_atoms.Smiles2Atoms(*, name: str | None = None, always_changed: bool = False, smiles: str, seed: int = 1234, frames_path: pathlib.Path = PosixPath('$nwd$/frames.h5'), molecule_image_path: pathlib.Path = PosixPath('$nwd$/molecule.png'))[source]

Bases: IPSNode

property frames: list[Atoms]
frames_path: Path = PosixPath('$nwd$/frames.h5')
molecule_image_path: Path = PosixPath('$nwd$/molecule.png')
run()[source]
seed: int = 1234
smiles: str
class ipsuite.configuration_generation.smiles_to_atoms.Smiles2Conformers(*args, **kwargs)[source]

Bases: IPSNode

Generate molecular conformers from a SMILES string.

Attributes

smilesstr

The SMILES string representing the molecule.

numConfsint

The number of conformers to generate.

seedint, optional

Random seed for conformer generation (default is 42).

maxAttemptsint, optional

Maximum number of attempts to generate conformers (default is 1000).

Methods

frameslist of ase.Atoms

Property to load and return the generated conformers as a list of ASE Atoms.

Notes

Instead of creating one composite smile like [B-](F)(F)(F)F.CCCCN1C=C[N+](=C1)C create two molecules and use MultiPackmol to generate the single molecule. This will avoid overlapping structures.

Examples

>>> with project:
...     methanol_conformers = ips.Smiles2Conformers(smiles="CO", numConfs=5)
>>> project.repro()
>>> frames = methanol_conformers.frames
>>> print(f"Generated {len(frames)} conformers.")
Generated 5 conformers.
property frames: list[Atoms]
frames_path: Path = PosixPath('$nwd$/frames.h5')
maxAttempts: int = 1000
molecule_image_path: Path = PosixPath('$nwd$/molecule.png')
numConfs: int
run()[source]
seed: int = 42
smiles: str

Module contents

Module for generating new configurations based on smiles.

class ipsuite.configuration_generation.MultiPackmol(*args, **kwargs)[source]

Bases: Packmol

Create multiple configurations with packmol.

This Node generates multiple configurations with packmol. This is best used in conjunction with Smiles2Conformers:

Attributes

n_configurationsint

Number of configurations to create.

seedint

Seed for the random number generator.

Notes

Output structures should be relaxed before further use.

Example

>>> import ipsuite as ips
>>> project = ips.Project()
>>> with project:
...     bf4 = ips.Smiles2Conformers(
...         smiles='[B-](F)(F)(F)F', numConfs=10
...     )
...     bmim = ips.Smiles2Conformers(
...         smiles='CCCCN1C=C[N+](=C1)C',
...         numConfs=10
...     )
...     molecules = ips.MultiPackmol(
...         data=[bf4.frames, bmim.frames],
...         count=[1, 1], density=1210, n_configurations=10
...     )
...     box = ips.MultiPackmol(
...         data=[molecules.frames], count=[10], density=1210, n_configurations=1
...     )
>>> project.build()
count: list
data: list[list[ase.Atoms]]
density: float
n_configurations: int
run()[source]
seed: int = 42
class ipsuite.configuration_generation.Packmol(*args, **kwargs)[source]

Bases: IPSNode

Create a box with packmol.

Attributes

data: list[list[ase.Atoms]]

For each entry in the list the last ase.Atoms object is used to create the new structure.

data_ids: list[int]

The id of the data to use for each entry in data. If None the last entry. Has to be the same length as data. data: [[A], [B]], [-1, 3] -> [A[-1], B[3]]

count: list[int]

Number of molecules to add for each entry in data.

tolerancefloat

Tolerance for the distance of atoms in angstrom.

densityfloat

Density of the system in kg/m^3. Either density or box is required.

pbcbool

If True the periodic boundary conditions are set for the generated structure and the box used by packmol is scaled by the tolerance, to avoid overlapping atoms with periodic boundary conditions.

Notes

Output structures should be relaxed before further use.

count: list
data: list[list[Atoms]]
data_ids: list[int] = None
density: float
property frames: list[Atoms]
frames_path: Path = PosixPath('$nwd$/frames.h5')
pbc: bool = True
run()[source]
tolerance: float = 2.0
class ipsuite.configuration_generation.Smiles2Atoms(*, name: str | None = None, always_changed: bool = False, smiles: str, seed: int = 1234, frames_path: pathlib.Path = PosixPath('$nwd$/frames.h5'), molecule_image_path: pathlib.Path = PosixPath('$nwd$/molecule.png'))[source]

Bases: IPSNode

property frames: list[Atoms]
frames_path: Path = PosixPath('$nwd$/frames.h5')
molecule_image_path: Path = PosixPath('$nwd$/molecule.png')
run()[source]
seed: int = 1234
smiles: str
class ipsuite.configuration_generation.Smiles2Conformers(*args, **kwargs)[source]

Bases: IPSNode

Generate molecular conformers from a SMILES string.

Attributes

smilesstr

The SMILES string representing the molecule.

numConfsint

The number of conformers to generate.

seedint, optional

Random seed for conformer generation (default is 42).

maxAttemptsint, optional

Maximum number of attempts to generate conformers (default is 1000).

Methods

frameslist of ase.Atoms

Property to load and return the generated conformers as a list of ASE Atoms.

Notes

Instead of creating one composite smile like [B-](F)(F)(F)F.CCCCN1C=C[N+](=C1)C create two molecules and use MultiPackmol to generate the single molecule. This will avoid overlapping structures.

Examples

>>> with project:
...     methanol_conformers = ips.Smiles2Conformers(smiles="CO", numConfs=5)
>>> project.repro()
>>> frames = methanol_conformers.frames
>>> print(f"Generated {len(frames)} conformers.")
Generated 5 conformers.
property frames: list[Atoms]
frames_path: Path = PosixPath('$nwd$/frames.h5')
maxAttempts: int = 1000
molecule_image_path: Path = PosixPath('$nwd$/molecule.png')
numConfs: int
run()[source]
seed: int = 42
smiles: str
class ipsuite.configuration_generation.Smiles2Gromacs(*args, **kwargs)[source]

Bases: IPSNode

Gromacs Node.

Attributes

smiles: list[str]

List of SMILES strings for the molecules to be packed.

count: list[int]

Number of each molecule to pack.

labels: list[str]

List of 3-letter labels for each molecule.

density: float

Density of the packed box in g/cm^3.

mdp_files: list[str | pathlib.Path]

List of paths to the Gromacs MDP files.

config_files: list[str | pathlib.Path]

Same like mdp_files but in the json or yaml format. These will run BEFORE the MDP files.

itp_files: list[str | None]|None

if given, for each label either the path to the ITP file or None. The order must match the order of the labels.

pdb_files: list[str | pathlib.Path]|None

if given, for each label either the path to the PDB file or None. The order must match the order of the labels.

production_indices: list[int]|None

The gromacs runs that should be stored in the trajectory file. If None, the last run is stored. The order is always the same as the order of the MDP files.

Installation

To install the required software, run the following commands:

conda install conda-forge::gromacs
conda install conda-forge::acpype
pip install MDAnalysis pyedr
cleanup: bool = True
config_files: Sequence[str | Path]
count: list[int]
density: float
property frames: list[Atoms]
fudgeLJ: float = 1.0
fudgeQQ: float = 1.0
itp_files: Sequence[str | Path | None]
labels: list[str]
maxwarn: int = 0
mdp_files: Sequence[str | Path]
output_dir: Path = PosixPath('$nwd$/gromacs')
pdb_files: Sequence[str | Path | None]
production_indices: list[int] = None
run()[source]
smiles: list[str]
tolerance: float = 2.0
traj_file: list[Atoms] = PosixPath('$nwd$/structures.h5')