iphasimulator.charmmgui_import ============================== .. py:module:: iphasimulator.charmmgui_import .. autoapi-nested-parse:: Helpers for CHARMM-GUI / CGenFF outputs (CHARMM/GROMACS route). Nothing here modifies a CHARMM-GUI download. The ``prepare_*`` functions write only into a new folder chosen by the caller, and ``gmx`` runs only when the ``run_*`` functions are called explicitly. Attributes ---------- .. autoapisummary:: iphasimulator.charmmgui_import.RESI_PENALTY_PATTERN iphasimulator.charmmgui_import.PARAMETER_PENALTY_PATTERN iphasimulator.charmmgui_import.PROGRAM_VERSION_PATTERN iphasimulator.charmmgui_import.FILES_VERSION_PATTERN iphasimulator.charmmgui_import.TOPOLOGY_FILES iphasimulator.charmmgui_import.PARAMETER_FILE iphasimulator.charmmgui_import.PENALTY_GRADE_RULES iphasimulator.charmmgui_import.CHARMM_GROMACS_TEMPLATE_DIR iphasimulator.charmmgui_import.CHARMM_GROMACS_MDP_FILES iphasimulator.charmmgui_import.LOCAL_SCRIPT iphasimulator.charmmgui_import.HPC_SCRIPT iphasimulator.charmmgui_import.HPC_SCRIPT_TEMPLATE iphasimulator.charmmgui_import.CHARMM_GUI_INDEX_GROUPS iphasimulator.charmmgui_import.CHARMM_DEFAULTS iphasimulator.charmmgui_import.CGENFF_TYPE_PATTERN iphasimulator.charmmgui_import.WATER_MOLECULES iphasimulator.charmmgui_import.ION_MOLECULES iphasimulator.charmmgui_import.DRY_COORDINATES iphasimulator.charmmgui_import.DRY_MDP iphasimulator.charmmgui_import.DRY_DEFFNM iphasimulator.charmmgui_import.DRY_MINIMIZATION_MDP iphasimulator.charmmgui_import.POTENTIAL_ENERGY_PATTERN iphasimulator.charmmgui_import.MAXIMUM_FORCE_PATTERN iphasimulator.charmmgui_import.ELEMENT_BY_MASS iphasimulator.charmmgui_import.SLURM_STAGES iphasimulator.charmmgui_import.CHARMM_POLYMER_TEMPLATE_DIR iphasimulator.charmmgui_import.WATER_ION_ATOMTYPES_INCLUDE iphasimulator.charmmgui_import.WATER_ION_MOLECULE_INCLUDES iphasimulator.charmmgui_import.SOLVATE_SCRIPT Classes ------- .. autoapisummary:: iphasimulator.charmmgui_import.PenaltyEntry iphasimulator.charmmgui_import.CGenFFPenaltyReport iphasimulator.charmmgui_import.ItpAtom iphasimulator.charmmgui_import.ItpMolecule iphasimulator.charmmgui_import.GroAtom iphasimulator.charmmgui_import.CheckResult iphasimulator.charmmgui_import.MinimizationResult iphasimulator.charmmgui_import.SignedVolume iphasimulator.charmmgui_import.MdpStage iphasimulator.charmmgui_import.CharmmPolymerWaterFolder Functions --------- .. autoapisummary:: iphasimulator.charmmgui_import.penalty_category iphasimulator.charmmgui_import.penalty_grade iphasimulator.charmmgui_import.read_cgenff_penalties iphasimulator.charmmgui_import.format_cgenff_penalty_report iphasimulator.charmmgui_import.format_checks iphasimulator.charmmgui_import.read_topology_molecules iphasimulator.charmmgui_import.read_topology_defaults iphasimulator.charmmgui_import.read_topology_molecule_counts iphasimulator.charmmgui_import.read_gro iphasimulator.charmmgui_import.check_charmm_defaults iphasimulator.charmmgui_import.check_includes iphasimulator.charmmgui_import.check_atom_counts iphasimulator.charmmgui_import.check_molecule_counts iphasimulator.charmmgui_import.check_net_charge iphasimulator.charmmgui_import.check_cgenff_types iphasimulator.charmmgui_import.check_ligand_atom_order iphasimulator.charmmgui_import.ligand_stereocentres iphasimulator.charmmgui_import.check_ligand_stereocentres iphasimulator.charmmgui_import.find_lig_topology iphasimulator.charmmgui_import.read_rtf_charges iphasimulator.charmmgui_import.read_cgenff_version iphasimulator.charmmgui_import.check_cgenff_penalties iphasimulator.charmmgui_import.check_ligand_charges_match_rtf iphasimulator.charmmgui_import.ligand_signed_volumes iphasimulator.charmmgui_import.check_ligand_signed_volumes iphasimulator.charmmgui_import.check_gromacs_run_files iphasimulator.charmmgui_import.validate_dry_ligand_folder iphasimulator.charmmgui_import.validate_charmm_gui_run_folder iphasimulator.charmmgui_import.prepare_dry_ligand_folder iphasimulator.charmmgui_import.prepare_charmm_gui_run_folder iphasimulator.charmmgui_import.read_mdp_stage iphasimulator.charmmgui_import.describe_run_folder_protocol iphasimulator.charmmgui_import.annotate_slurm_stage_lengths iphasimulator.charmmgui_import.run_dry_minimization iphasimulator.charmmgui_import.read_minimization_result iphasimulator.charmmgui_import.prepare_charmm_dry_polymer_folder iphasimulator.charmmgui_import.write_charmm_polymer_solvation_files iphasimulator.charmmgui_import.prepare_charmm_polymer_water_folder iphasimulator.charmmgui_import.run_charmm_polymer_solvation iphasimulator.charmmgui_import.validate_charmm_polymer_water_folder Module Contents --------------- .. py:data:: RESI_PENALTY_PATTERN .. py:data:: PARAMETER_PENALTY_PATTERN .. py:data:: PROGRAM_VERSION_PATTERN .. py:data:: FILES_VERSION_PATTERN .. py:data:: TOPOLOGY_FILES :value: ('lig.rtf', 'lig_g.rtf') .. py:data:: PARAMETER_FILE :value: 'lig.prm' .. py:class:: PenaltyEntry One penalised atom charge or bonded parameter. .. py:attribute:: source :type: str .. py:attribute:: label :type: str .. py:attribute:: penalty :type: float .. py:class:: CGenFFPenaltyReport Penalty scores parsed from a Ligand Reader & Modeler ``lig/`` folder. .. py:attribute:: lig_dir :type: pathlib.Path .. py:attribute:: files_read :type: tuple[str, ...] .. py:attribute:: program_version :type: str | None .. py:attribute:: parameter_files_version :type: str | None .. py:attribute:: resi_penalties :type: dict[str, tuple[float, float]] .. py:attribute:: charge_penalties :type: tuple[PenaltyEntry, ...] .. py:attribute:: parameter_penalties :type: tuple[PenaltyEntry, ...] .. py:property:: max_charge_penalty :type: float | None .. py:property:: max_parameter_penalty :type: float | None .. py:method:: top_charge_penalties(n: int = 5) -> tuple[PenaltyEntry, ...] .. py:method:: top_parameter_penalties(n: int = 5) -> tuple[PenaltyEntry, ...] .. py:function:: penalty_category(penalty: float | None) -> str Classify a CGenFF penalty with the thresholds printed in CGenFF output. .. py:data:: PENALTY_GRADE_RULES .. py:function:: penalty_grade(penalty: float) -> str GOOD (< 10), CHECK (10-50) or POOR (> 50) for a CGenFF penalty. .. py:function:: read_cgenff_penalties(lig_dir: str | pathlib.Path) -> CGenFFPenaltyReport Parse penalty scores from ``lig.rtf``, ``lig_g.rtf`` and ``lig.prm``. Missing files are skipped; at least one of them must exist. .. py:function:: format_cgenff_penalty_report(report: CGenFFPenaltyReport, top: int = 5) -> str Return a short plain-text summary suitable for notebook output. .. py:data:: CHARMM_GROMACS_TEMPLATE_DIR .. py:data:: CHARMM_GROMACS_MDP_FILES :value: ('step6.0_minimization.mdp', 'step6.1_nvt.mdp', 'step6.2_npt.mdp', 'step7_production.mdp') .. py:data:: LOCAL_SCRIPT :value: 'run_step6_local.sh' .. py:data:: HPC_SCRIPT :value: 'run_hpc_equilibration_production.slurm' .. py:data:: HPC_SCRIPT_TEMPLATE :value: 'run_hpc_equilibration_production.slurm.template' .. py:data:: CHARMM_GUI_INDEX_GROUPS :value: ('SOLU', 'SOLV') .. py:data:: CHARMM_DEFAULTS :value: ('1', '2', 'yes', 1.0, 1.0) .. py:data:: CGENFF_TYPE_PATTERN .. py:data:: WATER_MOLECULES :value: ('TIP3', 'SOL', 'HOH', 'WAT') .. py:data:: ION_MOLECULES :value: ('SOD', 'CLA', 'POT', 'NA', 'CL') .. py:data:: DRY_COORDINATES :value: 'lig.gro' .. py:data:: DRY_MDP :value: 'dry_minimization.mdp' .. py:data:: DRY_DEFFNM :value: 'dry_minimization' .. py:data:: DRY_MINIMIZATION_MDP :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """; Dry (no solvent) steepest-descent minimisation of the CGenFF polymer. ; Sanity check only: GROMACS' Verlet scheme needs a periodic box, so ; the molecule sits alone in a box larger than twice the cut-off. integrator = steep emtol = 100.0 emstep = 0.01 nsteps = 5000 nstlist = 10 cutoff-scheme = Verlet pbc = xyz rlist = 1.2 vdwtype = Cut-off vdw-modifier = Force-switch rvdw_switch = 1.0 rvdw = 1.2 coulombtype = PME rcoulomb = 1.2 constraints = h-bonds constraint_algorithm = LINCS """ .. raw:: html
.. py:data:: POTENTIAL_ENERGY_PATTERN .. py:data:: MAXIMUM_FORCE_PATTERN .. py:data:: ELEMENT_BY_MASS .. py:class:: ItpAtom .. py:attribute:: name :type: str .. py:attribute:: type :type: str .. py:attribute:: charge :type: float .. py:attribute:: mass :type: float .. py:class:: ItpMolecule One ``[ moleculetype ]`` with its atoms and bonds (0-based indices). .. py:attribute:: name :type: str .. py:attribute:: atoms :type: tuple[ItpAtom, ...] .. py:attribute:: bonds :type: tuple[tuple[int, int], ...] .. py:property:: charge :type: float .. py:class:: GroAtom .. py:attribute:: residue_number :type: int .. py:attribute:: residue_name :type: str .. py:attribute:: atom_name :type: str .. py:attribute:: position :type: tuple[float, float, float] .. py:class:: CheckResult One PASS/FAIL/SKIP line with the evidence behind it. .. py:attribute:: name :type: str .. py:attribute:: status :type: str .. py:attribute:: evidence :type: str .. py:property:: passed :type: bool .. py:class:: MinimizationResult .. py:attribute:: log_path :type: pathlib.Path .. py:attribute:: potential_energy :type: float | None .. py:attribute:: maximum_force :type: float | None .. py:function:: format_checks(results: list[CheckResult]) -> str Return one line per check, followed by an overall verdict. .. py:function:: read_topology_molecules(topology_path: str | pathlib.Path) -> dict[str, ItpMolecule] Read every ``[ moleculetype ]`` in a topology and its ``#include`` files. .. py:function:: read_topology_defaults(topology_path: str | pathlib.Path) -> tuple[str, ...] | None Return the first ``[ defaults ]`` line found in the topology or its includes. .. py:function:: read_topology_molecule_counts(topology_path: str | pathlib.Path) -> dict[str, int] Read the ``[ molecules ]`` table in order. .. py:function:: read_gro(gro_path: str | pathlib.Path) -> tuple[tuple[GroAtom, ...], tuple[float, ...]] Read atoms (positions in nm) and box vectors from a ``.gro`` file. .. py:function:: check_charmm_defaults(topology_path: str | pathlib.Path) -> CheckResult .. py:function:: check_includes(folder: str | pathlib.Path, topology_name: str = 'topol.top') -> CheckResult .. py:function:: check_atom_counts(folder: str | pathlib.Path, coordinate_name: str, topology_name: str = 'topol.top') -> CheckResult .. py:function:: check_molecule_counts(topology_path: str | pathlib.Path, *, ligand: str = 'LIG', require_water: bool) -> CheckResult .. py:function:: check_net_charge(topology_path: str | pathlib.Path, tolerance: float = 0.001) -> CheckResult .. py:function:: check_cgenff_types(topology_path: str | pathlib.Path, ligand: str = 'LIG') -> CheckResult .. py:function:: check_ligand_atom_order(gro_path: str | pathlib.Path, topology_path: str | pathlib.Path, ligand: str = 'LIG') -> CheckResult .. py:function:: ligand_stereocentres(gro_path: str | pathlib.Path, topology_path: str | pathlib.Path, sdf_path: str | pathlib.Path, ligand: str = 'LIG') -> list[tuple[str, str]] CIP labels of the ligand in ``gro_path``, using the SDF only for bond orders. The ligand graph comes from the ``.itp`` bonds and its geometry from the ``.gro`` coordinates (made whole across the box), so the labels describe the structure GROMACS will simulate, not the uploaded SDF. .. py:function:: check_ligand_stereocentres(gro_path: str | pathlib.Path, topology_path: str | pathlib.Path, sdf_path: str | pathlib.Path | None, ligand: str = 'LIG', expected: str = 'R') -> CheckResult .. py:function:: find_lig_topology(lig_dir: str | pathlib.Path | None) -> pathlib.Path | None The CGenFF topology in a ``lig/`` folder: ``lig_g.rtf``, or ``lig.rtf`` when there is no ``lig_g.rtf`` (the charges are identical). ``None`` when neither exists. .. py:function:: read_rtf_charges(rtf_path: str | pathlib.Path) -> dict[str, tuple[str, float]] Atom name -> (CGenFF type, charge) from the ATOM lines of a CHARMM ``.rtf``. .. py:function:: read_cgenff_version(path: str | pathlib.Path) -> tuple[str | None, str | None] (CGenFF program version, topology/parameter files version) from a ``lig.rtf``/``lig.prm`` header. .. py:function:: check_cgenff_penalties(lig_dir: str | pathlib.Path | None) -> CheckResult CGenFF parameter and charge penalties from ``lig/``: PASS < 10, WARN 10-50, FAIL > 50. .. py:function:: check_ligand_charges_match_rtf(topology_path: str | pathlib.Path, rtf_path: str | pathlib.Path | None, ligand: str = 'LIG', tolerance: float = 0.001) -> CheckResult Every LIG atom in the GROMACS topology has the type and charge from the rtf (``lig_g.rtf`` or ``lig.rtf``; their charges are identical). .. py:class:: SignedVolume .. py:attribute:: atom :type: str .. py:attribute:: neighbours :type: str .. py:attribute:: volume_md :type: float .. py:attribute:: volume_sdf :type: float .. py:attribute:: sdf_label :type: str .. py:attribute:: label :type: str .. py:function:: ligand_signed_volumes(gro_path: str | pathlib.Path, topology_path: str | pathlib.Path, sdf_path: str | pathlib.Path, ligand: str = 'LIG', centre_type: str = 'CG311') -> list[SignedVolume] Handedness of each ``centre_type`` stereocentre in the GROMACS coordinates vs the SDF. For every CG311 carbon (the PHA backbone CH), the signed volume of its three heavy neighbours (O, CH2, CH3 for PHB; O, CH2, CH2 for longer side chains), taken in the same order in both structures, is compared with the SDF. The same sign means the same configuration as the SDF (R for an R-configured SDF). .. py:function:: check_ligand_signed_volumes(gro_path: str | pathlib.Path, topology_path: str | pathlib.Path, sdf_path: str | pathlib.Path | None, ligand: str = 'LIG', expected: str = 'R') -> CheckResult .. py:function:: check_gromacs_run_files(folder: str | pathlib.Path, index_groups: tuple[str, ...] = CHARMM_GUI_INDEX_GROUPS) -> CheckResult .. py:function:: validate_dry_ligand_folder(folder: str | pathlib.Path, *, sdf_path: str | pathlib.Path | None = None, ligand: str = 'LIG') -> list[CheckResult] Read-only checks for a folder made by :func:`prepare_dry_ligand_folder`. .. py:function:: validate_charmm_gui_run_folder(folder: str | pathlib.Path, *, sdf_path: str | pathlib.Path | None = None, ligand: str = 'LIG') -> list[CheckResult] Read-only checks for a folder made by :func:`prepare_charmm_gui_run_folder`. .. py:function:: prepare_dry_ligand_folder(ligand_reader_dir: str | pathlib.Path, output_dir: str | pathlib.Path, *, padding_nm: float = 1.7) -> pathlib.Path Build a solvent-free GROMACS folder from a Ligand Reader & Modeler download. Copies ``gromacs/topol.top``, ``charmm36.itp`` and ``LIG.itp``, writes ``lig.gro`` from ``ligandrm.pdb`` centred in a cubic box of the molecule's extent plus ``2 * padding_nm``, and writes ``dry_minimization.mdp``. .. py:function:: prepare_charmm_gui_run_folder(solution_builder_dir: str | pathlib.Path, run_dir: str | pathlib.Path, *, template_dir: str | pathlib.Path | None = None, job_name: str | None = None) -> pathlib.Path Turn a Solution Builder download into a run folder, as in the production runs. Copies ``gromacs/`` (topology, ``toppar/``, ``index.ndx``, coordinates) into the new ``run_dir``, renames ``step3_input.gro`` to ``step5_input.gro``, leaves out CHARMM-GUI's ``step4.x``/``step5`` mdp files, and adds the CHARMM/GROMACS mdp files and scripts from ``template_dir`` (default: the packaged CHARMM/GROMACS templates). The SLURM job name defaults to the run folder's name, and the SLURM stage comments are written from the copied mdp files (nsteps x dt). .. py:data:: SLURM_STAGES :value: (('step6.1_nvt', 'Step 6.1', 'NVT'), ('step6.2_npt', 'Step 6.2', 'NPT'), ('step7_production',... .. py:class:: MdpStage .. py:attribute:: name :type: str .. py:attribute:: integrator :type: str .. py:attribute:: nsteps :type: int .. py:attribute:: dt_ps :type: float | None .. py:attribute:: temperature :type: str | None .. py:attribute:: pressure_coupling :type: str | None .. py:attribute:: position_restraints :type: bool .. py:property:: length_ps :type: float | None .. py:method:: length_text() -> str .. py:function:: read_mdp_stage(mdp_path: str | pathlib.Path) -> MdpStage Length and main settings of one mdp file (length = nsteps x dt). .. py:function:: describe_run_folder_protocol(folder: str | pathlib.Path) -> list[MdpStage] The step6.0–step7 stages of a run folder, as set in its mdp files. .. py:function:: annotate_slurm_stage_lengths(text: str, folder: str | pathlib.Path) -> str Rewrite the ``# Step 6.1/6.2/7 — ...`` comments from the folder's mdp files. .. py:function:: run_dry_minimization(folder: str | pathlib.Path, *, gmx: str = 'gmx', runner=subprocess.run) -> MinimizationResult Run ``grompp`` + ``mdrun`` for the dry folder and return Epot and Fmax. .. py:function:: read_minimization_result(log_path: str | pathlib.Path) -> MinimizationResult Read the final potential energy and maximum force from an ``mdrun`` log. .. py:data:: CHARMM_POLYMER_TEMPLATE_DIR .. py:data:: WATER_ION_ATOMTYPES_INCLUDE :value: 'tip3_ions_atomtypes.itp' .. py:data:: WATER_ION_MOLECULE_INCLUDES :value: ('TIP3_SOL.itp', 'SOD.itp', 'CLA.itp') .. py:data:: SOLVATE_SCRIPT :value: 'run_solvate_local.sh' .. py:class:: CharmmPolymerWaterFolder .. py:attribute:: run_dir :type: pathlib.Path .. py:attribute:: dry_dir :type: pathlib.Path .. py:attribute:: solvated_dir :type: pathlib.Path .. py:attribute:: solvate_script_path :type: pathlib.Path .. py:attribute:: local_script_path :type: pathlib.Path .. py:attribute:: hpc_script_path :type: pathlib.Path .. py:function:: prepare_charmm_dry_polymer_folder(ligand_reader_dir: str | pathlib.Path, gromacs_dir: str | pathlib.Path) -> pathlib.Path Write ``gromacs_dir/dry_polymer``: the CGenFF PHA ready for GROMACS, no solvent. The Ligand Reader topology (``topol.top``, ``charmm36.itp``, ``LIG.itp``) with the packaged CHARMM TIP3P/SOD/CLA files included, ``step5_input.gro`` and ``index.ndx`` (the same files ``prepare_gromacs_run_folder`` writes for a GAFF2 PHA), plus ``lig.gro`` and ``dry_minimization.mdp`` for an optional solvent-free minimisation. .. py:function:: write_charmm_polymer_solvation_files(gromacs_dir: str | pathlib.Path, *, box_padding_nm: float = 1.2, ion_concentration_molar: float = 0.15, job_name: str | None = None) -> CharmmPolymerWaterFolder Write ``gromacs_dir/solvated_polymer`` from ``dry_polymer`` like the polymer benchmark. Copies the topology include files and the CHARMM polymer mdp set, then calls :func:`write_gromacs_solvation_files` for the benchmark's ``run_solvate_local.sh`` (box, water, ions), ``run_step6_local.sh`` and SLURM script. Nothing is solvated until ``run_solvate_local.sh`` runs. .. py:function:: prepare_charmm_polymer_water_folder(ligand_reader_dir: str | pathlib.Path, run_dir: str | pathlib.Path, *, box_padding_nm: float = 1.2, ion_concentration_molar: float = 0.15, job_name: str | None = None) -> CharmmPolymerWaterFolder Both steps at once: :func:`prepare_charmm_dry_polymer_folder`, then :func:`write_charmm_polymer_solvation_files`, in a new ``run_dir``. .. py:function:: run_charmm_polymer_solvation(solvated_dir: str | pathlib.Path, *, runner=subprocess.run) -> subprocess.CompletedProcess Run ``run_solvate_local.sh`` (editconf, solvate, genion, grompp check) in ``solvated_dir``. .. py:function:: validate_charmm_polymer_water_folder(solvated_dir: str | pathlib.Path, *, sdf_path: str | pathlib.Path | None = None, ligand: str = 'LIG') -> list[CheckResult] Read-only checks for a solvated folder from :func:`prepare_charmm_polymer_water_folder`.