mentatpsi / OSGenome

An Open Source Web Application for Genetic Data (SNPs) using 23AndMe and Data Crawling Technologies
GNU General Public License v3.0
119 stars 17 forks source link

`SNPedia/DataCrawler.py` fails to create `data` directory #8

Closed ex-nerd closed 5 years ago

ex-nerd commented 6 years ago

When running the first step, it complains about a missing file/directory:

# python3 SNPedia/DataCrawler.py -f /Users/me/Downloads/genome_my_stuff_here.txt
Traceback (most recent call last):
  File "SNPedia/DataCrawler.py", line 139, in <module>
    personal = PersonalData(args["filepath"])
  File "/Users/me/code/OSGenome/SNPedia/GenomeImporter.py", line 10, in __init__
    self.export()
  File "/Users/me/code/OSGenome/SNPedia/GenomeImporter.py", line 27, in export
    with open(filepath, "w") as jsonfile:
FileNotFoundError: [Errno 2] No such file or directory: './data/snpDict.json'

Everything works fine if I manually run mkdir data first.

mentatpsi commented 6 years ago

Hi,

Thanks for pointing this out. The data directory should already be created since it's part of the repo with an empty init.py file in it. What's the relative path of the data directory relative to OSGenome root that you're manually creating the directory in?

ex-nerd commented 6 years ago

I was in the OSGenome root, which is what the instructions seem to imply. Maybe os.chdir isn't getting called at the right place to put the script's execution state into the right directory?

mentatpsi commented 6 years ago

Ah, I believe the script anticipates that the code is being run from within the SNPedia directory. I'll have to modify the code to check what directory it's in. Let me know if running it from within the SNPedia directory fixes the issue.

ex-nerd commented 6 years ago

That makes sense. However, the README instructions suggest running it from the top level. Either way, it would be nice to fix, especially if you ever intend to package this up so that it can be installed with pip and run from anywhere.

mentatpsi commented 6 years ago

I just fixed it. Let me know how it works.

mentatpsi commented 6 years ago

Fixed with: https://github.com/mentatpsi/OSGenome/commit/5ed5a7cdcfc6c7ef9fded545dd45308c3e38c4dd https://github.com/mentatpsi/OSGenome/commit/40ff9b8cdfd54405f4c342315e00c6c5f111f0cf

Jeremy-Harper commented 5 years ago

Hi Downloaded this today and I got the same error. Doing a quick creation of the data file in the top level fixed the issue. SNPedia/DataCrawler.py fails to create data directory

Great project, thanks!