chemaxon.io

This package contains functions for importing and exporting molecules.

GitHub examples: https://github.com/ChemAxon/python-examples/blob/main/jupyter/01_basic_functions.ipynb

@typecheck(Molecule, str)
def export_mol(mol: chemaxon.Molecule, format_opts: str) -> str:

Molecule export

Creates a string representation of the molecule. The format descriptor string can also contain export options. Format and options are separated by a colon, multiple options can be separated by commas. The line separator is '\n'.

The currently supported formats are: smiles, cxsmiles, smarts, MOL V2000, MOL V3000, mrv, cxon, name.

You can find more information about file formats and options on the following link: https://docs.chemaxon.com/display/docs/formats_index.html

Parameters
  • mol: chemaxon.Molecule - Input molecule
  • format_opts: str - This option is to specify the format and options for the export
Returns

str - The exported molecule

@typecheck(str, str)
def open_for_export(file_path: str, format_opts: str) -> chemaxon.io._exporter._MolExporter:

Factory function to create an instance of the molecule exporter with which molecules can be exported into files in the supported formats.

The currently supported formats are: smiles, cxsmiles, smarts, MOL V2000, MOL V3000, mrv, cxon, name.

For more information about file formats and format options, see: https://docs.chemaxon.com/display/docs/formats_index.html.

Parameters
  • file_path: str - The file path, where to export molecule data
  • format_opts: str - This option is to specify the format and options for the export
Returns

An exporter instance. Supported methods: write(Molecule), flush(), close()

@typecheck(str, str)
def import_mol(mol_str: str, format_opts: str = '') -> chemaxon.Molecule:

Molecule import

Reads a molecule from a string. If the string contains multiple molecules (e.g. in the case of an SDF or MRV file), reads only the first one. Processing is single-threaded.

The currently supported formats are: smiles, cxsmiles, smarts, MOL V2000, MOL V3000, mrv, cxon, name.

More info about file formats and options: https://docs.chemaxon.com/display/docs/formats_index.html

Parameters
  • mol_str: str - Input molecule string
  • format_opts: str - This option is to specify the input format and options for the import. If empty string, autodetect will be used. Default is auto-detect.
Returns

chemaxon.Molecule - The imported molecule

@typecheck(str)
def open_for_import( file_path: str, format_opts: str = '') -> chemaxon.io._importer._MolImporter:

Factory function to create a molecule importer for importing molecules from a file.

The currently supported formats are: smiles, cxsmiles, smarts, MOL V2000, MOL V3000, mrv, cxon, name.

More info about file formats and options: https://docs.chemaxon.com/display/docs/formats_index.html

Parameters
  • file_path: the path of the file to be imported.
  • format_opts: This option is to specify the format and options for the import. If empty string, autodetect will be used. Default is auto-detect.
Returns

An instance of the molecule importer. Supported methods: read(), close()