EGM: encapsulated gene-by-gene matching to identify gene orthologs and homologous segments in genomes