module Chem::Maestro

Overview

This module provides support for reading and writing Schrödinger Maestro files (.mae, .maegz, .mae.gz).

The layout follows maeparser: a file is a token stream of nested blocks, and each structure is an f_m_ct block. Atoms and bonds live in indexed m_atom[N] / m_bond[N] blocks with 1-based indexes. Bond rows are stored in one direction; files that list both directions are accepted and de-duplicated.

Multi-entry files are read with .each / .read_all and written as successive f_m_ct blocks. Path overloads decompress or compress .maegz and .mae.gz. Chem.read("file.mae.gz") selects this format because extensions are matched as a filename suffix.

<> is undefined: it is omitted from metadata and does not overwrite typed field defaults. Title and CRYST1 stay on Structure#title and #cell, not metadata. Extra columns are stored as metadata; on write, keys that are not already Maestro property names are emitted as {b|i|r|s}_user_<name>.

Atom names prefer s_m_pdb_atom_name, then s_m_atom_name. Residue atoms without a name use {element}{index}. Bonds of order 4 are Kekulized on read. Formal charges and bonds come from the file.

WARNING Basic support only. Stereo, display, and other advanced blocks are stored as metadata or skipped.

Defined in:

chem/formats/maestro.cr

Constant Summary

BLOCK_BEGINNING = '{'
BLOCK_END = '}'
DELIMITER = ":::"
EMPTY_FIELD = "<>"
PROPERTY_NAME_REGEX = /^[birs]_[a-zA-Z0-9]+_.+$/

Class Method Summary

Class Method Detail

def self.each(io : IO, source_file : Path | String | Nil = nil, & : Structure -> ) : Nil #

Yields each structure in io.


[View source]
def self.each(path : Path | String, & : Structure -> ) : Nil #

Yields each structure in path. Compressed .maegz and .mae.gz files are decompressed.


[View source]
def self.read(io : IO, source_file : Path | String | Nil = nil) : Structure #

Returns the next structure from io. Use .read_all or .each for multiple.


[View source]
def self.read(path : Path | String) : Structure #

Returns the first structure in path. Compressed .maegz and .mae.gz files are decompressed.


[View source]
def self.read_all(io : IO, source_file : Path | String | Nil = nil) : Array(Structure) #

Returns all structures in io.


[View source]
def self.read_all(path : Path | String) : Array(Structure) #

Returns all structures in path. Compressed .maegz and .mae.gz files are decompressed.


[View source]
def self.write(io : IO, struc : Structure) : Nil #

Writes struc to io.


[View source]
def self.write(io : IO, entries : Enumerable(Structure)) : Nil #

Writes each structure in entries to io as successive f_m_ct blocks.


[View source]
def self.write(path : Path | String, struc : Structure) : Nil #

Writes struc to path. Compressed .maegz and .mae.gz files are gzip-compressed.


[View source]
def self.write(path : Path | String, entries : Enumerable(Structure)) : Nil #

Writes each structure in entries to path. Compressed .maegz and .mae.gz files are gzip-compressed.


[View source]