Two New York police officers were sitting in a patrol car one night last August when they saw Avree Lamar, a 19-year-old with an open arrest warrant, climb into a cab near a housing project in Red Hook, Brooklyn.

The officers followed the cab, pulled it over, and arrested Lamar. In the back of Lamar’s waistband, they found a loaded 9mm pistol, court papers said. He was charged with criminal possession of a loaded weapon, a felony.

It seemed like a straightforward case. But for all New York City’s success in reducing violent crime, only about half of the people arrested for carrying a loaded gun in the city get convicted. Juries like hard evidence, and often mistrust cases that hinge on police testimony. Prosecutors say cases like Lamar’s are not always easy wins.

To change that, the city is pursuing an ambitious and expensive plan to collect and test DNA from every gun recovered by police. The goal is to boost the number of successful prosecutions, and discourage carrying illegal weapons in the nation’s largest city.

The Trace and WNYC contacted eight other major police departments. None are attempting DNA collection and testing on this scale. Several said such an undertaking would be extremely difficult without adding staff, lab space, and expensive equipment. The Federal Bureau of Investigation, and the Bureau of Alcohol, Tobacco, Firearms, and Explosives, only deploy DNA tests for select gun cases — often shootings and murders.

The New York program, which began in the summer of 2015, is continuing to expand. Last year, the Office of the Chief Medical Examiner performed DNA tests for 1,682 gun cases, nearly quadruple the number from 2014. Just this month, the city gave the office an additional $8 million to pay for 55 new employees to process gun swabs, plus training and equipment. That money amounts to about 10 percent of the office’s total annual budget.

Police officials and the medical examiner’s office said they could not estimate the total cost of the swabbing and testing program since it would include staff time for police, prosecutors, and scientists, as well as equipment and training in several different departments and agencies.

Lamar’s gun was swabbed at the police station, and sent to the medical examiner’s office.

Scientists in the M.E.’s office then compared a DNA sample from Lamar to the genetic mixture found on the pistol’s trigger guard. Their conclusion: the DNA retrieved from the weapon was 6.8 trillion times more likely to belong to Lamar than someone else.

Lamar pleaded guilty, and a judge sentenced him to three years in prison — a lengthy sentence for a first offense, lawyers said.

“That is the goal, to make it radioactive to even pick up a gun,” said Richard Aborn, president of the Citizens Crime Commission of New York City, a nonprofit group that helped the city develop its strategy for using DNA in gun cases.

Some legal and forensic experts said that DNA testing, while more sophisticated than ever, is not foolproof. They say the science used to test small amounts of DNA isn’t perfect, and there are ways an innocent person’s genetic material could get on a gun he or she never touched.

“What we’ve seen in the last few years are real efforts to push the boundaries of DNA evidence,” said Clinton Hughes, an attorney with the Legal Aid Society of New York’s DNA unit. “DNA does not necessarily mean that there’s going to be a just result, or an accurate result in a particular case.”

Some civil liberty groups have also raised concerns about the expansion of DNA collection by local law enforcement agencies.

DNA that is deemed “abandoned” — left on the rim of a soda can or the end of a cigarette, for example — can legally be picked up by police and entered into a local database. People whose genetic information is stored in the database are almost never aware of it, legal experts said.

NYPD Deputy Chief Emanuel Katranakis said DNA evidence from firearms often helps police investigate suspects they might otherwise overlook. Last year, police linked genetic material from a gun to a person in an existing DNA database 309 times, he said. New York has made remarkable strides in reducing gun crime. Last year, police recorded 998 shootings — the fewest in recorded city history.

But there are still neighborhoods where violent crime is common, and people are frequently shot. In a one-month span this summer in the Bronx, a 5-year-old boy was shot in the head; a police officer was fatally shot while sitting in her patrol car, and a man was caught on surveillance video shooting three men on a city street.

Some other large cities have struggled to control rising levels of gun crime, the violence that spurred President Donald Trump to speak of “American carnage” in his inaugural address. Chicago, which has a third of New York’s population, reported 3,550 shooting incidents last year.

Benjamin Meda is a detective who heads the Los Angeles Police Department’s gun unit for gangs and narcotics. Los Angeles saw shootings rise slightly last year, and Meda said police can use all the investigative tools they can get.

“We are extremely interested in what New York is doing,” he said. “We want to see what their success is — what the return on their DNA hits are, what they’re doing that we aren’t doing.”

 It’s been almost 25 years since a drop of blood on the pavement at OJ Simpson’s ex-wife’s house brought DNA evidence into the public consciousness. Back then, scientists needed a sample of blood or other bodily fluid the size of a quarter to test for DNA.

As the science became more sophisticated, the New York M.E.’s office developed a method that it used to make DNA matches from a tiny amount of recovered genetic material. It also developed an algorithm that helped scientists identify a possible match even when someone’s DNA was mixed up with that of other people.

Both these technologies are key when it comes to testing firearms. Guns — especially crime guns — are often passed among several people before they are confiscated by police.

Many judges allowed DNA evidence that was obtained using those testing methods to be admitted in criminal cases. But in 2015, a Brooklyn judge tossed DNA evidence obtained using those protocols in two cases, saying it was not scientifically reliable.

