pylift.builder ============== .. py:module:: pylift.builder .. autoapi-nested-parse:: pylift.builder License: The MIT License (MIT) Copyright 2025 Brandon C. Tapia Functions --------- .. autoapisummary:: pylift.builder.convert_to_pseudo pylift.builder.types_to_names pylift.builder.remove_h_old pylift.builder.remove_h pylift.builder.assign_linkers pylift.builder.adjust_charges pylift.builder.distribute_charges pylift.builder.add_ff_params Module Contents --------------- .. py:function:: convert_to_pseudo(mol2_dict: dict, h_identifiers: Optional[list[str]] = ['h', 'H']) -> dict 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) :param mol2_dict: contains molecule information generated with PyLIFT.reader.read_mol2 :type mol2_dict: dict :param h_identifiers: contains all identifiers hydrogen atoms may be referenced as :type h_identifiers: list[str] :returns: mol2_dict similar dictionary .. py:function:: types_to_names(mol2_dict: dict) -> dict 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. :param mol2_dict: contains molecule information generated with PyLIFT.reader.read_mol2 :type mol2_dict: dict :returns: mol2_dict similar dictionary .. py:function:: remove_h_old(mol2_dict: dict, specific_atoms: Optional[list[int]] = None, num_delete: Optional[list[int]] = None, charge_distribution: Optional[str] = 'heavy', h_identifiers: list[str] = ['h', 'H']) 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) :param mol2_dict: contains molecule information generated with PyLIFT.reader.read_mol2 :type mol2_dict: dict :param specific_atoms: if specified, heavy atoms to remove hydrogens from. If None, all hydrogens removed :type specific_atoms: list[int] :param charge_distribution: 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 :type charge_distribution: str :param h_identifiers: contains all identifiers hydrogen atom types may start with :type h_identifiers: list[str] :param num_delete: if specific_atoms is specified, num_delete specifies the number of hydrogens to remove from each specified atom :type num_delete: list[int] :returns: mol2_dict similar dictionary .. py:function:: remove_h(mol2_dict: dict, specific_atoms: Optional[list[int]] = None, num_delete: Optional[list[int]] = None, charge_distribution: Optional[str] = 'heavy', h_identifiers: list[str] = ['h', 'H']) 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) :param mol2_dict: contains molecule information generated with PyLIFT.reader.read_mol2 :type mol2_dict: dict :param specific_atoms: if specified, heavy atoms to remove hydrogens from. If None, all hydrogens removed :type specific_atoms: list[int] :param charge_distribution: 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 :type charge_distribution: str :param h_identifiers: contains all identifiers hydrogen atom types may start with :type h_identifiers: list[str] :param num_delete: if specific_atoms is specified, num_delete specifies the number of hydrogens to remove from each specified atom :type num_delete: list[int] :returns: mol2_dict similar dictionary .. py:function:: assign_linkers(mol2_dict: dict, linker_atoms: list[int], linker_identifier: str = 'L') pylift.builder.assign_linkers Adds an identifier to specific atoms to prepare them for linking in Polymatic :param mol2_dict: contains molecule information generated with PyLIFT.reader.read_mol2 :type mol2_dict: dict :param linker_atoms: id of atoms to assign identifier to :type linker_atoms: list[int] :param linker_identifier: what the identifier is :type linker_identifier: str :returns: mol2_dict similar dictionary .. py:function:: adjust_charges(monomer_dict: dict, xmer_dict: dict, monomer_atoms: list[int], xmer_atoms: list[int], charge_distribution=None, forced_charge: Optional[float] = float(0), verbose: Optional[bool] = True) -> dict 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 :param monomer_dict: monomer read in through reader.read_mol2 :type monomer_dict: dict :param xmer_dict: xmer read in through reader.read_mol2 :type xmer_dict: dict :param monomer_atoms: atoms where charge will be adjusted in monomer_dict :type monomer_atoms: list[int] :param dimer_atoms: atoms where charge will be read from in xmer_dict :type dimer_atoms: list[int] :param forced_charge: 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 :type forced_charge: float :returns: monomer_dict similar dictionary .. py:function:: distribute_charges(monomer_dict) .. py:function:: add_ff_params(lammps_dict: dict, ff_dict: dict, missing_ff_params: dict, pseudoatoms: bool, approx_match: bool = True, user_match: Optional[dict[str]] = None, verbose: Optional[bool] = True) pylift.builder.add_ff_params Adds forcefield parameters from a specified forcefield to pair, bond, angle, dihedral, and improper topology information :param lammps_dict: contains skeleton topology for molecule :type lammps_dict: dict :param ff_dict: contains forcefield to apply :type ff_dict: dict :param missing_ff_params: contains FRCMOD information :type missing_ff_params: dict :param pseudoatoms: whether the simulation is all-atom (False) or united-atom (True) :type pseudoatoms: bool :param approx_match: 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) :type approx_match: bool :param user_match: 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) :type user_match: dict[str] :returns: lammps_dict like dictionary with forcefield parameters :rtype: dict