BrooksResearchGroup-UM / pyCHARMM-Workshop

pyCHARMM tutorial, documentation and examples. This repository contains materials originally from the pyCHARMM Workshop run at the University of Michigan by Charles Brooks' Group, June 20-24.
MIT License
63 stars 10 forks source link

Error when running CDOCKER flexible docking example files #4

Closed ZzakB closed 1 year ago

ZzakB commented 1 year ago

Description: Hi, I am having trouble running flexible docking using pycharmm's CDOCKER implementation . I tried to run the example case provided in the repo, but I keep encountering an error.

Environment:

Error Message:

ValueError: could not convert string to float: '$[idx+1]'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/CDOCKER/pyCHARMM-Workshop-main/7CDOCKER_Tutorial/flex/standard_flex.py", line 40, in <module>
    sortedResult, dockResult = Flexible_CDOCKER(xcen = xcen, ycen = ycen, zcen = zcen, 
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/Soft/Anaconda3/envs/pycharmm/lib/python3.11/site-packages/pycharmm/cdocker.py", line 2312, in Flexible_CDOCKER
    cluster_result = top_N_cluster(N = top_N_result, total = num * copy)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/Soft/Anaconda3/envs/pycharmm/lib/python3.11/site-packages/pycharmm/cdocker.py", line 1396, in top_N_cluster
    cluster_list = np.loadtxt("cluster_list", dtype = int)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/Soft/Anaconda3/envs/pycharmm/lib/python3.11/site-packages/numpy/lib/npyio.py", line 1373, in loadtxt
    arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/Soft/Anaconda3/envs/pycharmm/lib/python3.11/site-packages/numpy/lib/npyio.py", line 1016, in _read
    arr = _load_from_filelike(
          ^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string '$[idx+1]' to int64 at row 141, column 2.

It seems the error originates from the cluster_list file. Here is a small snippet of the file content:

461 1
466 1
58 1
66 1
67 1
75 1
76 1
86 1
9 1
93 1
99 1
478 1
480 1
472 1
64 1
14 $[idx+1]
168 $[idx+1]
204 $[idx+1]
213 $[idx+1]
252 $[idx+1]
253 $[idx+1]
270 $[idx+1]
clbrooksiii commented 1 year ago

Hi, I note that I ran the tutorial using c47b2 and, aside from a very small changes which I introduced (please pull your repository to get the update) the flexible cdocker portion of the tutorial ran without problem. Do you have the MMTSB Toolset installed? Do you also have open babel installed in your environment? Please pull the updated tutorial and try this again since I cannot reproduce the problem with my installation of pyCHARMM and the current GitHub repo. Thank you, Charles Brooks

On Aug 17, 2023, at 9:23 AM, ZzakB @.***> wrote:

Description: Hi, I am having trouble running flexible docking using pycharmm's CDOCKER implementation . I tried to run the example case provided in the repo, but I keep encountering an error.

Environment:

charmm version: c47b2 Python : 3.11.4 OS: Ubuntu 20.04 Error Message:

ValueError: could not convert string to float: '$[idx+1]'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/home/user/CDOCKER/pyCHARMM-Workshop-main/7CDOCKER_Tutorial/flex/standard_flex.py", line 40, in sortedResult, dockResult = Flexible_CDOCKER(xcen = xcen, ycen = ycen, zcen = zcen, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Soft/Anaconda3/envs/pycharmm/lib/python3.11/site-packages/pycharmm/cdocker.py", line 2312, in Flexible_CDOCKER cluster_result = top_N_cluster(N = top_N_result, total = num * copy) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Soft/Anaconda3/envs/pycharmm/lib/python3.11/site-packages/pycharmm/cdocker.py", line 1396, in top_N_cluster cluster_list = np.loadtxt("cluster_list", dtype = int) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Soft/Anaconda3/envs/pycharmm/lib/python3.11/site-packages/numpy/lib/npyio.py", line 1373, in loadtxt arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/Soft/Anaconda3/envs/pycharmm/lib/python3.11/site-packages/numpy/lib/npyio.py", line 1016, in _read arr = _load_from_filelike( ^^^^^^^^^^^^^^^^^^^^ ValueError: could not convert string '$[idx+1]' to int64 at row 141, column 2. It seems the error originates from the cluster_list file. Here is a small snippet of the file content:

461 1 466 1 58 1 66 1 67 1 75 1 76 1 86 1 9 1 93 1 99 1 478 1 480 1 472 1 64 1 14 $[idx+1] 168 $[idx+1] 204 $[idx+1] 213 $[idx+1] 252 $[idx+1] 253 $[idx+1] 270 $[idx+1] — Reply to this email directly, view it on GitHub https://github.com/BrooksResearchGroup-UM/pyCHARMM-Workshop/issues/4, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIWBNMOJZVQ5M3XPXRZ5WDXVYLO7ANCNFSM6AAAAAA3UCN5VM. You are receiving this because you are subscribed to this thread.


Charles L. Brooks III (he/him) Cyrus Levinthal Distinguished University Professor of Chemistry and Biophysics Warner-Lambert/Parke-Davis Professor of Chemistry Professor of Biophysics Director of the Biophysics Program North American Editor-in-Chief of Journal of Computational Chemistry Department of Chemistry, Biophysics Program President of the Protein Society (2017-2020) 930 N. University Ave University of Michigan Ann Arbor, MI 48109 Phone: 734/647-6682 Fax: 734/647-1604 Phone: 734/763-6444 (Biophysics Office) Brooks Lab http://brooks.chem.lsa.umich.edu/ Journal of Computational Chemistry http://onlinelibrary.wiley.com/journal/10.1002/(ISSN)1096-987X Protein Society http://www.proteinsociety.org/

Nicholas O'Hair Administrative Assistant & JCC Editorial Assistant Phone: 734/763-2353 Email: @.***

Sandra Moing Biophysics Executive Secretary Phone: 734-764-1146 Email: @.***

Follow me on twitter: https://twitter.com/CharlesLBrooks

ZzakB commented 1 year ago

Hi Prof. Brooks,

Thank you for the reply. I followed the installation instructions and confirmed that I have the MMTSB toolset installed with the correct environment variables declared.

Upon further investigation into the code, I managed to pinpoint and resolve the problem. It appears the error originates from the top_N_cluster function in the cdocker module. Within the function, the following shell code is executed via the os.system method:

idx=1
    rm -f cluster_list 
    grep @cluster %s | sed 1d | awk '{if ($4 > %d) print}' | sort -nk 4 | tail -n %d | awk '{print $2}' | cut -b 3- > tmplist
    for init in `cat tmplist`; do
        final=$[init+1]
        awk "/cluster t.$init /, /cluster t.$final / {print}" %s | sed /cluster/d | awk '{print $2}' > tmp
        awk '{$2 = name; print}' name=$idx tmp >> cluster_list
        idx=$[idx+1]
done

The incrementing of the idx variable uses an older syntax that might not be universally supported across different shell versions. In my case, it failed for bash 5.0.17(1), but worked for and older version (4.2.46(2)). Resolving the issue was straightforward: I switched idx=$[idx+1] and final=$[init+1] to the more standard and consistent format:

final=$((init+1))
idx=$((idx+1))

To prevent similar issues in the future, I suggest updating the documentation or implementation notes to warn users about shell compatibility.

Best regards,

clbrooksiii commented 1 year ago

Hi,Thanks for troubleshooting this for us. We really need to get rid of all she’ll scripting anyway. This is a motivation for doing so. Cheers,Charlie ----------------------------------------------------------------------Charles L. Brooks III (he/him)Cyrus Levinthal Distinguished University Professor   of Chemistry and BiophysicsWarner-Lambert/Parke-Davis Professor   of ChemistryProfessor of BiophysicsDirector of the Biophysics ProgramNorth American Editor-in-Chief of     Journal of Computational ChemistryDepartment of Chemistry, Biophysics ProgramPresident of the Protein Society (2017-2020) 930 N. University AveUniversity of MichiganAnn Arbor, MI 48109Phone: 734/647-6682Fax:     734/647-1604Phone: 734/763-6444 (Biophysics Office)Brooks LabJournal of Computational ChemistryProtein SocietyNicholas O'HairAdministrative Assistant & JCC Editorial AssistantPhone: 734/763-2353Email: @. MoingBiophysics Executive @. me on twitter: https://twitter.com/CharlesLBrooks----------------------------------------------------------------------On Aug 18, 2023, at 4:21 PM, ZzakB @.***> wrote: Hi Prof. Brooks, Thank you for the reply. I followed the installation instructions and confirmed that I have the MMTSB toolset installed with the correct environment variables declared. Upon further investigation into the code, I managed to pinpoint and resolve the problem. It appears the error originates from the top_N_cluster function in the cdocker module. Within the function, the following shell code is executed via the os.system method: idx=1 rm -f cluster_list grep @cluster %s | sed 1d | awk '{if ($4 > %d) print}' | sort -nk 4 | tail -n %d | awk '{print $2}' | cut -b 3- > tmplist for init in cat tmplist; do final=$[init+1] awk "/cluster t.$init /, /cluster t.$final / {print}" %s | sed /cluster/d | awk '{print $2}' > tmp awk '{$2 = name; print}' name=$idx tmp >> cluster_list idx=$[idx+1] done The incrementing of the idx variable uses an older syntax that might not be universally supported across different shell versions. In my case, it failed for bash 5.0.17(1), but worked for and older version (4.2.46(2)). Resolving the issue was straightforward: I switched idx=$[idx+1] to the more standard and consistent format: idx=$((idx+1)) Best regards,

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>