An outbreak of the hospital superbug MRSA has been brought to an end by UK doctors cracking the bacterium's genetic code.
It led to them finding one member of staff at Rosie Hospital, in Cambridge, who may have unwittingly carried and spread the infection.
They say it is the first time rapid genetic testing has been used to track and then stop an outbreak.
One expert said this would soon become "standard practice" in hospitals.
Doctors were concerned after MRSA was detected in 12 babies during routine screening.
However, current tests could not tell if it was one single outbreak being spread around the unit or if they were separate cases being brought into the hospital. About one in 100 people carry MRSA on their skin without any health problems.
To find out, researchers at the University of Cambridge and the Sanger Institute embarked on more sophisticated version of a paternity test.
They compared the entire genetic code of MRSA bugs from each baby to build a family tree. It showed they were all closely related and part of the same outbreak.
After two months without a case and deep cleaning the ward, another case appeared. Analysing the DNA showed that it was again part of the outbreak and attention turned to a carrier.
Tests on 154 members of staff showed that one was also carrying MRSA, which may have been spread to babies in the unit. They were treated to remove the infection.
"We believe this brought the outbreak to a close," said Dr Julian Parkhill, from the Sanger Institute.
"This is really exciting for us because it gave the hospital the opportunity to intervene. "We think this is the first case where whole genome sequencing has actually led to a clinical intervention and brought the outbreak to a close."
The study was published in the medical journal Lancet Infectious Diseases.