1#![allow(clippy::too_many_arguments)]
3#![allow(clippy::should_implement_trait)]
4#![allow(clippy::type_complexity)]
5
6pub mod bed;
31pub mod commands;
32pub mod config;
33pub mod genome;
34pub mod index;
35pub mod interval;
36pub mod parallel;
37pub mod streaming;
38
39pub use bed::{read_intervals, read_records, BedReader};
41pub use index::IntervalIndex;
42pub use interval::{BedRecord, Interval, Strand};
43
44pub const VERSION: &str = env!("CARGO_PKG_VERSION");
46
47pub mod prelude {
49 pub use crate::bed::{read_intervals, read_records, BedReader};
50 pub use crate::commands::{
51 ClosestCommand, CoverageCommand, IntersectCommand, MergeCommand, SortCommand,
52 SubtractCommand, WindowCommand,
53 };
54 pub use crate::index::IntervalIndex;
55 pub use crate::interval::{BedRecord, Interval, Strand};
56}
57
58#[cfg(test)]
59mod tests {
60 #[test]
61 fn test_basic_workflow() {
62 use crate::bed::parse_intervals;
63 use crate::commands::MergeCommand;
64
65 let content = "chr1\t100\t200\nchr1\t150\t250\nchr1\t300\t400\n";
66 let intervals = parse_intervals(content).unwrap();
67
68 let cmd = MergeCommand::new();
69 let merged = cmd.merge(intervals);
70
71 assert_eq!(merged.len(), 2);
72 assert_eq!(merged[0].start, 100);
73 assert_eq!(merged[0].end, 250);
74 }
75
76 #[test]
77 fn test_intersect_workflow() {
78 use crate::bed::parse_intervals;
79 use crate::commands::IntersectCommand;
80 use crate::index::IntervalIndex;
81
82 let a_content = "chr1\t100\t200\nchr1\t300\t400\n";
83 let b_content = "chr1\t150\t250\n";
84
85 let a = parse_intervals(a_content).unwrap();
86 let b = parse_intervals(b_content).unwrap();
87
88 let cmd = IntersectCommand::new();
89 let b_index = IntervalIndex::from_intervals(b);
90 let results = cmd.find_intersections(&a, &b_index);
91
92 assert_eq!(results.len(), 1);
93 }
94}