I realize that this post is quite old now, but I hope this may come in handy for other users.
The output file from KAAS should include all coding regions detected, as well as any KO identifiers that could be assigned to that gene. You will need to write a simple script to parse this file and extract the KO identifiers.
If all you would like is the lowest level pathway annotation under which that KO identifier falls, obtain a KO:pathway name list using REST, via the following URL. You will want all entries that begin with the map prefix:
http://rest.kegg.jp/link/ko/path (<--this may take up to a minute to load)
Then get pathway names for the KO:path linkages:
http://rest.kegg.jp/list/path
For help on REST calls, see: http://www.kegg.jp/kegg/rest/keggapi.html
After copying this information to text files from a browser, the commandline, or whatever language you are using to make REST calls, it is straightforward to read them into a structure like a python dict or R dataframe to count occurrences and compare your two samples. However, there is heirarchical information hidden in the KO:pathway mapping that is usually discounted, and there isn't an existing resource to robustly process.
If you are interested in taking this hierarchical information into account, you will need to parse the following link and distribute your KO's accordingly: http://rest.kegg.jp/get/br:ko00001
The bioconductor package "keggorthology" served this purpose, but has temporarily been decommissioned due to KEGG licensing issues. Maintenance of this package has been transferred to me and I am working on getting it updated to function, within license terms, using the current version of KEGG.
I am a novice to bioinformatics. What is the significance of using paths starting from path:map? I saw somewhere that taking path from path:ko00 and path:ko01 gives metabolic pathway. I have little or no biology background.