phac-nml / staramr

Scans genome contigs against the ResFinder, PlasmidFinder, and PointFinder databases.
Apache License 2.0
116 stars 26 forks source link

Print error even if blast error message does not match pattern #160

Closed apetkau closed 1 year ago

apetkau commented 1 year ago

Fix for #155

Error message

  File "/usr/local/tools/_conda/envs/__staramr@0.7.2/lib/python3.7/site-packages/staramr/blast/JobHandler.py", line 289, in _make_blast_db
    err_msg = re.findall('REF\|(.*?)\'', err_msg)[0]
IndexError: list index out of range

Cause

While we weren't able to reproduce the issue, the error itself is triggered because we are parsing the output of makeblastdb and searching for particular patterns to extract an appropriate error message (re.findall('REF\|(.*?)\''). Perhaps either STDERR of makeblastdb was empty for the above issue, or different versions of blast print different messages. See below code

https://github.com/phac-nml/staramr/blob/6e8ded8a150f01bcd2fa0c6e3b116bf5c567c1dd/staramr/blast/JobHandler.py#L287-L290

Solution

The fix works by defaulting to just printing the full STDERR of makeblastdb if we can't pull out a more specific error message (rather than crashing).