Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
brentp committed Jan 22, 2024
1 parent 83123d0 commit 852800b
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions examples/intersect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fs;
use std::io::{self, BufReader, BufWriter, Write};
use std::path::PathBuf;

use bedder::{intersections, sniff};
use bedder::sniff;
use clap::Parser;
extern crate bedder;
use crate::bedder::chrom_ordering::parse_genome;
Expand Down Expand Up @@ -67,7 +67,7 @@ fn main() -> io::Result<()> {
.collect::<io::Result<Vec<_>>>()?;

// bedder always requires a hashmap that indicates the chromosome order
let fh = BufReader::new(fs::File::open(args.fai)?);
let fh = BufReader::new(fs::File::open(&args.fai)?);
let h = parse_genome(fh)?;

// we can have any number of b (other_iterators).
Expand Down Expand Up @@ -122,15 +122,22 @@ fn main() -> io::Result<()> {
)?;
continue;
}
//eprintln!("report: {:?}", report);
//eprintln!("args: {:?}", &args);

writeln!(
&mut stdout,
"{}\t{}\t{}\t{}",
intersection.base_interval.chrom(),
intersection.base_interval.start(),
intersection.base_interval.stop(),
intersection.overlapping.len()
)?;
for r in report.into_iter() {
let a = r.a.as_ref().expect("a");
writeln!(
&mut stdout,
"{}\t{}\t{}\t{:?}",
a.chrom(),
a.start(),
a.stop(),
r.b.iter()
.map(|r| format!("{}:{}-{}", r.chrom(), r.start(), r.stop()))
.collect::<Vec<_>>()
)?;
}
}

Ok(())
Expand Down

0 comments on commit 852800b

Please sign in to comment.