A bug-busting “black box” is being developed that can rapidly identify the source of hospital infections and help staff to stop them spreading.
The device, which combines sophisticated DNA profiling and database analysis, could be available within "a few years", say scientists.
In an early test of the technology, researchers halted an outbreak of the MRSA superbug in a special care baby unit at the Rosie Hospital in Cambridge.
By quickly identifying the bacterial strains from their genetic codes, or genomes, experts were able to target the transmission path of the infection and cut it off.
It is believed to be the first time DNA sequencing has been used to contain an infectious disease outbreak at a hospital.
The scientists are now developing the concept into a simple system that can be used routinely by hospital staff who are not genetics experts.
In future, it could be used to combat many kinds of infection outbreak, and also help doctors decide the best way of treating patients.
Professor Sharon Peacock, from Cambridge University, who led the research team, told a news briefing in London: "What we're working towards is effectively a 'black box'. Information on the genome sequence goes into the system and is interpreted, and what comes out the other end is a report to the health care worker.
"It could, for example, determine the species of the bacterium; it could determine antibiotic susceptibility, and it could provide information about what genes are present that are often associated with poor outcomes in patients.
"It will give information about how related that organism is to other organisms within the same setting, giving an indication of the capability of transmission from one patient to another."
A report on how the baby unit outbreak was brought under control appears in the latest issue of the journal The Lancet Infectious Diseases.
The scientists used a technique called rapid whole genome sequencing, which maps an organism's entire genetic code, to analyse MRSA bacteria taken from 12 babies.
MRSA (methicillin resistant Staphylococcus aureus) is an antibiotic resistant form of a common skin bug that can cause potentially deadly wound infections in hospitals.
Standard procedures had not been able to show whether a genuine outbreak had occurred, or whether the babies had all coincidentally been exposed to MRSA.
The team was quickly able to confirm that 10 babies were part of an MRSA outbreak involving a previously unknown strain of the bug.
It also became clear from swab tests of parents and visitors that the bacteria had spread outside the hospital into the community.
Measures were introduced to clear MRSA from carriers and deep-clean wards, but two months later a new infection case was identified in the baby unit.
DNA sequencing showed it was caused by the same strain identified earlier, carried to the ward by one of 154 screened health care workers.
Co-author Dr Julian Parkhill, head of pathogen genomics at the Wellcome Trust Sanger Institute in Hinxton, Cambridgeshire, said: "The staff member was decolonised and went back to work, and we believe this brought the outbreak to a close."
He said he expected the cost of whole genome sequencing of bacteria to fall from around £100 per sample to £50, and ultimately just "a few pounds" in the near future.
"People are talking about the thousand dollar human genome," he added.
"If you can do the human genome for a thousand dollars you can do a bacterial genome for one dollar."
The MRSA outbreak at the Rosie Hospital, part of Cambridge University Hospitals NHS Foundation Trust, was estimated to have cost the NHS around £10,000. This was double the cost of the DNA sequencing, said the researchers.
Comprehensive databases of bacterial genomes and drug resistance will have to be established before the infection control "black box" can be introduced, they pointed out.
Asked when the technology might become routinely available, Dr Parkhill said: "Maybe in the next few years."
Dr Nick Brown, consultant microbiologist at the Health Protection Agency and infection control doctor at Addenbrooke's Hospital in Cambridge, said: "What we have glimpsed through this pioneering study is a future in which new sequencing methods will help us to identify, manage and stop hospital outbreaks and deliver even better patient care."
A Health Protection Agency report in May said more than 6% of hospital patients in England acquired some form of infection during their stay.
However, a survey found that MRSA hospital infection rates had fallen significantly in recent years.
Compared with previous survey results in 2006, the proportion of patients becoming infected with the bug in England had dropped from 1.8% to less than 0.1%.
Rates of infection by Clostridium difficile (C. diff), another ward bug, had fallen from 2% to 0.4% in English hospitals.
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies