How to download coloured KEGG PATHWAY maps in python

326 views Asked by At

I have a list of enzymes (EC numbers, "df" from the code) that I want to highlight in KEGG PATHWAY maps. I would like to make a python script that automatically saves the highlighted maps. So far I could only make urls from which I manually download them:

from bioservices import KEGG
import webbrowser

s = KEGG()

def mapping(df, map_list):

    for map in map_list:
        names = ""
        to_parse = s.get("ec"+map)
        parsed = s.parse(to_parse)

        for ECs in df["EC_numbers"]:
            if str(ECs) in parsed["ENZYME"]:
                names=names+"+EC:"+str(ECs)
        url = "https://www.genome.jp/pathway/map"+map+names
        s.logging.info(url)
        webbrowser.open(url)

map_list_example = ["00520", "00010", "00020"]

Any ideas?

1

There are 1 answers

0
Cleb On BEST ANSWER

You can use the function save_pathway for this purpose.

from bioservices import KEGG

s = KEGG()

target_map = 'ko00340'
target_kos = ['K00765', 'K01814']
s.save_pathway(target_map, 'test.png', keggid=target_kos)

This will produce

enter image description here