read_structure_step package#

Subpackages#

Submodules#

read_structure_step.errors module#

Errors for the various modules in the plugin

exception read_structure_step.errors.Error[source]#

Bases: Exception

Base class for exceptions raised by the read_structure_step

exception read_structure_step.errors.Mol2Error[source]#

Bases: Error

Class for exceptions raised by the Mol2 module in read_structure_step

exception read_structure_step.errors.MopError[source]#

Bases: Error

Class for exceptions raised by the MOPAC module in read_structure_step

exception read_structure_step.errors.PDBError[source]#

Bases: Error

Class for exceptions raised by the PDB module in read_structure_step

exception read_structure_step.errors.SDFError[source]#

Bases: Error

Class for exceptions raised by the SDF module in read_structure_step

exception read_structure_step.errors.XYZError[source]#

Bases: Error

Class for exceptions raised by the XYZ module in read_structure_step

read_structure_step.read module#

The public interface to the read_structure_step SEAMM plugin

read_structure_step.read.read(file_name, configuration, extension=None, add_hydrogens=False, system_db=None, system=None, indices='1-end', subsequent_as_configurations=False, system_name=None, configuration_name=None, printer=None, references=None, bibliography=None, step=None)[source]#

Calls the appropriate functions to parse the requested file.

Parameters:
  • file_name (str) – Name of the file

  • configuration (Configuration) – The SEAMM configuration to read into

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

  • add_hydrogens (bool = False) – 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 = None) – 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 = None) – The name for systems. Can be directives like “SMILES” or “Canonical SMILES”. If None, no name is given.

  • configuration_name (str = None) – 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.

  • step (seamm.Node = None) – The node in the flowchart, used for running e.g. MOPAC.

Returns:

The list of configurations created.

Return type:

[Configuration]

read_structure_step.read_structure module#

Non-graphical part of the Read Structure step in a SEAMM flowchart

In addition to the normal logger, two logger-like printing facilities are defined: ‘job’ and ‘printer’. ‘job’ send output to the main job.out file for the job, and should be used very sparingly, typically to echo what this step will do in the initial summary of the job.

‘printer’ sends output to the file ‘step.out’ in this steps working directory, and is used for all normal output from this step.

class read_structure_step.read_structure.ReadStructure(flowchart=None, title='Read Structure', extension=None)[source]#

Bases: Node

create_parser()[source]#

Setup the command-line / config file parser

description_text(P=None)[source]#

Create the text description of what this step will do. The dictionary of control values is passed in as P so that the code can test values, etc.

Keyword Arguments:

P – An optional dictionary of the current values of the control parameters.

property git_revision#

The git version of this module.

read_tarfile(tarfile_path, P)[source]#

Read structures from a tarfile.

Parameters:
  • path (pathlib.Path) – The path to the tarfile.

  • P ({str: str}) – Dictionary of control parameters for this step.

run()[source]#

Run a Read Structure step.

run_mopac(files=None, return_files=['mopac.out'])[source]#

Run MOPAC to parse the input file.

property version#

The semantic version of this module.

read_structure_step.read_structure_parameters module#

Control parameters for the Read Structure step in a SEAMM flowchart

class read_structure_step.read_structure_parameters.ReadStructureParameters(defaults={}, data=None)[source]#

Bases: Parameters

The control parameters for Read Structure

This is a dictionary of Parameters objects, which themselves are dictionaries. You need to replace the ‘time’ example below with one or more definitions of the control parameters for your plugin and application.

The fields of each Parameter are:

default: the default value of the parameter, used to reset it kind: one of ‘integer’, ‘float’, ‘string’, ‘boolean’ or ‘enum’ default_units: the default units, used for reseting the value enumeration: a tuple of enumerated values. See below for more. format_string: a format string for ‘pretty’ output description: a short string used as a prompt in the GUI help_text: a longer string to display as help for the user

While the ‘kind’ of a variable might be a numeric value, it may still have enumerated values, such as ‘normal’, ‘precise’, etc. In addition, any parameter can be set to a variable of expression, indicated by having ‘$’ as the first character in the field.

