-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rs
47 lines (42 loc) · 1.33 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
extern crate bedder;
use bedder::sniff;
use clap::Parser;
use std::env;
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about=None)]
struct Args {
#[arg(help = "input file", short = 'a')]
query_path: PathBuf,
#[arg(help = "other file", short = 'b', required = true)]
other_paths: Vec<PathBuf>,
#[arg(
help = "genome file for chromosome ordering",
short = 'g',
required = true
)]
genome_file: PathBuf,
}
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
if env::var("RUST_LOG").is_err() {
env::set_var("RUST_LOG", "bedder=info");
}
env_logger::init();
log::info!("starting up");
let args = Args::parse();
let chrom_order =
bedder::chrom_ordering::parse_genome(std::fs::File::open(&args.genome_file)?)?;
let a_iter = sniff::open_file(&args.query_path)?;
let b_iters: Vec<_> = args
.other_paths
.iter()
.map(|p| sniff::open_file(p).expect("error opening file"))
.collect();
let ii = bedder::intersection::IntersectionIterator::new(a_iter, b_iters, &chrom_order)?;
// iterate over the intersections
ii.for_each(|intersection| {
let intersection = intersection.expect("error getting intersection");
println!("{:?}", intersection);
});
Ok(())
}