There is a lot of tools out there, very useful for command line usage, and very widely used in Bioinformatics, which rapidly turns out to be annoying (may be, sometimes) if we are writing a pipeline that cares about I/O connection and each tasks' exit status.

I am writing a pipeline using samtools, and samtools turns out to be a little bit annoying in the I/O management, because sometimes it generates an output file, but you don't really explicitly name that file. Sometimes, other tools don't even prompt for output files, or some other tools ask users to provide paths literally which adds up more turnarounds that need to be introduced and this can be a bit frustrating.
Here is an example using samtools. I am wrapping a call to samtools on a file that does not exist, the command is failing but the exit code is still zero which is a bit misleading if we care about reporting the status of the entire pipeline, which means here it means that the sort went Ok and this will trigger other tasks, which is wrong

I am cross posting to CodersCrowd as well with a code you can run on the browser: http://coderscrowd.com/app/codes/view/288. You can see that either the status coming back from the docker image and the one coming back from the python interpreter itself (which is basically samtools exit status) is being zero, and it shouldn't be.

![< image not found >][1]

 [1]: http://s12.postimg.org/izkv3yeu5/Screen_Shot_2014_12_02_at_2_18_11_PM.png
Thank you all for your contributions.

To all those who will be interested in this kind of problems, the overall message that should be retained from this discussion is : when there is a problem in the source, it should be treated in the source, whatever wrapper, codes, tricks that you may end up doing, will most likely be not reproducible at all.

I end up cross posting to samtools mailing list as well and here is the final thought :

```
You are testing an old version of samtools.  In the particular case of samtools sort's exit status
$ samtools-1.0 sort S222.bam S22.sorted; echo "exit code $?"
[E::hts_open] fail to open file 'S222.bam'
[bam_sort_core] fail to open file S222.bam
exit code 1
```

So as you can see, it was a minor bug, and that was fixed in the last version of samtools

Thank you all for contributing to this discussion