MOD Reader

class dendrotweaks.biophys.io.reader.MODFileReader[source]

Bases: object

Reader class for .mod files.

Provides methods to read and preprocess .mod files. Splits the content of the file into blocks for further parsing.

content

The content of the MOD file.

Type:

str

blocks

The blocks of the MOD file corresponding to the NMODL blocks e.g. NEURON, PARAMETER, ASSIGNED, etc.

Type:

Dict[str, List[str]]

unmatched

The unmatched content in the MOD file after splitting into blocks.

Type:

str

BLOCK_TYPES = ['TITLE', 'COMMENT', 'NEURON', 'UNITS', 'PARAMETER', 'ASSIGNED', 'STATE', 'BREAKPOINT', 'DERIVATIVE', 'INITIAL', 'FUNCTION', 'PROCEDURE', 'KINETIC']
read_file(path_to_file: str) str[source]

Read the content of the file.

Parameters:

path_to_file (str) – The path to the file.

preprocess(remove_inline_comments=True, remove_unitsoff=True, remove_verbatim=True) None[source]

Preprocess the content of the file.

replace_suffix_with_name(overwirte=False) None[source]

Replace the suffix in the content of the file with the file name.

Notes

Suffix is a string of the form SUFFIX suffix

Parameters:

overwirte (bool, optional) – Whether to overwrite the content of the file with the modified content.

remove_inline_comments() None[source]

Remove the rest of the line after “:” from the content of the file.

remove_unitsoff() None[source]

Remove ‘UNITSOFF’ and ‘UNITSON’ from the content of the file.

remove_verbatim() None[source]

Remove ‘VERBATIM’ and ‘ENDVERBATIM’ and everything in between from the content of the file.

remove_suffix_from_gbar() None[source]

Remove the suffix from ‘gbar’ in the content of the file.

Example

gnabar -> gbar

get_blocks(verbose=True) Dict[str, List[str]][source]

Split the content of the file into blocks and return them.

Parameters:

verbose (bool, optional) – Whether to print the blocks of the file.

Returns:

A dictionary of blocks where the key is the block name

Return type:

Dict[str, List[str]]

find_unmatched_content(verbose: bool = False) None[source]

Find unmatched content in the content of the file.

Parameters:

verbose (bool, optional) – Whether to print the unmatched content.