# Path: contact_map/topology.py
# def check_topologies(map0, map1, override_topology):
#     """Check if the topologies of two contact maps are ok or can be fixed"""
#     # Grab the two topologies
#     top0 = map0.topology
#     top1 = map1.topology
# 
#     # Figure out the overlapping atoms
#     all_atoms0 = set(map0._all_atoms)
#     all_atoms1 = set(map1._all_atoms)
# 
#     # Figure out overlapping residues
#     all_residues0 = set(map0._all_residues)
#     all_residues1 = set(map1._all_residues)
# 
#     # This is intersect (for difference)
#     overlap_atoms = all_atoms0.intersection(all_atoms1)
#     overlap_residues = all_residues0.intersection(all_residues1)
#     top0, top1, topology = _get_default_topologies(top0, top1,
#                                                    override_topology)
# 
#     if override_topology:
#         override_topology = topology
# 
#     all_atoms_ok = check_atoms_ok(top0, top1, overlap_atoms)
#     all_res_ok = check_residues_ok(top0, top1, overlap_residues,
#                                    override_topology)
#     if not all_res_ok and not all_atoms_ok:
#         topology = md.Topology()
# 
#     return all_atoms_ok, all_res_ok, topology


from .topology import check_topologies
        self._set_mixing = set_mixing

    def get_parameters(self, map0, map1):
        """Get the required parameters to initialise ContactDifference"""
        failed = map0._check_compatibility(map1, err=None)
        return self._fix_parameters(map0, map1, failed)

    def _fix_parameters(self, map0, map1, failed):
        # First make the default output
        output = {'topology': map0.topology,
                  'query': map0.query,
                  'haystack': map0.haystack,
                  'cutoff': map0.cutoff,
                  'n_neighbors_ignored': map0.n_neighbors_ignored}

        for fail in failed:
            if fail in {'query', 'haystack'}:
                map0_set = set(getattr(map0, fail))
                map1_set = set(getattr(map1, fail))
                fixed = getattr(map0_set, self._set_mixing)(map1_set)
            elif fail in {'cutoff', 'n_neighbors_ignored'}:
                # We just set them to None
                fixed = None
            elif fail == 'topology':
                # This requires quite a bit of logic
                fixed = self._check_topology(map0, map1)
            output[fail] = fixed
        return tuple(output.values())

    def _check_topology(self, map0, map1):

# Path: contact_map/topology.py
# def check_topologies(map0, map1, override_topology):
#     """Check if the topologies of two contact maps are ok or can be fixed"""
#     # Grab the two topologies
#     top0 = map0.topology
#     top1 = map1.topology
# 
#     # Figure out the overlapping atoms
#     all_atoms0 = set(map0._all_atoms)
#     all_atoms1 = set(map1._all_atoms)
# 
#     # Figure out overlapping residues
#     all_residues0 = set(map0._all_residues)
#     all_residues1 = set(map1._all_residues)
# 
#     # This is intersect (for difference)
#     overlap_atoms = all_atoms0.intersection(all_atoms1)
#     overlap_residues = all_residues0.intersection(all_residues1)
#     top0, top1, topology = _get_default_topologies(top0, top1,
#                                                    override_topology)
# 
#     if override_topology:
#         override_topology = topology
# 
#     all_atoms_ok = check_atoms_ok(top0, top1, overlap_atoms)
#     all_res_ok = check_residues_ok(top0, top1, overlap_residues,
#                                    override_topology)
#     if not all_res_ok and not all_atoms_ok:
#         topology = md.Topology()
# 
#     return all_atoms_ok, all_res_ok, topology


# Path: contact_map/fix_parameters.py
from .topology import check_topologies

        self._set_mixing = set_mixing

    def get_parameters(self, map0, map1):
        """Get the required parameters to initialise ContactDifference"""
        failed = map0._check_compatibility(map1, err=None)
        return self._fix_parameters(map0, map1, failed)

    def _fix_parameters(self, map0, map1, failed):
        # First make the default output
        output = {'topology': map0.topology,
                  'query': map0.query,
                  'haystack': map0.haystack,
                  'cutoff': map0.cutoff,
                  'n_neighbors_ignored': map0.n_neighbors_ignored}

        for fail in failed:
            if fail in {'query', 'haystack'}:
                map0_set = set(getattr(map0, fail))
                map1_set = set(getattr(map1, fail))
                fixed = getattr(map0_set, self._set_mixing)(map1_set)
            elif fail in {'cutoff', 'n_neighbors_ignored'}:
                # We just set them to None
                fixed = None
            elif fail == 'topology':
                # This requires quite a bit of logic
                fixed = self._check_topology(map0, map1)
            output[fail] = fixed
        return tuple(output.values())

    def _check_topology(self, map0, map1):

        all_atoms_ok, all_res_ok, topology = check_topologies(