Most of us have that one friend who inexplicably manages to stay thin and trim no matter what they eat, but finally scientists might have uncovered one of their secrets.

It's not just how active they are or their gut bacteria – some people actually have different genetic coding that helps them stay the same weight for life.

The rest of us might need a little extra help.

Plenty of previous research has linked genetic variations to obesity, but this study is one of the first to look at genes related to thinness instead.

And the results suggest that there is indeed a 'thin' mix of genes that can be inherited – or more specifically, an absence of obesity-associated genes.

"This research shows for the first time that healthy thin people are generally thin because they have a lower burden of genes that increase a person's chances of being overweight and not because they are morally superior, as some people like to suggest," says one of the team, Sadaf Farooqi from the University of Cambridge in the UK.

"It's easy to rush to judgement and criticise people for their weight, but the science shows that things are far more complex. We have far less control over our weight than we might wish to think."

By comparing DNA from 1,622 people with a low body mass index (BMI) against 1,985 severely obese people and 10,433 control people of normal weight, the scientists were able to spot patterns in the coding across the three groups.

They also looked at lifestyle questionnaires to rule out other lifestyle factors that could be contributing significantly, such as eating disorders.

The researchers found that something called the 'genetic risk score' for obese people is much higher than it is for thin people.

In other words, thin people tend to have fewer genetic variants that increase the chances of developing obesity.

As well as coming across common genetic variants that have already been linked to obesity, the team found new variants relating to obesity, as well as to healthy thinness.

Out of the naturally thin people in the study, the researchers also found that 74 percent or nearly three-quarters of them had a family history of staying thin and healthy.

Further down the line, the scientists want to identify more genes and biological mechanisms that help people stay the right weight.

Of course, genes aren't everything.

As previous research has shown, how thin or fat someone is can be down to a whole host of factors – from metabolism speed and exercise, to how tempting they find fatty foods – but this new study adds to the evidence that genetic factors play a big role.

The study isn't saying that thinness and obesity is all down to genetics, but it does suggest that scoffing burgers and chips every day is going to lead to different weight gains for different people – and it's the people at the obese end of the scale who are most likely to be able to blame genetic variants.

"The genetic dice are loaded against them," says one of the researchers, Inês Barroso from the Wellcome Sanger Institute in the UK.

Ultimately, when it comes to managing our weight, we're not all starting from a level playing field, but our actions do make a difference – which is something to bear in mind the next time you're weighing up a trip to the local fast food chain. Diet and exercise are still hugely important to our health.

"We already know that people can be thin for different reasons," says Farooqi. "Some people are just not that interested in food whereas others can eat what they like, but never put on weight."

"If we can find the genes that prevent them from putting on weight, we may be able to target those genes to find new weight loss strategies and help people who do not have this advantage."

The research has been published in PLOS Genetics.