BioSimSpace.Gateway.Node

class BioSimSpace.Gateway.Node(description, name=None)

A class for interfacing with BioSimSpace nodes.

Nodes are used to collect and validate user input, document the intentions of the workflow component, track and report errors, and validate output. Once written, a node can be run from within Jupyter, from the command-line, or plugged into a workflow engine, such as Knime.

Example

A generic energy minimisation node:

>>> import BioSimSpace as BSS
>>> node = BSS.Gateway.Node("Perform energy minimisation")
>>> node.addAuthor(name="Lester Hedges", email="lester.hedges@bristol.ac.uk", affiliation="University of Bristol")
>>> node.setLicence("GPLv3")
>>> node.addInput("files", BSS.Gateway.FileSet(help="A set of molecular input files."))
>>> node.addInput("steps", BSS.Gateway.Integer(help="The number of minimisation steps.", minimum=0, maximum=100000, default=10000))
>>> node.addOutput("minimised", BSS.Gateway.FileSet(help="The minimised molecular system."))
>>> node.showControls()
>>> system = BSS.IO.readMolecules(node.getInput("files"))
>>> protocol = BSS.Protocol.Minimisation(steps=node.getInput("steps"))
>>> process = BSS.MD.run(system, protocol)
>>> node.setOutput("minimised", BSS.IO.saveMolecules("minimised", process.getSystem(block=True), system.fileFormat()))
>>> node.validate()
__init__(description, name=None)

Constructor.

Parameters:
  • description (str) – A description of the node.
  • name (str) – The name of the node.

Methods

__init__(description[, name]) Constructor.
addAuthor([name, email, affiliation]) Add an author for the node.
addError(error) Add an error message.
addInput(name, input) Add an input requirement.
addOutput(name, output) Add an output requirement.
getAuthors() Return the list of authors.
getInput(name) Get the value of the named input.
getInputs() Get all of the input requirements.
getLicense() Return the license.
setLicense(license) Set the license for the node.
setOutput(name, value) Set the value of an output.
showControls() Show the Jupyter widget GUI to allow the user to enter input.
validate([file_prefix]) Whether the output requirements are satisfied.
addAuthor(name=None, email=None, affiliation=None)

Add an author for the node.

Parameters:
  • name (str) – The author’s name.
  • email (str) – The author’s email address.
  • affiliation (str) – The author’s affiliation.
addError(error)

Add an error message.

Parameters:error (str) – The error message.
addInput(name, input)

Add an input requirement.

Parameters:
  • name (str) – The name of the input.
  • input (Requirement) – The input requirement object.
addOutput(name, output)

Add an output requirement.

Parameters:
  • name (str) – The name of the output.
  • output (Requirement) – The output requirement object.
getAuthors()

Return the list of authors.

Returns:authors – A list of author dictionaries.
Return type:[dict]
getInput(name)

Get the value of the named input.

Parameters:name (str) – The name of the input requirement.
Returns:The value of the named input requirement.
Return type:input
getInputs()

Get all of the input requirements.

Returns:inputs – The dictionary of input requirements.
Return type:{ str : Requirement }
getLicense()

Return the license.

Returns:license – The license of the node.
Return type:str
setLicense(license)

Set the license for the node.

Parameters:license (str) – The license type.
setOutput(name, value)

Set the value of an output.

Parameters:
  • name (str) – The name of the output.
  • value – The value of the output.
showControls()

Show the Jupyter widget GUI to allow the user to enter input.

Returns:controls – A gui control panel for setting input requirements.
Return type:ipywidgets.form
validate(file_prefix='output')

Whether the output requirements are satisfied.

Parameters:file_prefix (str) – The prefix of the output file name.
Returns:output – If running interatvely: A link to a zipfile containing the validated output, else the name of a YAML file containing the node output.
Return type:IPython.lib.display.FileLink, str