minimap2
minimap2 copied to clipboard
(python) Throw an exception if the index file can't be opened
This has caught me out a few times so I thought I'd make it a PR.
before:
>>> import mappy
>>> a = mappy.Aligner("notafile")
>>> a.seq_names
[]
no exception is thrown and it's not immediately obvious that the filename is incorrect.
after:
>>> import mappy
>>> a = mappy.Aligner("notafile")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "python/mappy.pyx", line 151, in mappy.Aligner.__cinit__
PyErr_SetFromErrnoWithFilenameObject(OSError, fn_idx_in)
FileNotFoundError: [Errno 2] No such file or directory: 'notafile'
It can also throw PermissionError: [Errno 13] Permission denied: 'unreadablefile'
and so on.