MCPcopy Index your code
hub / github.com/alignoth/alignoth / read_fasta

Function read_fasta

src/plot.rs:73–85  ·  view source on GitHub ↗

Reads the given region from the given fasta file and returns it as a vec of the bases as chars

(path: P, region: &Region)

Source from the content-addressed store, hash-verified

71
72/// Reads the given region from the given fasta file and returns it as a vec of the bases as chars
73fn 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(&region.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)]

Callers 3

create_plot_dataFunction · 0.85
from_recordMethod · 0.85
test_fetch_referenceFunction · 0.85

Calls 3

OkFunction · 0.85
contextMethod · 0.45
mapMethod · 0.45

Tested by 1

test_fetch_referenceFunction · 0.68