Defining topological equivalences in protein structures by means of a dynamic programming algorithm