Skip to content

Commit 0d7084c

Browse files
authored
Merge pull request #1178 from haddocking/main
Updating from main branch
2 parents 7e7cc94 + a4487ad commit 0d7084c

File tree

19 files changed

+302
-413
lines changed

19 files changed

+302
-413
lines changed
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
on:
2-
push:
3-
branches: [main]
2+
pull_request:
43
paths:
54
- CITATION.cff
6-
pull_request:
75
workflow_dispatch:
86

9-
name: CITATION.cff
107
jobs:
11-
Validate-CITATION-cff:
8+
validate-citation:
129
runs-on: ubuntu-latest
13-
name: Validate CITATION.cff
1410
env:
1511
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1612

1713
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
14+
- uses: actions/checkout@v4
2015

21-
- name: Validate CITATION.cff
22-
uses: dieghernan/cff-validator@v3
16+
- uses: dieghernan/cff-validator@v3

CONTRIBUTING.md

Lines changed: 31 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -18,61 +18,35 @@ instructions in this file.
1818
HADDOCK3 has two main testing workflows. Here, within the repository, we
1919
test the HADDOCK3's Python shell, code style, and package building. Our
2020
Continuous Integration (CI) pipeline is based on
21-
[tox][tox] and GitHub Actions. We will
22-
explain you how to use them.
21+
pytest and GitHub Actions. We will explain you how to use them.
2322

2423
To contribute to the HADDOCK3's Python shell, follow these steps:
2524

2625
1. [Fork][fork] the HADDOCK3 repository
2726
2. Create a new branch in your fork (`git checkout -b <new_branch_name>`)
28-
3. Develop your code and tests:
27+
3. Develop your code:
2928

