def gen_plate_layout(cols): pp=[] for col in range(1, cols + 1): for row in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']: pp.append(row + str(col)) return pp PLATE_POSITIONS = gen_plate_layout(12) your_list = ['h3', 'a4', 'b4', 'c4', 'd4', 'e4', 'f4', 'g4', 'h4', 'a5'] #your_list = ['B3', 'C1', 'G3', 'B2'] def plate_target(well): targets_base = [0, 8, 16, 24, 32, 40] well_index = PLATE_POSITIONS.index(well) well_col = well_index/8 well_row = well_index % 8 plate = well_col/2 + 1 if (well_col - 1) % 2: #odd columns (ie w/ even column indexes) targets_indexes = [x + well_row for x in targets_base] else: targets_indexes = [48 + x + well_row for x in targets_base] #print targets_indexes return {'plate': plate, 'target': [PLATE_POSITIONS[index] for index in targets_indexes] } your_list = [i.upper() for i in your_list] plates_and_targets = map(plate_target, your_list) print plates_and_targets print "====================" plates = [] for p in [1,2,3]: print "Plate " + str(p) for t in [d['target'] for d in plates_and_targets if d['plate'] == p]: print t print ""
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question