Skip to content

Io script

thmd.io.script

This module contains functions to read/write some specific scripts.

Functions:

  • read_lines

    Function to read lines in a script that match some KEY_WORDs.

  • read_plumed_block

    Function to read block_command in PLUMED script.

  • write_lines

    Funtion to write a list of strings into file.

  • write_list

    Funtion to write a list of strings into file.

read_lines(file_name: str, keywords: list = [])

Function to read lines in a script that match some KEY_WORDs.

Parameters:

  • file_name (str) –

    a text file of any format.

  • keywords (list, default: [] ) –

    list-of-Keywords to extract a line, ex: METAD, LOGMFD. Default to [], mean read all lines.

Returns:

  • lines ( list ) –

    a list of lines.

  • rest_lines ( list ) –

    a list of rest lines.

read_plumed_block(file_name: str, block_name: str = ' ') -> list

Function to read block_command in PLUMED script.

Parameters:

  • file_name (str) –

    a text file of PLUMED format.

  • block_name (str, default: ' ' ) –

    block command in PLUMED, ex: METAD, LOGMFD

Returns:

  • lines ( list ) –

    block_of_commandlines

write_lines(filename: str, lines: list)

Funtion to write a list of strings into file.

Parameters:

  • filename (str) –

    file name.

  • lines (list) –

    list of strings.

write_list(lines: list, filename: str)

Funtion to write a list of strings into file.

Parameters:

  • filename (str) –

    file name.

  • lines (list) –

    list of strings.