Make sure the domains and ranges of the SequenceMaps match the Sequences.

def _validate_mapping_signature(self):
        '''Make sure the domains and ranges of the SequenceMaps match the Sequences.'''

        # rosetta_to_atom_sequence_maps
        for chain_id, sequence_map in self.rosetta_to_atom_sequence_maps.iteritems():
            # Check that all Rosetta residues have a mapping
            assert(sorted(sequence_map.keys()) == sorted(self.rosetta_sequences[chain_id].ids()))

            # Check that all ATOM residues in the mapping exist and that the mapping is injective
            rng = set(sequence_map.values())
            atom_residue_ids = set(self.atom_sequences[chain_id].ids())
            assert(rng.intersection(atom_residue_ids) == rng)
            assert(len(rng) == len(sequence_map.values()))

        # atom_to_seqres_sequence_maps
        for chain_id, sequence_map in self.atom_to_seqres_sequence_maps.iteritems():
            # Check that all ATOM residues have a mapping
            #print(sorted(sequence_map.keys()))
            #print(sorted(self.atom_sequences[chain_id].ids()))
            assert(sorted(sequence_map.keys()) == sorted(self.atom_sequences[chain_id].ids()))

            # Check that all SEQRES residues in the mapping exist and that the mapping is injective
            rng = set(sequence_map.values())
            seqres_residue_ids = set(self.seqres_sequences[chain_id].ids())
            assert(rng.intersection(seqres_residue_ids) == rng)
            assert(len(rng) == len(sequence_map.values()))

        # seqres_to_uniparc_sequence_maps
        for chain_id, sequence_map in self.seqres_to_uniparc_sequence_maps.iteritems():
            # Check that acceptable_sequence_percentage_match% of all SEQRES residues have a mapping (there may have been
            # insertions or bad mismatches i.e. low BLOSUM62/PAM250 scores). I chose 80% arbitrarily but this can be overridden
            #  with the acceptable_sequence_percentage_match argument to the constructor.
            if self.sequence_types[chain_id] == 'Protein' or self.sequence_types[chain_id] == 'Protein skeleton':
                if sequence_map:
                    mapped_SEQRES_residues = set(sequence_map.keys())
                    all_SEQRES_residues = set(self.seqres_sequences[chain_id].ids())
                    if len(all_SEQRES_residues) >= 20:
                        match_percentage = 100.0 * (float(len(mapped_SEQRES_residues))/float((len(all_SEQRES_residues))))
                        if not (self.acceptable_sequence_percentage_match <= match_percentage <= 100.0):
                            if not set(list(str(self.seqres_sequences[chain_id]))) == set(['X']):
                                # Skip cases where all residues are unknown e.g. 1DEQ, chain M
                                raise Exception("Chain %s in %s only had a match percentage of %0.2f%%" % (chain_id, self.pdb_id, match_percentage))

            # Check that all UniParc residues in the mapping exist and that the mapping is injective
            if self.pdb_chain_to_uniparc_chain_mapping.get(chain_id):
                rng = set([v[1] for v in sequence_map.values()])
                uniparc_chain_id = self.pdb_chain_to_uniparc_chain_mapping[chain_id]
                uniparc_residue_ids = set(self.uniparc_sequences[uniparc_chain_id].ids())
                assert(rng.intersection(uniparc_residue_ids) == rng)
                if len(rng) != len(sequence_map.values()):
                    rng_vals = set()
                    for x in sequence_map.values():
                        if x[1] in rng_vals:
                            err_msg = ['The SEQRES to UniParc map is not injective for %s, chain %s; the element %s occurs more than once in the range.' % (self.pdb_id, chain_id, str(x))]

                            err_msg.append(colortext.make('The seqres_to_uniparc_sequence_maps mapping is:', color = 'green'))
                            for k, v in sequence_map.map.iteritems():
                                err_msg.append(' %s -> %s' % (str(k).ljust(7), str(v).ljust(20)))

                            err_msg.append(colortext.make('The clustal_seqres_to_uniparc_sequence_maps mapping is:', color = 'green'))
                            for k, v in self.clustal_seqres_to_uniparc_sequence_maps[chain_id].map.iteritems():
                                err_msg.append(' %s -> %s' % (str(k).ljust(7), str(v).ljust(20)))

                            err_msg.append(colortext.make('The sifts_seqres_to_uniparc_sequence_maps mapping is:', color = 'green'))
                            for k, v in self.sifts_seqres_to_uniparc_sequence_maps[chain_id].map.iteritems():
                                err_msg.append(' %s -> %s' % (str(k).ljust(7), str(v).ljust(20)))

                            raise Exception('\n'.join(err_msg))
                        rng_vals.add(x[1])