Theory of helix-coil transitions in biopolymers