pestifer.scripters.namd module

class pestifer.scripters.namd.NAMDScripter(*args, **kwargs)[source]

Bases: TcLScripter

This class extends the TcLScripter class to provide functionality for creating and managing NAMD scripts (which NAMD refers to as “configurations” – this is not to be confused with Pestifer’s Config class).

Parameters:

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

consolidate_params(psf_path: str) str | None[source]

Replace the full parameter file set with a single minimal .prm for this PSF.

Reads atom types from psf_path, merges all files in self.parameters, extracts only the records needed for those atom types, writes {basename}_minimal.prm, and rewrites the NAMD script so that its parameters lines reference only that one file.

Returns the path to the written minimal .prm on success, or None if consolidation was skipped (e.g. no parameter files, PSF unreadable, or parse failures on all files).

fetch_standard_charmm_parameters()[source]

Fetch the standard CHARMM parameters from the configuration and copy them to the local directory. This method retrieves the parameters defined in the CHARMM force field configuration and copies them to the local directory for use in the NAMD script.

Returns:

A list of parameter files that have been copied to the local directory.

Return type:

list

newscript(basename=None, addl_paramfiles=[], skip_standard_params=False)[source]

Initialize a new NAMD script with a specified basename and additional parameter files. 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.

  • addl_paramfiles (list, optional) – A list of additional parameter files to be included in the script. These files should not contain a path, but they should be recognizable .prm or .str files within the CHARMM force field or the custom CHARMM-format directories.

  • skip_standard_params (bool, optional) – If True, skip fetching the standard CHARMM parameter files and treat addl_paramfiles as the complete parameter file list. Use this when generating a self-contained package that includes a pre-consolidated minimal .prm file.

runscript(**kwargs)[source]

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

Parameters:

kwargs (dict) – A dictionary of options to be passed to the NAMD command. This can include: - local_execution_only: If True, use the local CPU count instead of the configured CPU count. - single_gpu_only: If True, use only one GPU device. - cpu_override: If True, force the use of CPU settings even if the NAMD type is gpu.

writescript(params, cpu_override=False)[source]

Write the NAMD script based on the provided parameters. This method constructs the NAMD script by adding lines based on the parameters provided. If the NAMD type is ‘gpu’ and cpu_override is False, it will also add GPU-specific configurations.

Parameters:
  • params (dict) – A dictionary of parameters to include in the NAMD script.

  • cpu_override (bool, optional) – If True, the script will be written with CPU-specific configurations, even if the NAMD type is ‘gpu’.