[C-I-Tasser standalone] minor python fixes

This forum is shown on the index page along with all topics.

Moderator: robpearc

khaledmc
Posts: 2
Joined: Thu Nov 10, 2022 11:01 pm

[C-I-Tasser standalone] minor python fixes

Post by khaledmc »

Hi,

I have encountered the following warning when running the standalone application on Python 3.8:

Code: Select all

-------------- run ResTriplet -------------------
deeppre.py:14: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
  from collections import defaultdict, Iterable
I fixed it by editing < C-I-TASSER-1.0/contact/ResTriplet/deeppre.py > line 14:

Code: Select all

import torch
import torch.nn as nn
from torch.autograd import Variable
#from collections import defaultdict, Iterable		# comment out original line
from collections import defaultdict			### add fix
from collections.abc import Iterable			### add fix

Another warning could significantly reduce performance and/or break the program, mentioned elsewhere in the forum:

Code: Select all

/home/khaled/programs/C-I-TASSER-1.0/contact/ResTriplet/aaweights.py:189: NumbaWarning:  
Compilation is falling back to object mode WITH looplifting enabled because Function "cal_large_matrix1" failed type inference due to: No implementation of function Function(<built-in function zeros>) found 
for signature:

 >>> zeros(list(int64)<iv=None>)

There are 2 candidate implementations:
   - Of which 2 did not match due to:
   Overload in function 'ol_np_zeros': File: numba/np/arrayobj.py: Line 4164.
     With argument(s): '(list(int64)<iv=None>)':
    Rejected as the implementation raised a specific error:
      TypingError: Failed in nopython mode pipeline (step: nopython frontend)
    No implementation of function Function(<built-in function empty>) found for signature:

     >>> empty(list(int64)<iv=None>, dtype=Function(<class 'float'>))

    There are 2 candidate implementations:
          - Of which 2 did not match due to:
          Overload in function 'ol_np_empty': File: numba/np/arrayobj.py: Line 4086.
            With argument(s): '(list(int64)<iv=None>, dtype=Function(<class 'float'>))':
           Rejected as the implementation raised a specific error:
             TypingError: Cannot parse input types to function np.empty(list(int64)<iv=None>, Function(<class 'float'>))
      raised from /home/khaled/.local/lib/python3.8/site-packages/numba/np/arrayobj.py:4105

    During: resolving callee type: Function(<built-in function empty>)
    During: typing of call at /home/khaled/.local/lib/python3.8/site-packages/numba/np/arrayobj.py (4169)


    File "../../../../.local/lib/python3.8/site-packages/numba/np/arrayobj.py", line 4169:
        def impl(shape, dtype=float):
            arr = np.empty(shape, dtype=dtype)
            ^

  raised from /home/khaled/.local/lib/python3.8/site-packages/numba/core/typeinfer.py:1086

During: resolving callee type: Function(<built-in function zeros>)
During: typing of call at /home/khaled/programs/C-I-TASSER-1.0/contact/ResTriplet/aaweights.py (198)
I fixed it by editing < C-I-TASSER-1.0/contact/ResTriplet/aaweights.py > near line 189:

Code: Select all

#cov=np.zeros([N*ALPHA,N*ALPHA ])		# comment out original line
cov=np.zeros((N*ALPHA,N*ALPHA))			### add fix 	# replace the square brackets with parentheses
And repeating for
contact/TripletRes/aaweights.py
contact/ResPre/aaweights.py
contact/DeepPLM/aaweights.py
contact/ResPLM/aaweights.py

Quick one-liner to find and replace:

Code: Select all

grep -rlP '\(\[N\*ALPHA\,N\*ALPHA \]\)' --include='*py' | xargs sed -i 's/\(\[N\*ALPHA\,N\*ALPHA \]\)/((N*ALPHA,N*ALPHA))/g'
Maybe sharing can save users running newer python installations some troubleshooting time.

My setup:

Code: Select all

Python 3.8.10

Package                  Version
------------------------ --------------------
biopython                1.76
Cython                   0.29.32
numba                    0.56.4
numpy                    1.22.2
scikit-learn             1.1.3
scipy                    1.9.3
six                      1.14.0
torch                    1.13.0
Thank you for writing I-Tasser!
Last edited by khaledmc on Fri Nov 11, 2022 9:40 pm, edited 2 times in total.
jlspzw
Posts: 247
Joined: Tue May 04, 2021 5:04 pm

Re: [C-I-Tasser standalone] minor python fixes

Post by jlspzw »

Dear user,

Thanking for sharing your wonderful work. This will save a lot of other users working time. Greatly appreciate it!

Best
IT Team
khaledmc
Posts: 2
Joined: Thu Nov 10, 2022 11:01 pm

Re: [C-I-Tasser standalone] minor python fixes

Post by khaledmc »

My absolute pleasure.
jlspzw
Posts: 247
Joined: Tue May 04, 2021 5:04 pm

Re: [C-I-Tasser standalone] minor python fixes

Post by jlspzw »

BTW, we have new generation I-TASSER software that will be released soon, and we are now testing the issues. if you are interested in it, you can find it at https://zhanggroup.org/D-I-TASSER/download.html. we would appreciate that if you find any issues or give us any feedback.

Best
IT Team
Post Reply