aiagents4pharma 1.45.0__py3-none-any.whl → 1.45.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,84 @@
1
1
  """
2
2
  Test cases for utils/pubchem_utils.py
3
+
4
+ These tests mock PubChem HTTP calls to avoid network dependency and verify
5
+ parsing logic without modifying business logic.
3
6
  """
4
7
 
8
+ from types import SimpleNamespace
9
+
10
+ import pytest
11
+
5
12
  from ..utils import pubchem_utils
6
13
 
7
14
 
15
+ def _resp(json_data):
16
+ """Create a minimal response-like object exposing .json()."""
17
+ return SimpleNamespace(json=lambda: json_data)
18
+
19
+
20
+ @pytest.fixture(autouse=True)
21
+ def mock_requests_get(monkeypatch):
22
+ """Mock requests.get used by pubchem_utils to return deterministic JSON."""
23
+
24
+ def _mock_get(url, _timeout=60, **_kwargs):
25
+ # CAS RN lookup: ethyl carbonate 105-58-8 -> CID 7766
26
+ if "substance/xref/RN/105-58-8/record/JSON" in url:
27
+ return _resp(
28
+ {"PC_Substances": [{"compound": [{"id": {"type": 1, "id": {"cid": 7766}}}]}]}
29
+ )
30
+
31
+ # DrugBank: DB00240 (Alclometasone) -> CID 5311000
32
+ if (
33
+ "substance/sourceid//drugbank/DB00240/JSON" in url
34
+ or "substance/sourceid/drugbank/DB00240/JSON" in url
35
+ ):
36
+ return _resp(
37
+ {"PC_Substances": [{"compound": [{"id": {"type": 1, "id": {"cid": 5311000}}}]}]}
38
+ )
39
+
40
+ # CTD: D002083 (Butylated Hydroxyanisole) -> CID 24667
41
+ if (
42
+ "substance/sourceid//comparative toxicogenomics database/D002083/JSON" in url
43
+ or "substance/sourceid/comparative toxicogenomics database/D002083/JSON" in url
44
+ ):
45
+ return _resp(
46
+ {"PC_Substances": [{"compound": [{"id": {"type": 1, "id": {"cid": 24667}}}]}]}
47
+ )
48
+
49
+ # CID description for 5311000
50
+ if (
51
+ "compound/cid//5311000/description/JSON" in url
52
+ or "compound/cid/5311000/description/JSON" in url
53
+ ):
54
+ return _resp(
55
+ {
56
+ "InformationList": {
57
+ "Information": [
58
+ {
59
+ "Description": (
60
+ "Alclometasone is a prednisolone compound having an "
61
+ "alpha-chloro substituent at the 9alpha-position."
62
+ ),
63
+ }
64
+ ]
65
+ }
66
+ }
67
+ )
68
+
69
+ # Default empty response
70
+ return _resp({})
71
+
72
+ monkeypatch.setattr(pubchem_utils.requests, "get", _mock_get)
73
+ return _mock_get
74
+
75
+
8
76
  def test_cas_rn2pubchem_cid():
9
77
  """
10
78
  Test the casRN2pubchem_cid function.
11
79
 
12
- The CAS RN for ethyl cabonate is 105-58-8.
13
- The PubChem CID for ethyl cabonate is 7766.
80
+ The CAS RN for ethyl carbonate is 105-58-8.
81
+ The PubChem CID for ethyl carbonate is 7766.
14
82
  """
15
83
  casrn = "105-58-8"
16
84
  pubchem_cid = pubchem_utils.cas_rn2pubchem_cid(casrn)
@@ -21,11 +89,8 @@ def test_external_id2pubchem_cid():
21
89
  """
22
90
  Test the external_id2pubchem_cid function.
23
91
 
24
- The DrugBank ID for Alclometasone is DB00240.
25
- The PubChem CID for Alclometasone is 5311000.
26
-
27
- The CTD ID for Butylated Hydroxyanisole is D002083
28
- The PubChem CID for Butylated Hydroxyanisole is 24667.
92
+ The DrugBank ID for Alclometasone is DB00240 -> CID 5311000.
93
+ The CTD ID for Butylated Hydroxyanisole is D002083 -> CID 24667.
29
94
  """
