Skip to content

Commit

Permalink
clamp number of counts based on chromsize for #43
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcampbelljr committed Dec 12, 2024
1 parent bb34c5d commit f12fd2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions gtars/src/uniwig/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ pub fn uniwig_main(
smoothsize,
),
stepsize,
current_chrom_size,
);
}
"bedGraph" => {
Expand Down Expand Up @@ -507,6 +508,7 @@ pub fn uniwig_main(
smoothsize,
),
stepsize,
current_chrom_size,
);
}
"csv" => {
Expand Down Expand Up @@ -658,6 +660,7 @@ pub fn uniwig_main(
0,
),
stepsize,
current_chrom_size,
);
}
"csv" => {
Expand Down
3 changes: 2 additions & 1 deletion gtars/src/uniwig/writing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit f12fd2f

Please sign in to comment.