We present two new sets of energy functions for protein structure recognition, given the primary sequence of amino acids along the polypeptide chain. The first set of potentials is based on the positions of alpha- and the second on positions of beta- and alpha-carbon atoms of amino acid residues. The potentials are derived using a theory of Boltzmann-like statistics of protein structure. 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 the interval is optimized to preserve as much detail as possible without introducing excessive error due to limited statistics. A database of 214 non-homologous proteins was used both for the derivation of the potentials, and for the 'threading' test originally suggested by Hendlich et al. (1990) J. Mol. Biol., 216, 167-180. Special care is taken to avoid systematic error in this test. For threading, we used 100 non-homologous protein chains of 60-205 residues. The energy of each of the native structures was compared with the energy of 43,000 to 19,000 alternative structures generated by threading. Of these 100 native structures, 92 have the lowest energy with alpha-carbon-based potentials and, even more, 98 of these 100 structures, have the lowest energy with the beta- and alpha-carbon based potentials.