sstadick / perbase

Per-base per-nucleotide depth analysis
MIT License
115 stars 13 forks source link

Missing bam/cram file should return an error code #57

Open patbohn opened 1 year ago

patbohn commented 1 year ago

Hi, when running perbase base-depth with an incorrect BAM/CRAM path, even though stderr reports thread '<unnamed>' panicked at 'Indexed BAM/CRAM: FileNotFound [...] perbase/src/lib/par_granges.rs:159:72, it seems that no error code was returned (i.e. it apparently returned 0). This can be an issue when using pipeline or workload managers.

sstadick commented 1 year ago

Thanks for making this issue! I look into it and get an update out in the near future. That is definitely not the desired behavior, it should exit > 0.👍

nano-pat commented 2 months ago

Small bump - I think what's happening here is that while you're catching any Error returned here:

https://github.com/sstadick/perbase/blob/abdfb7595ac8c42cc24d93b80175fb3e4585d7c6/src/main.rs#L38

A missing file will not return an Error, but just panic due to the .expect() call here:

https://github.com/sstadick/perbase/blob/abdfb7595ac8c42cc24d93b80175fb3e4585d7c6/src/lib/par_granges.rs#L159

For the specific call in granges I suppose returning the Error early should work as the output of the process_region function is already a Result type.