Last active
February 23, 2023 21:13
-
-
Save zdk123/720a7c490a4e8f067d5ae97fce1b9a63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Prints the compressed-uncompressed position pairs of a GZ index. | |
//! Unmodified from: | |
//! https://github.com/zaeleus/noodles/blob/master/noodles-bgzf/examples/bgzf_gzi_inspect.rs | |
use std::{env, io, fs}; | |
use std::io::prelude::*; | |
use std::io::BufReader; | |
use std::fs::File; | |
use noodles_bgzf::gzi; | |
fn buf_read(src: String) -> io::Result<gzi::Index> { | |
let file_size = fs::metadata(src.clone()).expect("could not get file meta data").len() as usize; | |
let buf_size = file_size/8; | |
let file = File::open(src).expect("failed to open file"); | |
let mut buf_reader = BufReader::new(&file); | |
let mut buffer = Vec::with_capacity(buf_size); | |
buf_reader.read_to_end(&mut buffer)?; | |
let mut reader = gzi::Reader::new(&buffer[..]); | |
reader.read_index() | |
} | |
fn main() -> io::Result<()> { | |
let src = env::args().nth(1).expect("missing src"); | |
let index = buf_read(src)?; | |
for record in &index { | |
println!("{}\t{}", record.0, record.1); | |
} | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment