Skip to content

Commit

Permalink
tests: fix broken gene test
Browse files Browse the repository at this point in the history
  • Loading branch information
a-frantz committed Feb 12, 2024
1 parent 11dc18d commit 4225ec0
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/derive/strandedness/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn disqualify_gene(gene: &gff::Record, exons: &HashMap<&str, Lapper<usize, Stran
let at_least_one_exon = match exons.get(gene.reference_sequence_name()) {
Some(intervals) => intervals
.find(gene.start().into(), gene.end().into())
.any(|exon| {
.all(|exon| {
if exon.val != gene_strand {
all_on_same_strand = false;
}
Expand Down Expand Up @@ -422,6 +422,7 @@ mod tests {

#[test]
fn test_disqualify_gene() {
// test mixed strands
let mut exons = HashMap::new();
exons.insert(
"chr1",
Expand All @@ -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::<gff::Record>().unwrap();
assert!(disqualify_gene(&record, &exons)); // disqualified

// test all on same strand
let mut exons = HashMap::new();
exons.insert(
"chr1",
Expand All @@ -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::<gff::Record>().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]
Expand Down

0 comments on commit 4225ec0

Please sign in to comment.