MDFactoryMDFactory

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.Atom

RDKit atom object.

Returns

str

Sybyl 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.Bond

RDKit bond object.

Returns

str

Tripos 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.Mol

RDKit molecule with at least one conformer.

parammol2_pathstr or Path

Output file path.

paramtitlestr
= 'XXX'

Molecule title written in the MOLECULE section. Default is "XXX".

Returns

None
funcrun_cgenff_to_gmx(mol2_file)

Run the CGenFF-to-GROMACS conversion script on a mol2 file.

parammol2_filestr

Path 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

list

Contiguous 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 Path

Path 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
= True

Whether the file MUST have a moleculetype section. Default is True.

Returns

tuple

A 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 Path

Paths to GROMACS topology files containing parameter sections.

Returns

str

Merged, deduplicated parameter sections as a single string.