Sort `bamfile` using samtools

    :param toil.fileStore.FileID bamfile: fsID for the bam file
    :param str sample_type: Description of the sample to inject into the filename
    :param dict univ_options: Dict of universal options used by almost all tools
    :param dict samtools_options: Options specific to samtools
    :return: fsID for the sorted bamfile
    :rtype: toil.fileStore.FileID

def sort_bamfile(job, bamfile, sample_type, univ_options, samtools_options):
    """
    Sort `bamfile` using samtools

    :param toil.fileStore.FileID bamfile: fsID for the bam file
    :param str sample_type: Description of the sample to inject into the filename
    :param dict univ_options: Dict of universal options used by almost all tools
    :param dict samtools_options: Options specific to samtools
    :return: fsID for the sorted bamfile
    :rtype: toil.fileStore.FileID
    """
    work_dir = os.getcwd()
    in_bamfile = ''.join([sample_type, '.bam'])
    out_bamfile = '_'.join([sample_type, 'sorted.bam'])
    input_files = {
        in_bamfile: bamfile}
    input_files = get_files_from_filestore(job, input_files, work_dir, docker=True)
    parameters = ['sort',
                  '-o', docker_path(out_bamfile),
                  '-O', 'bam',
                  '-T', 'temp_sorted',
                  '-@', str(samtools_options['n']),
                  input_files[in_bamfile]]
    docker_call(tool='samtools', tool_parameters=parameters, work_dir=work_dir,
                dockerhub=univ_options['dockerhub'], tool_version=samtools_options['version'])
    job.fileStore.deleteGlobalFile(bamfile)
    job.fileStore.logToMaster('Ran samtools-sort on %s:%s successfully'
                              % (univ_options['patient'], sample_type))
    return job.fileStore.writeGlobalFile(out_bamfile)