Optimal variable selection and adaptive noisy compressed sensing