A switch from α-helical to β-strand conformation during co-translational protein folding