Mechanism of foreign DNA selection in a bacterial adaptive immune system.