seamm_util package

Submodules

seamm_util.argument_parser module

A configuration and argument parser tailored to SEAMM.

The goal of this is to allow options to be specified both on the command line and in ini files, with command line having precedence. This is tailored to SEAMM flowcharts so that options for each type of step (plug-in) is in its own section on the command line or in the ini file, labeled by the type of section.

class seamm_util.argument_parser.ArgumentParser(*args, ini_files=['/home/runner/.seamm.d/seamm.ini', 'seamm.ini'], interpolation=<configparser.ExtendedInterpolation object>, **kwargs)[source]

Bases: object

Replacement and extension for argparse.ArgumentParser that adds support for .ini files plus something like the subcommands in argparse but with multiple ones active at the same time.

This is accomplished by separating sections with ‘<section name>’ on the commandline, and using ‘[<section name>] in the .ini files. e.g.

test.flow lammps-step –log-level debug psi4-step –np 32

add_argument(section, *args, **kwargs)[source]
add_argument_group(section, title, description=None)[source]
add_parser(section, prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True)[source]

Capture the information needed to create a subparser.

Parameters:
  • section (str) – The name of this section of the parsing.

  • prog (str = sys.argv[0]) – The name of the program

  • usage (str = None) – A usage message (default: auto-generated from arguments)

  • description (str = None) – A description of what the program does

  • epilog (str = None) – Text following the argument descriptions

  • parents ([argparse.ArgumentParser] = []) – Parsers whose arguments should be copied into this one

  • formatter_class (argparse.HelpFormatter) – HelpFormatter class for printing help messages

  • prefix_chars (str = '-') – Characters that prefix optional arguments

  • fromfile_prefix_chars (str = None) – Characters that prefix files containing additional arguments

  • argument_default (str = None) – The default value for all arguments

  • conflict_handler (str = 'error') – String indicating how to handle conflicts

  • add_help (bool = True) – Add a -h/-help option

  • allow_abbrev (bool = True) – Allow long options to be abbreviated unambiguously

exists(name)[source]
format_help(args=None)[source]

Prepare the help message.

Parameters:

args ([str] = sys.argv[1:]) – The arguments to pass the parsers, defaults to sys.argv[1:]

get(section, option, *, raw=False, vars=None, fallback=<object object>)[source]

Get an option value for a given section.

If `vars’ is provided, it must be a dictionary. The option is looked up in `vars’ (if provided), `section’, and in `DEFAULTSECT’ in that order. If the key is not found and `fallback’ is provided, it is used as a fallback value. `None’ can be provided as a `fallback’ value.

If interpolation is enabled and the optional argument `raw’ is False, all interpolations are expanded in the return values.

