This function takes a PDB ID, maps it to UniProt ACCs, then returns the common set of PDB IDs related to those ACCs.
       The purpose is to find any PDB files related to pdb_id, particularly for complexes, such that the other PDB files
       contain identical sequences or mutant complexes.

def get_common_PDB_IDs(pdb_id, cache_dir = None, exception_on_failure = True):
    '''This function takes a PDB ID, maps it to UniProt ACCs, then returns the common set of PDB IDs related to those ACCs.
       The purpose is to find any PDB files related to pdb_id, particularly for complexes, such that the other PDB files
       contain identical sequences or mutant complexes.'''
    m = pdb_to_uniparc([pdb_id], cache_dir = cache_dir)
    UniProtACs = []
    if pdb_id in m:
        for entry in m[pdb_id]:
            if entry.UniProtACs:
                UniProtACs.extend(entry.UniProtACs)
            elif exception_on_failure:
                raise Exception('No UniProtAC for one entry.Lookup failed.')
    elif exception_on_failure:
        raise Exception('Lookup failed.')

    if not UniProtACs:
        if exception_on_failure:
            raise Exception('Lookup failed.')
        else:
            return None
    common_set = set(uniprot_map('ACC', 'PDB_ID', [UniProtACs[0]], cache_dir = cache_dir).get(UniProtACs[0], []))
    for acc in UniProtACs[1:]:
         common_set = common_set.intersection(set(uniprot_map('ACC', 'PDB_ID', [acc], cache_dir = cache_dir).get(acc, [])))
    return sorted(common_set)