Last active
March 30, 2018 02:23
-
-
Save laserson/367eb9f8eff162d9b0d9d604f2b5296c to your computer and use it in GitHub Desktop.
Fix for containers file to reorder based on wells.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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