A federal appeals court in Manhattan overturned a six-and-a-half-year sentence in a child pornography case on Friday, saying the judge who imposed it improperly found that the defendant would return to viewing child pornography “because of an as-of-yet undiscovered gene.”

The judge, Gary L. Sharpe of Federal District Court in Albany, was quoted as saying, “It is a gene you were born with. And it’s not a gene you can get rid of,” before he sentenced the defendant, Gary Cossey, in December 2009.

A three-judge panel of the United States Court of Appeals for the Second Circuit said in ruling on the defendant’s appeal, “It would be impermissible for the court to base its decision of recidivism on its unsupported theory of genetics.”

Judges Amalya L. Kearse, John M. Walker Jr. and Rosemary S. Pooler ruled that a sentence relying on findings not supported in the record “seriously affects the fairness, integrity and public reputation of judicial proceedings.”