We present a method for deriving energy functions for protein folding by ma
ximizing the thermodynamic average of the overlap with the native state. Th
e method has been tested by using the pairwise contact approximation of the
energy function and generating alternative structures by threading sequenc
es over a database of 1,169 structures. With the derived energy function, m
ost native structures: (i) have minimal energy and (ii) are thermodynamical
ly rather stable, and (iii) the corresponding energy landscapes are smooth.
Precisely, 92% of the 1,013 x-ray structures are stabilized. Most failures
can be attributed to the neglect of interactions between chains forming po
lychain proteins and of interactions with cofactors, When these are conside
red, only nine cases remain unexplained. In contrast, 38% of NMR structures
are not assigned properly.