Preparing nucleic acids for analysis