30
95
  drugbank_id = "DB00240"
31
96
  pubchem_cid = pubchem_utils.external_id2pubchem_cid("drugbank", drugbank_id)
@@ -35,7 +100,7 @@ def test_external_id2pubchem_cid():
35
100
  pubchem_cid = pubchem_utils.external_id2pubchem_cid(
36
101
  "comparative toxicogenomics database", ctd_id
37
102
  )
38
- assert pubchem_cid == 8456
103
+ assert pubchem_cid == 24667
39
104
 
40
105
 
41
106
  def test_pubchem_cid_description():
@@ -43,11 +108,16 @@ def test_pubchem_cid_description():
43
108
  Test the pubchem_cid_description function.
44
109
 
45
110
  The PubChem CID for Alclometasone is 5311000.
46
- The description for Alclometasone starts with
47
- "Alclometasone is a prednisolone compound having an alpha-chloro substituent".
111
+ The description starts with the expected prefix.
48
112
  """
49
113
  pubchem_cid = 5311000
50
114
  description = pubchem_utils.pubchem_cid_description(pubchem_cid)
51
115
  assert description.startswith(
52
116
  "Alclometasone is a prednisolone compound having an alpha-chloro substituent"
53
117
  )
118
+
119
+
120
+ def test_mock_fallback_path_coverage():
121
+ """Exercise the default branch of the mocked requests.get for coverage."""
122
+ resp = pubchem_utils.requests.get("unknown://unmatched/url", timeout=1)
123
+ assert resp.json() == {}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiagents4pharma
3
- Version: 1.45.0
3
+ Version: 1.45.1
4
4
  Summary: AI Agents for drug discovery, drug development, and other pharmaceutical R&D.
5
5
  License-File: LICENSE
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -57,7 +57,6 @@ Requires-Dist: pydantic==2.10.5
57
57
  Requires-Dist: pygeneconverter==0.3
58
58
  Requires-Dist: pylint==3.3.1
59
59
  Requires-Dist: pymilvus==2.5.11
60
- Requires-Dist: pypdf2==3.0.1
61
60
  Requires-Dist: pypdf==6.0.0
62
61
  Requires-Dist: pytest-asyncio==0.25.2
63
62
  Requires-Dist: pytest==8.3.3
@@ -99,7 +98,7 @@ Description-Content-Type: text/markdown
99
98
  <!-- Deployment Workflows -->
100
99
 
101
100
  [![Pages Deployment](https://github.com/VirtualPatientEngine/AIAgents4Pharma/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/VirtualPatientEngine/AIAgents4Pharma/actions/workflows/pages/pages-build-deployment)
102
- [![MkDocs Deploy](https://github.com/VirtualPatientEngine/AIAgents4Pharma/actions/workflows/mkdocs-deploy.yml/badge.svg)](https://github.com/VirtualPatientEngine/AIAgents4Pharma/actions/workflows/mkdocs-deploy.yml)
101
+ [![MkDocs Deploy](https://github.com/VirtualPatientEngine/AIAgents4Pharma/actions/workflows/mkdocs_deploy.yml/badge.svg)](https://github.com/VirtualPatientEngine/AIAgents4Pharma/actions/workflows/mkdocs_deploy.yml)
103
102
  [![Docker Build & Push](https://github.com/VirtualPatientEngine/AIAgents4Pharma/actions/workflows/docker_build.yml/badge.svg)](https://github.com/VirtualPatientEngine/AIAgents4Pharma/actions/workflows/docker_build.yml)
104
103
  [![Docker Compose Release](https://github.com/VirtualPatientEngine/AIAgents4Pharma/actions/workflows/docker_compose_release.yml/badge.svg)](https://github.com/VirtualPatientEngine/AIAgents4Pharma/actions/workflows/docker_compose_release.yml)
105
104
 
@@ -150,7 +150,7 @@ aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_reactome.py,sh
150
150
  aiagents4pharma/talk2knowledgegraphs/tests/test_utils_enrichments_uniprot.py,sha256=8JqptVypftx4IrObzxGPDjQ1C7I24f3zUUx69D8svAo,1615
151
151
  aiagents4pharma/talk2knowledgegraphs/tests/test_utils_extractions_milvus_multimodal_pcst.py,sha256=Oo6IvPB9L9lAmdxc4UqFJVX-lYYdFKYv3lNaHrjkvS8,21515
152
152
  aiagents4pharma/talk2knowledgegraphs/tests/test_utils_kg_utils.py,sha256=RDheTkkRxnGCxIoaTmTRKOQA2ewJyOOlKtgxdABgSSA,2397
153
- aiagents4pharma/talk2knowledgegraphs/tests/test_utils_pubchem_utils.py,sha256=OWmxd7d7E3Z63UpiFMTAXBM2fmGSUE9UFUXiUMxk61I,1522
153
+ aiagents4pharma/talk2knowledgegraphs/tests/test_utils_pubchem_utils.py,sha256=80PhbFXD287LeCwGpXGtPal5vkjqKKCACefR_BPdfbM,3967
154
154
  aiagents4pharma/talk2knowledgegraphs/tools/__init__.py,sha256=unrqqDUAmfTpgiJSV65Pag9FWHpnf3eEsE8Cwh59NWI,242
155
155
  aiagents4pharma/talk2knowledgegraphs/tools/graphrag_reasoning.py,sha256=cCPBH1tKs9MjX1q9v6BXi-dInz_gxKwMyIVA-XdKocg,5251
156
156
  aiagents4pharma/talk2knowledgegraphs/tools/load_arguments.py,sha256=zhmsRp-8vjB5rRekqTA07d3yb-42HWqng9dDMkvK6hM,623
@@ -318,7 +318,7 @@ aiagents4pharma/talk2scholars/tools/zotero/utils/review_helper.py,sha256=-q-UuzP
318
318
  aiagents4pharma/talk2scholars/tools/zotero/utils/write_helper.py,sha256=K1EatPfC-riGyFmkOAS3ReNBaGPY-znne1KqOnFahkI,7339
319
319
  aiagents4pharma/talk2scholars/tools/zotero/utils/zotero_path.py,sha256=sKkfJu3u4LKSZjfoQRfeqz26IESHRwBtcSDzLMLlJMo,6311
320
320
  aiagents4pharma/talk2scholars/tools/zotero/utils/zotero_pdf_downloader.py,sha256=DBrF5IiF7VRP58hUK8T9LST3lQWLFixLUfnpMSTccoQ,4614
321
- aiagents4pharma-1.45.0.dist-info/METADATA,sha256=1AaG7ESWZtjMhF88cLZNOKf2BYGFh0ZnDI5fovUJuoY,16314
322
- aiagents4pharma-1.45.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
323
- aiagents4pharma-1.45.0.dist-info/licenses/LICENSE,sha256=IcIbyB1Hyk5ZDah03VNQvJkbNk2hkBCDqQ8qtnCvB4Q,1077
324
- aiagents4pharma-1.45.0.dist-info/RECORD,,
321
+ aiagents4pharma-1.45.1.dist-info/METADATA,sha256=JFqD43WM9t6Qp9zi5odBVfXPhDC5WCsmY_pe4RkbGcU,16285
322
+ aiagents4pharma-1.45.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
323
+ aiagents4pharma-1.45.1.dist-info/licenses/LICENSE,sha256=IcIbyB1Hyk5ZDah03VNQvJkbNk2hkBCDqQ8qtnCvB4Q,1077
324
+ aiagents4pharma-1.45.1.dist-info/RECORD,,