Skip to content

Commit

Permalink
feat: added strandedness to closest and match bedrs-2.0 api for call
Browse files Browse the repository at this point in the history
  • Loading branch information
noamteyssier committed Apr 11, 2024
1 parent 25da60d commit 0452016
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/cli/closest.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use super::{outputs::Output, overlap_predicates::WrapStrandedness, DualInput};
use clap::Parser;

use super::{outputs::Output, DualInput};

/// Finds the closest interval in a secondary BED file for all intervals in a primary BED file
#[derive(Parser, Debug)]
#[clap(next_help_heading = "Global options")]
Expand All @@ -27,7 +26,11 @@ pub struct ClosestParams {
#[clap(short = 'd', long, conflicts_with = "upstream")]
pub downstream: bool,

/// Strand-specificity of closest intervals
#[clap(short, long, default_value = "i")]
pub strandedness: WrapStrandedness,

/// Specify that the input files are already presorted
#[clap(short, long)]
#[clap(short = 'S', long)]
pub sorted: bool,
}
7 changes: 4 additions & 3 deletions src/commands/closest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ where
Renamer: Rename<'a, Ia, Na> + Rename<'a, Ib, Nb>,
{
sort_pairs(&mut a_set, &mut b_set, params.sorted);
let method = params.strandedness.into();
let pairs_iter = a_set
.iter()
.map(|query| {
let target = match params.into() {
ClosestType::Both => b_set.closest(query),
ClosestType::Upstream => b_set.closest_upstream(query),
ClosestType::Downstream => b_set.closest_downstream(query),
ClosestType::Both => b_set.closest(query, method),
ClosestType::Upstream => b_set.closest_upstream(query, method),
ClosestType::Downstream => b_set.closest_downstream(query, method),
}
.expect("Could not build closest index");
(query, target)
Expand Down

0 comments on commit 0452016

Please sign in to comment.