| 10 | } |
| 11 | |
| 12 | pub fn read_h5ad<P: AsRef<Path>>( |
| 13 | path_to_file: P, |
| 14 | scope: FileScope, |
| 15 | enable_cache: bool, |
| 16 | ) -> anyhow::Result<AnnData<H5>> { |
| 17 | let h5_file = match scope { |
| 18 | FileScope::Read => H5::open(path_to_file)?, |
| 19 | FileScope::ReadWrite => H5::open_rw(path_to_file)?, |
| 20 | }; |
| 21 | let adata = AnnData::<H5>::open(h5_file)?; |
| 22 | if enable_cache { |
| 23 | adata.get_x().inner().enable_cache(); |
| 24 | } |
| 25 | Ok(adata) |
| 26 | } |
| 27 | |
| 28 | pub fn read_h5ad_memory<P: AsRef<Path>>(path_to_file: P) -> anyhow::Result<IMAnnData> { |
| 29 | let adata = read_h5ad(path_to_file, FileScope::Read, false)?; |