Arguments `raw’, `vars’, and `fallback’ are keyword only.

The section DEFAULT is special.

get_ini_files()[source]

Return a list of the .ini files actually used.

Returns:

The list of .ini files found

Return type:

[str]

get_options(section=None)[source]

Return the options for the given section.

Parameters:

section (str = None) – Return the options for the given section, or all sections

Returns:

{str – The dictionary of options for the section, or all sections.

Return type:

int, float, str or bool}

get_origins(section=None)[source]

Return the origins of the options for the given section.

Parameters:

section (str = None) – Return the origins for the given section, or all sections

Returns:

{str – The dictionary of origins for the section, or all sections.

Return type:

str}

items(section=<object object>, raw=False, vars=None)[source]

Return a list of (name, value) tuples for each option in a section.

All % interpolations are expanded in the return values, based on the defaults passed into the constructor, unless the optional argument `raw’ is true. Additional substitutions may be provided using the `vars’ argument, which must be a dictionary whose contents overrides any pre-existing defaults.

The section DEFAULT is special.

optionxform(optionstr)[source]
parse_args(args=None)[source]

Parse the .ini file and command-line arguments.

There are three distinct steps to the process:

  1. Process the command-line arguments, breaking them into sections corresponding to the subparsers.

  2. Read the .ini files, if any.

  3. Create the actual parsers from the saved information, replacing or adding defaults for any values found in the .ini files.

  4. Parse each section of the command-line with the correct parser.

Parameters:

args ([str] = sys.argv[1:]) – The arguments to parse. Defaults to the command-line arguments.

print_help(args=None, fd=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]
split_args(args=None)[source]

Break the argument line into sections for each plug-in.

Parameters:

args ([str] = sys.argv[1:])

Returns:

dict[str – A dictionary with entries of an array of strings for all plug-ins plus ‘SEAMM’

Return type:

[str]]

seamm_util.argument_parser.getParser(name='SEAMM', **kwargs)[source]

Get the named command-line argument parser.

Returns:

The seamm.ArgumentParser for handling commandline and config-file parsing.

Return type:

ArgumentParser

seamm_util.argument_parser.seamm_parser(name='SEAMM')[source]

Setup the command-line argument parser for SEAMM.

Returns:

The seamm.ArgumentParser for handling commandline and config-file parsing.

Return type:

ArgumentParser

seamm_util.check_executable module

Functions for handling executables

seamm_util.check_executable.check_executable(executable)[source]

Check that an executable exists.

Check that an executable exists and is executable. If no path is given, but just the executable name, then the current path is checked. If the executable is missing or not actually executable this function raises a useful error with a message letting the user know where the path came from – a command line option, an environment variable, configuration file, or default.

Parameters:

of (executable -- required positional parameter giving the name) – the executable as a string. It can be a simple name or contain a path to the executable.

Returns:

The string for the path to the executable. If it was found on the path, the full path is returned, otherwise the return is the same as the executable string passed in.

Errors:
FileNotFoundError if the executable is not found or is not executable.

The message contains information about where the option came from, either the command-line, an environment variable, configuration file or the default.

seamm_util.compact_json_encoder module

From a gist by Jannis Mainczyk https://gist.github.com/jannismain/e96666ca4f059c3e5bc28abb711b5c92

class seamm_util.compact_json_encoder.CompactJSONEncoder(*args, **kwargs)[source]

Bases: JSONEncoder

A JSON Encoder that puts small containers on single lines.

CONTAINER_TYPES = (<class 'list'>, <class 'tuple'>, <class 'dict'>)

Container datatypes include primitives or other containers.

MAX_ITEMS = 6

Maximum number of items in container that might be put on single line.

MAX_WIDTH = 80

Maximum width of a container that might be put on a single line.

encode(o)[source]

Encode JSON object o with respect to single line lists.

property indent_str: str
iterencode(o, **kwargs)[source]

Required to also work with json.dump.

seamm_util.dictionary module

Provides a Dictionary, identical to a dict, but which can be subclassed safely.

class seamm_util.dictionary.Dictionary(*args, ordered=False, **kwargs)[source]

Bases: MutableMapping

Class that acts like a dictionary, but can safely be subclassed.

The Dictionary class implements a dictionary-like class that other classes can inherit from. In addition, __init__ accepts a keyword ‘ordered’ specifying the use of an ordered dictionary.

copy()[source]

Return a shallow copy.

classmethod fromkeys(iterable, value=None)[source]

Create a new Dictionary with keys from iterable and values set to value.

seamm_util.elemental_data module

Tabulated data about the elements.

seamm_util.include_open module

Context manager for extending file reading to handle include’s

class seamm_util.include_open.Open(filename, mode='r', logger=None, include=None, history=10)[source]

Bases: object

property depth
property filename
property lineno
property path
push(n=1)[source]

push the n last lines back onto the device (virtually)

stack()[source]

Provide the traceback of the included files

property total_lines
seamm_util.include_open.splitext(filename)[source]

Get the extension of a file, ignoring .gz or .bz2 on the end

Parameters:

filename ('str') – the name, including any path, of the file

seamm_util.md_statistics module

Helpful routine using the underlying Python functions in ‘statistics’ and ‘statsmodels’ to handle common needs in molecular modeling

seamm_util.md_statistics.analyze_autocorrelation(y, interval=1, nlags=64, method='zr', use_confidence=False)[source]

Find the statistical inefficiency, correlation time and other useful parameters given the time sequence of values ‘y’.

This function implements two approaches, ‘zr’ and ‘cspsd’ corresponding to the two papers (using the initials as the method name):

zr: Zięba, A.; Ramza, P. Standard Deviation of the Mean of Autocorrelated Observations Estimated with the Use of the Autocorrelation Function Estimated From the Data. Metrology and Measurement Systems 2011, 18 (4), 3–14.

cspsd: Chodera, J. D.; Swope, W. C.; Pitera, J. W.; Seok, C.; Dill, K. A. Use of the Weighted Histogram Analysis Method for the Analysis of Simulated and Parallel Tempering Simulations. J. Chem. Theory Comput. 2006, 3 (1), 26–41.

Parameters:
  • y ([float]) – the time sequence to analyze

  • interval (float) – the time interval between values, defaults to 1

  • nlags (int) – the number of lags to start with

  • method (str) – the approach to use, ‘zr’ or ‘cspsd’. Defaults to ‘zr’

Returns:

dict(

‘n’: (int) number of values in y ‘n_effective’: (int) effective number of uncorrelated values ‘n_c’: (int) the first zero crossing in the ACF ‘n_tau’: (int) number of intervals in the correlation time ‘tau’: (float) the correlation time if <interval> is correct ‘inefficiency’: (float) the statistical inefficiency ‘acf’: ([float]) the autocorrelation function ‘confidence_interval’: [(float, float)] the 95% confidence interval

The input parameter <nlags> is solely for performance. Since calculating the ACF is expensive (O(N^2)) and often the correlation time is short, at least if the trajectory is sampled reasonably, this function starts with a small number of lags, and doubles the number repeatedly if it does not find the zero crossing it expects.

seamm_util.md_statistics.ar1(n=1000, a=10.0, b=0.2, sigma=0.5, seed=None)[source]

Generate an AR(1) series of length n

seamm_util.output module

A class for wrapping output from the MolSSI Framework and plugins. Initially it is a thin wrapper around a dictionary to store the output, using JSON to serialize and deserialize the data.

It presents the dict api with the addition of methods to serialize and deserialize the contents.

class seamm_util.output.Output(filename=None, **kwargs)[source]

Bases: MutableMapping

copy()[source]

Return a shallow copy of the dictionary

property filename

The filename for the serialized data

seamm_util.plotting module

A package for handling plotly plots in SEAMM.

A figure comprises one or more plots (or graphs) laid out in a grid. The datasets within a plot are represetned by traces, lines, scatter plots, pie chart elements, etc.

This package consists of a Figure class which is a container, a Plot class that handles the actual plotting, and a Trace class for the individual datasets and their graphical representations. The figure class uses a grid similar to the Tk grid to control the layout of the plots.

This package does not directly interact with plotly. Rather, it uses templates and Jinja to create the JSON, HTML or other representation of a plotly figure. The various containers in this package contain dictionaries of Jinja keys and the associated values. The keys needed are defined by the template used.

class seamm_util.plotting.Axis(direction, *args, anchor=None, **kwargs)[source]

Bases: Dictionary

Class to represent an axis in a plotly plot.

The Axis class defines an axis and the associated graphical control for how to display them. The class is a dict-like object where the elements of the dictionary are the control parameters for the axis.

to_dict()[source]

Return a dictionary representing the axis.

Returns:

A dictionary of the axis data, suitable for Jinja.

Return type:

dict

class seamm_util.plotting.Figure(*args, jinja_env=None, template=None, **kwargs)[source]

Bases: Dictionary

Holds one or more subplots and controls the layout.

add_plot(name, **kwargs)[source]

Create a new plot and return it.

Parameters:

name (str) – The name of the plot, which must be unique.

Return type:

The plot object.

dump(filename)[source]

Write the filled in template to disk as <filename>.

Parameters:

filename (str or filepath) – The name or path to the file to write.

Return type:

nothing

dumps()[source]

Return the filled in template document as a string.

Merge the layout data and the traces into the template document and return a string version of the document.

Returns:

The resulting document.

Return type:

str

get_plot(name)[source]

Return the named plot.

Parameters:

name (str) – The name of the plot, which must exist.

Return type:

The plot object.

grid_plots(*args, padx=0.02, pady=0.02)[source]

Define the layout of the plots.

When there is more than one plot, they need to be laid out in a grid. This method is called to define the layout, and will follow closely the approach used in Tk grid.

Parameters:
  • *args

    Positional arguments specifying the layout of one or more rows. each row is given as a string composed of the following:

    <plot> :

    is the name of a plot.

    x :

    leaves an empty column between the plot on the left and the plot on the right.

    ^ :

    extends the row span of the plot above the ^’s in the grid. The number of ^’s in a row must match the number of columns spanned by the plot above it.

    • :

      increases the column span of the plot to the left. Several -‘s in a row will successively increase the number of columns spanned. A - may not follow a ^ or a x, nor may it be the first plot argument to grid configure.

  • **kwargs

    Keyword arguments for options for the given rows:
    padxfloat, optional

    The fraction of space to leave between plots in a row. Defaults to 0.02.

    padyfloat, optional

    The fraction of space to leave between rows. Defaults to 0.02.

property template

The template to use for this figure.

class seamm_util.plotting.Plot(left=0, right=1, top=1, bottom=0, row=0, column=0, column_span=1, row_span=1)[source]

Bases: Dictionary

Class to represent a plotly plot.

The Plot class contains Axes and Traces, which represent the datasets being plotted. This class is a dict-like object where the elements of the dictionary are the traces.

add_axis(direction, anchor=None, **kwargs)[source]

Create a new axis and return it.

Parameters:

direction (str (one of 'x', 'y', or 'z')) – The direction of this axis.

Return type:

The axis object.

add_trace(name, x_axis=None, y_axis=None, z_axis=None, **kwargs)[source]

Create a new trace and return it.

Parameters:

name (str) – The name of the trace, which must be unique.

Return type:

The trace object.

property axes

The list of axes for this plot.

class seamm_util.plotting.Trace(x_axis=None, y_axis=None, z_axis=None, **kwargs)[source]

Bases: Dictionary

Class to represent a trace in a plotly plot.

The Trace class contains the datasets and associated graphical control for how to display them. The class is a dict-like object where the elements of the dictionary are the traces.

to_dict()[source]

Return a dictionary representing the trace.

Returns:

A dictionary of the trace data, suitable for Jinja.

Return type:

dict

seamm_util.printing module

The Printer class provides control over printing output, based on the Python logging module. The levels a translated to more reasonable names for output, rather than debugging:

Level Logger Level Numeric value ——– ———— ————- JOB CRITICAL 50 IMPORTANT ERROR 40 TERSE WARNING 30 NORMAL INFO 20 VERBOSE DEBUG 10 ALL ALL 0

By default, JOB level output is mirrored in the main log for the job as well as the local log for the stage. All output from the cutoff level up, which is NORMAL by default, is placed in the local stage log. Optionally, output from a cutoff level and up is also written to the standard output.

class seamm_util.printing.FormattedText(text, dedent=True, indent='', indent_initial=True, indent_all=False, wrap=True, line_length=80, *args, **kwargs)[source]

Bases: object

Class for wrapping, formatting and indenting text to make textual output from the MolSSI Framework and its plugins easier

The __str__ method returns the formatted text, so e.g. print(<object>) formats the text and prints it as expected.

Example:

ft = FormattedText(‘’’ This is the first line. And the second. And a very, very, very, very, very, very, very, very, very, very, very, very long line. And i = ‘{i}’ and j = ‘{j}’ followed by a line break

Ending with the last line. Which can of course also be wrapped if we want it to be.

What about a list: 1

With a second item: 2

Does that work?’’’, i=1, j=2, indent=’—>’, line_length=70)

print(ft)

—>This is the first line. And the second. And a very, very, very, —>very, very, very, very, very, very, very, very, very long line. —>And i = ‘1’ and j = ‘2’ followed by a line break

—>Ending with the last line. Which can of course also be wrapped if —>we want it to be.

—> What about a list: 1

—> With a second item: 2

—>Does that work?

where the start of each arrow is aligned to the left (not indented as in this string).

class seamm_util.printing.Manager(print_root)[source]

Bases: object

There is [under normal circumstances] just one Manager instance, which holds the hierarchy of printers.

getPrinter(name)[source]

Get a printer with the specified name (channel name), creating it if it doesn’t yet exist. If a PlaceHolder existed for the specified name [i.e. the printer didn’t exist but a child of it did], replace it with the created printer and fix up the parent/child references which pointed to the placeholder to now point to the printer.

class seamm_util.printing.PlaceHolder(aprinter)[source]

Bases: object

PlaceHolder instances are used in the Manager printer hierarchy to take the place of nodes for which no printers have been defined [FIXME add example].

append(aprinter)[source]

Add the specified printer as a child of this placeholder.

class seamm_util.printing.Printer(name, level=0)[source]

Bases: Filterer

Provide controlled printing for plugins for the MolSSI Framework.

addHandler(hdlr)[source]

Add the specified handler to this printer.

callHandlers(record)[source]

Loop through all handlers for this printer and its parents in the printer hierarchy. If no handler was found, output a one-off error message to sys.stderr. Stop searching up the hierarchy whenever a printer with the “propagate” attribute set to zero is found - that will be the last printer whose handlers are called.

property disabled
findCaller()[source]

Find the stack frame of the caller so that we can note the source file name and line number.

getEffectiveLevel()[source]

Loop through this printer and its parents in the printer hierarchy, looking for a non-zero logging level. Return the first one found.

handle(record)[source]

Call the handlers for the specified record. This method is used for unpickled records received from a socket, as well as those created locally. Logger-level filtering is applied.

property handlers
important(msg, *args, **kwargs)[source]

Logs a message with level IMPORTANT on this printer. The msg is the message format string, and the args are the arguments which are merged into msg using the string formatting operator. (Note that this means that you can use keywords in the format string, together with a single dictionary argument.)

isEnabledFor(lvl)[source]

Is this printer enabled for level lvl?

job(msg, *args, **kwargs)[source]

Logs a message with level JOB on this printer. The msg is the message format string, and the args are the arguments which are merged into msg using the string formatting operator. (Note that this means that you can use keywords in the format string, together with a single dictionary argument.)

property level
makeRecord(name, lvl, fn, lno, msg, args, exc_info)[source]

A factory method which can be overridden in subclasses to create specialized LogRecords.

manager = <seamm_util.printing.Manager object>
property name
normal(msg, *args, **kwargs)[source]

Logs a message with level NORMAL on this printer. The msg is the message format string, and the args are the arguments which are merged into msg using the string formatting operator. (Note that this means that you can use keywords in the format string, together with a single dictionary argument.)

property parent
print(lvl, msg, *args, **kwargs)[source]

Prints a message with integer level lvl on this logger. The other arguments are interpreted as for verbose().

print_root = <seamm_util.printing.RootPrinter object>
property propagate
removeHandler(hdlr)[source]

Remove the specified handler from this printer.

setLevel(lvl)[source]

Set the printing level of this printer.

terse(msg, *args, **kwargs)[source]

Logs a message with level TERSE on this printer. The msg is the message format string, and the args are the arguments which are merged into msg using the string formatting operator. (Note that this means that you can use keywords in the format string, together with a single dictionary argument.)

verbose(msg, *args, **kwargs)[source]

Logs a message with level VERBOSE on this printer. The msg is the message format string, and the args are the arguments which are merged into msg using the string formatting operator. (Note that this means that you can use keywords in the format string, together with a single dictionary argument.)

class seamm_util.printing.RootPrinter(lvl)[source]

Bases: Printer

A root printer is not that different to any other printer, except that it must have a printing level and there is only one instance of it in the hierarchy.

seamm_util.printing.addLevelName(lvl, levelName)[source]

Associate ‘levelName’ with ‘lvl’. This is used when converting levels to text during message formatting.

seamm_util.printing.basicConfig()[source]

Do basic configuration for the printing system by creating a StreamHandler with a default Formatter and adding it to the root logger.

seamm_util.printing.disable(level)[source]

Disable all printing calls less severe than ‘level’.

seamm_util.printing.fileConfig(fname)[source]

Read the printing configuration from a ConfigParser-format file. This can be called several times from an application, allowing an end user the ability to select from various pre-canned configurations (if the developer provides a mechanism to present the choices and load the chosen configuration). In versions of ConfigParser which have the readfp method [typically shipped in 2.x versions of Python], you can pass in a file-like object rather than a filename, in which case the file-like object will be read using readfp.

seamm_util.printing.getLevelName(lvl)[source]

Return the textual representation of printing level ‘lvl’. If the level is one of the predefined levels (JOB, IMPORTANT, TERSE, NORMAL, VERBOSE) then you get the corresponding string. If you have associated levels with names using addLevelName then the name you have associated with ‘lvl’ is returned. Otherwise, the string “Level %s” % lvl is returned.

seamm_util.printing.getPrinter(name=None)[source]

Return a printer with the specified name, creating it if necessary. If no name is specified, return the root printer.

seamm_util.printing.important(msg, *args, **kwargs)[source]

Log a message with severity ‘IMPORTANT’ on the root printer.

seamm_util.printing.job(msg, *args, **kwargs)[source]

Log a message with severity ‘JOB’ on the root printer.

seamm_util.printing.normal(msg, *args, **kwargs)[source]

Log a message with severity ‘NORMAL’ on the root printer.

seamm_util.printing.setPrinterClass(klass)[source]

Set the class to be used when instantiating a printer. The class should define __init__() such that only a name argument is required, and the __init__() should call Printer.__init__()

seamm_util.printing.shutdown()[source]

Perform any cleanup actions in the printing system (e.g. flushing buffers). Should be called at application exit.

seamm_util.printing.terse(msg, *args, **kwargs)[source]

Log a message with severity ‘TERSE’ on the root printer.

seamm_util.printing.verbose(msg, *args, **kwargs)[source]

Log a message with severity ‘VERBOSE’ on the root printer.

seamm_util.seamm_file module

A class for wrapping output from the MolSSI Framework and plugins. Initially it is a thin wrapper around a dictionary to store the output, using JSON to serialize and deserialize the data.

It presents the dict api with the addition of methods to serialize and deserialize the contents.

class seamm_util.seamm_file.File(filename, mode, compression=None, organization='MolSSI', filetype=None, version=None)[source]

Bases: object

read_header()[source]

seamm_util.seamm_json module

Extend JSON encoding/decoding to handle pint Quantities, as well as datetimes and timedeltas

To encode:

import seamm_util dump = json.dumps(<variable>, cls=seamm_util.JSONEncoder)

and to decode:

import seamm_util decoder = seamm_util.JSONDecoder() <variable> = decoder.decode(dump)

Adapted from http://taketwoprogramming.blogspot.com/2009/06/subclassing-jsonencoder-and-jsondecode

class seamm_util.seamm_json.JSONDecoder[source]

Bases: JSONDecoder

Decodes a json string, where pint Quantities, datetime and timedelta objects were converted into objects using the seamm_util.JSONEncoder, back into a python object.

dict_to_object(d)[source]
class seamm_util.seamm_json.JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: JSONEncoder

Encodes a python object, where pint Quantities, datetime and timedelta objects are converted into objects that can be decoded using the seamm_util.JSONDecoder.

Adapted from http://taketwoprogramming.blogspot.com/2009/06/subclassing-jsonencoder-and-jsondecoder.html # noqa: E501

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)

seamm_util.seamm_util module

Main module.

seamm_util.units module

Localize the unit handling.

seamm_util.units.default_units(units_or_dimensions)[source]

Return the default units.

Parameters:

units_or_dimensions (str) – The units or dimensionality.

Returns:

The list of unit strings.

Return type:

[str]

seamm_util.variable_names module

Utility routines to help with variable names for scripts

seamm_util.variable_names.clean(raw_name)[source]

Fix up an input string so that it is a valid variable name

seamm_util.variable_names.is_valid(name)[source]

Check if a variable name is valid and is not a keyword

seamm_util.variable_names.iskeyword()

x.__contains__(y) <==> y in x.

seamm_util.water_models module

Various water models.

class seamm_util.water_models.SPC[source]

Bases: Water

atom_types()[source]

The atom types for this model.

Returns:

types – 3-vector of atom types

Return type:

str[3]

class seamm_util.water_models.SPC_E[source]

Bases: Water

atom_types()[source]

The atom types for this model.

Returns:

types – 3-vector of atom types

Return type:

str[3]

reference()[source]
class seamm_util.water_models.TIP3P[source]

Bases: Water

atom_types()[source]

The atom types for this model.

Returns:

types – 3-vector of atom types

Return type:

str[3]

class seamm_util.water_models.Water(r0, theta0, qO=None, qH=None, lj_a=None, lj_b=None)[source]

Bases: object

Generic water model

coordinates()[source]

A standard set of coordinates in Angstrom

The oxygen is at the origin, with the hydrogens in the x-z plane. Z is the two-fold axis of symmetry.

Return type:

Tuple of three tuples with (x, y z)

static create_model(model_name)[source]

Static method to simplify constructing models for string names.

static find_waters(system)[source]

Find the water molecules in the given system.

At the moment, the atoms are 0-based, but the bonds are given using 1-based atom numbers!

Parameters:

system (System object)

property mass
pdb()[source]

The contents of a PDB file for this model.

Returns:

pdb – The contents of a PDB file for this model.

Return type:

str

system()[source]

Return the model as a SEAMM system.

Returns:

system

Return type:

SEAMM system

seamm_util.zenodo module

Interact with Zenodo via its REST API

class seamm_util.zenodo.Record(data, token)[source]

Bases: Mapping

A class for handling uploading a record to Zenodo.

data

The record data from Zenodo. See https://developers.zenodo.org/#depositions

Type:

dict()

token

The Zenodo access token for the user.

Type:

str

metadata

The metadata for updating the record.

Type:

dict()

add_creator(name, affiliation=None, orcid=None, ignore_duplicates=False)[source]

Add a creator (author) to the record.

Parameters:
  • name (str) – The creators name as “family name, other names”

  • affiliation (str, optional) – The creators affiliation (University, company,…)

  • orcid (str, optional) – The ORCID id of the creator.

  • ignore_duplicates (bool = False) – Silently ignore duplicate records.

add_file(path, contents=None, binary=False)[source]

Add the given file to the record.

Parameters:
  • path (str or pathlib.Path) – The path to the file to upload.

  • binary (bool = False) – Whether to open as a binary file.

add_keyword(keyword)[source]

Add a keyword to the record.

Parameters:

keyword (str) – The keyword

property authors

Synonym for creators

property conceptdoi

The generic concept DOI.

property creators

The creators for the record.

property description

The description for the record.

property doi

The (prereserved) DOI.

download_file(filename, path)[source]

Download a file to a local copy.

Parameters:
  • filename (str) – The name of the file.

  • path (pathlib.Path) – The path to download the file to. Can be a directory in which case the filename is used in that directory.

Returns:

The path to the downloaded file.

Return type:

pathlib.Path

files()[source]

List of the files deposited.

Return type:

[str]

get_file(filename)[source]

Get the contents of a file.

Parameters:

filename (str) – The name of the file.

Return type:

str or byte

property in_progress

Whether the deposition is still in progress, i.e. editable.

Return type:

bool

property keywords

The keywords for the record.

publish()[source]

Publish the record on Zenodo.

This registers the DOI, and after this the files cannot be changed. Any new metadata is uploaded before publishing.

remove_file(filename)[source]

Remove a file.

Parameters:

filename (str) – The name of the file.

remove_keyword(keyword)[source]

Remove a keyword from the record.

Parameters:

keyword (str) – The keyword

property submitted

Whether the record has been submitted.

If so the files can’t be changed, but it may be possible to edit the metadata.

Return type:

bool

property title

The title for the record.

update_metadata()[source]

Update the metadata for the record in Zenodo.

property upload_type

The type of record in Zenodo.

class seamm_util.zenodo.Zenodo(token=None, configfile='~/.seamm.d/seammrc', use_sandbox=False)[source]

Bases: object

add_version(_id)[source]

Create a new record object for uploading a new version to Zenodo.

create_record()[source]

Create a new record object for uploading to Zenodo.

get_deposit_record(_id)[source]

Get an existing deposit record object from Zenodo.

get_record(_id)[source]

Get an existing record object from Zenodo.

search(authors=None, query='', communities=None, keywords=None, title=None, description=None, all_versions=False, size=25, page=1)[source]

Search for records in Zenodo.

property token

The appropriate token for Zenodo.

Module contents

seamm_util Utility functions for the SEAMM environment.