autoprotocol/autoprotocol-python

catching incorrect transfers and provision operations

scottbecker opened this issue · 1 comments

The following methods need to check if the source wells have either too little volume before the operation and/or the destination volumes have too much volume after the operation. Otherwise, you can accidentally create negative volumes and overflow wells.

transfer, consolidate, distribute, stamp

provision, dispense

Here are some helper methods I have used inside of custom versions of these:


def ensure_list(potential_item_or_items):
    try:
        some_object_iterator = iter(potential_item_or_items)
    except TypeError:
        return [potential_item_or_items]
    return list(potential_item_or_items)
...
 def _assert_safe_to_pipette_from(self, sources):
        sources = ensure_list(sources)
        if not all([well.volume >= get_well_safe_volume(well) for well in sources]):
            raise Exception('Not safe to pipette from %s'%sources)

    def _assert_valid_add_volume(self, dests):
        dests = ensure_list(dests)
        if not all([well.volume <= get_well_max_volume(well) for well in dests]):
            raise Exception('Too much liquid added to dests: %s'%dests)            

    def _assert_valid_transfer(self, sources, dests):
        sources = ensure_list(sources)
        if not all([well.volume >= get_well_dead_volume(well) for well in sources]):
            raise Exception('Too much liquid drawn from sources: %s'%sources)
        self._assert_valid_add_volume(dests)

Sorry for the late response, but this has already been resolved and is no longer valid due to the deprecation of most of these functions