Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into gpu-model
Browse files Browse the repository at this point in the history
  • Loading branch information
caic99 authored Feb 10, 2024
2 parents 69bab96 + bf7e986 commit 540536f
Show file tree
Hide file tree
Showing 53 changed files with 2,111 additions and 1,035 deletions.
63 changes: 63 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Contribution Guidelines

Thank you for your interest in contributing to Uni-Dock! We value your time and effort, and aim to make the contribution process enjoyable and efficient. To ensure consistency and maintainability, please follow these guidelines when submitting your contributions.

## Troubleshooting

If you encountered problems using Uni-Dock, please refer to our GitHub [issue tracker](https://github.com/dptech-corp/Uni-Dock/issues), and check if it is a known problem.
If you found a bug, you can help us improve by [submitting a new issue](https://github.com/dptech-corp/Uni-Dock/issues/new) to our GitHub Repository. Provide a clear and concise title and description, including steps to reproduce the issue (if applicable) and any relevant context.
Even better, you can submit a Pull Request with a patch.

## Feature requests

We highly appreciate your contributions, and would like to help you crafting the changes and making contributions to the community.
If you would like to implement a new feature, please **submit a feature requesting issue with a proposal for your work first**.
This help fitting your ideas and work with the development road map well, coordinating our efforts, and avoiding duplication of work.

## Submitting a Pull Request

**Please fork your own copy of the Uni-Dock repository, and draft your changes there.** Once the modified codes work as expected, please submit a pull request to merge your contributions.

1. [Fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) the [Uni-Dock repository](https://github.com/dptech-corp/Uni-Dock). If you already had an existing fork, [sync](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork) the fork to keep your modification up-to-date.

2. Pull your forked repository, create a new git branch, and make your changes in it:

```shell
git checkout -b bug-fix
```

3. Coding your patch and commit the changes.

4. Push your branch to GitHub:

```shell
git push origin my-fix-branch
```

5. On GitHub, create a pull request (PR) from your bug-fix branch targeting `dptech-corp/Uni-Dock`.

6. After your pull request is merged, you can safely delete your branch and sync the changes from the main (upstream) repository:

- Delete the remote branch on GitHub either [through the GitHub web UI](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/deleting-and-restoring-branches-in-a-pull-request#deleting-a-branch-used-for-a-pull-request) or your local shell as follows:

```shell
git push origin --delete my-fix-branch
```

- Check out the master branch:

```shell
git checkout develop -f
```

- Delete the local branch:

```shell
git branch -D my-fix-branch
```

- Update your master with the latest upstream version:

```shell
git pull --ff upstream develop
```
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior.
Please provide necessary information including input file, running commands, error log, etc.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Environment (please complete the following information):**
- CUDA version
- GPU model
- Uni-Dock version

**Additional context**
Add any other context about the problem here.
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/custom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Custom issue template
about: Describe this issue template's purpose here.
title: ''
labels: ''
assignees: ''

---


20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is.

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
14 changes: 6 additions & 8 deletions .github/workflows/ci_tools.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Uni-Dock Tools CI/CD
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
flake8:
Expand All @@ -15,7 +13,7 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
Expand Down Expand Up @@ -83,15 +81,15 @@ jobs:
strategy:
matrix:
python-version: ["3.9"]
container:
container:
image: docker.io/dptechnology/unidock:latest
options: --gpus all
steps:
- name: checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup conda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
Expand All @@ -107,9 +105,9 @@ jobs:
working-directory: ./unidock_tools
run: |
export PATH=/__w/Uni-Dock/Uni-Dock/3/envs/test/bin:$PATH
python setup.py install
conda run -n test python setup.py install
- name: perform unit-test
run: |
export PATH=/__w/Uni-Dock/Uni-Dock/3/envs/test/bin:$PATH
pytest unidock_tools/tests/ut -v
conda run -n test pytest unidock_tools/tests/ut -v
23 changes: 10 additions & 13 deletions .github/workflows/ci_unidock.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Uni-Dock CI/CD
on:
push:
branches: [ main ]
branches: []
pull_request:
branches: [ main ]

jobs:
unidock_test:
runs-on: nvidia
container:
container:
image: nvidia/cuda:12.2.0-devel-ubuntu22.04
options: --gpus all
steps:
Expand All @@ -19,7 +19,7 @@ jobs:
run: |
apt-get update
apt-get install -y build-essential cmake libboost-all-dev ninja-build
- if: ${{ env.ACT }}
name: Hack container for local development
run: |
Expand All @@ -42,32 +42,29 @@ jobs:
nvidia-smi
unidock --version
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: 3.8
python-version: '3.10'

- name: perform unit-test
run: |
python -m pip install --upgrade pip
pip install pytest coverage
coverage run -m pytest unidock/test/ut -v
coverage xml
pip install pytest>=8.0.0 pytest-cov
pytest unidock/test/ut -vv --doctest-modules --junitxml=junit/test-results.xml --cov --cov-report term
build_docker_image:
needs: unidock_test
runs-on: ubuntu-latest
steps:

- name: log in to docker hub
uses: docker/login-action@v2
uses: docker/login-action@v3
if: github.event_name == 'push'
with:
username: dptechnology
password: ${{ secrets.DOCKERHUB_PAT }}

- name: set up QEMU
uses: docker/setup-qemu-action@v2

- name: set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -86,4 +83,4 @@ jobs:
tags: dptechnology/unidock:${{ steps.short-sha.outputs.sha }},dptechnology/unidock:latest
file: Dockerfile
context: "{{defaultContext}}:unidock"
push: true
push: ${{ github.event_name == 'push' }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ build/
test/ligands
test/results
.vscode
.idea
unidock/build/
unidock/example/screening_test/indata
unidock/example/screening_test/result
Expand Down
13 changes: 10 additions & 3 deletions unidock/src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ bug reporting, license agreements, and more information. \n";
std::string score_file("scores.txt");

positional_options_description positional; // remains empty
// GPU Device id to use
int device_id = 0;

options_description inputs("Input");
inputs.add_options()("receptor", value<std::string>(&rigid_name),
Expand Down Expand Up @@ -281,7 +283,9 @@ bug reporting, license agreements, and more information. \n";
"output filename (directory + prefix name) for maps. Option --force_even_voxels may be "
"needed to comply with .map format");
options_description advanced("Advanced options (see the manual)");
advanced.add_options()("score_only", bool_switch(&score_only),
advanced.add_options()("device_id", value<int>(&device_id)->default_value(0),
"GPU device id to use (default 0)")
("score_only", bool_switch(&score_only),
"score only - search space can be omitted")(
"score_file", value<std::string>(&score_file)->default_value(score_file),
"score only output file in batch mode, with 'score_only' option")(
Expand Down Expand Up @@ -498,7 +502,8 @@ bug reporting, license agreements, and more information. \n";

std::vector<double> box_size = {size_x, size_y, size_z};
simulation_container sc(seed, num_modes, refine_step, out_dir,
ligand_index, paired_batch_size, box_size, local_only, max_step, verbosity, exhaustiveness);
ligand_index, paired_batch_size, box_size, local_only, max_step,
verbosity, exhaustiveness, device_id);

int res = sc.prime();
if (res <= 0)
Expand Down Expand Up @@ -766,7 +771,9 @@ bug reporting, license agreements, and more information. \n";
if (sf_name.compare("ad4") == 0) ad4 = true;
cudaGetDeviceCount(&deviceCount);
if (deviceCount > 0) {
cudaSetDevice(0);
checkCUDA(cudaSetDevice(device_id));

printf("Set GPU device id to %d\n", device_id);
cudaMemGetInfo(&avail, &total);
printf("Available Memory = %dMiB Total Memory = %dMiB\n",
int(avail / 1024 / 1024), int(total / 1024 / 1024));
Expand Down
9 changes: 6 additions & 3 deletions unidock/src/main/simulation_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct simulation_container
int m_seed = 5;
int m_num_modes = 9;
int m_refine_steps = 3;
int m_device_id = 0;

std::vector<std::string> m_complex_names;
std::string m_config_json_path;
Expand All @@ -79,7 +80,8 @@ struct simulation_container
int local_only,
int max_step,
int verbosity,
int exh):
int exh,
int device_id):

m_seed(seed),
m_num_modes(num_modes),
Expand All @@ -93,7 +95,8 @@ struct simulation_container
m_verbosity(verbosity),
m_exhaustiveness(exh),
m_isGPU(true),
m_successful_property_count (0)
m_successful_property_count (0),
m_device_id(device_id)
{
//m_out_phrase = util_random_string(5);
}
Expand Down Expand Up @@ -490,7 +493,7 @@ struct simulation_container
vina_cuda_worker vcw(m_seed, m_num_modes, m_refine_steps, props[i].center_x, props[i].center_y,
props[i].center_z, props[i].protein_name,props[i].ligand_name,
local_only, std::vector<double>{props[i].box_x, props[i].box_y, props[i].box_z}, m_max_global_steps, m_verbosity,
m_exhaustiveness, workdir, input_dir, out_phrase);
m_exhaustiveness, workdir, input_dir, out_phrase, m_device_id);
try
{
int ret = vcw.launch();
Expand Down
6 changes: 5 additions & 1 deletion unidock/src/main/vina_cuda_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class vina_cuda_worker : public Vina
double center_z;
std::string protein_name;
std::string ligand_name;
int m_device_id = 0;
void init(std::string out_phrase)
{
out_dir = workdir + "/" + out_phrase;
Expand All @@ -88,6 +89,7 @@ class vina_cuda_worker : public Vina
boost::filesystem::create_directory(out_dir);
}
m_seed = seed;
checkCUDA(cudaSetDevice(m_device_id));
}
public:
vina_cuda_worker(
Expand All @@ -106,7 +108,8 @@ class vina_cuda_worker : public Vina
int exh,
std::string workdir,
std::string input_dir,
std::string out_phrase):
std::string out_phrase,
int device_id):

seed(seed),
num_modes(num_modes),
Expand All @@ -125,6 +128,7 @@ class vina_cuda_worker : public Vina
ligand_name(ligand_name),
local_only(local_only),
out_dir(out_phrase),
m_device_id(device_id),
Vina{"vina", 0, seed, verbosity, false, NULL}
{
init(out_phrase);
Expand Down
Loading

0 comments on commit 540536f

Please sign in to comment.