'Creates the index for the BCF file.'

def set_meta(self, dataset, overwrite=True, **kwd):

    index_file = dataset.metadata.bcf_index
    if (not index_file):
        index_file = dataset.metadata.spec['bcf_index'].param.new_file(dataset=dataset)
    dataset_symlink = os.path.join(os.path.dirname(index_file.file_name), ('__dataset_%d_%s' % (dataset.id, os.path.basename(index_file.file_name))))
    os.symlink(dataset.file_name, dataset_symlink)
    stderr_name = tempfile.NamedTemporaryFile(prefix='bcf_index_stderr').name
    command = ['bcftools', 'index', dataset_symlink]
    try:
        subprocess.check_call(args=command, stderr=open(stderr_name, 'wb'))
        shutil.move((dataset_symlink + '.csi'), index_file.file_name)
    except Exception as e:
        stderr = open(stderr_name).read().strip()
        raise Exception(('Error    setting    BCF    metadata:    %s' % (stderr or str(e))))
    finally:
        os.remove(stderr_name)
        os.remove(dataset_symlink)
    dataset.metadata.bcf_index = index_file
