We present two new sets of energy functions for protein structure recognition. The first set of potentials is based on the positions of alpha- and the second on positions of beta-carbon atoms of amino acid residues. The potentials are derived using a theory of Boltzmann-like statistics of protein structure by Finkelstein et al. The energy terms incorporate both long-range interactions between residues remote along a chain and short-range interactions between near neighbors. Distance-dependence is approximated by a piecewise constant function defined on intervals of equal size. The size of this interval is optimized. A database of 222 non-homologous proteins was used both for the derivation of the potentials, and for the "threading" test originally suggested by Hendlich et al. For threading, we used 102 non-homologous protein chains of 60 to 200 residues. The energy of each of the native structures was compared with the energy of 45 to 20 thousand alternative structures generated by threading. Of these 102 native structures 94 have the lowest energy with alpha-carbon-based potentials, and even more, 100 of these 102 structures, have the lowest energy with the beta-carbon-based potentials.