A new breakthrough could point scientists towards stopping the spread of genes that pose a threat to us, such as those involved in antibiotic resistance.
The new discovery, made by a leading New Zealand microbiologist and US collaborators, reveals how the ability of bacteria to transfer genes is determined by previously unknown rules that are stamped into the recipient's DNA.
In nature, bacteria are constantly exchanging genetic material, even between distant relatives, in a process called horizontal gene transfer.
Importantly, the genetic material donated from one bacterium to another may carry novel traits like metabolic pathways, virulence genes and even antibiotic resistance elements.
But this didn't happen randomly - and the transfer was actually governed by something found in all bacterial chromosomes.
Their name: architecture imparting sequences, or AIMS.
Massey University's Dr Heather Hendrickson and her colleagues found that if sets of AIMS were well matched between a donor and recipient genome, then the DNA moving between those genomes could be maintained.
But if the sets weren't well matched, then the opposite was true, and it was this pattern that effectively set the rules.
When it came to horizontal gene transfer, AIMS were a little like blood groups for genetic exchange between bacterial species, Hendrickson said.
"AIMS are most likely to be similar in closely-related bacteria, but when it comes to distant transfer events, there were some surprises.
"For example, one of our findings was that some species have sequence structures that make them good general donors but very selective recipients, a little like people with group O-blood types."
Critically, AIMS were easily recognised in all bacterial chromosomes, making possible the prediction of routes of likely gene transfer.
"If we can understand the properties that govern this transfer species, perhaps in the future we can prevent the spread of genes we are worried about, like antibiotic resistance genes or virulence genes, which allow bacteria to avoid things like the host's immune response."
Study co-author Professor Jeffrey Lawrence, of the University of Pittsburgh, said even strains of the same bacterial species could share a minority of their common gene pool - something that reflected an "enormous" rate of horizontal gene transfer.
"Despite this massive influx, bacteria can be organised into genera, families and higher taxonomic groups based on genetic similarity," Lawrence said.
"This implies that interspecific gene transfer is not random and may be more frequent between more closely-related bacteria."
The missing piece of the puzzle had been a molecular mechanism for preventing rampant gene transfer between distantly-related species.
"We now see that AIMS can impede these distant transfer events, thereby structuring the road map of gene transfer between species."