├── Dockerfiles ├── README.md ├── cpu │ ├── Dockerfile │ └── Makefile ├── gpu │ ├── Dockerfile │ └── Makefile └── mpi │ ├── Dockerfile │ └── Makefile ├── data └── SAMPLE.table ├── src ├── constant.h ├── contact.py ├── parallel.h ├── ligand.h ├── receptor.h ├── control.h ├── docking.h ├── pdb_entry.h ├── mpidp.h ├── cpu_time.h ├── pdb_entry.cpp ├── protein.h ├── parameter.h ├── calcrg.cpp ├── main.cpp ├── main.cu ├── protein.cpp ├── decoygen.cpp ├── fft_process.h ├── cpu_time.cpp ├── ligand.cpp ├── receptor.cpp ├── cuda_kernel.cu └── control.cpp ├── .github └── workflows │ └── build_container.yml ├── block ├── doc ├── README_for_docker.md ├── BUILD.md └── README.md ├── ppiscore ├── README.md ├── Makefile ├── Makefile.colab └── LICENSE /Dockerfiles/README.md: -------------------------------------------------------------------------------- 1 | Please read the documentation for docker users ([doc/README_for_docker.md](../doc/README_for_docker.md)). 2 | -------------------------------------------------------------------------------- /data/SAMPLE.table: -------------------------------------------------------------------------------- 1 | TITLE=sample jobs 2 | PARAM=-R $1 -L $2 -O 3 | data/1gcq_r.pdb data/1gcq_r.pdb 4 | data/1gcq_r.pdb data/1gcq_l.pdb 5 | data/1gcq_l.pdb data/1gcq_r.pdb 6 | data/1gcq_l.pdb data/1gcq_l.pdb 7 | -------------------------------------------------------------------------------- /src/constant.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //==================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : (Constant) 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //==================================================================// 14 | 15 | #ifndef Constant_h 16 | #define Constant_h 1 17 | 18 | #include 19 | 20 | using namespace std; 21 | 22 | const float EPS = 1.0e-6; 23 | const float BIG = 1.0e+9; 24 | const float PI = 4.0*atan(1.0); 25 | const float RAD = PI/180.0; 26 | const float clockpersec_float = (float)CLOCKS_PER_SEC; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /.github/workflows/build_container.yml: -------------------------------------------------------------------------------- 1 | name: Build containers 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | jobs: 10 | 11 | build-cpu: 12 | name: build megadock-cpu 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: checkout 17 | uses: actions/checkout@master 18 | 19 | - name: build container 20 | run: docker build . --file Dockerfiles/cpu/Dockerfile --tag megadock:cpu 21 | 22 | - name: test docking example 23 | run: docker run megadock:cpu megadock -R data/1gcq_r.pdb -L data/1gcq_l.pdb 24 | 25 | build-gpu: 26 | name: build megadock-gpu 27 | runs-on: ubuntu-latest 28 | 29 | steps: 30 | - name: checkout 31 | uses: actions/checkout@master 32 | 33 | - name: build container 34 | run: docker build . --file Dockerfiles/gpu/Dockerfile --tag megadock:gpu 35 | 36 | # - name: test docking example 37 | # run: docker run --gpus all megadock:gpu megadock-gpu -R data/1gcq_r.pdb -L data/1gcq_l.pdb 38 | -------------------------------------------------------------------------------- /src/contact.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Masahito Ohue 4 | # 5 | # Usage: Contact.py pdb1 pdb2 6 | # 7 | 8 | import os 9 | import sys 10 | import math 11 | import Bio 12 | from Bio.PDB import * 13 | from math import * 14 | 15 | dist = 4 # contact distance 16 | 17 | PDB1 = sys.argv[1] 18 | PDB2 = sys.argv[2] 19 | 20 | parser = PDBParser() 21 | str1 = parser.get_structure("1", PDB1) 22 | str2 = parser.get_structure("2", PDB2) 23 | rescon = 0 24 | #chain 1 -> chain 2 25 | for model1 in str1.get_list(): 26 | for chain1 in model1.get_list(): 27 | for r1 in chain1.get_list(): 28 | for a1 in r1.get_list(): 29 | for model2 in str2.get_list(): 30 | for chain2 in model2.get_list(): 31 | for r2 in chain2.get_list(): 32 | for a2 in r2.get_list(): 33 | if rescon == 1: 34 | continue 35 | d = a1 - a2 36 | if d < dist: 37 | rescon = 1 38 | 39 | if rescon == 1: 40 | print r1, r2 41 | rescon = 0 42 | 43 | -------------------------------------------------------------------------------- /Dockerfiles/cpu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | MAINTAINER Akiyama Laboratory, Tokyo Institute of Technology 4 | 5 | RUN apt-get update -y 6 | RUN apt-get install -y --no-install-recommends \ 7 | wget \ 8 | make \ 9 | g++ \ 10 | && rm -rf /var/lib/apt/lists/* 11 | 12 | 13 | # FFTW 14 | ENV FFTW_TARGET fftw-3.3.8 15 | 16 | RUN wget -P /tmp http://www.fftw.org/${FFTW_TARGET}.tar.gz && \ 17 | tar xzf /tmp/${FFTW_TARGET}.tar.gz -C /tmp && \ 18 | rm -rf /tmp/${FFTW_TARGET}.tar.gz && \ 19 | cd /tmp/${FFTW_TARGET} && \ 20 | ./configure --enable-float --enable-sse2 --prefix=/usr/local/${FFTW_TARGET} && \ 21 | make -j$(nproc) && \ 22 | make install 23 | 24 | 25 | # MEGADOCK 26 | ENV MEGADOCK_WORK_DIR /opt/MEGADOCK 27 | 28 | ADD . ${MEGADOCK_WORK_DIR} 29 | COPY Dockerfiles/cpu/Makefile ${MEGADOCK_WORK_DIR}/Makefile 30 | 31 | RUN cd ${MEGADOCK_WORK_DIR} && \ 32 | make -j$(nproc) 33 | 34 | WORKDIR ${MEGADOCK_WORK_DIR} 35 | 36 | RUN ln -s ${MEGADOCK_WORK_DIR}/megadock /usr/local/bin/megadock && \ 37 | ln -s ${MEGADOCK_WORK_DIR}/decoygen /usr/local/bin/decoygen && \ 38 | ln -s ${MEGADOCK_WORK_DIR}/block /usr/local/bin/block && \ 39 | ln -s ${MEGADOCK_WORK_DIR}/ppiscore /usr/local/bin/ppiscore 40 | 41 | -------------------------------------------------------------------------------- /src/parallel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : Parallel 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #ifndef Parallel_h 16 | #define Parallel_h 1 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #ifdef _OPENMP 23 | #include 24 | #endif 25 | 26 | class Parallel 27 | { 28 | private: 29 | Parallel(Parallel &c) {} 30 | size_t _Nproc2; 31 | int _Num_gpu; 32 | public: 33 | Parallel(const size_t &nproc2) : _Nproc2(nproc2) { 34 | #ifdef DEBUG 35 | cout << "Constructing Parallel.\n"; 36 | #endif 37 | } 38 | virtual ~Parallel() { 39 | #ifdef DEBUG 40 | cout << "Destructing Parallel.\n"; 41 | #endif 42 | } 43 | void nproc2(int i) { 44 | _Nproc2 = i; 45 | } 46 | size_t nproc2() { 47 | return _Nproc2; 48 | } 49 | void num_gpu(int i) { 50 | _Num_gpu = i; 51 | } 52 | int num_gpu() { 53 | return _Num_gpu; 54 | } 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /Dockerfiles/gpu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nvidia/cuda:11.1.1-devel-ubuntu20.04 2 | 3 | MAINTAINER Akiyama Laboratory, Tokyo Institute of Technology 4 | 5 | RUN apt-get update -y 6 | RUN apt-get install -y --no-install-recommends \ 7 | wget \ 8 | make \ 9 | g++ \ 10 | cuda-samples-11-1 \ 11 | && rm -rf /var/lib/apt/lists/* 12 | 13 | # FFTW 14 | ENV FFTW_TARGET fftw-3.3.8 15 | 16 | RUN wget -P /tmp http://www.fftw.org/${FFTW_TARGET}.tar.gz && \ 17 | tar xzf /tmp/${FFTW_TARGET}.tar.gz -C /tmp && \ 18 | rm -rf /tmp/${FFTW_TARGET}.tar.gz && \ 19 | cd /tmp/${FFTW_TARGET} && \ 20 | ./configure --enable-float --enable-sse2 --prefix=/usr/local/${FFTW_TARGET} && \ 21 | make -j$(nproc) && \ 22 | make install 23 | 24 | 25 | # MEGADOCK 26 | ENV MEGADOCK_WORK_DIR /opt/MEGADOCK 27 | 28 | ADD . ${MEGADOCK_WORK_DIR} 29 | COPY Dockerfiles/gpu/Makefile ${MEGADOCK_WORK_DIR}/Makefile 30 | 31 | RUN cd ${MEGADOCK_WORK_DIR} && \ 32 | make -j$(nproc) 33 | 34 | WORKDIR ${MEGADOCK_WORK_DIR} 35 | 36 | RUN ln -s ${MEGADOCK_WORK_DIR}/megadock-gpu /usr/local/bin/megadock-gpu && \ 37 | ln -s ${MEGADOCK_WORK_DIR}/decoygen /usr/local/bin/decoygen && \ 38 | ln -s ${MEGADOCK_WORK_DIR}/block /usr/local/bin/block && \ 39 | ln -s ${MEGADOCK_WORK_DIR}/ppiscore /usr/local/bin/ppiscore 40 | 41 | -------------------------------------------------------------------------------- /Dockerfiles/mpi/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | MAINTAINER Akiyama Laboratory, Tokyo Institute of Technology 4 | 5 | RUN apt-get update -y 6 | RUN apt-get install -y --no-install-recommends \ 7 | wget \ 8 | make \ 9 | g++ \ 10 | openmpi-bin \ 11 | libopenmpi-dev \ 12 | ssh \ 13 | && rm -rf /var/lib/apt/lists/* 14 | 15 | 16 | # FFTW 17 | ENV FFTW_TARGET fftw-3.3.8 18 | 19 | RUN wget -P /tmp http://www.fftw.org/${FFTW_TARGET}.tar.gz && \ 20 | tar xzf /tmp/${FFTW_TARGET}.tar.gz -C /tmp && \ 21 | rm -rf /tmp/${FFTW_TARGET}.tar.gz && \ 22 | cd /tmp/${FFTW_TARGET} && \ 23 | ./configure --enable-float --enable-sse2 --prefix=/usr/local/${FFTW_TARGET} && \ 24 | make -j$(nproc) && \ 25 | make install 26 | 27 | 28 | # MEGADOCK 29 | ENV MEGADOCK_WORK_DIR /opt/MEGADOCK 30 | 31 | ADD . ${MEGADOCK_WORK_DIR} 32 | COPY Dockerfiles/mpi/Makefile ${MEGADOCK_WORK_DIR}/Makefile 33 | 34 | RUN cd ${MEGADOCK_WORK_DIR} && \ 35 | make -j$(nproc) 36 | 37 | RUN ln -s ${MEGADOCK_WORK_DIR}/megadock-dp /usr/local/bin/megadock-dp && \ 38 | ln -s ${MEGADOCK_WORK_DIR}/decoygen /usr/local/bin/decoygen && \ 39 | ln -s ${MEGADOCK_WORK_DIR}/block /usr/local/bin/block && \ 40 | ln -s ${MEGADOCK_WORK_DIR}/ppiscore /usr/local/bin/ppiscore 41 | 42 | WORKDIR ${MEGADOCK_WORK_DIR} 43 | 44 | # CONFIGURATION 45 | ENV OMP_NUM_THREADS 8 46 | RUN echo "export OMP_NUM_THREADS=${OMP_NUM_THREADS}" >> /etc/profile 47 | -------------------------------------------------------------------------------- /src/ligand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : Ligand 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #ifndef Ligand_h 16 | #define Ligand_h 1 17 | 18 | #include "protein.h" 19 | #include "parameter.h" 20 | 21 | using namespace std; 22 | 23 | class Ligand : public Protein // Ligand class 24 | { 25 | private: 26 | // const Ligand & operator=(const Ligand &c); 27 | 28 | public: 29 | Ligand(string &rinput_file) : Protein(rinput_file) { 30 | #ifdef DEBUG 31 | cout << "Constructing Ligand.\n"; 32 | #endif 33 | } 34 | virtual ~Ligand() { 35 | #ifdef DEBUG 36 | cout << "Destructing Ligand.\n"; 37 | #endif 38 | } 39 | 40 | virtual void electro(const float &beta,const float &eratio, 41 | const int &num_grid,float *grid_coord,float *atom_coord_rotated, 42 | int *iwork,float *fwork,const int &old_voxel_flag); 43 | virtual void rpscace(const float &aceratio, const int &num_grid, float *grid_coord, 44 | float *atom_coord_rotated, int *iwork, float *fwork, 45 | const float ¶m_rec_core, const float ¶m_lig_core,const int &old_voxel_flag); 46 | virtual void precalc(const int &num_grid,int *nearesta,float *rjudge2, 47 | float *radius_core2,float *radius_surf2); 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/receptor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : Receptor 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #ifndef Receptor_h 16 | #define Receptor_h 1 17 | 18 | #include "protein.h" 19 | #include "parameter.h" 20 | 21 | using namespace std; 22 | 23 | class Receptor : public Protein // Receptor class 24 | { 25 | private: 26 | // const Receptor & operator=(const Receptor &c); 27 | public: 28 | Receptor(string &rinput_file) : Protein(rinput_file) { 29 | #ifdef DEBUG 30 | cout << "Constructing Receptor.\n"; 31 | #endif 32 | } 33 | virtual ~Receptor() { 34 | #ifdef DEBUG 35 | cout << "Destructing Receptor.\n"; 36 | #endif 37 | } 38 | virtual void electro(const float &beta,const float &eratio, 39 | const int &num_grid,float *grid_coord,float *atom_coord_rotated, 40 | int *iwork,float *fwork,const int &old_voxel_flag); 41 | virtual void rpscace(const float &aceratio, const int &num_grid, float *grid_coord, 42 | float *atom_coord_rotated, int *iwork, float *fwork, 43 | const float ¶m_rec_core, const float ¶m_lig_core,const int &old_voxel_flag); 44 | virtual void precalc(const int &num_grid,int *nearesta,float *rjudge2, 45 | float *radius_core2,float *radius_surf2); 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /block: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Copyright (C) 2020 Tokyo Institute of Technology 4 | # 5 | # ===================================================================== 6 | # 7 | # Software Name : MEGADOCK (blocking residues) 8 | # 9 | # Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 10 | # 11 | # Last update: December 3, 2014 12 | # 13 | # ===================================================================== 14 | import os 15 | import sys 16 | import csv 17 | 18 | if (len(sys.argv) != 4): 19 | print 'Usage: $ %s [pdbfile] [chain] [target residue list]' % sys.argv[0] 20 | print '' 21 | print ' e.g.) $ %s 1gcq_r.pdb B 182-186,189,195-198,204 > blocked.pdb' % sys.argv[0] 22 | print '' 23 | print 'Note: Target residue list is separated by commas and no spaces.' 24 | print ' You can also use hyphen \"-\": \"182-186\" means blocking residues of 182, 183, ..., 186.' 25 | print ' Blocked residues are substituted for \'BLK\'.' 26 | print ' Updated PDB coordinates are written to \"standard output\".' 27 | quit(1) 28 | 29 | ch = sys.argv[2] 30 | 31 | reslist = [] 32 | resarg = sys.argv[3].split(",") 33 | for r in resarg: 34 | if "-" in r: 35 | rseq = r.split("-") 36 | for i in range(int(rseq[0]), int(rseq[1])+1): 37 | reslist.append(str(i)) 38 | else: 39 | reslist.append(r) 40 | 41 | fp = open(sys.argv[1], "r") 42 | try: 43 | for l in fp.readlines(): 44 | l = l.strip() 45 | 46 | if l[0:4] != "ATOM" and l[0:6] != "HETATM": 47 | print l 48 | continue 49 | 50 | if l[21] != ch: 51 | print l 52 | continue 53 | 54 | ll = l 55 | if ll[22:26].strip() not in reslist: 56 | print l 57 | continue 58 | 59 | print l[0:16] + " BLK" + l[20:] 60 | 61 | finally: 62 | fp.close() 63 | -------------------------------------------------------------------------------- /src/control.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : Control 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #ifndef Control_h 16 | #define Control_h 1 17 | 18 | #include "cpu_time.h" 19 | #include "parallel.h" 20 | #include "parameter.h" 21 | #include "receptor.h" 22 | #include "ligand.h" 23 | #include "docking.h" 24 | 25 | using namespace std; 26 | 27 | class Control 28 | { 29 | private: 30 | Control(Control &c) {} 31 | const Control & operator=(const Control &c); 32 | CPUTime *_cputime; 33 | Parallel *_parallel; 34 | Parameter *_parameter; 35 | Receptor *_receptor; 36 | Ligand *_ligand; 37 | Docking *_docking; 38 | protected: 39 | virtual void gridtable_11base_normal(int &ngrid,vector &ngrid_table); 40 | virtual void gridtable_13base_normal(int &ngrid,vector &ngrid_table); 41 | virtual void gridtable_07base_normal(int &ngrid,vector &ngrid_table); 42 | virtual void gridtable_fftw_custom(int &ngrid,vector &ngrid_table); 43 | virtual void gridtable_cufft_custom(int &ngrid,vector &ngrid_table); 44 | virtual void autogridr(const int &ngrid,vector &ngrid_table); 45 | virtual void autogridl(const int &ngrid,vector &ngrid_table); 46 | virtual void checkgridr(); 47 | virtual void checkgridl(); 48 | public: 49 | Control(CPUTime *pcputime,Parallel *pparallel) 50 | : _cputime(pcputime),_parallel(pparallel) { 51 | #ifdef DEBUG 52 | cout << "Constructing Control.\n"; 53 | #endif 54 | } 55 | virtual ~Control() { 56 | #ifdef DEBUG 57 | cout << "Destructing Control.\n"; 58 | #endif 59 | } 60 | virtual void initialize(int argc,char *argv[]); 61 | virtual void execute(); 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/docking.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : Docking 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #ifndef Docking_h 16 | #define Docking_h 1 17 | 18 | #include "cpu_time.h" 19 | #include "parallel.h" 20 | #include "parameter.h" 21 | #include "receptor.h" 22 | #include "ligand.h" 23 | #include "fft_process.h" 24 | 25 | using namespace std; 26 | 27 | class Docking 28 | { 29 | private: 30 | Docking(Docking &c) {} 31 | const Docking & operator=(const Docking &c); 32 | CPUTime *_cputime; 33 | Parallel *_parallel; 34 | Parameter *_parameter; 35 | Receptor *_receptor; 36 | Ligand *_ligand; 37 | FFTProcess *_fft_process; 38 | int _Num_grid; 39 | float *_Grid_coord; 40 | float **_Mol_coord; 41 | float *_Fwork; 42 | int *_Iwork; 43 | size_t _Memfw; 44 | size_t _Memiw; 45 | protected: 46 | virtual void maxsize_voxel(); 47 | virtual void alloc_array(const int &maxatom, const int &nag, const size_t &ng3); 48 | virtual void create_voxel(Protein *rprotein, size_t myid2); 49 | virtual void ligand_rotationz(float *theta, size_t myid2); 50 | public: 51 | Docking(CPUTime *pcputime,Parallel *pparallel,Parameter *pparameter, 52 | Receptor *rreceptor,Ligand *rligand) 53 | : _cputime(pcputime),_parallel(pparallel),_parameter(pparameter), 54 | _receptor(rreceptor),_ligand(rligand) { 55 | #ifdef DEBUG 56 | cout << "Constructing Docking.\n"; 57 | #endif 58 | } 59 | virtual ~Docking() { 60 | #ifdef DEBUG 61 | cout << "Destructing Docking.\n"; 62 | #endif 63 | delete [] _Grid_coord; 64 | delete [] _Mol_coord; 65 | delete [] _Fwork; 66 | delete [] _Iwork; 67 | delete _fft_process; 68 | } 69 | virtual void initialize(); 70 | virtual void rec_init(); 71 | virtual void dockz(); 72 | virtual void dock_memory_free(); 73 | virtual void output(); 74 | virtual void output_detail(); // for analysis 75 | virtual void output_calc_time_log(); // for analysis 76 | }; 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /src/pdb_entry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : PDBEntry 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #ifndef PDBEntry_h 16 | #define PDBEntry_h 1 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include "parallel.h" 23 | 24 | using namespace std; 25 | 26 | 27 | class PDBEntry // ATOM element of pdb file class 28 | { 29 | private: 30 | friend class FFTProcess; 31 | string _Input_file; // Input file 32 | int _Num_atoms; // Number of atoms 33 | vector _Atom_type; // Atom type of PDB file 34 | float *_Coordinate; // Atomic coordinate 35 | protected: 36 | virtual void pdb_read(); // Read pdb file 37 | virtual string erase_space(const string &s); // Head and tail space erase and double space to single 38 | public: 39 | PDBEntry(string &rinput_file) : _Input_file(rinput_file) { 40 | #ifdef DEBUG 41 | cout << "Constructing PDBEntry.\n"; 42 | #endif 43 | } 44 | virtual ~PDBEntry() { // Destructor 45 | #ifdef DEBUG 46 | cout << "Destructing PDBEntry.\n"; 47 | #endif 48 | delete [] _Coordinate; 49 | } 50 | virtual string input_file() { 51 | return _Input_file; 52 | } 53 | virtual void num_atoms(int &Num_atoms) { 54 | _Num_atoms = Num_atoms; 55 | return; 56 | } 57 | virtual int num_atoms() { 58 | return _Num_atoms; 59 | } 60 | virtual void coordinate(const int &i,float *Coordinate) { 61 | for( int j = 0 ; j < 3 ; j++ ) { 62 | _Coordinate[3*i+j] = Coordinate[j]; 63 | } 64 | return; 65 | } 66 | virtual void coord_all(float *cod) { 67 | for( int i = 0 ; i < _Num_atoms*3 ; i++ ) { 68 | _Coordinate[i] = cod[i]; 69 | } 70 | return; 71 | } 72 | virtual float coordinate(const int &i,int j) { 73 | return _Coordinate[3*i+j]; 74 | } 75 | virtual string atom_type(const int &i) { 76 | return _Atom_type[i]; 77 | } 78 | }; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /doc/README_for_docker.md: -------------------------------------------------------------------------------- 1 | # MEGADOCK with Docker 2 | 3 | Docker container images are available on [`akiyamalab/megadock`](https://hub.docker.com/r/akiyamalab/megadock/) repository (DockerHub). 4 | - [`akiyamalab/megadock:cpu`](https://hub.docker.com/r/akiyamalab/megadock/) 5 | - [`akiyamalab/megadock:gpu`](https://hub.docker.com/r/akiyamalab/megadock/) 6 | 7 | ## Requirements 8 | | Requirement Tools | GPU | CPU | Notes | 9 | |:----------------------------------------------------------|:---:|:---:|:------------| 10 | | [Docker](https://docs.docker.com/engine/installation/) | x | x | | 11 | | [nvidia-docker](https://github.com/NVIDIA/nvidia-docker) | x | | > 2.0 | 12 | 13 | ## Quick Example 14 | ```sh 15 | # CPU single node (OpenMP parallelization) 16 | docker run akiyamalab/megadock:cpu megadock -R data/1gcq_r.pdb -L data/1gcq_l.pdb -o data/1gcq_r-1gcq_r.out 17 | 18 | # GPU single node (GPU parallelization) 19 | docker run --runtime=nvidia akiyamalab/megadock:gpu megadock-gpu -R data/1gcq_r.pdb -L data/1gcq_l.pdb -o data/1gcq_r-1gcq_r.out 20 | ``` 21 | 22 | ---- 23 | 24 | ## Build Docker Container for MEGADOCK (CPU) 25 | 26 | ### 1. build Docker image 27 | ```sh 28 | # on ${REPOSITORY_ROOT} dir 29 | docker build . -f Dockerfiles/cpu/Dockerfile -t akiyamalab/megadock:cpu 30 | ``` 31 | 32 | ### 2. run sample 33 | ```sh 34 | docker run akiyamalab/megadock:cpu megadock -R data/1gcq_r.pdb -L data/1gcq_l.pdb 35 | 36 | # optional) start interactive shell 37 | docker run -it akiyamalab/megadock:cpu 38 | 39 | # optional) run with your pdb (e.g. ${DATA_PATH} = your pdb-data directory abs path ) 40 | docker run -v ${DATA_PATH}:/opt/MEGADOCK/data akiyamalab/megadock:cpu megadock -R data/${RECEPTOR}.pdb -L data/${LIGAND}.pdb 41 | ``` 42 | 43 | ## Build Docker Container for MEGADOCK (GPU) 44 | 45 | **[nvidia-docker](https://github.com/NVIDIA/nvidia-docker) is required.** 46 | 47 | ### 1. build Docker image 48 | ```sh 49 | # on ${REPOSITORY_ROOT} dir 50 | docker build . -f Dockerfiles/gpu/Dockerfile -t akiyamalab/megadock:gpu 51 | ``` 52 | 53 | ### 2. run sample 54 | ```sh 55 | docker run -it --runtime=nvidia akiyamalab/megadock:gpu megadock-gpu -R data/1gcq_r.pdb -L data/1gcq_l.pdb 56 | 57 | # optional) start interactive shell 58 | docker run -it --runtime=nvidia akiyamalab/megadock:gpu 59 | 60 | # optional) run with your pdb (e.g. ${DATA_PATH} = your pdb-data directory abs path ) 61 | docker run -it --runtime=nvidia -v ${DATA_PATH}:/opt/MEGADOCK/data akiyamalab/megadock:gpu megadock-gpu -R data/${RECEPTOR}.pdb -L data/${LIGAND}.pdb 62 | ``` 63 | -------------------------------------------------------------------------------- /ppiscore: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | # 3 | # Copyright (C) 2020 Tokyo Institute of Technology 4 | # 5 | # ===================================================================== 6 | # 7 | # Software Name : MEGADOCK (calculate PPI score) 8 | # 9 | # Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 10 | # 11 | # Last update: Oct. 10, 2014 12 | # 13 | # ===================================================================== 14 | 15 | use File::Basename; 16 | 17 | if ( (@ARGV != 2 and @ARGV != 3) or ($ARGV[1] !~ /^[0-9]+$/) ){ 18 | print "Usage : $0 [outfile] [#decoys]\n"; 19 | print "Usage : $0 [outfile] [#decoys] [ZRANK outfile]\n"; 20 | exit(1); 21 | } 22 | 23 | $decoys = $ARGV[1]; 24 | 25 | # outfile read 26 | $outfile = $ARGV[0]; 27 | open(IN, "tail -n +5 ./" . $outfile . " |"); 28 | 29 | @rawscore = (); 30 | while ( $line = ) { 31 | chomp $line; 32 | @line_arr = split (/\s+/, $line); 33 | push(@rawscore, $line_arr[6]); 34 | } 35 | 36 | # ZRANK outfile read 37 | if ( @ARGV == 3 ){ 38 | $zrankoutfile = $ARGV[2]; 39 | @zrankscores = (); 40 | open(ZRIN, "cut -f 2 ./" . $zrankoutfile . " |"); 41 | while ( $line = ) { 42 | chomp $line; 43 | push( @zrankscores, $line); 44 | } 45 | @zrankranks = sort { $zrankscores[$a] <=> $zrankscores[$b] } 0 .. $#zrankscores; 46 | #print join("\n", @zrankranks); 47 | } 48 | 49 | for (my $i = 0; $i < $decoys; $i++){ 50 | if ( @ARGV == 3 ) { # with ZRANK 51 | push(@score, $rawscore[$zrankranks[$i]]); 52 | } else { # without ZRANK 53 | push(@score, $rawscore[$i]); 54 | } 55 | } 56 | #print join("\n", @score); 57 | $p = basename($outfile); 58 | 59 | eval { 60 | $zs = sprintf("%.4f", zscore($score[0], @score)); 61 | if ( @ARGV == 3 ) { # with ZRANK 62 | print $p, ", E = ", $zs, ", ", $decoys, " decoys, with Reranking\n"; 63 | } else { # without ZRANK 64 | print $p, ", E = ", $zs, ", ", $decoys, " decoys\n"; 65 | } 66 | }; 67 | 68 | if( $@ ){ # error message in $@ 69 | print $p, ", !!zero divided error!!\n"; 70 | } 71 | 72 | close(IN); 73 | 74 | ########################################################## 75 | sub ave { 76 | my $n = scalar(@_); 77 | my $s = 0; 78 | while (@_) { 79 | my $t = shift; 80 | $s += $t; 81 | } 82 | return $s/$n; 83 | } 84 | 85 | sub std { 86 | my $n = scalar(@_); 87 | my $ss = 0; 88 | my $av = ave(@_); 89 | while (@_) { 90 | my $t = shift; 91 | $ss += ($t - $av)**2; 92 | } 93 | return sqrt($ss/$n); 94 | } 95 | 96 | sub zscore { # zscore( $s, @score ) 97 | my $s = shift; 98 | return ($s - ave(@_))/std(@_) ; 99 | } 100 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MEGADOCK 2 | 3 | **MEGADOCK** is an ultra-high-performance protein-protein prediction software for heterogeneous supercomputers using FFT-grid-based docking with MPI/OpenMP/GPU parallelization. 4 | 5 | [![License: CC BY-NC 4.0](https://licensebuttons.net/l/by-nc/4.0/80x15.png)](https://creativecommons.org/licenses/by-nc/4.0/) 6 | [![License: CC BY-NC 4.0](https://img.shields.io/badge/License-CC%20BY--NC%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by-nc/4.0/) 7 | 8 | ![Build Status](https://github.com/akiyamalab/MEGADOCK/workflows/Build%20containers/badge.svg?branch=master) 9 | 10 | 11 | ## Target Environments 12 | 13 | | Type | Target Env. | Approach | 14 | |:----:|-----------------|--------------------| 15 | | (a) | GPU cluster | GPU + OpenMP + MPI | 16 | | (b) | CPU cluster | OpenMP + MPI | 17 | | (c) | GPU node | GPU + OpenMP | 18 | | (d) | CPU node | OpenMP | 19 | 20 | 21 | ## Installation and Command Details 22 | 23 | For installation and command details, please read appropriate section on followings: 24 | - Read command and script details 25 | - [doc/README.md](./doc/README.md) 26 | - Build a binary from source code 27 | - [doc/BUILD.md](./doc/BUILD.md) 28 | - Build a docker container image 29 | - [doc/README_for_docker.md](doc/README_for_docker.md) 30 | - [akiyamalab/megadock](https://hub.docker.com/r/akiyamalab/megadock/) (Docker Hub) 31 | 32 | 33 | ## Reference 34 | 35 | Masahito Ohue, Takehiro Shimoda, Shuji Suzuki, Yuri Matsuzaki, Takashi Ishida, Yutaka Akiyama. **MEGADOCK 4.0: an ultra-high-performance protein-protein docking software for heterogeneous supercomputers**, *Bioinformatics*, 30(22): 3281-3283, 2014. http://doi.org/10.1093/bioinformatics/btu532 36 | 37 | Masahito Ohue, Yuri Matsuzaki, Nobuyuki Uchikoga, Takashi Ishida, Yutaka Akiyama. **MEGADOCK: An all-to-all protein-protein interaction prediction system using tertiary structure data**, *Protein and Peptide Letters*, 21(8): 766-778, 2014. https://doi.org/10.2174/09298665113209990050 38 | 39 | 40 | ## Older Versions 41 | 42 | [http://www.bi.cs.titech.ac.jp/megadock/archives/](http://www.bi.cs.titech.ac.jp/megadock/archives/) 43 | 44 | 45 | ## License 46 | 47 | MEGADOCK is licensed by CC BY-NC 4.0. (See [LICENSE](./LICENSE)) 48 | This software and derivatives are NOT allowed for any commercial use without formal prior authorization. If you are considering commercial use, please contact us as there are differently charged use options licensed by [Ahead Biocomputing, Co. Ltd.](https://ahead-biocomputing.co.jp/en/), a private company as a Tokyo Tech Venture. 49 | 50 | ## Fundings 51 | 52 | This work is partially supported by JSPS Grant-in-Aid for Scientific Research (KAKENHI) (A) Grant Number 24240044. 53 | 54 | ---- 55 | Copyright © 2014-2022 Akiyama Laboratory, Tokyo Institute of Technology, All Rights Reserved. 56 | -------------------------------------------------------------------------------- /src/mpidp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : Mpidp 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #ifndef Mpidp_h 16 | #define Mpidp_h 1 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | using namespace std; 28 | 29 | // JOB management table 30 | typedef struct { 31 | string name; // Job name 32 | int exec; // EXEC 33 | int status; // calculation control flag 34 | vector worker; // WID 35 | vector rcode[3]; // 0:END 1:RET 2:FILE 36 | } NameLog; 37 | 38 | // Worker management table 39 | typedef struct { 40 | vector name; // Job name 41 | vector rcode; // 0: failure 1:success 42 | int failure; // calculation failure counter 43 | } WorkerLog; 44 | 45 | class Mpidp 46 | { 47 | private: 48 | Mpidp(Mpidp &c){} 49 | const Mpidp & operator=(const Mpidp &c); 50 | MPI_Status _Status; 51 | string _Table_file; 52 | string _Out_file; 53 | int _Out_option; 54 | int _Ntry; 55 | int _Worker_life; 56 | string _Title; 57 | string _Param; 58 | char _Name[7]; 59 | vector _Table_list; 60 | NameLog *_Namelog; 61 | WorkerLog *_Workerlog; 62 | int _Csize; 63 | int _Psize; 64 | int _Ndata; 65 | protected: 66 | virtual string erase_space(const string &s0,const int ip); 67 | virtual int argument(int argc,char *argv[],char **wargv); 68 | virtual int argument(int argc,char *argv[],string &main_argv); 69 | virtual int for_worker(int &retry,char *ctable,int argc2, 70 | char **wargv); 71 | virtual void for_worker(int &retry,char *ctable,int &ia, 72 | string &argv_joblist); 73 | virtual string replace_pattern(const string &pattern, 74 | const string &position, 75 | const string &option); 76 | public: 77 | Mpidp() { 78 | #ifdef DEBUG 79 | cout << "Constructing Mpidp.\n"; 80 | #endif 81 | } 82 | virtual ~Mpidp() { 83 | #ifdef DEBUG 84 | cout << "Destructing Mpidp.\n"; 85 | #endif 86 | } 87 | virtual void read_table(int argc,char *argv[],int &ntry, 88 | ofstream &logout); 89 | virtual int master0(const int &nproc); 90 | virtual int master(const int &nproc); 91 | virtual void worker(int &myid,char *hostname,int argc, 92 | char *argv[]); 93 | virtual void write_table(const int &nproc,ofstream &logout); 94 | }; 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /src/cpu_time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : CPUTime 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #ifndef Cpu_time_h 16 | #define Cpu_time_h 1 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | using namespace std; 23 | 24 | class CPUTime 25 | { 26 | private: 27 | friend class main; 28 | friend class Control; 29 | friend class Docking; 30 | friend class FFTProcess; 31 | CPUTime(CPUTime &c) {} 32 | const CPUTime & operator=(const CPUTime &c); 33 | 34 | public: 35 | float t1_initialize; 36 | float t2_receptor_process; 37 | float t3_docking_total; 38 | float t4_docking_output_detail; 39 | float t5_docking_output; 40 | 41 | float t3_1_ligand_voxelization; 42 | float t3_2_fftprocess_ligand_fft; 43 | float t3_3_fftprocess_convolution; 44 | float t3_4_fftprocess_fft_inverse; 45 | float t3_5_fftprocess_score_sort; 46 | float t3_6_fftprocess_sort_index; 47 | 48 | float t3_1_1_ligvoxgpu_copy_htod; 49 | float t3_1_2_ligvoxgpu_kernel_init; 50 | float t3_1_3_ligvoxgpu_kernel_fill_core; 51 | float t3_1_4_ligvoxgpu_kernel_cut_surf; 52 | float t3_1_5_ligvoxgpu_kernel_fill_surf; 53 | float t3_1_6_ligvoxgpu_kernel_elec; 54 | float t3_1_7_ligvoxgpu_kernel_set_array; 55 | 56 | float t6_data_transfer_rec; 57 | float t6_data_transfer_lig; 58 | float t6_data_transfer_in_loop; 59 | 60 | float t7_offload_transfer; 61 | float t7_offload_calc; 62 | 63 | long long m1_current_malloc_size; 64 | long long m2_maximum_malloc_size; 65 | 66 | CPUTime() { 67 | #ifdef DEBUG 68 | cout << "Constructing CPUTime.\n"; 69 | #endif 70 | } 71 | virtual ~CPUTime() { 72 | #ifdef DEBUG 73 | cout << "Destructing CPUTime\n"; 74 | #endif 75 | } 76 | virtual void initialize(); 77 | virtual void output(); 78 | virtual void record_malloc(const int &size) { 79 | m1_current_malloc_size += (long long)size; 80 | if(m1_current_malloc_size > m2_maximum_malloc_size){ 81 | m2_maximum_malloc_size = m1_current_malloc_size; 82 | } 83 | //printf(" # %11d bytes allocated, Current alloc size : %11lld [Bytes], Max alloc size : %11lld [Bytes] (%.2f GB)\n" 84 | //, size, m1_current_malloc_size, m2_maximum_malloc_size, (float)(m2_maximum_malloc_size/1024.0/1024.0/1024.0)); 85 | } 86 | virtual void record_free(const int &size) { 87 | m1_current_malloc_size -= (long long)size; 88 | if(m1_current_malloc_size < 0){ 89 | //printf(" # Allocate memory size error\n"); 90 | } 91 | //printf(" # %11d bytes freed , Current alloc size : %11lld [Bytes], Max alloc size : %11lld [Bytes] (%.2f GB)\n" 92 | //, size, m1_current_malloc_size, m2_maximum_malloc_size, (float)(m2_maximum_malloc_size/1024.0/1024.0/1024.0)); 93 | } 94 | }; 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /src/pdb_entry.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : PDBEntry 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #include "pdb_entry.h" 16 | 17 | //============================================================================// 18 | void PDBEntry::pdb_read() 19 | //============================================================================// 20 | { 21 | string pdb, atomtype; 22 | vector coordinate0[3]; 23 | 24 | #ifdef DEBUG 25 | cout << "Input file = " << _Input_file << endl; 26 | #endif 27 | 28 | ifstream Input(_Input_file.c_str(),ios::in); 29 | if( !Input ) { 30 | cerr << "[ERROR] PDB file [" << _Input_file << "] not open!!" << endl; 31 | exit(1); 32 | } 33 | 34 | while(1) { 35 | if( !getline(Input,pdb) ) break; 36 | #ifdef DEBUG2 37 | cout << pdb << endl; 38 | #endif 39 | 40 | if( pdb.substr(0,6) == "ATOM " || pdb.substr(0,6) == "HETATM" ) { 41 | if( pdb.substr(76,2) == " H" ) { 42 | printf("# This PDB file contains hydrogen atom. MEGADOCK skips hydrogen atom line.\n"); 43 | } else { 44 | coordinate0[0].push_back(atof(pdb.substr(30,8).c_str())); 45 | coordinate0[1].push_back(atof(pdb.substr(38,8).c_str())); 46 | coordinate0[2].push_back(atof(pdb.substr(46,8).c_str())); 47 | 48 | atomtype = pdb.substr(11,10); 49 | _Atom_type.push_back(erase_space(atomtype)); 50 | } 51 | } 52 | } 53 | 54 | Input.close(); 55 | 56 | _Num_atoms = coordinate0[0].size(); 57 | 58 | _Coordinate = new float[3*_Num_atoms]; 59 | if( !_Coordinate ) { 60 | cerr << "[ERROR] Out of memory. Number of atomic coordinates*3(x,y,z) = (" 61 | << 3*_Num_atoms << ") for (_Coordinate) in pdb_entry.cpp!!\n"; 62 | exit(1); 63 | } 64 | 65 | for( int i = 0 ; i < _Num_atoms ; i++ ) { 66 | float coord[3]; 67 | 68 | for( int j = 0 ; j < 3 ; j++ ) { 69 | coord[j] = coordinate0[j][i]; 70 | } 71 | coordinate(i,coord); 72 | } 73 | 74 | return; 75 | } 76 | 77 | //============================================================================// 78 | string PDBEntry::erase_space(const string &s0) 79 | //============================================================================// 80 | { 81 | int n; 82 | string s1; 83 | 84 | s1 = s0; 85 | 86 | while(1) { 87 | n = s1.find(" "); 88 | 89 | if( n == (int) std::string::npos ) { 90 | break; 91 | } else { 92 | s1.erase(n,1); 93 | } 94 | } 95 | 96 | if( s1.substr(0,1) == " " ) { 97 | s1.erase(0,1); 98 | } 99 | 100 | if( s1.substr(s1.size()-1,1) == " " ) { 101 | s1.erase(s1.size()-1,1); 102 | } 103 | 104 | return s1; 105 | } 106 | -------------------------------------------------------------------------------- /src/protein.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : Protein 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #ifndef Protein_h 16 | #define Protein_h 1 17 | 18 | #include "pdb_entry.h" 19 | #include "parameter.h" 20 | 21 | using namespace std; 22 | 23 | class Protein : public PDBEntry // Protein class 24 | { 25 | private: 26 | friend class Docking; 27 | friend class Receptor; 28 | friend class Ligand; 29 | friend class FFTProcess; 30 | // const Protein & operator=(const Protein &c); 31 | int _Num_grid; 32 | float grid_width; 33 | float _Edge[3][2]; 34 | float _Center[3]; 35 | float _Angle[3]; 36 | float *_Radius; 37 | float *_Charge; 38 | float *_ACE; 39 | int *_Atomtype; 40 | 41 | protected: 42 | virtual void axis_edge(); 43 | virtual void voxel_init(const int &num_grid,float *grid_coord, 44 | float *mol_coord,float *grid_r,float *grid_i, 45 | float *distance3,float *xd,float *yd,float *zd); 46 | public: 47 | Protein(string &rinput_file) : PDBEntry(rinput_file) { 48 | #ifdef DEBUG 49 | cout << "Constructing Protein.\n"; 50 | #endif 51 | } 52 | virtual ~Protein() { 53 | #ifdef DEBUG 54 | cout << "Destructing Protein.\n"; 55 | #endif 56 | delete [] _Radius; 57 | delete [] _Charge; 58 | delete [] _ACE; 59 | delete [] _Atomtype; 60 | } 61 | virtual void initialize(Parameter *rparameter); 62 | virtual void shift_center(float *mol_coord); 63 | virtual float edge(const int &i,int j) { 64 | return _Edge[i][j]; 65 | } 66 | virtual float center(const int &i) { 67 | return _Center[i]; 68 | } 69 | virtual void center(float *coord) { 70 | for( int i = 0 ; i < 3 ; i++ ) { 71 | _Center[i] = coord[i]; 72 | } 73 | return; 74 | } 75 | virtual float angle(const int &i) { 76 | return _Angle[i]; 77 | } 78 | virtual void angle(float *angle) { 79 | for( int i = 0 ; i < 3 ; i++ ) { 80 | _Angle[i] = angle[i]; 81 | } 82 | return; 83 | } 84 | virtual int num_grid() { 85 | return _Num_grid; 86 | } 87 | virtual void num_grid(const int &num_grid) { 88 | _Num_grid = num_grid; 89 | return; 90 | } 91 | 92 | virtual void rpscace(const float &aceratio, const int &num_grid,float *grid_coord,float *atom_coord_rotated, 93 | int *iwork,float *fwork, 94 | const float ¶m_rec_core, const float ¶m_lig_core,const int &old_voxel_flag) { 95 | ; 96 | } 97 | virtual void electro(const float &beta,const float &eratio, 98 | const int &num_grid,float *grid_coord,float *atom_coord_rotated, 99 | int *iwork,float *fwork,const int &old_voxel_flag) { 100 | ; 101 | } 102 | virtual void precalc(const int &num_grid,int *nearesta,float *rjudge2, 103 | float *radius_core2,float *radius_surf2) { 104 | ; 105 | } 106 | }; 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /src/parameter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : Parameter 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #ifndef Parameter_h 16 | #define Parameter_h 1 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "constant.h" 28 | #include "parallel.h" 29 | 30 | using namespace std; 31 | 32 | class Parameter 33 | { 34 | private: 35 | friend class Control; 36 | friend class Docking; 37 | friend class FFTProcess; 38 | friend class Protein; 39 | friend class HeaderDB; 40 | Parameter(Parameter &c) {} 41 | const Parameter & operator=(const Parameter &c); 42 | Parallel *_parallel; 43 | string _RecPDB_file; 44 | string _LigPDB_file; 45 | string _RLOut_file; 46 | string _RLOut_file_detail; 47 | string _RLOut_file_csv; 48 | string calc_id; 49 | int _IO_flag[3]; 50 | int detail_output_flag; 51 | int calc_time_log_output_flag; 52 | 53 | int _Num_grid; 54 | int _Num_fft; 55 | int _Num_fft_flag; 56 | int _Num_atom_max; 57 | int _Num_output; 58 | int _Num_output_flag; 59 | int _Num_thread_limit; 60 | int _Num_GPU_limit; 61 | 62 | int _Score_func; 63 | int _Num_sort; 64 | float _Elec_ratio; 65 | float _ACE_ratio; 66 | float grid_width; 67 | float ligand_max_edge; 68 | int _Rotation_angle_set; 69 | int fft_base_set; 70 | int lig_elec_serial_flag; 71 | int fft_library_type; 72 | 73 | int tem_flag1; 74 | int tem_flag2; 75 | int tem_flag3; 76 | int tem_flag4; 77 | int f1_flag; 78 | int f2_flag; 79 | 80 | int _Old_voxel_flag; 81 | float _Grid_space_rec; 82 | float _Grid_space_lig; 83 | //rPSC tuning 84 | float _rPSC_param_rec_core; 85 | float _rPSC_param_lig_core; 86 | 87 | float *_Zangle; 88 | int _Num_rot_angles; 89 | map _Charmmr; 90 | map _Charmmc; 91 | map _ACE; 92 | protected: 93 | virtual void usage(); 94 | virtual void default_param(); 95 | virtual void pdb_step(); 96 | virtual void parameter_set(); 97 | virtual void charmm_radius(); 98 | virtual void charmm_charge(); 99 | virtual void ace_value(); 100 | virtual void dangle_rot1(); 101 | virtual void dangle_rot3(); 102 | virtual void dangle_rot24(); 103 | virtual void dangle_rot360(); 104 | virtual void dangle_rot3600(); 105 | virtual void dangle_rot54000(); 106 | 107 | public: 108 | Parameter(Parallel *pparallel) : _parallel(pparallel) { 109 | #ifdef DEBUG 110 | cout << "Constructing Parameter.\n"; 111 | #endif 112 | } 113 | virtual ~Parameter() { 114 | #ifdef DEBUG 115 | cout << "Destructing Parameter.\n"; 116 | #endif 117 | delete [] _Zangle; 118 | } 119 | virtual void initialize(int argc,char *argv[]); 120 | virtual float atom_radius(const string &atype); 121 | virtual float atom_charge(const string &atype); 122 | virtual float atom_ace(const string &atype); 123 | }; 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /src/calcrg.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | 6 | //==================================================================// 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | struct parse_res { 14 | float r1, r2, r3, l1, l2, l3, 15 | a1, a2, a3, t1, t2, t3, 16 | rand1, rand2, rand3, spacing, score; 17 | int N; 18 | char receptor[100], ligand[100]; 19 | }; 20 | 21 | void rotateAtom(float, float, float, float *, float *, float *, 22 | float, float, float ); 23 | 24 | void createRg(char *, float, float, float, float, float, float, 25 | float, float, float, int, int, int, int, float, int, int); 26 | 27 | //-------------------------------------------------- 28 | // Function rotateAtom 29 | //-------------------------------------------------- 30 | void rotateAtom (float oldX, float oldY, float oldZ, 31 | float *newX, float *newY, float *newZ, 32 | float psi, float theta, float phi ) 33 | { 34 | float r11, r21, r31, r12, r22, r32, r13, r23, r33; 35 | r11 = cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi); 36 | r21 = sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi); 37 | r31 = sin(theta)*sin(phi); 38 | 39 | r12 = -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi); 40 | r22 = -sin(psi)*sin(phi) + cos(psi)*cos(theta)*cos(phi); 41 | r32 = sin(theta)*cos(phi); 42 | 43 | r13 = sin(psi)*sin(theta); 44 | r23 = -cos(psi)*sin(theta); 45 | r33 = cos(theta); 46 | 47 | *newX = r11 * oldX + r12 * oldY + r13 * oldZ; 48 | *newY = r21 * oldX + r22 * oldY + r23 * oldZ; 49 | *newZ = r31 * oldX + r32 * oldY + r33 * oldZ; 50 | 51 | } 52 | 53 | //-------------------------------------------------- 54 | // Function createRg 55 | //-------------------------------------------------- 56 | void createRg(float rand1, float rand2, float rand3, 57 | float r1, float r2, float r3, float l1, float l2, float l3, 58 | float a1, float a2, float a3, int t1, int t2, int t3, 59 | int N, float spacing, int isPDB, int nl) 60 | { 61 | float tx1, ty1, tz1, tx2, ty2, tz2, oldx, oldy, oldz; 62 | oldx = 0.0; oldy = 0.0; oldz = 0.0; 63 | rotateAtom(oldx, oldy, oldz, &tx1, &ty1, &tz1, rand1, rand2, rand3); 64 | rotateAtom(tx1, ty1, tz1, &tx2, &ty2, &tz2, a1, a2, a3); 65 | if (t1 >= N/2) t1 -= N; 66 | if (t2 >= N/2) t2 -= N; 67 | if (t3 >= N/2) t3 -= N; 68 | 69 | if ( isPDB == 0 ) 70 | printf ("%7.3f, %7.3f, %7.3f\n", tx2-t1*spacing+r1, ty2-t2*spacing+r2, tz2-t3*spacing+r3); 71 | else if ( isPDB == 1 ) 72 | printf ("HETATM %4d S RGS P%4d %8.3f%8.3f%8.3f 1.00 1.00 S\n", nl, nl, 73 | tx2-t1*spacing+r1, ty2-t2*spacing+r2, tz2-t3*spacing+r3); 74 | 75 | } 76 | 77 | //-------------------------------------------------- 78 | int main(int argc, char **argv ) 79 | { 80 | 81 | char outfile[256]; 82 | int isPDBflag; 83 | if (argc != 3){ 84 | printf("++ center points of ligand ++\n"); 85 | printf("\n%s [.outfile] [isPDB? 0: csv, 1: pseudo PDB]\n", argv[0]); 86 | exit(-1); 87 | } 88 | 89 | strcpy(outfile, argv[1]); 90 | isPDBflag = atoi(argv[2]); 91 | 92 | struct parse_res ret; 93 | FILE *fp; 94 | fp = fopen(outfile, "r"); 95 | fscanf(fp, "%d %f", &ret.N, &ret.spacing); /* parse 4 lines of .out */ 96 | fscanf(fp, "%f %f %f", &ret.rand1, &ret.rand2, &ret.rand3); 97 | fscanf(fp, "%s %f %f %f", ret.receptor, &ret.r1, &ret.r2, &ret.r3); 98 | fscanf(fp, "%s %f %f %f", ret.ligand, &ret.l1, &ret.l2, &ret.l3); 99 | 100 | int i = 1; 101 | while((fscanf(fp, "%f %f %f %f %f %f %f", &ret.a1, &ret.a2, &ret.a3, &ret.t1, &ret.t2, &ret.t3, &ret.score)) != EOF){ 102 | createRg(ret.rand1, ret.rand2, ret.rand3, ret.r1, ret.r2, ret.r3, ret.l1, ret.l2, ret.l3, 103 | ret.a1, ret.a2, ret.a3, ret.t1, ret.t2, ret.t3, ret.N, ret.spacing, isPDBflag, i); 104 | i++; 105 | if(i == 10000) 106 | i = 0; 107 | } 108 | fclose(fp); 109 | return 0; 110 | } 111 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : (main) 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #include 16 | #include "cpu_time.h" 17 | #include "control.h" 18 | 19 | #ifdef CUFFT 20 | #include 21 | #define VERSION "4.1.3 for GPU & " 22 | #else 23 | #define VERSION "4.1.3 for CPU & " 24 | #endif 25 | 26 | #ifdef MPI_DP 27 | #define VTEXT "multiple nodes" 28 | #else 29 | #define VTEXT "single node" 30 | #endif 31 | 32 | #define LASTUPDATED "26 March, 2019" 33 | 34 | //============================================================================// 35 | #ifdef MPI_DP 36 | int application(int argc,char *argv[]) 37 | #else 38 | int main(int argc, char *argv[]) 39 | #endif 40 | //============================================================================// 41 | { 42 | Parallel *_parallel; 43 | CPUTime *_cputime; 44 | Control *_control; 45 | 46 | struct timeval et1, et2; 47 | struct timeval et3, et4; 48 | int nproc2 = 0; 49 | int device_count_gpu = 0; 50 | 51 | gettimeofday(&et1,NULL); 52 | gettimeofday(&et3,NULL); 53 | 54 | 55 | cout << " MEGADOCK ver. "<< VERSION << VTEXT << endl; 56 | cout << " megadock@bi.c.titech.ac.jp lastupdated: " << LASTUPDATED << endl; 57 | cout << endl; 58 | 59 | _cputime = new CPUTime(); 60 | _cputime->initialize(); 61 | 62 | #ifdef _OPENMP 63 | #pragma omp parallel 64 | { 65 | nproc2 = omp_get_num_threads(); 66 | if(omp_get_thread_num() == 0) { 67 | cout << "# Using OpenMP parallelization: " << nproc2 << " threads." << endl; 68 | } 69 | } 70 | //printf("#OpenMP version %d\n", _OPENMP); 71 | #else 72 | nproc2 = 1; 73 | #endif //#ifdef _OPENMP 74 | 75 | #ifdef CUFFT 76 | int nogpu_flag = 0; 77 | for (int num = 0; num < (argc-1); ++num) { 78 | if(!strcmp(argv[num], "-G")) { 79 | if(argv[num+1] != NULL) { 80 | if(atoi(argv[num+1]) == 0) { 81 | nogpu_flag = 1; 82 | } 83 | } 84 | } 85 | } 86 | 87 | if(nogpu_flag != 1) { 88 | checkCudaErrors( cudaGetDeviceCount(&device_count_gpu) ); 89 | if (device_count_gpu == 0) { 90 | fprintf(stderr, "GPU Error: no devices supporting CUDA.\n"); 91 | exit(-1); 92 | } 93 | 94 | cudaDeviceProp deviceProp; 95 | checkCudaErrors( cudaGetDeviceProperties(&deviceProp, 0)); 96 | if (deviceProp.major < 1) { 97 | fprintf(stderr, "GPU Error: device does not support CUDA.\n"); 98 | exit(-1); 99 | } 100 | 101 | cudaSetDeviceFlags(cudaDeviceMapHost); 102 | fprintf(stdout, "# Using CUDA device %d: %s\n", 0, deviceProp.name); 103 | cudaSetDevice(0); 104 | //fprintf(stdout, "# Init CUDA device OK.\n"); 105 | 106 | int cufft_version; 107 | cufftGetVersion(&cufft_version); 108 | printf("# CUFFT version : %d\n", cufft_version); 109 | } 110 | #endif 111 | 112 | _parallel = new Parallel(nproc2); 113 | _parallel->num_gpu(device_count_gpu); 114 | 115 | #ifdef CUFFT 116 | printf("# Number of available [threads / GPUs] : [%d / %d]\n",nproc2,device_count_gpu); 117 | #endif 118 | 119 | gettimeofday(&et4,NULL); 120 | _cputime->t1_initialize += (et4.tv_sec-et3.tv_sec + (float)((et4.tv_usec-et3.tv_usec)*1e-6)); 121 | 122 | _control = new Control(_cputime,_parallel); 123 | _control->initialize(argc,argv); 124 | _control->execute(); 125 | 126 | delete _control; 127 | delete _parallel; 128 | 129 | _cputime->output(); 130 | 131 | delete _cputime; 132 | 133 | gettimeofday(&et2,NULL); 134 | 135 | const float elapsed_time = (et2.tv_sec-et1.tv_sec + (float)((et2.tv_usec-et1.tv_usec)*1e-6)); 136 | printf("\n"); 137 | printf("Elapsed time = %8.2f sec.\n",elapsed_time); 138 | 139 | return 0; 140 | } 141 | -------------------------------------------------------------------------------- /src/main.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : (main) 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #include 16 | #include "cpu_time.h" 17 | #include "control.h" 18 | 19 | #ifdef CUFFT 20 | #include 21 | #define VERSION "4.1.3 for GPU & " 22 | #else 23 | #define VERSION "4.1.3 for CPU & " 24 | #endif 25 | 26 | #ifdef MPI_DP 27 | #define VTEXT "multiple nodes" 28 | #else 29 | #define VTEXT "single node" 30 | #endif 31 | 32 | #define LASTUPDATED "26 March, 2019" 33 | 34 | //============================================================================// 35 | #ifdef MPI_DP 36 | int application(int argc,char *argv[]) 37 | #else 38 | int main(int argc, char *argv[]) 39 | #endif 40 | //============================================================================// 41 | { 42 | Parallel *_parallel; 43 | CPUTime *_cputime; 44 | Control *_control; 45 | 46 | struct timeval et1, et2; 47 | struct timeval et3, et4; 48 | int nproc2 = 0; 49 | int device_count_gpu = 0; 50 | 51 | gettimeofday(&et1,NULL); 52 | gettimeofday(&et3,NULL); 53 | 54 | 55 | cout << " MEGADOCK ver. "<< VERSION << VTEXT << endl; 56 | cout << " megadock@bi.c.titech.ac.jp lastupdated: " << LASTUPDATED << endl; 57 | cout << endl; 58 | 59 | _cputime = new CPUTime(); 60 | _cputime->initialize(); 61 | 62 | #ifdef _OPENMP 63 | #pragma omp parallel 64 | { 65 | nproc2 = omp_get_num_threads(); 66 | if(omp_get_thread_num() == 0) { 67 | cout << "# Using OpenMP parallelization: " << nproc2 << " threads." << endl; 68 | } 69 | } 70 | //printf("#OpenMP version %d\n", _OPENMP); 71 | #else 72 | nproc2 = 1; 73 | #endif //#ifdef _OPENMP 74 | 75 | #ifdef CUFFT 76 | int nogpu_flag = 0; 77 | for (int num = 0; num < (argc-1); ++num) { 78 | if(!strcmp(argv[num], "-G")) { 79 | if(argv[num+1] != NULL) { 80 | if(atoi(argv[num+1]) == 0) { 81 | nogpu_flag = 1; 82 | } 83 | } 84 | } 85 | } 86 | 87 | if(nogpu_flag != 1) { 88 | checkCudaErrors( cudaGetDeviceCount(&device_count_gpu) ); 89 | if (device_count_gpu == 0) { 90 | fprintf(stderr, "GPU Error: no devices supporting CUDA.\n"); 91 | exit(-1); 92 | } 93 | 94 | cudaDeviceProp deviceProp; 95 | checkCudaErrors( cudaGetDeviceProperties(&deviceProp, 0)); 96 | if (deviceProp.major < 1) { 97 | fprintf(stderr, "GPU Error: device does not support CUDA.\n"); 98 | exit(-1); 99 | } 100 | 101 | cudaSetDeviceFlags(cudaDeviceMapHost); 102 | fprintf(stdout, "# Using CUDA device %d: %s\n", 0, deviceProp.name); 103 | cudaSetDevice(0); 104 | //fprintf(stdout, "# Init CUDA device OK.\n"); 105 | 106 | int cufft_version; 107 | cufftGetVersion(&cufft_version); 108 | printf("# CUFFT version : %d\n", cufft_version); 109 | } 110 | #endif 111 | 112 | _parallel = new Parallel(nproc2); 113 | _parallel->num_gpu(device_count_gpu); 114 | 115 | #ifdef CUFFT 116 | printf("# Number of available [threads / GPUs] : [%d / %d]\n",nproc2,device_count_gpu); 117 | #endif 118 | 119 | gettimeofday(&et4,NULL); 120 | _cputime->t1_initialize += (et4.tv_sec-et3.tv_sec + (float)((et4.tv_usec-et3.tv_usec)*1e-6)); 121 | 122 | _control = new Control(_cputime,_parallel); 123 | _control->initialize(argc,argv); 124 | _control->execute(); 125 | 126 | delete _control; 127 | delete _parallel; 128 | 129 | _cputime->output(); 130 | 131 | delete _cputime; 132 | 133 | gettimeofday(&et2,NULL); 134 | 135 | const float elapsed_time = (et2.tv_sec-et1.tv_sec + (float)((et2.tv_usec-et1.tv_usec)*1e-6)); 136 | printf("\n"); 137 | printf("Elapsed time = %8.2f sec.\n",elapsed_time); 138 | 139 | return 0; 140 | } 141 | -------------------------------------------------------------------------------- /src/protein.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : Protein 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #include "protein.h" 16 | #include "string.h" 17 | 18 | //============================================================================// 19 | void Protein::initialize(Parameter *rparameter) 20 | //============================================================================// 21 | { 22 | pdb_read(); 23 | axis_edge(); 24 | const int na = num_atoms(); 25 | grid_width = rparameter->grid_width; 26 | 27 | 28 | // for radius 29 | _Radius = new float[na]; 30 | 31 | for( int i = 0 ; i < na ; i++ ) { 32 | _Radius[i] = rparameter->atom_radius(atom_type(i)); 33 | } 34 | 35 | // for charge 36 | if( rparameter->_Score_func == 2 || rparameter -> _Score_func == 3 ) { 37 | _Charge = new float[na]; 38 | for( int i = 0 ; i < na ; i++ ) { 39 | _Charge[i] = rparameter->atom_charge(atom_type(i)); 40 | } 41 | } 42 | 43 | // for ACE 44 | if ( rparameter -> _Score_func == 3 ) { 45 | _ACE = new float[na]; 46 | for ( int i = 0; i < na; i++) { 47 | _ACE[i] = rparameter->atom_ace(atom_type(i)); 48 | } 49 | } 50 | 51 | _Atomtype = new int[na]; 52 | for( int i = 0 ; i < na ; i++ ) { // 1:CA, 2:C,N, 0:others 53 | if(!strcmp(atom_type(i).substr(0,3).c_str(),"CA ")){ 54 | _Atomtype[i] = 1; 55 | }else if( (!strcmp(atom_type(i).substr(0,2).c_str(),"C ")) || (!strcmp(atom_type(i).substr(0,2).c_str(),"N ")) ){ 56 | _Atomtype[i] = 2; 57 | }else{ 58 | _Atomtype[i] = 0; 59 | } 60 | //printf(" %5d, %10s, %2d\n",i,atom_type(i).c_str(),_Atomtype[i]); 61 | } 62 | 63 | return; 64 | } 65 | 66 | //============================================================================// 67 | void Protein::axis_edge() 68 | //============================================================================// 69 | { 70 | float coord[3]; 71 | 72 | for( int i = 0 ; i < 3 ; i++ ) { 73 | _Edge[i][0] = BIG; 74 | _Edge[i][1] = -BIG; 75 | } 76 | 77 | for( int i = 0 ; i < num_atoms() ; i++ ) { 78 | for( int j = 0 ; j < 3 ; j++ ) { 79 | coord[j] = coordinate(i,j); 80 | } 81 | #ifdef DEBUG2 82 | cout << "i = " << i << " X = " << coord[0] << " Y = " << coord[1] 83 | << " Z = " << coord[2] << endl; 84 | #endif 85 | for( int j = 0 ; j < 3 ; j++ ) { 86 | if( coord[j] < _Edge[j][0] ) { 87 | _Edge[j][0] = coord[j]; 88 | } 89 | if( coord[j] > _Edge[j][1] ) { 90 | _Edge[j][1] = coord[j]; 91 | } 92 | } 93 | } 94 | 95 | for( int i = 0 ; i < 3 ; i++ ) { 96 | _Center[i] = (_Edge[i][0] + _Edge[i][1]) / 2.0; 97 | } 98 | 99 | for( int i = 0 ; i < 3 ; i++ ) { 100 | _Angle[i] = 0.0; 101 | } 102 | 103 | #ifdef DEBUG2 104 | for( int i = 0 ; i < 3 ; i++ ) { 105 | cout << "_Edge[" << i << "][0] = " << _Edge[i][0] << endl; 106 | cout << "_Edge[" << i << "][1] = " << _Edge[i][1] << endl; 107 | } 108 | #endif 109 | 110 | return; 111 | } 112 | 113 | //============================================================================// 114 | void Protein::shift_center(float *mol_coord) 115 | //============================================================================// 116 | { 117 | float coord[3]; 118 | const int na = num_atoms(); 119 | 120 | for( int i = 0 ; i < 3 ; i++ ) { 121 | coord[i] = ( _Edge[i][0] + _Edge[i][1] ) / 2.0; 122 | } 123 | 124 | for( int i = 0 ; i < na ; i++ ) { 125 | for( int j = 0 ; j < 3 ; j++ ) { 126 | mol_coord[i*3+j] = coordinate(i,j) - coord[j]; 127 | } 128 | } 129 | 130 | return; 131 | } 132 | 133 | //============================================================================// 134 | void Protein::voxel_init(const int &num_grid,float *grid_coord,float *mol_coord, 135 | float *grid_r,float *grid_i,float *distance3,float *xd, 136 | float *yd,float *zd) 137 | //============================================================================// 138 | { 139 | const int na = num_atoms(); 140 | const int nag = num_atoms() * num_grid; 141 | const int ng3 = num_grid * num_grid * num_grid; 142 | 143 | memset(grid_r, 0.0, sizeof(float)*ng3); 144 | memset(grid_i, 0.0, sizeof(float)*ng3); 145 | memset(distance3, BIG, sizeof(float)*ng3); 146 | 147 | 148 | for( int l = 0, k = 0 ; l < na ; l++ ) { 149 | const int l3 = l * 3; 150 | 151 | for( int i = 0 ; i < num_grid ; i++ ) { 152 | xd[k ] = mol_coord[l3 ] - grid_coord[i]; 153 | yd[k ] = mol_coord[l3+1] - grid_coord[i]; 154 | zd[k++] = mol_coord[l3+2] - grid_coord[i]; 155 | } 156 | } 157 | 158 | for( int i = 0 ; i < nag ; i++ ) { 159 | xd[i] *= xd[i]; 160 | yd[i] *= yd[i]; 161 | zd[i] *= zd[i]; 162 | } 163 | 164 | return; 165 | } 166 | -------------------------------------------------------------------------------- /src/decoygen.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | 6 | //==================================================================// 7 | // 8 | // Software Name : MEGADOCK (decoygen tool) 9 | // 10 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 11 | // 12 | // Last update: December 2, 2014 13 | // 14 | //==================================================================// 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | struct parse_res { 22 | float r1, r2, r3, l1, l2, l3, 23 | a1, a2, a3, t1, t2, t3, 24 | rand1, rand2, rand3, spacing, score; 25 | int N; 26 | char receptor[300], ligand[300]; 27 | }; 28 | 29 | void rotateAtom(float, float, float, float *, float *, float *, 30 | float, float, float ); 31 | void createPDB(char *, char *, float, float, float, float, float, 32 | float, float, float, float, float, float, float, 33 | int, int, int, int, float); 34 | struct parse_res parse_out(char *, int); 35 | 36 | //-------------------------------------------------- 37 | // Function rotateAtom 38 | //-------------------------------------------------- 39 | void rotateAtom (float oldX, float oldY, float oldZ, 40 | float *newX, float *newY, float *newZ, 41 | float psi, float theta, float phi ) 42 | { 43 | float r11, r21, r31, r12, r22, r32, r13, r23, r33; 44 | r11 = cos(psi)*cos(phi) - sin(psi)*cos(theta)*sin(phi); 45 | r21 = sin(psi)*cos(phi) + cos(psi)*cos(theta)*sin(phi); 46 | r31 = sin(theta)*sin(phi); 47 | 48 | r12 = -cos(psi)*sin(phi) - sin(psi)*cos(theta)*cos(phi); 49 | r22 = -sin(psi)*sin(phi) + cos(psi)*cos(theta)*cos(phi); 50 | r32 = sin(theta)*cos(phi); 51 | 52 | r13 = sin(psi)*sin(theta); 53 | r23 = -cos(psi)*sin(theta); 54 | r33 = cos(theta); 55 | 56 | *newX = r11 * oldX + r12 * oldY + r13 * oldZ; 57 | *newY = r21 * oldX + r22 * oldY + r23 * oldZ; 58 | *newZ = r31 * oldX + r32 * oldY + r33 * oldZ; 59 | 60 | } 61 | 62 | //-------------------------------------------------- 63 | // Function createPDB 64 | //-------------------------------------------------- 65 | void createPDB(char *out, char *in, float rand1, float rand2, float rand3, 66 | float r1, float r2, float r3, float l1, float l2, float l3, 67 | float a1, float a2, float a3, int t1, int t2, int t3, int N, 68 | float spacing) 69 | { 70 | FILE *newfp, *oldfp; 71 | char liner[85], coord1[10], coord2[10], coord3[10], lastline[100], tmp[85]; 72 | float tx1, ty1, tz1, tx2, ty2, tz2, oldx, oldy, oldz; 73 | 74 | newfp = fopen(out, "w"); 75 | oldfp = fopen(in, "r"); 76 | while ((fgets(liner, 31, oldfp)) != NULL){ 77 | strcpy(tmp, liner); 78 | if(!(strncmp(tmp, "ATOM ", 6)) || !(strncmp(tmp, "HETATM", 6))){ 79 | fgets(coord1, 9, oldfp); 80 | oldx = atof(coord1) - l1; 81 | fgets(coord2, 9, oldfp); 82 | oldy = atof(coord2) - l2; 83 | fgets(coord3, 9, oldfp); 84 | oldz = atof(coord3) - l3; 85 | fgets(lastline, 60, oldfp); 86 | rotateAtom(oldx, oldy, oldz, &tx1, &ty1, &tz1, rand1, rand2, rand3); 87 | rotateAtom(tx1, ty1, tz1, &tx2, &ty2, &tz2, a1, a2, a3); 88 | // adjust so coordinates are in the box 89 | if (t1 >= N/2) t1 -= N; 90 | if (t2 >= N/2) t2 -= N; 91 | if (t3 >= N/2) t3 -= N; 92 | 93 | /* write to the file using grid-adjusted coords */ 94 | fprintf (newfp, "%s%8.3f%8.3f%8.3f%s", liner, tx2-t1*spacing+r1, 95 | ty2-t2*spacing+r2, tz2-t3*spacing+r3, lastline); 96 | }else if(!(strncmp(tmp, "TER ", 6)) || !(strncmp(tmp, "ENDMDL", 6)) || !(strncmp(tmp, "END ", 6))) { 97 | fgets(lastline, 60, oldfp); 98 | fprintf(newfp, "%s%s", liner, lastline); 99 | } 100 | } 101 | fclose(oldfp); 102 | fclose(newfp); 103 | } 104 | 105 | //-------------------------------------------------- 106 | // Function parse_out 107 | //-------------------------------------------------- 108 | struct parse_res parse_out(char *out_name, int line_num){ 109 | struct parse_res ret; 110 | FILE *fp; 111 | fp = fopen(out_name, "r"); 112 | fscanf(fp, "%d %f", &ret.N, &ret.spacing); /* parse 4 lines of .out */ 113 | fscanf(fp, "%f %f %f", &ret.rand1, &ret.rand2, &ret.rand3); 114 | fscanf(fp, "%s %f %f %f", ret.receptor, &ret.r1, &ret.r2, &ret.r3); 115 | fscanf(fp, "%s %f %f %f", ret.ligand, &ret.l1, &ret.l2, &ret.l3); 116 | int i; 117 | for (i = 0; i < line_num; i++){ 118 | fscanf(fp, "%f %f %f %f %f %f %f", &ret.a1, &ret.a2, &ret.a3, &ret.t1, &ret.t2, &ret.t3, &ret.score); 119 | } 120 | fclose(fp); 121 | return ret; 122 | } 123 | 124 | 125 | //-------------------------------------------------- 126 | int main(int argc, char **argv ) 127 | { 128 | 129 | char new_lig[256], old_lig[256], outfile[256]; 130 | int line_num; 131 | if (argc != 5){ 132 | printf("++ decoygen tool ++\n"); 133 | printf("\n%s [decoy_filename] [used_ligand.pdb] [.outfile] [decoy no.]", argv[0]); 134 | printf("\n **Note: files must be in PDB format.\n"); 135 | exit(-1); 136 | } 137 | 138 | strcpy(new_lig, argv[1]); 139 | strcpy(old_lig, argv[2]); 140 | strcpy(outfile, argv[3]); 141 | line_num = atof(argv[4]); 142 | struct parse_res ret = parse_out(outfile, line_num); 143 | createPDB(new_lig, old_lig, ret.rand1, ret.rand2, ret.rand3, 144 | ret.r1, ret.r2, ret.r3, ret.l1, ret.l2, ret.l3, 145 | ret.a1, ret.a2, ret.a3, ret.t1, ret.t2, ret.t3, ret.N, ret.spacing); 146 | 147 | return 0; 148 | 149 | } 150 | -------------------------------------------------------------------------------- /src/fft_process.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : FFTProcess 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #ifndef FFTProcess_h 16 | #define FFTProcess_h 1 17 | 18 | #include 19 | #include 20 | 21 | #include "cpu_time.h" 22 | #include "parallel.h" 23 | #include "parameter.h" 24 | #include "protein.h" 25 | #include "ligand.h" 26 | #include "receptor.h" 27 | 28 | #ifdef CUFFT 29 | #include "helper_cuda.h" 30 | #include "cufft.h" 31 | //#include 32 | //#include 33 | 34 | #endif 35 | 36 | #include "fftw3.h" 37 | 38 | using namespace std; 39 | 40 | typedef struct { 41 | float score; 42 | int index[4]; 43 | } SortScore; 44 | 45 | class FFTProcess 46 | { 47 | private: 48 | FFTProcess(FFTProcess &c) {} 49 | const FFTProcess & operator=(const FFTProcess &c); 50 | #ifdef CUFFT 51 | //host side 52 | cufftHandle *cufft_plan; 53 | cufftResult *cufft_result; 54 | cufftComplex *CUFFTin_host; 55 | cufftComplex *CUFFTout_host; 56 | float **top_score_host; 57 | int **top_index_host; 58 | 59 | //device side 60 | cufftComplex **CUFFTin_gpu; 61 | cufftComplex **CUFFTout_gpu; 62 | float **_FFT_rec_r_gpu; 63 | float **_FFT_rec_i_gpu; 64 | float **top_score_gpu; 65 | int **top_index_gpu; 66 | 67 | float **radius_core2_gpu; 68 | float **radius_surf2_gpu; 69 | float **_Charge_gpu; 70 | float **xd_gpu; 71 | float **yd_gpu; 72 | float **zd_gpu; 73 | float **grid_coord_gpu; 74 | float **atom_coord_rotated_gpu; 75 | float **grid_r_gpu; 76 | float **grid_i_gpu; 77 | float **atom_coord_orig_gpu; 78 | float **mole_center_coord_gpu; 79 | float **ligand_rotation_angle_gpu; 80 | 81 | 82 | #endif /* CUFFT */ 83 | 84 | fftwf_plan *plan_fftw_forward; 85 | fftwf_plan *plan_fftw_inverse; 86 | 87 | fftwf_complex *_FFTWin; 88 | fftwf_complex *_FFTWout; 89 | 90 | CPUTime *_cputime; 91 | Parallel *_parallel; 92 | Parameter *_parameter; 93 | Ligand *_ligand; 94 | Receptor *_receptor; 95 | vector _Top; 96 | vector< vector > _Select; 97 | int _Num_fft; 98 | float *_FFT_rec_r; 99 | float *_FFT_rec_i; 100 | int *_Current_rot_angle_num; 101 | protected: 102 | virtual void alloc_fft(); 103 | public: 104 | virtual void fft3d(const float &theta, size_t myid2); 105 | FFTProcess(CPUTime *pcputime,Parallel *pparallel,Parameter *pparameter, Receptor *preceptor, Ligand *pligand) 106 | : _cputime(pcputime),_parallel(pparallel),_parameter(pparameter),_receptor(preceptor),_ligand(pligand) { 107 | 108 | #ifdef DEBUG 109 | cout << "Constructing FFTProcess.\n"; 110 | #endif 111 | //cout << "FFTP const "<< _parameter->_Num_sort < > tmp1; 164 | vector tmp2; 165 | _Select.swap(tmp1); 166 | _Top.swap(tmp2); 167 | } 168 | virtual void alloc_array(const int &num_fft); 169 | virtual void receptor_fft(float *grid_r,float *grid_i); 170 | #ifdef CUFFT 171 | virtual void cuda_fft(float *grid_r,float *grid_i,float *grid_coord,float *atom_coord_rotated,float *theta, size_t myid2); 172 | virtual void ligand_voxelization_on_gpu(float *theta, size_t myid2); 173 | virtual void ligand_data_transfer_gpu(float *grid_coord); 174 | #endif 175 | virtual void ligand_preparation(float *grid_r,float *grid_i, size_t myid2); 176 | virtual void convolution(size_t myid2); 177 | virtual void score_sort(size_t myid2); 178 | virtual void fft_memory_free(); 179 | virtual void top_score_clean(); 180 | virtual int num_fft() { 181 | return _Num_fft; 182 | } 183 | virtual void num_fft(const int &i) { 184 | _Num_fft = i; 185 | } 186 | virtual void rotation_index(int i,const int &j) { 187 | _Current_rot_angle_num[i] = j; 188 | } 189 | virtual float top_score(const int &j) { 190 | return _Top[j].score; 191 | } 192 | virtual int top_index(const int &j,int k) { 193 | return _Top[j].index[k]; 194 | } 195 | virtual void sort_index(float *fwork,int *iwork); 196 | }; 197 | 198 | #endif 199 | -------------------------------------------------------------------------------- /doc/BUILD.md: -------------------------------------------------------------------------------- 1 | # Installation Guide 2 | 3 | 4 | ## Target Environments 5 | 6 | | Type | Target Env. | Approach | 7 | |:----:|-----------------|--------------------| 8 | | (a) | GPU cluster | GPU + OpenMP + MPI | 9 | | (b) | CPU cluster | OpenMP + MPI | 10 | | (c) | GPU node | GPU + OpenMP | 11 | | (d) | CPU node | OpenMP | 12 | 13 | 14 | ## Requirement 15 | 16 | | Library | GPU cluster | CPU cluster | GPU node | CPU node | Note | 17 | |:----------------------------------------------------------------|:-----------:|:-----------:|:---:|:---:|:------| 18 | | [FFTW3](http://www.fftw.org) | yes | yes | yes | yes | `--enable-float` required ([FAQ](http://www.bi.cs.titech.ac.jp/megadock/faq.html))| 19 | | MPI (e.g. [OpenMPI](http://www.open-mpi.org)) | yes | yes | | | | 20 | | [CUDA Toolkit](https://developer.nvidia.com/cuda-zone) | yes | | yes | | `ver >= 5.0` required | 21 | | [CUDA SDK code samples](https://developer.nvidia.com/cuda-zone) | yes | | yes | | same version as toolkit | 22 | 23 | For more detailed build information, please reffer to the [FAQ](http://www.bi.cs.titech.ac.jp/megadock/faq.html) page. 24 | 25 | 26 | ## Section Link 27 | 28 | Please select appropriate section for your environment: 29 | 30 | - [(a) Compile for GPU cluster (GPU & MPI)](#a-compile-for-gpu-cluster-gpu--mpi) 31 | - [(b) Compile for MPI cluster (MPI)](#b-compile-for-mpi-cluster-mpi) 32 | - [(c) Compile for GPU node (GPU)](#c-compile-for-gpu-node-gpu) 33 | - [(d) Compile for CPU node (only thread parallelization)](#d-compile-for-cpu-node-only-thread-parallelization) 34 | - [Note for compilation](#note-for-compilation) 35 | ---- 36 | 37 | # (a) Compile for GPU cluster (GPU & MPI) 38 | 39 | ## 1. Get source code and change directory 40 | 41 | ```sh 42 | # from GitHub (clone) 43 | git clone https://github.com/akiyamalab/MEGADOCK.git 44 | cd MEGADOCK 45 | 46 | # from GitHub (zip) 47 | wget https://github.com/akiyamalab/MEGADOCK/archive/master.zip 48 | unzip master.zip 49 | cd MEGADOCK-master 50 | ``` 51 | 52 | ## 2. Edit Makefile (PATH, options) 53 | 54 | ```Makefile 55 | CUDA_INSTALL_PATH ?= your/cuda/toolkit/install/path # default: /usr/local/cuda 56 | CUDA_SAMPLES_PATH ?= your/cuda/sdk/install/path # default: /usr/local/cuda/samples 57 | FFTW_INSTALL_PATH ?= your/fftw/library/install/path # default: /usr/local 58 | CPPCOMPILER ?= g++ # default: g++ (or icpc, others) 59 | MPICOMPILER ?= mpicxx # default: mpicxx (or others) 60 | OPTIMIZATION ?= -O3 # 61 | OMPFLAG ?= -fopenmp # default: -fopenmp (g++), or -openmp, -qopenmp (intel) 62 | ``` 63 | 64 | ```Makefile 65 | USE_GPU := 1 66 | USE_MPI := 1 67 | ``` 68 | 69 | ## 3. generate binary 70 | 71 | After completion of `make` command, a binary file `megadock-gpu-dp` will be generated. 72 | 73 | ```sh 74 | # build a binary 75 | make 76 | 77 | # see help 78 | megadock-gpu-dp -h 79 | ``` 80 | 81 | ---- 82 | 83 | # (b) Compile for MPI cluster (MPI) 84 | 85 | 86 | ## 1. Get source code and change directory 87 | 88 | ```sh 89 | # from GitHub (clone) 90 | git clone https://github.com/akiyamalab/MEGADOCK.git 91 | cd MEGADOCK 92 | 93 | # from GitHub (zip) 94 | wget https://github.com/akiyamalab/MEGADOCK/archive/master.zip 95 | unzip master.zip 96 | cd MEGADOCK-master 97 | ``` 98 | 99 | ## 2. Edit Makefile (PATH, options) 100 | 101 | ```Makefile 102 | FFTW_INSTALL_PATH ?= your/fftw/library/install/path # default: /usr/local 103 | CPPCOMPILER ?= g++ # default: g++ (or icpc, others) 104 | MPICOMPILER ?= mpicxx # default: mpicxx (or others) 105 | OPTIMIZATION ?= -O3 # 106 | OMPFLAG ?= -fopenmp # default: -fopenmp (g++), or -openmp, -qopenmp (intel) 107 | ``` 108 | 109 | ```Makefile 110 | USE_GPU := 0 111 | USE_MPI := 1 112 | ``` 113 | 114 | ## 3. generate binary 115 | 116 | After completion of `make` command, a binary file `megadock-dp` will be generated. 117 | 118 | ```sh 119 | # build a binary 120 | make 121 | 122 | # see help 123 | megadock-dp -h 124 | ``` 125 | 126 | ---- 127 | 128 | # (c) Compile for GPU node (GPU) 129 | 130 | ## 1. Get source code and change directory 131 | ```sh 132 | # from GitHub (clone) 133 | git clone https://github.com/akiyamalab/MEGADOCK.git 134 | cd MEGADOCK 135 | 136 | # from GitHub (zip) 137 | wget https://github.com/akiyamalab/MEGADOCK/archive/master.zip 138 | unzip master.zip 139 | cd MEGADOCK-master 140 | ``` 141 | 142 | ## 2. Edit Makefile (PATH, options) 143 | 144 | ```Makefile 145 | CUDA_INSTALL_PATH ?= your/cuda/toolkit/install/path # default: /usr/local/cuda 146 | CUDA_SAMPLES_PATH ?= your/cuda/sdk/install/path # default: /usr/local/cuda/samples 147 | FFTW_INSTALL_PATH ?= your/fftw/library/install/path # default: /usr/local 148 | CPPCOMPILER ?= g++ # default: g++ (or icpc, others) 149 | OPTIMIZATION ?= -O3 # 150 | OMPFLAG ?= -fopenmp # default: -fopenmp (g++), or -openmp, -qopenmp (intel) 151 | ``` 152 | 153 | ```Makefile 154 | USE_GPU := 1 155 | USE_MPI := 0 156 | ``` 157 | 158 | ## 3. generate binary 159 | 160 | After completion of `make` command, a binary file `megadock-gpu` will be generated. 161 | 162 | ```sh 163 | # build a binary 164 | make 165 | 166 | # see help 167 | megadock-gpu -h 168 | ``` 169 | 170 | -------------------------------------------------------- 171 | 172 | # (d) Compile for CPU node (only thread parallelization) 173 | 174 | ## 1. Get source code and change directory 175 | ```sh 176 | # from GitHub (clone) 177 | git clone https://github.com/akiyamalab/MEGADOCK.git 178 | cd MEGADOCK 179 | 180 | # from GitHub (zip) 181 | wget https://github.com/akiyamalab/MEGADOCK/archive/master.zip 182 | unzip master.zip 183 | cd MEGADOCK-master 184 | ``` 185 | 186 | ## 2. Edit Makefile (PATH, options) 187 | 188 | ```Makefile 189 | FFTW_INSTALL_PATH ?= your/fftw/library/install/path # default: /usr/local 190 | CPPCOMPILER ?= g++ # default: g++ (or icpc, others) 191 | OPTIMIZATION ?= -O3 # 192 | OMPFLAG ?= -fopenmp # default: -fopenmp (g++), or -openmp, -qopenmp (intel) 193 | ``` 194 | 195 | ``` 196 | USE_GPU := 0 197 | USE_MPI := 0 198 | ``` 199 | 200 | ## 3. generate binary 201 | 202 | After completion of `make` command, a binary file `megadock` will be generated. 203 | 204 | ```sh 205 | # build a binary 206 | make 207 | 208 | # see help 209 | megadock -h 210 | ``` 211 | 212 | ---- 213 | 214 | ## Clean up 215 | 216 | ```sh 217 | # remove generated files 218 | make allclean 219 | ``` 220 | 221 | ---- 222 | 223 | # Note for compilation 224 | 225 | - `USE_MPI` and `USE_GPU` flags in Makefile should be `1` or `0` for all compilations. If the white spaces exist at end of the line, those flags will be ignored. 226 | - For GPU use, `SM_VERSIONS` can specity the target NVIDIA GPU architectures of the generated binary. Please change it for your target system. (Default: `sm_60`) 227 | -------------------------------------------------------------------------------- /Dockerfiles/cpu/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # Compile options start # 3 | #-----------------------------------------------------------# 4 | # # 5 | 6 | #----------------------------------------------# 7 | # Library PATH and compiler settings # 8 | #----------------------------------------------# 9 | 10 | CUDA_INSTALL_PATH ?= NONE 11 | CUDA_SAMPLES_PATH ?= NONE 12 | FFTW_INSTALL_PATH ?= /usr/local/fftw-3.3.8 13 | CPPCOMPILER ?= g++ 14 | MPICOMPILER ?= NONE 15 | OPTIMIZATION ?= -O3 16 | OMPFLAG ?= -fopenmp 17 | # (If you use g++ compiler, please set the value as "-fopenmp".) 18 | 19 | #----------------------------------------------# 20 | # Environment settings # 21 | #----------------------------------------------# 22 | 23 | USE_GPU := 0 24 | # (If you do not use GPU, please set the value as 0 or comment out of the line.) 25 | 26 | USE_MPI := 0 27 | # (If you do not use MPI, please set the value as 0 or comment out of the line.) 28 | 29 | # # 30 | #-----------------------------------------------------------# 31 | # Compile options end # 32 | ############################################################# 33 | 34 | #-----------------------------------------------------------------------------------------# 35 | CUFILES := fft_process.cu main.cu 36 | CCFILES := control.cpp cpu_time.cpp docking.cpp parameter.cpp pdb_entry.cpp \ 37 | protein.cpp receptor.cpp ligand.cpp 38 | 39 | ifndef USE_GPU 40 | USE_GPU := 0 41 | endif 42 | ifndef USE_MPI 43 | USE_MPI := 0 44 | endif 45 | 46 | ifeq ($(USE_GPU),1) 47 | CXXFLAGS += -DCUFFT 48 | NVCCFLAGS += -DCUFFT 49 | ifeq ($(USE_MPI),1) 50 | CCFILES += mpidp.cpp 51 | EXECUTABLE := megadock-gpu-dp 52 | COMPILER = $(MPICOMPILER) 53 | CXXFLAGS += -DMPI_DP 54 | NVCCFLAGS += -DMPI_DP 55 | OBJDIRPR := gm 56 | else 57 | EXECUTABLE := megadock-gpu 58 | COMPILER = $(CPPCOMPILER) 59 | OBJDIRPR := gs 60 | endif 61 | else 62 | CUFILES := 63 | CCFILES += fft_process.cpp main.cpp 64 | ifeq ($(USE_MPI),1) 65 | CCFILES += mpidp.cpp 66 | EXECUTABLE := megadock-dp 67 | COMPILER = $(MPICOMPILER) 68 | CXXFLAGS += -DMPI_DP 69 | NVCCFLAGS += -DMPI_DP 70 | OBJDIRPR := cm 71 | else 72 | EXECUTABLE := megadock 73 | COMPILER = $(CPPCOMPILER) 74 | OBJDIRPR := cs 75 | endif 76 | endif 77 | 78 | .SUFFIXES : .cuda.c .cu_dbg.o .c_dbg.o .cpp_dbg.o .cu_rel.o .c_rel.o .cpp_rel.o .cubin .ptx 79 | 80 | # FFTW setup 81 | FFTW_CFLAGS ?= -I$(FFTW_INSTALL_PATH)/include 82 | FFTW_LDFLAGS ?= -lm -L$(FFTW_INSTALL_PATH)/lib -lfftw3f 83 | 84 | # Add new SM Versions here as devices with new Compute Capability are released 85 | SM_VERSIONS := sm_60 86 | 87 | # Basic directory setup for SDK 88 | SRCDIR ?= src 89 | ROOTDIR ?= $(CUDA_SAMPLES_PATH) 90 | BINDIR ?= . 91 | ROOTOBJDIR ?= obj_$(OBJDIRPR) 92 | COMMONDIR := $(ROOTDIR)/common 93 | 94 | # Compilers 95 | NVCC := $(CUDA_INSTALL_PATH)/bin/nvcc -Xcompiler -fopenmp -arch=$(SM_VERSIONS) -use_fast_math 96 | CXX := $(COMPILER) $(OMPFLAG) 97 | LINK := $(COMPILER) -fPIC $(OMPFLAG) 98 | 99 | # Includes 100 | INCLUDES += -I$(SRCDIR) 101 | ifeq ($(USE_GPU),1) 102 | INCLUDES += -I$(CUDA_INSTALL_PATH)/include -I$(COMMONDIR)/inc 103 | endif 104 | 105 | # Warning flags 106 | CXXWARN_FLAGS := # -W -Wall \ 107 | # -Wimplicit \ 108 | # -Wformat \ 109 | # -Wparentheses \ 110 | # -Wmultichar \ 111 | # -Wtrigraphs \ 112 | # -Wpointer-arith \ 113 | # -Wreturn-type \ 114 | # -Wno-unused-function 115 | 116 | # Compiler-specific flags 117 | NVCCFLAGS += 118 | CXXFLAGS += -static $(CXXWARN_FLAGS) 119 | 120 | # Common flags 121 | COMMONFLAGS += $(OPTIMIZATION) $(INCLUDES) $(FFTW_CFLAGS) 122 | LIBSUFFIX := _x86_64 123 | NVCCFLAGS += --compiler-options -fno-strict-aliasing 124 | #CXXFLAGS += -fno-strict-aliasing -funroll-loops 125 | 126 | # FFTW Libs 127 | LIB := $(FFTW_LDFLAGS) 128 | 129 | # CUDA Libs 130 | ifeq ($(USE_GPU),1) 131 | LIB += -L$(CUDA_INSTALL_PATH)/lib64 -lcudart -lcufft 132 | endif 133 | 134 | TARGETDIR := $(BINDIR) 135 | TARGET := $(TARGETDIR)/$(EXECUTABLE) 136 | LINKLINE = $(LINK) -o $(TARGET) $(OBJS) $(LIB) 137 | 138 | ################################################################################ 139 | # Check for input flags and set compiler flags appropriately 140 | ################################################################################ 141 | ifdef maxregisters 142 | NVCCFLAGS += -maxrregcount $(maxregisters) 143 | endif 144 | 145 | # Add cudacc flags 146 | NVCCFLAGS += $(CUDACCFLAGS) 147 | 148 | # Add common flags 149 | NVCCFLAGS += $(COMMONFLAGS) 150 | CXXFLAGS += $(COMMONFLAGS) 151 | 152 | ################################################################################ 153 | # Set up object files 154 | ################################################################################ 155 | OBJDIR := $(ROOTOBJDIR) 156 | OBJS += $(patsubst %.cpp,$(OBJDIR)/%.cpp.o,$(notdir $(addprefix $(SRCDIR)/, $(CCFILES)))) 157 | OBJS += $(patsubst %.c,$(OBJDIR)/%.c.o,$(notdir $(addprefix $(SRCDIR)/, $(CCFILES)))) 158 | OBJS += $(patsubst %.cu,$(OBJDIR)/%.cu.o,$(notdir $(addprefix $(SRCDIR)/, $(CUFILES)))) 159 | OBJS := $(filter %.o,$(OBJS)) 160 | 161 | ################################################################################ 162 | # Rules 163 | ################################################################################ 164 | 165 | $(OBJDIR)/%.c.o : $(SRCDIR)/%.c $(C_DEPS) 166 | $(VERBOSE)$(CXX) $(CXXFLAGS) -o $@ -c $< 167 | 168 | $(OBJDIR)/%.cpp.o : $(SRCDIR)/%.cpp $(C_DEPS) 169 | $(VERBOSE)$(CXX) $(CXXFLAGS) -o $@ -c $< 170 | 171 | $(OBJDIR)/%.cu.o : $(SRCDIR)/%.cu $(CU_DEPS) 172 | $(VERBOSE)$(NVCC) $(NVCCFLAGS) $(SMVERSIONFLAGS) -o $@ -c $< 173 | 174 | define SMVERSION_template 175 | OBJS += $(patsubst %.cu,$(OBJDIR)/%.cu_$(1).o,$(notdir $(CUFILES_$(1)))) 176 | $(OBJDIR)/%.cu_$(1).o : $(SRCDIR)%.cu $(CU_DEPS) 177 | $(VERBOSE)$(NVCC) -o $$@ -c $$< $(NVCCFLAGS) -arch $(1) 178 | endef 179 | 180 | # This line invokes the above template for each arch version stored in 181 | # SM_VERSIONS. The call funtion invokes the template, and the eval 182 | # function interprets it as make commands. 183 | $(foreach smver,$(SM_VERSIONS),$(eval $(call SMVERSION_template,$(smver)))) 184 | 185 | $(TARGET): messeages makedirectories $(OBJS) decoygen calcrg Makefile 186 | $(VERBOSE)$(LINKLINE) 187 | 188 | messeages : 189 | @echo -------------------------- 190 | @echo make $(EXECUTABLE) start 191 | @echo -------------------------- 192 | 193 | makedirectories : 194 | $(VERBOSE)mkdir -p $(OBJDIR) 195 | 196 | decoygen : $(SRCDIR)/decoygen.cpp 197 | $(VERBOSE)$(CPPCOMPILER) $(SRCDIR)/decoygen.cpp -lm -o decoygen 198 | 199 | calcrg : $(SRCDIR)/calcrg.cpp 200 | $(VERBOSE)$(CPPCOMPILER) $(SRCDIR)/calcrg.cpp -o calcrg 201 | 202 | .PHONY : clean allclean 203 | clean : 204 | $(VERBOSE)rm -rf $(ROOTOBJDIR) 205 | $(VERBOSE)rm -f $(TARGET) 206 | 207 | allclean : 208 | $(VERBOSE)rm -rf obj_cs obj_gs obj_cm obj_gm 209 | $(VERBOSE)rm -f megadock megadock-gpu megadock-dp megadock-gpu-dp decoygen calcrg 210 | -------------------------------------------------------------------------------- /Dockerfiles/mpi/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # Compile options start # 3 | #-----------------------------------------------------------# 4 | # # 5 | 6 | #----------------------------------------------# 7 | # Library PATH and compiler settings # 8 | #----------------------------------------------# 9 | 10 | CUDA_INSTALL_PATH ?= NONE 11 | CUDA_SAMPLES_PATH ?= NONE 12 | FFTW_INSTALL_PATH ?= /usr/local/fftw-3.3.8 13 | CPPCOMPILER ?= g++ 14 | MPICOMPILER ?= mpicxx 15 | OPTIMIZATION ?= -O3 16 | OMPFLAG ?= -fopenmp 17 | # (If you use g++ compiler, please set the value as "-fopenmp".) 18 | 19 | #----------------------------------------------# 20 | # Environment settings # 21 | #----------------------------------------------# 22 | 23 | USE_GPU := 0 24 | # (If you do not use GPU, please set the value as 0 or comment out of the line.) 25 | 26 | USE_MPI := 1 27 | # (If you do not use MPI, please set the value as 0 or comment out of the line.) 28 | 29 | # # 30 | #-----------------------------------------------------------# 31 | # Compile options end # 32 | ############################################################# 33 | 34 | #-----------------------------------------------------------------------------------------# 35 | CUFILES := fft_process.cu main.cu 36 | CCFILES := control.cpp cpu_time.cpp docking.cpp parameter.cpp pdb_entry.cpp \ 37 | protein.cpp receptor.cpp ligand.cpp 38 | 39 | ifndef USE_GPU 40 | USE_GPU := 0 41 | endif 42 | ifndef USE_MPI 43 | USE_MPI := 0 44 | endif 45 | 46 | ifeq ($(USE_GPU),1) 47 | CXXFLAGS += -DCUFFT 48 | NVCCFLAGS += -DCUFFT 49 | ifeq ($(USE_MPI),1) 50 | CCFILES += mpidp.cpp 51 | EXECUTABLE := megadock-gpu-dp 52 | COMPILER = $(MPICOMPILER) 53 | CXXFLAGS += -DMPI_DP 54 | NVCCFLAGS += -DMPI_DP 55 | OBJDIRPR := gm 56 | else 57 | EXECUTABLE := megadock-gpu 58 | COMPILER = $(CPPCOMPILER) 59 | OBJDIRPR := gs 60 | endif 61 | else 62 | CUFILES := 63 | CCFILES += fft_process.cpp main.cpp 64 | ifeq ($(USE_MPI),1) 65 | CCFILES += mpidp.cpp 66 | EXECUTABLE := megadock-dp 67 | COMPILER = $(MPICOMPILER) 68 | CXXFLAGS += -DMPI_DP 69 | NVCCFLAGS += -DMPI_DP 70 | OBJDIRPR := cm 71 | else 72 | EXECUTABLE := megadock 73 | COMPILER = $(CPPCOMPILER) 74 | OBJDIRPR := cs 75 | endif 76 | endif 77 | 78 | .SUFFIXES : .cuda.c .cu_dbg.o .c_dbg.o .cpp_dbg.o .cu_rel.o .c_rel.o .cpp_rel.o .cubin .ptx 79 | 80 | # FFTW setup 81 | FFTW_CFLAGS ?= -I$(FFTW_INSTALL_PATH)/include 82 | FFTW_LDFLAGS ?= -lm -L$(FFTW_INSTALL_PATH)/lib -lfftw3f 83 | 84 | # Add new SM Versions here as devices with new Compute Capability are released 85 | SM_VERSIONS := sm_60 86 | 87 | # Basic directory setup for SDK 88 | SRCDIR ?= src 89 | ROOTDIR ?= $(CUDA_SAMPLES_PATH) 90 | BINDIR ?= . 91 | ROOTOBJDIR ?= obj_$(OBJDIRPR) 92 | COMMONDIR := $(ROOTDIR)/common 93 | 94 | # Compilers 95 | NVCC := $(CUDA_INSTALL_PATH)/bin/nvcc -Xcompiler -fopenmp -arch=$(SM_VERSIONS) -use_fast_math 96 | CXX := $(COMPILER) $(OMPFLAG) 97 | LINK := $(COMPILER) -fPIC $(OMPFLAG) 98 | 99 | # Includes 100 | INCLUDES += -I$(SRCDIR) 101 | ifeq ($(USE_GPU),1) 102 | INCLUDES += -I$(CUDA_INSTALL_PATH)/include -I$(COMMONDIR)/inc 103 | endif 104 | 105 | # Warning flags 106 | CXXWARN_FLAGS := # -W -Wall \ 107 | # -Wimplicit \ 108 | # -Wformat \ 109 | # -Wparentheses \ 110 | # -Wmultichar \ 111 | # -Wtrigraphs \ 112 | # -Wpointer-arith \ 113 | # -Wreturn-type \ 114 | # -Wno-unused-function 115 | 116 | # Compiler-specific flags 117 | NVCCFLAGS += 118 | CXXFLAGS += -static $(CXXWARN_FLAGS) 119 | 120 | # Common flags 121 | COMMONFLAGS += $(OPTIMIZATION) $(INCLUDES) $(FFTW_CFLAGS) 122 | LIBSUFFIX := _x86_64 123 | NVCCFLAGS += --compiler-options -fno-strict-aliasing 124 | #CXXFLAGS += -fno-strict-aliasing -funroll-loops 125 | 126 | # FFTW Libs 127 | LIB := $(FFTW_LDFLAGS) 128 | 129 | # CUDA Libs 130 | ifeq ($(USE_GPU),1) 131 | LIB += -L$(CUDA_INSTALL_PATH)/lib64 -lcudart -lcufft 132 | endif 133 | 134 | TARGETDIR := $(BINDIR) 135 | TARGET := $(TARGETDIR)/$(EXECUTABLE) 136 | LINKLINE = $(LINK) -o $(TARGET) $(OBJS) $(LIB) 137 | 138 | ################################################################################ 139 | # Check for input flags and set compiler flags appropriately 140 | ################################################################################ 141 | ifdef maxregisters 142 | NVCCFLAGS += -maxrregcount $(maxregisters) 143 | endif 144 | 145 | # Add cudacc flags 146 | NVCCFLAGS += $(CUDACCFLAGS) 147 | 148 | # Add common flags 149 | NVCCFLAGS += $(COMMONFLAGS) 150 | CXXFLAGS += $(COMMONFLAGS) 151 | 152 | ################################################################################ 153 | # Set up object files 154 | ################################################################################ 155 | OBJDIR := $(ROOTOBJDIR) 156 | OBJS += $(patsubst %.cpp,$(OBJDIR)/%.cpp.o,$(notdir $(addprefix $(SRCDIR)/, $(CCFILES)))) 157 | OBJS += $(patsubst %.c,$(OBJDIR)/%.c.o,$(notdir $(addprefix $(SRCDIR)/, $(CCFILES)))) 158 | OBJS += $(patsubst %.cu,$(OBJDIR)/%.cu.o,$(notdir $(addprefix $(SRCDIR)/, $(CUFILES)))) 159 | OBJS := $(filter %.o,$(OBJS)) 160 | 161 | ################################################################################ 162 | # Rules 163 | ################################################################################ 164 | 165 | $(OBJDIR)/%.c.o : $(SRCDIR)/%.c $(C_DEPS) 166 | $(VERBOSE)$(CXX) $(CXXFLAGS) -o $@ -c $< 167 | 168 | $(OBJDIR)/%.cpp.o : $(SRCDIR)/%.cpp $(C_DEPS) 169 | $(VERBOSE)$(CXX) $(CXXFLAGS) -o $@ -c $< 170 | 171 | $(OBJDIR)/%.cu.o : $(SRCDIR)/%.cu $(CU_DEPS) 172 | $(VERBOSE)$(NVCC) $(NVCCFLAGS) $(SMVERSIONFLAGS) -o $@ -c $< 173 | 174 | define SMVERSION_template 175 | OBJS += $(patsubst %.cu,$(OBJDIR)/%.cu_$(1).o,$(notdir $(CUFILES_$(1)))) 176 | $(OBJDIR)/%.cu_$(1).o : $(SRCDIR)%.cu $(CU_DEPS) 177 | $(VERBOSE)$(NVCC) -o $$@ -c $$< $(NVCCFLAGS) -arch $(1) 178 | endef 179 | 180 | # This line invokes the above template for each arch version stored in 181 | # SM_VERSIONS. The call funtion invokes the template, and the eval 182 | # function interprets it as make commands. 183 | $(foreach smver,$(SM_VERSIONS),$(eval $(call SMVERSION_template,$(smver)))) 184 | 185 | $(TARGET): messeages makedirectories $(OBJS) decoygen calcrg Makefile 186 | $(VERBOSE)$(LINKLINE) 187 | 188 | messeages : 189 | @echo -------------------------- 190 | @echo make $(EXECUTABLE) start 191 | @echo -------------------------- 192 | 193 | makedirectories : 194 | $(VERBOSE)mkdir -p $(OBJDIR) 195 | 196 | decoygen : $(SRCDIR)/decoygen.cpp 197 | $(VERBOSE)$(CPPCOMPILER) $(SRCDIR)/decoygen.cpp -lm -o decoygen 198 | 199 | calcrg : $(SRCDIR)/calcrg.cpp 200 | $(VERBOSE)$(CPPCOMPILER) $(SRCDIR)/calcrg.cpp -o calcrg 201 | 202 | .PHONY : clean allclean 203 | clean : 204 | $(VERBOSE)rm -rf $(ROOTOBJDIR) 205 | $(VERBOSE)rm -f $(TARGET) 206 | 207 | allclean : 208 | $(VERBOSE)rm -rf obj_cs obj_gs obj_cm obj_gm 209 | $(VERBOSE)rm -f megadock megadock-gpu megadock-dp megadock-gpu-dp decoygen calcrg 210 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # Compile options start # 3 | #-----------------------------------------------------------# 4 | # # 5 | 6 | #----------------------------------------------# 7 | # Library PATH and compiler settings # 8 | #----------------------------------------------# 9 | 10 | CUDA_INSTALL_PATH ?= /usr/local/cuda 11 | CUDA_SAMPLES_PATH ?= /usr/local/cuda/samples 12 | FFTW_INSTALL_PATH ?= /usr/local 13 | CPPCOMPILER ?= g++ 14 | MPICOMPILER ?= mpicxx 15 | OPTIMIZATION ?= -O3 16 | OMPFLAG ?= -fopenmp 17 | # (If you use g++ compiler, please set the value as "-fopenmp".) 18 | 19 | #----------------------------------------------# 20 | # Environment settings # 21 | #----------------------------------------------# 22 | 23 | USE_GPU := 1 24 | # (If you do not use GPU, please set the value as 0 or comment out of the line.) 25 | 26 | USE_MPI := 0 27 | # (If you do not use MPI, please set the value as 0 or comment out of the line.) 28 | 29 | # # 30 | #-----------------------------------------------------------# 31 | # Compile options end # 32 | ############################################################# 33 | 34 | #-----------------------------------------------------------------------------------------# 35 | CUFILES := fft_process.cu main.cu 36 | CCFILES := control.cpp cpu_time.cpp docking.cpp parameter.cpp pdb_entry.cpp \ 37 | protein.cpp receptor.cpp ligand.cpp 38 | 39 | ifndef USE_GPU 40 | USE_GPU := 0 41 | endif 42 | ifndef USE_MPI 43 | USE_MPI := 0 44 | endif 45 | 46 | ifeq ($(USE_GPU),1) 47 | CXXFLAGS += -DCUFFT 48 | NVCCFLAGS += -DCUFFT 49 | ifeq ($(USE_MPI),1) 50 | CCFILES += mpidp.cpp 51 | EXECUTABLE := megadock-gpu-dp 52 | COMPILER = $(MPICOMPILER) 53 | CXXFLAGS += -DMPI_DP 54 | NVCCFLAGS += -DMPI_DP 55 | OBJDIRPR := gm 56 | else 57 | EXECUTABLE := megadock-gpu 58 | COMPILER = $(CPPCOMPILER) 59 | OBJDIRPR := gs 60 | endif 61 | else 62 | CUFILES := 63 | CCFILES += fft_process.cpp main.cpp 64 | ifeq ($(USE_MPI),1) 65 | CCFILES += mpidp.cpp 66 | EXECUTABLE := megadock-dp 67 | COMPILER = $(MPICOMPILER) 68 | CXXFLAGS += -DMPI_DP 69 | NVCCFLAGS += -DMPI_DP 70 | OBJDIRPR := cm 71 | else 72 | EXECUTABLE := megadock 73 | COMPILER = $(CPPCOMPILER) 74 | OBJDIRPR := cs 75 | endif 76 | endif 77 | 78 | .SUFFIXES : .cuda.c .cu_dbg.o .c_dbg.o .cpp_dbg.o .cu_rel.o .c_rel.o .cpp_rel.o .cubin .ptx 79 | 80 | # FFTW setup 81 | FFTW_CFLAGS ?= -I$(FFTW_INSTALL_PATH)/include 82 | FFTW_LDFLAGS ?= -lm -L$(FFTW_INSTALL_PATH)/lib -lfftw3f 83 | 84 | # Add new SM Versions here as devices with new Compute Capability are released 85 | SM_VERSIONS := sm_60 86 | 87 | # Basic directory setup for SDK 88 | SRCDIR ?= src 89 | ROOTDIR ?= $(CUDA_SAMPLES_PATH) 90 | BINDIR ?= . 91 | ROOTOBJDIR ?= obj_$(OBJDIRPR) 92 | COMMONDIR := $(ROOTDIR)/common 93 | 94 | # Compilers 95 | NVCC := $(CUDA_INSTALL_PATH)/bin/nvcc -Xcompiler -fopenmp -arch=$(SM_VERSIONS) -use_fast_math 96 | CXX := $(COMPILER) $(OMPFLAG) 97 | LINK := $(COMPILER) -fPIC $(OMPFLAG) 98 | 99 | # Includes 100 | INCLUDES += -I$(SRCDIR) 101 | ifeq ($(USE_GPU),1) 102 | INCLUDES += -I$(CUDA_INSTALL_PATH)/include -I$(COMMONDIR)/inc 103 | endif 104 | 105 | # Warning flags 106 | CXXWARN_FLAGS := # -W -Wall \ 107 | # -Wimplicit \ 108 | # -Wformat \ 109 | # -Wparentheses \ 110 | # -Wmultichar \ 111 | # -Wtrigraphs \ 112 | # -Wpointer-arith \ 113 | # -Wreturn-type \ 114 | # -Wno-unused-function 115 | 116 | # Compiler-specific flags 117 | NVCCFLAGS += 118 | CXXFLAGS += -static $(CXXWARN_FLAGS) 119 | 120 | # Common flags 121 | COMMONFLAGS += $(OPTIMIZATION) $(INCLUDES) $(FFTW_CFLAGS) 122 | LIBSUFFIX := _x86_64 123 | NVCCFLAGS += --compiler-options -fno-strict-aliasing 124 | #CXXFLAGS += -fno-strict-aliasing -funroll-loops 125 | 126 | # FFTW Libs 127 | LIB := $(FFTW_LDFLAGS) 128 | 129 | # CUDA Libs 130 | ifeq ($(USE_GPU),1) 131 | LIB += -L$(CUDA_INSTALL_PATH)/lib64 -lcudart -lcufft 132 | endif 133 | 134 | TARGETDIR := $(BINDIR) 135 | TARGET := $(TARGETDIR)/$(EXECUTABLE) 136 | LINKLINE = $(LINK) -o $(TARGET) $(OBJS) $(LIB) 137 | 138 | ################################################################################ 139 | # Check for input flags and set compiler flags appropriately 140 | ################################################################################ 141 | ifdef maxregisters 142 | NVCCFLAGS += -maxrregcount $(maxregisters) 143 | endif 144 | 145 | # Add cudacc flags 146 | NVCCFLAGS += $(CUDACCFLAGS) 147 | 148 | # Add common flags 149 | NVCCFLAGS += $(COMMONFLAGS) 150 | CXXFLAGS += $(COMMONFLAGS) 151 | 152 | ################################################################################ 153 | # Set up object files 154 | ################################################################################ 155 | OBJDIR := $(ROOTOBJDIR) 156 | OBJS += $(patsubst %.cpp,$(OBJDIR)/%.cpp.o,$(notdir $(addprefix $(SRCDIR)/, $(CCFILES)))) 157 | OBJS += $(patsubst %.c,$(OBJDIR)/%.c.o,$(notdir $(addprefix $(SRCDIR)/, $(CCFILES)))) 158 | OBJS += $(patsubst %.cu,$(OBJDIR)/%.cu.o,$(notdir $(addprefix $(SRCDIR)/, $(CUFILES)))) 159 | OBJS := $(filter %.o,$(OBJS)) 160 | 161 | ################################################################################ 162 | # Rules 163 | ################################################################################ 164 | 165 | $(OBJDIR)/%.c.o : $(SRCDIR)/%.c $(C_DEPS) 166 | $(VERBOSE)$(CXX) $(CXXFLAGS) -o $@ -c $< 167 | 168 | $(OBJDIR)/%.cpp.o : $(SRCDIR)/%.cpp $(C_DEPS) 169 | $(VERBOSE)$(CXX) $(CXXFLAGS) -o $@ -c $< 170 | 171 | $(OBJDIR)/%.cu.o : $(SRCDIR)/%.cu $(CU_DEPS) 172 | $(VERBOSE)$(NVCC) $(NVCCFLAGS) $(SMVERSIONFLAGS) -o $@ -c $< 173 | 174 | define SMVERSION_template 175 | OBJS += $(patsubst %.cu,$(OBJDIR)/%.cu_$(1).o,$(notdir $(CUFILES_$(1)))) 176 | $(OBJDIR)/%.cu_$(1).o : $(SRCDIR)%.cu $(CU_DEPS) 177 | $(VERBOSE)$(NVCC) -o $$@ -c $$< $(NVCCFLAGS) -arch $(1) 178 | endef 179 | 180 | # This line invokes the above template for each arch version stored in 181 | # SM_VERSIONS. The call funtion invokes the template, and the eval 182 | # function interprets it as make commands. 183 | $(foreach smver,$(SM_VERSIONS),$(eval $(call SMVERSION_template,$(smver)))) 184 | 185 | $(TARGET): messeages makedirectories $(OBJS) decoygen calcrg Makefile 186 | $(VERBOSE)$(LINKLINE) 187 | 188 | messeages : 189 | @echo -------------------------- 190 | @echo make $(EXECUTABLE) start 191 | @echo -------------------------- 192 | 193 | makedirectories : 194 | $(VERBOSE)mkdir -p $(OBJDIR) 195 | 196 | decoygen : $(SRCDIR)/decoygen.cpp 197 | $(VERBOSE)$(CPPCOMPILER) $(SRCDIR)/decoygen.cpp -lm -o decoygen 198 | 199 | calcrg : $(SRCDIR)/calcrg.cpp 200 | $(VERBOSE)$(CPPCOMPILER) $(SRCDIR)/calcrg.cpp -o calcrg 201 | 202 | .PHONY : clean allclean 203 | clean : 204 | $(VERBOSE)rm -rf $(ROOTOBJDIR) 205 | $(VERBOSE)rm -f $(TARGET) 206 | 207 | allclean : 208 | $(VERBOSE)rm -rf obj_cs obj_gs obj_cm obj_gm 209 | $(VERBOSE)rm -f megadock megadock-gpu megadock-dp megadock-gpu-dp decoygen calcrg 210 | -------------------------------------------------------------------------------- /Makefile.colab: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # Compile options start # 3 | #-----------------------------------------------------------# 4 | # # 5 | 6 | #----------------------------------------------# 7 | # Library PATH and compiler settings # 8 | #----------------------------------------------# 9 | 10 | CUDA_INSTALL_PATH ?= /usr/local/cuda 11 | CUDA_SAMPLES_PATH ?= /content/cuda-samples 12 | FFTW_INSTALL_PATH ?= /usr/local 13 | CPPCOMPILER ?= g++ 14 | MPICOMPILER ?= mpicxx 15 | OPTIMIZATION ?= -O3 16 | OMPFLAG ?= -fopenmp 17 | # (If you use g++ compiler, please set the value as "-fopenmp".) 18 | 19 | #----------------------------------------------# 20 | # Environment settings # 21 | #----------------------------------------------# 22 | 23 | USE_GPU := 1 24 | # (If you do not use GPU, please set the value as 0 or comment out of the line.) 25 | 26 | USE_MPI := 0 27 | # (If you do not use MPI, please set the value as 0 or comment out of the line.) 28 | 29 | # # 30 | #-----------------------------------------------------------# 31 | # Compile options end # 32 | ############################################################# 33 | 34 | #-----------------------------------------------------------------------------------------# 35 | CUFILES := fft_process.cu main.cu 36 | CCFILES := control.cpp cpu_time.cpp docking.cpp parameter.cpp pdb_entry.cpp \ 37 | protein.cpp receptor.cpp ligand.cpp 38 | 39 | ifndef USE_GPU 40 | USE_GPU := 0 41 | endif 42 | ifndef USE_MPI 43 | USE_MPI := 0 44 | endif 45 | 46 | ifeq ($(USE_GPU),1) 47 | CXXFLAGS += -DCUFFT 48 | NVCCFLAGS += -DCUFFT 49 | ifeq ($(USE_MPI),1) 50 | CCFILES += mpidp.cpp 51 | EXECUTABLE := megadock-gpu-dp 52 | COMPILER = $(MPICOMPILER) 53 | CXXFLAGS += -DMPI_DP 54 | NVCCFLAGS += -DMPI_DP 55 | OBJDIRPR := gm 56 | else 57 | EXECUTABLE := megadock-gpu 58 | COMPILER = $(CPPCOMPILER) 59 | OBJDIRPR := gs 60 | endif 61 | else 62 | CUFILES := 63 | CCFILES += fft_process.cpp main.cpp 64 | ifeq ($(USE_MPI),1) 65 | CCFILES += mpidp.cpp 66 | EXECUTABLE := megadock-dp 67 | COMPILER = $(MPICOMPILER) 68 | CXXFLAGS += -DMPI_DP 69 | NVCCFLAGS += -DMPI_DP 70 | OBJDIRPR := cm 71 | else 72 | EXECUTABLE := megadock 73 | COMPILER = $(CPPCOMPILER) 74 | OBJDIRPR := cs 75 | endif 76 | endif 77 | 78 | .SUFFIXES : .cuda.c .cu_dbg.o .c_dbg.o .cpp_dbg.o .cu_rel.o .c_rel.o .cpp_rel.o .cubin .ptx 79 | 80 | # FFTW setup 81 | FFTW_CFLAGS ?= -I$(FFTW_INSTALL_PATH)/include 82 | FFTW_LDFLAGS ?= -lm -L$(FFTW_INSTALL_PATH)/lib -lfftw3f 83 | 84 | # Add new SM Versions here as devices with new Compute Capability are released 85 | SM_VERSIONS := sm_60 86 | 87 | # Basic directory setup for SDK 88 | SRCDIR ?= src 89 | ROOTDIR ?= $(CUDA_SAMPLES_PATH) 90 | BINDIR ?= . 91 | ROOTOBJDIR ?= obj_$(OBJDIRPR) 92 | COMMONDIR := $(ROOTDIR)/Common 93 | 94 | # Compilers 95 | NVCC := $(CUDA_INSTALL_PATH)/bin/nvcc -Xcompiler -fopenmp -arch=$(SM_VERSIONS) -use_fast_math 96 | CXX := $(COMPILER) $(OMPFLAG) 97 | LINK := $(COMPILER) -fPIC $(OMPFLAG) 98 | 99 | # Includes 100 | INCLUDES += -I$(SRCDIR) 101 | ifeq ($(USE_GPU),1) 102 | INCLUDES += -I$(CUDA_INSTALL_PATH)/include -I$(COMMONDIR) 103 | endif 104 | 105 | # Warning flags 106 | CXXWARN_FLAGS := # -W -Wall \ 107 | # -Wimplicit \ 108 | # -Wformat \ 109 | # -Wparentheses \ 110 | # -Wmultichar \ 111 | # -Wtrigraphs \ 112 | # -Wpointer-arith \ 113 | # -Wreturn-type \ 114 | # -Wno-unused-function 115 | 116 | # Compiler-specific flags 117 | NVCCFLAGS += 118 | CXXFLAGS += -static $(CXXWARN_FLAGS) 119 | 120 | # Common flags 121 | COMMONFLAGS += $(OPTIMIZATION) $(INCLUDES) $(FFTW_CFLAGS) 122 | LIBSUFFIX := _x86_64 123 | NVCCFLAGS += --compiler-options -fno-strict-aliasing 124 | #CXXFLAGS += -fno-strict-aliasing -funroll-loops 125 | 126 | # FFTW Libs 127 | LIB := $(FFTW_LDFLAGS) 128 | 129 | # CUDA Libs 130 | ifeq ($(USE_GPU),1) 131 | LIB += -L$(CUDA_INSTALL_PATH)/lib64 -lcudart -lcufft 132 | endif 133 | 134 | TARGETDIR := $(BINDIR) 135 | TARGET := $(TARGETDIR)/$(EXECUTABLE) 136 | LINKLINE = $(LINK) -o $(TARGET) $(OBJS) $(LIB) 137 | 138 | ################################################################################ 139 | # Check for input flags and set compiler flags appropriately 140 | ################################################################################ 141 | ifdef maxregisters 142 | NVCCFLAGS += -maxrregcount $(maxregisters) 143 | endif 144 | 145 | # Add cudacc flags 146 | NVCCFLAGS += $(CUDACCFLAGS) 147 | 148 | # Add common flags 149 | NVCCFLAGS += $(COMMONFLAGS) 150 | CXXFLAGS += $(COMMONFLAGS) 151 | 152 | ################################################################################ 153 | # Set up object files 154 | ################################################################################ 155 | OBJDIR := $(ROOTOBJDIR) 156 | OBJS += $(patsubst %.cpp,$(OBJDIR)/%.cpp.o,$(notdir $(addprefix $(SRCDIR)/, $(CCFILES)))) 157 | OBJS += $(patsubst %.c,$(OBJDIR)/%.c.o,$(notdir $(addprefix $(SRCDIR)/, $(CCFILES)))) 158 | OBJS += $(patsubst %.cu,$(OBJDIR)/%.cu.o,$(notdir $(addprefix $(SRCDIR)/, $(CUFILES)))) 159 | OBJS := $(filter %.o,$(OBJS)) 160 | 161 | ################################################################################ 162 | # Rules 163 | ################################################################################ 164 | 165 | $(OBJDIR)/%.c.o : $(SRCDIR)/%.c $(C_DEPS) 166 | $(VERBOSE)$(CXX) $(CXXFLAGS) -o $@ -c $< 167 | 168 | $(OBJDIR)/%.cpp.o : $(SRCDIR)/%.cpp $(C_DEPS) 169 | $(VERBOSE)$(CXX) $(CXXFLAGS) -o $@ -c $< 170 | 171 | $(OBJDIR)/%.cu.o : $(SRCDIR)/%.cu $(CU_DEPS) 172 | $(VERBOSE)$(NVCC) $(NVCCFLAGS) $(SMVERSIONFLAGS) -o $@ -c $< 173 | 174 | define SMVERSION_template 175 | OBJS += $(patsubst %.cu,$(OBJDIR)/%.cu_$(1).o,$(notdir $(CUFILES_$(1)))) 176 | $(OBJDIR)/%.cu_$(1).o : $(SRCDIR)%.cu $(CU_DEPS) 177 | $(VERBOSE)$(NVCC) -o $$@ -c $$< $(NVCCFLAGS) -arch $(1) 178 | endef 179 | 180 | # This line invokes the above template for each arch version stored in 181 | # SM_VERSIONS. The call funtion invokes the template, and the eval 182 | # function interprets it as make commands. 183 | $(foreach smver,$(SM_VERSIONS),$(eval $(call SMVERSION_template,$(smver)))) 184 | 185 | $(TARGET): messeages makedirectories $(OBJS) decoygen calcrg Makefile 186 | $(VERBOSE)$(LINKLINE) 187 | 188 | messeages : 189 | @echo -------------------------- 190 | @echo make $(EXECUTABLE) start 191 | @echo -------------------------- 192 | 193 | makedirectories : 194 | $(VERBOSE)mkdir -p $(OBJDIR) 195 | 196 | decoygen : $(SRCDIR)/decoygen.cpp 197 | $(VERBOSE)$(CPPCOMPILER) $(SRCDIR)/decoygen.cpp -lm -o decoygen 198 | 199 | calcrg : $(SRCDIR)/calcrg.cpp 200 | $(VERBOSE)$(CPPCOMPILER) $(SRCDIR)/calcrg.cpp -o calcrg 201 | 202 | .PHONY : clean allclean 203 | clean : 204 | $(VERBOSE)rm -rf $(ROOTOBJDIR) 205 | $(VERBOSE)rm -f $(TARGET) 206 | 207 | allclean : 208 | $(VERBOSE)rm -rf obj_cs obj_gs obj_cm obj_gm 209 | $(VERBOSE)rm -f megadock megadock-gpu megadock-dp megadock-gpu-dp decoygen calcrg 210 | -------------------------------------------------------------------------------- /Dockerfiles/gpu/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # Compile options start # 3 | #-----------------------------------------------------------# 4 | # # 5 | 6 | #----------------------------------------------# 7 | # Library PATH and compiler settings # 8 | #----------------------------------------------# 9 | 10 | CUDA_INSTALL_PATH ?= /usr/local/cuda 11 | CUDA_SAMPLES_PATH ?= /usr/local/cuda/samples 12 | FFTW_INSTALL_PATH ?= /usr/local/fftw-3.3.8 13 | CPPCOMPILER ?= g++ 14 | MPICOMPILER ?= mpicxx 15 | OPTIMIZATION ?= -O3 16 | OMPFLAG ?= -fopenmp 17 | # (If you use g++ compiler, please set the value as "-fopenmp".) 18 | 19 | #----------------------------------------------# 20 | # Environment settings # 21 | #----------------------------------------------# 22 | 23 | USE_GPU := 1 24 | # (If you do not use GPU, please set the value as 0 or comment out of the line.) 25 | 26 | USE_MPI := 0 27 | # (If you do not use MPI, please set the value as 0 or comment out of the line.) 28 | 29 | # # 30 | #-----------------------------------------------------------# 31 | # Compile options end # 32 | ############################################################# 33 | 34 | #-----------------------------------------------------------------------------------------# 35 | CUFILES := fft_process.cu main.cu 36 | CCFILES := control.cpp cpu_time.cpp docking.cpp parameter.cpp pdb_entry.cpp \ 37 | protein.cpp receptor.cpp ligand.cpp 38 | 39 | ifndef USE_GPU 40 | USE_GPU := 0 41 | endif 42 | ifndef USE_MPI 43 | USE_MPI := 0 44 | endif 45 | 46 | ifeq ($(USE_GPU),1) 47 | CXXFLAGS += -DCUFFT 48 | NVCCFLAGS += -DCUFFT 49 | ifeq ($(USE_MPI),1) 50 | CCFILES += mpidp.cpp 51 | EXECUTABLE := megadock-gpu-dp 52 | COMPILER = $(MPICOMPILER) 53 | CXXFLAGS += -DMPI_DP 54 | NVCCFLAGS += -DMPI_DP 55 | OBJDIRPR := gm 56 | else 57 | EXECUTABLE := megadock-gpu 58 | COMPILER = $(CPPCOMPILER) 59 | OBJDIRPR := gs 60 | endif 61 | else 62 | CUFILES := 63 | CCFILES += fft_process.cpp main.cpp 64 | ifeq ($(USE_MPI),1) 65 | CCFILES += mpidp.cpp 66 | EXECUTABLE := megadock-dp 67 | COMPILER = $(MPICOMPILER) 68 | CXXFLAGS += -DMPI_DP 69 | NVCCFLAGS += -DMPI_DP 70 | OBJDIRPR := cm 71 | else 72 | EXECUTABLE := megadock 73 | COMPILER = $(CPPCOMPILER) 74 | OBJDIRPR := cs 75 | endif 76 | endif 77 | 78 | .SUFFIXES : .cuda.c .cu_dbg.o .c_dbg.o .cpp_dbg.o .cu_rel.o .c_rel.o .cpp_rel.o .cubin .ptx 79 | 80 | # FFTW setup 81 | FFTW_CFLAGS ?= -I$(FFTW_INSTALL_PATH)/include 82 | FFTW_LDFLAGS ?= -lm -L$(FFTW_INSTALL_PATH)/lib -lfftw3f 83 | 84 | # Add new SM Versions here as devices with new Compute Capability are released 85 | SM_VERSIONS := sm_60 86 | 87 | # Basic directory setup for SDK 88 | SRCDIR ?= src 89 | ROOTDIR ?= $(CUDA_SAMPLES_PATH) 90 | BINDIR ?= . 91 | ROOTOBJDIR ?= obj_$(OBJDIRPR) 92 | COMMONDIR := $(ROOTDIR)/common 93 | 94 | # Compilers 95 | NVCC := $(CUDA_INSTALL_PATH)/bin/nvcc -Xcompiler -fopenmp -arch=$(SM_VERSIONS) -use_fast_math 96 | CXX := $(COMPILER) $(OMPFLAG) 97 | LINK := $(COMPILER) -fPIC $(OMPFLAG) 98 | 99 | # Includes 100 | INCLUDES += -I$(SRCDIR) 101 | ifeq ($(USE_GPU),1) 102 | INCLUDES += -I$(CUDA_INSTALL_PATH)/include -I$(COMMONDIR)/inc 103 | endif 104 | 105 | # Warning flags 106 | CXXWARN_FLAGS := # -W -Wall \ 107 | # -Wimplicit \ 108 | # -Wformat \ 109 | # -Wparentheses \ 110 | # -Wmultichar \ 111 | # -Wtrigraphs \ 112 | # -Wpointer-arith \ 113 | # -Wreturn-type \ 114 | # -Wno-unused-function 115 | 116 | # Compiler-specific flags 117 | NVCCFLAGS += 118 | CXXFLAGS += -static $(CXXWARN_FLAGS) 119 | 120 | # Common flags 121 | COMMONFLAGS += $(OPTIMIZATION) $(INCLUDES) $(FFTW_CFLAGS) 122 | LIBSUFFIX := _x86_64 123 | NVCCFLAGS += --compiler-options -fno-strict-aliasing 124 | #CXXFLAGS += -fno-strict-aliasing -funroll-loops 125 | 126 | # FFTW Libs 127 | LIB := $(FFTW_LDFLAGS) 128 | 129 | # CUDA Libs 130 | ifeq ($(USE_GPU),1) 131 | LIB += -L$(CUDA_INSTALL_PATH)/lib64 -lcudart -lcufft 132 | endif 133 | 134 | TARGETDIR := $(BINDIR) 135 | TARGET := $(TARGETDIR)/$(EXECUTABLE) 136 | LINKLINE = $(LINK) -o $(TARGET) $(OBJS) $(LIB) 137 | 138 | ################################################################################ 139 | # Check for input flags and set compiler flags appropriately 140 | ################################################################################ 141 | ifdef maxregisters 142 | NVCCFLAGS += -maxrregcount $(maxregisters) 143 | endif 144 | 145 | # Add cudacc flags 146 | NVCCFLAGS += $(CUDACCFLAGS) 147 | 148 | # Add common flags 149 | NVCCFLAGS += $(COMMONFLAGS) 150 | CXXFLAGS += $(COMMONFLAGS) 151 | 152 | ################################################################################ 153 | # Set up object files 154 | ################################################################################ 155 | OBJDIR := $(ROOTOBJDIR) 156 | OBJS += $(patsubst %.cpp,$(OBJDIR)/%.cpp.o,$(notdir $(addprefix $(SRCDIR)/, $(CCFILES)))) 157 | OBJS += $(patsubst %.c,$(OBJDIR)/%.c.o,$(notdir $(addprefix $(SRCDIR)/, $(CCFILES)))) 158 | OBJS += $(patsubst %.cu,$(OBJDIR)/%.cu.o,$(notdir $(addprefix $(SRCDIR)/, $(CUFILES)))) 159 | OBJS := $(filter %.o,$(OBJS)) 160 | 161 | ################################################################################ 162 | # Rules 163 | ################################################################################ 164 | 165 | $(OBJDIR)/%.c.o : $(SRCDIR)/%.c $(C_DEPS) 166 | $(VERBOSE)$(CXX) $(CXXFLAGS) -o $@ -c $< 167 | 168 | $(OBJDIR)/%.cpp.o : $(SRCDIR)/%.cpp $(C_DEPS) 169 | $(VERBOSE)$(CXX) $(CXXFLAGS) -o $@ -c $< 170 | 171 | $(OBJDIR)/%.cu.o : $(SRCDIR)/%.cu $(CU_DEPS) 172 | $(VERBOSE)$(NVCC) $(NVCCFLAGS) $(SMVERSIONFLAGS) -o $@ -c $< 173 | 174 | define SMVERSION_template 175 | OBJS += $(patsubst %.cu,$(OBJDIR)/%.cu_$(1).o,$(notdir $(CUFILES_$(1)))) 176 | $(OBJDIR)/%.cu_$(1).o : $(SRCDIR)%.cu $(CU_DEPS) 177 | $(VERBOSE)$(NVCC) -o $$@ -c $$< $(NVCCFLAGS) -arch $(1) 178 | endef 179 | 180 | # This line invokes the above template for each arch version stored in 181 | # SM_VERSIONS. The call funtion invokes the template, and the eval 182 | # function interprets it as make commands. 183 | $(foreach smver,$(SM_VERSIONS),$(eval $(call SMVERSION_template,$(smver)))) 184 | 185 | $(TARGET): messeages makedirectories $(OBJS) decoygen calcrg Makefile 186 | $(VERBOSE)$(LINKLINE) 187 | 188 | messeages : 189 | @echo -------------------------- 190 | @echo make $(EXECUTABLE) start 191 | @echo -------------------------- 192 | 193 | makedirectories : 194 | $(VERBOSE)mkdir -p $(OBJDIR) 195 | 196 | decoygen : $(SRCDIR)/decoygen.cpp 197 | $(VERBOSE)$(CPPCOMPILER) $(SRCDIR)/decoygen.cpp -lm -o decoygen 198 | 199 | calcrg : $(SRCDIR)/calcrg.cpp 200 | $(VERBOSE)$(CPPCOMPILER) $(SRCDIR)/calcrg.cpp -o calcrg 201 | 202 | .PHONY : clean allclean 203 | clean : 204 | $(VERBOSE)rm -rf $(ROOTOBJDIR) 205 | $(VERBOSE)rm -f $(TARGET) 206 | 207 | allclean : 208 | $(VERBOSE)rm -rf obj_cs obj_gs obj_cm obj_gm 209 | $(VERBOSE)rm -f megadock megadock-gpu megadock-dp megadock-gpu-dp decoygen calcrg 210 | -------------------------------------------------------------------------------- /src/cpu_time.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : CPUTime 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #include "cpu_time.h" 16 | 17 | //============================================================================// 18 | void CPUTime::initialize() 19 | //============================================================================// 20 | { 21 | 22 | t1_initialize = 0.0; 23 | t2_receptor_process = 0.0; 24 | t3_docking_total = 0.0; 25 | t4_docking_output_detail = 0.0; 26 | t5_docking_output = 0.0; 27 | 28 | t3_1_ligand_voxelization = 0.0; 29 | t3_2_fftprocess_ligand_fft = 0.0; 30 | t3_3_fftprocess_convolution = 0.0; 31 | t3_4_fftprocess_fft_inverse = 0.0; 32 | t3_5_fftprocess_score_sort = 0.0; 33 | t3_6_fftprocess_sort_index = 0.0; 34 | 35 | t3_1_1_ligvoxgpu_copy_htod = 0.0; 36 | t3_1_2_ligvoxgpu_kernel_init = 0.0; 37 | t3_1_3_ligvoxgpu_kernel_fill_core = 0.0; 38 | t3_1_4_ligvoxgpu_kernel_cut_surf = 0.0; 39 | t3_1_5_ligvoxgpu_kernel_fill_surf = 0.0; 40 | t3_1_6_ligvoxgpu_kernel_elec = 0.0; 41 | t3_1_7_ligvoxgpu_kernel_set_array = 0.0; 42 | 43 | t6_data_transfer_rec = 0.0; 44 | t6_data_transfer_lig = 0.0; 45 | t6_data_transfer_in_loop = 0.0; 46 | 47 | t7_offload_transfer = 0.0; 48 | t7_offload_calc = 0.0; 49 | 50 | m1_current_malloc_size = 0; 51 | m2_maximum_malloc_size = 0; 52 | 53 | return; 54 | } 55 | 56 | //============================================================================// 57 | void CPUTime::output() 58 | //============================================================================// 59 | { 60 | 61 | float total_time = t1_initialize+ 62 | t2_receptor_process+ 63 | t3_docking_total+ 64 | t4_docking_output_detail+ 65 | t5_docking_output; 66 | 67 | float total_transfer = t6_data_transfer_rec+ 68 | t6_data_transfer_lig+ 69 | t6_data_transfer_in_loop; 70 | 71 | //correct the calc-time gap due to parallel calc 72 | const float cufft_ligvox_on_GPU_total_idzero = 0.00000000001 73 | + t3_1_1_ligvoxgpu_copy_htod 74 | + t3_1_2_ligvoxgpu_kernel_init 75 | + t3_1_3_ligvoxgpu_kernel_fill_core 76 | + t3_1_4_ligvoxgpu_kernel_cut_surf 77 | + t3_1_5_ligvoxgpu_kernel_fill_surf 78 | + t3_1_6_ligvoxgpu_kernel_elec 79 | + t3_1_7_ligvoxgpu_kernel_set_array; 80 | 81 | //printf(" max:%f, one:%f",t3_1_ligand_voxelization,cufft_ligvox_on_GPU_total_idzero); 82 | t3_1_1_ligvoxgpu_copy_htod *= (t3_1_ligand_voxelization / cufft_ligvox_on_GPU_total_idzero); 83 | t3_1_2_ligvoxgpu_kernel_init *= (t3_1_ligand_voxelization / cufft_ligvox_on_GPU_total_idzero); 84 | t3_1_3_ligvoxgpu_kernel_fill_core *= (t3_1_ligand_voxelization / cufft_ligvox_on_GPU_total_idzero); 85 | t3_1_4_ligvoxgpu_kernel_cut_surf *= (t3_1_ligand_voxelization / cufft_ligvox_on_GPU_total_idzero); 86 | t3_1_5_ligvoxgpu_kernel_fill_surf *= (t3_1_ligand_voxelization / cufft_ligvox_on_GPU_total_idzero); 87 | t3_1_6_ligvoxgpu_kernel_elec *= (t3_1_ligand_voxelization / cufft_ligvox_on_GPU_total_idzero); 88 | t3_1_7_ligvoxgpu_kernel_set_array *= (t3_1_ligand_voxelization / cufft_ligvox_on_GPU_total_idzero); 89 | 90 | float t3_docking_total_idzero = 0.00000000001 91 | + t3_1_ligand_voxelization 92 | + t3_2_fftprocess_ligand_fft 93 | + t3_3_fftprocess_convolution 94 | + t3_4_fftprocess_fft_inverse 95 | + t3_5_fftprocess_score_sort 96 | + t3_6_fftprocess_sort_index; 97 | //printf(" max:%f, one:%f",t3_docking_total,t3_docking_total_idzero); 98 | 99 | printf("\n"); 100 | printf("CPU time (initialize) = %8.2f sec. (%4.1f%%)\n",t1_initialize , 100.0*t1_initialize /total_time); 101 | printf("CPU time (receptor process) = %8.2f sec. (%4.1f%%)\n",t2_receptor_process , 100.0*t2_receptor_process /total_time); 102 | printf("CPU time (docking) = %8.2f sec. (%4.1f%%)\n",t3_docking_total , 100.0*t3_docking_total /total_time); 103 | printf(" | Ligand voxelization = %8.2f sec. (%4.1f%%)\n",t3_1_ligand_voxelization , 100.0*t3_1_ligand_voxelization /total_time); 104 | #ifdef CUFFT 105 | if(cufft_ligvox_on_GPU_total_idzero>0.1){ 106 | printf(" | ligvox_copy_htod = %8.2f sec. (%4.1f%%)\n",t3_1_1_ligvoxgpu_copy_htod , 100.0*t3_1_1_ligvoxgpu_copy_htod /total_time); 107 | printf(" | ligvox_kernel_init = %8.2f sec. (%4.1f%%)\n",t3_1_2_ligvoxgpu_kernel_init , 100.0*t3_1_2_ligvoxgpu_kernel_init /total_time); 108 | printf(" | ligvox_kernel_fill_core = %8.2f sec. (%4.1f%%)\n",t3_1_3_ligvoxgpu_kernel_fill_core , 100.0*t3_1_3_ligvoxgpu_kernel_fill_core /total_time); 109 | printf(" | ligvox_kernel_cut_surf = %8.2f sec. (%4.1f%%)\n",t3_1_4_ligvoxgpu_kernel_cut_surf , 100.0*t3_1_4_ligvoxgpu_kernel_cut_surf /total_time); 110 | printf(" | ligvox_kernel_fill_surf = %8.2f sec. (%4.1f%%)\n",t3_1_5_ligvoxgpu_kernel_fill_surf , 100.0*t3_1_5_ligvoxgpu_kernel_fill_surf /total_time); 111 | printf(" | ligvox_kernel_elec = %8.2f sec. (%4.1f%%)\n",t3_1_6_ligvoxgpu_kernel_elec , 100.0*t3_1_6_ligvoxgpu_kernel_elec /total_time); 112 | printf(" | ligvox_kernel_set_array = %8.2f sec. (%4.1f%%)\n",t3_1_7_ligvoxgpu_kernel_set_array , 100.0*t3_1_7_ligvoxgpu_kernel_set_array /total_time); 113 | } 114 | #endif 115 | printf(" | Ligand FFT = %8.2f sec. (%4.1f%%)\n",t3_2_fftprocess_ligand_fft , 100.0*t3_2_fftprocess_ligand_fft /total_time); 116 | printf(" | Convolution = %8.2f sec. (%4.1f%%)\n",t3_3_fftprocess_convolution , 100.0*t3_3_fftprocess_convolution /total_time); 117 | printf(" | Inverse FFT = %8.2f sec. (%4.1f%%)\n",t3_4_fftprocess_fft_inverse , 100.0*t3_4_fftprocess_fft_inverse /total_time); 118 | printf(" | Sort score (each core) = %8.2f sec. (%4.1f%%)\n",t3_5_fftprocess_score_sort , 100.0*t3_5_fftprocess_score_sort /total_time); 119 | printf(" | Sort score (merge) = %8.2f sec. (%4.1f%%)\n",t3_6_fftprocess_sort_index , 100.0*t3_6_fftprocess_sort_index /total_time); 120 | #ifdef PHI 121 | printf(" | Data transfer = %8.2f sec. (%4.1f%%)\n",t7_offload_transfer , 100.0*t7_offload_transfer /total_time); 122 | #endif 123 | printf("CPU time (detailed output) = %8.2f sec. (%4.1f%%)\n",t4_docking_output_detail , 100.0*t4_docking_output_detail /total_time); 124 | printf("CPU time (output) = %8.2f sec. (%4.1f%%)\n",t5_docking_output , 100.0*t5_docking_output /total_time); 125 | 126 | return; 127 | } 128 | -------------------------------------------------------------------------------- /doc/README.md: -------------------------------------------------------------------------------- 1 | # Command Guide 2 | 3 | This documentation show the command usage and examples for protein-protein docking calculation using MEGADOCK. 4 | If you do not have any MEGADOCK binary, please read the build documentation ([doc/BUILD.md](./BUILD.md)). 5 | 6 | > Note: The sample input files (`.pdb`, `.table`) are stored in `data` directory. 7 | 8 | 9 | ## Section Link 10 | 11 | Please select your target environment and check the command example. 12 | 13 | | Type | Target Env. | Binary | Note 14 | |:----:|-----------------|--------------------| :- 15 | | (a) | [GPU cluster](#command-for-multiple-nodes-environment) | `megadock-gpu-dp` | multiple nodes 16 | | (b) | [CPU cluster](#command-for-multiple-nodes-environment) | `megadock-dp` | multiple nodes 17 | | (c) | [GPU node](#command-for-single-node-environment) | `megadock-gpu` | single node 18 | | (d) | [CPU node](#command-for-single-node-environment) | `megadock` | single node 19 | 20 | Other Commands: 21 | 22 | | Command | Note 23 | | :- | :- 24 | | `decoygen` | [Generate decoy pdb files from docking output](#Generate-decoy-from-docking-output) 25 | | `block` | [Blocking target residues](#Blocking-target-residues) 26 | | `ppiscore` | [Protein-Protein interaction prediction](#Protein-Protein-interaction-prediction) 27 | 28 | ---- 29 | 30 | # Command for Single Node Environment 31 | 32 | Target Environments: 33 | - (c) Compile for GPU node (GPU) 34 | - (d) Compile for CPU node (only thread parallelization) 35 | 36 | ## Command example 37 | 38 | ```sh 39 | # (c) GPU single node 40 | ./megadock-gpu -R receptor.pdb -L ligand.pdb -o receptor-ligand.out 41 | 42 | # (d) CPU single node 43 | ./megadock -R receptor.pdb -L ligand.pdb -o receptor-ligand.out 44 | ``` 45 | 46 | ### Run small sample 47 | 48 | ```sh 49 | # (c) GPU single node 50 | ./megadock-gpu -R data/1gcq_r.pdb -L data/1gcq_l.pdb -o data/1gcq_r-1gcq_l.out 51 | 52 | # (d) CPU single node 53 | ./megadock -R data/1gcq_r.pdb -L data/1gcq_l.pdb -o data/1gcq_r-1gcq_l.out 54 | ``` 55 | 56 | ## Parameters for docking calculation 57 | 58 | | Required | Note 59 | | :-------------------| :- 60 | | `-R [filename]` | receptor pdb file (input) 61 | | `-L [filename]` | ligand pdb file (input) 62 | 63 | 64 | | Optional | default | Note 65 | | :------------------------ | :------------ | :-- 66 | | `-o [filename]` | $R-$L.out | output filename (output) 67 | | `-O` | | output docking detail files 68 | | `-N [integer]` | 2000 | set the number of output predictions 69 | | `-t [integer]` | 1 | set the number of predictions per each rotation 70 | | `-F [integer]` | | set the number of FFT point (default: none) 71 | | `-v [float]` | 1.2 (angstrom)| set the voxel pitch size 72 | | `-D` | | set the 6 deg. (54000 angles) of rotational sampling (default to none, 15 deg. (3600 angles) of rotational sampling) 73 | | `-r [integer]` | 3600 | set the number of rotational sampling angles (54000: 54000 angles, 1: 1 angles, 24: 24 angles, default to 3600 angles) 74 | | `-e [float]` | 1.0 | set the electrostatics term ratio 75 | | `-d [float]` | 1.0 | set the hydrophobic term ratio 76 | | `-a [float]` | -45.0 | set the rPSC receptor core penalty 77 | | `-b [float]` | 1.0 | set the rPSC ligand core penalty 78 | | `-f [1/2/3]` | 3 | set function (1: rPSC only, 2: rPSC+Elec, 3: rPSC+Elec+RDE, default to 3) 79 | | `-h` | | show command help 80 | 81 | 82 | ---- 83 | 84 | # Command for Multiple Nodes Environment 85 | 86 | Target Environments: 87 | - (a) Compile for GPU cluster (GPU & MPI) 88 | - (b) Compile for CPU cluster (MPI) 89 | 90 | ## Command example 91 | 92 | ```sh 93 | # (a) GPU & MPI (e.g. 4 MPI processes) 94 | mpirun -n 4 ./megadock-gpu-dp -tb data/SAMPLE.table 95 | 96 | # (b) CPU & MPI (e.g. 4 MPI processes) 97 | mpirun -n 4 ./megadock-dp -tb data/SAMPLE.table 98 | ``` 99 | 100 | 101 | ## Parameters for parallel execution 102 | 103 | | Required | Note 104 | | :----------------------------| :- 105 | | `-tb [filename] ` | docking table (.table) 106 | 107 | 108 | | Optional | default | Note 109 | | :------------------------ | :------------ | :-- 110 | | `-lg [filename]` | master.log | log filename 111 | | `-rt [integer]` | 0 | the number of retries 112 | 113 | 114 | ## Example of docking table (.table) 115 | 116 | Parameters and docking target list should be written in a text file. 117 | A table file should have `TITLE` and `PARAM` lines followed by parameters listed by the same order as in the `PARAM` line. 118 | `SAMPLE.table` file in this package shows an example. 119 | 120 | - [data/SAMPLE.table](data/SAMPLE.table) 121 | 122 | ``` 123 | TITLE=sample jobs 124 | PARAM=-R $1 -L $2 -O 125 | data/1gcq_r.pdb data/1gcq_r.pdb 126 | data/1gcq_r.pdb data/1gcq_l.pdb 127 | data/1gcq_l.pdb data/1gcq_r.pdb 128 | data/1gcq_l.pdb data/1gcq_l.pdb 129 | ``` 130 | 131 | You can specify docking parameters loaded by MEGADOCK by setting `PARAM` in the table file. 132 | Lines follows the `PARAM` lines specifies parameters for each docking job which will be distributed to available nodes by MPI. 133 | 134 | ### More details about parameters for each docking calculation 135 | 136 | - [See above section](#Parametersfor-docking-calculation) 137 | 138 | ---- 139 | 140 | # Thread parallelization (OpenMP) 141 | 142 | MEGADOCK parallelizes rotation calculations by using OpenMP. 143 | You can specify the number of OpenMP threads for parallel calculations by environmental variable such as `$OMP_NUM_THREADS`. 144 | 145 | ```sh 146 | # e.g.) megadock binary using 8 OpenMP threads 147 | export OMP_NUM_THREADS=8 148 | ./megadock -R data/receptor.pdb -L data/ligand.pdb -o data/receptor_ligand.out 149 | 150 | # e.g.) each MPI process uses 8 OpenMP threads 151 | mpirun -n 4 -x OMP_NUM_THREADS=8 ./megadock-dp -tb data/SAMPLE.table 152 | ``` 153 | 154 | ---- 155 | 156 | 157 | # Generate decoy from docking output 158 | 159 | Each docking job generates docking output file in which rotation angles (x, y, z) of ligand from the initial structure, numbers of voxel translation (x, y, z) from receptor center coordinate and docking scores are listed. 160 | 161 | If you want to generate decoy pdbfiles, please use `decoygen` command. It is generated together with MEGADOCK binary. 162 | 163 | ## Command Usage 164 | 165 | ```sh 166 | ./decoygen [decoy_filename] [used_ligand.pdb] [.outfile] [decoy no.] 167 | ``` 168 | 169 | 170 | ## Command Example 171 | 172 | For example, the megadock output file was generated as `dock.out` using `rec.pdb` as receputer input and `lig.pdb` as ligand output, and you want to **generate 1st ranked decoy**. 173 | 174 | ```sh 175 | # megadock docking calculation 176 | megadock -R rec.pdb -L lig.pdb -o dock.out 177 | 178 | # generate 1st ranked decoy 179 | ./decoygen lig.1.pdb lig.pdb dock.out 1 180 | cat rec.pdb lig.1.pdb > decoy.1.pdb 181 | 182 | # lig.1.pdb : rotated and translated lig.pdb 183 | # decoy.1.pdb : complex pdb file 184 | ``` 185 | 186 | If you want to generate all decoys; 187 | 188 | ```sh 189 | # megadock docking calculation 190 | megadock -R rec.pdb -L lig.pdb -o dock.out 191 | 192 | # generate all decoys 193 | for i in `seq 1 2000`; do ./decoygen lig.${i}.pdb lig.pdb dock.out $i; cat rec.pdb lig.${i}.pdb > decoy.${i}.pdb; done 194 | ``` 195 | 196 | ---- 197 | 198 | # Blocking target residues 199 | 200 | `block` tool (python script) is to block some residues of a receptor protein from docking. 201 | If you know that some residues are not in the binding sides, please list their residue numbers and input `block` tool. 202 | This program changes the name of residues to "BLK" and prints the new pdb on the screen. 203 | 204 | ```sh 205 | ./block [pdbfile] [chain] [target residue list] 206 | # ex) 207 | # ./block 1gcq_r.pdb B 182-186,189,195-198,204 > blocked.pdb 208 | ``` 209 | 210 | Target residues list is separated by commas and no spaces. 211 | You can also use `-` (hyphen): "182-186" means blocking residues of 182, 183, ..., 186. 212 | Blocked residues are substituted for 'BLK'. 213 | Updated PDB coordinates are written to "standard output". MEGADOCK can only block receptor residues. 214 | 215 | ---- 216 | 217 | # Protein-Protein interaction prediction 218 | 219 | You can calculates the evaluated value of Protein-Protein Interaction scores (PPI score) by using `ppiscore` command which is written in perl script. 220 | 221 | ## Command Example 222 | 223 | ```sh 224 | # 1. Docking calculation using MEGADOCK with `-t=3` option 225 | megadock -R rec.pdb -L lig.pdb -o dock.out -t 3 -N 10800 226 | 227 | # -t: the number of predictions per each rotation 228 | # -N: the number of output predictions 229 | 230 | 231 | # 2. Output PPI score 232 | ./ppiscore dock.out 10800 233 | ``` 234 | 235 | ### Note 236 | 237 | `ppiscore` is compatible with re-ranking tools to get better docking candidates (e.g. [ZRANK1](http://zdock.umassmed.edu/software/)) and those tools can be used for the output files of docking calculation using megadock. 238 | If you want to use such reranking tools, please refer to [our website documentation](http://www.bi.cs.titech.ac.jp/megadock/ppi.html). 239 | 240 | For more details about `ppiscore`, please check [our webpage documentation](http://www.bi.cs.titech.ac.jp/megadock/ppi.html) or following references. 241 | 242 | ---- 243 | 244 | 245 | ## References 246 | 247 | - Masahito Ohue, Takehiro Shimoda, Shuji Suzuki, Yuri Matsuzaki, Takashi Ishida, Yutaka Akiyama. MEGADOCK 4.0: an ultra-high-performance protein-protein docking software for heterogeneous supercomputers. Bioinformatics, 30(22), 3281-3283, 2014. 248 | 249 | - Masahito Ohue, Yuri Matsuzaki, Nobuyuki Uchikoga, Takashi Ishida, Yutaka Akiyama. MEGADOCK: An all-to-all protein-protein interaction prediction system using tertiary structure data. Protein and Peptide Letters, 21(8), 766-778, 2014. 250 | 251 | - Takehiro Shimoda, Takashi Ishida, Shuji Suzuki, Masahito Ohue, Yutaka Akiyama. MEGADOCK-GPU: An accelerated protein-protein docking calculation on GPUs. In Proc. ACM-BCB 2013 (ParBio Workshop 2013), 884-890, 2013. 252 | 253 | - Yuri Matsuzaki, Nobuyuki Uchikoga, Masahito Ohue, Takehiro Shimoda, Toshiyuki Sato, Takashi Ishida, Yutaka Akiyama. MEGADOCK 3.0: A high-performance protein-protein interaction prediction software using hybrid parallel computing for petascale supercomputing environments. Source Code for Biology and Medicine, 8(1): 18, 2013. 254 | 255 | - Masahito Ohue, Yuri Matsuzaki, Takashi Ishida, Yutaka Akiyama. Improvement of the Protein-Protein Docking Prediction by Introducing a Simple Hydrophobic Interaction Model: an Application to Interaction Pathway Analysis. Lecture Note in Bioinformatics 7632 (In Proc. of PRIB 2012), 178-187, Springer Heidelberg, 2012. 256 | 257 | ---- 258 | 259 | ## Contact 260 | 261 | - Email : megadock@bi.c.titech.ac.jp 262 | - URL : http://www.bi.cs.titech.ac.jp/megadock 263 | -------------------------------------------------------------------------------- /src/ligand.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : Ligand 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #include "ligand.h" 16 | #include 17 | #include 18 | 19 | //============================================================================// 20 | void Ligand::rpscace(const float &aceratio, const int &num_grid,float *grid_coord, 21 | float *atom_coord_rotated, int *iwork, float *fwork, 22 | const float ¶m_rec_core, const float ¶m_lig_core,const int &old_voxel_flag) 23 | //============================================================================// 24 | { 25 | const float delta = param_lig_core; // Tuning Parameter 26 | const float surface = 1.0; // grid-assignment score (protein surface) 27 | const float swollen_surface = -8888.0; // temporary score for swollen ligand surface 28 | 29 | int *nearesta; 30 | int *surf_atom; 31 | float *grid_r, *grid_i; 32 | float *rjudge2, *radius_core2, *radius_surf2; 33 | float *distance3; 34 | float *xd, *yd, *zd; 35 | 36 | const int ng1 = num_grid; 37 | const int ng2 = ng1 * ng1; 38 | const int ng3 = ng1 * ng1 * ng1; 39 | const int na = num_atoms(); 40 | const int nag = num_atoms() * ng1; 41 | 42 | nearesta = iwork; 43 | surf_atom = &iwork[ng3]; 44 | grid_r = fwork; 45 | grid_i = &fwork[ng3]; 46 | rjudge2 = &fwork[ng3*2]; 47 | radius_core2 = &fwork[ng3*2+na]; 48 | radius_surf2 = &fwork[ng3*2+na*2]; 49 | distance3 = &fwork[ng3*2+na*3]; 50 | xd = &fwork[ng3*3+na*3]; 51 | yd = &fwork[ng3*3+na*3+nag]; 52 | zd = &fwork[ng3*3+na*3+nag*2]; 53 | 54 | precalc(ng1,nearesta,rjudge2,radius_core2,radius_surf2); 55 | voxel_init(ng1,grid_coord,atom_coord_rotated,grid_r,grid_i,distance3,xd,yd,zd); 56 | 57 | 58 | // ############################## 59 | // #fill up grid by atom-sphere # 60 | // ############################## 61 | // 62 | // Reason for search_range = 2 63 | // search_range means the range of searching grids(around atom) 64 | // If search_range = 2 and nearest grid is (10,5,-2), search from (8,3,-4) to (12,7,0) as rectangular 65 | // In the 3 next grid, distance between grid and atom is 3A (2*1.2A + 1.2A/2) 66 | // 2 is enough because max VdW radius (charmm) is 2.13A and rcore2 = 1.5, so 2.13A * sqrt(1.5) = 2.61A < 3A 67 | 68 | for( int l = 0 ; l < na ; l++ ) {// atom-grid assignment 69 | const int search_range = 2; 70 | const int lc = ng1 * l; 71 | const int i2 = atom_coord_rotated[3*l ] / grid_width + ng1 / 2; 72 | const int j2 = atom_coord_rotated[3*l+1] / grid_width + ng1 / 2; 73 | const int k2 = atom_coord_rotated[3*l+2] / grid_width + ng1 / 2; 74 | const int ia = max(i2 - search_range, 0); 75 | const int ja = max(j2 - search_range, 0); 76 | const int ka = max(k2 - search_range, 0); 77 | const int ib = min(i2 + search_range+1, ng1); 78 | const int jb = min(j2 + search_range+1, ng1); 79 | const int kb = min(k2 + search_range+1, ng1); 80 | 81 | for( int i = ia ; i < ib ; i++ ) {// grid around atom[l] 82 | if(xd[lc+i] > radius_core2[l]) continue; 83 | const int ib=ng2*i; 84 | 85 | for( int j = ja ; j < jb ; j++ ) { 86 | const float d2 = xd[lc+i]+yd[lc+j]; 87 | const int ij=ib+ng1*j; 88 | if(d2 > radius_core2[l]) continue; 89 | 90 | for( int k = ka ; k < kb ; k++ ) { 91 | const float d3 = d2 + zd[lc+k]; 92 | if( d3 < radius_core2[l] ) {// distance(grid-atom) < Van der Waals radius (* core) 93 | 94 | grid_r[ij+k] = delta; // grid[i] is filled up by atom[l] 95 | 96 | } 97 | } 98 | } 99 | } 100 | } 101 | 102 | // ############################ 103 | // # scrape swollen surface # 104 | // ############################ 105 | // 106 | // 1. scrape surface grid (1 or 2 layer) because protein surface is swollen due to radius_core2 107 | // 2. re-assign score by radius_surf2 in [make protein surface] 108 | 109 | 110 | for(int i=1; i radius_surf2[l]) continue; 155 | const int ib=ng2*i; 156 | 157 | for( int j = ja ; j < jb ; j++ ) { 158 | const float d2 = xd[lc+i]+yd[lc+j]; 159 | const int ij=ib+ng1*j; 160 | if(d2 > radius_surf2[l]) continue; 161 | 162 | for( int k = ka ; k < kb ; k++ ) { 163 | const int ijk = ij+k; 164 | if(grid_r[ijk]==delta) continue; 165 | 166 | const float d3 = d2 + zd[lc+k]; 167 | if( d3 < radius_surf2[l] ) {// distance(grid-atom) < Van der Waals radius (* surf) 168 | grid_r[ijk] = surface; // grid[i] is filled up by atom[l] 169 | } 170 | } 171 | } 172 | } 173 | } 174 | 175 | 176 | if(surface!=delta) {// convert surface grid (next to open space) to [1] 177 | for(int ijk=ng2; ijk %f)\n",i,j,k,grid_i[i*ng2+j*ng1+k],_Charge[l]); 231 | } 232 | */ 233 | grid_i[i*ng2+j*ng1+k] += _Charge[l]; 234 | } 235 | //for(int i=0;i 17 | #include 18 | 19 | //============================================================================// 20 | void Receptor::rpscace(const float &aceratio, const int &num_grid, float *grid_coord, 21 | float *atom_coord_rotated, int *iwork, float *fwork, 22 | const float ¶m_rec_core, const float ¶m_lig_core,const int &old_voxel_flag) 23 | //============================================================================// 24 | { 25 | const float rho = -3.0; // MEGADOCK parameter 26 | const float epsilon = param_rec_core; // Tuning Parameter 27 | const float open_space = -7777.0; // temporary score for open space 28 | 29 | int *nearesta; 30 | int *surf_atom; 31 | int *counter; 32 | float *grid_r, *grid_i; 33 | float *rjudge2, *radius_core2, *radius_surf2; 34 | float *distance3; 35 | float *xd, *yd, *zd; 36 | 37 | const int ng1 = num_grid; 38 | const int ng2 = ng1 * ng1; 39 | const int ng3 = ng1 * ng1 * ng1; 40 | const int na = num_atoms(); 41 | const int nag = num_atoms() * ng1; 42 | 43 | float *voxel_rpscace; 44 | voxel_rpscace = new float[ng3]; 45 | 46 | memset(voxel_rpscace, 0.0, sizeof(float)*ng3); 47 | memset(fwork, 0.0, sizeof(float)*ng3); 48 | 49 | nearesta = iwork; 50 | surf_atom = &iwork[ng3]; 51 | counter = &iwork[ng3+na]; 52 | grid_r = fwork; 53 | grid_i = &fwork[ng3]; 54 | rjudge2 = &fwork[ng3*2]; 55 | radius_core2 = &fwork[ng3*2+na]; 56 | radius_surf2 = &fwork[ng3*2+na*2]; 57 | distance3 = &fwork[ng3*2+na*3]; 58 | xd = &fwork[ng3*3+na*3]; 59 | yd = &fwork[ng3*3+na*3+nag]; 60 | zd = &fwork[ng3*3+na*3+nag*2]; 61 | 62 | precalc(ng1,nearesta,rjudge2,radius_core2,radius_surf2); 63 | voxel_init(ng1,grid_coord,atom_coord_rotated,grid_r,grid_i,distance3,xd,yd,zd); 64 | 65 | 66 | // ############################## 67 | // #fill up grid by atom-sphere # 68 | // ############################## 69 | 70 | for( int l = 0 ; l < na ; l++ ) {// atom-grid assignment 71 | //const int search_range = 2; 72 | const int search_range = (2.4 + grid_width -0.01) / grid_width; 73 | const int lc = ng1 * l; 74 | const int i2 = atom_coord_rotated[3*l ] / grid_width + ng1 / 2; 75 | const int j2 = atom_coord_rotated[3*l+1] / grid_width + ng1 / 2; 76 | const int k2 = atom_coord_rotated[3*l+2] / grid_width + ng1 / 2; 77 | const int ia = max(i2 - search_range, 0); 78 | const int ja = max(j2 - search_range, 0); 79 | const int ka = max(k2 - search_range, 0); 80 | const int ib = min(i2 + search_range+1, ng1); 81 | const int jb = min(j2 + search_range+1, ng1); 82 | const int kb = min(k2 + search_range+1, ng1); 83 | 84 | for( int i = ia ; i < ib ; i++ ) {// grid around atom[l] 85 | if(xd[lc+i] > radius_core2[l]) continue; 86 | 87 | for( int j = ja ; j < jb ; j++ ) { 88 | const float d2 = xd[lc+i]+yd[lc+j]; 89 | if(d2 > radius_core2[l]) continue; 90 | const int ij=ng2*i+ng1*j; 91 | 92 | for( int k = ka ; k < kb ; k++ ) { 93 | const float d3 = xd[lc+i] + yd[lc+j] + zd[lc+k]; 94 | if( d3 < radius_core2[l] ) {// distance(grid-atom) < Van der Waals radius (* core) 95 | grid_r[ij+k] = epsilon; // grid[i] is filled up by atom[l] 96 | } 97 | } 98 | } 99 | } 100 | } 101 | 102 | // ##################### 103 | // #fill up cavity # 104 | // ##################### 105 | 106 | for (int ij=0; ij=0; k--) {// X, backward 119 | if(grid_r[i+ng1*j+ng2*k]!=epsilon) { 120 | grid_r[i+ng1*j+ng2*k]=open_space; 121 | } else { 122 | break; 123 | } 124 | } 125 | 126 | for (int k=0; k=0; k--) {// Y, backward 135 | if(grid_r[k+ng1*i+ng2*j]!=epsilon) { 136 | grid_r[k+ng1*i+ng2*j]=open_space; 137 | } else { 138 | break; 139 | } 140 | } 141 | 142 | for (int k=0; k=0; k--) {// Z, backward 151 | if(grid_r[j+ng1*k+ng2*i]!=epsilon) { 152 | grid_r[j+ng1*k+ng2*i]=open_space; 153 | } else { 154 | break; 155 | } 156 | } 157 | } 158 | 159 | for (int ink=0; ink<2; ink++) {// fill up cavity (phase1, 2/2) 160 | 161 | for (int ijk=ng2; ijkng1-2) continue; // skip border 165 | const int k = ijk % ng1; 166 | if(k<2||k>ng1-2) continue; // skip border 167 | 168 | if(grid_r[ijk]==open_space) { 169 | if(grid_r[ijk+1]==0) { 170 | grid_r[ijk+1]=open_space; 171 | } 172 | if(grid_r[ijk-1]==0) { 173 | grid_r[ijk-1]=open_space; 174 | } 175 | if(grid_r[ijk+ng1]==0) { 176 | grid_r[ijk+ng1]=open_space; 177 | } 178 | if(grid_r[ijk-ng1]==0) { 179 | grid_r[ijk-ng1]=open_space; 180 | } 181 | if(grid_r[ijk+ng2]==0) { 182 | grid_r[ijk+ng2]=open_space; 183 | } 184 | if(grid_r[ijk-ng2]==0) { 185 | grid_r[ijk-ng2]=open_space; 186 | } 187 | } 188 | } 189 | } 190 | 191 | 192 | for(int i=0; i rjudge2[l]) continue; 225 | 226 | for( int j = ja ; j < jb ; j++ ) { 227 | const float d2 = xd[lc+i]+yd[lc+j]; 228 | if(d2 > rjudge2[l]) continue; 229 | const int ij = ng2*i+ng1*j; 230 | 231 | for( int k = ka ; k < kb ; k++ ) { 232 | const int ijk = ij+k; 233 | const float d3 = xd[lc+i] + yd[lc+j] + zd[lc+k]; 234 | 235 | if( d3 < rjudge2[l]) {// distance(grid-atom) < Van der Waals radius + cutoff D(=3.6ang) 236 | //counter[ijk] ++; // grid[i] is filled up by atom[l] 237 | voxel_rpscace[ijk] += 1.0 + _ACE[l] * (-0.8) * aceratio; 238 | // rPSC value(1.0) + ACE value (0.8 is weight parameter) * w_h 239 | } 240 | } 241 | } 242 | } 243 | } 244 | 245 | for( int ijk = 0 ; ijk < ng3 ; ijk++ ) { 246 | if( grid_r[ijk]==epsilon ) continue; 247 | 248 | grid_r[ijk] = voxel_rpscace[ijk]; 249 | } 250 | 251 | delete[] voxel_rpscace; 252 | 253 | return; 254 | } 255 | 256 | 257 | //============================================================================// 258 | void Receptor::electro(const float &beta,const float &eratio, 259 | const int &num_grid,float *grid_coord,float *atom_coord_rotated, 260 | int *iwork,float *fwork,const int &old_voxel_flag) 261 | //============================================================================// 262 | { 263 | const float ftr1 = 6.0; // FTDock parameter 264 | const float ftr2 = 8.0; // FTDock parameter 265 | const float er1 = 4.0; // FTDock parameter 266 | const float er2 = 38.0; // FTDock parameter 267 | const float er3 = -224.0; // FTDock parameter 268 | const float er4 = 80.0; // FTDock parameter 269 | 270 | float *grid_r; 271 | float *grid_i; 272 | const float *xd, *yd, *zd; 273 | 274 | const int ng1 = num_grid; 275 | const int ng2 = ng1 * ng1; 276 | const int ng3 = ng1 * ng1 * ng1; 277 | const int na = num_atoms(); 278 | const int nag = num_atoms() * ng1; 279 | 280 | int search_range; 281 | float er, d3; 282 | 283 | grid_r = fwork; 284 | grid_i = &fwork[ng3]; 285 | xd = &fwork[ng3*3+na*3]; 286 | yd = &fwork[ng3*3+na*3+nag]; 287 | zd = &fwork[ng3*3+na*3+nag*2]; 288 | 289 | 290 | const float grid_width = grid_coord[1] - grid_coord[0]; 291 | const float charge_per_grid = -1 * grid_width * er4 / (beta * eratio);//formula derived from e(r) (r>8A) 292 | 293 | for( int l = 0 ; l < na ; l++ ) { 294 | const float abs_charge = fabs(_Charge[l]); 295 | if( abs_charge <= EPS ) continue; 296 | 297 | if (abs_charge < 0.07) { //hardcode (Gridsize = 1.2A) 298 | search_range = 4; 299 | } else if (abs_charge < 0.21) { 300 | search_range = 5; 301 | } else { 302 | search_range = (int)(abs_charge / charge_per_grid); 303 | } 304 | 305 | const int lc = ng1 * l; 306 | const int i2 = atom_coord_rotated[3*l ] / grid_width + ng1 / 2; //limit search range 307 | const int j2 = atom_coord_rotated[3*l+1] / grid_width + ng1 / 2; 308 | const int k2 = atom_coord_rotated[3*l+2] / grid_width + ng1 / 2; 309 | const int ia = max(i2 - search_range, 0); 310 | const int ja = max(j2 - search_range, 0); 311 | const int ka = max(k2 - search_range, 0); 312 | const int ib = min(i2 + search_range+1, ng1); 313 | const int jb = min(j2 + search_range+1, ng1); 314 | const int kb = min(k2 + search_range+1, ng1); 315 | 316 | for( int i = ia ; i < ib ; i++ ) {// grid around atom[l] 317 | const int ijk_a = ng2 * i; 318 | 319 | for( int j = ja ; j < jb ; j++ ) { 320 | const int ijk_b = ijk_a + ng1 * j; 321 | const float d2 = xd[lc+i]+yd[lc+j]; 322 | 323 | for( int k = ka ; k < kb ; k++ ) { 324 | const int ijk = ijk_b + k; 325 | 326 | if( grid_r[ijk] < 0.0 ) continue; //this grid is core of receptor 327 | 328 | d3 = d2 + zd[lc+k]; 329 | d3 = sqrt(d3); 330 | 331 | if( d3 >= ftr2 ) { 332 | er = er4; 333 | } else if( d3 > ftr1 ) { 334 | er = er2*d3 + er3; 335 | } else { 336 | er = er1; 337 | } 338 | const float elec = eratio * beta * _Charge[l] / er / d3; 339 | grid_i[ijk] += elec; 340 | } 341 | } 342 | } 343 | } 344 | 345 | return; 346 | } 347 | 348 | //============================================================================// 349 | void Receptor::precalc(const int &num_grid,int *nearesta,float *rjudge2, 350 | float *radius_core2,float *radius_surf2) 351 | //============================================================================// 352 | { 353 | const float D = 3.6; 354 | const float rcore2 = 1.5; 355 | const float rsurf2 = 0.8; 356 | 357 | const int na = num_atoms(); 358 | const int ng1 = num_grid; 359 | const int ng3 = ng1 * ng1 * ng1; 360 | 361 | for( int i = 0 ; i < na ; i++ ) { 362 | rjudge2[i] = (_Radius[i] + D)*(_Radius[i] + D); 363 | radius_core2[i] = _Radius[i] * _Radius[i] * rcore2; 364 | radius_surf2[i] = _Radius[i] * _Radius[i] * rsurf2; 365 | } 366 | 367 | for( int i = 0 ; i < ng3 ; i++ ) { 368 | nearesta[i] = -99; 369 | } 370 | 371 | return; 372 | } 373 | -------------------------------------------------------------------------------- /src/cuda_kernel.cu: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // cuda_kernel.cu 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #include 16 | #define FMAX(a,b) ( ((a)>(b) ) ? (a) : (b) ) 17 | #define FMIN(a,b) ( ((a)>(b) ) ? (b) : (a) ) 18 | 19 | __global__ void lig_vox_fill(int ng1 20 | ,int na 21 | ,float delta 22 | ,float *radius2 23 | ,float *xd 24 | ,float *yd 25 | ,float *zd 26 | ,float *grid_coord 27 | ,float *atom_coord_rotated 28 | ,float *grid_r 29 | ,float grid_width) 30 | { 31 | const int id = blockIdx.x * blockDim.x + threadIdx.x; 32 | const int ng2 = ng1 * ng1; 33 | //const int ng3 = ng2 * ng1; 34 | 35 | if(id < na) { 36 | //const int search_range = 2; 37 | const int search_range = (2.4 + grid_width -0.01) / grid_width; 38 | const int lc = ng1 * id; 39 | const int id3 = id * 3; 40 | const int i2 = atom_coord_rotated[id3 ] / grid_width + ng1 / 2; 41 | const int j2 = atom_coord_rotated[id3+1] / grid_width + ng1 / 2; 42 | const int k2 = atom_coord_rotated[id3+2] / grid_width + ng1 / 2; 43 | const int ia = FMAX(i2 - search_range, 0); 44 | const int ja = FMAX(j2 - search_range, 0); 45 | const int ka = FMAX(k2 - search_range, 0); 46 | const int ib = FMIN(i2 + search_range+1, ng1); 47 | const int jb = FMIN(j2 + search_range+1, ng1); 48 | const int kb = FMIN(k2 + search_range+1, ng1); 49 | 50 | for( int i = ia ; i < ib ; i++ ) {// grid around atom[l] 51 | if(xd[lc+i] > radius2[id]) continue; 52 | for( int j = ja ; j < jb ; j++ ) { 53 | const float d2 = xd[lc+i]+yd[lc+j]; 54 | if(d2 > radius2[id]) continue; 55 | const int ij = ng2*i+ng1*j; 56 | for( int k = ka ; k < kb ; k++ ) { 57 | const float d3 = d2 + zd[lc+k]; 58 | if( d3 < radius2[id] ) {// distance(grid-atom) < Van der Waals radius (* core) 59 | grid_r[ij+k] = delta; // grid[i] is filled up by atom[l] 60 | } 61 | } 62 | } 63 | } 64 | } 65 | //*/ 66 | } 67 | 68 | 69 | __global__ void lig_rotation(int na, float *theta, float *atom_coord_orig, float *mole_center_coord, float *atom_coord_rotated) 70 | { 71 | const int id = blockIdx.x * blockDim.x + threadIdx.x; 72 | 73 | const float r11 = cos(theta[0])*cos(theta[2]) - sin(theta[0])*cos(theta[1])*sin(theta[2]); 74 | const float r21 = sin(theta[0])*cos(theta[2]) + cos(theta[0])*cos(theta[1])*sin(theta[2]); 75 | const float r31 = sin(theta[1])*sin(theta[2]); 76 | const float r12 = -cos(theta[0])*sin(theta[2]) - sin(theta[0])*cos(theta[1])*cos(theta[2]); 77 | const float r22 = -sin(theta[0])*sin(theta[2]) + cos(theta[0])*cos(theta[1])*cos(theta[2]); 78 | const float r32 = sin(theta[1])*cos(theta[2]); 79 | const float r13 = sin(theta[0])*sin(theta[1]); 80 | const float r23 = -cos(theta[0])*sin(theta[1]); 81 | const float r33 = cos(theta[1]); 82 | 83 | if(id < na) { 84 | const int id3 = id * 3; 85 | float x, y, z; 86 | 87 | x = atom_coord_orig[id3 ] - mole_center_coord[0]; 88 | y = atom_coord_orig[id3+1] - mole_center_coord[1]; 89 | z = atom_coord_orig[id3+2] - mole_center_coord[2]; 90 | atom_coord_rotated[id3 ] = r11 * x + r12 * y + r13 * z; 91 | atom_coord_rotated[id3+1] = r21 * x + r22 * y + r23 * z; 92 | atom_coord_rotated[id3+2] = r31 * x + r32 * y + r33 * z; 93 | } 94 | } 95 | 96 | 97 | __global__ void lig_calc_dis_atomgrid(int na, int ng1, float *xd, float *yd, float *zd, float *grid_coord, float *atom_coord_rotated) 98 | { 99 | const int id = blockIdx.x * blockDim.x + threadIdx.x; 100 | const int nag = na * ng1; 101 | if(id < nag) { 102 | const int cur_atom = (id / ng1); 103 | const int cur_atom3 = cur_atom * 3; 104 | const int cur_grid = id % ng1; 105 | xd[id] = atom_coord_rotated[cur_atom3 ] - grid_coord[cur_grid]; 106 | yd[id] = atom_coord_rotated[cur_atom3+1] - grid_coord[cur_grid]; 107 | zd[id] = atom_coord_rotated[cur_atom3+2] - grid_coord[cur_grid]; 108 | xd[id] *= xd[id]; 109 | yd[id] *= yd[id]; 110 | zd[id] *= zd[id]; 111 | } 112 | } 113 | 114 | __global__ void lig_vox_init_grid(int ng3,float *grid_r,float *grid_i) 115 | { 116 | const int id = blockIdx.x * blockDim.x + threadIdx.x; 117 | if(id < ng3) { //initialize 118 | grid_r[id]=0.0; 119 | grid_i[id]=0.0; 120 | } 121 | } 122 | 123 | __global__ void lig_vox_init_fft(int nf3,cufftComplex *lig_in) 124 | { 125 | const int id = blockIdx.x * blockDim.x + threadIdx.x; 126 | if(id < nf3) { //initialize 127 | lig_in[id] = make_cuComplex( 0.0, 0.0); 128 | //lig_in[id].x=0.0; 129 | //lig_in[id].y=0.0; 130 | } 131 | } 132 | 133 | __global__ void ligand_voxel_set(int ng1 134 | ,cufftComplex *lig_in 135 | ,float *grid_r 136 | ,float *grid_i) 137 | { 138 | const int id = blockIdx.x * blockDim.x + threadIdx.x; 139 | const int ng2 = ng1 * ng1; 140 | const int ng3 = ng2 * ng1; 141 | const int nf1 = ng1 * 2; 142 | const int nf2 = nf1 * nf1; 143 | const int ng1_half = ng1 / 2; 144 | const float surface = 1.0; // grid-assignment score (protein surface) 145 | 146 | //if(id == 0) for(int i=0;i 0; offset /= 2) { 286 | if (thr_id < offset) { 287 | sdata[thr_id] = FMAX(sdata[thr_id], sdata[thr_id + offset]); 288 | } 289 | __syncthreads(); 290 | } 291 | 292 | if (mscore == sdata[0]) {//mscore specify position of max score 293 | score[blockIdx.x] = sdata[0]; 294 | pos[blockIdx.x] = id; 295 | //printf(" BLOCK ID:%d, sdata[0]=%f, pos=%d\n",blockIdx.x,sdata[0],id); 296 | } 297 | } 298 | } 299 | 300 | __global__ void max_pos_multi_set(int nf3, cufftComplex *out, float *temp_score, int *temp_index) 301 | { 302 | const int id = blockIdx.x * blockDim.x + threadIdx.x; 303 | if(id < nf3) { 304 | temp_score[id] = out[id].x; 305 | temp_index[id] = id; 306 | } 307 | } 308 | 309 | //, std::vector *temp_result , thrust::vector *temp_result 310 | //thrust::device_ptr *temp_result cufftComplex *temp_result,thrust::device_ptr temp_result 311 | __global__ void max_pos_multi(int nf3, cufftComplex *out, float *score, int *pos,const int num_sort,const int offset) 312 | { 313 | const int id = blockIdx.x * blockDim.x + threadIdx.x; 314 | if (id < offset) { 315 | if (out[id].x < out[id+offset].x) { 316 | out[id].x = out[id+offset].x; 317 | out[id].y = out[id+offset].y; 318 | } 319 | /* 320 | if(id==0) { 321 | for(int i=0; i num_sort; ) { 356 | offset /= 2; 357 | if (thr_id < offset) { 358 | sdata[thr_id] = FMAX(sdata[thr_id], sdata[thr_id + offset]); 359 | } 360 | //if(id<1)printf(" id=%d, t=%d, off=%d\n",id,num_sort,offset); 361 | __syncthreads(); 362 | } 363 | //if(id<1)printf(" [last] id=%d, t=%d, off=%d\n",id,num_sort,offset); 364 | 365 | //thrust::sort(sdata,sdata+10); 366 | 367 | if(id < num_sort) { 368 | if (mscore == sdata[id]) {//mscore specify position of max score (float equality comparison... amari yokunai) 369 | score[blockIdx.x] = sdata[0]; 370 | pos[blockIdx.x] = id; 371 | //printf(" BLOCK ID:%d, sdata[0]=%f, pos=%d\n",blockIdx.x,sdata[0],i); 372 | } 373 | } 374 | //* 375 | if(temp_score[id] >3000) printf(" id=%d, %f %d\n",id,temp_score[id],temp_index[id]); 376 | } 377 | //* 378 | } 379 | //*/ 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Attribution-NonCommercial 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution-NonCommercial 4.0 International Public 58 | License 59 | 60 | By exercising the Licensed Rights (defined below), You accept and agree 61 | to be bound by the terms and conditions of this Creative Commons 62 | Attribution-NonCommercial 4.0 International Public License ("Public 63 | License"). To the extent this Public License may be interpreted as a 64 | contract, You are granted the Licensed Rights in consideration of Your 65 | acceptance of these terms and conditions, and the Licensor grants You 66 | such rights in consideration of benefits the Licensor receives from 67 | making the Licensed Material available under these terms and 68 | conditions. 69 | 70 | 71 | Section 1 -- Definitions. 72 | 73 | a. Adapted Material means material subject to Copyright and Similar 74 | Rights that is derived from or based upon the Licensed Material 75 | and in which the Licensed Material is translated, altered, 76 | arranged, transformed, or otherwise modified in a manner requiring 77 | permission under the Copyright and Similar Rights held by the 78 | Licensor. For purposes of this Public License, where the Licensed 79 | Material is a musical work, performance, or sound recording, 80 | Adapted Material is always produced where the Licensed Material is 81 | synched in timed relation with a moving image. 82 | 83 | b. Adapter's License means the license You apply to Your Copyright 84 | and Similar Rights in Your contributions to Adapted Material in 85 | accordance with the terms and conditions of this Public License. 86 | 87 | c. Copyright and Similar Rights means copyright and/or similar rights 88 | closely related to copyright including, without limitation, 89 | performance, broadcast, sound recording, and Sui Generis Database 90 | Rights, without regard to how the rights are labeled or 91 | categorized. For purposes of this Public License, the rights 92 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 93 | Rights. 94 | d. Effective Technological Measures means those measures that, in the 95 | absence of proper authority, may not be circumvented under laws 96 | fulfilling obligations under Article 11 of the WIPO Copyright 97 | Treaty adopted on December 20, 1996, and/or similar international 98 | agreements. 99 | 100 | e. Exceptions and Limitations means fair use, fair dealing, and/or 101 | any other exception or limitation to Copyright and Similar Rights 102 | that applies to Your use of the Licensed Material. 103 | 104 | f. Licensed Material means the artistic or literary work, database, 105 | or other material to which the Licensor applied this Public 106 | License. 107 | 108 | g. Licensed Rights means the rights granted to You subject to the 109 | terms and conditions of this Public License, which are limited to 110 | all Copyright and Similar Rights that apply to Your use of the 111 | Licensed Material and that the Licensor has authority to license. 112 | 113 | h. Licensor means the individual(s) or entity(ies) granting rights 114 | under this Public License. 115 | 116 | i. NonCommercial means not primarily intended for or directed towards 117 | commercial advantage or monetary compensation. For purposes of 118 | this Public License, the exchange of the Licensed Material for 119 | other material subject to Copyright and Similar Rights by digital 120 | file-sharing or similar means is NonCommercial provided there is 121 | no payment of monetary compensation in connection with the 122 | exchange. 123 | 124 | j. Share means to provide material to the public by any means or 125 | process that requires permission under the Licensed Rights, such 126 | as reproduction, public display, public performance, distribution, 127 | dissemination, communication, or importation, and to make material 128 | available to the public including in ways that members of the 129 | public may access the material from a place and at a time 130 | individually chosen by them. 131 | 132 | k. Sui Generis Database Rights means rights other than copyright 133 | resulting from Directive 96/9/EC of the European Parliament and of 134 | the Council of 11 March 1996 on the legal protection of databases, 135 | as amended and/or succeeded, as well as other essentially 136 | equivalent rights anywhere in the world. 137 | 138 | l. You means the individual or entity exercising the Licensed Rights 139 | under this Public License. Your has a corresponding meaning. 140 | 141 | 142 | Section 2 -- Scope. 143 | 144 | a. License grant. 145 | 146 | 1. Subject to the terms and conditions of this Public License, 147 | the Licensor hereby grants You a worldwide, royalty-free, 148 | non-sublicensable, non-exclusive, irrevocable license to 149 | exercise the Licensed Rights in the Licensed Material to: 150 | 151 | a. reproduce and Share the Licensed Material, in whole or 152 | in part, for NonCommercial purposes only; and 153 | 154 | b. produce, reproduce, and Share Adapted Material for 155 | NonCommercial purposes only. 156 | 157 | 2. Exceptions and Limitations. For the avoidance of doubt, where 158 | Exceptions and Limitations apply to Your use, this Public 159 | License does not apply, and You do not need to comply with 160 | its terms and conditions. 161 | 162 | 3. Term. The term of this Public License is specified in Section 163 | 6(a). 164 | 165 | 4. Media and formats; technical modifications allowed. The 166 | Licensor authorizes You to exercise the Licensed Rights in 167 | all media and formats whether now known or hereafter created, 168 | and to make technical modifications necessary to do so. The 169 | Licensor waives and/or agrees not to assert any right or 170 | authority to forbid You from making technical modifications 171 | necessary to exercise the Licensed Rights, including 172 | technical modifications necessary to circumvent Effective 173 | Technological Measures. For purposes of this Public License, 174 | simply making modifications authorized by this Section 2(a) 175 | (4) never produces Adapted Material. 176 | 177 | 5. Downstream recipients. 178 | 179 | a. Offer from the Licensor -- Licensed Material. Every 180 | recipient of the Licensed Material automatically 181 | receives an offer from the Licensor to exercise the 182 | Licensed Rights under the terms and conditions of this 183 | Public License. 184 | 185 | b. No downstream restrictions. You may not offer or impose 186 | any additional or different terms or conditions on, or 187 | apply any Effective Technological Measures to, the 188 | Licensed Material if doing so restricts exercise of the 189 | Licensed Rights by any recipient of the Licensed 190 | Material. 191 | 192 | 6. No endorsement. Nothing in this Public License constitutes or 193 | may be construed as permission to assert or imply that You 194 | are, or that Your use of the Licensed Material is, connected 195 | with, or sponsored, endorsed, or granted official status by, 196 | the Licensor or others designated to receive attribution as 197 | provided in Section 3(a)(1)(A)(i). 198 | 199 | b. Other rights. 200 | 201 | 1. Moral rights, such as the right of integrity, are not 202 | licensed under this Public License, nor are publicity, 203 | privacy, and/or other similar personality rights; however, to 204 | the extent possible, the Licensor waives and/or agrees not to 205 | assert any such rights held by the Licensor to the limited 206 | extent necessary to allow You to exercise the Licensed 207 | Rights, but not otherwise. 208 | 209 | 2. Patent and trademark rights are not licensed under this 210 | Public License. 211 | 212 | 3. To the extent possible, the Licensor waives any right to 213 | collect royalties from You for the exercise of the Licensed 214 | Rights, whether directly or through a collecting society 215 | under any voluntary or waivable statutory or compulsory 216 | licensing scheme. In all other cases the Licensor expressly 217 | reserves any right to collect such royalties, including when 218 | the Licensed Material is used other than for NonCommercial 219 | purposes. 220 | 221 | 222 | Section 3 -- License Conditions. 223 | 224 | Your exercise of the Licensed Rights is expressly made subject to the 225 | following conditions. 226 | 227 | a. Attribution. 228 | 229 | 1. If You Share the Licensed Material (including in modified 230 | form), You must: 231 | 232 | a. retain the following if it is supplied by the Licensor 233 | with the Licensed Material: 234 | 235 | i. identification of the creator(s) of the Licensed 236 | Material and any others designated to receive 237 | attribution, in any reasonable manner requested by 238 | the Licensor (including by pseudonym if 239 | designated); 240 | 241 | ii. a copyright notice; 242 | 243 | iii. a notice that refers to this Public License; 244 | 245 | iv. a notice that refers to the disclaimer of 246 | warranties; 247 | 248 | v. a URI or hyperlink to the Licensed Material to the 249 | extent reasonably practicable; 250 | 251 | b. indicate if You modified the Licensed Material and 252 | retain an indication of any previous modifications; and 253 | 254 | c. indicate the Licensed Material is licensed under this 255 | Public License, and include the text of, or the URI or 256 | hyperlink to, this Public License. 257 | 258 | 2. You may satisfy the conditions in Section 3(a)(1) in any 259 | reasonable manner based on the medium, means, and context in 260 | which You Share the Licensed Material. For example, it may be 261 | reasonable to satisfy the conditions by providing a URI or 262 | hyperlink to a resource that includes the required 263 | information. 264 | 265 | 3. If requested by the Licensor, You must remove any of the 266 | information required by Section 3(a)(1)(A) to the extent 267 | reasonably practicable. 268 | 269 | 4. If You Share Adapted Material You produce, the Adapter's 270 | License You apply must not prevent recipients of the Adapted 271 | Material from complying with this Public License. 272 | 273 | 274 | Section 4 -- Sui Generis Database Rights. 275 | 276 | Where the Licensed Rights include Sui Generis Database Rights that 277 | apply to Your use of the Licensed Material: 278 | 279 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 280 | to extract, reuse, reproduce, and Share all or a substantial 281 | portion of the contents of the database for NonCommercial purposes 282 | only; 283 | 284 | b. if You include all or a substantial portion of the database 285 | contents in a database in which You have Sui Generis Database 286 | Rights, then the database in which You have Sui Generis Database 287 | Rights (but not its individual contents) is Adapted Material; and 288 | 289 | c. You must comply with the conditions in Section 3(a) if You Share 290 | all or a substantial portion of the contents of the database. 291 | 292 | For the avoidance of doubt, this Section 4 supplements and does not 293 | replace Your obligations under this Public License where the Licensed 294 | Rights include other Copyright and Similar Rights. 295 | 296 | 297 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 298 | 299 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 300 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 301 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 302 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 303 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 304 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 305 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 306 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 307 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 308 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 309 | 310 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 311 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 312 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 313 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 314 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 315 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 316 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 317 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 318 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 319 | 320 | c. The disclaimer of warranties and limitation of liability provided 321 | above shall be interpreted in a manner that, to the extent 322 | possible, most closely approximates an absolute disclaimer and 323 | waiver of all liability. 324 | 325 | 326 | Section 6 -- Term and Termination. 327 | 328 | a. This Public License applies for the term of the Copyright and 329 | Similar Rights licensed here. However, if You fail to comply with 330 | this Public License, then Your rights under this Public License 331 | terminate automatically. 332 | 333 | b. Where Your right to use the Licensed Material has terminated under 334 | Section 6(a), it reinstates: 335 | 336 | 1. automatically as of the date the violation is cured, provided 337 | it is cured within 30 days of Your discovery of the 338 | violation; or 339 | 340 | 2. upon express reinstatement by the Licensor. 341 | 342 | For the avoidance of doubt, this Section 6(b) does not affect any 343 | right the Licensor may have to seek remedies for Your violations 344 | of this Public License. 345 | 346 | c. For the avoidance of doubt, the Licensor may also offer the 347 | Licensed Material under separate terms or conditions or stop 348 | distributing the Licensed Material at any time; however, doing so 349 | will not terminate this Public License. 350 | 351 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 352 | License. 353 | 354 | 355 | Section 7 -- Other Terms and Conditions. 356 | 357 | a. The Licensor shall not be bound by any additional or different 358 | terms or conditions communicated by You unless expressly agreed. 359 | 360 | b. Any arrangements, understandings, or agreements regarding the 361 | Licensed Material not stated herein are separate from and 362 | independent of the terms and conditions of this Public License. 363 | 364 | 365 | Section 8 -- Interpretation. 366 | 367 | a. For the avoidance of doubt, this Public License does not, and 368 | shall not be interpreted to, reduce, limit, restrict, or impose 369 | conditions on any use of the Licensed Material that could lawfully 370 | be made without permission under this Public License. 371 | 372 | b. To the extent possible, if any provision of this Public License is 373 | deemed unenforceable, it shall be automatically reformed to the 374 | minimum extent necessary to make it enforceable. If the provision 375 | cannot be reformed, it shall be severed from this Public License 376 | without affecting the enforceability of the remaining terms and 377 | conditions. 378 | 379 | c. No term or condition of this Public License will be waived and no 380 | failure to comply consented to unless expressly agreed to by the 381 | Licensor. 382 | 383 | d. Nothing in this Public License constitutes or may be interpreted 384 | as a limitation upon, or waiver of, any privileges and immunities 385 | that apply to the Licensor or You, including from the legal 386 | processes of any jurisdiction or authority. 387 | 388 | ======================================================================= 389 | 390 | Creative Commons is not a party to its public 391 | licenses. Notwithstanding, Creative Commons may elect to apply one of 392 | its public licenses to material it publishes and in those instances 393 | will be considered the “Licensor.” The text of the Creative Commons 394 | public licenses is dedicated to the public domain under the CC0 Public 395 | Domain Dedication. Except for the limited purpose of indicating that 396 | material is shared under a Creative Commons public license or as 397 | otherwise permitted by the Creative Commons policies published at 398 | creativecommons.org/policies, Creative Commons does not authorize the 399 | use of the trademark "Creative Commons" or any other trademark or logo 400 | of Creative Commons without its prior written consent including, 401 | without limitation, in connection with any unauthorized modifications 402 | to any of its public licenses or any other arrangements, 403 | understandings, or agreements concerning use of licensed material. For 404 | the avoidance of doubt, this paragraph does not form part of the 405 | public licenses. 406 | 407 | Creative Commons may be contacted at creativecommons.org. 408 | -------------------------------------------------------------------------------- /src/control.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Tokyo Institute of Technology 3 | */ 4 | 5 | //============================================================================// 6 | // 7 | // Software Name : MEGADOCK 8 | // 9 | // Class Name : Control 10 | // 11 | // Contact address : Tokyo Institute of Technology, AKIYAMA Lab. 12 | // 13 | //============================================================================// 14 | 15 | #include "control.h" 16 | 17 | //============================================================================// 18 | void Control::initialize(int argc,char *argv[]) 19 | //============================================================================// 20 | { 21 | int ngrid; 22 | vector ngrid_table; 23 | 24 | struct timeval et1, et2; 25 | gettimeofday(&et1,NULL); 26 | 27 | // Parameter 28 | _parameter = new Parameter(_parallel); 29 | _parameter->initialize(argc,argv); 30 | _cputime->record_malloc( sizeof(float)*_parameter->_Num_rot_angles*3 + sizeof(map)*(_parameter->_Charmmr.size() + _parameter->_Charmmc.size() + _parameter->_ACE.size()) ); //Rotation angles[], Atom radius, charge, ACE[] 31 | 32 | // Number of processors limitation 33 | const int thread_limit = _parameter->_Num_thread_limit; 34 | const int gpu_limit = _parameter->_Num_GPU_limit; 35 | 36 | if(_parallel->nproc2() > thread_limit) { 37 | _parallel->nproc2(thread_limit); 38 | } 39 | 40 | if(_parallel->num_gpu() > gpu_limit || _parallel->num_gpu() > _parallel->nproc2()) { 41 | _parallel->num_gpu( min(gpu_limit, (int)_parallel->nproc2()) ); 42 | } 43 | printf("# Using %3d CPU cores, %d GPUs\n", _parallel->nproc2(), _parallel->num_gpu()); 44 | 45 | // Receptor 46 | _receptor = new Receptor(_parameter->_RecPDB_file); 47 | _receptor->initialize(_parameter); 48 | _cputime->record_malloc( sizeof(float)*_receptor->num_atoms()*3 ); //Atom coordinate 49 | 50 | // Ligand 51 | _ligand = new Ligand(_parameter->_LigPDB_file); 52 | _ligand->initialize(_parameter); 53 | _cputime->record_malloc( sizeof(float)*_ligand->num_atoms()*3 ); //Atom coordinate 54 | 55 | if( !_parameter->_Num_fft_flag ) { 56 | switch (_parameter->fft_base_set) { 57 | case 13: 58 | gridtable_13base_normal(ngrid,ngrid_table); 59 | break; 60 | case 7: 61 | gridtable_07base_normal(ngrid,ngrid_table); 62 | break; 63 | case 11: 64 | gridtable_11base_normal(ngrid,ngrid_table); 65 | break; 66 | case 0: 67 | gridtable_fftw_custom(ngrid,ngrid_table); 68 | break; 69 | case 1: 70 | gridtable_cufft_custom(ngrid,ngrid_table); 71 | break; 72 | } 73 | autogridr(ngrid,ngrid_table); 74 | autogridl(ngrid,ngrid_table); 75 | } else { 76 | checkgridr(); 77 | checkgridl(); 78 | } 79 | 80 | // Docking 81 | _docking = new Docking(_cputime,_parallel,_parameter,_receptor,_ligand); 82 | _docking->initialize(); 83 | 84 | gettimeofday(&et2,NULL); 85 | _cputime->t1_initialize += (et2.tv_sec-et1.tv_sec + (float)((et2.tv_usec-et1.tv_usec)*1e-6)); 86 | 87 | return; 88 | } 89 | 90 | //============================================================================// 91 | void Control::gridtable_11base_normal(int &ngrid,vector &ngrid_table) 92 | //============================================================================// 93 | { 94 | 95 | int grid_table[] = {2,3,4,5,6,7,8,9,10,11,12,14,15,16,18,20,21,22,24,25,27, 96 | 28,30,32,33,35,36,40,42,44,45,48,49,50,54,55,56,60,63, 97 | 64,66,70,72,75,77,80,81,84,88,90,96,98,99,100,105,108, 98 | 110,112,120,121,125,126,128,132,135,140,144,147,150, 99 | 154,160,162,165,168,175,176,180,189,192,196,198,200, 100 | 210,216,220,224,225,231,240,242,243,245,250,252,256, 101 | 264,270,275,280,288,294,297,300,308,315,320,324,330, 102 | 336,343,350,352,360,363,375,378,384,385,392,396,400, 103 | 405,420,432,440,441,448,450,462,480,484,486,490,495, 104 | 500,504,512,525,528,539,540,550,560,567,576,588,594, 105 | 600,605,616,625,630,640,648,660,672,675,686,693,700, 106 | 704,720,726,729,735,750,756,768,770,784,792,800,810, 107 | 825,840,847,864,875,880,882,891,896,900,924,945,960, 108 | 968,972,980,990,1000,1008,1024 109 | }; 110 | 111 | ngrid = sizeof(grid_table)/sizeof(grid_table[0]); 112 | ngrid_table.resize(ngrid); 113 | if( ngrid_table.size() < ngrid ) { 114 | cerr << "[ERROR] Out of memory. Number of FFT table lists = (" 115 | << ngrid << ") for (ngrid_table) in control.cpp!!\n"; 116 | exit(1); 117 | } 118 | 119 | for( int i = 0 ; i < ngrid ; i++ ) { 120 | ngrid_table[i] = grid_table[i]; 121 | } 122 | 123 | return; 124 | } 125 | 126 | //============================================================================// 127 | void Control::gridtable_13base_normal(int &ngrid,vector &ngrid_table) 128 | //============================================================================// 129 | { 130 | 131 | int grid_table[] = { 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 132 | 12 , 13 , 14 , 15 , 16 , 18 , 20 , 21 , 22 , 24 , 133 | 25 , 26 , 27 , 28 , 30 , 32 , 33 , 35 , 36 , 39 , 134 | 40 , 42 , 44 , 45 , 48 , 49 , 50 , 52 , 54 , 55 , 135 | 56 , 60 , 63 , 64 , 65 , 66 , 70 , 72 , 75 , 77 , 136 | 78 , 80 , 81 , 84 , 88 , 90 , 91 , 96 , 98 , 99 , 137 | 100 , 104 , 105 , 108 , 110 , 112 , 117 , 120 , 121 , 125 , 138 | 126 , 128 , 130 , 132 , 135 , 140 , 143 , 144 , 147 , 150 , 139 | 154 , 156 , 160 , 162 , 165 , 168 , 169 , 175 , 176 , 180 , 140 | 182 , 189 , 192 , 195 , 196 , 198 , 200 , 208 , 210 , 216 , 141 | 220 , 224 , 225 , 231 , 234 , 240 , 242 , 243 , 245 , 250 , 142 | 252 , 256 , 260 , 264 , 270 , 273 , 275 , 280 , 286 , 288 , 143 | 294 , 297 , 300 , 308 , 312 , 315 , 320 , 324 , 325 , 330 , 144 | 336 , 338 , 343 , 350 , 351 , 352 , 360 , 363 , 364 , 375 , 145 | 378 , 384 , 385 , 390 , 392 , 396 , 400 , 405 , 416 , 420 , 146 | 429 , 432 , 440 , 441 , 448 , 450 , 455 , 462 , 468 , 480 , 147 | 484 , 486 , 490 , 495 , 500 , 504 , 507 , 512 , 520 , 525 , 148 | 528 , 539 , 540 , 546 , 550 , 560 , 567 , 572 , 576 , 585 , 149 | 588 , 594 , 600 , 605 , 616 , 624 , 625 , 630 , 637 , 640 , 150 | 648 , 650 , 660 , 672 , 675 , 676 , 686 , 693 , 700 , 702 , 151 | 704 , 715 , 720 , 726 , 728 , 729 , 735 , 750 , 756 , 768 , 152 | 770 , 780 , 784 , 792 , 800 , 810 , 819 , 825 , 832 , 840 , 153 | 845 , 847 , 858 , 864 , 875 , 880 , 882 , 891 , 896 , 900 , 154 | 910 , 924 , 936 , 945 , 960 , 968 , 972 , 975 , 980 , 990 , 155 | 1000 , 1001 , 1008 , 1014 , 1024 156 | }; 157 | 158 | ngrid = sizeof(grid_table)/sizeof(grid_table[0]); 159 | ngrid_table.resize(ngrid); 160 | if( ngrid_table.size() < ngrid ) { 161 | cerr << "[ERROR] Out of memory. Number of FFT table lists = (" 162 | << ngrid << ") for (ngrid_table) in control.cpp!!\n"; 163 | exit(1); 164 | } 165 | 166 | for( int i = 0 ; i < ngrid ; i++ ) { 167 | ngrid_table[i] = grid_table[i]; 168 | } 169 | 170 | return; 171 | } 172 | 173 | //============================================================================// 174 | void Control::gridtable_07base_normal(int &ngrid,vector &ngrid_table) 175 | //============================================================================// 176 | { 177 | 178 | int grid_table[] = { 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 12 , 179 | 14 , 15 , 16 , 18 , 20 , 21 , 24 , 25 , 27 , 28 , 180 | 30 , 32 , 35 , 36 , 40 , 42 , 45 , 48 , 49 , 50 , 181 | 54 , 56 , 60 , 63 , 64 , 70 , 72 , 75 , 80 , 81 , 182 | 84 , 90 , 96 , 98 , 100 , 105 , 108 , 112 , 120 , 125 , 183 | 126 , 128 , 135 , 140 , 144 , 147 , 150 , 160 , 162 , 168 , 184 | 175 , 180 , 189 , 192 , 196 , 200 , 210 , 216 , 224 , 225 , 185 | 240 , 243 , 245 , 250 , 252 , 256 , 270 , 280 , 288 , 294 , 186 | 300 , 315 , 320 , 324 , 336 , 343 , 350 , 360 , 375 , 378 , 187 | 384 , 392 , 400 , 405 , 420 , 432 , 441 , 448 , 450 , 480 , 188 | 486 , 490 , 500 , 504 , 512 , 525 , 540 , 560 , 567 , 576 , 189 | 588 , 600 , 625 , 630 , 640 , 648 , 672 , 675 , 686 , 700 , 190 | 720 , 729 , 735 , 750 , 756 , 768 , 784 , 800 , 810 , 840 , 191 | 864 , 875 , 882 , 896 , 900 , 945 , 960 , 972 , 980 , 1000 , 192 | 1008 , 1024 193 | }; 194 | 195 | 196 | ngrid = sizeof(grid_table)/sizeof(grid_table[0]); 197 | ngrid_table.resize(ngrid); 198 | if( ngrid_table.size() < ngrid ) { 199 | cerr << "[ERROR] Out of memory. Number of FFT table lists = (" 200 | << ngrid << ") for (ngrid_table) in control.cpp!!\n"; 201 | exit(1); 202 | } 203 | 204 | for( int i = 0 ; i < ngrid ; i++ ) { 205 | ngrid_table[i] = grid_table[i]; 206 | } 207 | 208 | return; 209 | } 210 | 211 | //============================================================================// 212 | void Control::gridtable_fftw_custom(int &ngrid,vector &ngrid_table) 213 | //============================================================================// 214 | { 215 | 216 | int grid_table[] = { 8,10,16,18,21,22,24,25,32,33,35, 217 | 36,39,40,42,44,45,49,50,52,55,56,60,64,70,75,78,84,91, 218 | 100,105,110,117,126,130,140,147,150,154,156,162,165,169,175,189,200,210,216,220,225, 219 | 231 , 234 , 240 , 242 , 243 , 245 , 250 , 220 | 252 , 256 , 260 , 264 , 270 , 273 , 275 , 280 , 286 , 288 , 221 | 294 , 297 , 300 , 308 , 312 , 315 , 320 , 324 , 325 , 330 , 222 | 336 , 338 , 343 , 350 , 351 , 352 , 360 , 363 , 364 , 375 , 223 | 378 , 384 , 385 , 390 , 392 , 396 , 400 , 405 , 416 , 420 , 224 | 429 , 432 , 440 , 441 , 448 , 450 , 455 , 462 , 468 , 480 , 225 | 484 , 486 , 490 , 495 , 500 , 504 , 507 , 512 , 520 , 525 , 226 | 528 , 539 , 540 , 546 , 550 , 560 , 567 , 572 , 576 , 585 , 227 | 588 , 594 , 600 , 605 , 616 , 624 , 625 , 630 , 637 , 640 , 228 | 648 , 650 , 660 , 672 , 675 , 676 , 686 , 693 , 700 , 702 , 229 | 704 , 715 , 720 , 726 , 728 , 729 , 735 , 750 , 756 , 768 , 230 | 770 , 780 , 784 , 792 , 800 , 810 , 819 , 825 , 832 , 840 , 231 | 845 , 847 , 858 , 864 , 875 , 880 , 882 , 891 , 896 , 900 , 232 | 910 , 924 , 936 , 945 , 960 , 968 , 972 , 975 , 980 , 990 , 233 | 1000 , 1001 , 1008 , 1014 , 1024 234 | }; //selected the just values to have faster FFT calculation time (in n < 226) 235 | 236 | 237 | ngrid = sizeof(grid_table)/sizeof(grid_table[0]); 238 | ngrid_table.resize(ngrid); 239 | if( ngrid_table.size() < ngrid ) { 240 | cerr << "[ERROR] Out of memory. Number of FFT table lists = (" 241 | << ngrid << ") for (ngrid_table) in control.cpp!!\n"; 242 | exit(1); 243 | } 244 | 245 | for( int i = 0 ; i < ngrid ; i++ ) { 246 | ngrid_table[i] = grid_table[i]; 247 | } 248 | 249 | return; 250 | } 251 | 252 | //============================================================================// 253 | void Control::gridtable_cufft_custom(int &ngrid,vector &ngrid_table) 254 | //============================================================================// 255 | { 256 | 257 | int grid_table[] = { 16,32,36,40,42,48,50,64,72,80,81,84,96,98,100,108,112,128,144,160,162,168,200,216,224,240 , 258 | 243 , 245 , 250 , 252 , 256 , 270 , 280 , 288 , 294 , 259 | 300 , 315 , 320 , 324 , 336 , 343 , 350 , 360 , 375 , 378 , 260 | 384 , 392 , 400 , 405 , 420 , 432 , 441 , 448 , 450 , 480 , 261 | 486 , 490 , 500 , 504 , 512 , 525 , 540 , 560 , 567 , 576 , 262 | 588 , 600 , 625 , 630 , 640 , 648 , 672 , 675 , 686 , 700 , 263 | 720 , 729 , 735 , 750 , 756 , 768 , 784 , 800 , 810 , 840 , 264 | 864 , 875 , 882 , 896 , 900 , 945 , 960 , 972 , 980 , 1000 , 265 | 1008 , 1024 266 | }; //selected the just values to have faster FFT calculation time (in n < 226) 267 | 268 | 269 | ngrid = sizeof(grid_table)/sizeof(grid_table[0]); 270 | ngrid_table.resize(ngrid); 271 | if( ngrid_table.size() < ngrid ) { 272 | cerr << "[ERROR] Out of memory. Number of FFT table lists = (" 273 | << ngrid << ") for (ngrid_table) in control.cpp!!\n"; 274 | exit(1); 275 | } 276 | 277 | for( int i = 0 ; i < ngrid ; i++ ) { 278 | ngrid_table[i] = grid_table[i]; 279 | } 280 | 281 | return; 282 | } 283 | 284 | 285 | 286 | //============================================================================// 287 | void Control::autogridr(const int &ngrid,vector &ngrid_table) 288 | //============================================================================// 289 | { 290 | int num_grid = 1; 291 | float size, size_rec = 0.0; 292 | 293 | for( int i = 0 ; i < 3 ; i++ ) { 294 | size = _receptor->edge(i,1) - _receptor->edge(i,0); 295 | 296 | //printf(" %f, %f\n",_receptor->edge(i,1),_receptor->edge(i,0)); 297 | 298 | if( size > size_rec ) { 299 | size_rec = size; 300 | } 301 | } 302 | 303 | cout << "\nReceptor = " << _receptor->input_file() << endl; 304 | cout << "Receptor max size = " << size_rec << endl; 305 | 306 | size_rec += 2.0 * _parameter->_Grid_space_rec; 307 | cout << "Required voxel size = " << size_rec << endl; 308 | 309 | num_grid = 1 + int(size_rec / _parameter->grid_width); 310 | 311 | for( int i = 0 ; i < ngrid ; i++ ) { 312 | if( ngrid_table[i] >= num_grid ) { 313 | num_grid = ngrid_table[i]; 314 | break; 315 | } 316 | } 317 | 318 | _receptor->num_grid(num_grid); 319 | 320 | cout << "Number of grid = " << num_grid << endl; 321 | cout << "FFT N = " << num_grid*2 << endl; 322 | 323 | return; 324 | } 325 | 326 | //============================================================================// 327 | void Control::autogridl(const int &ngrid,vector &ngrid_table) 328 | //============================================================================// 329 | { 330 | int num_grid = 1; 331 | float size_lig = 0.0; 332 | float x1, y1, z1, x2, y2, z2, d2; 333 | const int na = _ligand->num_atoms(); 334 | 335 | for( int i = 0 ; i < na-1 ; i++ ) { 336 | x1 = _ligand->coordinate(i,0); 337 | y1 = _ligand->coordinate(i,1); 338 | z1 = _ligand->coordinate(i,2); 339 | 340 | for( int j = i+1 ; j < na ; j++ ) { 341 | x2 = _ligand->coordinate(j,0); 342 | y2 = _ligand->coordinate(j,1); 343 | z2 = _ligand->coordinate(j,2); 344 | 345 | d2 = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1); 346 | 347 | if( d2 > size_lig ) { 348 | size_lig = d2; 349 | } 350 | } 351 | } 352 | 353 | size_lig = sqrt(size_lig); 354 | 355 | cout << "\nLigand = " << _ligand->input_file() << endl; 356 | cout << "Ligand max size = " << size_lig << endl; 357 | 358 | size_lig += 2.0 * _parameter->_Grid_space_lig; 359 | 360 | _parameter->ligand_max_edge = size_lig; 361 | 362 | cout << "Required voxel size = " << size_lig << endl; 363 | 364 | num_grid = 1 + int(size_lig / _parameter->grid_width); 365 | 366 | for( int i = 0 ; i < ngrid ; i++ ) { 367 | if( ngrid_table[i] >= num_grid ) { 368 | num_grid = ngrid_table[i]; 369 | break; 370 | } 371 | } 372 | 373 | _ligand->num_grid(num_grid); 374 | 375 | cout << "Number of grid = " << num_grid << endl; 376 | cout << "FFT N = " << num_grid*2 << endl; 377 | 378 | return; 379 | } 380 | 381 | //============================================================================// 382 | void Control::checkgridr() 383 | //============================================================================// 384 | { 385 | float size, size_rec = 0.0; 386 | const int num_grid = _parameter->_Num_grid; 387 | const float search_length = _parameter->grid_width * num_grid; 388 | 389 | for( int i = 0 ; i < 3 ; i++ ) { 390 | size = _receptor->edge(i,1) - _receptor->edge(i,0); 391 | 392 | if( size > size_rec ) { 393 | size_rec = size; 394 | } 395 | } 396 | 397 | cout << "\nReceptor max size = " << size_rec << endl; 398 | 399 | size_rec += 2.0*_parameter->_Grid_space_rec; 400 | 401 | cout << "Required voxel size = " << size_rec << endl; 402 | 403 | if( size_rec > search_length ) { 404 | cerr << "[ERROR] Receptor data is too big!!\n"; 405 | exit(1); 406 | } 407 | 408 | _receptor->num_grid(num_grid); 409 | 410 | cout << "\n(Receptor)\n"; 411 | cout << "Number of grid = " << num_grid << endl; 412 | cout << "FFT N = " << num_grid*2 << endl; 413 | cout << "Grid size = " << _parameter->grid_width << endl; 414 | 415 | return; 416 | } 417 | 418 | //============================================================================// 419 | void Control::checkgridl() 420 | //============================================================================// 421 | { 422 | float size_lig = 0.0; 423 | float x1, y1, z1, x2, y2, z2, d2; 424 | const int na = _ligand->num_atoms(); 425 | const int num_grid = _parameter->_Num_grid; 426 | const float search_length = _parameter->grid_width * num_grid; 427 | 428 | for( int i = 0 ; i < na-1 ; i++ ) { 429 | x1 = _ligand->coordinate(i,0); 430 | y1 = _ligand->coordinate(i,1); 431 | z1 = _ligand->coordinate(i,2); 432 | 433 | for( int j = i+1 ; j < na ; j++ ) { 434 | x2 = _ligand->coordinate(j,0); 435 | y2 = _ligand->coordinate(j,1); 436 | z2 = _ligand->coordinate(j,2); 437 | 438 | d2 = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1); 439 | 440 | if( d2 > size_lig ) { 441 | size_lig = d2; 442 | } 443 | } 444 | } 445 | 446 | size_lig = sqrt(size_lig); 447 | cout << "\nLigand max size = " << size_lig << endl; 448 | 449 | size_lig += 2.0*_parameter->_Grid_space_lig; 450 | cout << "Required voxel size = " << size_lig << endl; 451 | 452 | if( size_lig > search_length ) { 453 | cerr << "[ERROR] Ligand data is too big!!\n"; 454 | exit(1); 455 | } 456 | 457 | _ligand->num_grid(num_grid); 458 | 459 | cout << "\n(Ligand)\n"; 460 | cout << "Number of grid = " << num_grid << endl; 461 | cout << "FFT N = " << num_grid*2 << endl; 462 | cout << "Grid size = " << _parameter->grid_width << endl; 463 | 464 | return; 465 | } 466 | 467 | //============================================================================// 468 | void Control::execute() 469 | //============================================================================// 470 | { 471 | struct timeval et1, et2; 472 | 473 | cout << "\n---------- Start docking calculations" << endl; 474 | 475 | gettimeofday(&et1,NULL); // Receptor process (voxelization, forward FFT of Receptor) 476 | _docking->rec_init(); 477 | gettimeofday(&et2,NULL); 478 | _cputime->t2_receptor_process += (et2.tv_sec-et1.tv_sec + (float)((et2.tv_usec-et1.tv_usec)*1e-6)); 479 | 480 | gettimeofday(&et1,NULL); // docking 481 | _docking->dockz(); 482 | gettimeofday(&et2,NULL); 483 | _cputime->t3_docking_total += (et2.tv_sec-et1.tv_sec + (float)((et2.tv_usec-et1.tv_usec)*1e-6)); 484 | 485 | if(_parameter->detail_output_flag == 1) { // detailed result output 486 | gettimeofday(&et1,NULL); 487 | _docking->output_detail(); 488 | gettimeofday(&et2,NULL); 489 | _cputime->t4_docking_output_detail += (et2.tv_sec-et1.tv_sec + (float)((et2.tv_usec-et1.tv_usec)*1e-6)); 490 | } 491 | 492 | if(_parameter->calc_time_log_output_flag >= 1) { // calculation info 493 | _docking->output_calc_time_log(); 494 | } 495 | 496 | gettimeofday(&et1,NULL); // normal result output 497 | _docking->output(); 498 | gettimeofday(&et2,NULL); 499 | _cputime->t5_docking_output += (et2.tv_sec-et1.tv_sec + (float)((et2.tv_usec-et1.tv_usec)*1e-6)); 500 | 501 | _docking->dock_memory_free(); 502 | 503 | const int ng1 = _parameter->_Num_grid; 504 | const int ng3 = ng1*ng1*ng1; 505 | const int nf1 = ng1*2; 506 | const int nf3 = nf1*nf1*nf1; 507 | const int nproc2 = _parallel->nproc2(); 508 | const int natom = _parameter->_Num_atom_max; 509 | const int nag = natom * ng1; 510 | const size_t _Memfw = ng3*3+natom*3+nag*3; 511 | const size_t _Memiw = ng3*2+natom*4; 512 | 513 | //delete docking include delete fft_process, _FFT_rec_r/i[nf3], _FFTWin/out[nf3*nproc2] 514 | _cputime->record_free( sizeof(float)*nf3*2 + sizeof(fftwf_complex)*nf3*2*nproc2); 515 | #ifdef CUFFT 516 | _cputime->record_free( sizeof(cufftComplex)*nf3*2 ); //_in/outBuf 517 | #endif 518 | _cputime->record_free( sizeof(float)*_Memfw*nproc2 + sizeof(int)*_Memiw*nproc2 ); //_F/Iwork 519 | delete _docking; 520 | _cputime->record_free( sizeof(float)*_ligand->num_atoms()*3 ); 521 | delete _ligand; 522 | _cputime->record_free( sizeof(float)*_receptor->num_atoms()*3 ); 523 | delete _receptor; 524 | _cputime->record_free( sizeof(float)*_parameter->_Num_rot_angles*3 + sizeof(map)*(_parameter->_Charmmr.size() + _parameter->_Charmmc.size() + _parameter->_ACE.size()) ); 525 | delete _parameter; 526 | 527 | 528 | return; 529 | } 530 | --------------------------------------------------------------------------------