Skip to content

Commit

Permalink
Basic validation of uploaded sequencing results
Browse files Browse the repository at this point in the history
  • Loading branch information
alubbock committed Oct 4, 2023
1 parent d29075f commit fb72916
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
19 changes: 19 additions & 0 deletions backend/antigenapi/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,10 +596,29 @@ def upload_sequencing_run_results(self, request, pk, submission_idx):
raise ValidationError("file", "Results file should be a .zip file")

# TODO: Validate submission_idx
try:
sr = SequencingRun.objects.get(pk=int(pk))
except SequencingRun.DoesNotExist:
raise ValidationError(
f"Sequencing run {pk} does not exist " "to attach results"
)

wells = [w["location"] for w in sr.wells if w["plate"] == int(submission_idx)]
if not wells:
raise ValidationError(
f"Plate index {submission_idx} not found in " "sequencing run {pk}"
)

# Run bioinformatics using .zip file
# print("Extracting zip file...")
seq_data = load_sequences(results_file.temporary_file_path())
if len(seq_data) != len(wells):
raise ValidationError(
{
"file": f"Upload contains data for {len(seq_data)} "
f"wells, expected {len(wells)}"
}
)

# Convert to FASTA in-memory (vquest api handles chunking to
# max 50 seqs per file)
Expand Down
1 change: 1 addition & 0 deletions frontend/src/crudtemplates/ViewObjectPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ const ViewObjectPage = (props) => {
displayField(field, record, "ViewObjectPage", {
setRecord: setRecord,
setLoading: setLoading,
setError: props.onSetError,
})}
{loading && (
<div className="h-2.5 bg-gray-300 w-12 rounded-full mb-2.5 rounded shadow animate-pulse"></div>
Expand Down
12 changes: 11 additions & 1 deletion frontend/src/crudtemplates/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,17 @@ export const uploadSequencingResults = (event, props) => {
).then((res) => {
props.setLoading(false);
res.json().then((json) => {
props.setRecord(json);
if (res.status >= 200 && res.status < 300) {
props.setRecord(json);
} else {
if (typeof json === "string") {
props.setError(json);
} else if ("file" in json) {
props.setError("Problem with file: " + json["file"]);
} else {
props.setError("Error code " + res.status);
}
}
});
});
};
Expand Down

0 comments on commit fb72916

Please sign in to comment.