Electrostatics / apbs

Software for biomolecular electrostatics and solvation calculations
http://www.poissonboltzmann.org/
Other
94 stars 26 forks source link

python2->3 bug in psize.py #62

Open itaneja2 opened 4 years ago

itaneja2 commented 4 years ago

At line 175, a list is compared to an integer. This is ok to do in python2, but not 3:

image

To fix the issue, consider replacing line 175 with:

if any([val <= 0 for val in nsmall]):

intendo commented 4 years ago

I think it is easier to only test the value that changed: if nsmall[i] <= 0:

Thanks for catching this.

sobolevnrm commented 4 years ago

@intendo -- what happened to the PR to fix this?

intendo commented 4 years ago

Sorry, I made the change from if nsmall <= 0: to if nsmall[i] <= 0: in main since it was just a simple logic error.

sobolevnrm commented 4 years ago

Great! I'm closing this.

Drvanon commented 2 years ago

As far as I can see, this is still an issue. I just cloned main git clone https://Electrostatics/apbs and ran cd apbs/tools/manip; python psize.py ~/my.pdb and got

Traceback (most recent call last):
  File "/home/robin/external/apbs/tools/manip/psize.py", line 541, in <module>
    main()
  File "/home/robin/external/apbs/tools/manip/psize.py", line 530, in main
    psize.runPsize(filename)
  File "/home/robin/external/apbs/tools/manip/psize.py", line 289, in runPsize
    self.set_all()
  File "/home/robin/external/apbs/tools/manip/psize.py", line 233, in set_all
    self.setSmallest(n)
  File "/home/robin/external/apbs/tools/manip/psize.py", line 174, in setSmallest
    if nsmall <= 0:
TypeError: '<=' not supported between instances of 'list' and 'int'
intendo commented 2 years ago

My guess is that you have another psize.py (/home/robin/external/apbs/tools/manip/psize.py) in your path because line 174 of psize.py should be if nsmall[i] <= 0: What directory did you clone apbs into? What OS and version of Python are you using?

Drvanon commented 2 years ago
(base) robin@robin-VirtualBox:~ $ conda create --name snakemake
(base) robin@robin-VirtualBox:~ $ conda activate snakemake
(snakemake) robin@robin-VirtualBox:~ $ mkdir repro
(snakemake) robin@robin-VirtualBox:~ $ cd repro/
(snakemake) robin@robin-VirtualBox:~/repro $ git clone https://github.com/Electrostatics/apbs
Cloning into 'apbs'...
remote: Enumerating objects: 11077, done.
remote: Counting objects: 100% (2539/2539), done.
remote: Compressing objects: 100% (1620/1620), done.
remote: Total 11077 (delta 1403), reused 1936 (delta 893), pack-reused 8538
Receiving objects: 100% (11077/11077), 68.38 MiB | 25.75 MiB/s, done.
Resolving deltas: 100% (6553/6553), done.
(snakemake) robin@robin-VirtualBox:~/repro $ cd apbs/tools/manip/
(snakemake) robin@robin-VirtualBox:~/repro/apbs/tools/manip [master] $ sed -n '174p' psize.py
                if nsmall <= 0:
# Os version:
(snakemake) robin@robin-VirtualBox:~/repro/apbs/tools/manip [master] $ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:    20.04
Codename:   focal

But also in the git repo I can find this line: https://github.com/Electrostatics/apbs/blob/34fd2bbacb84e1289490fe746ba0cc7553a23ce2/tools/manip/psize.py#L174

intendo commented 2 years ago

@nsoblath can you add this to your list of issues when you work on the code base again? The fix is to change line 174 of psize.py from if nsmall <= 0: to if nsmall[i] <= 0:.