3029
1. HADDOCK3 source is in `src/haddock`. Always implement code in
3130
the lowest Python version supported (this case is 3.9).
32-
2. Tests sit in the `tests/` folder. Use
33-
[pytest](https://docs.pytest.org/en/6.2.x/) for testing.
34-
3. See more details on how to contribute with code and tests in the
31+
2. See more details on how to contribute with code and tests in the
3532
subheadings below.
3633

37-
4. While you are developing (or when you think you have finished), you can
38-
(should) use our `tox` environments to test your code. Use the
39-
following commands from the main repository folder:
34+
4. Test your code:
35+
1. Unit tests sit in the `tests/` folder. Use
36+
[pytest](https://docs.pytest.org/en/6.2.x/) for testing by running `pytest tests/`.
37+
2. Integration tests are located in the `integration_tests/` folder.
38+
You can run them with `pytest integration_tests/`.
4039

41-
1. `tox -e test` runs tests in current python version. If you tox
42-
to report test names and status for every single test (high verbosity) use
43-
`tox -e test -- -vv`.
44-
2. `tox -e lint` shows you errors in the code style.
45-
3. `tox -e build` simulates building the HADDOCK3 package.
46-
4. Run the above altogether with the simple `tox` command
47-
5. If you want to submit high-quality code, you may wish to run
48-
`tox -e radon` to assess your code cyclomatic complexity.
49-
50-
5. You can work on these `tox` tests until they all pass green before
40+
5. You can work on these tests until they all pass green before
5141
submitting your PR.
5242

5343
6. Check if your contribution fulfills the requeriments proposed in the
5444
PR template, these are based on the experience of some developers to ensure the long-term
5545
survival of the codebase. Suggestions are always welcomed.
5646

57-
7. We also have an `examples` folder with test cases that you can run
58-
(should) to ensure the integrity of the python shell as a whole:
59-
1. Navigate to any of the examples folder and run the `-test.cfg`
60-
file (see [USAGE](USAGE.md)).
61-
2. `*-test.cfg` runs are meant for testing purposes only. The
62-
`examples/` folder also contain `*-full.cfg` files for production runs.
63-
You don't need to run these for testin.
64-
2. If you have a powerful computer and want to run all tests in a
65-
row, navigate to the `examples` folder and run `python run_tests.py
66-
-b`. The `-b` flag ensures the run will stop asap an error is found.
67-
3. if your computer is not powerful enough, you can ask us to run
68-
those tests once you submitted the pull request.
69-
4. For example, the `docking-protein-protein-test.cfg` run in less
70-
than 3 minutes on a `Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz` laptop
71-
using 7 cores. All `-test.cfg` together take about 45 minutes.
72-
73-
8. Add a list of your new additions to the `CHANGELOG.md` file by
74-
adding a new sub-header as described bellow. This is mandatory for `tox
75-
-e build` to pass. Note this applies only after we have released the
47+
7. Add a list of your new additions to the `CHANGELOG.md` file by
48+
adding a new sub-header as described bellow.
49+
Note this applies only after we have released the
7650
stable `3.0.0` version.
7751

7852
```markdown
@@ -86,7 +60,7 @@ stable `3.0.0` version.
8660
(... the rest of the file ...)
8761
```
8862

89-
8. If you have difficulties with `tox`, let us know. These `tox` tests
63+
8. If you have difficulties with the `tests`, let us know. These tests
9064
are the same that run on the GitHub Actions once you send the PR. So,
9165
sending the PR is another way to ensure all tests pass.
9266

@@ -106,7 +80,7 @@ contribute to that folder and respective files. Summarizing here:
10680

10781
* New command-line clients go in the `clis/` folder. See how the current
10882
clients here created and use that as a template. Remember to update also the
109-
`setup.py` file.
83+
`pyproject.toml` file.
11084
* Add any new functions that you foresee are general and
11185
could serve different places in the code to the `libs/` folder. Find a
11286
`lib*.py` files that would serve your purpuses, otherwise create a new
@@ -130,8 +104,8 @@ you create new `*.py` files you should create a new test file of the
130104
same name, `test_new_file_name.py`. Aim at 100% test coverage for the
131105
code you have created. Write tests according to [pytest][pytest]. You
132106
can see examples in our `test_*.py` files. You can run the tests using
133-
the `tox -e test` commands explained above. Or, if you want to run the
134-
tests for a singly file use `tox -e test -- tests/test_myfile.py`.
107+
the `pytest tests/` command explained above. Or, if you want to run the
108+
tests for a singly file use `pytest tests/test_myfile.py`.
135109

136110
### 1.3 Dependencies
137111

@@ -152,118 +126,16 @@ us by opening an issue.
152126
another project. If licenses are compatible, copy their code to the
153127
HADDOCK3 repository writing all necessary headers to grant authorship
154128
and comply with license requirements.
155-
1. If licenses aren't compatible, talk is us. We may have an
129+
1. If licenses aren't compatible, talk to us. We may have an
156130
alternative.
157131
1. Your new module largely depends on a library and reimplementing or
158132
copying is not an option. Then, consider if we can use that dependency
159-
as a **runtime dependency** (like `gdock` or `lightdock`) instead of an
133+
as a **runtime (thirdparty) dependency** (like `gdock` or `lightdock`) instead of an
160134
installation dependency.
161135
1. Nothing of the above is possible. You **really** need an *install
162136
dependency*. Talk with us before.
163137

164-
### 1.4 Code style
165-
166-
HADDOCK3 follows nice code style rules. These are *almost* hard rules,
167-
but there is some room for exceptions - common sense prevails. When
168-
developing code, run `tox -e lint` to inspect if your code follows our
169-
conventions. We use [flake8][flake] with the [following rules][fr] and
170-
docstrings follow [numpydoc][numpydoc] style. You can hold on our code
171-
for style. Nevertheless, here's a dummy code snippet for your reference.
172-
Line have a soft max of 80 chars.
173-
174-
```python
175-
"""Module's docstring."""
176-
# any comments. You can add here licensing stuff
177-
# first import standard library
178-
import os
179-
from path import Pathlib
180-
181-
# import third library
182-
import numpy as np
183-
184-
# import from haddock3
185-
from haddock import log
186-
# multiline import
187-
from haddock.libs.libio import (
188-
lib1,
189-
lib2,
190-
lib3,
191-
lib4,
192-
)
193-
194-
195-
# all this are possible
196-
GLOBAL_VARIBLE = None
197-
_hidden_global_variable = None
198-
199-
avoid_lower_case_globals = None
200-
201-
202-
def my_nice_func(arg1, arg2, arg3):
203-
"""Docstring here."""
204-
# do stuf
205-
206-
# if the function has many arguments, separate them by new lines.
207-
# mind the identations
208-
def my_nice_func_with_big_name(
209-
var1,
210-
var2,
211-
var3,
212-
named_var1="something",
213-
named_var2="else",
214-
**kwargs,
215-
):
216-
"""Docstring here."""
217-
# do stuff
218-
return
219-
220-
221-
multiline_list = [
222-
var1,
223-
var2,
224-
var3,
225-
var4,
226-
]
227-
228-
multiline_dict = {
229-
"key1": 1,
230-
"key2": 2,
231-
"key3": 3,
232-
"key4": 4,
233-
"key5": 5,
234-
}
235-
236-
# separate comprehensions by sections if line don't fit 80 chars
237-
# same for dictionaries
238-
cool_list_comprehension = [
239-
dome_some_long_stuff(i)
240-
for i in some_iterable
241-
if validate(i)
242-
]
243-
244-
double_quotes_allowed = "string"
245-
single_quotes_allowed = 'string'
246-
# don't try to homogenize quotes all around the code, respect the
247-
# original input.
248-
249-
# define first use later
250-
generator_with_a_large_name = zip(
251-
iter1,
252-
iter2,
253-
iter3,
254-
iter4,
255-
iter5,
256-
)
257-
258-
for a, b, c, d, e in generator_with_a_large_name:
259-
# do stuff
260-
261-
# use noqa: E501 for slightly long lines, in case splitting into
262-
# multiple lines reduces readability
263-
this_is_a_long_line = that_makes_no_much_sense(to_separate, in_multiple_lines, abcd) # noqa: E501
264-
```
265-
266-
### 1.5 Code structure
138+
### 1.4 Code structure
267139

268140
Write code in the form of small functions, because small functions are
269141
easier to test. Combine small functions to compose larger functions. If
@@ -276,7 +148,7 @@ needed. Write comments that explain why you do stuff, and not how you do
276148
stuff. Use the `TODO:` flag in your comments to note something for the
277149
future. If needed, raise an issue.
278150

279-
### 1.6 Creating a new module
151+
### 1.5 Creating a new module
280152

281153
To develop a new HADDOCK3 module follow our guidelines and templates
282154
under `src/haddock/modules/_template_cat/_template_mod/`.
@@ -302,9 +174,17 @@ the documentation website.
302174

303175
You can render the documentation locally to inspect the end result
304176
before creating a pull request. To compile the documentation locally:
305-
activate the `haddock3` python environment inside the haddock3 github
306-
folder, run `tox -e docs` and then use your favourite browser to open the
307-
`haddock3-docs/index.html` file. We invite you to read through Sphinx-doc
177+
- install HADDOCK in development mode with the `docs` extra requirements
178+
(`pip install -e '.[docs]'`)
179+
- activate the `haddock3` python environment inside the haddock3 github
180+
folder
181+
- run the following commands:
182+
```bash
183+
sphinx-apidoc -f -e -o docs/ src/haddock -d 1
184+
sphinx-build -b html docs haddock3-docs
185+
```
186+
187+
We invite you to read through Sphinx-doc
308188
webpage if you want to exploit any advanced feature of Sphinx, but we
309189
already provide examples for virtually any use you may need.
310190

@@ -321,11 +201,8 @@ an example. See also the `docs/conf.py` file `setup(app)` line.
321201
need to add that library name to the `mock` list in the `docs/conf.py`
322202
file.
323203

324-
325-
[tox]: https://tox.wiki/en/latest/index.html "tox"
326204
[fork]: https://docs.github.com/en/get-started/quickstart/fork-a-repo
327205
[pytest]: https://docs.pytest.org/ "pytest"
328206
[flake]: https://flake8.pycqa.org/en/latest/ "flake8"
329-
[fr]: https://github.com/haddocking/haddock3/blob/b44304f0a1509d44d9689d7e2e4124f0ae3af0a1/tox.ini#L116-L130
330207
[numpydoc]: https://numpydoc.readthedocs.io/en/latest/format.html
331208
[numba]: https://numba.pydata.org/ "Numba"

MANIFEST.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ exclude .gitmodules
99
exclude .bumpversion.cfg
1010
exclude .coveragerc
1111
exclude .readthedocs.yml
12-
exclude tox.ini
1312
prune devtools
1413
prune examples
1514
prune src/fcc
1615
prune tests
1716
# exclude params*.rst documentation that is generated with
18-
# `tox -e docs`
17+
# sphinx-apidoc
1918
exclude docs/modules/*/params/*.rst
2019
exclude docs/reference/core/mandatory_parameters.rst
2120
exclude docs/modules/general_module_params.rst

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,17 @@ Please check [DEVELOPMENT](https://github.com/haddocking/haddock3/blob/main/DEVE
103103

104104
The code documentation is automatically built and hosted at [bonvinlab.org/haddock3](https://www.bonvinlab.org/haddock3/).
105105

106-
To build it locally (considering you have followed the installation instructions):
106+
To build it locally it is necessary to have some extra packages installed. You can install them using the following command:
107107

108108
```bash
109-
tox -e docs
109+
pip install -e '.[docs]'
110+
```
111+
112+
Then, to build the documentation, run the following commands:
113+
114+
```bash
115+
sphinx-apidoc -f -e -o docs/ src/haddock -d 1
116+
sphinx-build -b html docs haddock3-docs
110117
```
111118

112119
> Warning messages are expected, but the documentation should be built successfully.

devtools/clean_dist_check.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ dev = [
5656
"fastapi==0.115.5",
5757
"httpx==0.28.0",
5858
"mpi4py==4.0.1",
59-
"kaleido==0.4.1",
59+
"kaleido==0.2.1",
6060
"pytest-random-order==1.1.1",
61-
6261
]
6362
docs = [
6463
"sphinx>=7",

src/haddock/libs/libcns.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from haddock.libs.libfunc import false, true
1414
from haddock.libs.libmath import RandomNumberGenerator
1515
from haddock.libs.libontology import PDBFile
16+
from haddock.libs.libpdb import check_combination_chains
1617
from haddock.libs.libutil import transform_to_list
1718

1819

@@ -335,25 +336,14 @@ def prepare_cns_input(
335336
# prepare chain/seg IDs
336337
segid_str = ""
337338
if native_segid:
338-
chainid_list: list[str] = []
339339
if isinstance(input_element, (list, tuple)):
340-
for pdb in input_element:
341-
342-
segids, chains = libpdb.identify_chainseg(pdb.rel_path, sort=False)
343-
344-
chainsegs = sorted(list(set(segids) | set(chains)))
345-
# check if any of chainsegs is already in chainid_list
346-
if not identifier.endswith("scoring"):
347-
if any(chainseg in chainid_list for chainseg in chainsegs):
348-
raise ValueError(
349-
f"Chain/seg IDs are not unique for pdbs {input_element}."
350-
)
351-
chainid_list.extend(chainsegs)
340+
chainid_list = check_combination_chains(input_element)
352341

353342
for i, _chainseg in enumerate(chainid_list, start=1):
354343
segid_str += write_eval_line(f"prot_segid_{i}", _chainseg)
355344

356345
else:
346+
chainid_list: list[str] = []
357347
segids, chains = libpdb.identify_chainseg(
358348
input_element.rel_path, sort=False
359349
)

0 commit comments

Comments
 (0)