Compile CNS for HADDOCK3 with tcsh

The HADDOCK category is meant to discuss any HADDOCK-related issue. For general information about HADDOCK refer to HADDOCK – Bonvin Lab

Dear HADDOCK team,

I am currently attempting to compile CNS for integration with HADDOCK3, and I’d like to describe my current setup and the steps I’ve taken so far:

1. System Environment:

  • Linux system, x86_64 architecture
  • No root privileges
  • tcsh installed via Conda (conda install -c conda-forge tcsh)
  • Created a symbolic link from tcsh to csh in ~/bin/, and added this path to $PATH

2. CNS Setup & Adjustments:

  • I cloned the HADDOCK3 repository from GitHub (https://github.com/haddocking/haddock3), but the varia/cns1.3/ directory only contains getarch, and does not include the patched CNS files necessary to build CNS:
    • Missing: bin/install, bin/depend, bin/objects, bin/modify_path, patched source/ files, etc.
  • I obtained a cns_solve_1.3 directory separately and attempted to compile it.

3. Manual Modifications for Compatibility:

To allow CNS scripts to run with my environment (no /bin/csh, only Conda-installed tcsh), I made the following changes:

  • Edited all CNS scripts (bin/install, bin/modify_path, etc.) and changed the shebang lines:

  • #!/bin/csh -f to #!/usr/bin/env csh

  • Modified the Makefile to set: CSHELL = /home/data/t210416/bin/csh

  • Compilation Progress
    csh
    source ./cns_solve_env
    setenv CNS_ARCH intel-x86_64bit-linux
    ./bin/install

Installation directory: /home/data/t210416/biosoft/cns/cns_solve_1.3/intel-x86_64bit-linux
copying files in instlib directory intel-x86_64bit-linux to intel-x86_64bit-linux

0read.me
arch_env
machine_c.c
machine_f.f
Makefile.header.1.ifort
Makefile.header.2.gfortran
Makefile.header.3.ifort_mp
Makefile.header.4.pgf95
Makefile.header.5.ifort_mp_profile
Makefile.header.6.ifort_mp_tcheck
Makefile.header.7.gfortran_mp
Using Makefile template for compiler: gfortran
removing old source files
linking source files to intel-x86_64bit-linux/source
removing old object files
linking machine_f.f to source directory
linking machine_c.c to source directory
linking generic fft file to source directory
making Makefile in source directory
/bin/sh: 1: ../../bin/objects: not found
/bin/sh: 12: ../../bin/depend: not found
make[1]: *** [Makefile.proto:67: makefiles] Error 127
make: *** [Makefile:131: makefiles] Error 2
testing Fortran and C compilers
compiling: gcc -O -DINTEGER='long int' -DCNS_ARCH_TYPE_LINUX 
C compiler passes test
compiling: gfortran -fdefault-integer-8 -w  -fallow-argument-mismatch -O3  -funroll-loops -ffast-math -static   
linking: gfortran -w  -static-libgfortran
Fortran compiler passes test
making utility programs
make relink
make default
gfortran -o PSmapx -w -O PSmapx.f 
gfortran -o PSmapy -w -O PSmapy.f 
gfortran -o PSmapz -w -O PSmapz.f 
gcc -o to_cns -O to_cns.c -lm
to_cns.c:65:1: error: return type defaults to 'int' [-Wimplicit-int]
   65 | main(int argc, char *argv[]) {
      | ^~~~
make[3]: *** [Makefile:28: to_cns] Error 1
make[2]: *** [Makefile:21: utils] Error 2
make[1]: *** [Makefile.header:26: compile-utils] Error 2
make: *** [Makefile:60: utils] Error 2

flags:
 fortran -> [gfortran] -fdefault-integer-8 -w  -fallow-argument-mismatch -O3  -funroll-loops -ffast-math -static   
       c -> [gcc] -O -DINTEGER='long int' -DCNS_ARCH_TYPE_LINUX 
    link -> [gfortran] -w  -static-libgfortran  


compiling: dmemory.c

compiling: machine_c.c

linking: cns_solve

/home/data/t210416/miniconda3/envs/haddock_3.9/bin/../lib/gcc/x86_64-conda-linux-gnu/14.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /home/data/t210416/miniconda3/envs/haddock_3.9/bin/../x86_64-conda-linux-gnu/sysroot/usr/lib/../lib/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
problems with new executable - old version retained

I was unable to obtain the working cns executable, and I am not sure where exactly the error occurred.
I would greatly appreciate your guidance in resolving this issue.

1 Like

Dear liujiarui,

We currently ship a compiled CNS binary at installation time.
Please follow the instructions in INSTALL.md, and let us know if you still cannot make haddock3 work.
With a little bit of luck, you will not have to compile CNS yourself anymore :slight_smile:

Basically:

  • Clone the haddock3 repository: git clone https://github.com/haddocking/haddock3
  • Go to the haddock3 directory: cd haddock3
  • Create a virtual env: python3 -m venv haddock3-env (this step could be performed by creating a conda env too)
  • Activate it: source haddock3-env/bin/activate (this step could be performed by loading the conda env)
  • Install haddock3 package: pip install .

Let us know if this is still not functional.

P.S: CNS will be installed in the env, not in the haddock3 directory

Cheers

Victor

Thank you for your response. I followed the steps you provided to install HADDOCK3 and successfully ran test_cns_paths.py using pytest. However, when I try to run my own .cfg file, I keep encountering an error. I’m new to HADDOCK3 and I’m not sure where the problem is.I look forward to your reply. Thank you very much.

***This is the content of my directory.

(haddock_3.9) [t210416@stark11-server ~/HIV/vdj/haddock/test]$ tree
.
├── data
│   ├── af005496_1_gp120_aa.pdb
│   ├── ambig.tbl
│   ├── H1_clono3255.pdb
│   └── unambig.tbl
└── test.cfg

***This is my error output

[2025-04-08 17:38:45,513 libutil ERROR] [Errno 17] File exists: '/home/data/t210416/HIV/vdj/haddock/test/run_H1_clono3255_af005496/0_topoaa'
[2025-04-08 17:38:45,513 libutil ERROR] An error has occurred, see log file. And contact the developers if needed.
[2025-04-08 17:38:45,514 libutil INFO] Finished at 08/04/2025 17:38:45. For any help contact us at https://github.com/haddocking/haddock3/issues. Good bye! Agur! Tchau!.
[2025-04-08 17:38:45,531 libworkflow INFO] Reading instructions step 0_topoaa
[2025-04-08 17:38:45,531 libworkflow INFO] Reading instructions step 1_rigidbody
[2025-04-08 17:38:45,532 libworkflow INFO] Reading instructions step 2_flexref
[2025-04-08 17:38:45,532 libworkflow INFO] Reading instructions step 3_emref
[2025-04-08 17:38:45,533 libworkflow INFO] Reading instructions step 4_clustfcc
[2025-04-08 17:38:45,533 libutil ERROR] [Errno 17] File exists: '/home/data/t210416/HIV/vdj/haddock/test/run_H1_clono3255_af005496/0_topoaa'
Traceback (most recent call last):
  File "/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/libs/libutil.py", line 378, in log_error_and_exit
    yield
  File "/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/clis/cli.py", line 195, in main
    workflow.run()
  File "/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/libs/libworkflow.py", line 43, in run
    step.execute()
  File "/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/libs/libworkflow.py", line 148, in execute
    self.working_path.resolve().mkdir(parents=False, exist_ok=False)
  File "/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/pathlib.py", line 1323, in mkdir
    self._accessor.mkdir(self, mode)
FileExistsError: [Errno 17] File exists: '/home/data/t210416/HIV/vdj/haddock/test/run_H1_clono3255_af005496/0_topoaa'
[2025-04-08 17:38:45,533 libutil ERROR] [Errno 17] File exists: '/home/data/t210416/HIV/vdj/haddock/test/run_H1_clono3255_af005496/0_topoaa'
[2025-04-08 17:38:45,533 libutil ERROR] An error has occurred, see log file. And contact the developers if needed.
[2025-04-08 17:38:45,533 libutil INFO] Finished at 08/04/2025 17:38:45. For any help contact us at https://github.com/haddocking/haddock3/issues. Do pobachennya! 再见! Dovidenia!.
--------------------------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
--------------------------------------------------------------------------
--------------------------------------------------------------------------
mpirun detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

  Process name: [[49318,1],1]
  Exit code:    1
--------------------------------------------------------------------------

*** This is my command and .cfg file

mpirun -np 16 haddock3 test.cfg
(haddock_3.9) [t210416@stark11-server ~/HIV/vdj/haddock/test]$ cat test.cfg 
run_dir = "run_H1_clono3255_af005496"
mode = "mpi"
ncores = 16
concat = 1
clean = true
molecules = [
    "data/H1_clono3255.pdb",
    "data/af005496_1_gp120_aa.pdb"
]

# ====================================================================
# Parameters for each stage are defined below, prefer full paths
# ====================================================================
[topoaa]

[rigidbody]
ambig_fname = "data/ambig.tbl"
unambig_fname = "data/unambig.tbl"
sampling = 96

[flexref]
tolerance = 5
ambig_fname = "data/ambig.tbl"
unambig_fname = "data/unambig.tbl"

[emref]
tolerance = 5
ambig_fname = "data/ambig.tbl"
unambig_fname = "data/unambig.tbl"

[clustfcc]
strictness = 0.75

Hi!
Take a look at this:
“”"
FileExistsError: [Errno 17] File exists: ‘/home/data/t210416/HIV/vdj/haddock/test/run_H1_clono3255_af005496/0_topoaa
“””

Haddock cannot re-use already used directory for run_dir. You should either delete files inside “run_H1_clono3255_af005496" directory before running the same .cfg again, or define a new run_dir in your .cfg

Or use —restart option. Here is more info about it: Command Line Interfaces - HADDOCK3 User Manual

I followed your method to run it, but the error still occurred. I did not generate the “run” folder myself, yet the same error keeps appearing.

[2025-04-08 18:18:57,043 libmpi INFO] Executing tasks with the haddock3-mpitask runner using 16 processors...
[2025-04-08 18:18:57,060 libworkflow INFO] Reading instructions step 0_topoaa
[2025-04-08 18:18:57,060 libworkflow INFO] Reading instructions step 1_rigidbody
[2025-04-08 18:18:57,060 libworkflow INFO] Reading instructions step 2_flexref
[2025-04-08 18:18:57,061 libworkflow INFO] Reading instructions step 3_emref
[2025-04-08 18:18:57,061 libworkflow INFO] Reading instructions step 4_clustfcc
[2025-04-08 18:18:57,061 libutil ERROR] [Errno 17] File exists: '/home/data/t210416/HIV/vdj/haddock/test/run_H1_clono/0_topoaa'
Traceback (most recent call last):
  File "/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/libs/libutil.py", line 378, in log_error_and_exit
    yield

This is the folder I got after running the job.

(haddock_3.9) [t210416@stark11-server ~/HIV/vdj/haddock/test]$ tree
.
├── data
│   ├── af005496_1_gp120_aa.pdb
│   ├── ambig.tbl
│   ├── H1_clono3255.pdb
│   └── unambig.tbl
├── run_H1_clono
│   ├── 0_topoaa
│   │   ├── mpi.pkl
│   │   └── params.cfg
│   ├── data
│   │   ├── 0_topoaa
│   │   │   ├── af005496_1_gp120_aa.pdb
│   │   │   └── H1_clono3255.pdb
│   │   ├── 1_rigidbody
│   │   │   ├── ambig.tbl
│   │   │   └── unambig.tbl
│   │   ├── 2_flexref
│   │   │   ├── ambig.tbl
│   │   │   └── unambig.tbl
│   │   ├── 3_emref
│   │   │   ├── ambig.tbl
│   │   │   └── unambig.tbl
│   │   └── configurations
│   │       ├── cleaned_input.toml
│   │       ├── enhanced_haddock_params.json
│   │       ├── enhanced_haddock_params.toml
│   │       ├── raw_input.toml
│   │       └── README.txt
│   └── log
└── test.cfg

9 directories, 21 files

But if I run it without using MPI, it doesn’t produce this error—instead, it says that my GLIBC is missing.

**cfg**:run_dir = "/home/data/t210416/HIV/vdj/haddock/test/run_H1_clono"

concat = 1
clean = true



molecules = [
    "data/H1_clono3255.pdb",
    "data/af005496_1_gp120_aa.pdb"
]
**(haddock_3.9) [t210416@stark11-server ~/HIV/vdj/haddock/test]$ haddock3 test.cfg**

[2025-04-08 18:27:59,755 base_cns_module INFO] Running [topoaa] module
[2025-04-08 18:27:59,756 __init__ INFO] [topoaa] Molecule 1: H1_clono3255.pdb
[2025-04-08 18:27:59,759 __init__ INFO] [topoaa] Sanitizing molecule H1_clono3255.pdb
[2025-04-08 18:27:59,773 __init__ INFO] [topoaa] Topology CNS input created
[2025-04-08 18:27:59,773 __init__ INFO] [topoaa] Molecule 2: af005496_1_gp120_aa.pdb
[2025-04-08 18:27:59,776 __init__ INFO] [topoaa] Sanitizing molecule af005496_1_gp120_aa.pdb
[2025-04-08 18:27:59,790 __init__ INFO] [topoaa] Topology CNS input created
[2025-04-08 18:27:59,791 __init__ INFO] [topoaa] Running CNS Jobs n=2
[2025-04-08 18:27:59,791 libutil INFO] Selected 2 cores to process 2 jobs, with 256 maximum available cores.
[2025-04-08 18:27:59,794 libparallel INFO] Using 2 cores
[2025-04-08 18:27:59,820 libparallel WARNING] Exception in task execution: b"/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/bin/cns: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/bin/cns)\n/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/bin/cns: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/bin/cns)\n"
[2025-04-08 18:27:59,821 libparallel WARNING] Exception in task execution: b"/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/bin/cns: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/bin/cns)\n/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/bin/cns: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/bin/cns)\n"
[2025-04-08 18:27:59,831 libparallel INFO] 2 tasks finished
[2025-04-08 18:27:59,832 __init__ INFO] [topoaa] CNS jobs have finished
[2025-04-08 18:27:59,835 libutil ERROR] 100.00% of output was not generated for this module and tolerance was set to 0.00%.
Traceback (most recent call last):
  File "/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/libs/libutil.py", line 378, in log_error_and_exit
    yield
  File "/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/clis/cli.py", line 195, in main
    workflow.run()
  File "/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/libs/libworkflow.py", line 43, in run
    step.execute()
  File "/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/libs/libworkflow.py", line 162, in execute
    self.module.run()  # type: ignore
  File "/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/modules/base_cns_module.py", line 61, in run
    self._run()
  File "/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/modules/topology/topoaa/__init__.py", line 334, in _run
    self.export_io_models(faulty_tolerance=self.params["tolerance"])
  File "/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/modules/__init__.py", line 309, in export_io_models
    self.finish_with_error(_msg)
  File "/home/data/t210416/miniconda3/envs/haddock_3.9/lib/python3.9/site-packages/haddock/modules/__init__.py", line 317, in finish_with_error
    raise RuntimeError(reason)
RuntimeError: 100.00% of output was not generated for this module and tolerance was set to 0.00%.
[2025-04-08 18:27:59,838 libutil ERROR] 100.00% of output was not generated for this module and tolerance was set to 0.00%.
[2025-04-08 18:27:59,838 libutil ERROR] An error has occurred, see log file. And contact the developers if needed.
[2025-04-08 18:27:59,839 libutil INFO] Finished at 08/04/2025 18:27:59. For any help contact us at https://github.com/haddocking/haddock3/issues. Adiós! Good bye! Adéu-siau!.

Looks like you will need to recompile CNS for your system

Check the instructions at:

https://github.com/haddocking/haddock3/blob/main/docs/INSTALL.md

and

https://github.com/haddocking/haddock3/blob/main/docs/CNS.md

Yes, it was indeed an issue with CNS. Previously, when I tried to recompile it, I was prompted that GLIBC was missing. Since I don’t have root privileges, I couldn’t upgrade it directly. However, my server does have Docker, so I pulled the HADDOCK3 image, and now it’s running successfully. Thank you very much for taking the time to answer my questions.

1 Like

Glad to hear the image solved it for you. :whale: