An Algebra for Theoretical Genetics