Search code examples
phpgeneticsgenetic

Best way to create a Punnett Square in PHP?


I've hunted high and low for some answers to this but can't find anything helpful.

I'm working on a genetics project, and I need to create a script that can generate a punnett square from the genetics passed.

The sort of thing I'll be working with is something like bbEe x bbEe, but there could be longer strings like bbEeWwss x bbeeSS.

It could then result in something like bbee, bbEe, bbEE

I've had ideas on using arrays to split the alleles and combine them but i feel like that might be quite costly resource wise.

Is there a smart way of achieving what i'm trying to do?

Thanks for any info, Andy


Solution

  • I know you are after a PHP solution, but there is a solution written in javascript that might actually be easier to work with: https://github.com/armatronic/punnett-squares-js

    Here's a preview of how it looks:

    enter image description here