Skip to content

Instantly share code, notes, and snippets.

@laserson
Last active March 30, 2018 02:23
Show Gist options
  • Save laserson/367eb9f8eff162d9b0d9d604f2b5296c to your computer and use it in GitHub Desktop.
Save laserson/367eb9f8eff162d9b0d9d604f2b5296c to your computer and use it in GitHub Desktop.
Fix for containers file to reorder based on wells.
import json
from copy import deepcopy
from itertools import product
from collections import OrderedDict
all_wells = ['{}{}'.format(r, c) for c in range(1, 13) for r in 'ABCDEFGH']
with open('_containers_create.json.bak','r') as ip:
obj = json.load(ip)
for container_name in obj['containers']:
container = obj['containers'][container_name]
unordered_locations = deepcopy(container['locations'])
container['locations'] = OrderedDict()
for well in all_wells:
container['locations'][well] = unordered_locations[well]
with open('_containers_create.json','w') as op:
json.dump(obj, op)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment