Scientists have linked a gene to compulsive behavior  in dogs.

Researchers studied Doberman pinschers that curled up into balls, sucking their flanks for hours at a time, and found that the afflicted dogs shared a gene. They describe their findings  the first such gene identified in dogs  in a short report this month in Molecular Psychiatry.

Dr. Nicholas Dodman, director of the animal behavior clinic at the Cummings School of Veterinary Medicine at Tufts University, in North Grafton, Mass., and the lead author of the report, said the findings had broad implications for compulsive disorders in people and animals.

Estimates have obsessive-compulsive disorder afflicting anywhere from 2.5 percent to 8 percent of the human population. It shows up in behavior like excessive hand washing, repetitive checking of stoves, locks and lights, and damaging actions like pulling one’s hair out by the roots and self-mutilation.

The disorder has been used in popular movies and television shows to define characters like the reclusive writer Melvin Udall, played by Jack Nicholson, in “As Good as It Gets” and Adrian Monk, played by Tony Shalhoub, in the television series “Monk.”