Joshua Osborn, 14, lay in a coma at American Family Children’s Hospital in Madison, Wis. For weeks his brain had been swelling with fluid, and a battery of tests had failed to reveal the cause.

The doctors told his parents, Clark and Julie, that they wanted to run one more test with an experimental new technology. Scientists would search Joshua’s cerebrospinal fluid for pieces of DNA. Some of them might belong to the pathogen causing his encephalitis.

The Osborns agreed, although they were skeptical that the test would succeed where so many others had failed. But in the first procedure of its kind, researchers at the University of California, San Francisco, managed to pinpoint the cause of Joshua’s problem — within 48 hours. He had been infected with an obscure species of bacteria. Once identified, it was eradicated within days.

The case, reported on Wednesday in The New England Journal of Medicine, signals an important advance in the science of diagnosis. For years, scientists have been sequencing DNA to identify pathogens. But until now, the process has been too cumbersome to yield useful information about an individual patient in a life-threatening emergency.