parameters = {'add hydrogens': {'default': 'no', 'default_units': '', 'description': 'Add hydrogens:', 'enumeration': ('yes', 'no'), 'format_string': 's', 'help_text': 'Whether to add missing hydrogen atoms.', 'kind': 'boolean'}, 'file': {'default': '', 'default_units': '', 'description': 'Structure file:', 'enumeration': (), 'format_string': 's', 'help_text': 'The file containing the structure.', 'kind': 'string'}, 'file type': {'default': 'from extension', 'default_units': '', 'description': 'Type of file:', 'enumeration': ('from extension', '.CONFIG', '.CONTCAR', '.CONTFF', '.HISTORY', '.MDFF', '.POSCAR', '.POSFF', '.VASP', '.abinit', '.acesout', '.acr', '.adfband', '.adfdftb', '.adfout', '.alc', '.aoforce', '.arc', '.axsf', '.bgf', '.box', '.bs', '.c09out', '.c3d1', '.c3d2', '.caccrt', '.can', '.car', '.castep', '.ccc', '.cdjson', '.cdx', '.cdxml', '.cif', '.ck', '.cml', '.cmlr', '.cof', '.crk2d', '.crk3d', '.ct', '.cub', '.cube', '.dallog', '.dalmol', '.dat', '.dmol', '.dx', '.ent', '.exyz', '.fa', '.fasta', '.fch', '.fchk', '.fck', '.feat', '.fhiaims', '.fract', '.fs', '.fsa', '.g03', '.g09', '.g16', '.g92', '.g94', '.g98', '.gal', '.gam', '.gamess', '.gamin', '.gamout', '.got', '.gpr', '.gro', '.gukin', '.gukout', '.gzmat', '.hin', '.inchi', '.inp', '.ins', '.jin', '.jout', '.log', '.lpmd', '.mcdl', '.mcif', '.mdl', '.ml2', '.mmcif', '.mmd', '.mmod', '.mol', '.mol2', '.mold', '.molden', '.molf', '.moo', '.mop', '.mopcrt', '.mopin', '.mopout', '.mpc', '.mpo', '.mpqc', '.mrv', '.msi', '.nwo', '.orca', '.out', '.outmol', '.output', '.pc', '.pcjson', '.pcm', '.pdb', '.pdbqt', '.png', '.pos', '.pqr', '.pqs', '.prep', '.pwscf', '.qcout', '.res', '.rsmi', '.rxn', '.sd', '.sdf', '.siesta', '.smi', '.smiles', '.smy', '.sy2', '.t41', '.tdd', '.text', '.therm', '.tmol', '.txt', '.txyz', '.unixyz', '.vmol', '.wln', '.xml', '.xsf', '.xtc', '.xyz', '.yob'), 'format_string': 's', 'help_text': 'The type of file, overrides the extension', 'kind': 'enum'}, 'indices': {'default': '1-end', 'default_units': '', 'description': 'Structures to read:', 'enumeration': ('1-end',), 'format_string': 's', 'help_text': 'The set of structures to read', 'kind': 'string'}}#

read_structure_step.read_structure_step module#

Helper class needed for the stevedore integration.

This must provide a description() method that returns a dict containing a description of this node, and create_node() and create_tk_node() methods for creating the graphical and non-graphical nodes.

class read_structure_step.read_structure_step.ReadStructureStep(flowchart=None, gui=None)[source]#

Bases: object

create_node(flowchart=None, **kwargs)[source]#

Create and return the new node object.

create_tk_node(canvas=None, **kwargs)[source]#

Create and return the graphical Tk node object.

description()[source]#

Return a description of what this extension does

my_description = {'description': 'An interface for Read Structure', 'group': 'Data', 'name': 'Read Structure'}#

The description needs three fields:

description:

A human-readable description of this step. It can be several lines long, and needs to be clear to non-expert users.

group:

Which group in the menus to put this step. If the group does not exist it will be created. Common groups are ‘Building’, ‘Calculations’, ‘Control’ and ‘Data’.

name:

The name of this step, to be displayed in the menus.

read_structure_step.tk_read_structure module#

The graphical part of a Read Structure step

class read_structure_step.tk_read_structure.TkReadStructure(tk_flowchart=None, node=None, canvas=None, x=None, y=None, w=200, h=50)[source]#

Bases: TkNode

The graphical part of a Read Structure step in a flowchart.

create_dialog()[source]#

Create a dialog for editing the control parameters

reset_dialog(widget=None)[source]#

Layout the widgets in the dialog

This initial function simply lays them out row by rows with aligned labels. You may wish a more complicated layout that is controlled by values of some of the control parameters.

right_click(event)[source]#

Probably need to add our dialog…

read_structure_step.tk_write_structure module#

The graphical part of a Write Structure step

class read_structure_step.tk_write_structure.TkWriteStructure(tk_flowchart=None, node=None, canvas=None, x=None, y=None, w=200, h=50)[source]#

Bases: TkNode

The graphical part of a Write Structure step in a flowchart.

create_dialog()[source]#

Create a dialog for editing the control parameters

reset_dialog(widget=None)[source]#

Layout the widgets in the dialog

This initial function simply lays them out row by rows with aligned labels. You may wish a more complicated layout that is controlled by values of some of the control parameters.

right_click(event)[source]#

Probably need to add our dialog…

read_structure_step.utils module#

read_structure_step.utils.guess_extension(file_name, use_file_name=False)[source]#

Returns the file format. It can either use the file name extension or guess based on signatures found in the file.

Correctly handles .gz and .bz2 files.

Parameters:
  • file_name (str) – Name of the file

  • use_file_name (bool, optional, default: False) – If set to True, uses the file name extension to identify the file format.

Returns:

extension – The file format.

Return type:

str

read_structure_step.utils.parse_indices(text, maximum)[source]#

Return a list of values in the given index expression.

Handles expressions like “1-10 by 2, 20-end” which would result in 1,3,5,7,9,20,21,22,23,24,25 if there were 25 items in the list.

read_structure_step.utils.sanitize_file_format(file_format)[source]#

Returns a uniform file format string.

Parameters:

file_format (str) – Extension of the file.

Returns:

file_format – The sanitized file format.

Return type:

str

read_structure_step.write module#

The public interface to the read_structure_step SEAMM plugin

read_structure_step.write.write(file_name, configurations, extension=None, remove_hydrogens='no', printer=None, references=None, bibliography=None)[source]#

Calls the appropriate functions to parse the requested file.

Parameters:
  • file_name (str) – Name of the file

  • configurations ([Configuration]) – The SEAMM configuration(s) to write

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

  • remove_hydrogens (str = "no") – Whether to remove hydrogen atoms before writing the structure to 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. The list of configurations created.

read_structure_step.write_structure module#

Non-graphical part of the Write Structure step in a SEAMM flowchart

In addition to the normal logger, two logger-like printing facilities are defined: ‘job’ and ‘printer’. ‘job’ send output to the main job.out file for the job, and should be used very sparingly, typically to echo what this step will do in the initial summary of the job.

‘printer’ sends output to the file ‘step.out’ in this steps working directory, and is used for all normal output from this step.

class read_structure_step.write_structure.WriteStructure(flowchart=None, title='Write Structure', extension=None)[source]#

Bases: Node

description_text(P=None)[source]#

Create the text description of what this step will do. The dictionary of control values is passed in as P so that the code can test values, etc.

Keyword Arguments:

P – An optional dictionary of the current values of the control parameters.

property git_revision#

The git version of this module.

run()[source]#

Run a Write Structure step.

property version#

The semantic version of this module.

read_structure_step.write_structure_parameters module#

Control parameters for the Write Structure step in a SEAMM flowchart

class read_structure_step.write_structure_parameters.WriteStructureParameters(defaults={}, data=None)[source]#

Bases: Parameters

The control parameters for Write Structure

This is a dictionary of Parameters objects, which themselves are dictionaries. You need to replace the ‘time’ example below with one or more definitions of the control parameters for your plugin and application.

The fields of each Parameter are:

default: the default value of the parameter, used to reset it kind: one of ‘integer’, ‘float’, ‘string’, ‘boolean’ or ‘enum’ default_units: the default units, used for reseting the value enumeration: a tuple of enumerated values. See below for more. format_string: a format string for ‘pretty’ output description: a short string used as a prompt in the GUI help_text: a longer string to display as help for the user

While the ‘kind’ of a variable might be a numeric value, it may still have enumerated values, such as ‘normal’, ‘precise’, etc. In addition, any parameter can be set to a variable of expression, indicated by having ‘$’ as the first character in the field.

