pestifer.logparsers.namdlogparser module

NAMD log parsing utility

class pestifer.logparsers.namdlogparser.NAMDLogParser(basename='namd-logparser')[source]

Bases: LogParser

A class for parsing NAMD log files. This class is a subclass of LogParser and provides methods for reading, updating, and dumping NAMD log data. It also includes methods for processing specific lines in the log file, such as those containing information about the simulation, energy calculations, and pressure profiles.

Parameters:

basename (str) – The base name for the log parser. This is used to name the output log file.

bail_out_key = 'Stack Traceback:'

The key used to identify lines indicating a stack traceback in the NAMD log file, which may indicate an error or crash.

default_etitle_npt = ['TS', 'BOND', 'ANGLE', 'DIHED', 'IMPRP', 'ELECT', 'VDW', 'BOUNDARY', 'MISC', 'KINETIC', 'TOTAL', 'TEMP', 'POTENTIAL', 'TOTAL3', 'TEMPAVG', 'PRESSURE', 'GPRESSURE', 'VOLUME', 'PRESSAVG', 'GPRESSAVG']

The default energy titles for NPT ensembles in NAMD log files.

default_etitle_nvt = ['TS', 'BOND', 'ANGLE', 'DIHED', 'IMPRP', 'ELECT', 'VDW', 'BOUNDARY', 'MISC', 'KINETIC', 'TOTAL', 'TEMP', 'POTENTIAL', 'TOTAL3', 'TEMPAVG']

The default energy titles for NVT ensembles in NAMD log files.

energy_key = 'ENERGY: '

The key used to identify energy lines in the NAMD log file.

etitle_key = 'ETITLE: '

The key used to identify energy title lines in the NAMD log file.

finalize()[source]

Finalize the log parsing by creating dataframes for each time series.

classmethod from_file(filename: Path | str, passfilter: list[str] = [])[source]

Create a NAMDLog instance from an existing NAMD log file.

Parameters:

filename (str) – The path to the NAMD log file to read.

Returns:

An instance of NAMDLog with the data from the specified file.

Return type:

NAMDLog

info_key = 'Info: '

The key used to identify information lines in the NAMD log file.

measure_progress()[source]

Measure the progress of the NAMD simulation based on the metadata and time series data. This method calculates the fraction of completed steps relative to the total number of steps, using the first time step and the last recorded time step in the energy data.

performance_key = 'PERFORMANCE: '

The key used to identify performance lines in the NAMD log file, e.g., PERFORMANCE: 34000 averaging 23.789 ns/day, 0.00726387 sec/step with standard deviation 3.76697e-05

pressureprofile_key = 'PRESSUREPROFILE: '

The key used to identify pressure profile lines in the NAMD log file.

process_energy_line(line: str)[source]

Process a line from the energy section of the NAMD log file.

Parameters:

line (str) – A line from the NAMD log file that contains energy data.

process_energy_title(line: str)[source]

Process a line from the energy title section of the NAMD log file.

Parameters:

line (str) – A line from the NAMD log file that contains the energy titles.

process_info_line(line: str)[source]

Process a line from the information section of the NAMD log file.

process_line(line: str)[source]

Process a line from the NAMD log file. This method identifies the type of line (information, TCL command, energy, pressure profile, or wall clock time) and processes it accordingly.

Parameters:

line (str) – A line from the NAMD log file to be processed.

process_performance_line(line: str)[source]

Process a line from the performance section of the NAMD log file, e.g., PERFORMANCE: 34000 averaging 23.789 ns/day, 0.00726387 sec/step with standard deviation 3.76697e-05

Parameters:

line (str) – A line from the NAMD log file that contains performance data.

process_pressureprofile_line(line: str)[source]

Process a line from the pressure profile section of the NAMD log file.

Parameters:

line (str) – A line from the NAMD log file that contains pressure profile data.

process_restart_line(line: str)[source]

Process a line from the restart section of the NAMD log file.

Parameters:

line (str) – A line from the NAMD log file that contains restart information.

process_struct_summ_datum(line: str)[source]

Process a line from the structure summary section of the NAMD log file.

process_tcl_line(line: str)[source]

Process a line from the TCL command section of the NAMD log file.

process_timing_line(line: str)[source]

Process a line from the timing section of the NAMD log file, e.g., TIMING: 34000 CPU: 100.266, 0.00728793/step Wall: 100.267, 0.00728689/step, 1.9962 hours remaining, 0.000000 MB of memory in use. or TIMING: 19000 CPU: 130.551, 0.025328/step Wall: 140.3 , 0.0272845/step , 6.33326 ns/days , 0.0621481 hours remaining, 0.000000 MB of memory in use.

Parameters:

line (str) – A line from the NAMD log file that contains timing data.

process_wallclock_line(line: str)[source]

Process a line from the wall clock time section of the NAMD log file.

Parameters:

line (str) – A line from the NAMD log file that contains the wall clock time.

restart_key = 'WRITING COORDINATES TO RESTART FILE AT STEP '

The key used to identify lines indicating that coordinates are being written to a restart file in the NAMD log file.

static(filename: Path | str, passfilter: list[str] = [])[source]

Initialize the NAMDLog from an existing, static file.

Parameters:
  • filename (str) – The path to the NAMD log file to read.

  • filter (list) – A list of strings to filter the lines in the log file. Only lines containing these strings will be processed.

struct_sep = '*****************************'

The key used to identify the structure summary in the NAMD log file.

success()[source]

Check if the NAMD log parsing was successful. This method checks if the metadata contains the wallclock_time key, which indicates that the log file has been processed successfully.

tcl_key = 'TCL: '

The key used to identify TCL command lines in the NAMD log file.

timing_key = 'TIMING: '

The key used to identify timing lines in the NAMD log file, e.g., TIMING: 34000 CPU: 100.266, 0.00728793/step Wall: 100.267, 0.00728689/step, 1.9962 hours remaining, 0.000000 MB of memory in use.

update(bytes: str)[source]

Update the NAMD log parser with new bytes of data. This method appends the new bytes to the byte collector and processes the lines in the log file. It identifies the end of each line and processes each line based on its content. This is best used on a log file that is being written to, such as a live NAMD simulation log file. For static files, use the static method instead.

Parameters:

bytes (bytes) – The bytes to update the log parser with. This can be a string or bytes object containing the log data.

wallclock_key = 'WallClock: '

The key used to identify wall clock time lines in the NAMD log file.

write_csv()[source]

Write the parsed data to CSV files. This method creates a CSV file for each dataframe in the dataframes attribute, using the basename provided during initialization. The files will be named <basename>-<key>.csv, where <key> is the key of the dataframe in the dataframes dictionary.

class pestifer.logparsers.namdlogparser.NAMDxstParser(basename: str = 'namd-xstparser')[source]

Bases: LogParser

A class for parsing NAMD xst files, which contain information about the simulation cell dimensions.

Parameters:

filename (str) – The path to the NAMD xst file to parse.

dataframe: DataFrame | None
classmethod from_file(basename: str = 'namd-xstparser')[source]

Generate a NAMDxst instance from an existing NAMD xst file.

pestifer.logparsers.namdlogparser.subcommand_follow_namd_log(filename, basename: str | None = None)[source]

Follow a NAMD log file and parse it