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:unit object
10000010.0:microliter
10.0:microliter / second
0.036:liter / hour
Return type:Unit
__str__(ndigits=12)
Parameters:ndigits (int, optional) – Number of decimal places to round to, useful for numerical precision reasons
Returns:This rounds the string presentation to 12 decimal places by default to account for the majority of numerical precision issues
Return type:str
ceil()

Equivalent of math.ceil(Unit) for python 2 compatibility

Returns:ceil of Unit
Return type:Unit
floor()

Equivalent of math.floor(Unit) for python 2 compatibility

Returns:floor of Unit
Return type:Unit
round(ndigits)

Equivalent of round(Unit) for python 2 compatibility

Parameters:ndigits (int) – number of decimal places to be rounded to
Returns:rounded unit
Return type:Unit

autoprotocol.util

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. Currently supports plate reader instructions and could be extended for use with other instructions.

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

Dictionary of incubate parameters

Return type:

dict

Raises:

RuntimeError – Specifying only shake amplitude or shake orbital

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 or 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
Returns:

Dictionary of band parameters

Return type:

dict

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 or 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
Returns:

Dictionary of gel extract parameters

Return type:

dict

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_dict)

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": []
      }
    }
  ]
}