Statistical mechanics of warm and cold unfolding in proteins