the main code for creating clustering files