An algebra for theoretical genetics