BioSimSpace.Gateway.Node#

class BioSimSpace.Gateway.Node(description, name=None)[source]#

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@openbiosim.org", affiliation="OpenBioSim")
>>> 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)[source]#

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)[source]#

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)[source]#

Add an error message.

Parameters:

error (str) – The error message.

addInput(name, input)[source]#

Add an input requirement.

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

  • input (Requirement) – The input requirement object.

addOutput(name, output)[source]#

Add an output requirement.

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

  • output (Requirement) – The output requirement object.

getAuthors()[source]#

Return the list of authors.

Returns:

authors – A list of author dictionaries.

Return type:

[dict]

getInput(name)[source]#

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()[source]#

Get all of the input requirements.

Returns:

inputs – The dictionary of input requirements.

Return type:

{ str : Requirement }

getLicense()[source]#

Return the license.

Returns:

license – The license of the node.

Return type:

str

setLicense(license)[source]#

Set the license for the node.

Parameters:

license (str) – The license type.

setOutput(name, value)[source]#

Set the value of an output.

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

  • value – The value of the output.

showControls()[source]#

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')[source]#

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