Functional analysis of microbial genomes and metagenomes