def remove_GATK_bai(bamfile):
    """
    A bug in some versions of GATK cause it to create an x.bai file, and this gets in the way of using the properly named x.bam.bai file. If the given file exists, delete it.
    """
    bad_bai = os.path.splitext(bamfile)[0] + ".bai"
    try:
        os.remove(bad_bai)
    except __HOLE__, e:
        # Ignore error only if it is OSError #2, ie File Not Found
        if e.errno != 2:
            raise e
dataset/ETHPy150Open vlsci/variant_calling_pipeline/pipeline.py/remove_GATK_bai