[FIX] Adds mutexes and auto-detect of SGEJobArrays

Fixes #8. When using SGE Job Arrays to run samples in parallel, only 1
sample is allowed to prepare data, and only the last sample to complete
is allowed to gather data.
- Currently using mkdir-based locking:
      http://mywiki.wooledge.org/BashFAQ/045