parameters = {'configurations': {'default': 'all', 'default_units': '', 'description': 'Configuration(s) to write:', 'enumeration': ('all',), 'format_string': 's', 'help_text': "The configurations to write: a name, or 'all'", 'kind': 'string'}, 'file': {'default': '', 'default_units': '', 'description': 'File:', 'enumeration': (), 'format_string': 's', 'help_text': 'The file to write.', 'kind': 'string'}, 'file type': {'default': 'from extension', 'default_units': '', 'description': 'Type of file:', 'enumeration': ('from extension', '.CONFIG', '.CONTCAR', '.CONTFF', '.MDFF', '.POSCAR', '.POSFF', '.VASP', '.acesin', '.adf', '.alc', '.ascii', '.bgf', '.box', '.bs', '.c3d1', '.c3d2', '.cac', '.caccrt', '.cache', '.cacint', '.can', '.cdjson', '.cdxml', '.cht', '.cif', '.ck', '.cml', '.cmlr', '.cof', '.com', '.confabreport', '.copy', '.crk2d', '.crk3d', '.csr', '.cssr', '.ct', '.cub', '.cube', '.dalmol', '.dmol', '.dx', '.ent', '.exyz', '.fa', '.fasta', '.feat', '.fh', '.fhiaims', '.fix', '.fps', '.fpt', '.fract', '.fs', '.fsa', '.gamin', '.gau', '.gjc', '.gjf', '.gpr', '.gr96', '.gro', '.gukin', '.gukout', '.gzmat', '.hin', '.inchi', '.inchikey', '.inp', '.jin', '.k', '.lmpdat', '.lpmd', '.mcdl', '.mcif', '.mdl', '.ml2', '.mmcif', '.mmd', '.mmod', '.mna', '.mol', '.mol2', '.mold', '.molden', '.molf', '.molreport', '.mop', '.mopcrt', '.mopin', '.mp', '.mpc', '.mpd', '.mpqcin', '.mrv', '.msms', '.nul', '.nw', '.orcainp', '.outmol', '.paint', '.pcjson', '.pcm', '.pdb', '.pdbqt', '.png', '.pointcloud', '.pov', '.pqr', '.pqs', '.qcin', '.report', '.rinchi', '.rsmi', '.rxn', '.sd', '.sdf', '.smi', '.smiles', '.stl', '.svg', '.sy2', '.tdd', '.text', '.therm', '.tmol', '.txt', '.txyz', '.unixyz', '.vmol', '.xed', '.xyz', '.yob', '.zin'), 'format_string': 's', 'help_text': 'The type of file, overrides the extension', 'kind': 'enum'}, 'ignore missing': {'default': 'yes', 'default_units': '', 'description': 'Ignore missing structures:', 'enumeration': ('yes', 'no'), 'format_string': 's', 'help_text': "Silently ignore structures that don't exist.", 'kind': 'boolean'}, 'number per file': {'default': 'all', 'default_units': '', 'description': '# structures per file:', 'enumeration': ('all',), 'format_string': '', 'help_text': 'The number of structures to write per file.', 'kind': 'integer'}, 'remove hydrogens': {'default': 'no', 'default_units': '', 'description': 'Remove hydrogens:', 'enumeration': ('no', 'nonpolar', 'all'), 'format_string': 's', 'help_text': 'Whether to remove hydrogen atoms before writing, and if so, just the nonpolar ones or all.', 'kind': 'enum'}, 'structures': {'default': 'current configuration', 'default_units': '', 'description': 'Structures to write:', 'enumeration': ('current configuration', 'current system', 'all systems'), 'format_string': 's', 'help_text': 'The set of structures to write', 'kind': 'string'}}#

read_structure_step.write_structure_step module#

Helper class needed for the stevedore integration.

This must provide a description() method that returns a dict containing a description of this node, and create_node() and create_tk_node() methods for creating the graphical and non-graphical nodes.

class read_structure_step.write_structure_step.WriteStructureStep(flowchart=None, gui=None)[source]#

Bases: object

create_node(flowchart=None, **kwargs)[source]#

Create and return the new node object.

create_tk_node(canvas=None, **kwargs)[source]#

Create and return the graphical Tk node object.

description()[source]#

Return a description of what this extension does

my_description = {'description': 'An interface for Write Structure', 'group': 'Data', 'name': 'Write Structure'}#

The description needs three fields:

description:

A human-readable description of this step. It can be several lines long, and needs to be clear to non-expert users.

group:

Which group in the menus to put this step. If the group does not exist it will be created. Common groups are ‘Building’, ‘Calculations’, ‘Control’ and ‘Data’.

name:

The name of this step, to be displayed in the menus.

Module contents#

read_structure_step A SEAMM plugin to read common formats in computational chemistry