A trade card from the late 19th century shows Little Red Riding Hood standing at the door to Grandma's house. Library of Congress

Computer software that's traditionally used to trace evolutionary trees helped a scientist untangle the origins of one of the world's best-known stories — the tale of Little Red Riding Hood — but the end of this story turned out to be anything but traditional.

"We're turning current ideas on their head," Durham University anthropologist Jamshid Tehrani told NBC News.

Most Westerners know the story by heart: Little Red Riding Hood sets out for Grandma's house with a basket of goodies, but a big bad wolf finds out about her itinerary, gobbles up Grandma and disguises itself to lure the little girl to her doom.

"What big teeth you have!" Little Red Riding Hood remarks before the wolf devours her.

The best-known version, published by the Brothers Grimm 200 years ago, is based on a 17th-century story by the Frenchman Charles Perrault. That story, in turn, was distilled from oral retellings in France, Austria and northern Italy.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

But there's another side to the story: A similar tale, known as "The Wolf and the Kids," is told in parts of Europe and the Middle East — and still other variants are told elsewhere. In Japan, Korea and China, there's the story of "The Tiger Grandmother" (also known as "Grand-aunt Tiger"). In Africa, there's "Motikatika and the Ogre."

Did all these stories spring from a common source? To resolve that question, Tehrani took 58 variants of the X-eats-Y tale and classified them based on 72 plot variables: For example, are the protagonists human children or animals? Male or female? What kind of creature plays the villain? Do the protagonists escape, and if so, how?

Next, Tehrani fed that data into three different kinds of algorithms that are used for phylogenetic analysis, a method that biologists commonly use to group together closely related organisms or even genetic signatures and form a "tree of life" diagram. The technique has also been used to trace relationships between different manuscripts, including versions of biblical texts and Chaucer's "Canterbury Tales."

"This is one of the first attempts to do it with oral traditions," Tehrani said.

This is a phylogenetic trees showing the relationships between different versions of the Little Red Riding Hood story, produced using the NeighbourNet analysis tool. Tehrani / PLOS ONE

Most folklorists had assumed that Little Red Riding Hood's roots went back to Asia, because the tales told in that region reflect elements of "Little Red Riding Hood" as well as "The Wolf and the Kids." They suggested that the original story made its way westward along the Silk Road, and that different versions diverged along the way.

"My analysis demonstrates that in fact the Chinese version is derived from the European oral traditions, and not vice versa," Tehrani said in a news release. It turns out that "Little Red Riding Hood" and "The Wolf and the Kids" are more closely related to each other than they are to the Asian tales. In biological circles, that's a tip-off that the common ancestor of those two main versions originated in the West, and not in the East.

The Asian versions of the tale presumably blended elements from the two stories into hybrids. Tehrani said those Asian tales were derived from older oral versions of the stories, and then they evolved. At about the same time that Perrault was writing about Little Red Riding Hood in the 17th century, the Chinese poet Huang Zhing was setting down the tale of the Tiger Grandmother.

Tehrani's analysis determined that "The Wolf and the Kids" probably originated in the first century, and that the version featuring Little Red Riding Hood branched off about 1,000 years later. "This is rather like a biologist showing that humans and other apes share a common ancestor but have evolved into separate species," Tehrani said.

Tehrani's scientific tale, titled "The Phylogeny of Little Red Riding Hood," was published online Wednesday in the open-access journal PLOS ONE.

More scientific tales:

Alan Boyle is NBCNews.com's science editor. Connect with the Cosmic Log community by "liking" the log's Facebook page, following @b0yle on Twitter and adding the Cosmic Log page to your Google+ presence. To keep up with Cosmic Log as well as NBCNews.com's other stories about science and space, sign up for the Tech & Science newsletter, delivered to your email in-box every weekday. You can also check out "The Case for Pluto," my book about the controversial dwarf planet and the search for new worlds.