<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def index_bamfile(job, bamfile, sample_type, univ_options, samtools_options, sample_info=None, export=True):
 """ Index `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 :param str sample_info: Information regarding the sample that will beinjected into the filename as `sample_type`_`sample_info`.bam(.bai) :param bool export: Should the bam and bai be exported to the output directory? :return: Dict containing input bam and the generated index (.bam.bai) output_files: |- '<sample_type>(_<sample_info>).bam': fsID +- '<sample_type>(_<sample_info>).bam.bai': fsID :rtype: dict """

    work_dir = os.getcwd()
    in_bamfile = sample_type
    if sample_info is not None:
        assert isinstance(sample_info, str)
        in_bamfile = '_'.join([in_bamfile, sample_info])
    in_bamfile += '.bam'
    input_files = {
        in_bamfile: bamfile}
    input_files = get_files_from_filestore(job, input_files, work_dir, docker=True)
    parameters = ['index',
                  input_files[in_bamfile]]
    docker_call(tool='samtools', tool_parameters=parameters, work_dir=work_dir,
                dockerhub=univ_options['dockerhub'], tool_version=samtools_options['version'])
    out_bai = '/'.join([work_dir, in_bamfile + '.bai'])
    output_files = {in_bamfile: bamfile,
                    in_bamfile + '.bai': job.fileStore.writeGlobalFile(out_bai)}
    if export:
        export_results(job, bamfile, os.path.splitext(out_bai)[0], univ_options,
                       subfolder='alignments')
        export_results(job, output_files[in_bamfile + '.bai'], out_bai, univ_options,
                       subfolder='alignments')
    job.fileStore.logToMaster('Ran samtools-index on %s:%s successfully'
                              % (univ_options['patient'], sample_type))
    return output_files