A simple blood test could determine a person’s risk of suicide and provide a future tool of prevention.

In a study published online Wednesday in the American Journal of Psychiatry, researchers say they have discovered a genetic indicator of a person’s vulnerability to the effects of stress and anxiety and, therefore, the risk of suicidal thoughts or attempts.

The researchers, at Johns Hopkins University, looked at how a group of chemicals known as methyl affect the gene SKA2, which modifies how the brain reacts to stress hormones.

If the gene’s function is impaired by a chemical change, someone who is stressed won’t be able to shut down the effect of the stress hormone, which would be like having a faulty brake pad in a car for the fear center of the brain, worsening the impact of even everyday stresses.

Researchers studied about 150 postmortem brain samples of healthy people and those with mental illness, including some who had committed suicide. They found that those who died by suicide had significantly higher levels of the chemical that altered the SKA2 gene. As a result of the gene’s modification, it was not able to “switch off” the effect of the stress hormone.

The researchers then tested sets of blood samples from more than 325 participants in the study to see whether they could determine those who were at greater risk of suicide by the same biomarker.

They were able to guess with 80 to 90 percent accuracy whether a person had thoughts of suicide or made an attempt by looking at the single gene, while accounting for age, gender and levels of stress or anxiety.

Zachary Kaminsky, an assistant professor of psychiatry and behavioral sciences at the Johns Hopkins School of Medicine who led the study, said that while the biomarker indicates a person’s vulnerability to stress and anxiety, it does not make a person destined to experience suicidal thoughts and could equally show one’s resilience.

The stress hormone cortisol has a role in performing both daily tasks and responding to extreme situations.

“It helps you get up in the morning, it helps you cross the road, and it helps you run away from a lion,” Kaminsky said.

Suicide is the 10th-leading cause of death for Americans, according to the National Action Alliance for Suicide Prevention.