1pub mod blat;
4pub mod interval;
5pub mod io;
6pub mod strategy;
7pub mod sv;
8
9#[cfg(feature = "python")]
10pub mod python;
11
12use colored::Colorize;
13use pyo3::prelude::*;
14
15use pyo3_stub_gen::derive::*;
16
17#[gen_stub_pyfunction(module = "deepbiop.utils")]
18#[pyfunction]
19#[pyo3(signature = (sequence, targets, text_width=None))]
20pub fn highlight_targets(
21 sequence: &str,
22 targets: Vec<(usize, usize)>,
23 text_width: Option<usize>,
24) -> String {
25 let mut highlighted = String::new();
26 let mut last_end = 0;
27 for (start, end) in targets {
28 highlighted.push_str(&sequence[last_end..start]);
29 highlighted.push_str(&sequence[start..end].magenta().bold().to_string());
30 last_end = end;
31 }
32 highlighted.push_str(&sequence[last_end..]);
33 let text_width = text_width.unwrap_or(80);
34 let chunked = textwrap::wrap(&highlighted, text_width);
35 chunked.join("\n")
36}
37
38#[cfg(test)]
39mod tests {
40 use super::*;
41
42 #[test]
43 fn test_highlight() {
44 let sequence = "ATGCACTGACTGACATGCACTGACTGAC";
45
46 let hstr = highlight_targets(sequence, vec![(0, 3), (10, 13)], None);
47
48 println!("{}", hstr);
49 }
50}