pylift.builder

pylift.builder

License: The MIT License (MIT)

Copyright 2025 Brandon C. Tapia

Functions

convert_to_pseudo(→ dict)

pylift.builder.convert_to_pseudo

types_to_names(→ dict)

pylift.builder.types_to_names

remove_h_old(mol2_dict[, specific_atoms, num_delete, ...])

pylift.builder.remove_h

remove_h(mol2_dict[, specific_atoms, num_delete, ...])

pylift.builder.remove_h

assign_linkers(mol2_dict, linker_atoms[, ...])

pylift.builder.assign_linkers

adjust_charges(, verbose)

pylift.builder.adjust_charges

distribute_charges(monomer_dict)

add_ff_params(lammps_dict, ff_dict, missing_ff_params, ...)

pylift.builder.add_ff_params

Module Contents

pylift.builder.convert_to_pseudo(mol2_dict: dict, h_identifiers: list[str] | None = ['h', 'H']) dict[source]

pylift.builder.convert_to_pseudo

Converts all-atom molecules type names to be able to identify united-atom molecules. Atom types are updated by appending the number of hydrogens onto the end (e.g., a c3 gaff2 type is retyped as c33 if it is connected to three hydrogens)

Parameters:
  • mol2_dict (dict) – contains molecule information generated with PyLIFT.reader.read_mol2

  • h_identifiers (list[str]) – contains all identifiers hydrogen atoms may be referenced as

Returns:

mol2_dict similar dictionary

pylift.builder.types_to_names(mol2_dict: dict) dict[source]

pylift.builder.types_to_names

Mol2 files have unique columns for atom types and atom names. This function copies the forcefield descriptive atom types to the atom names as TopoTools uses atom names to generate LAMMPS skeleton files.

Parameters:

mol2_dict (dict) – contains molecule information generated with PyLIFT.reader.read_mol2

Returns:

mol2_dict similar dictionary

pylift.builder.remove_h_old(mol2_dict: dict, specific_atoms: list[int] | None = None, num_delete: list[int] | None = None, charge_distribution: str | None = 'heavy', h_identifiers: list[str] = ['h', 'H'])[source]

pylift.builder.remove_h

Removes hydrogen atoms. If specific_atoms is not specified, all hydrogens are removed. If specific_atoms is specified:

num_delete[i] amount of hydrogens removed from specific_atoms[i] len(num_delete) therefore must equal len(specific_atoms)

Parameters:
  • mol2_dict (dict) – contains molecule information generated with PyLIFT.reader.read_mol2

  • specific_atoms (list[int]) – if specified, heavy atoms to remove hydrogens from. If None, all hydrogens removed

  • charge_distribution (str) –

    method to distribute the charge of removed hydrogens Options: ‘heavy’, ‘uniform’, None ‘heavy’: Charge from removed hydrogens is consolidated into the corresponding heavy atom

    recommended if specific_atoms = None or if adjust_polymer_charges will be used

    ’uniform’: Charge from removed hydrogens is distributed across all remaining atoms

    recommended if specific_atoms != None and adjust_polymer_charges will not be used

    None: charge is not adjusted (will lead to a molecule with a different overall charge)

    not recommended

  • h_identifiers (list[str]) – contains all identifiers hydrogen atom types may start with

  • num_delete (list[int]) – if specific_atoms is specified, num_delete specifies the number of hydrogens to remove from each specified atom

Returns:

mol2_dict similar dictionary

pylift.builder.remove_h(mol2_dict: dict, specific_atoms: list[int] | None = None, num_delete: list[int] | None = None, charge_distribution: str | None = 'heavy', h_identifiers: list[str] = ['h', 'H'])[source]

pylift.builder.remove_h

Removes hydrogen atoms. If specific_atoms is not specified, all hydrogens are removed. If specific_atoms is specified:

num_delete[i] amount of hydrogens removed from specific_atoms[i] len(num_delete) therefore must equal len(specific_atoms)

