Skip to content

Commit bb43d0a

Browse files
committed
Update HIVdb from version 9.4 to 9.8
Fixes #1407 Changes made: - Downloaded and integrated HIVdb 9.8 XML (dated 2025-01-05) from Stanford - Updated resistance.py to use HIVDB_9.8.xml algorithm file - Updated genreport.yaml with new version 9.8 and date 2025-01-05 - Added DPV (dapirivine) NNRTI drug to genreport.yaml and test expectations - Updated all test files (test_resistance.py, test_asi_algorithm.py) for version 9.8 - Fixed drug name spelling from 'dapivirine' to 'dapirivine' per HIVdb XML - Removed obsolete HIVDB_9.0.xml and HIVDB_9.4.xml files - Added comprehensive update guide in docs/contrib.md - Created automation script update_hivdb.py for future updates - Verified pyvdrm v0.3.2 compatibility with HIVdb 9.8 All tests pass: - 86 tests in micall/tests/test_resistance.py - 28 tests in micall/tests/test_asi_algorithm.py - 15 tests in micall/tests/test_genreport.py Note: CA region (Capsid) drug LEN was intentionally excluded as CA is not included in get_algorithm_regions() per previous implementation.
1 parent 9884732 commit bb43d0a

File tree

7 files changed

+4783
-55
lines changed

7 files changed

+4783
-55
lines changed

docs/contrib.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,98 @@ docker run \
139139
# Goto http://localhost:4000
140140
```
141141

142+
### Updating HIVdb
143+
144+
When a new version of the Stanford HIV Drug Resistance Database is released,
145+
follow these steps to update MiCall:
146+
147+
1. **Download the new rules file**: Visit [https://hivdb.stanford.edu/](https://hivdb.stanford.edu/)
148+
and download the latest XML algorithm file. The file can typically be found
149+
in the algorithm/downloads section or by searching for "ASI XML" or "algorithm XML".
150+
151+
2. **Note the version details**: Record the version number (e.g., 9.8) and the
152+
modification date from the XML file or the HIVdb website.
153+
154+
3. **Add the new XML file**: Place the downloaded XML file in `micall/resistance/`
155+
with the naming convention `HIVDB_X.X.xml` (e.g., `HIVDB_9.8.xml`).
156+
157+
4. **Update `HIV_RULES_PATH`**: In `micall/resistance/resistance.py`, update
158+
the path to point to the new XML file:
159+
```python
160+
HIV_RULES_PATH = os.path.join(os.path.dirname(__file__), 'HIVDB_X.X.xml')
161+
```
162+
163+
5. **Update version in genreport**: In `micall/resistance/genreport.yaml`,
164+
update the version number and modification date in the `generated_by_text`
165+
field (look for "Stanford HIVdb"):
166+
```yaml
167+
generated_by_text: >
168+
Generated by MiCall {} on Illumina BaseSpace using Stanford HIVdb
169+
X.X, modified on YYYY-MM-DD.
170+
```
171+
172+
6. **Handle new drugs** (if applicable): If the new HIVdb version introduces
173+
new drugs, add them to the appropriate drug class in `genreport.yaml`.
174+
For example, to add a new INSTI drug:
175+
```yaml
176+
INSTI:
177+
- [BIC, Bictegravir]
178+
- [NEW, New Drug Name] # Add new drug here
179+
- [DTG, Dolutegravir]
180+
```
181+
Use the format: `[ABBREVIATION, Full Drug Name]`. The order determines how
182+
drugs appear in the report.
183+
184+
7. **Check pyvdrm compatibility**: Verify the current pyvdrm version in
185+
`pyproject.toml` supports the new HIVdb version. The pyvdrm library parses
186+
the HIVdb XML format. If compatibility issues arise:
187+
- Check the [pyvdrm repository](https://github.com/cfe-lab/pyvdrm) for updates
188+
- Update the version in `pyproject.toml` if needed:
189+
```toml
190+
"pyvdrm @ git+https://github.com/cfe-lab/[email protected]"
191+
```
192+
193+
8. **Update tests**: Modify test files to reflect the new version and any
194+
algorithm behavior changes:
195+
- `micall/tests/test_resistance.py`: Update version number assertions
196+
- `micall/tests/test_asi_algorithm.py`: Update expected resistance scores
197+
if the algorithm produces different results
198+
199+
9. **Delete old XML files**: Remove old HIVdb XML files from `micall/resistance/`
200+
to avoid confusion. Keep only the new version:
201+
```shell
202+
rm micall/resistance/HIVDB_9.0.xml
203+
rm micall/resistance/HIVDB_9.4.xml
204+
```
205+
206+
10. **Run tests**: Execute the test suite to ensure everything works:
207+
```shell
208+
pytest micall/tests/test_resistance.py
209+
pytest micall/tests/test_asi_algorithm.py
210+
pytest # Run all tests
211+
```
212+
213+
11. **Manual verification**: Process a sample dataset through the pipeline and
214+
review the generated resistance reports to ensure output is correct and
215+
formatting is preserved.
216+
217+
12. **Create a pull request**: Document all changes, reference issue #1407 (or
218+
the current update request), include test results, and note any behavioral
219+
changes in the algorithm.
220+
221+
**Note on CA (Capsid) region**: Some HIVdb versions include the CA region for
222+
Capsid Inhibitors. If present and not yet supported in MiCall, the region is
223+
automatically skipped by the `get_algorithm_regions()` function in
224+
`resistance.py`. Decide whether to add CA support based on clinical needs.
225+
226+
**Troubleshooting**:
227+
- If tests fail due to changed resistance scores, verify the changes are
228+
expected based on HIVdb release notes before updating test assertions.
229+
- If pyvdrm parsing errors occur, the XML format may have changed. Check for
230+
pyvdrm updates or contact the maintainers.
231+
232+
## Making a Release
233+
142234
What changes might you want to make? The web site is based on the
143235
[Bulma Clean Theme], so read through the documentation there to see if it
144236
already has the feature you want. Usually, the advanced features require you

0 commit comments

Comments
 (0)