Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliusroemer committed May 22, 2024
1 parent c09cfa2 commit 018868b
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions preprocessing/nextclade/src/loculus_preprocessing/prepro.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -241,15 +242,14 @@ 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
nextclade_prefix = "nextclade."
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(
Expand All @@ -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
)
Expand All @@ -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(
Expand Down

0 comments on commit 018868b

Please sign in to comment.