By LORENA RAMIREZ & ANNA GLEKSMAN

The Manhattan trial of a former Goldman Sachs programmer accused of stealing computer codes from the investment bank took an unusual turn on Tuesday when the judge ruled out the testimony of a prosecution witness because he was not portrayed as an expert when he was.

Before the trial, prosecutor Daniel Holmes downplayed Spencer Lynch’s credentials by not listing him as an expert witness. However, when Lynch testified yesterday he included charts that displayed forensic computer analysis, making it clear that he was an expert.

Defense Attorney Kevin Marino said that it was unfair that the prosecutors have this qualified expert witness and that Lynch should have been cross-examined to confirm that he is an expert or hire an expert.

Marino was so worked up that he told the prosecutors to stop talking among themselves and at one point said, “I feel like I’m in Never Never land.”

Judge Daniel Conviser deemed the fact that the prosecutors had a witness without proper notice unfair because it was their responsibility to provide the information on the witness.

“I don’t like to do these things. I’m disappointed that I have to,” said Conviser about ruling out Lynch’s testimony.

Sergey Aleynikov, 45, a naturalized U.S. citizen from Russia, is charged by state prosecutors with stealing computer code as he prepared to leave Goldman for a high-frequency trading startup in Chicago.

Aleynikov was first arrested in 2009, where he was tried and convicted in federal court. He served one year out of his eight-year sentence in federal prison, until a federal appeals court in New York reversed his conviction in 2012 on the count that the anti-espionage law did not apply, therefore releasing him.

In August 2012 Manhattan DA Cyrus Vance reopened the case, this time in state court and charged him “unlawful use of secret scientific material” and “unlawful duplication of computer related material,” as stated in a felony arrest warrant signed by an FBI agent.

He may face 1 1/2 to four years in prison if convicted on state charges.

The defense argues that the case should be dismissed by double jeopardy since Aleynikov was tried in federal court, convicted and dismissed, and that he did not economically harm Goldman Sachs.

In February, Aleynikov filed a lawsuit against the FBI agents who investigated and arrested him back in 2009, saying that they violated his Fourth Amendment right – the constitutional right that prohibits unreasonable searches and seizures without a warrant.

The on and off trial of Aleynikov inspired Michael Lewis’ best-selling book “Flash Boys.”