diff --git a/backend/antigenapi/views.py b/backend/antigenapi/views.py index 8087ca2..8b2f87b 100644 --- a/backend/antigenapi/views.py +++ b/backend/antigenapi/views.py @@ -1,4 +1,5 @@ import collections.abc +import io import os import urllib.error import urllib.parse @@ -597,7 +598,7 @@ def upload_sequencing_run_results(self, request, pk, submission_idx): # TODO: Validate submission_idx # Run bioinformatics using .zip file - print("Extracting zip file...") + # print("Extracting zip file...") seq_data = load_sequences(results_file.temporary_file_path()) # Convert to FASTA in-memory (vquest api handles chunking to @@ -605,7 +606,7 @@ def upload_sequencing_run_results(self, request, pk, submission_idx): fasta_file = as_fasta_files(seq_data, max_file_size=None)[0] # Submit to vquest - print("Running vquest...") + # print("Running vquest...") vquest_results = run_vquest(fasta_file) parameters_file_data = vquest_results["Parameters.txt"] @@ -613,6 +614,22 @@ def upload_sequencing_run_results(self, request, pk, submission_idx): base_filename = f"SequencingResults_{pk}_{submission_idx}" + # Make sure directory exists + base_dirs = set( + [ + os.path.join( + settings.MEDIA_ROOT, + SequencingRunResults.parameters_file.field.upload_to, + ), + os.path.join( + settings.MEDIA_ROOT, SequencingRunResults.airr_file.field.upload_to + ), + ] + ) + + for base_dir in base_dirs: + os.makedirs(base_dir, exist_ok=True) + # Create SequencingRunResults object with open( os.path.join( @@ -655,7 +672,7 @@ def upload_sequencing_run_results(self, request, pk, submission_idx): name="Get sequencing results.", url_path="results", ) - def upload_sequencing_run_results(self, request, pk): + def get_sequencing_run_results(self, request, pk): """Get sequencing results.""" IMPORTANT_COLUMNS = ( "sequence_id", @@ -673,7 +690,8 @@ def upload_sequencing_run_results(self, request, pk): sequencing_run_id=int(pk) ).order_by("seq") - import io + if not results: + return JsonResponse({"records": []}) csvs = [] for r in results: diff --git a/frontend/src/crudtemplates/utils.js b/frontend/src/crudtemplates/utils.js index 75a5e2e..3cf2355 100644 --- a/frontend/src/crudtemplates/utils.js +++ b/frontend/src/crudtemplates/utils.js @@ -145,7 +145,6 @@ export const uploadSequencingResults = (event, props) => { ).then((res) => { props.setLoading(false); res.json().then((json) => { - console.log(json); props.setRecord(json); }); }); @@ -208,28 +207,26 @@ export const displayFieldSingle = (field, record, context, props) => { , ); - if (record.sequencingrunresults_set.find((x) => x.seq === p)) { - // Sequencing results found - } else { - // Sequencing results not uploaded yet - retVal.push( - , - ); - } + retVal.push( + , + ); } return retVal; } else if (field.type === "platethreshold" && record[field.field]) {