def get_motif_coordinates(end_site, motif_def, pairing,
    motif_upstream_extension, motif_downstream_extension, min_target_length):
    """
    Returns motif coordinates based on end_site (1-based)
    """
    if motif_def is None:
        motif_def = 'seed'
    if motif_def == 'seed' or motif_def == 'seed_extended':
        mirna_start_pairing = 0
        if motif_def == 'seed':
            for p in pairing:
                if p == 0:
                    mirna_start_pairing += 1
                else:
                    break
        start_motif = end_site - len(pairing) + 1 - motif_upstream_extension
        end_motif = end_site - mirna_start_pairing + motif_downstream_extension
    elif motif_def == 'site':
        start_motif = (end_site - min_target_length + 1 -
            motif_upstream_extension)
        end_motif = end_site + motif_downstream_extension
    return start_motif, end_motif
