the `system()` calls to `samtools` might be unreliable and inefficient - use `Rsamtools`. While at it, change copy to `file.copy` also.