Scientists have woken up and smelled the coffee — and analyzed its DNA.

They found that what we love about coffee — the caffeine — is a genetic quirk, not related to the caffeine in chocolate or tea.

"It's an accident that has been frozen in place very likely by the influence of natural selection," said University of Buffalo evolutionary biologist Victor Albert.

He and more than 60 other researchers from around the world mapped out the genetic instruction book of java. Their results were published Thursday in the journal Science.

Albert says researchers discovered that caffeine developed separately in coffee, tea and chocolate because it is in different genes in different areas of plants' genomes.

Pollinators [of coffee plants] come back for more — just like we do for our cups of coffee. - Victor Albert, evolutionary biologist

But once coffee mutated to have caffeine — not just in the bean, there's even more in the leaves — it turned out to be a good thing for the plant, Albert says. Bugs don't chew on the coffee plant leaves because they don't like the caffeine, but pollinators like bees do.

"So, pollinators come back for more — just like we do for our cups of coffee," Albert says, admitting he also likes the buzz.

"It wakes me up every morning. I wouldn't be able to do all this fabulous work on coffee if it weren't for the coffee itself."

University of North Carolina plant genomics professor Jeff Dangl, who wasn't part of the study, notes "natural selection to help coffee plants deter insects turned out so well for us." But he adds, "Unfortunately, coffee is now under epidemic attack by pathogens that are not deterred by caffeine, and we need all the clever genetics and genomics to save it."

The research will be presented next week at the 25th International Conference on Coffee Science in Colombia.