tanghaibao / goatools

Python library to handle Gene Ontology (GO) terms
BSD 2-Clause "Simplified" License
783 stars 210 forks source link

Where to store obo file #307

Open Tim-Kirkwood opened 1 month ago

Tim-Kirkwood commented 1 month ago

Hello,

Thank you for making this tool.

I am trying to replicate this usecase with this command on Windows 11, Python 3:

python C:\Anaconda3\pkgs\goatools-1.2.3-pyh7cba7a3_2\python-scripts\plot_go_term.py --term=GO:0055013,GO:0060048,GO:0003300,GO:0055008,GO:0055003,GO:0035995,GO:0007076,GO:0006936,GO:0010628,GO:0050714,GO:0010737,GO:0051592,GO:0045214,GO:0048769,GO:0030241,GO:0030240,GO:0006941

I get this error:

Traceback (most recent call last):
  File "C:\Anaconda3\pkgs\goatools-1.2.3-pyh7cba7a3_2\python-scripts\plot_go_term.py", line 84, in <module>
    g = GODag(obo_file)
  File "C:\Anaconda3\envs\pip_env\lib\site-packages\goatools\obo_parser.py", line 321, in __init__
    self.version, self.data_version = self.load_obo_file(
  File "C:\Anaconda3\envs\pip_env\lib\site-packages\goatools\obo_parser.py", line 327, in load_obo_file
    reader = OBOReader(obo_file, optional_attrs)
  File "C:\Anaconda3\envs\pip_env\lib\site-packages\goatools\obo_parser.py", line 56, in __init__
    raise Exception(
Exception: COULD NOT READ(go-basic.obo)
download obo file first
 [http://geneontology.org/ontology/go-basic.obo]

As I am on Windows, I cant use wget. Therefore, I manually downloaded the go-basic.obo file and put it in C:\Anaconda3\pkgs\goatools-1.2.3-pyh7cba7a3_2\site-packages\goatools. This is because it looks like OBOReader expects the obo file to be in the same location as the obo_parser module. However, I got the same error.

Can I confirm where the obo file should be placed? Please could you suggest any other potential fixes?

Thanks very much! Tim

tanghaibao commented 4 weeks ago

@Tim-Kirkwood

For this script and most other cases, the obo file should be placed in the current working directory.

For example, let's say you download the obo to /tmp, then you can just run the script there.

$ ls -1 *.obo
go-basic.obo

$ plot_go_term.py --term=GO:0055013
go-basic.obo: fmt(1.2) rel(2024-06-17) 45,494 Terms
GO:0055013  level-05    depth-05    cardiac muscle cell development [biological_process]
all parents: {'GO:0048856', 'GO:0009987', 'GO:0032502', 'GO:0055006', 'GO:0008150', 'GO:0048468', 'GO:0048869', 'GO:0055001'}
all children: {'GO:0055014', 'GO:0060926', 'GO:0055015', 'GO:0060928', 'GO:0060931'}
lineage info for terms ['GO:0055013'] written to GO_lineage.pdf