Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to parse .json, .obo, or .owl to get dictionary of enzymes {id_go:{ec_1, ec_2, ..., ec_n}} #292

Closed
jolespin opened this issue Apr 30, 2024 · 1 comment

Comments

@jolespin
Copy link

I'm trying to understand how I can use GOTATOOLS to parse any of the GO files to yield a dictionary that has the following structure:

{id_go: {ec_1, ec_2, ..., ec_n}}

I was able to load the obo file but I couldn't figure out how to get the enzymes:


from goatools.base import get_godag

godag = get_godag('Databases/GO/go-basic.obo', optional_attrs='relationship')
go = godag['GO:0000015']

for id_go, go in godag.items():
    
    print(id_go, go.get_all_children())
#GO:0000001 set()
#GO:0000002 set()
#GO:0000006 set()
#GO:0000007 set()
#GO:0000009 {'GO:0033164', 'GO:0052917'}

They are definitely in there, I just don't how to access them:

%%bash
grep -c "EC:" /Users/jolespin/Databases/GO/go-basic.obo

# Databases/GO/go-basic.obo:26098
@tanghaibao
Copy link
Owner

@jolespin

You are close, EC number is under xref (you can check which field they are under in the .obo file).

Here are some sample code:

from goatools.base import get_godag

godag = get_godag("go-basic.obo", optional_attrs="xref")

for id_go, go in godag.items():
    ecs = [x for x in go.xref if x.startswith("EC:")]
    if ecs:
        print(id_go, ecs)

This prints out:

...
GO:0008557 ['EC:7.6.2.1']
GO:1901237 ['EC:7.3.2.6']
GO:0090450 ['EC:3.6.1.64']
GO:0043851 ['EC:2.1.1.246']

@jolespin jolespin closed this as completed May 5, 2024
tanghaibao added a commit that referenced this issue May 5, 2024
tanghaibao added a commit that referenced this issue May 5, 2024
* Add test_godag_ecs() per #292

* upgrade versions in build.yml

* Add test_get_godag.py in test list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants