diff --git a/trust/src/main.rs b/trust/src/main.rs index add4f955..02437c13 100644 --- a/trust/src/main.rs +++ b/trust/src/main.rs @@ -21,7 +21,7 @@ fn main() { for i in parts { println!("{:?}", i); } - + let mat = matching::Matcher::new(); let mut up_record = vcf::Record::default(); reader .read_record(&header, &mut up_record) @@ -29,6 +29,10 @@ fn main() { for result in reader.records(&header) { let dn_record = result.expect("Unable to parse record"); // Need to put a sequence resolved guard on seq_similarity + if mat.filter_call(&dn_record, false) { + println!("filtering {:?}", up_record); + continue; + } println!( "size={:?} type={:?} bound={:?} dist={:?} ovl={:?} szsim={:?} gtcmp={:?} pres={:?} filt={:?} sim={:?}", comparisons::entry_size(&dn_record), diff --git a/trust/src/matching.rs b/trust/src/matching.rs index 30bf75c9..2fc619df 100644 --- a/trust/src/matching.rs +++ b/trust/src/matching.rs @@ -1,4 +1,5 @@ use crate::types::Gt; +use crate::comparisons; use noodles_vcf::{self as vcf}; use std::cmp::Ordering; @@ -96,12 +97,44 @@ impl Eq for MatchResult {} #[derive(Debug)] pub struct Matcher { pub params: String, // This will be tricky? Maybe... - pub fn filter_call(entry: &vcf::Record, base: bool) { - } } -impl Matcher ( +impl Matcher { + pub fn new() -> Self { + Matcher { params: "Wouldbeparams".to_string() } + } + + pub fn filter_call(&self, entry: &vcf::Record, base: bool) -> bool { + // self.params.check_monref & e + if entry.alternate_bases().len() == 0 { + return true; + } + + // self.params.check_multi + if entry.alternate_bases().len() > 1 { + //panic and exit + return true; + } + + // self.params.passonly + if comparisons::entry_is_filtered(&entry) { + return true; + } + + let size = comparisons::entry_size(&entry); + //self.params.sizemax + //self.params.sizemin + //self.params.sizefilt + if (size > 1209) || (base & (size < 5)) || (!base & (size < 6)) { + return true; + } + //self.params.bSample / self.params.cSample + let (samp, prefix) = if base { (0, 'b') } else { (1, 'c') }; + //if (self.params.no_ref.. + false + } +} //check_monref and alts is None //# check_multi and /* TODO diff --git a/truvari/matching.py b/truvari/matching.py index 4dc99112..28b323bf 100644 --- a/truvari/matching.py +++ b/truvari/matching.py @@ -170,8 +170,7 @@ def filter_call(self, entry, base=False): or (not base and size < self.params.sizefilt): return True - samp = self.params.bSample if base else self.params.cSample - prefix = 'b' if base else 'c' + samp, prefix = (self.params.bSample, 'b') if base else (self.params.cSample, 'c') if (self.params.no_ref in ["a", prefix] or self.params.pick == 'ac') \ and not truvari.entry_is_present(entry, samp): return True