Skip to content

Commit

Permalink
feat: added stranded method to Growth to propagate stranded methods t…
Browse files Browse the repository at this point in the history
…o flank, window, extend
  • Loading branch information
noamteyssier committed Apr 10, 2024
1 parent 76d0aae commit 095be2b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/cli/growth.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::types::{Genome, Translater};
use anyhow::Result;
use bedrs::traits::IntervalBounds;
use bedrs::{traits::IntervalBounds, Strand};
use clap::Parser;

#[derive(Parser, Debug, Clone)]
Expand All @@ -25,6 +25,13 @@ pub struct Growth {
/// Genome file to validate growth against
#[clap(short, long)]
pub genome: Option<String>,

/// Follow strand specificity when applying growth
///
/// i.e. if the strand is negative, apply growth to the right side of the interval
/// when the left side is requested (and vice versa) [default = false]
#[clap(short, long)]
pub stranded: bool,
}
impl Growth {
#[allow(clippy::option_map_unit_fn)]
Expand Down Expand Up @@ -52,14 +59,19 @@ impl Growth {
where
I: IntervalBounds<usize, usize>,
{
if let Some(val) = self.both {
let (left, right) = if let Some(val) = self.both {
self.calculate_percentage(iv, val, val)
} else {
self.calculate_percentage(
iv,
self.left.unwrap_or_default(),
self.right.unwrap_or_default(),
)
};
if self.stranded && iv.strand() == Some(Strand::Reverse) {
(right, left)
} else {
(left, right)
}
}

Expand Down

0 comments on commit 095be2b

Please sign in to comment.