Skip to content

Commit 3baaa03

Browse files
authored
Merge pull request #86 from njzjz/copilot/sub-pr-85
2 parents 4484383 + 41eb096 commit 3baaa03

3 files changed

Lines changed: 114 additions & 84 deletions

File tree

tests/cases.py

Lines changed: 78 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class ReferenceCase:
1717
expected_markdown: str
1818
pmid: int | None = None
1919
arxiv: str | None = None
20+
skip_reason: str | None = None
2021

2122
@property
2223
def expected_text(self) -> str:
@@ -390,82 +391,83 @@ def expected_text(self) -> str:
390391
expected_markdown=r"Jinzhe Zeng, Linfeng Zhang, Han Wang, Tong Zhu, Exploring the Chemical Space of Linear Alkane Pyrolysis via Deep Potential GENerator, *Energy Fuels*, 2021, 35, 762-769, DOI: [10.1021/acs.energyfuels.0c03211](https://doi.org/10.1021/acs.energyfuels.0c03211). [![Citations](https://citations.njzjz.win/10.1021/acs.energyfuels.0c03211)](https://badge.dimensions.ai/details/doi/10.1021/acs.energyfuels.0c03211)",
391392
),
392393
# ChemRxiv
393-
# ReferenceCase(
394-
# reference=Reference(
395-
# author=[
396-
# Author(first="Manyi", last="Yang"),
397-
# Author(first="Duo", last="Zhang"),
398-
# Author(first="Xinyan", last="Wang"),
399-
# # why not Linfeng???
400-
# Author(first="Lingfeng", last="Zhang"),
401-
# Author(first="Tong", last="Zhu"),
402-
# Author(first="Han", last="Wang"),
403-
# ],
404-
# title="Ab initio Accuracy Neural Network Potential for Drug-like Molecules",
405-
# journal="ChemRxiv",
406-
# year=2024,
407-
# annote=textwrap.dedent("""\
408-
# <jats:p>The advent of machine learning
409-
# (ML) in computational chemistry heralds a transformative approach to
410-
# one of the quintessential challenges in computer-aided drug design
411-
# (CADD): the accurate and cost-effective calculation of atomic
412-
# interactions. By leveraging a neural network (NN) potential, we
413-
# address this balance and push the boundaries of the NN potential's
414-
# representational capacity. Our work details the development of a
415-
# robust general-purpose NN potential, architected on the framework of
416-
# DPA-2, a deep learning potential with attention, which demonstrates
417-
# remarkable fidelity in replicating the interatomic potential energy
418-
# surface for drug-like molecules comprising eight critical chemical
419-
# elements: H, C, N, O, F, S, Cl, and P. We employed state-of-the-art
420-
# molecular dynamic techniques, including temperature acceleration and
421-
# enhanced sampling, to construct a comprehensive dataset to ensure
422-
# exhaustive coverage of relevant configurational spaces. Our rigorous
423-
# testing protocols, including torsion scanning, global minimum
424-
# searches, and high-temperature MD simulations across various organic
425-
# molecules, have culminated in an NN model that achieves chemical
426-
# precision commensurate with the highly regarded DFT model, while
427-
# significantly outstripping the accuracy of prevalent semi-empirical
428-
# methods. This study presents a leap forward in the predictive
429-
# modelling of molecular interactions, offering extensive applications
430-
# in drug development and beyond.</jats:p>
431-
# """)
432-
# .strip()
433-
# .replace("\n", " "),
434-
# doi="10.26434/chemrxiv-2024-sq8nh",
435-
# ),
436-
# expected_bibtex=textwrap.dedent(r"""
437-
# @Article{Yang_ChemRxiv_2024,
438-
# author = {Manyi Yang and Duo Zhang and Xinyan Wang and Lingfeng Zhang and Tong
439-
# Zhu and Han Wang},
440-
# title = {{Ab initio Accuracy Neural Network Potential for Drug-like Molecules}},
441-
# journal = {ChemRxiv},
442-
# year = 2024,
443-
# doi = {10.26434/chemrxiv-2024-sq8nh},
444-
# abstract = {The advent of machine learning (ML) in computational chemistry heralds
445-
# a transformative approach to one of the quintessential challenges in
446-
# computer-aided drug design (CADD): the accurate and cost-effective
447-
# calculation of atomic interactions. By leveraging a neural network
448-
# (NN) potential, we address this balance and push the boundaries of the
449-
# NN potential's representational capacity. Our work details the
450-
# development of a robust general-purpose NN potential, architected on
451-
# the framework of DPA-2, a deep learning potential with attention,
452-
# which demonstrates remarkable fidelity in replicating the interatomic
453-
# potential energy surface for drug-like molecules comprising eight
454-
# critical chemical elements: H, C, N, O, F, S, Cl, and P. We employed
455-
# state-of-the-art molecular dynamic techniques, including temperature
456-
# acceleration and enhanced sampling, to construct a comprehensive
457-
# dataset to ensure exhaustive coverage of relevant configurational
458-
# spaces. Our rigorous testing protocols, including torsion scanning,
459-
# global minimum searches, and high-temperature MD simulations across
460-
# various organic molecules, have culminated in an NN model that
461-
# achieves chemical precision commensurate with the highly regarded DFT
462-
# model, while significantly outstripping the accuracy of prevalent
463-
# semi-empirical methods. This study presents a leap forward in the
464-
# predictive modelling of molecular interactions, offering extensive
465-
# applications in drug development and beyond.},
466-
# }""").strip(),
467-
# expected_markdown=r"Manyi Yang, Duo Zhang, Xinyan Wang, Lingfeng Zhang, Tong Zhu, Han Wang, Ab initio Accuracy Neural Network Potential for Drug-like Molecules, *ChemRxiv*, 2024, DOI: [10.26434/chemrxiv-2024-sq8nh](https://doi.org/10.26434/chemrxiv-2024-sq8nh). [![Citations](https://citations.njzjz.win/10.26434/chemrxiv-2024-sq8nh)](https://badge.dimensions.ai/details/doi/10.26434/chemrxiv-2024-sq8nh)",
468-
# ),
394+
ReferenceCase(
395+
reference=Reference(
396+
author=[
397+
Author(first="Manyi", last="Yang"),
398+
Author(first="Duo", last="Zhang"),
399+
Author(first="Xinyan", last="Wang"),
400+
# why not Linfeng???
401+
Author(first="Lingfeng", last="Zhang"),
402+
Author(first="Tong", last="Zhu"),
403+
Author(first="Han", last="Wang"),
404+
],
405+
title="Ab initio Accuracy Neural Network Potential for Drug-like Molecules",
406+
journal="ChemRxiv",
407+
year=2024,
408+
annote=textwrap.dedent("""\
409+
<jats:p>The advent of machine learning
410+
(ML) in computational chemistry heralds a transformative approach to
411+
one of the quintessential challenges in computer-aided drug design
412+
(CADD): the accurate and cost-effective calculation of atomic
413+
interactions. By leveraging a neural network (NN) potential, we
414+
address this balance and push the boundaries of the NN potential's
415+
representational capacity. Our work details the development of a
416+
robust general-purpose NN potential, architected on the framework of
417+
DPA-2, a deep learning potential with attention, which demonstrates
418+
remarkable fidelity in replicating the interatomic potential energy
419+
surface for drug-like molecules comprising eight critical chemical
420+
elements: H, C, N, O, F, S, Cl, and P. We employed state-of-the-art
421+
molecular dynamic techniques, including temperature acceleration and
422+
enhanced sampling, to construct a comprehensive dataset to ensure
423+
exhaustive coverage of relevant configurational spaces. Our rigorous
424+
testing protocols, including torsion scanning, global minimum
425+
searches, and high-temperature MD simulations across various organic
426+
molecules, have culminated in an NN model that achieves chemical
427+
precision commensurate with the highly regarded DFT model, while
428+
significantly outstripping the accuracy of prevalent semi-empirical
429+
methods. This study presents a leap forward in the predictive
430+
modelling of molecular interactions, offering extensive applications
431+
in drug development and beyond.</jats:p>
432+
""")
433+
.strip()
434+
.replace("\n", " "),
435+
doi="10.26434/chemrxiv-2024-sq8nh",
436+
),
437+
expected_bibtex=textwrap.dedent(r"""
438+
@Article{Yang_ChemRxiv_2024,
439+
author = {Manyi Yang and Duo Zhang and Xinyan Wang and Lingfeng Zhang and Tong
440+
Zhu and Han Wang},
441+
title = {{Ab initio Accuracy Neural Network Potential for Drug-like Molecules}},
442+
journal = {ChemRxiv},
443+
year = 2024,
444+
doi = {10.26434/chemrxiv-2024-sq8nh},
445+
abstract = {The advent of machine learning (ML) in computational chemistry heralds
446+
a transformative approach to one of the quintessential challenges in
447+
computer-aided drug design (CADD): the accurate and cost-effective
448+
calculation of atomic interactions. By leveraging a neural network
449+
(NN) potential, we address this balance and push the boundaries of the
450+
NN potential's representational capacity. Our work details the
451+
development of a robust general-purpose NN potential, architected on
452+
the framework of DPA-2, a deep learning potential with attention,
453+
which demonstrates remarkable fidelity in replicating the interatomic
454+
potential energy surface for drug-like molecules comprising eight
455+
critical chemical elements: H, C, N, O, F, S, Cl, and P. We employed
456+
state-of-the-art molecular dynamic techniques, including temperature
457+
acceleration and enhanced sampling, to construct a comprehensive
458+
dataset to ensure exhaustive coverage of relevant configurational
459+
spaces. Our rigorous testing protocols, including torsion scanning,
460+
global minimum searches, and high-temperature MD simulations across
461+
various organic molecules, have culminated in an NN model that
462+
achieves chemical precision commensurate with the highly regarded DFT
463+
model, while significantly outstripping the accuracy of prevalent
464+
semi-empirical methods. This study presents a leap forward in the
465+
predictive modelling of molecular interactions, offering extensive
466+
applications in drug development and beyond.},
467+
}""").strip(),
468+
expected_markdown=r"Manyi Yang, Duo Zhang, Xinyan Wang, Lingfeng Zhang, Tong Zhu, Han Wang, Ab initio Accuracy Neural Network Potential for Drug-like Molecules, *ChemRxiv*, 2024, DOI: [10.26434/chemrxiv-2024-sq8nh](https://doi.org/10.26434/chemrxiv-2024-sq8nh). [![Citations](https://citations.njzjz.win/10.26434/chemrxiv-2024-sq8nh)](https://badge.dimensions.ai/details/doi/10.26434/chemrxiv-2024-sq8nh)",
469+
skip_reason="ChemRxiv API broken",
470+
),
469471
# chapter
470472
ReferenceCase(
471473
reference=Reference(

tests/test_from_identifier.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,35 @@
66

77
from wenxian.from_identifier import from_identifier
88

9-
from .cases import TEST_CASES
9+
from .cases import TEST_CASES, ReferenceCase
10+
11+
12+
def _create_test_param(test_case: ReferenceCase, identifier: str | None):
13+
"""Create a pytest.param with skip marks if needed."""
14+
return pytest.param(
15+
identifier,
16+
test_case.reference,
17+
marks=pytest.mark.skip(reason=test_case.skip_reason)
18+
if test_case.skip_reason
19+
else (),
20+
)
1021

1122

1223
@pytest.mark.parametrize(
1324
"identifier, expected",
1425
[
15-
*[(test_case.reference.doi, test_case.reference) for test_case in TEST_CASES],
26+
*[
27+
_create_test_param(test_case, test_case.reference.doi)
28+
for test_case in TEST_CASES
29+
],
1630
*[
1731
# from_identifier accept str
18-
(str(test_case.pmid), test_case.reference)
32+
_create_test_param(test_case, str(test_case.pmid))
1933
for test_case in TEST_CASES
2034
if test_case.pmid is not None
2135
],
2236
*[
23-
(test_case.arxiv, test_case.reference)
37+
_create_test_param(test_case, test_case.arxiv)
2438
for test_case in TEST_CASES
2539
if test_case.arxiv is not None
2640
],

tests/test_output.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,44 @@
66

77
import pytest
88

9-
from .cases import TEST_CASES
9+
from .cases import TEST_CASES, ReferenceCase
1010

1111
if TYPE_CHECKING:
1212
from wenxian.reference import Reference
1313

1414

15+
def _create_test_param(test_case: ReferenceCase, expected_value: str):
16+
"""Create a pytest.param with skip marks if needed."""
17+
return pytest.param(
18+
test_case.reference,
19+
expected_value,
20+
marks=pytest.mark.skip(reason=test_case.skip_reason)
21+
if test_case.skip_reason
22+
else (),
23+
)
24+
25+
1526
@pytest.mark.parametrize(
16-
"reference, expected", [(cc.reference, cc.expected_bibtex) for cc in TEST_CASES]
27+
"reference, expected",
28+
[_create_test_param(cc, cc.expected_bibtex) for cc in TEST_CASES],
1729
)
1830
def test_bibtex(reference: Reference, expected):
1931
"""Test generating BibTeX entries from references."""
2032
assert reference.bibtex.strip() == expected
2133

2234

2335
@pytest.mark.parametrize(
24-
"reference, expected", [(cc.reference, cc.expected_markdown) for cc in TEST_CASES]
36+
"reference, expected",
37+
[_create_test_param(cc, cc.expected_markdown) for cc in TEST_CASES],
2538
)
2639
def test_markdown(reference: Reference, expected):
2740
"""Test generating Markdown from references."""
2841
assert reference.markdown.strip() == expected
2942

3043

3144
@pytest.mark.parametrize(
32-
"reference, expected", [(cc.reference, cc.expected_text) for cc in TEST_CASES]
45+
"reference, expected",
46+
[_create_test_param(cc, cc.expected_text) for cc in TEST_CASES],
3347
)
3448
def test_text(reference: Reference, expected):
3549
"""Test generating text from references."""

0 commit comments

Comments
 (0)