autoprotocol support

autoprotocol.unit

unit.Unit

class autoprotocol.unit.Unit(value, units=None)

A representation of a measure of physical quantities such as length, mass, time and volume. Uses Pint’s Quantity as a base class for implementing units and inherits functionalities such as conversions and proper unit arithmetic. Note that the magnitude is stored as a double-precision float, so there are inherent issues when dealing with extremely large/small numbers as well as numerical rounding for non-base 2 numbers.

Example

vol_1 = Unit(10, 'microliter')
vol_2 = Unit(10, 'liter')
print(vol_1 + vol_2)

time_1 = Unit(1, 'second')
speed_1 = vol_1/time_1
print (speed_1)
print (speed_1.to('liter/hour'))
Returns:10000010.0:microliter 10.0:microliter / second 0.036:liter / hour
Return type:

Unit.fromstring()

static Unit.fromstring(s)

Convert a string representation of a unit into a Unit object.

Example

Unit.fromstring("10:microliter")

becomes

Unit(10, "microliter")
Parameters:s (str) – String in the format of “value:unit”

autoprotocol.util

util.make_dottable_dict

class autoprotocol.util.make_dottable_dict

Enable dictionaries to be accessed using dot notation instead of bracket notation. This class should probably never be used.

Example

>>> d = {"foo": {
            "bar": {
                "bat": "Hello!"
                }
            }
        }

>>> print d["foo"]["bar"]["bat"]
Hello!

>>> d = make_dottable_dict(d)

>>> print d.foo.bar.bat
Hello!
Parameters:dict (dict) – Dictionary to be made dottable.

util.deep_merge_params()

autoprotocol.util.deep_merge_params(defaults, override)

Merge two dictionaries while retaining common key-value pairs.

Parameters:
  • defaults (dict) – Default dictionary to compare with overrides.
  • override (dict) – Dictionary containing additional keys and/or values to override those corresponding to keys in the defaults dicitonary.

util.incubate_params()

autoprotocol.util.incubate_params(duration, shake_amplitude=None, shake_orbital=None)

Create a dictionary with incubation parameters which can be used as input for instructions. Currenly supports plate reader instructions and could be extended for use with other instructions.

Parameters:
  • shake_amplitude (str, Unit) – amplitude of shaking between 1 and 6:millimeter
  • shake_orbital (bool) – True for oribital and False for linear shaking
  • duration (str, Unit) – time for shaking

util.make_band_param()

autoprotocol.util.make_band_param(elution_buffer, elution_volume, max_bp, min_bp, destination)

Support function to generate gel extraction parameters The Protocol.gel_purify() instruction requires band parameters for extraction, which this function will generate.

Parameters:
  • elution_buffer (str) – Elution buffer to use to retrieve band
  • elution_volume (str, Unit) – Volume to elute band into
  • max_bp (int) – Max basepairs of band
  • min_bp (int) – Min basepairs of band
  • destination (Well) – Well to place extracted band into

util.make_gel_extract_params()

autoprotocol.util.make_gel_extract_params(source, band_list, lane=None, gel=None)

Support function to generate gel extraction parameters The Protocol.gel_purify() instruction requires a list of extraction parameters, which this function helps to generate.

Parameters:
  • source (well) – Source well for the extraction
  • band_list (list, dict) – List of bands to collect from the source (use make_band_param to make a band dictionary)
  • lane (int, optional) – Lane to load and collect the source. If not set, lane will be auto-generated
  • gel (int, optional) – Gel to load and collect the source. If not set, gel will be auto-generated

autoprotocol.harness

harness.run()

autoprotocol.harness.run(fn, protocol_name=None, seal_after_run=True)

Run the protocol specified by the function.

If protocol_name is passed, use preview parameters from the protocol with the matching “name” value in the manifest.json file to run the given function. Otherwise, take configuration JSON file from the command line and run the given function.

Parameters:
  • fn (function) – Function that generates Autoprotocol
  • protocol_name (str, optional) – str matching the “name” value in the manifest.json file
  • seal_after_run (bool, optional) – Implicitly add a seal/cover to all stored refs within the protocol using seal_on_store()

harness.seal_on_store()

autoprotocol.harness.seal_on_store(protocol)

Implicitly adds seal/cover instructions to the end of a run for containers that do not have a cover. Cover type applied defaults first to “seal” if its within the capabilities of the container type, otherwise to “cover”.

Example Usage:

def example_method(protocol, params):
cont = params['container']
p.transfer(cont.well("A1"), cont.well("A2"), "10:microliter")
p.seal(cont)
p.unseal(cont)
p.cover(cont)
p.uncover(cont)

Autoprotocol Output:

{
  "refs": {
    "plate": {
      "new": "96-pcr",
      "store": {
        "where": "ambient"
      }
    }
  },
  "instructions": [
    {
      "groups": [
        {
          "transfer": [
            {
              "volume": "10.0:microliter",
              "to": "plate/1",
              "from": "plate/0"
            }
          ]
        }
      ],
      "op": "pipette"
    },
    {
      "object": "plate",
      "type": "ultra-clear",
      "op": "seal"
    },
    {
      "object": "plate",
      "op": "unseal"
    },
    {
      "lid": "universal",
      "object": "plate",
      "op": "cover"
    },
    {
      "object": "plate",
      "op": "uncover"
    },
    {
      "type": "ultra-clear",
      "object": "plate",
      "op": "seal"
    }
  ]
}

harness.Manifest

class autoprotocol.harness.Manifest(json)

Object representation of a manifest.json file

Parameters:object (JSON object) –

A manifest.json file with the following format:

{
  "format": "python",
  "license": "MIT",
  "description": "This is a protocol.",
  "protocols": [
    {
      "name": "SampleProtocol",
      "version": 1.0.0,
      "command_string": "python sample_protocol.py",
      "preview": {
        "refs":{},
        "parameters": {},
      "inputs": {},
      "dependencies": []
    }
  ]
}