pestifer.scripters.vmd module

class pestifer.scripters.vmd.VMDScripter(*args, **kwargs)[source]

Bases: TcLScripter

This class extends the TcLScripter class to provide functionality for creating and managing VMD scripts.

Parameters:

config (Config) – The configuration object containing settings for the script.

backup_selection(selname, dataholder='data', attributes=['chain', 'x', 'y', 'z', 'resid', 'resname', 'name'])[source]

Backup a selection of atoms in VMD to a data holder variable. This method creates a backup of the specified selection by storing its attributes in a data holder variable.

Parameters:
  • selname (str) – The name of the selection to be backed up.

  • dataholder (str, optional) – The name of the variable where the backup data will be stored. Default is data.

  • attributes (list, optional) – A list of attributes to be included in the backup. Default includes chain, x, y, z, resid, resname, and name.

cleanup(cleanup=False)[source]

Perform post-execution clean-up by flushing the file collector. If cleanup is True, it will remove all files collected during the script execution.

Parameters:

cleanup (bool, optional) – If True, the method will remove all files collected during the script execution. Default is False

load_psf_pdb(*objs, new_molid_varname='mX')[source]

Load a PSF and PDB file into VMD. This method takes one or two objects (PSF and PDB files) and loads them into VMD. If only one object is provided, it is assumed to be the basename of both the PSF and PDB files. If two objects are provided, the first is treated as the PSF file and the second as the PDB file.

Parameters:
  • objs (tuple) –

    A tuple containing either one or two objects:

    • If one object, it should be the basename of both the PSF and PDB files.

    • If two objects, the first should be the PSF file and the second should be the PDB file.

  • new_molid_varname (str, optional) – The variable name to be used for the new molecule ID in VMD. Default is ‘mX’.

newscript(basename=None, packages=[])[source]

Initialize a new VMD script with a specified basename and packages. If no basename is provided, a default script name is used.

Parameters:
  • basename (str, optional) – The base name for the script file. If not provided, a default name is used.

  • packages (list, optional) – A list of Tcl packages to be imported in the script.

restore_selection(selname, dataholder='data', attributes=['chain', 'x', 'y', 'z', 'resid', 'resname', 'name'])[source]

Restore a selection of atoms in VMD from a data holder variable. This method restores the specified selection by retrieving its attributes from the data holder variable.

Parameters:
  • selname (str) – The name of the selection to be restored.

  • dataholder (str, optional) – The name of the variable from which the backup data will be retrieved. Default is data.

  • attributes (list, optional) – A list of attributes to be restored. Default includes chain, x, y, z, resid, resname, and name.

runscript(*args, **options)[source]

Run the VMD script using the VMD command line interface. This method constructs a command to execute VMD with the specified script and options.

Parameters:
  • args (tuple) – Additional arguments to be passed to the VMD command.

  • options (dict) – A dictionary of options to be passed to the VMD command.

Returns:

The command object that was constructed to run the VMD script, after it has been executed.

Return type:

Command

set_molecule(mol: Molecule, altcoords=None)[source]

Set up a VMD molecule from the given molecule object.

Parameters:
  • mol (Molecule) – The molecule object to be set up in VMD.

  • altcoords (str, optional) – Alternative coordinates file to be loaded for the molecule.

usescript(scriptbasename, local=False, add_banners=False)[source]

Ingest a VMD Tcl script file into the current script. This method reads the specified script file and adds its contents to the current script.

Parameters:
  • scriptbasename (str) – The base name of the script file to be ingested (without extension).

  • local (bool, optional) – If True, the script is searched for in the current directory; otherwise, it is searched for in the Tcl script path.

  • add_banners (bool, optional) – If True, banners are added to the script indicating the start and end of the ingested script.

write_align(align: Align)[source]

Write VMD commands to align the pipeline system to a reference coordinate file.

Uses measure fit to compute the least-RMSD homogeneous transformation between mobile_sel atoms in the pipeline molecule and ref_sel atoms in the reference molecule, then applies that matrix to apply_to atoms. The reference molecule is deleted after the fit so it leaves no state.

write_crot(crot: Crot, chainIDmap: dict = {})[source]

Write a CROT object to the VMD script. This method generates VMD commands to create a CROT object based on the provided CROT data.

Parameters:
  • crot (Crot) – The CROT object containing the data to be written to the script.

  • chainIDmap (dict, optional) – A mapping of original chain IDs to new chain IDs. Default is an empty dictionary.

write_crots(crots: CrotList, chainIDmap: dict = {})[source]
write_orient(orient: Orient, molid: str = None)[source]

Write a VMD Orient object to the script. This method generates the Tcl commands to orient a coordinate set in VMD based on the provided Orient object.

Parameters:

orient (Orient) – The Orient object containing the orientation data.

write_orients(orients: OrientList)[source]
write_pdb(basename, molid_varname)[source]

Write the current VMD molecule to a PDB file. This method exports the current molecule in VMD to a PDB file with the specified basename.

Parameters:
  • basename (str) – The base name for the PDB file to be created.

  • molid_varname (str) – The variable name of the molecule ID in VMD. This is used to select the molecule for writing to the PDB file.

write_protein_loop_lines(mol: Molecule, cycles=100, **options)[source]

Write Tcl commands to declare loops in the asymmetric unit that are in the MISSING state and have a length greater than or equal to the specified minimum length. This method iterates through the segments of the asymmetric unit and generates Tcl commands to declare the loops.

Parameters:
  • mol (Molecule) – An instance of the Molecule class that contains the structural information.

  • cycles (int, optional) – The number of cycles for the loop declaration. Default is 100.

  • options (dict, optional) –

    Additional options for loop declaration. It can include:

    • min_length: The minimum length of loops to consider. Default is 4.

    • include_c_termini: If True, includes C-terminal loops in the declaration. If False, skips C-terminal loops. Default is False.

write_rottrans(rottrans: RotTrans)[source]
write_rottranslist(rottranslist: RotTransList)[source]
write_transfer_coords(tc: TransferCoords)[source]

Write VMD commands to copy coordinates from a donor system onto the pipeline system.

If tc.pre_align is true, the entire donor is first rigidly fitted to the pipeline system using align_donor_sel / align_mobile_sel before the coordinate transfer is performed. Both the alignment and transfer selections are checked for congruency before use.

writescript(force_exit=False)[source]

Finalize the VMD script by adding an exit statement and banners. This method checks if an exit statement is already present in the script; if not, it adds one.

Parameters:

force_exit (bool, optional) – If True, the exit statement is added even if one is already present.