Case 3: Identifying a compound in KEGG

This walkthrough looks up a compound by name, retrieves its entry, and finds the reactions it participates in.

1. Find a compound by name

kegg_find searches a database by keyword. To look for a compound, pass the compound database and the compound name:

hits = KEGGAPI.kegg_find("compound", "chitin")
DataFrame(hits.data, hits.colnames)
1×2 DataFrame
RowIDDetails
StringString
1C00461Chitin; beta-1,4-Poly-N-acetyl-D-glucosamine; [1,4-(N-Acetyl-beta-D-glucosaminyl)]n; [1,4-(N-Acetyl-beta-D-glucosaminyl)]n+1

2. Retrieve the compound entry

The first column of hits.data holds the compound identifiers (cpd:C…). Fetch the full entry with kegg_get:

cpd = KEGGAPI.kegg_get("cpd:C00461")
println(join(first(split(cpd.data, "\n"), 8), "\n"))
ENTRY       C00461                      Compound
NAME        Chitin;
            beta-1,4-Poly-N-acetyl-D-glucosamine;
            [1,4-(N-Acetyl-beta-D-glucosaminyl)]n;
            [1,4-(N-Acetyl-beta-D-glucosaminyl)]n+1
FORMULA     (C8H13NO5)n
REMARK      Same as: G10483
REACTION    R01206 R02333 R02334 R02335 R11660

3. Compound image

The :image option returns the PNG bytes of the compound structure, which you can save to disk:

img = KEGGAPI.kegg_get("cpd:C00461", :image)
open("C00461.png", "w") do io
    write(io, img.data)
end

4. Reactions linked to the compound

kegg_link returns one row for every reaction the compound takes part in:

rxns = KEGGAPI.kegg_link("reaction", "cpd:C00461")
DataFrame(rxns.data, rxns.colnames)
9×2 DataFrame
RowTarget IDSource ID
StringString
1cpd:C00461rn:R01206
2cpd:C00461rn:R01206
3cpd:C00461rn:R02333
4cpd:C00461rn:R02334
5cpd:C00461rn:R02334
6cpd:C00461rn:R02335
7cpd:C00461rn:R02335
8cpd:C00461rn:R11660
9cpd:C00461rn:R11660

5. Reaction information

Feed the reaction identifiers (the second column of rxns.data) back into kegg_get to retrieve their entries:

info = KEGGAPI.kegg_get(rxns.data[2])
println(join(first(split(info.data[1], "\n"), 6), "\n"))
ENTRY       R01206                      Reaction
NAME        [1,4-(N-acetyl-beta-D-glucosaminyl)]n glycanohydrolase
DEFINITION  Chitin + H2O <=> N-Acetyl-D-glucosamine + Chitin
EQUATION    C00461 + C00001 <=> C00140 + C00461
REMARK      Same as: R06081
RCLASS      RC00467  C00140_C00461