|
|
@@ -1,6 +1,6 @@
|
|
|
use crate::{
|
|
|
annotation::Annotations,
|
|
|
- collection::{Initialize, ShouldRun},
|
|
|
+ collection::ShouldRun,
|
|
|
helpers::Hash128,
|
|
|
positions::{GenomePosition, GetGenomePosition, VcfPosition},
|
|
|
runners::Run,
|
|
|
@@ -8,7 +8,7 @@ use crate::{
|
|
|
};
|
|
|
use anyhow::{anyhow, Context};
|
|
|
use bitcode::{Decode, Encode};
|
|
|
-use log::{info, warn};
|
|
|
+use log::{error, info};
|
|
|
use rayon::prelude::*;
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
use std::{cmp::Ordering, collections::HashSet, fmt, hash::Hash, str::FromStr};
|
|
|
@@ -1042,6 +1042,10 @@ pub trait VariantId {
|
|
|
fn variant_id(&self) -> String;
|
|
|
}
|
|
|
|
|
|
+pub trait Label {
|
|
|
+ fn label(&self) -> String;
|
|
|
+}
|
|
|
+
|
|
|
// pub trait AsAny {
|
|
|
// fn as_any(&self) -> &dyn std::any::Any;
|
|
|
// }
|
|
|
@@ -1060,10 +1064,10 @@ pub trait VariantId {
|
|
|
/// - Is thread-safe (`Send + Sync`) to be boxed and dispatched concurrently
|
|
|
///
|
|
|
/// Components implementing this trait can be boxed as `ShouldRunBox`.
|
|
|
-pub trait ShouldRunTrait: ShouldRun + Run + Send + Sync {}
|
|
|
+pub trait ShouldRunTrait: ShouldRun + Run + Send + Sync + Label {}
|
|
|
|
|
|
/// Blanket implementation for all compatible types.
|
|
|
-impl<T> ShouldRunTrait for T where T: ShouldRun + Run + Send + Sync {}
|
|
|
+impl<T> ShouldRunTrait for T where T: ShouldRun + Run + Send + Sync + Label {}
|
|
|
|
|
|
/// A boxed trait object to hold any runner implementing `ShouldRunTrait`.
|
|
|
pub type ShouldRunBox = Box<dyn ShouldRunTrait>;
|
|
|
@@ -1209,7 +1213,7 @@ pub fn run_if_required(iterable: &mut [ShouldRunBox]) -> anyhow::Result<()> {
|
|
|
if e.should_run() {
|
|
|
e.run()
|
|
|
} else {
|
|
|
- // info!("Skipping runner: {}", std::any::type_name::<_>()); // or add name field
|
|
|
+ info!("Skipping running: {}", e.label());
|
|
|
|
|
|
Ok(())
|
|
|
}
|
|
|
@@ -1220,7 +1224,10 @@ pub fn run_if_required(iterable: &mut [ShouldRunBox]) -> anyhow::Result<()> {
|
|
|
/// conditional re-running, and variant extraction (VCF + annotations).
|
|
|
///
|
|
|
/// Used to enable polymorphic handling of both solo and somatic callers in the pipeline.
|
|
|
-pub trait RunnerVariants: Run + Variants + Send + Sync {}
|
|
|
+pub trait RunnerVariants: Variants + Send + Sync + Label {}
|
|
|
+
|
|
|
+/// Blanket implementation for all compatible types.
|
|
|
+impl<T> RunnerVariants for T where T: Variants + Send + Sync + Label {}
|
|
|
|
|
|
pub type CallerBox = Box<dyn RunnerVariants + Send + Sync>;
|
|
|
|
|
|
@@ -1345,34 +1352,36 @@ pub fn load_variants(
|
|
|
iterable
|
|
|
.par_iter()
|
|
|
.map(|runner| {
|
|
|
- let r = runner.variants(annotations);
|
|
|
- if let Err(ref e) = r {
|
|
|
- warn!("{e}");
|
|
|
+ let result = runner.variants(annotations);
|
|
|
+ if let Err(ref e) = result {
|
|
|
+ error!("Failed to load variants from: {}\n{e}", runner.label());
|
|
|
+ } else {
|
|
|
+ info!("Variants from {} loaded.", runner.label());
|
|
|
};
|
|
|
- r
|
|
|
+ result
|
|
|
})
|
|
|
.filter(|r| r.is_ok())
|
|
|
.collect::<anyhow::Result<Vec<_>>>()
|
|
|
.map_err(|e| anyhow::anyhow!("Failed to load variants.\n{e}"))
|
|
|
}
|
|
|
|
|
|
-pub fn par_load_variants(
|
|
|
- iterable: &mut [Box<dyn Variants + Send + Sync>],
|
|
|
- annotations: &Annotations,
|
|
|
-) -> anyhow::Result<Vec<VariantCollection>> {
|
|
|
- iterable
|
|
|
- .par_iter()
|
|
|
- .map(|runner| {
|
|
|
- let r = runner.variants(annotations);
|
|
|
- if let Err(ref e) = r {
|
|
|
- warn!("{e}");
|
|
|
- };
|
|
|
- r
|
|
|
- })
|
|
|
- .filter(|r| r.is_ok())
|
|
|
- .collect::<anyhow::Result<Vec<_>>>()
|
|
|
- .map_err(|e| anyhow::anyhow!("Failed to load variants.\n{e}"))
|
|
|
-}
|
|
|
+// pub fn par_load_variants(
|
|
|
+// iterable: &mut [Box<dyn Variants + Send + Sync>],
|
|
|
+// annotations: &Annotations,
|
|
|
+// ) -> anyhow::Result<Vec<VariantCollection>> {
|
|
|
+// iterable
|
|
|
+// .par_iter()
|
|
|
+// .map(|runner| {
|
|
|
+// let r = runner.variants(annotations);
|
|
|
+// if let Err(ref e) = r {
|
|
|
+// warn!("{e}");
|
|
|
+// };
|
|
|
+// r
|
|
|
+// })
|
|
|
+// .filter(|r| r.is_ok())
|
|
|
+// .collect::<anyhow::Result<Vec<_>>>()
|
|
|
+// .map_err(|e| anyhow::anyhow!("Failed to load variants.\n{e}"))
|
|
|
+// }
|
|
|
|
|
|
pub fn parallel_intersection<T: Hash + Eq + Clone + Send + Sync>(
|
|
|
vec1: &[T],
|