def cigar_conversion(cigar):
    """Convert character or integer to corresponding integer or character for the SAM/BAM formatting
    :param cigar: character or int to get corresponding CIGAR equivalent
    """
    assert type(cigar) is str or type(cigar
        ) is int, 'Cigar character must be int or str'
    chars = ['M', 'I', 'D', 'N', 'S', 'H', 'P', '=', 'X']
    if type(cigar) is str:
        assert cigar in chars, 'Character is not a cigar string character'
        return chars.index(cigar)
    else:
        assert 0 <= cigar <= 8, 'Integer must be between 0 and 8'
        return chars[cigar]
