Reads the given region from the given fasta file and returns it as a vec of the bases as chars
(path: P, region: &Region)
| 71 | |
| 72 | /// Reads the given region from the given fasta file and returns it as a vec of the bases as chars |
| 73 | fn read_fasta<P: AsRef<Path> + std::fmt::Debug>(path: P, region: &Region) -> Result<Vec<char>> { |
| 74 | let mut reader = fasta::IndexedReader::from_file(&path).unwrap(); |
| 75 | let index = |
| 76 | fasta::Index::with_fasta_file(&path).context("error reading index file of input FASTA")?; |
| 77 | let _sequences = index.sequences(); |
| 78 | |
| 79 | let mut seq: Vec<u8> = Vec::new(); |
| 80 | |
| 81 | reader.fetch(®ion.target, region.start as u64, region.end as u64)?; |
| 82 | reader.read(&mut seq)?; |
| 83 | |
| 84 | Ok(seq.iter().map(|u| char::from(*u)).collect_vec()) |
| 85 | } |
| 86 | |
| 87 | /// A Read containing all relevant information for being plotted in a read plot |
| 88 | #[derive(Serialize, Debug, PartialEq, Eq)] |