Exemplo n.º 1
0
def _get_labware(command):
    containers = []
    instruments = []
    modules = []
    interactions = []

    location = command.get('location')
    instrument = command.get('instrument')

    placeable = location
    if (type(location) == tuple):
        placeable = location[0]

    maybe_module = _get_parent_module(placeable)
    modules.append(maybe_module)

    locations = command.get('locations')

    if location:
        containers.append(get_container(location))

    if locations:
        list_of_locations = location_to_list(locations)
        containers.extend(
            [get_container(location) for location in list_of_locations])

    containers = [c for c in containers if c is not None]
    modules = [m for m in modules if m is not None]

    if instrument:
        instruments.append(instrument)
        interactions.extend(
            [(instrument, container) for container in containers])

    return instruments, containers, modules, interactions
Exemplo n.º 2
0
def stringify_location(location):
    def get_slot(location):
        trace = location.get_trace()
        for item in trace:
            if isinstance(item, Slot):
                return item

    type_to_text = {
        Slot: 'slot',
        Container: 'container',
        Well: 'well'
    }

    # Coordinates only
    if location is None:
        return '?'

    location = location_to_list(location)
    multiple = len(location) > 1

    return '{object_text}{suffix} {first}{last} in "{slot_text}"'.format(
            object_text=type_to_text[type(location[0])],
            suffix='s' if multiple else '',
            first=location[0].get_name(),
            last='...'+location[-1].get_name() if multiple else '',
            slot_text=get_slot(location[0]).get_name()
        )
Exemplo n.º 3
0
def consolidate(instrument, volume, source, dest):
    text = 'Consolidating {volume} from {source} to {dest}'.format(
        volume=volume,
        source=stringify_location(source),
        dest=stringify_location(dest)
    )
    # incase either source or dest is list of tuple location
    # strip both down to simply lists of Placeables
    locations = [] + location_to_list(source) + location_to_list(dest)
    return make_command(
        name=types.CONSOLIDATE,
        payload={
            'instrument': instrument,
            'locations': locations,
            'volume': volume,
            'source': source,
            'dest': dest,
            'text': text
        }
    )