Thanks Youri,

That's the bit of code I was worrying about (BAM grooming). I've filed an issue for this:


On Wed, Dec 16, 2015 at 9:47 AM, Y. Hoogstrate <> wrote:
Great news Peter,

This is how Galaxy seems to do it:

        command = "samtools sort %s %s" % ( file_name, tmp_sorted_dataset_file_name_prefix )
        proc = subprocess.Popen( args=command, shell=True, cwd=tmp_dir, stderr=open( stderr_name, 'wb' ) )

Since galaxy ships with a builtin pysam (0.8.3) wheel, I think it would be handier to use pysam for sorting (once updated to the latest HTSlib).
Pysam now also has all samtools c functions directly builtin:

pysam.index( "arg1", "arg2" ) is the equivalent of the command line argument samtools index "arg1" "arg2"