The problem was that there were two parts of the code which read from stdin. So the first read works, but the second read doesn't as stdin has been emptied.
The second place that read from stdin was the function to calculate the genome size, which only needs the header. So I just return a copy of the header from the first read and then made that the input to the get_genome_size function.
I've also removed an unwrap or two relating to reading the BAM file as unwrapping assumes the BAM will always been Ok, which it might not. And the subsequent error would have been cryptic.
I also made - the default value for input if no argument is given. This removes the need to add - explicitly when calling cramino.
This PR fixes reading a BAM from stdin.
The problem was that there were two parts of the code which read from stdin. So the first read works, but the second read doesn't as stdin has been emptied.
The second place that read from stdin was the function to calculate the genome size, which only needs the header. So I just return a copy of the header from the first read and then made that the input to the
get_genome_size
function.I've also removed an
unwrap
or two relating to reading the BAM file as unwrapping assumes the BAM will always beenOk
, which it might not. And the subsequent error would have been cryptic.I also made
-
the default value for input if no argument is given. This removes the need to add-
explicitly when callingcramino
.