topology_utilities
Molecular topology file manipulation utilities.
func_get_sybyl_atom_type(atom)Return the Sybyl atom type string for an RDKit atom.
paramatomrdkit.Chem.rdchem.AtomRDKit atom object.
Returns
strSybyl atom type (e.g. "C.3", "N.ar", "O.2").
func_get_tripos_bond_type(bond)Return the Tripos bond type string for an RDKit bond.
parambondrdkit.Chem.rdchem.BondRDKit bond object.
Returns
strTripos bond type ("1", "2", "3", "ar", or "am").
funcwrite_mol2_from_rdkit(rdkit_mol, mol2_path, title='XXX')Write a Tripos mol2 file directly from an RDKit molecule.
Produces @\<TRIPOS>MOLECULE, @\<TRIPOS>ATOM, and @\<TRIPOS>BOND
sections with Sybyl atom types and Tripos bond types suitable for CGenFF
parametrization.
paramrdkit_molrdkit.Chem.MolRDKit molecule with at least one conformer.
parammol2_pathstr or PathOutput file path.
paramtitlestr= 'XXX'Molecule title written in the MOLECULE section. Default is "XXX".
Returns
Nonefuncrun_cgenff_to_gmx(mol2_file)Run the CGenFF-to-GROMACS conversion script on a mol2 file.
parammol2_filestrPath to the mol2 file.
Returns
tuple of (int, str, str)(return_code, stdout, stderr) from the subprocess.
funccount_contiguous_strings(str_list) → list[tuple[str, int]]Generate from a list of strings a list of tuples with the string as the first element and the number of continuous repetitions as second element. For example, ['a', 'a', 'b', 'a'] would yield [('a', 2), ('b', 1), ('a', 1)].
paramstr_listlist[str]List of strings
Returns
listContiguous counts of strings.
funcextract_reusable_parts_from_cgenff_gmx_top(fname, replace_name='ABC', must_have_moleculetype=True) → tuple[str, str, list[tuple[str, str]]]Extract reusable moleculetype and parameter sections from a GROMACS topology file generated by CGenFF.
This function parses a topology file, identifies the molecule definition and parameter sections, and returns the moleculetype section (with a customizable molecule name) and the concatenated parameter sections.
Notes
- The function expects the molecule name to be "XXX" and replaces it with
replace_name. - Parameter sections extracted include: atomtypes, bondtypes, pairtypes, angletypes, dihedraltypes, and nonbond_params.
paramfnamestr or PathPath to the GROMACS topology file to be parsed.
paramreplace_namestr= 'ABC'The string to replace the default molecule name ("XXX") in the molecule section. Default is "ABC".
parammust_have_moleculetype= TrueWhether the file MUST have a moleculetype section. Default is True.
Returns
tupleA tuple containing:
- The molecule section as a string, with the molecule name replaced.
- The concatenated parameter sections as a single string.
- The individual sections
funcmerge_extra_parameter_itps(prm_files)Merge parameter sections from multiple CGenFF topology files.
Extract parameter sections (atomtypes, bondtypes, etc.) from each file, deduplicate lines, and concatenate into a single parameter string.
paramprm_fileslist of str or PathPaths to GROMACS topology files containing parameter sections.
Returns
strMerged, deduplicated parameter sections as a single string.
