From 095be2ba8a4e6a63091f619884e16628763f2118 Mon Sep 17 00:00:00 2001 From: noam teyssier <22600644+noamteyssier@users.noreply.github.com> Date: Wed, 10 Apr 2024 14:03:26 -0700 Subject: [PATCH] feat: added stranded method to Growth to propagate stranded methods to flank, window, extend --- src/cli/growth.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/cli/growth.rs b/src/cli/growth.rs index 548e4b4..9ea9ee8 100644 --- a/src/cli/growth.rs +++ b/src/cli/growth.rs @@ -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)] @@ -25,6 +25,13 @@ pub struct Growth { /// Genome file to validate growth against #[clap(short, long)] pub genome: Option, + + /// 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)] @@ -52,7 +59,7 @@ impl Growth { where I: IntervalBounds, { - 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( @@ -60,6 +67,11 @@ impl Growth { self.left.unwrap_or_default(), self.right.unwrap_or_default(), ) + }; + if self.stranded && iv.strand() == Some(Strand::Reverse) { + (right, left) + } else { + (left, right) } }