Assembling genome history from gene stories: Phylogeny aware genome scale inference of ancestral traits and ancient environments