Source code for ligandparam.stages.leap

import MDAnalysis as mda

from ligandparam.stages.abstractstage import AbstractStage
from ligandparam.io.leapIO import LeapWriter
from ligandparam.interfaces import Leap

[docs] class StageLeap(AbstractStage): def __init__(self, name, inputoptions=None) -> None: """ This class is used to run a basic leap calculations on the ligand. Parameters ---------- name : str The name of the stage inputoptions : dict The input options """ self.name = name self._parse_inputoptions(inputoptions) self._add_required(f"{self.base_name}.frcmod") self._add_required(f"{self.base_name}.resp.mol2") self._add_output(f"{self.base_name}.off") return
[docs] def _append_stage(self, stage: "AbstractStage") -> "AbstractStage": """ Appends the stage. """ return stage
[docs] def _execute(self, dry_run=False): """ Setup the leap calculations to produce the off file. This function will generate the leap input file and then call tleap to generate the off (library) file with parameters for the ligand. Parameters ---------- dry_run : bool, optional If True, the stage will not be executed, but the function will print the commands that would """ # Generate the leap input file leapgen = LeapWriter("param") # Add the leaprc files for rc in self.leaprc: leapgen.add_leaprc(rc) u = mda.Universe(f"{self.base_name}.resp.mol2") resname = u.residues.resnames[0] # Add the leap commands leapgen.add_line(f"loadamberparams {self.base_name}.frcmod") leapgen.add_line(f"{resname} = loadmol2 {self.base_name}.resp.mol2") leapgen.add_line(f"saveOff {resname} {self.base_name}.off") leapgen.add_line("quit") # Write the leap input file leapgen.write() # Call the leap program leap = Leap() leap.call(f="tleap.param.in", dry_run = dry_run) return
[docs] def _clean(self): """ Clean the files generated during the stage. """ raise NotImplementedError("clean method not implemented")