Skip to content

Commit

Permalink
fix(cli): don't crash on unknown nucleotide characters
Browse files Browse the repository at this point in the history
Nextclade v2 crashes when encounters unknown nucleotide letters which converting fasta string to the internal sequence representation.

This PR aligns behavior with v1: sequences with unknown nucleotide letters are now ignored, excluded from results, added to errors.csv and the run continues.
  • Loading branch information
ivan-aksamentov committed Jun 22, 2022
1 parent e27dc48 commit 444ceaa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
25 changes: 13 additions & 12 deletions packages_rs/nextclade-cli/src/cli/nextalign_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,20 @@ pub fn nextalign_run(args: NextalignRunArgs) -> Result<(), Report> {

for FastaRecord { seq_name, seq, index } in &fasta_receiver {
info!("Processing sequence '{seq_name}'");
let qry_seq = to_nuc_seq(&seq)
.wrap_err_with(|| format!("When processing sequence #{index} '{seq_name}'"))
.unwrap();

let outputs_or_err = nextalign_run_one(
&qry_seq,
ref_seq,
ref_peptides,
gene_map,
gap_open_close_nuc,
gap_open_close_aa,
alignment_params,
);
let outputs_or_err = to_nuc_seq(&seq)
.wrap_err_with(|| format!("When processing sequence #{index} '{seq_name}'"))
.and_then(|qry_seq| {
nextalign_run_one(
&qry_seq,
ref_seq,
ref_peptides,
gene_map,
gap_open_close_nuc,
gap_open_close_aa,
alignment_params,
)
});

let record = NextalignRecord {
index,
Expand Down
35 changes: 18 additions & 17 deletions packages_rs/nextclade-cli/src/cli/nextclade_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,25 @@ pub fn nextclade_run(args: NextcladeRunArgs) -> Result<(), Report> {

for FastaRecord { seq_name, seq, index } in &fasta_receiver {
info!("Processing sequence '{seq_name}'");
let qry_seq = to_nuc_seq(&seq)
.wrap_err_with(|| format!("When processing sequence #{index} '{seq_name}'"))
.unwrap();

let outputs_or_err = nextclade_run_one(
&seq_name,
&qry_seq,
ref_seq,
ref_peptides,
gene_map,
primers,
tree,
qc_config,
virus_properties,
gap_open_close_nuc,
gap_open_close_aa,
alignment_params,
);
let outputs_or_err = to_nuc_seq(&seq)
.wrap_err_with(|| format!("When processing sequence #{index} '{seq_name}'"))
.and_then(|qry_seq| {
nextclade_run_one(
&seq_name,
&qry_seq,
ref_seq,
ref_peptides,
gene_map,
primers,
tree,
qc_config,
virus_properties,
gap_open_close_nuc,
gap_open_close_aa,
alignment_params,
)
});

let record = NextcladeRecord {
index,
Expand Down

0 comments on commit 444ceaa

Please sign in to comment.