use super::{Output, Staged};
use crate::convert::{build_from_h5_matrix, MatrixLayout};
#[derive(Clone, Debug)]
pub struct TenxMatrixImport {
pub h5_file: Box<str>,
pub root_group: Box<str>,
pub layout: MatrixLayout,
}
impl TenxMatrixImport {
pub fn new(h5_file: &str) -> Self {
Self {
h5_file: h5_file.into(),
root_group: MatrixLayout::H5_ROOT.into(),
layout: MatrixLayout::cell_ranger_h5(),
}
}
}
pub fn from_10x_matrix(h5: &TenxMatrixImport, out: &Output) -> anyhow::Result<Box<str>> {
stage_10x_matrix(h5, out)?.finish()
}
pub fn stage_10x_matrix(h5: &TenxMatrixImport, out: &Output) -> anyhow::Result<Staged> {
let (staged, backend) = out.stage()?;
build_from_h5_matrix(
&h5.h5_file,
&h5.root_group,
&h5.layout,
staged.working(),
&backend,
)?;
Ok(staged)
}