From 4225ec05b5a5b64fcce8ec5359536e9743f714f2 Mon Sep 17 00:00:00 2001 From: Andrew Frantz Date: Mon, 12 Feb 2024 10:24:51 -0500 Subject: [PATCH] tests: fix broken gene test --- src/derive/strandedness/compute.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/derive/strandedness/compute.rs b/src/derive/strandedness/compute.rs index c63035b..9be8f3c 100644 --- a/src/derive/strandedness/compute.rs +++ b/src/derive/strandedness/compute.rs @@ -166,7 +166,7 @@ fn disqualify_gene(gene: &gff::Record, exons: &HashMap<&str, Lapper intervals .find(gene.start().into(), gene.end().into()) - .any(|exon| { + .all(|exon| { if exon.val != gene_strand { all_on_same_strand = false; } @@ -422,6 +422,7 @@ mod tests { #[test] fn test_disqualify_gene() { + // test mixed strands let mut exons = HashMap::new(); exons.insert( "chr1", @@ -439,9 +440,11 @@ mod tests { ]), ); - let gene = gff::Record::default(); - assert!(disqualify_gene(&gene, &exons)); + let s = "chr1\tNOODLES\tgene\t5\t14\t.\t+\t.\tgene_id=ndls0;gene_name=gene0"; + let record = s.parse::().unwrap(); + assert!(disqualify_gene(&record, &exons)); // disqualified + // test all on same strand let mut exons = HashMap::new(); exons.insert( "chr1", @@ -459,9 +462,11 @@ mod tests { ]), ); - let s = "chr1\tNOODLES\tgene\t8\t13\t.\t+\t.\tgene_id=ndls0;gene_name=gene0"; - let record = s.parse::().unwrap(); - assert!(!disqualify_gene(&record, &exons)); + assert!(!disqualify_gene(&record, &exons)); // accepted + + // test no exons + let exons = HashMap::new(); + assert!(disqualify_gene(&record, &exons)); // disqualified } #[test]