From 018868b9cdfabf7dbb141e322fd6ec904ec08ba2 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Wed, 22 May 2024 14:39:51 +0200 Subject: [PATCH] fix --- .../src/loculus_preprocessing/prepro.py | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/preprocessing/nextclade/src/loculus_preprocessing/prepro.py b/preprocessing/nextclade/src/loculus_preprocessing/prepro.py index 49069a80f7..39ea0e767a 100644 --- a/preprocessing/nextclade/src/loculus_preprocessing/prepro.py +++ b/preprocessing/nextclade/src/loculus_preprocessing/prepro.py @@ -231,6 +231,7 @@ def process_single( "length": len(unprocessed.unalignedNucleotideSequences), } + alignment_failed = False for output_field, spec_dict in config.processing_spec.items(): if output_field == "length": continue @@ -241,7 +242,6 @@ def process_single( args=spec_dict.get("args", {}), ) input_data: InputMetadata = {} - nextclade_failed = False for arg_name, input_path in spec.inputs.items(): input_data[arg_name] = None # If field starts with "nextclade.", take from nextclade metadata @@ -249,7 +249,7 @@ def process_single( if input_path.startswith(nextclade_prefix): # Remove "nextclade." prefix if unprocessed.nextcladeMetadata is None: - nextclade_failed = True + alignment_failed = True continue sub_path = input_path[len(nextclade_prefix) :] input_data[arg_name] = str( @@ -273,18 +273,6 @@ def process_single( # ) continue input_data[arg_name] = unprocessed.inputMetadata[input_path] - if nextclade_failed: - errors.append( - ProcessingAnnotation( - source=[ - AnnotationSource( - name="main", - type=AnnotationSourceType.NUCLEOTIDE_SEQUENCE, - ) - ], - message="Nucleotide sequence failed to align", - ) - ) processing_result = ProcessingFunctions.call_function( spec.function, spec.args, input_data, output_field ) @@ -298,6 +286,19 @@ def process_single( ) output_metadata[output_field] = "Not provided" + if alignment_failed: + errors.append( + ProcessingAnnotation( + source=[ + AnnotationSource( + name="main", + type=AnnotationSourceType.NUCLEOTIDE_SEQUENCE, + ) + ], + message="Nucleotide sequence failed to align", + ) + ) + logging.debug(f"Processed {id}: {output_metadata}") return ProcessedEntry(