read_structure_step.formats.openbabel_io package#

Submodules#

read_structure_step.formats.openbabel_io.checkers module#

read_structure_step.formats.openbabel_io.checkers.add_format_checkers()[source]#

Add any missing format checkers.

read_structure_step.formats.openbabel_io.checkers.check_for_pdb(file_name)[source]#

Check if a file appears to be a PDB file.

The PDB files have a number of required keywords; however, some, like “AUTHOR” are common words, so this routine checks for the simultaneous presence of a number of the strangely spelled keywords.

Parameters:

file_name (str) – The path to the file.

Returns:

True if the file appears to be a PDB file.

Return type:

bool

read_structure_step.formats.openbabel_io.checkers.check_for_xyz(file_name)[source]#

Check if a file appears to be an XYZ file.

Parameters:

file_name (str) – The path to the file.

Returns:

True if the file appears to be a PDB file.

Return type:

bool

read_structure_step.formats.openbabel_io.obabel module#

Implementation of the chemical file reader/write using Open Babel

read_structure_step.formats.openbabel_io.obabel.load_file(path, configuration, extension='.sdf', add_hydrogens=True, system_db=None, system=None, indices='1:end', subsequent_as_configurations=False, system_name='Canonical SMILES', configuration_name='sequential', printer=None, references=None, bibliography=None, **kwargs)[source]#

Use Open Babel for reading any of the formats it supports.

See https://en.wikipedia.org/wiki/Chemical_table_file for a description of the format. This function is using Open Babel to handle the file, so trusts that Open Babel knows what it is doing.

Parameters:
  • file_name (str or Path) – The path to the file, as either a string or Path.

  • configuration (molsystem.Configuration) – The configuration to put the imported structure into.

  • extension (str, optional, default: None) – The extension, including initial dot, defining the format.

  • add_hydrogens (bool = True) – Whether to add any missing hydrogen atoms.

  • system_db (System_DB = None) – The system database, used if multiple structures in the file.

  • system (System = None) – The system to use if adding subsequent structures as configurations.

  • indices (str = "1:end") – The generalized indices (slices, SMARTS, etc.) to select structures from a file containing multiple structures.

  • subsequent_as_configurations (bool = False) – Normally and subsequent structures are loaded into new systems; however, if this option is True, they will be added as configurations.

  • system_name (str = "from file") – The name for systems. Can be directives like “SMILES” or “Canonical SMILES”. If None, no name is given.

  • configuration_name (str = "sequential") – The name for configurations. Can be directives like “SMILES” or “Canonical SMILES”. If None, no name is given.

  • printer (Logger or Printer) – A function that prints to the appropriate place, used for progress.

  • references (ReferenceHandler = None) – The reference handler object or None

  • bibliography (dict) – The bibliography as a dictionary.

Returns:

The list of configurations created.

Return type:

[Configuration]

read_structure_step.formats.openbabel_io.obabel.write_file(path, configurations, extension='.sdf', remove_hydrogens='no', printer=None, references=None, bibliography=None, **kwargs)[source]#

Use Open Babel for reading any of the formats it supports.

See https://en.wikipedia.org/wiki/Chemical_table_file for a description of the format. This function is using Open Babel to handle the file, so trusts that Open Babel knows what it is doing.

Parameters:
  • file_name (str or Path) – The path to the file, as either a string or Path.

  • configurations ([molsystem.Configuration]) – The configurations to write – should be one for this module

  • extension (str, optional, default: None) – The extension, including initial dot, defining the format.

  • remove_hydrogens (str = "no") – Whether to remove any hydrogen atoms before writing the file.

  • printer (Logger or Printer) – A function that prints to the appropriate place, used for progress.

  • references (ReferenceHandler = None) – The reference handler object or None

  • bibliography (dict) – The bibliography as a dictionary.

Returns:

The list of configurations created.

Return type:

[Configuration]

Module contents#