|
|
@@ -8,7 +8,7 @@ use rayon::prelude::*;
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
use std::{
|
|
|
collections::HashSet,
|
|
|
- fmt::Display,
|
|
|
+ fmt::{self, Display},
|
|
|
fs::{self, File, Metadata},
|
|
|
hash::{Hash, Hasher},
|
|
|
io::{BufReader, Read},
|
|
|
@@ -689,18 +689,31 @@ pub struct Pod5Run {
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
pub enum FlowCellExperiment {
|
|
|
- WGSUnalignedMux(String),
|
|
|
- WGSUnalignedDemux(String),
|
|
|
+ WGSPod5Mux(String),
|
|
|
+ WGSPod5Demux(String),
|
|
|
+}
|
|
|
+
|
|
|
+impl fmt::Display for FlowCellExperiment {
|
|
|
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
+ write!(
|
|
|
+ f,
|
|
|
+ "{}",
|
|
|
+ match self {
|
|
|
+ FlowCellExperiment::WGSPod5Mux(_) => "WGS Pod5 Muxed",
|
|
|
+ FlowCellExperiment::WGSPod5Demux(_) => "WGS Pod5 Demuxed",
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
impl FlowCellExperiment {
|
|
|
pub fn from_path(flowcell_path: &str) -> Option<Self> {
|
|
|
for dir in list_directories(flowcell_path).ok().unwrap() {
|
|
|
if dir == "pod5" {
|
|
|
- return Some(FlowCellExperiment::WGSUnalignedMux(dir.to_string()));
|
|
|
+ return Some(FlowCellExperiment::WGSPod5Mux(dir.to_string()));
|
|
|
}
|
|
|
if &dir == "pod5_pass" {
|
|
|
- return Some(FlowCellExperiment::WGSUnalignedDemux(dir.to_string()));
|
|
|
+ return Some(FlowCellExperiment::WGSPod5Demux(dir.to_string()));
|
|
|
}
|
|
|
}
|
|
|
None
|
|
|
@@ -709,11 +722,11 @@ impl FlowCellExperiment {
|
|
|
pub fn from_pod5_paths(all_paths: &Vec<String>) -> Option<Self> {
|
|
|
for path in all_paths {
|
|
|
if path.ends_with("/pod5/") || path.ends_with("/pod5") {
|
|
|
- return Some(FlowCellExperiment::WGSUnalignedMux(path.to_string()));
|
|
|
+ return Some(FlowCellExperiment::WGSPod5Mux(path.to_string()));
|
|
|
}
|
|
|
|
|
|
if path.ends_with("/pod5_pass/") || path.ends_with("/pod5_pass") {
|
|
|
- return Some(FlowCellExperiment::WGSUnalignedMux(path.to_string()));
|
|
|
+ return Some(FlowCellExperiment::WGSPod5Mux(path.to_string()));
|
|
|
}
|
|
|
}
|
|
|
None
|
|
|
@@ -721,51 +734,51 @@ impl FlowCellExperiment {
|
|
|
|
|
|
pub fn inner(&self) -> &str {
|
|
|
match self {
|
|
|
- FlowCellExperiment::WGSUnalignedMux(v) => v,
|
|
|
- FlowCellExperiment::WGSUnalignedDemux(v) => v,
|
|
|
+ FlowCellExperiment::WGSPod5Mux(v) => v,
|
|
|
+ FlowCellExperiment::WGSPod5Demux(v) => v,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
-pub struct FlowCellArchived {
|
|
|
- pub archive_id: String,
|
|
|
- pub last_seen: DateTime<Utc>,
|
|
|
- pub run: MinKnowSampleSheet,
|
|
|
-}
|
|
|
-
|
|
|
-impl FlowCellArchived {
|
|
|
- pub fn from_tar(tar_path: &str) -> Result<Vec<(String, u64, u64)>> {
|
|
|
- // Open the tar file safely with context for errors
|
|
|
- let file = File::open(tar_path)
|
|
|
- .with_context(|| format!("Failed to open tar file at path: {}", tar_path))?;
|
|
|
-
|
|
|
- let mut archive = tar::Archive::new(file);
|
|
|
- let mut result = Vec::new();
|
|
|
-
|
|
|
- // Iterate through the entries in the archive
|
|
|
- for entry in archive.entries_with_seek()? {
|
|
|
- let file = entry.context("Failed to read an entry from the tar archive")?;
|
|
|
-
|
|
|
- // Extract file properties safely
|
|
|
- let size = file.size();
|
|
|
- let modified = file
|
|
|
- .header()
|
|
|
- .mtime()
|
|
|
- .context("Failed to get modification time")?;
|
|
|
- let path = file
|
|
|
- .path()
|
|
|
- .context("Failed to get file path from tar entry")?
|
|
|
- .to_string_lossy()
|
|
|
- .into_owned();
|
|
|
-
|
|
|
- println!("{path}");
|
|
|
- result.push((path, size, modified));
|
|
|
- }
|
|
|
+// #[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
+// pub struct FlowCellArchived {
|
|
|
+// pub archive_id: String,
|
|
|
+// pub last_seen: DateTime<Utc>,
|
|
|
+// pub run: MinKnowSampleSheet,
|
|
|
+// }
|
|
|
|
|
|
- Ok(result)
|
|
|
- }
|
|
|
-}
|
|
|
+// impl FlowCellArchived {
|
|
|
+// pub fn from_tar(tar_path: &str) -> Result<Vec<(String, u64, u64)>> {
|
|
|
+// // Open the tar file safely with context for errors
|
|
|
+// let file = File::open(tar_path)
|
|
|
+// .with_context(|| format!("Failed to open tar file at path: {}", tar_path))?;
|
|
|
+//
|
|
|
+// let mut archive = tar::Archive::new(file);
|
|
|
+// let mut result = Vec::new();
|
|
|
+//
|
|
|
+// // Iterate through the entries in the archive
|
|
|
+// for entry in archive.entries_with_seek()? {
|
|
|
+// let file = entry.context("Failed to read an entry from the tar archive")?;
|
|
|
+//
|
|
|
+// // Extract file properties safely
|
|
|
+// let size = file.size();
|
|
|
+// let modified = file
|
|
|
+// .header()
|
|
|
+// .mtime()
|
|
|
+// .context("Failed to get modification time")?;
|
|
|
+// let path = file
|
|
|
+// .path()
|
|
|
+// .context("Failed to get file path from tar entry")?
|
|
|
+// .to_string_lossy()
|
|
|
+// .into_owned();
|
|
|
+//
|
|
|
+// println!("{path}");
|
|
|
+// result.push((path, size, modified));
|
|
|
+// }
|
|
|
+//
|
|
|
+// Ok(result)
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
pub fn scan_archive(
|
|
|
tar_path: &str,
|
|
|
@@ -871,6 +884,19 @@ pub enum FlowCellLocation {
|
|
|
Archived(String),
|
|
|
}
|
|
|
|
|
|
+impl fmt::Display for FlowCellLocation {
|
|
|
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
+ write!(
|
|
|
+ f,
|
|
|
+ "{}",
|
|
|
+ match self {
|
|
|
+ FlowCellLocation::Local(_) => "local",
|
|
|
+ FlowCellLocation::Archived(_) => "archived",
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
impl FlowCel {
|
|
|
pub fn new(
|
|
|
sample_sheet: MinKnowSampleSheet,
|
|
|
@@ -918,6 +944,7 @@ impl FlowCel {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
|
pub struct FlowCells {
|
|
|
pub flow_cells: Vec<FlowCel>,
|
|
|
@@ -951,10 +978,14 @@ impl FlowCells {
|
|
|
|
|
|
let inputs = IdsInput::load_json(inputs_path)?;
|
|
|
flow_cells.iter_mut().for_each(|fc| {
|
|
|
- fc.cases = inputs.data.iter().filter(|info| {
|
|
|
- info.flow_cell == fc.run.sample_id
|
|
|
- && info.run == fc.run.experiment_id
|
|
|
- }).cloned().collect();
|
|
|
+ fc.cases = inputs
|
|
|
+ .data
|
|
|
+ .iter()
|
|
|
+ .filter(|info| {
|
|
|
+ info.flow_cell == fc.run.sample_id && info.run == fc.run.experiment_id
|
|
|
+ })
|
|
|
+ .cloned()
|
|
|
+ .collect();
|
|
|
});
|
|
|
|
|
|
Ok(Self { flow_cells })
|