Last year, the M.E.’s office turned to a widely used computer model called STRMix, which as of this spring was being used by 17 American crime laboratories and the Federal Bureau of Investigation, to test mixed DNA samples.

A scientist at work in the training laboratory in the New York Medical Examiner’s Office. Gun swabs now account for about 10 percent of the caseload at the office’s forensic laboratory.

In a chilly, sterile DNA lab on Manhattan’s East Side, scientists cut the cotton off the swabs mailed to them by police and drop them in test tubes. They then clean and measure those samples, running them through a giant whirring machine that looks like a high-tech microwave.

The lab needs 37.5 picograms — as little as six cells of genetic material — to test a sample against a suspect in a case. Police swab handguns in three places: The grip area, the trigger area, and, the slide area, which on a pistol needs to be pulled back before firing.

If enough DNA is recovered, scientists go on to do more tests. They add chemicals, some of which contain fluorescent tags, to each sample. They put the samples into what is essentially a DNA “Xerox machine.” The machine copies the DNA millions of times at the locations that the scientists are testing.

The samples are then run through another instrument which picks up the fluorescent tags and uses them to produce a color chart. This gives scientists a visual representation of the DNA found on the gun that they can compare with a suspect’s.  

If a gun swab shows that a mixture of DNA from several people is on the gun, a scientist can enter information about the mixture into a computer, together with the suspect’s DNA profile. The computer produces a ratio showing how likely it is that the suspect’s DNA is part of the genetic mixture recovered from the firearm.

A gun swab does not always produce a usable sample. Rachel Singer, chief of forensic science at the Brooklyn District Attorney’s Office, said that in about half of all cases, there is either too little DNA on a swab — or there’s genetic material from too many people — to produce a result that can be tested against a suspect’s DNA.

The medical examiner can determine whether someone’s DNA is part of a mix of as many as three biological samples, but if a fourth person’s DNA is detected on a weapon, the office will not make a determination.

Prosecutors say they are aware of the limitations of DNA evidence, but that they are using it responsibly to get more plea deals and longer sentences.

“We have found that when we do have DNA on a criminal possession of a weapons case, we either are able to negotiate a plea, or the defendant ultimately gets convicted,” Singer said.

Timothy Kupferschmid, the chief of laboratories at the New York Medical Examiner’s Office, stands in his office in Lower Manhattan. The lab he oversees tested DNA recovered from firearms in more than 1,600 cases last year.

Prosecutors said there is almost always other evidence in gun-possessions cases — like video footage or police testimony — to prevent wrongful convictions. In Lamar’s case, for example, DNA evidence was used to support the testimony of a police officer who said he pulled a gun out of the defendant’s waistband.

It can take weeks for the lab to come back with the results of a DNA test. Defense lawyers say that in the lag time, prosecutors often try to use the possibility of a DNA match to convince their clients to agree to a deal.

“When I’m having a conversation with a prosecutor, oftentimes DNA is used as a threat to exact a guilty plea,” said Scott Hechniger, a senior staff attorney at Brooklyn Defender Services, a public defense law firm. Hechniger said a prosecutor might offer his client a one-time deal before DNA results come back from the lab. If they come back and there’s a match, the deal is off.

Hechinger said New York’s initiative to increase DNA testing is part of a broader move toward a zero-tolerance, one-size-fits-all approach to guns — where prosecutors seek the stiffest sentences for everyone, even defendants with no prior record.

Still, there is room to challenge DNA evidence. Brooklyn attorney Douglas Rankin said that if his client’s DNA is not found on a gun, or the test is inconclusive, he can make a strong case for reasonable doubt. Even when there is DNA evidence, Rankin said he has sometimes had luck arguing that it can’t be relied upon. He recalled one case in which a man was charged with illegally possessing a loaded gun after police found it under a couch he was sleeping on in a friend’s apartment. At trial, Rankin argued that because of his client’s proximity to the weapon, it would have been easy for a tiny quantity of his client’s DNA to end up on it. The man was acquitted.

While it is impossible to tie conviction rates to any one factor, there is some evidence that the city’s push to swab all recovered guns for DNA is translating to more pleas and longer sentences.

In the first half of this year, about 56 percent of all gun-possession arrests ended in convictions. That’s higher than in any year in the last decade, according to data provided by the state Division of Criminal Justice Services.

People who possess loaded guns illegally have also been slightly more likely to serve time for their offenses since DNA swabs became more commonplace. In the first half of 2017, almost 25 percent of people who were arrested on charges of possessing a loaded gun were sent to prison — a higher percentage than in any full year since 2007.

STRMix has yet to be put to the test in a New York City court. It was successfully challenged in one upstate murder trial last year, when a judge ruled that the state laboratory that collected the DNA samples was not approved to collect samples for the new STRMix analysis.

Now lawyers and scientists are waiting for a challenge to STRMix in a New York City gun case, likely to come within the next few months.

“I expect, as we have a very strong and robust defense community, that they will do their job and challenge us appropriately,” Timothy Kupferschmid, chief of laboratories for the New York Medical Examiner’s Office. “I look forward to those challenges and to showing them what we’re doing.”