Mid code cleanup
This commit is contained in:
@@ -541,28 +541,30 @@ class DocxWriter(object):
|
||||
@classmethod
|
||||
def create_plate_map(self, sample_list: List[dict], rows: int = 0, columns: int = 0) -> List[list]:
|
||||
sample_list = sorted(sample_list, key=itemgetter('column', 'row'))
|
||||
# NOTE if rows or samples is default, set to maximum value in sample list
|
||||
if rows == 0:
|
||||
rows = max([sample['row'] for sample in sample_list])
|
||||
if columns == 0:
|
||||
columns = max([sample['column'] for sample in sample_list])
|
||||
# output = []
|
||||
for row in range(0, rows):
|
||||
contents = [''] * columns
|
||||
for column in range(0, columns):
|
||||
try:
|
||||
ooi = [item for item in sample_list if item['row'] == row + 1 and item['column'] == column + 1][0]
|
||||
except IndexError:
|
||||
continue
|
||||
contents[column] = ooi['submitter_id']
|
||||
# contents = [sample['submitter_id'] for sample in sample_list if sample['row'] == row + 1]
|
||||
# contents = [f"{sample['row']},{sample['column']}" for sample in sample_list if sample['row'] == row + 1]
|
||||
if len(contents) < columns:
|
||||
contents += [''] * (columns - len(contents))
|
||||
if not contents:
|
||||
contents = [''] * columns
|
||||
# NOTE: Create a list with length equal to columns length
|
||||
# contents = [''] * columns
|
||||
contents = [next((item['submitter_id'] for item in sample_list if item['row'] == row + 1 and
|
||||
item['column'] == column + 1), '') for column in range(0, columns)]
|
||||
# for column in range(0, columns):
|
||||
# contents[column] = next((item['submitter_id'] for item in sample_list if item['row'] == row + 1 and item['column'] == column), '')
|
||||
# try:
|
||||
# # ooi = [item for item in sample_list if item['row'] == row + 1 and item['column'] == column + 1][0]
|
||||
# ooi = next(item for item in sample_list if item['row'] == row + 1 and item['column'] == column)
|
||||
# except StopIteration:
|
||||
# continue
|
||||
# contents[column] = ooi['submitter_id']
|
||||
# NOTE: Pad length of contents to reflect columns
|
||||
# if len(contents) < columns:
|
||||
# contents += [''] * (columns - len(contents))
|
||||
# if not contents:
|
||||
# contents = [''] * columns
|
||||
yield contents
|
||||
# output.append(contents)
|
||||
# return output
|
||||
|
||||
def create_merged_template(self, *args) -> BytesIO:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user