Computational Approach to the Statistical Mechanics of Protein Folding