def calc_site_distances(sites_list, id2cp_dic):
    """

    sites_list:
        List with site IDs on reference for which to calculate distances.
    id2cp_dic:
        site_id -> center position (1-based) on reference.

    >>> sites_list = ["sid1", "sid2", "sid3"]
    >>> id2cp_dic = {"sid1": 100, "sid2": 150, "sid3": 300}
    >>> calc_site_distances(sites_list, id2cp_dic)
    {'sid1,sid2': 50, 'sid1,sid3': 200, 'sid2,sid3': 150}

    """
    ids_seen_dic = {}
    sids2dist_dic = {}
    for sid1 in sites_list:
        for sid2 in sites_list:
            if sid1 == sid2:
                continue
            sid1sid2 = sid1 + "," + sid2
            sid2sid1 = sid2 + "," + sid1
            if sid1sid2 in ids_seen_dic:
                continue
            if sid2sid1 in ids_seen_dic:
                continue
            dist = abs(id2cp_dic[sid1] - id2cp_dic[sid2])
            sids2dist_dic[sid1sid2] = dist
            ids_seen_dic[sid1sid2] = 1
            ids_seen_dic[sid2sid1] = 1
    assert sids2dist_dic, "sids2dist_dic empty"
    return sids2dist_dic