This function defines the ligand atoms that are closest to the residues that will be plotted
        in the final graph.

def find_the_closest_atoms(self,topology):
        """
        This function defines the ligand atoms that are closest to the residues that will be plotted
        in the final graph.
        """

        # The measurements are made to ligand molecule without hydrogen atoms (ligand_noH) because the
        # hydrogen atoms are not plotted in the final graph
        self.universe.load_new(topology)
        self.universe.ligand_noH = self.universe.ligand.select_atoms("not name H*")
        ligand_positions = self.universe.ligand_noH.positions

        for residue in self.dict_of_plotted_res.keys():
            residue_selection = self.universe.select_atoms("resname "+residue[0]+" and resid "+residue[1]+" and segid "+ residue[2])
            residue_positions = residue_selection.positions
            dist_array = MDAnalysis.analysis.distances.distance_array(ligand_positions,residue_positions)
            min_values_per_atom={}
            i=0
            for atom in self.universe.ligand_noH:
                min_values_per_atom[atom.name]=dist_array[i].min()
                i+=1
            sorted_min_values = sorted(min_values_per_atom.items(), key=operator.itemgetter(1))
            self.closest_atoms[residue]=[(sorted_min_values[0][0],sorted_min_values[0][1])]