Stochastic dynamics and the adaptive immune system