def get_bam_ref_name(bam_file):
    """Get first ref name in bam file"""
    import pysam
    samfile = pysam.AlignmentFile(bam_file, 'r')
    try:
        aln = samfile.fetch()
    except ValueError:
        return
    for a in aln:
        chr = samfile.get_reference_name(a.next_reference_id)
        if chr != None:
            break
    return chr
