A single molecule study of the conformational dynamics of nucleic acids in different environments