https://string-db.org/api
with the following aGOtool URL
https://agotool.org/api
import requests
import pandas as pd
from io import StringIO
url = r"https://agotool.org/api_orig"
response = requests.get(r"https://agotool.org/api_help")
print(response.json())
Protein name: trpA; Organism: Escherichia coli K12_MG1655
ENSPs = ['511145.b1260', '511145.b1261', '511145.b1262', '511145.b1263', '511145.b1264', '511145.b1812',
'511145.b2551', '511145.b3117', '511145.b3360', '511145.b3772', '511145.b4388']
fg = "%0d".join(ENSPs)
result = requests.post(url,
params={"output_format": "json",
"enrichment_method": "genome",
"taxid": 83333},
# UniProt reference proteomes uses "Escherichia coli (strain K12)"
# with Taxid 83333 as a pan proteome instead of 511145 (TaxID on taxonomic rank of species).
data={"foreground": fg})
result_json = result.json()
print("Enrichment results for {} number of terms".format(len(result_json)))
print(result_json[0])
Protein name: CDC15; Organism: Saccharomyces cerevisiae
ENSPs = ['4932.YAR019C', '4932.YFR028C', '4932.YGR092W', '4932.YHR152W', '4932.YIL106W', '4932.YJL076W',
'4932.YLR079W', '4932.YML064C', '4932.YMR055C', '4932.YOR373W', '4932.YPR119W']
fg = "%0d".join(ENSPs)
result = requests.post(url,
params={"output_format": "tsv",
"enrichment_method": "genome",
"taxid": 559292},
# UniProt reference proteomes uses "Saccharomyces cerevisiae S288C"
# with Taxid 559292 as a pan proteome instead of 4932 (TaxID on taxonomic rank of species).
data={"foreground": fg})
df = pd.read_csv(StringIO(result.text), sep='\t')
print(df.head())
Protein name: smoothened; Organism: Mus musculus
ENSPs = ['10090.ENSMUSP00000001812', '10090.ENSMUSP00000002708', '10090.ENSMUSP00000021921',
'10090.ENSMUSP00000025791', '10090.ENSMUSP00000026474', '10090.ENSMUSP00000030443',
'10090.ENSMUSP00000054837', '10090.ENSMUSP00000084430', '10090.ENSMUSP00000099623',
'10090.ENSMUSP00000106137', '10090.ENSMUSP00000107498']
fg = "%0d".join(ENSPs)
result = requests.post(url,
params={"output_format": "json",
"enrichment_method": "compare_samples",
"limit_2_entity_type": "-56;-51;-57",
# comma separate desired entity_types (e.g. PMIDs, UniProt Keywords, and Reactome).
"p_value_cutoff": 1,
"FDR_cutoff": 1,
"taxid": 10090},
data={"foreground": fg,
"background": fg})
# since the foreground equals the background completely no significant enrichment will result from this analysis
# it is meant to show how to show how to use the method call, and to apply a sanity check in case you get no results (try using p value or FDR cutoff of 1)
result_json = result.json()
print(result_json[0])
Characterize foreground, get functional information
ENSPs = ["9606.ENSP00000266970"]
fg = "%0d".join(ENSPs)
result = requests.post(url,
params={"output_format": "tsv",
"filter_foreground_count_one": False,
"enrichment_method": "characterize_foreground"},
data={"foreground": fg})
df = pd.read_csv(StringIO(result.text), sep='\t')
print(df.head())