See here: https://github.com/CollepardoLab/Minimal_Chromatin/blob/main/contacts.py and here: https://github.com/CollepardoLab/lammps_dna/blob/master/setup_scripts/MINIMAL_RECIPES/LLPS/uniform_run_from_most_populated/analysis_esmae.py