From 650687b083890bbb8054a16df5276bcfe9e569c8 Mon Sep 17 00:00:00 2001 From: Miguel Brown Date: Fri, 2 Feb 2024 19:45:12 +0000 Subject: [PATCH 1/6] :hammer: --- src/commands/annotate_cmd.rs | 10 ++++++++++ tests/.gitignore | 6 ++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/commands/annotate_cmd.rs b/src/commands/annotate_cmd.rs index 09884d8..9e97ee1 100644 --- a/src/commands/annotate_cmd.rs +++ b/src/commands/annotate_cmd.rs @@ -125,7 +125,17 @@ pub fn annotate_main( ); } n += 1; + // First check if the variant is *, skip those + if String::from_utf8_lossy(record.alleles()[1]) == "*" { + eprintln!( + "alt has * value, skipping annotation for {:?}", + &record + ); + 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]); } diff --git a/tests/.gitignore b/tests/.gitignore index 8bb1f46..0162c54 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,6 +1,4 @@ anno.vcf.gz -generated-all.vcf -generated-exclude.vcf -test.echtvar -test.echtvar.before +generated-* +test.echtvar* sl.zip From 08ceffcc4b9138ba28780ba24451111a571f171f Mon Sep 17 00:00:00 2001 From: Miguel Brown Date: Fri, 2 Feb 2024 19:59:33 +0000 Subject: [PATCH 2/6] :broom: clean up output message --- src/commands/annotate_cmd.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/commands/annotate_cmd.rs b/src/commands/annotate_cmd.rs index 9e97ee1..5649e85 100644 --- a/src/commands/annotate_cmd.rs +++ b/src/commands/annotate_cmd.rs @@ -127,9 +127,12 @@ pub fn annotate_main( n += 1; // First check if the variant is *, skip those if String::from_utf8_lossy(record.alleles()[1]) == "*" { + let rid = record.rid().unwrap(); + let chrom = std::str::from_utf8(oheader_view.rid2name(rid).unwrap()).unwrap(); eprintln!( - "alt has * value, skipping annotation for {:?}", - &record + "contig {} pos {} alt has * value, skipping annotation, outputting entry as-is", + &chrom, + record.pos() + 1 ); ovcf.write(&record).expect("failed to write record"); continue; From bade14c8360f4cf526f01c5af6cb6367a1115e41 Mon Sep 17 00:00:00 2001 From: Miguel Brown Date: Fri, 2 Feb 2024 19:45:12 +0000 Subject: [PATCH 3/6] :hammer: add skip * alleles --- src/commands/annotate_cmd.rs | 13 +++++++++++++ tests/.gitignore | 6 ++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/commands/annotate_cmd.rs b/src/commands/annotate_cmd.rs index 09884d8..5649e85 100644 --- a/src/commands/annotate_cmd.rs +++ b/src/commands/annotate_cmd.rs @@ -125,7 +125,20 @@ pub fn annotate_main( ); } n += 1; + // First check if the variant is *, skip those + if String::from_utf8_lossy(record.alleles()[1]) == "*" { + let rid = record.rid().unwrap(); + let chrom = std::str::from_utf8(oheader_view.rid2name(rid).unwrap()).unwrap(); + eprintln!( + "contig {} pos {} alt has * value, skipping annotation, outputting entry as-is", + &chrom, + record.pos() + 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]); } diff --git a/tests/.gitignore b/tests/.gitignore index 8bb1f46..0162c54 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,6 +1,4 @@ anno.vcf.gz -generated-all.vcf -generated-exclude.vcf -test.echtvar -test.echtvar.before +generated-* +test.echtvar* sl.zip From c5ec38b821721f45343e93234dc43ad5f9150e59 Mon Sep 17 00:00:00 2001 From: Miguel Brown Date: Mon, 5 Feb 2024 14:37:31 +0000 Subject: [PATCH 4/6] :hammer: change vec eval, limit print warn --- src/commands/annotate_cmd.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/commands/annotate_cmd.rs b/src/commands/annotate_cmd.rs index 5649e85..9aaf5c3 100644 --- a/src/commands/annotate_cmd.rs +++ b/src/commands/annotate_cmd.rs @@ -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"); @@ -126,14 +127,18 @@ pub fn annotate_main( } n += 1; // First check if the variant is *, skip those - if String::from_utf8_lossy(record.alleles()[1]) == "*" { + if record.alleles()[1][0] == b'*' { let rid = record.rid().unwrap(); let chrom = std::str::from_utf8(oheader_view.rid2name(rid).unwrap()).unwrap(); - eprintln!( - "contig {} pos {} alt has * value, skipping annotation, outputting entry as-is", - &chrom, - record.pos() + 1 - ); + // 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 + ); + } + skip_warn += 1; ovcf.write(&record).expect("failed to write record"); continue; } @@ -193,6 +198,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]); From 2e5b08d66269936748394d7aa621bfd4ad270214 Mon Sep 17 00:00:00 2001 From: Miguel Brown Date: Mon, 5 Feb 2024 17:26:24 +0000 Subject: [PATCH 5/6] :hammer: added skip final warn --- src/commands/annotate_cmd.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/annotate_cmd.rs b/src/commands/annotate_cmd.rs index 9aaf5c3..c6483cc 100644 --- a/src/commands/annotate_cmd.rs +++ b/src/commands/annotate_cmd.rs @@ -138,6 +138,7 @@ pub fn annotate_main( record.pos() + 1 ); } + if skip_warn == 9 { eprintln!("not reporting further warnings") } skip_warn += 1; ovcf.write(&record).expect("failed to write record"); continue; From e02d006bd22fb3d754d5cafa720a6a71ff35deb1 Mon Sep 17 00:00:00 2001 From: Miguel Brown Date: Mon, 5 Feb 2024 18:41:00 +0000 Subject: [PATCH 6/6] :racehorse: change scope of warn message --- src/commands/annotate_cmd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/annotate_cmd.rs b/src/commands/annotate_cmd.rs index c6483cc..cae266f 100644 --- a/src/commands/annotate_cmd.rs +++ b/src/commands/annotate_cmd.rs @@ -137,8 +137,8 @@ pub fn annotate_main( &chrom, record.pos() + 1 ); + if skip_warn == 9 { eprintln!("not reporting further warnings") } } - if skip_warn == 9 { eprintln!("not reporting further warnings") } skip_warn += 1; ovcf.write(&record).expect("failed to write record"); continue;