diff --git a/gtars/src/uniwig/mod.rs b/gtars/src/uniwig/mod.rs index 99fb5bf..3e0ecd0 100644 --- a/gtars/src/uniwig/mod.rs +++ b/gtars/src/uniwig/mod.rs @@ -316,6 +316,7 @@ pub fn uniwig_main( smoothsize, ), stepsize, + current_chrom_size, ); } "bedGraph" => { @@ -507,6 +508,7 @@ pub fn uniwig_main( smoothsize, ), stepsize, + current_chrom_size, ); } "csv" => { @@ -658,6 +660,7 @@ pub fn uniwig_main( 0, ), stepsize, + current_chrom_size, ); } "csv" => { diff --git a/gtars/src/uniwig/writing.rs b/gtars/src/uniwig/writing.rs index 446a373..45a363b 100644 --- a/gtars/src/uniwig/writing.rs +++ b/gtars/src/uniwig/writing.rs @@ -96,6 +96,7 @@ pub fn write_to_wig_file( chromname: String, start_position: i32, stepsize: i32, + chrom_size: i32, ) { let path = std::path::Path::new(&filename).parent().unwrap(); let _ = create_dir_all(path); @@ -117,7 +118,7 @@ pub fn write_to_wig_file( let mut buf = BufWriter::new(file); - for count in counts.iter() { + for count in counts.iter().take(chrom_size as usize) { // must set upper bound for wiggles based on reported chromsize, this is for downstream tool interoperability writeln!(&mut buf, "{}", count).unwrap(); } buf.flush().unwrap();