tooluniverse 0.2.0__py3-none-any.whl → 1.0.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.
Potentially problematic release.
This version of tooluniverse might be problematic. Click here for more details.
- tooluniverse/__init__.py +340 -4
- tooluniverse/admetai_tool.py +84 -0
- tooluniverse/agentic_tool.py +563 -0
- tooluniverse/alphafold_tool.py +96 -0
- tooluniverse/base_tool.py +129 -6
- tooluniverse/boltz_tool.py +207 -0
- tooluniverse/chem_tool.py +192 -0
- tooluniverse/compose_scripts/__init__.py +1 -0
- tooluniverse/compose_scripts/biomarker_discovery.py +293 -0
- tooluniverse/compose_scripts/comprehensive_drug_discovery.py +186 -0
- tooluniverse/compose_scripts/drug_safety_analyzer.py +89 -0
- tooluniverse/compose_scripts/literature_tool.py +34 -0
- tooluniverse/compose_scripts/output_summarizer.py +279 -0
- tooluniverse/compose_scripts/tool_description_optimizer.py +681 -0
- tooluniverse/compose_scripts/tool_discover.py +705 -0
- tooluniverse/compose_scripts/tool_graph_composer.py +448 -0
- tooluniverse/compose_tool.py +371 -0
- tooluniverse/ctg_tool.py +1002 -0
- tooluniverse/custom_tool.py +81 -0
- tooluniverse/dailymed_tool.py +108 -0
- tooluniverse/data/admetai_tools.json +155 -0
- tooluniverse/data/adverse_event_tools.json +108 -0
- tooluniverse/data/agentic_tools.json +1156 -0
- tooluniverse/data/alphafold_tools.json +87 -0
- tooluniverse/data/boltz_tools.json +9 -0
- tooluniverse/data/chembl_tools.json +16 -0
- tooluniverse/data/clinicaltrials_gov_tools.json +326 -0
- tooluniverse/data/compose_tools.json +202 -0
- tooluniverse/data/dailymed_tools.json +70 -0
- tooluniverse/data/dataset_tools.json +646 -0
- tooluniverse/data/disease_target_score_tools.json +712 -0
- tooluniverse/data/efo_tools.json +17 -0
- tooluniverse/data/embedding_tools.json +319 -0
- tooluniverse/data/enrichr_tools.json +31 -0
- tooluniverse/data/europe_pmc_tools.json +22 -0
- tooluniverse/data/expert_feedback_tools.json +10 -0
- tooluniverse/data/fda_drug_adverse_event_tools.json +491 -0
- tooluniverse/data/fda_drug_labeling_tools.json +1 -1
- tooluniverse/data/fda_drugs_with_brand_generic_names_for_tool.py +76929 -148860
- tooluniverse/data/finder_tools.json +209 -0
- tooluniverse/data/gene_ontology_tools.json +113 -0
- tooluniverse/data/gwas_tools.json +1082 -0
- tooluniverse/data/hpa_tools.json +333 -0
- tooluniverse/data/humanbase_tools.json +47 -0
- tooluniverse/data/idmap_tools.json +74 -0
- tooluniverse/data/mcp_client_tools_example.json +113 -0
- tooluniverse/data/mcpautoloadertool_defaults.json +28 -0
- tooluniverse/data/medlineplus_tools.json +141 -0
- tooluniverse/data/monarch_tools.json +1 -1
- tooluniverse/data/openalex_tools.json +36 -0
- tooluniverse/data/opentarget_tools.json +1 -1
- tooluniverse/data/output_summarization_tools.json +101 -0
- tooluniverse/data/packages/bioinformatics_core_tools.json +1756 -0
- tooluniverse/data/packages/categorized_tools.txt +206 -0
- tooluniverse/data/packages/cheminformatics_tools.json +347 -0
- tooluniverse/data/packages/earth_sciences_tools.json +74 -0
- tooluniverse/data/packages/genomics_tools.json +776 -0
- tooluniverse/data/packages/image_processing_tools.json +38 -0
- tooluniverse/data/packages/machine_learning_tools.json +789 -0
- tooluniverse/data/packages/neuroscience_tools.json +62 -0
- tooluniverse/data/packages/original_tools.txt +0 -0
- tooluniverse/data/packages/physics_astronomy_tools.json +62 -0
- tooluniverse/data/packages/scientific_computing_tools.json +560 -0
- tooluniverse/data/packages/single_cell_tools.json +453 -0
- tooluniverse/data/packages/structural_biology_tools.json +396 -0
- tooluniverse/data/packages/visualization_tools.json +399 -0
- tooluniverse/data/pubchem_tools.json +215 -0
- tooluniverse/data/pubtator_tools.json +68 -0
- tooluniverse/data/rcsb_pdb_tools.json +1332 -0
- tooluniverse/data/reactome_tools.json +19 -0
- tooluniverse/data/semantic_scholar_tools.json +26 -0
- tooluniverse/data/special_tools.json +2 -25
- tooluniverse/data/tool_composition_tools.json +88 -0
- tooluniverse/data/toolfinderkeyword_defaults.json +34 -0
- tooluniverse/data/txagent_client_tools.json +9 -0
- tooluniverse/data/uniprot_tools.json +211 -0
- tooluniverse/data/url_fetch_tools.json +94 -0
- tooluniverse/data/uspto_downloader_tools.json +9 -0
- tooluniverse/data/uspto_tools.json +811 -0
- tooluniverse/data/xml_tools.json +3275 -0
- tooluniverse/dataset_tool.py +296 -0
- tooluniverse/default_config.py +165 -0
- tooluniverse/efo_tool.py +42 -0
- tooluniverse/embedding_database.py +630 -0
- tooluniverse/embedding_sync.py +396 -0
- tooluniverse/enrichr_tool.py +266 -0
- tooluniverse/europe_pmc_tool.py +52 -0
- tooluniverse/execute_function.py +1775 -95
- tooluniverse/extended_hooks.py +444 -0
- tooluniverse/gene_ontology_tool.py +194 -0
- tooluniverse/graphql_tool.py +158 -36
- tooluniverse/gwas_tool.py +358 -0
- tooluniverse/hpa_tool.py +1645 -0
- tooluniverse/humanbase_tool.py +389 -0
- tooluniverse/logging_config.py +254 -0
- tooluniverse/mcp_client_tool.py +764 -0
- tooluniverse/mcp_integration.py +413 -0
- tooluniverse/mcp_tool_registry.py +925 -0
- tooluniverse/medlineplus_tool.py +337 -0
- tooluniverse/openalex_tool.py +228 -0
- tooluniverse/openfda_adv_tool.py +283 -0
- tooluniverse/openfda_tool.py +393 -160
- tooluniverse/output_hook.py +1122 -0
- tooluniverse/package_tool.py +195 -0
- tooluniverse/pubchem_tool.py +158 -0
- tooluniverse/pubtator_tool.py +168 -0
- tooluniverse/rcsb_pdb_tool.py +38 -0
- tooluniverse/reactome_tool.py +108 -0
- tooluniverse/remote/boltz/boltz_mcp_server.py +50 -0
- tooluniverse/remote/depmap_24q2/depmap_24q2_mcp_tool.py +442 -0
- tooluniverse/remote/expert_feedback/human_expert_mcp_tools.py +2013 -0
- tooluniverse/remote/expert_feedback/simple_test.py +23 -0
- tooluniverse/remote/expert_feedback/start_web_interface.py +188 -0
- tooluniverse/remote/expert_feedback/web_only_interface.py +0 -0
- tooluniverse/remote/immune_compass/compass_tool.py +327 -0
- tooluniverse/remote/pinnacle/pinnacle_tool.py +328 -0
- tooluniverse/remote/transcriptformer/transcriptformer_tool.py +586 -0
- tooluniverse/remote/uspto_downloader/uspto_downloader_mcp_server.py +61 -0
- tooluniverse/remote/uspto_downloader/uspto_downloader_tool.py +120 -0
- tooluniverse/remote_tool.py +99 -0
- tooluniverse/restful_tool.py +53 -30
- tooluniverse/scripts/generate_tool_graph.py +408 -0
- tooluniverse/scripts/visualize_tool_graph.py +829 -0
- tooluniverse/semantic_scholar_tool.py +62 -0
- tooluniverse/smcp.py +2452 -0
- tooluniverse/smcp_server.py +975 -0
- tooluniverse/test/mcp_server_test.py +0 -0
- tooluniverse/test/test_admetai_tool.py +370 -0
- tooluniverse/test/test_agentic_tool.py +129 -0
- tooluniverse/test/test_alphafold_tool.py +71 -0
- tooluniverse/test/test_chem_tool.py +37 -0
- tooluniverse/test/test_compose_lieraturereview.py +63 -0
- tooluniverse/test/test_compose_tool.py +448 -0
- tooluniverse/test/test_dailymed.py +69 -0
- tooluniverse/test/test_dataset_tool.py +200 -0
- tooluniverse/test/test_disease_target_score.py +56 -0
- tooluniverse/test/test_drugbank_filter_examples.py +179 -0
- tooluniverse/test/test_efo.py +31 -0
- tooluniverse/test/test_enrichr_tool.py +21 -0
- tooluniverse/test/test_europe_pmc_tool.py +20 -0
- tooluniverse/test/test_fda_adv.py +95 -0
- tooluniverse/test/test_fda_drug_labeling.py +91 -0
- tooluniverse/test/test_gene_ontology_tools.py +66 -0
- tooluniverse/test/test_gwas_tool.py +139 -0
- tooluniverse/test/test_hpa.py +625 -0
- tooluniverse/test/test_humanbase_tool.py +20 -0
- tooluniverse/test/test_idmap_tools.py +61 -0
- tooluniverse/test/test_mcp_server.py +211 -0
- tooluniverse/test/test_mcp_tool.py +247 -0
- tooluniverse/test/test_medlineplus.py +220 -0
- tooluniverse/test/test_openalex_tool.py +32 -0
- tooluniverse/test/test_opentargets.py +28 -0
- tooluniverse/test/test_pubchem_tool.py +116 -0
- tooluniverse/test/test_pubtator_tool.py +37 -0
- tooluniverse/test/test_rcsb_pdb_tool.py +86 -0
- tooluniverse/test/test_reactome.py +54 -0
- tooluniverse/test/test_semantic_scholar_tool.py +24 -0
- tooluniverse/test/test_software_tools.py +147 -0
- tooluniverse/test/test_tool_description_optimizer.py +49 -0
- tooluniverse/test/test_tool_finder.py +26 -0
- tooluniverse/test/test_tool_finder_llm.py +252 -0
- tooluniverse/test/test_tools_find.py +195 -0
- tooluniverse/test/test_uniprot_tools.py +74 -0
- tooluniverse/test/test_uspto_tool.py +72 -0
- tooluniverse/test/test_xml_tool.py +113 -0
- tooluniverse/tool_finder_embedding.py +267 -0
- tooluniverse/tool_finder_keyword.py +693 -0
- tooluniverse/tool_finder_llm.py +699 -0
- tooluniverse/tool_graph_web_ui.py +955 -0
- tooluniverse/tool_registry.py +416 -0
- tooluniverse/uniprot_tool.py +155 -0
- tooluniverse/url_tool.py +253 -0
- tooluniverse/uspto_tool.py +240 -0
- tooluniverse/utils.py +369 -41
- tooluniverse/xml_tool.py +369 -0
- tooluniverse-1.0.1.dist-info/METADATA +387 -0
- tooluniverse-1.0.1.dist-info/RECORD +182 -0
- tooluniverse-1.0.1.dist-info/entry_points.txt +9 -0
- tooluniverse/generate_mcp_tools.py +0 -113
- tooluniverse/mcp_server.py +0 -3340
- tooluniverse-0.2.0.dist-info/METADATA +0 -139
- tooluniverse-0.2.0.dist-info/RECORD +0 -21
- tooluniverse-0.2.0.dist-info/entry_points.txt +0 -4
- {tooluniverse-0.2.0.dist-info → tooluniverse-1.0.1.dist-info}/WHEEL +0 -0
- {tooluniverse-0.2.0.dist-info → tooluniverse-1.0.1.dist-info}/licenses/LICENSE +0 -0
- {tooluniverse-0.2.0.dist-info → tooluniverse-1.0.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
from tooluniverse import ToolUniverse
|
|
2
|
+
|
|
3
|
+
# Step 1: Initialize tool universe
|
|
4
|
+
tooluni = ToolUniverse()
|
|
5
|
+
tooluni.load_tools()
|
|
6
|
+
|
|
7
|
+
test_queries = [
|
|
8
|
+
# Test 1: Search for a specific drug by name
|
|
9
|
+
{"name": "drugbank_vocab_search", "arguments": {"query": "aspirin"}},
|
|
10
|
+
# Test 2: Exact match search for a DrugBank ID
|
|
11
|
+
{
|
|
12
|
+
"name": "drugbank_vocab_search",
|
|
13
|
+
"arguments": {
|
|
14
|
+
"query": "DB00001",
|
|
15
|
+
"search_fields": ["DrugBank ID"],
|
|
16
|
+
"exact_match": True,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
# Test 3: Search in synonyms with case sensitivity
|
|
20
|
+
{
|
|
21
|
+
"name": "drugbank_vocab_search",
|
|
22
|
+
"arguments": {
|
|
23
|
+
"query": "Lepirudin",
|
|
24
|
+
"search_fields": ["Synonyms", "Common name"],
|
|
25
|
+
"case_sensitive": True,
|
|
26
|
+
"limit": 10,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
# Test 4: Filter drugs that have CAS numbers
|
|
30
|
+
{
|
|
31
|
+
"name": "drugbank_vocab_filter",
|
|
32
|
+
"arguments": {"field": "CAS", "condition": "not_empty", "limit": 5},
|
|
33
|
+
},
|
|
34
|
+
# Test 5: Filter drugs starting with "DB000"
|
|
35
|
+
{
|
|
36
|
+
"name": "drugbank_vocab_filter",
|
|
37
|
+
"arguments": {
|
|
38
|
+
"field": "DrugBank ID",
|
|
39
|
+
"condition": "starts_with",
|
|
40
|
+
"value": "DB000",
|
|
41
|
+
"limit": 10,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
# Test 6: Filter drugs containing "interferon" in common name
|
|
45
|
+
{
|
|
46
|
+
"name": "drugbank_vocab_filter",
|
|
47
|
+
"arguments": {
|
|
48
|
+
"field": "Common name",
|
|
49
|
+
"condition": "contains",
|
|
50
|
+
"value": "interferon",
|
|
51
|
+
"limit": 5,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
# Test 7: Complex search with multiple fields
|
|
55
|
+
{
|
|
56
|
+
"name": "drugbank_vocab_search",
|
|
57
|
+
"arguments": {
|
|
58
|
+
"query": "insulin",
|
|
59
|
+
"search_fields": ["Common name", "Synonyms"],
|
|
60
|
+
"case_sensitive": False,
|
|
61
|
+
"exact_match": False,
|
|
62
|
+
"limit": 3,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
# ---------- drugbank_full_search ----------
|
|
66
|
+
# 1. Partial common-name query
|
|
67
|
+
{
|
|
68
|
+
"name": "drugbank_full_search",
|
|
69
|
+
"arguments": {
|
|
70
|
+
"query": "acetylsalicylic",
|
|
71
|
+
"search_fields": ["name"],
|
|
72
|
+
"limit": 5,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
# 2. Exact-match lookup by DrugBank ID
|
|
76
|
+
{
|
|
77
|
+
"name": "drugbank_full_search",
|
|
78
|
+
"arguments": {
|
|
79
|
+
"query": "DB00003",
|
|
80
|
+
"search_fields": ["drugbank_id"],
|
|
81
|
+
"exact_match": True,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
# 3. Case-sensitive synonym search
|
|
85
|
+
{
|
|
86
|
+
"name": "drugbank_full_search",
|
|
87
|
+
"arguments": {
|
|
88
|
+
"query": "Olanzapine",
|
|
89
|
+
"search_fields": ["synonyms"],
|
|
90
|
+
"case_sensitive": True,
|
|
91
|
+
"limit": 3,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
# ---------- drugbank_links_search ----------
|
|
95
|
+
# 4. Exact CAS-number lookup
|
|
96
|
+
{
|
|
97
|
+
"name": "drugbank_links_search",
|
|
98
|
+
"arguments": {
|
|
99
|
+
"query": "205923-56-4",
|
|
100
|
+
"search_fields": ["CAS Number"],
|
|
101
|
+
"exact_match": True,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
# 5. Search by PharmGKB identifier
|
|
105
|
+
{
|
|
106
|
+
"name": "drugbank_links_search",
|
|
107
|
+
"arguments": {"query": "PA10040", "search_fields": ["PharmGKB ID"]},
|
|
108
|
+
},
|
|
109
|
+
# 6. Search by KEGG Drug ID
|
|
110
|
+
{
|
|
111
|
+
"name": "drugbank_links_search",
|
|
112
|
+
"arguments": {"query": "D03455", "search_fields": ["KEGG Drug ID"]},
|
|
113
|
+
},
|
|
114
|
+
# ---------- dict_search (DICTrank) ----------
|
|
115
|
+
# 7. Search by trade name
|
|
116
|
+
{
|
|
117
|
+
"name": "dict_search",
|
|
118
|
+
"arguments": {"query": "ZYPREXA", "search_fields": ["Trade Name"], "limit": 2},
|
|
119
|
+
},
|
|
120
|
+
# 8. Search by active ingredient (case-insensitive)
|
|
121
|
+
{
|
|
122
|
+
"name": "dict_search",
|
|
123
|
+
"arguments": {
|
|
124
|
+
"query": "trimethobenzamide",
|
|
125
|
+
"search_fields": ["Active Ingredient(s)"],
|
|
126
|
+
"case_sensitive": False,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
# ---------- dili_search (DILIrank) ----------
|
|
130
|
+
# 9. Exact compound-name search
|
|
131
|
+
{
|
|
132
|
+
"name": "dili_search",
|
|
133
|
+
"arguments": {
|
|
134
|
+
"query": "acetaminophen",
|
|
135
|
+
"search_fields": ["Compound Name"],
|
|
136
|
+
"exact_match": True,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
# 10. Partial compound-name query
|
|
140
|
+
{
|
|
141
|
+
"name": "dili_search",
|
|
142
|
+
"arguments": {
|
|
143
|
+
"query": "mercap",
|
|
144
|
+
"search_fields": ["Compound Name"],
|
|
145
|
+
"limit": 5,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
# ---------- diqt_search (DIQTA) ----------
|
|
149
|
+
# 11. Exact DrugBank ID lookup
|
|
150
|
+
{
|
|
151
|
+
"name": "diqt_search",
|
|
152
|
+
"arguments": {
|
|
153
|
+
"query": "DB00637",
|
|
154
|
+
"search_fields": ["DrugBank ID"],
|
|
155
|
+
"exact_match": True,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
# 12. Generic name search (case-insensitive)
|
|
159
|
+
{
|
|
160
|
+
"name": "diqt_search",
|
|
161
|
+
"arguments": {
|
|
162
|
+
"query": "dofetilide",
|
|
163
|
+
"search_fields": ["Generic/Proper Name(s)"],
|
|
164
|
+
"case_sensitive": False,
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
]
|
|
168
|
+
|
|
169
|
+
for idx, query in enumerate(test_queries):
|
|
170
|
+
print(
|
|
171
|
+
f"\n[{idx+1}] Running tool: {query['name']} with arguments: {query['arguments']}"
|
|
172
|
+
)
|
|
173
|
+
try:
|
|
174
|
+
result = tooluni.run(query)
|
|
175
|
+
print("✅ Success. Example output snippet:")
|
|
176
|
+
|
|
177
|
+
# Pretty print the result based on its structure
|
|
178
|
+
if isinstance(result, dict):
|
|
179
|
+
if "results" in result:
|
|
180
|
+
print(
|
|
181
|
+
f"Found {result.get('total_results', result.get('total_matches', 0))} results"
|
|
182
|
+
)
|
|
183
|
+
if result["results"]:
|
|
184
|
+
# Show first result
|
|
185
|
+
first_result = result["results"][0]
|
|
186
|
+
# print(f"First result: {first_result.get('Common name', 'N/A')} (ID: {first_result.get('DrugBank ID', 'N/A')})")
|
|
187
|
+
print(f"First result: {first_result})")
|
|
188
|
+
if "matched_fields" in first_result:
|
|
189
|
+
print(f"Matched fields: {first_result['matched_fields']}")
|
|
190
|
+
elif "error" in result:
|
|
191
|
+
print(f"Error: {result['error']}")
|
|
192
|
+
else:
|
|
193
|
+
print(
|
|
194
|
+
str(result)[:200] + "..." if len(str(result)) > 200 else str(result)
|
|
195
|
+
)
|
|
196
|
+
else:
|
|
197
|
+
print(str(result)[:200] + "..." if len(str(result)) > 200 else str(result))
|
|
198
|
+
|
|
199
|
+
except Exception as e:
|
|
200
|
+
print(f"❌ Error: {e}")
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Simple test for disease-target score extraction tools.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import sys
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
# Add the src directory to the path
|
|
10
|
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
|
|
11
|
+
|
|
12
|
+
from tooluniverse import ToolUniverse # noqa: E402
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_disease_target_score_tools():
|
|
16
|
+
"""Test the disease-target score extraction tools"""
|
|
17
|
+
print("Testing Disease-Target Score Tools...")
|
|
18
|
+
|
|
19
|
+
# Initialize ToolUniverse and load all tools
|
|
20
|
+
engine = ToolUniverse()
|
|
21
|
+
engine.load_tools()
|
|
22
|
+
|
|
23
|
+
# Test both generic and specific tools
|
|
24
|
+
tests = [
|
|
25
|
+
(
|
|
26
|
+
"generic tool",
|
|
27
|
+
"disease_target_score",
|
|
28
|
+
{"efoId": "EFO_0000339", "datasourceId": "impc"},
|
|
29
|
+
),
|
|
30
|
+
(
|
|
31
|
+
"ChEMBL-specific tool",
|
|
32
|
+
"chembl_disease_target_score",
|
|
33
|
+
{"efoId": "EFO_0000339"},
|
|
34
|
+
),
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
for name, tool_name, args in tests:
|
|
38
|
+
print(f"Testing {name}...")
|
|
39
|
+
result = engine.run_one_function({"name": tool_name, "arguments": args})
|
|
40
|
+
print(f"\033[92m{result}\033[0m")
|
|
41
|
+
assert (
|
|
42
|
+
result and result.get("total_targets_with_scores", 0) > 0
|
|
43
|
+
), f"{name} failed"
|
|
44
|
+
print(f"✅ Found {result['total_targets_with_scores']} targets")
|
|
45
|
+
|
|
46
|
+
print("🎉 All tests passed!")
|
|
47
|
+
return True
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
if __name__ == "__main__":
|
|
51
|
+
try:
|
|
52
|
+
test_disease_target_score_tools()
|
|
53
|
+
print("SUCCESS")
|
|
54
|
+
except Exception as e:
|
|
55
|
+
print(f"FAILED: {e}")
|
|
56
|
+
sys.exit(1)
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
from tooluniverse import ToolUniverse
|
|
2
|
+
from typing import Any, Dict, List
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
# Initialize tool universe
|
|
6
|
+
tooluni = ToolUniverse()
|
|
7
|
+
tooluni.load_tools()
|
|
8
|
+
|
|
9
|
+
print("=== DrugBank Filter Tool Usage Examples ===\n")
|
|
10
|
+
|
|
11
|
+
# 详细的使用示例,展示如何使用各种过滤器
|
|
12
|
+
filter_examples: List[Dict[str, Any]] = [
|
|
13
|
+
{
|
|
14
|
+
"name": "Example 1: Find all insulin-related drugs",
|
|
15
|
+
"query": {
|
|
16
|
+
"name": "drugbank_filter",
|
|
17
|
+
"arguments": {
|
|
18
|
+
"filters": {"Common name": {"contains": "insulin"}},
|
|
19
|
+
"limit": 5,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "Example 2: Find drugs with specific DrugBank ID pattern",
|
|
25
|
+
"query": {
|
|
26
|
+
"name": "drugbank_filter",
|
|
27
|
+
"arguments": {
|
|
28
|
+
"filters": {"DrugBank ID": {"starts_with": "DB001"}},
|
|
29
|
+
"limit": 5,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "Example 3: Find drugs with CAS numbers (quality check)",
|
|
35
|
+
"query": {
|
|
36
|
+
"name": "drugbank_filter",
|
|
37
|
+
"arguments": {"filters": {"CAS": {"not_empty": True}}, "limit": 3},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "Example 4: Find interferon drugs with UNII identifiers",
|
|
42
|
+
"query": {
|
|
43
|
+
"name": "drugbank_filter",
|
|
44
|
+
"arguments": {
|
|
45
|
+
"filters": {
|
|
46
|
+
"Common name": {"contains": "interferon"},
|
|
47
|
+
"UNII": {"not_empty": True},
|
|
48
|
+
},
|
|
49
|
+
"limit": 3,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "Example 5: Find drugs ending with 'acid'",
|
|
55
|
+
"query": {
|
|
56
|
+
"name": "drugbank_filter",
|
|
57
|
+
"arguments": {
|
|
58
|
+
"filters": {"Common name": {"ends_with": "acid"}},
|
|
59
|
+
"limit": 4,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "Example 6: Simple string filter (aspirin in synonyms)",
|
|
65
|
+
"query": {
|
|
66
|
+
"name": "drugbank_filter",
|
|
67
|
+
"arguments": {"filters": {"Synonyms": "aspirin"}, "limit": 3},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "Example 7: Exact drug name match",
|
|
72
|
+
"query": {
|
|
73
|
+
"name": "drugbank_filter",
|
|
74
|
+
"arguments": {
|
|
75
|
+
"filters": {"Common name": {"exact": "Lepirudin"}},
|
|
76
|
+
"limit": 5,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "Example 8: Complex multi-field filter",
|
|
82
|
+
"query": {
|
|
83
|
+
"name": "drugbank_filter",
|
|
84
|
+
"arguments": {
|
|
85
|
+
"filters": {
|
|
86
|
+
"DrugBank ID": {"starts_with": "DB00"},
|
|
87
|
+
"CAS": {"not_empty": True},
|
|
88
|
+
"Common name": {"contains": "alfa"},
|
|
89
|
+
},
|
|
90
|
+
"limit": 3,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
for idx, example in enumerate(filter_examples, 1):
|
|
97
|
+
print(f"[{idx}] {example['name']}")
|
|
98
|
+
print("Filter Arguments:")
|
|
99
|
+
print(json.dumps(example["query"]["arguments"], indent=2, ensure_ascii=False))
|
|
100
|
+
|
|
101
|
+
try:
|
|
102
|
+
result = tooluni.run(example["query"])
|
|
103
|
+
|
|
104
|
+
if isinstance(result, dict) and "results" in result:
|
|
105
|
+
total = result.get("total_matches", 0)
|
|
106
|
+
returned = result.get("returned_results", 0)
|
|
107
|
+
print(f"✅ Success: Found {total} matches, showing {returned} results")
|
|
108
|
+
|
|
109
|
+
# Show first result details
|
|
110
|
+
if result["results"]:
|
|
111
|
+
first = result["results"][0]
|
|
112
|
+
print(
|
|
113
|
+
f" First result: {first.get('Common name', 'N/A')} (ID: {first.get('DrugBank ID', 'N/A')})"
|
|
114
|
+
)
|
|
115
|
+
if first.get("CAS"):
|
|
116
|
+
print(f" CAS: {first['CAS']}")
|
|
117
|
+
if first.get("UNII"):
|
|
118
|
+
print(f" UNII: {first['UNII']}")
|
|
119
|
+
if first.get("Synonyms"):
|
|
120
|
+
synonyms = (
|
|
121
|
+
first["Synonyms"][:100] + "..."
|
|
122
|
+
if len(first["Synonyms"]) > 100
|
|
123
|
+
else first["Synonyms"]
|
|
124
|
+
)
|
|
125
|
+
print(f" Synonyms: {synonyms}")
|
|
126
|
+
|
|
127
|
+
# Show applied filters
|
|
128
|
+
if "applied_filters" in result:
|
|
129
|
+
print(f" Applied filters: {', '.join(result['applied_filters'])}")
|
|
130
|
+
|
|
131
|
+
elif isinstance(result, dict) and "error" in result:
|
|
132
|
+
print(f"❌ Error: {result['error']}")
|
|
133
|
+
else:
|
|
134
|
+
print("❌ Unexpected result format")
|
|
135
|
+
|
|
136
|
+
except Exception as e:
|
|
137
|
+
print(f"❌ Exception: {e}")
|
|
138
|
+
|
|
139
|
+
print("-" * 80)
|
|
140
|
+
|
|
141
|
+
print("\n=== Filter Usage Summary ===")
|
|
142
|
+
print(
|
|
143
|
+
"""
|
|
144
|
+
Common Filter Patterns:
|
|
145
|
+
|
|
146
|
+
1. Simple String Matching:
|
|
147
|
+
{"field_name": "search_text"}
|
|
148
|
+
|
|
149
|
+
2. Contains Pattern:
|
|
150
|
+
{"field_name": {"contains": "text"}}
|
|
151
|
+
|
|
152
|
+
3. Starts With Pattern:
|
|
153
|
+
{"field_name": {"starts_with": "prefix"}}
|
|
154
|
+
|
|
155
|
+
4. Ends With Pattern:
|
|
156
|
+
{"field_name": {"ends_with": "suffix"}}
|
|
157
|
+
|
|
158
|
+
5. Exact Match:
|
|
159
|
+
{"field_name": {"exact": "exact_value"}}
|
|
160
|
+
|
|
161
|
+
6. Data Quality Check:
|
|
162
|
+
{"field_name": {"not_empty": true}}
|
|
163
|
+
|
|
164
|
+
7. Multiple Conditions (AND logic):
|
|
165
|
+
{
|
|
166
|
+
"field1": {"contains": "text1"},
|
|
167
|
+
"field2": {"not_empty": true}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
Available Fields:
|
|
171
|
+
- DrugBank ID
|
|
172
|
+
- Common name
|
|
173
|
+
- CAS
|
|
174
|
+
- UNII
|
|
175
|
+
- Synonyms
|
|
176
|
+
- Accession Numbers
|
|
177
|
+
- Standard InChI Key
|
|
178
|
+
"""
|
|
179
|
+
)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from tooluniverse import ToolUniverse
|
|
2
|
+
|
|
3
|
+
# Step 1: Initialize tool universe
|
|
4
|
+
tooluni = ToolUniverse()
|
|
5
|
+
tooluni.load_tools()
|
|
6
|
+
|
|
7
|
+
# Step 2: Define test queries for the ChEMBLTool
|
|
8
|
+
test_queries = [
|
|
9
|
+
{
|
|
10
|
+
"name": "OSL_get_efo_id_by_disease_name",
|
|
11
|
+
"arguments": {"disease": "Bardet Biedl syndrome"},
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "OSL_get_efo_id_by_disease_name",
|
|
15
|
+
"arguments": {"disease": "Bardet-Biedl syndrome"},
|
|
16
|
+
},
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
# Step 3: Run all test queries
|
|
20
|
+
for idx, query in enumerate(test_queries):
|
|
21
|
+
# try:
|
|
22
|
+
print(
|
|
23
|
+
f"\n[{idx+1}] Running tool: {query['name']} with arguments: {query['arguments']}"
|
|
24
|
+
)
|
|
25
|
+
result = tooluni.run(query)
|
|
26
|
+
print("✅ Success. Example output snippet:")
|
|
27
|
+
print(
|
|
28
|
+
result if isinstance(result, dict) else str(result)
|
|
29
|
+
) # Print snippet if result is big
|
|
30
|
+
# except Exception as e:
|
|
31
|
+
# print(f"❌ Failed. Error: {str(e)}")
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from tooluniverse import ToolUniverse
|
|
2
|
+
|
|
3
|
+
# Step 1: Initialize tool universe
|
|
4
|
+
tooluni = ToolUniverse()
|
|
5
|
+
tooluni.load_tools()
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
test_queries = [
|
|
9
|
+
{
|
|
10
|
+
"name": "enrichr_gene_enrichment_analysis",
|
|
11
|
+
"arguments": {"gene_list": ["TP53", "USP7"]},
|
|
12
|
+
},
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
for idx, query in enumerate(test_queries):
|
|
16
|
+
print(
|
|
17
|
+
f"\n[{idx+1}] Running tool: {query['name']} with arguments: {query['arguments']}"
|
|
18
|
+
)
|
|
19
|
+
result = tooluni.run(query)
|
|
20
|
+
print("✅ Success. Example output snippet:")
|
|
21
|
+
print(result if isinstance(result, dict) else str(result))
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from tooluniverse import ToolUniverse
|
|
2
|
+
|
|
3
|
+
# ...existing code initializing ToolUniverse...
|
|
4
|
+
tooluni = ToolUniverse()
|
|
5
|
+
tooluni.load_tools()
|
|
6
|
+
|
|
7
|
+
test_queries = [
|
|
8
|
+
{
|
|
9
|
+
"name": "EuropePMC_search_articles",
|
|
10
|
+
"arguments": {"query": "cancer immunotherapy", "limit": 3},
|
|
11
|
+
},
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
for idx, query in enumerate(test_queries):
|
|
15
|
+
print(
|
|
16
|
+
f"\n[{idx+1}] Running tool: {query['name']} with arguments: {query['arguments']}"
|
|
17
|
+
)
|
|
18
|
+
result = tooluni.run(query)
|
|
19
|
+
print("✅ Success. Example output snippet:")
|
|
20
|
+
print(result if isinstance(result, dict) else str(result))
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# === openfda_test_all_tools.py ===
|
|
2
|
+
|
|
3
|
+
from tooluniverse import ToolUniverse
|
|
4
|
+
|
|
5
|
+
# Step 1: Initialize tool universe
|
|
6
|
+
tooluni = ToolUniverse()
|
|
7
|
+
tooluni.load_tools()
|
|
8
|
+
|
|
9
|
+
# Step 2: Define all test queries for all tools
|
|
10
|
+
test_queries = [
|
|
11
|
+
# # ====== Tests for FAERS_count_reactions_by_drug_event ======
|
|
12
|
+
# {"name": "FAERS_count_reactions_by_drug_event", "arguments": {"medicinalproduct": "LIPITOR"}},
|
|
13
|
+
# {"name": "FAERS_count_reactions_by_drug_event", "arguments": {"medicinalproduct": "LIPITOR", "patient.patientsex": "Male", "serious": "Serious"}},
|
|
14
|
+
# {"name": "FAERS_count_reactions_by_drug_event", "arguments": {"medicinalproduct": "ASPIRIN", "patient.patientagegroup": "Adult"}},
|
|
15
|
+
# {"name": "FAERS_count_reactions_by_drug_event", "arguments": {"medicinalproduct": "ADVIL", "patient.patientsex": "Female", "patient.patientagegroup": "Elderly", "occurcountry": "US", "serious": "Non-serious"}},
|
|
16
|
+
# {"name": "FAERS_count_reactions_by_drug_event", "arguments": {"medicinalproduct": "ADVIL", "seriousnessdeath": "Yes"}},
|
|
17
|
+
# # ====== Tests for FAERS_count_drugs_by_drug_event ======
|
|
18
|
+
# {"name": "FAERS_count_drugs_by_drug_event", "arguments": {"patient.patientsex": "Female"}},
|
|
19
|
+
# {"name": "FAERS_count_drugs_by_drug_event", "arguments": {"patient.patientagegroup": "Child"}},
|
|
20
|
+
# {"name": "FAERS_count_drugs_by_drug_event", "arguments": {"serious": "Serious"}},
|
|
21
|
+
# {"name": "FAERS_count_drugs_by_drug_event", "arguments": {"occurcountry": "CA", "serious": "Non-serious"}},
|
|
22
|
+
# # ====== Tests for FAERS_count_country_by_drug_event ======
|
|
23
|
+
# {"name": "FAERS_count_country_by_drug_event", "arguments": {"medicinalproduct": "METFORMIN"}},
|
|
24
|
+
# {"name": "FAERS_count_country_by_drug_event", "arguments": {"medicinalproduct": "INSULIN", "patient.patientsex": "Male"}},
|
|
25
|
+
# {"name": "FAERS_count_country_by_drug_event", "arguments": {"medicinalproduct": "ASPIRIN", "serious": "Serious"}},
|
|
26
|
+
# {"name": "FAERS_count_country_by_drug_event", "arguments": {"medicinalproduct": "STATIN", "patient.patientsex": "Female", "patient.patientagegroup": "Adult", "serious": "Non-serious"}},
|
|
27
|
+
# # ====== Tests for FAERS_count_reportercountry_by_drug_event ======
|
|
28
|
+
# {"name": "FAERS_count_reportercountry_by_drug_event", "arguments": {"medicinalproduct": "LANTUS"}},
|
|
29
|
+
# {"name": "FAERS_count_reportercountry_by_drug_event", "arguments": {"medicinalproduct": "AMLODIPINE", "patient.patientsex": "Unknown"}},
|
|
30
|
+
# {"name": "FAERS_count_reportercountry_by_drug_event", "arguments": {"medicinalproduct": "ATORVASTATIN", "patient.patientagegroup": "Elderly"}},
|
|
31
|
+
# {"name": "FAERS_count_reportercountry_by_drug_event", "arguments": {"medicinalproduct": "GABAPENTIN", "patient.patientsex": "Male", "patient.patientagegroup": "Adult", "serious": "Serious"}},
|
|
32
|
+
# # ====== Tests for FAERS_count_seriousness_by_drug_event ======
|
|
33
|
+
# {"name": "FAERS_count_seriousness_by_drug_event", "arguments": {"medicinalproduct": "NAPROXEN"}},
|
|
34
|
+
# {"name": "FAERS_count_seriousness_by_drug_event", "arguments": {"medicinalproduct": "ALBUTEROL", "patient.patientsex": "Female"}},
|
|
35
|
+
# {"name": "FAERS_count_seriousness_by_drug_event", "arguments": {"medicinalproduct": "PREDNISONE", "patient.patientagegroup": "Child"}},
|
|
36
|
+
# {"name": "FAERS_count_seriousness_by_drug_event", "arguments": {"medicinalproduct": "METHOTREXATE", "patient.patientsex": "Male", "patient.patientagegroup": "Adult", "occurcountry": "US"}},
|
|
37
|
+
# # ====== Tests for FAERS_count_outcomes_by_drug_event ======
|
|
38
|
+
# {"name": "FAERS_count_outcomes_by_drug_event", "arguments": {"medicinalproduct": "IBUPROFEN"}},
|
|
39
|
+
# {"name": "FAERS_count_outcomes_by_drug_event", "arguments": {"medicinalproduct": "IBUPROFEN", "patient.patientsex": "Female", "occurcountry": "GB"}},
|
|
40
|
+
# {"name": "FAERS_count_outcomes_by_drug_event", "arguments": {"medicinalproduct": "IBUPROFEN", "patient.patientsex": "Male", "patient.patientagegroup": "Adolescent"}},
|
|
41
|
+
# # ====== Tests for FAERS_count_drug_routes_by_event ======
|
|
42
|
+
# {"name": "FAERS_count_drug_routes_by_event", "arguments": {"medicinalproduct": "INSULIN", "serious": "Serious"}},
|
|
43
|
+
# {"name": "FAERS_count_drug_routes_by_event", "arguments": {"medicinalproduct": "MORPHINE", "serious": "Non-serious"}},
|
|
44
|
+
# # ====== Tests for FAERS_count_patient_age_distribution ======
|
|
45
|
+
# {"name": "FAERS_count_patient_age_distribution", "arguments": {"medicinalproduct": "PENICILLIN"}},
|
|
46
|
+
# {"name": "FAERS_count_patient_age_distribution", "arguments": {"medicinalproduct": "ACETAMINOPHEN"}},
|
|
47
|
+
# ====== Tests for FAERS_count_death_related_by_drug ======
|
|
48
|
+
# {"name": "FAERS_count_death_related_by_drug", "arguments": {"medicinalproduct": "FENTANYL"}},
|
|
49
|
+
# {"name": "FAERS_count_death_related_by_drug", "arguments": {"medicinalproduct": "WARFARIN"}},
|
|
50
|
+
# # ====== Tests for FAERS_count_additive_adverse_reactions ======
|
|
51
|
+
# {"name": "FAERS_count_additive_adverse_reactions", "arguments": {"medicinalproducts": ["LIPITOR", "ASPIRIN"]}},
|
|
52
|
+
# {"name": "FAERS_count_additive_adverse_reactions", "arguments": {"medicinalproducts": ["LIPITOR", "ASPIRIN"], "patient.patientsex": "Male"}},
|
|
53
|
+
# {"name": "FAERS_count_additive_adverse_reactions", "arguments": {"medicinalproducts": ["LIPITOR", "ASPIRIN"], "serious": "Serious"}},
|
|
54
|
+
# # ====== Tests for FAERS_count_additive_event_reports_by_country ======
|
|
55
|
+
# {"name": "FAERS_count_additive_event_reports_by_country", "arguments": {"medicinalproducts": ["LIPITOR", "ASPIRIN"]}},
|
|
56
|
+
# {"name": "FAERS_count_additive_event_reports_by_country", "arguments": {"medicinalproducts": ["LIPITOR", "ASPIRIN"], "serious": "Non-serious"}},
|
|
57
|
+
# # ====== Tests for FAERS_count_additive_reports_by_reporter_country ======
|
|
58
|
+
# {"name": "FAERS_count_additive_reports_by_reporter_country", "arguments": {"medicinalproducts": ["LIPITOR", "ASPIRIN"]}},
|
|
59
|
+
# {"name": "FAERS_count_additive_reports_by_reporter_country", "arguments": {"medicinalproducts": ["LIPITOR", "ASPIRIN"], "patient.patientagegroup": "Elderly"}},
|
|
60
|
+
# # ====== Tests for FAERS_count_additive_seriousness_classification ======
|
|
61
|
+
# {"name": "FAERS_count_additive_seriousness_classification", "arguments": {"medicinalproducts": ["LIPITOR", "ASPIRIN"]}},
|
|
62
|
+
# {"name": "FAERS_count_additive_seriousness_classification", "arguments": {"medicinalproducts": ["LIPITOR", "ASPIRIN"], "occurcountry": "CA"}},
|
|
63
|
+
# ====== Tests for FAERS_count_additive_reaction_outcomes ======
|
|
64
|
+
# {"name": "FAERS_count_additive_reaction_outcomes", "arguments": {"medicinalproducts": ["LIPITOR", "ASPIRIN"]}},
|
|
65
|
+
# {"name": "FAERS_count_additive_reaction_outcomes", "arguments": {"medicinalproducts": ["LIPITOR", "ASPIRIN"]}},
|
|
66
|
+
# ====== Tests for FAERS_count_additive_administration_routes ======
|
|
67
|
+
# {"name": "FAERS_count_additive_administration_routes", "arguments": {"medicinalproducts": ["LIPITOR", "ASPIRIN"]}},
|
|
68
|
+
# {"name": "FAERS_count_additive_administration_routes", "arguments": {"medicinalproducts": ["LIPITOR", "ASPIRIN"], "serious": "Non-serious"}},
|
|
69
|
+
# {'name': 'FAERS_count_additive_seriousness_classification', 'arguments': {'medicinalproducts': ['Dysport'], 'occurcountry': 'US', 'patient.patientagegroup': 'Adult'}},
|
|
70
|
+
# {'name': 'FAERS_count_additive_adverse_reactions', 'arguments': {'medicinalproducts': ['atorvastatin calcium'], 'serious': 'Yes', 'seriousnessdeath': 'Yes'}},
|
|
71
|
+
{
|
|
72
|
+
"name": "FAERS_count_additive_adverse_reactions",
|
|
73
|
+
"arguments": {
|
|
74
|
+
"medicinalproducts": ["Antara"],
|
|
75
|
+
"patient.patientsex": "Male",
|
|
76
|
+
"patient.patientagegroup": "Elderly",
|
|
77
|
+
"serious": "Yes",
|
|
78
|
+
"seriousnessdeath": "No",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
# Step 3: Run all test queries
|
|
84
|
+
for idx, query in enumerate(test_queries):
|
|
85
|
+
try:
|
|
86
|
+
print(
|
|
87
|
+
f"\n[{idx+1}] Running tool: {query['name']} with arguments: {query['arguments']}"
|
|
88
|
+
)
|
|
89
|
+
result = tooluni.run(query)
|
|
90
|
+
print("✅ Success. Example output snippet:")
|
|
91
|
+
print(
|
|
92
|
+
result if isinstance(result, dict) else str(result)[:500]
|
|
93
|
+
) # Print snippet if result is big
|
|
94
|
+
except Exception as e:
|
|
95
|
+
print(f"❌ Failed. Error: {str(e)}")
|