'None Type Comparison' issue when running Blaster with ResFinder results

Issue #9 resolved
Lauren Elam created an issue

I have a dataset that I have been trying to use with ResFinder, with an error occurring in blaster.py

for hsp in alignment.hsps:
                        if hsp.expect < best_e_value or hsp.bits > best_bit:

Debugging through the code, it looks like I have an alignment with multiple HSPs, both with 0.0 expect values. The first case evaluates true for hsp.expect < best_e_value and then the second case evaluates false (because best_e_value has been updated to 0). When it attempts to evaluate hsp.bits > best_bit, hsp.bits always has the value of None and I get an exception:

'>' not supported between instances of 'NoneType' and 'NoneType'

I can prevent this error if I update the blaster.py code to:

for hsp in alignment.hsps:
                        if hsp.expect < best_e_value or (hsp.bits != None and hsp.bits > best_bit):

In which case neither condition is met and the code is skipped.

My question is then, is my case valid, making the None-check a valid fix, or should I not be getting into this situation?

Is it valid for hsp.bits to be None?

I have run ResFinder with the test.fsa dataset, and it seems hsp.bits is always None there as well, there just aren’t any alignments with multiple HSPs (the second condition is not checked)

Comments (13)

  1. RolfKaas

    Hi Lauren,

    Thanks for reporting this. We will loook into this and your pull request ASAP.

    Best regards,

    Rolf

  2. Alfred Ferrer Florensa

    Hi Lauren,

    I am taking a closer look at the problem. Could you send me the data that you are using? It is for recreating the problem in my computer.

    Best,

    Alfred

  3. Lauren Elam reporter

    Hi Alfred, I responded via email a few days ago with the data attached. I just wanted to check that it was received.

    Thanks,

    Lauren

  4. Alfred Ferrer Florensa

    Hi Lauren,

    I have run your data and I am not getting None at hsp.bits at any moment. It might be some problem of your installation/versions.

    Which version of blastn are you using? And which version of cgecore?

    Alfred

  5. Lauren Elam reporter

    I will have to check when I get to my lab (under the impression they are both up to date since I reinstalled while troubleshooting), but could you tell me the version you are using for comparison?

  6. Lauren Elam reporter

    I was using cgecore 1.5.0 and Blast 2.6.0+. Updating Blast did not correct the problem. What version of biopython are you using? I’m using the most current release, 1.74

  7. Alfred Ferrer Florensa

    Hi Lauren,

    I was using 1.72 and everything was okey, but I have updated it to 1.74 and I am getting the Nones you were saying. I will take a look at how to solve it.

  8. Lauren Elam reporter

    I was able to get it running after reverting to 1.72. I can give switching to Python 3.7 a try too, though. Thanks so much for you help!

  9. Log in to comment