Molecule
Details
Base class for all flowerMD molecules, Polymers, and CoPolymers.
- class flowermd.base.molecule.Molecule(num_mols, force_field=None, smiles=None, file=None, compound=None)
Base class for all flowerMD molecules.
The Molecule class generates molecules from the provided input and can be used to initialize a molecular structure. This class also provides information about the molecule topology, such as the number of particles, bonds, angles, etc.
- Parameters:
num_mols (int, required) – Number of molecules to generate.
force_field (flowermd.ForceField or a list of) – hoomd.md.force.Force objects, default=None The forcefield to be applied to the molecule for parameterization. Note that setting force_field does not actually apply the forcefield to the molecule. The forcefield in this step is mainly used for validation purposes.
smiles (str, default None) – The smiles string of the molecule to generate.
file (str, default None) – The file path to the molecule to generate. Supported file types are: .mol2, .pdb, .sdf
compound (mbuild Compound or GMSO Topology, default None) – The mbuild Compound or GMSO Topology of the molecule to generate.
Notes
The molecule can be generated from either a smiles string, a file path, or a mbuild Compound or GMSO Topology.
- coarse_grain(beads=None)
Coarse grain the molecule.
- Parameters:
beads (dict, default None) – A dictionary of bead names and their corresponding SMILES string.
Examples
Coarse grain atomistic benzene molecules into a single bead type called “A”.
>>> from flowermd import Molecule >>> benzene = Molecule(num_mols=10, smiles="c1ccccc1") >>> benzene.coarse_grain(beads={"A": "c1ccccc1"})
Warning
The changes applied by coarse grain are in-place. All molecule properties will be modified after coarse graining based on the bead mapping.
- property mapping
Dictionary of particle index to coarse grained bead mapping.
- property molecules
List of all instances of the molecule.
- property n_bonds
Total number of bonds in all of the molecules.
- property n_particles
Total number of particles in all of the molecules.
- property topology_information
Dictionary of topology information for the molecule.
The dictionary contains the following keys:
particle_types: list of all particle types.
hydrogen_types: list of all hydrogen types.
particle_charge: list of all particle charges.
particle_typeid: list of all particle type indices.
pair_types: list of all unique particle pairs.
bond_types: list of all unique bond types.
angle_types: list of all unique angle types.
dihedral_types: list of all unique dihedral types.
improper_types: list of all unique improper types.
- class flowermd.base.molecule.Polymer(lengths, num_mols, smiles=None, file=None, force_field=None, bond_indices=None, bond_length=None, bond_orientation=None, **kwargs)
Bases:
Molecule
Builds a polymer from a monomer.
- Parameters:
lengths (int, required) – The total number of monomers in each chain.
num_mols (int, required) – Number of chains to generate.
smiles (str, default None) – The smiles string of the monomer to generate.
file (str, default None) – The file path to the monomer to generate.
force_field (flowermd.ForceField or a list of) – hoomd.md.force.Force objects, default=None The forcefield to be applied to the molecule for parameterization. Note that setting force_field does not actually apply the forcefield to the molecule. The forcefield in this step is mainly used for validation purposes.
bond_indices (list, default None) – The indices of the atoms to bond.
bond_length (float, default None) – The bond length between connected atoms (units: nm)
bond_orientation (list, default None) – The orientation of the bond between connected atoms.
- property monomer
The monomer of the polymer.
- class flowermd.base.molecule.CoPolymer(monomer_A, monomer_B, lengths, num_mols, force_field=None, sequence=None, AB_ratio=0.5, seed=24)
Bases:
Molecule
Builds a polymer consisting of two monomer types.
- Parameters:
monomer_A (flowermd.molecules.Polymer, required) – Class of the A-type monomer
monomer_B (flowermd.molecules.Polymer, required) – Class of the B-type monomer
length (int, required) – The total number of monomers in the molecule
num_mols (int, required) – Number of chains to generate.
sequence (str, default None) – Manually define the sequence of ‘A’ and ‘B’ monomers. Leave as None if generating random sequences. Example: sequence = “AABAABAAB”
AB_ratio (float, default 0.50) – The relative weight of A to B monomer types. Used when generating random sequences.
force_field (flowermd.ForceField or a list of) – hoomd.md.force.Force objects, default=None The forcefield to be applied to the molecule for parameterization. Note that setting force_field does not actually apply the forcefield to the molecule. The forcefield in this step is mainly used for validation purposes.
seed (int, default 24) – Set the seed used when generating random sequences
- property A_ratio
The ratio of A monomers to B monomers in the CoPolymer.
- property B_ratio
The ratio of B monomers to A monomers in the CoPolymer.