Skip to content

Add Barcodes to Existing Kits#110

Closed
cassidysymons wants to merge 20 commits intomasterfrom
csymons_add_barcodes
Closed

Add Barcodes to Existing Kits#110
cassidysymons wants to merge 20 commits intomasterfrom
csymons_add_barcodes

Conversation

@cassidysymons
Copy link
Copy Markdown
Collaborator

@cassidysymons cassidysymons commented Dec 16, 2024

This PR addresses two related needs:

  1. It allows an admin to add barcodes to existing kits, either by providing barcodes or allowing the system to generate novel barcodes.
  2. It enhances the kit creation process by allowing the admin to create kits with a mix of admin-provided barcodes (e.g. matrix tubes with pre-determined barcodes) and system-generated barcodes.

The corresponding microsetta-private-api PR is biocore/microsetta-private-api#590

Copy link
Copy Markdown
Member

@wasade wasade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the uncertainty about why this is needed raised on the other PR, I'm concerned here particularly with the handling of the kit ID and barcodes files

Comment on lines +585 to +590
start_index = result.find("Key")
if start_index != -1:
error_message = result[start_index:]
error_message = error_message[:44]
else:
error_message = result
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Comment on lines +602 to +606
for kit_index, row in kits.iterrows():
sample_barcodes = row['sample_barcodes']
for sample_index in range(len(sample_barcodes)):
kits.at[kit_index, f'barcode_{sample_index + 1}'] = \
sample_barcodes[sample_index]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a logical join or concat operation, could it be re-expressed as that? The iteration and subsequent elementwise calls to .at are inefficient, and though this is an administrative interface, it would disrupt wet lab technicians if the web server is locked up.


def _read_csv_file(file):
content = file.read().decode('utf-8-sig')
return [row[0] for row in csv.reader(io.StringIO(content),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're already using Pandas, shouldn't we fallback on its parser?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this doesn't really "_read_csv_file" but rather just expects an individual string per line?

kit_ids = _read_csv_file(kit_ids_file)
if 'barcodes_file' in request.files:
# User provided barcodes
barcodes = _read_csv_file(request.files['barcodes_file'])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The barcodes are provided in a different file than the kit IDs? What's the schema of these files, and if the kit ID is a key between them, can that be enforced?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_read_csv_file will produce [list, of, barcodes, ]. A few lines above, it will also produce [list, of, kit, ids, ].

If kit_ids has len() > 1, how is it determined which barcode is associated with which kit?


with tempfile.NamedTemporaryFile(
mode='w',
delete=False,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will the temp file be deleted? Why not just use StringIO or BytesIO and avoid tmp?

<tr>
<td colspan="2">
<br />
Upload comma-separated value file(s) (CSV)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't describe anything about what these files should contain or how they should be structured

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants