The animal kingdom is practically dripping in mucus.

Amphibians, snails, and slugs are among the more famous masters of mucus, but even the loneliest microorganism can ooze a viscous slime from time to time.

In our own species, mucus is produced in the mouth, the nose, the throat, the lungs, the gut, the cervix, and the urinary tract, all for a variety of purposes.

Yet the origin of the world's slime is a mystery.

Despite the many similarities between mucuses, many forms have evolved in parallel and not in a branching, tree-like way.

Across glands and between mammals, a small study has found many mucus genes do not in fact share a common ancestor.

This is unusual because most genes with similar functions originate from a shared ancestral gene that is passed down through the generations because it bestows benefits to survival.

Even in our own species, the genes that encode for mucus proteins belong to several families. One secretes gel-forming mucus proteins, while another produces mucus proteins bound to a cell's membrane. There are also 'orphan' genes that encode for mucus production that don't quite fit anywhere else.

Each of these separate lineages probably evolved independently, and researchers now think they've figured out where they came from.

When comparing mucus-encoding genes, known as mucin genes, across 49 mammal species, the team found non-mucin proteins can evolve into slimy, mucin proteins when short repeated chains of amino acids (protein building blocks) are added again.

Among all the mucin genes studied, such random repeats were counted 15 different times.

In other words, some genes in mammals that encode for non-mucin proteins lean towards sliminess over time. Those proteins that are rich in the organic acid proline are most likely to go gooey with the generations, according to the authors of the current study.

"I don't think it was previously known that protein function can evolve this way, from a protein gaining repeated sequences," says evolutionary biologist Omer Gokcumen from the University at Buffalo.

"A protein that isn't a mucin becomes a mucin just by gaining repeats. This is an important way that evolution makes slime. It's an evolutionary trick, and we now document this happening over and over again."

The authors chanced upon their discovery when studying human saliva. During experiments, they noticed one particular mucin gene in humans had similarities to another seen in mice.

When they tried to find a common ancestry, however, they failed.

The mucin gene in mice appeared to have evolved independently, although a portion of the gene shared a structure seen in the genes responsible for human tears, which aren't considered mucus.

"We think that somehow that tear gene ends up repurposed," explains Gokcumen.

"It gains the repeats that give it the mucin function, and it's now abundantly expressed in mouse and rat saliva."

If Gokcumen and his colleagues are right, their results offer scientists a new genetic evolutionary mechanism – the formation of a new gene function without the usual process of a gene duplication event.

This parallel series of mutations in unrelated genes resulting in the same function is an example of convergent evolution (where selective pressure molds the same function from unrelated biological origins, like bat and bird wings) happening on the genetic level.

"If these mucins keep evolving from non-mucins over and over again in different species at different times, it suggests that there is some sort of adaptive pressure that makes it beneficial," explains evolutionary geneticist Petar Pajic from the University at Buffalo.

"And then, at the other end of the spectrum, maybe if this mechanism goes 'off the rails' – happening too much, or in the wrong tissue – then maybe it can lead to disease like certain cancers or mucosal illnesses."

While studying mucus might not sound like the most magical of scientific endeavors, it's hardly a pursuit to sniff at.

The study was published in Science Advances.