Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sjneph committed Aug 24, 2024
1 parent 23f6388 commit 2988fba
Showing 1 changed file with 0 additions and 70 deletions.
70 changes: 0 additions & 70 deletions src/utils/ftexpression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,76 +127,6 @@ pub fn parse_filter(filter_orig: &str) -> ParsedExpr {
}
}

/*
pub fn parse_filter(filter_orig: &str) -> ParsedExpr {
let mut filter = filter_orig.to_string();
filter.retain(|c| !c.is_whitespace());
let func_name_end = filter.find('(').unwrap_or(filter.len());
let func_name = filter[..func_name_end].trim().to_string();
if !["len", "cmp"].contains(&func_name.as_str()) {
eprintln!("Invalid function: {}", func_name);
std::process::exit(1);
}
let gnm_feat_start = filter.find('(').unwrap_or(filter.len()) + 1;
let gnm_feat_end = filter.find(')').unwrap_or(filter.len());
let gnm_feat = filter[gnm_feat_start..gnm_feat_end].to_string();
if !["msp", "nuc", "m6a", "5mC"].contains(&gnm_feat.as_str()) {
eprintln!("Invalid argument for {} function: {}", func_name, gnm_feat);
std::process::exit(1);
}
let rest = &filter[gnm_feat_end + 1..].trim();
let operators = ["!=", ">=", "<=", ">", "<", "="];
let mut operator = "".to_string();
let mut threshold = None;
let mut range = None;
for &op in operators.iter() {
if let Some(pos) = rest.find(op) {
operator = op.to_string();
let threshold_str = rest[pos + op.len()..].trim();
if threshold_str.contains(':') {
let range_parts: Vec<&str> = threshold_str.split(':').collect();
if range_parts.len() == 2 {
range = Some((
range_parts[0].trim().parse::<f64>().unwrap(),
range_parts[1].trim().parse::<f64>().unwrap(),
));
} else {
eprintln!("Range thresholds require 2 numerical values, ex: 'len(msp)=50:100'");
std::process::exit(1);
}
} else {
threshold = Some(threshold_str.parse::<f64>().unwrap());
}
break;
}
}
if let Some((_, _)) = range {
if operator != "=" {
eprintln!("Range thresholds can only be used with the '=' operator.");
std::process::exit(1);
}
}
let threshold_value = match range {
Some((min, max)) => Threshold::Range(min, max),
None => Threshold::Single(threshold.unwrap()),
};
ParsedExpr {
fn_name: func_name,
feat_name: gnm_feat,
op: operator,
threshold: threshold_value,
}
}
*/

pub fn apply_filter_to_range(
parsed: &ParsedExpr,
range: &mut bamranges::Ranges,
Expand Down

0 comments on commit 2988fba

Please sign in to comment.