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
magnitude

Quantity’s magnitude. Long form for m

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.is_valid_well()

autoprotocol.util.is_valid_well(well)

Checks if an input is of type Well, WellGroup or list of type Well.

Example Usage:

if not is_valid_well(source):
    raise TypeError("Source must be of type Well, list of Wells, or "
                    "WellGroup.")
Parameters:well (Well or WellGroup or list(Well)) – Parameter to validate is type Well, WellGroup, list of Wells.
Returns:Returns True if param is of type Well, WellGroup or list of type Well.
Return type:bool

util.parse_unit()

autoprotocol.util.parse_unit(unit, accepted_unit=None)

Parses and checks unit provided and ensures its of valid type and dimensionality.

Note that this also checks against the dimensionality of the accepted_unit. I.e. parse_unit(“1:s”, “minute”) will return True.

Raises type errors if the Unit provided is invalid.

Parameters:
  • unit (Unit or str) – Input to be checked
  • accepted_unit (Unit or str or list(Unit) or list(str), optional) – Dimensionality of unit should match against the accepted unit(s).

Examples

parse_unit("1:ul", "1:ml")
parse_unit("1:ul", "ml")
parse_unit("1:ul", ["ml", "kg"])
Returns:Parsed and checked unit
Return type:Unit
Raises:TypeError – Error when input does not match expected type or dimensionality

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