Case 2: EC reaction information in KEGG
This walkthrough uses an Enzyme Commission (EC) number to find KEGG reactions, their compounds, and the associated orthology group.
1. Reactions associated with an EC number
kegg_link takes the target database (reaction) and the EC number as ec:X.X.X.X, and returns every reaction linked to that enzyme:
rxns = KEGGAPI.kegg_link("reaction", "ec:3.2.1.14")
@assert rxns isa KEGGAPI.KeggTupleList
DataFrame(rxns.data, rxns.colnames)4×2 DataFrame
| Row | Target ID | Source ID |
|---|---|---|
| String | String | |
| 1 | ec:3.2.1.14 | rn:R01206 |
| 2 | ec:3.2.1.14 | rn:R02334 |
| 3 | ec:3.2.1.14 | rn:R06081 |
| 4 | ec:3.2.1.14 | rn:R06082 |
2. Reaction information
The second column of rxns.data holds the reaction identifiers, such as rn:R01206. Pass them to kegg_get to retrieve the full entries. The .data field contains one flat-file String per reaction:
info = KEGGAPI.kegg_get(rxns.data[2])
@assert info.url isa Vector{String} && all(item -> item isa String, info.data)
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_C004613. Compounds involved in a reaction
cpds = KEGGAPI.kegg_link("compound", "rn:R01206")
@assert cpds isa KEGGAPI.KeggTupleList
DataFrame(cpds.data, cpds.colnames)4×2 DataFrame
| Row | Target ID | Source ID |
|---|---|---|
| String | String | |
| 1 | rn:R01206 | cpd:C00001 |
| 2 | rn:R01206 | cpd:C00140 |
| 3 | rn:R01206 | cpd:C00461 |
| 4 | rn:R01206 | cpd:C00461 |
Retrieve the compound entries the same way as the reactions:
cpd_info = KEGGAPI.kegg_get(cpds.data[2])
@assert cpd_info.url isa Vector{String} && all(item -> item isa String, cpd_info.data)
println(join(first(split(cpd_info.data[1], "\n"), 6), "\n"))ENTRY C00001 Compound
NAME H2O;
Water
FORMULA H2O
EXACT_MASS 18.0106
MOL_WEIGHT 18.024. Reaction image
The :image option returns the PNG bytes for a reaction, which you can save to disk:
img = KEGGAPI.kegg_get("rn:R01206", :image)
@assert img.data isa Vector{UInt8} && !isempty(img.data)
path = tempname()
bytes_written = open(path, "w") do io
write(io, img.data)
end
rm(path)
bytes_written == length(img.data)true5. Orthology group for a reaction
ko = KEGGAPI.kegg_link("ko", "rn:R01206")
@assert ko isa KEGGAPI.KeggTupleList
DataFrame(ko.data, ko.colnames)4×2 DataFrame
| Row | Target ID | Source ID |
|---|---|---|
| String | String | |
| 1 | rn:R01206 | ko:K01183 |
| 2 | rn:R01206 | ko:K13381 |
| 3 | rn:R01206 | ko:K20547 |
| 4 | rn:R01206 | ko:K29107 |