def get_chr_prefix(sam_file):
    """
    Check if chromosomes names contains "chr".
    :param sam_file: SAM file already opened for reading
    :return: chromosome prefix (either 'chr' or '')
    """
    prefix = ''
    for r in sam_file.fetch():
        if not r.is_unmapped:
            if 'chr' in r.reference_name:
                prefix = 'chr'
            else:
                prefix = ''
            break
    return prefix
