pylift package
Submodules
pylift.builder module
pylift.builder
License: The MIT License (MIT)
Copyright 2025 Brandon C. Tapia
- 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]
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
- 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 = 0.0, verbose: bool | None = True) dict[source]
- 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.assign_linkers(mol2_dict: dict, linker_atoms: list[int], linker_identifier: str = 'L')[source]
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.convert_to_pseudo(mol2_dict: dict, h_identifiers: list[str] | None = ['h', 'H']) dict[source]
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.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]
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_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.types_to_names(mol2_dict: dict) dict[source]
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.reader module
pylift.reader module
License: The MIT License (MIT)
Copyright (c) 2024 Brandon C. Tapia
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- pylift.reader.read_frcmod(frcmod_file: str, out_json: str | None = None) dict[source]
Read in a FRCMOD file from the AmberTools prmchk or prmchk2 utilities.
- Parameters:
frcmod_file (str) – name of the FRCMOD file
out_json (str) – name of the FRCMOD information translated to a PyLIFT-readable JSON file
- Returns:
FRCMOD file contents in a PyLIFT-readable dictionary
- Return type:
dict
- pylift.reader.read_gaff2(gaff2_in: str | None = 'gaff2.dat', default_loc=True, out_json: str | None = None, verbose: bool | None = True) dict[source]
Read in a GAFF2 molecule file.
- Parameters:
gaff2_in (str) – gaff2 filename if default_loc=True, or gaff2 filepath otherwise
default_loc (bool) – if GAFF2 file can be found in default Amber location: ~/amber24/dat/leap/parm/
out_json (str) – name of the GAFF2 information translated to a PyLIFT-readable JSON file
verbose (bool) – Print out optional information
- Returns:
GAFF2 information translated to a PyLIFT-readable dictionary
- Return type:
dict
- pylift.reader.read_mol2(mol2_in: str, out_json: str | None = None) dict[source]
Extracts all information from a provided mol2 file
- Parameters:
mol2_in (str) – mol2 input file
out_json (str) – JSON file with mol2 information in PyLIFT-parsable dictionary
- Returns:
mol2 information in PyLIFT-parsable dictionary
- Return type:
dict
- pylift.reader.read_topo(topo_in: str = 'topo.tmp.lmps', linker_identifier: str | None = 'L', pseudoatoms: str = None, out_json: str | None = None) dict[source]
Extracts information from a skeleton LAMMPS output file provided from the TopoTools program
- Parameters:
topo_in (str) – input LAMMPS file from TopoTools
linker_identifier – same as linker_identifier previously defined in builder.assign_linkers() Otherwise, set linker_identifier = None
Pseudoatoms – Determines wether there is the hydrogen count appended to the atoms type. If builder.convert_to_pseudo() was used, pseudoatoms = True Otherwise, pseudoatoms = False
out_json (str) – JSON file with information from TopoTools file in PyLIFT-parsable dictionary
- Returns:
TopoTools information in PyLIFT-parsable dictionary
- Return type:
dict
pylift.utilities module
pylift.utilities module
License: The MIT License (MIT)
Copyright (c) 2024 Brandon C. Tapia
- pylift.utilities.cleanup_pylift(user_files: list[str] = None, temp: bool = True, antechamber: bool = True, verbose: bool = True) dict[source]
Cleans up temporary files generated during program execution.
- Parameters:
user_files (list[str]) – List of additional file paths to be removed. Default is None.
temp (bool) – Removes all files with tmp in their name
antechamber (bool) – Removes all extraneous files generated with Antechamber
- Returns:
information regarding the success/failure of deletion
- Return type:
dict
pylift.vmd module
pylift.vmd module
License: The MIT License (MIT)
Copyright 2025 Brandon C. Tapia
- pylift.vmd.run_vmd_commands(commands: str, verbose: bool | None = True) tuple[str, str, int][source]
Send and run commands in VMD.
- Parameters:
commands (str) – Commands to run in VMD
verbose (bool) – Print out additional information to screen
- Returns:
process output, prcess error, process returncode
- Return type:
tuple
- pylift.vmd.test_vmd_exec()[source]
Tests if VMD executable can be found and run from the environment variable.
- Returns:
bool for success/fail
- pylift.vmd.topo_write(molecule_in: str, lammps_out: str, bonds: bool | None = True, angles: bool | None = True, dihedrals: bool | None = True, impropers: bool | None = True, verbose: bool | None = True) None[source]
pylift.vmd.writelammpsdata
Writes a skeleton LAMMPS file using TopoTools in VMD.
- Parameters:
molecule_in (str) – filename of molecule to be read into VMD
lammps_out (str) – filename of skelton LAMMPS file to be created
bonds (bool) – if TopoTools should include bond section
angles (bool) – if TopoTools should include angles section
dihedrals (bool) – if TopoTools should include dihedrals section
impropers (bool) – if TopoTools should include impropers section
verbose (bool) – if additional information should be printed to screen
- Returns:
None
pylift.writer module
pylift.writer
License: The MIT License (MIT)
Copyright 2025 Brandon C. Tapia
- pylift.writer.write_lammps(lammps_dict, lammps_out, comment_style=None)[source]
Writes out a LAMMPS file from PyLIFT-readable dictionaries
- Parameters:
lammps_dict (dict) – LAMMPS information stored from pylift.reader.read_lammps()
lammps_out (str) – name of output LAMMPS file
comment_style (str) – if/how parameter types are appended as comments after parameters (e.g., comment_style = ‘,’ may append # c3,c3 to a c3-c3 bonding parameter) comment_style = ‘,’ is especially useful if using pysimm
- Returns:
None
Module contents
pylift.__init__ module
License: The MIT License (MIT)
Copyright (c) 2024 Brandon C. Tapia
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.