Edinburgh-Genome-Foundry / DnaChisel

:pencil2: A versatile DNA sequence optimizer
https://edinburgh-genome-foundry.github.io/DnaChisel/
MIT License
213 stars 38 forks source link

Issue when using codon optimization with harmonization #7

Closed SenyorDrew closed 5 years ago

SenyorDrew commented 5 years ago

I ran into an issue when using codon optimization using mode="harmonized". I get a division by zero error that occurs on line 522 of biotools.py:

data[codon] = 1.0 * value / total

My gene did not have an amino acid ("H") and so that value for "total" for this amino acid was 0, causing the divide by zero error.

Suggested fix: line 519: total = max(data['total'], 1)

Zulko commented 5 years ago

Thanks for the catch and the suggestion, I fixed it. Are you aware of the discussion in #2 around codon harmonization in DNA Chisel? Apparently the harmonization algorithm in DNA Chisel does not follow the definition you commonly find in literature. Will that be an issue and do you have an opinion on this thread ?

SenyorDrew commented 5 years ago

Thanks for the quick fix. I did notice the discussion on harmonization. I can't comment on whether the term "harmonization" is consistent with the literature, but I thought the code documentation was clear as to what was being done (which for my case was what I'm looking for).