mdshw5 / pyfaidx

Efficient pythonic random access to fasta subsequences
https://pypi.python.org/pypi/pyfaidx
Other
459 stars 75 forks source link

Incomplete index #174

Closed marco-mariotti closed 3 years ago

marco-mariotti commented 3 years ago

Hi, I noticed that upon calling Fasta(filename), pyfaidx starts building the index directly in filename+'.fai'. The problem is that if the process is stopped before finishing for whatever reason, the resulting file will be recognized as a valid file even if basically empty (e.g. try with Ctrl-C). Since the path to the index file is hardcoded, it is hard to circumvent this. I recommend building the index to a temporary file ('.fai.tmp', for example) and move it to its final location only after the index is correctly built.

Thanks,

mdshw5 commented 3 years ago

That's a very good idea @marco-mariotti. Have you encountered such incomplete index files before?

mdshw5 commented 3 years ago

@marco-mariotti I implemented your suggestion and released v0.6.0 to PyPI. Thanks again.

marco-mariotti commented 3 years ago

Terrific, thanks! And thanks for developing this awesome package.