Add index bam to function

Add index bam after get sorted bam.