Skip to content

Commit

Permalink
Feature/fix issue 36 (#39)
Browse files Browse the repository at this point in the history
* 🔨

* 🧹 clean up output message

* 🔨 add skip * alleles

* 🔨 change vec eval, limit print warn

* 🔨 added skip final warn

* 🐎 change scope of warn message
  • Loading branch information
migbro authored Feb 6, 2024
1 parent 95bd420 commit 45b468e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
23 changes: 23 additions & 0 deletions src/commands/annotate_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub fn annotate_main(
let mut n = 0u64;
let mut n_written = 0u64;
let mut modu = 10000u64;
let mut skip_warn = 0;

for r in vcf.records() {
let mut record = r.expect("error reading record");
Expand All @@ -125,7 +126,25 @@ pub fn annotate_main(
);
}
n += 1;
// First check if the variant is *, skip those
if record.alleles()[1][0] == b'*' {
let rid = record.rid().unwrap();
let chrom = std::str::from_utf8(oheader_view.rid2name(rid).unwrap()).unwrap();
// Only warn up to 10 times, just keep count in general
if skip_warn < 10 {
eprintln!(
"contig {} pos {} alt has * value, skipping annotation, outputting entry as-is",
&chrom,
record.pos() + 1
);
if skip_warn == 9 { eprintln!("not reporting further warnings") }
}
skip_warn += 1;
ovcf.write(&record).expect("failed to write record");
continue;
}
// this updates evalues and fills expr values

for (i, e) in echts.iter_mut().enumerate() {
e.update_expr_values(&mut record, &mut expr_values[i]);
}
Expand Down Expand Up @@ -180,6 +199,10 @@ pub fn annotate_main(
1000 * (n as u128) / mili,
n_written,
);
eprintln!(
"Skipped {} variants with * alt.",
skip_warn,
);

/*
//let ep = std::path::Path::new(&*epaths[0]);
Expand Down
6 changes: 2 additions & 4 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
anno.vcf.gz
generated-all.vcf
generated-exclude.vcf
test.echtvar
test.echtvar.before
generated-*
test.echtvar*
sl.zip

0 comments on commit 45b468e

Please sign in to comment.