Parameters:
  • mol2_dict (dict) – contains molecule information generated with PyLIFT.reader.read_mol2

  • specific_atoms (list[int]) – if specified, heavy atoms to remove hydrogens from. If None, all hydrogens removed

  • charge_distribution (str) –

    method to distribute the charge of removed hydrogens Options: ‘heavy’, ‘uniform’, None ‘heavy’: Charge from removed hydrogens is consolidated into the corresponding heavy atom

    recommended if specific_atoms = None or if adjust_polymer_charges will be used

    ’uniform’: Charge from removed hydrogens is distributed across all remaining atoms

    recommended if specific_atoms != None and adjust_polymer_charges will not be used

    None: charge is not adjusted (will lead to a molecule with a different overall charge)

    not recommended

  • h_identifiers (list[str]) – contains all identifiers hydrogen atom types may start with

  • num_delete (list[int]) – if specific_atoms is specified, num_delete specifies the number of hydrogens to remove from each specified atom

Returns:

mol2_dict similar dictionary

pylift.builder.assign_linkers(mol2_dict: dict, linker_atoms: list[int], linker_identifier: str = 'L')[source]

pylift.builder.assign_linkers

Adds an identifier to specific atoms to prepare them for linking in Polymatic

Parameters:
  • mol2_dict (dict) – contains molecule information generated with PyLIFT.reader.read_mol2

  • linker_atoms (list[int]) – id of atoms to assign identifier to

  • linker_identifier (str) – what the identifier is

Returns:

mol2_dict similar dictionary

pylift.builder.adjust_charges(monomer_dict: dict, xmer_dict: dict, monomer_atoms: list[int], xmer_atoms: list[int], charge_distribution=None, forced_charge: float | None = float(0), verbose: bool | None = True) dict[source]

pylift.builder.adjust_charges

Adjust charge on atoms involved/near to linkers by using an xmer (e.g., dimer) for some charges

(e.g., adjust the charges on the heavy atoms involved in polymerization as well as the hydrogens attached)

Any charge discrpency is uniformly distributed across all atoms

such that overall_charge = forced_charge

Parameters:
  • monomer_dict (dict) – monomer read in through reader.read_mol2

  • xmer_dict (dict) – xmer read in through reader.read_mol2

  • monomer_atoms (list[int]) – atoms where charge will be adjusted in monomer_dict

  • dimer_atoms (list[int]) – atoms where charge will be read from in xmer_dict

  • forced_charge (float) – overall monomer charge after adjusting polymer charges. Charge is uniformly distributed across all atoms including monomer_atoms If forced_charge=None, forced_charge is the overall_charge existing prior to adjustments

Returns:

monomer_dict similar dictionary

pylift.builder.distribute_charges(monomer_dict)[source]
pylift.builder.add_ff_params(lammps_dict: dict, ff_dict: dict, missing_ff_params: dict, pseudoatoms: bool, approx_match: bool = True, user_match: dict[str] | None = None, verbose: bool | None = True)[source]

pylift.builder.add_ff_params

Adds forcefield parameters from a specified forcefield to pair, bond, angle, dihedral, and improper topology information

Parameters:
  • lammps_dict (dict) – contains skeleton topology for molecule

  • ff_dict (dict) – contains forcefield to apply

  • missing_ff_params (dict) – contains FRCMOD information

  • pseudoatoms (bool) – whether the simulation is all-atom (False) or united-atom (True)

  • approx_match (bool) – whether only exact matches to forcefield types should be found (e.g., if approx_match = True then c3-c3-ca-c3 would first look for parameters for c3-c3-ca-c3 and if not found, then X-c3-ca-X)

  • user_match (dict[str]) – contains a dictionary of current atoms (key) to atom to search for instead (value) (e.g., if {‘c3’, ‘cy’} is specified then X-c3-cy-X would first look for parameters for X-c3-cy-X and if not found, then X-c3-c3-X)

Returns:

lammps_dict like dictionary with forcefield parameters

Return type:

dict