Parser#

class Parser(filename, mode='r', **kwargs)[source]

Bases: ABC

Base class for structure file parsers.

Classes inheriting from Parser need to define a function Parser.parse_input() that creates a dictionary representation of the given file. The input is a deque of all lines in the file.

Parameters:
filenamestr

File name to parse data from.

modestr, optional

Mode to open the file. Default is ‘r’ for read.

kwargsDict, optional

Optional keyword arguments passed to the child’s parse_input method.

Attributes#

Parser.get(key[, default])

Retrieve a value from the internal data using a given key.

Parser.keys()

List keys available in internal dictionary.

Parser.values()

List values available in internal dictionary.

Parser.items()

List items available in internal dictionary.

Parser.parse_input(lines)

Parse a list of lines from a file and convert the data into a dictionary.

Supported formats#

PDBParser(filename[, mode])

Convert PDB file data into a dictionary representation [Ra4c9f6a816d0-1].

MMCIFParser(filename[, mode])

Convert MMCIF file data into a dictionary representation.

GROParser(filename[, mode])

Convert GRO file in Gromos87 format into a dictionary representation [R9139f7711c9e-1].

StarParser(filename[, mode])

Convert STAR file data into a dictionary representation [Rd1c0acc01191-1].

XMLParser(filename[, mode])

Parser for XML files.

MDOCParser(filename[, mode])

Convert MDOC file (SerialEM metadata) into a dictionary representation.