|
|
@@ -138,6 +138,14 @@ impl Phase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ pub fn contains(&self, records_ids: &[String]) -> bool {
|
|
|
+ self.reads
|
|
|
+ .par_iter()
|
|
|
+ .filter(|v| records_ids.contains(*v))
|
|
|
+ .count()
|
|
|
+ > 0
|
|
|
+ }
|
|
|
+
|
|
|
pub fn try_merge_phase(&mut self, phase: &Phase, min_records: usize) -> bool {
|
|
|
if phase
|
|
|
.reads
|
|
|
@@ -227,13 +235,15 @@ impl Phase {
|
|
|
|
|
|
pub fn bed_string(&self) -> Option<String> {
|
|
|
if let (Some((min, _min_cov, _max_cov, max)), Some(id)) = (self.range, self.id()) {
|
|
|
- Some([
|
|
|
- self.data.first().unwrap().chr.to_string(),
|
|
|
- min.to_string(),
|
|
|
- max.to_string(),
|
|
|
- format!("{} {:.2}", id, self.mean_vaf()),
|
|
|
- ]
|
|
|
- .join("\t"))
|
|
|
+ Some(
|
|
|
+ [
|
|
|
+ self.data.first().unwrap().chr.to_string(),
|
|
|
+ min.to_string(),
|
|
|
+ max.to_string(),
|
|
|
+ format!("{} {:.2}", id, self.mean_vaf()),
|
|
|
+ ]
|
|
|
+ .join("\t"),
|
|
|
+ )
|
|
|
} else {
|
|
|
None
|
|
|
}
|
|
|
@@ -253,7 +263,6 @@ impl Phase {
|
|
|
} else {
|
|
|
None
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -437,7 +446,6 @@ pub fn write_phases_bed(
|
|
|
phases: &[Phase], // should be already sorted and with ranges
|
|
|
file: &str,
|
|
|
) -> Result<()> {
|
|
|
-
|
|
|
let mut w = OpenOptions::new()
|
|
|
.read(true)
|
|
|
// .write(true)
|