tooluniverse 0.1.4__py3-none-any.whl → 1.0.0__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.

Files changed (187) hide show
  1. tooluniverse/__init__.py +340 -4
  2. tooluniverse/admetai_tool.py +84 -0
  3. tooluniverse/agentic_tool.py +563 -0
  4. tooluniverse/alphafold_tool.py +96 -0
  5. tooluniverse/base_tool.py +129 -6
  6. tooluniverse/boltz_tool.py +207 -0
  7. tooluniverse/chem_tool.py +192 -0
  8. tooluniverse/compose_scripts/__init__.py +1 -0
  9. tooluniverse/compose_scripts/biomarker_discovery.py +293 -0
  10. tooluniverse/compose_scripts/comprehensive_drug_discovery.py +186 -0
  11. tooluniverse/compose_scripts/drug_safety_analyzer.py +89 -0
  12. tooluniverse/compose_scripts/literature_tool.py +34 -0
  13. tooluniverse/compose_scripts/output_summarizer.py +279 -0
  14. tooluniverse/compose_scripts/tool_description_optimizer.py +681 -0
  15. tooluniverse/compose_scripts/tool_discover.py +705 -0
  16. tooluniverse/compose_scripts/tool_graph_composer.py +448 -0
  17. tooluniverse/compose_tool.py +371 -0
  18. tooluniverse/ctg_tool.py +1002 -0
  19. tooluniverse/custom_tool.py +81 -0
  20. tooluniverse/dailymed_tool.py +108 -0
  21. tooluniverse/data/admetai_tools.json +155 -0
  22. tooluniverse/data/agentic_tools.json +1156 -0
  23. tooluniverse/data/alphafold_tools.json +87 -0
  24. tooluniverse/data/boltz_tools.json +9 -0
  25. tooluniverse/data/chembl_tools.json +16 -0
  26. tooluniverse/data/clait_tools.json +108 -0
  27. tooluniverse/data/clinicaltrials_gov_tools.json +326 -0
  28. tooluniverse/data/compose_tools.json +202 -0
  29. tooluniverse/data/dailymed_tools.json +70 -0
  30. tooluniverse/data/dataset_tools.json +646 -0
  31. tooluniverse/data/disease_target_score_tools.json +712 -0
  32. tooluniverse/data/efo_tools.json +17 -0
  33. tooluniverse/data/embedding_tools.json +319 -0
  34. tooluniverse/data/enrichr_tools.json +31 -0
  35. tooluniverse/data/europe_pmc_tools.json +22 -0
  36. tooluniverse/data/expert_feedback_tools.json +10 -0
  37. tooluniverse/data/fda_drug_adverse_event_tools.json +491 -0
  38. tooluniverse/data/fda_drug_labeling_tools.json +544 -168
  39. tooluniverse/data/fda_drugs_with_brand_generic_names_for_tool.py +76929 -148860
  40. tooluniverse/data/finder_tools.json +209 -0
  41. tooluniverse/data/gene_ontology_tools.json +113 -0
  42. tooluniverse/data/gwas_tools.json +1082 -0
  43. tooluniverse/data/hpa_tools.json +333 -0
  44. tooluniverse/data/humanbase_tools.json +47 -0
  45. tooluniverse/data/idmap_tools.json +74 -0
  46. tooluniverse/data/mcp_client_tools_example.json +113 -0
  47. tooluniverse/data/mcpautoloadertool_defaults.json +28 -0
  48. tooluniverse/data/medlineplus_tools.json +141 -0
  49. tooluniverse/data/monarch_tools.json +1 -1
  50. tooluniverse/data/openalex_tools.json +36 -0
  51. tooluniverse/data/opentarget_tools.json +82 -58
  52. tooluniverse/data/output_summarization_tools.json +101 -0
  53. tooluniverse/data/packages/bioinformatics_core_tools.json +1756 -0
  54. tooluniverse/data/packages/categorized_tools.txt +206 -0
  55. tooluniverse/data/packages/cheminformatics_tools.json +347 -0
  56. tooluniverse/data/packages/earth_sciences_tools.json +74 -0
  57. tooluniverse/data/packages/genomics_tools.json +776 -0
  58. tooluniverse/data/packages/image_processing_tools.json +38 -0
  59. tooluniverse/data/packages/machine_learning_tools.json +789 -0
  60. tooluniverse/data/packages/neuroscience_tools.json +62 -0
  61. tooluniverse/data/packages/original_tools.txt +0 -0
  62. tooluniverse/data/packages/physics_astronomy_tools.json +62 -0
  63. tooluniverse/data/packages/scientific_computing_tools.json +560 -0
  64. tooluniverse/data/packages/single_cell_tools.json +453 -0
  65. tooluniverse/data/packages/software_tools.json +4954 -0
  66. tooluniverse/data/packages/structural_biology_tools.json +396 -0
  67. tooluniverse/data/packages/visualization_tools.json +399 -0
  68. tooluniverse/data/pubchem_tools.json +215 -0
  69. tooluniverse/data/pubtator_tools.json +68 -0
  70. tooluniverse/data/rcsb_pdb_tools.json +1332 -0
  71. tooluniverse/data/reactome_tools.json +19 -0
  72. tooluniverse/data/semantic_scholar_tools.json +26 -0
  73. tooluniverse/data/special_tools.json +2 -25
  74. tooluniverse/data/tool_composition_tools.json +88 -0
  75. tooluniverse/data/toolfinderkeyword_defaults.json +34 -0
  76. tooluniverse/data/txagent_client_tools.json +9 -0
  77. tooluniverse/data/uniprot_tools.json +211 -0
  78. tooluniverse/data/url_fetch_tools.json +94 -0
  79. tooluniverse/data/uspto_downloader_tools.json +9 -0
  80. tooluniverse/data/uspto_tools.json +811 -0
  81. tooluniverse/data/xml_tools.json +3275 -0
  82. tooluniverse/dataset_tool.py +296 -0
  83. tooluniverse/default_config.py +165 -0
  84. tooluniverse/efo_tool.py +42 -0
  85. tooluniverse/embedding_database.py +630 -0
  86. tooluniverse/embedding_sync.py +396 -0
  87. tooluniverse/enrichr_tool.py +266 -0
  88. tooluniverse/europe_pmc_tool.py +52 -0
  89. tooluniverse/execute_function.py +1775 -95
  90. tooluniverse/extended_hooks.py +444 -0
  91. tooluniverse/gene_ontology_tool.py +194 -0
  92. tooluniverse/graphql_tool.py +158 -36
  93. tooluniverse/gwas_tool.py +358 -0
  94. tooluniverse/hpa_tool.py +1645 -0
  95. tooluniverse/humanbase_tool.py +389 -0
  96. tooluniverse/logging_config.py +254 -0
  97. tooluniverse/mcp_client_tool.py +764 -0
  98. tooluniverse/mcp_integration.py +413 -0
  99. tooluniverse/mcp_tool_registry.py +925 -0
  100. tooluniverse/medlineplus_tool.py +337 -0
  101. tooluniverse/openalex_tool.py +228 -0
  102. tooluniverse/openfda_adv_tool.py +283 -0
  103. tooluniverse/openfda_tool.py +393 -160
  104. tooluniverse/output_hook.py +1122 -0
  105. tooluniverse/package_tool.py +195 -0
  106. tooluniverse/pubchem_tool.py +158 -0
  107. tooluniverse/pubtator_tool.py +168 -0
  108. tooluniverse/rcsb_pdb_tool.py +38 -0
  109. tooluniverse/reactome_tool.py +108 -0
  110. tooluniverse/remote/boltz/boltz_mcp_server.py +50 -0
  111. tooluniverse/remote/depmap_24q2/depmap_24q2_mcp_tool.py +442 -0
  112. tooluniverse/remote/expert_feedback/human_expert_mcp_tools.py +2013 -0
  113. tooluniverse/remote/expert_feedback/simple_test.py +23 -0
  114. tooluniverse/remote/expert_feedback/start_web_interface.py +188 -0
  115. tooluniverse/remote/expert_feedback/web_only_interface.py +0 -0
  116. tooluniverse/remote/expert_feedback_mcp/human_expert_mcp_server.py +1611 -0
  117. tooluniverse/remote/expert_feedback_mcp/simple_test.py +34 -0
  118. tooluniverse/remote/expert_feedback_mcp/start_web_interface.py +91 -0
  119. tooluniverse/remote/immune_compass/compass_tool.py +327 -0
  120. tooluniverse/remote/pinnacle/pinnacle_tool.py +328 -0
  121. tooluniverse/remote/transcriptformer/transcriptformer_tool.py +586 -0
  122. tooluniverse/remote/uspto_downloader/uspto_downloader_mcp_server.py +61 -0
  123. tooluniverse/remote/uspto_downloader/uspto_downloader_tool.py +120 -0
  124. tooluniverse/remote_tool.py +99 -0
  125. tooluniverse/restful_tool.py +53 -30
  126. tooluniverse/scripts/generate_tool_graph.py +408 -0
  127. tooluniverse/scripts/visualize_tool_graph.py +829 -0
  128. tooluniverse/semantic_scholar_tool.py +62 -0
  129. tooluniverse/smcp.py +2452 -0
  130. tooluniverse/smcp_server.py +975 -0
  131. tooluniverse/test/mcp_server_test.py +0 -0
  132. tooluniverse/test/test_admetai_tool.py +370 -0
  133. tooluniverse/test/test_agentic_tool.py +129 -0
  134. tooluniverse/test/test_alphafold_tool.py +71 -0
  135. tooluniverse/test/test_chem_tool.py +37 -0
  136. tooluniverse/test/test_compose_lieraturereview.py +63 -0
  137. tooluniverse/test/test_compose_tool.py +448 -0
  138. tooluniverse/test/test_dailymed.py +69 -0
  139. tooluniverse/test/test_dataset_tool.py +200 -0
  140. tooluniverse/test/test_disease_target_score.py +56 -0
  141. tooluniverse/test/test_drugbank_filter_examples.py +179 -0
  142. tooluniverse/test/test_efo.py +31 -0
  143. tooluniverse/test/test_enrichr_tool.py +21 -0
  144. tooluniverse/test/test_europe_pmc_tool.py +20 -0
  145. tooluniverse/test/test_fda_adv.py +95 -0
  146. tooluniverse/test/test_fda_drug_labeling.py +91 -0
  147. tooluniverse/test/test_gene_ontology_tools.py +66 -0
  148. tooluniverse/test/test_gwas_tool.py +139 -0
  149. tooluniverse/test/test_hpa.py +625 -0
  150. tooluniverse/test/test_humanbase_tool.py +20 -0
  151. tooluniverse/test/test_idmap_tools.py +61 -0
  152. tooluniverse/test/test_mcp_server.py +211 -0
  153. tooluniverse/test/test_mcp_tool.py +247 -0
  154. tooluniverse/test/test_medlineplus.py +220 -0
  155. tooluniverse/test/test_openalex_tool.py +32 -0
  156. tooluniverse/test/test_opentargets.py +28 -0
  157. tooluniverse/test/test_pubchem_tool.py +116 -0
  158. tooluniverse/test/test_pubtator_tool.py +37 -0
  159. tooluniverse/test/test_rcsb_pdb_tool.py +86 -0
  160. tooluniverse/test/test_reactome.py +54 -0
  161. tooluniverse/test/test_semantic_scholar_tool.py +24 -0
  162. tooluniverse/test/test_software_tools.py +147 -0
  163. tooluniverse/test/test_tool_description_optimizer.py +49 -0
  164. tooluniverse/test/test_tool_finder.py +26 -0
  165. tooluniverse/test/test_tool_finder_llm.py +252 -0
  166. tooluniverse/test/test_tools_find.py +195 -0
  167. tooluniverse/test/test_uniprot_tools.py +74 -0
  168. tooluniverse/test/test_uspto_tool.py +72 -0
  169. tooluniverse/test/test_xml_tool.py +113 -0
  170. tooluniverse/tool_finder_embedding.py +267 -0
  171. tooluniverse/tool_finder_keyword.py +693 -0
  172. tooluniverse/tool_finder_llm.py +699 -0
  173. tooluniverse/tool_graph_web_ui.py +955 -0
  174. tooluniverse/tool_registry.py +416 -0
  175. tooluniverse/uniprot_tool.py +155 -0
  176. tooluniverse/url_tool.py +253 -0
  177. tooluniverse/uspto_tool.py +240 -0
  178. tooluniverse/utils.py +369 -41
  179. tooluniverse/xml_tool.py +369 -0
  180. tooluniverse-1.0.0.dist-info/METADATA +377 -0
  181. tooluniverse-1.0.0.dist-info/RECORD +186 -0
  182. {tooluniverse-0.1.4.dist-info → tooluniverse-1.0.0.dist-info}/WHEEL +1 -1
  183. tooluniverse-1.0.0.dist-info/entry_points.txt +9 -0
  184. tooluniverse-0.1.4.dist-info/METADATA +0 -141
  185. tooluniverse-0.1.4.dist-info/RECORD +0 -18
  186. {tooluniverse-0.1.4.dist-info → tooluniverse-1.0.0.dist-info}/licenses/LICENSE +0 -0
  187. {tooluniverse-0.1.4.dist-info → tooluniverse-1.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,91 @@
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
+ {
71
+ "name": "FDA_get_drug_names_by_clinical_studies",
72
+ "arguments": {
73
+ "clinical_studies": "NSCLC hepatic impairment",
74
+ "indication": "cardiovascular",
75
+ },
76
+ },
77
+ ]
78
+
79
+ # Step 3: Run all test queries
80
+ for idx, query in enumerate(test_queries):
81
+ try:
82
+ print(
83
+ f"\n[{idx+1}] Running tool: {query['name']} with arguments: {query['arguments']}"
84
+ )
85
+ result = tooluni.run(query)
86
+ print("✅ Success. Example output snippet:")
87
+ print(
88
+ result if isinstance(result, dict) else str(result)[:500]
89
+ ) # Print snippet if result is big
90
+ except Exception as e:
91
+ print(f"❌ Failed. Error: {str(e)}")
@@ -0,0 +1,66 @@
1
+ # test_go.py
2
+
3
+ from tooluniverse import (
4
+ ToolUniverse,
5
+ ) # Assuming your ToolUniverse class is in this module
6
+ from typing import Any, Dict, List
7
+
8
+ # Step 1: Initialize ToolUniverse and load the GO tools
9
+ tooluni = ToolUniverse()
10
+ # This assumes your ToolUniverse is configured to find 'go_tools.json'
11
+ # when the 'go' category is requested.
12
+ tooluni.load_tools(["go"])
13
+
14
+ # Test GO ID for cell cycle process
15
+ TEST_GO_ID = "GO:0007049" # cell cycle
16
+ TEST_GENE_NAME = "TP53" # TP53 gene
17
+
18
+ test_queries: List[Dict[str, Any]] = [
19
+ {"name": "GO_search_terms", "arguments": {"query": "cell cycle"}},
20
+ {"name": "GO_get_term_by_id", "arguments": {"id": TEST_GO_ID}},
21
+ {"name": "GO_get_term_details", "arguments": {"id": TEST_GO_ID}},
22
+ {"name": "GO_get_genes_for_term", "arguments": {"id": TEST_GO_ID, "rows": 5}},
23
+ {"name": "GO_get_annotations_for_gene", "arguments": {"gene_id": TEST_GENE_NAME}},
24
+ ]
25
+
26
+
27
+ def format_value(value, max_items=5, max_length=200):
28
+ """Helper function to format output values with more detail"""
29
+ if isinstance(value, dict):
30
+ dict_str = str(value)
31
+ return f"Dict ({len(dict_str)} chars): {dict_str[:500]}{'...' if len(dict_str) > 500 else ''}"
32
+ elif isinstance(value, list):
33
+ if not value:
34
+ return "Empty list"
35
+ items_to_show = value[:max_items]
36
+ items_str = "\n - ".join(
37
+ [
38
+ str(item)[:max_length] + ("..." if len(str(item)) > max_length else "")
39
+ for item in items_to_show
40
+ ]
41
+ )
42
+ remaining = len(value) - max_items
43
+ return f"List with {len(value)} items:\n - {items_str}" + (
44
+ f"\n ... and {remaining} more items" if remaining > 0 else ""
45
+ )
46
+ elif isinstance(value, str):
47
+ return f"String ({len(value)} chars): {value[:max_length]}{'...' if len(value) > max_length else ''}"
48
+ else:
49
+ return f"Type: {type(value)}, Value: {value}"
50
+
51
+
52
+ print("--- Starting Gene Ontology (GO) Tool Test ---")
53
+
54
+ for idx, q in enumerate(test_queries, 1):
55
+ print(
56
+ f"\n{'='*80}\n[{idx}] {q['name']}({', '.join([f'{k}={v}' for k, v in q['arguments'].items()])})"
57
+ )
58
+ res = tooluni.run(q)
59
+
60
+ if isinstance(res, dict) and "error" in res:
61
+ print(f"ERROR: {res['error']}")
62
+ else:
63
+ print(format_value(res))
64
+ print()
65
+
66
+ print("\n--- GO Tool Test Completed ---")
@@ -0,0 +1,139 @@
1
+ # test_gwas_tool.py
2
+
3
+ from tooluniverse import ToolUniverse
4
+
5
+ # Step 1: Initialize ToolUniverse and load all tools (including GWAS tools)
6
+ tooluni = ToolUniverse()
7
+ tooluni.load_tools()
8
+
9
+ # Step 2: Define test queries for GWAS tools based on the examples
10
+ test_queries = [
11
+ # Test basic association search (Question 1 from examples)
12
+ {
13
+ "name": "gwas_search_associations",
14
+ "arguments": {"efo_trait": "type 2 diabetes mellitus", "size": 10},
15
+ },
16
+ # Test study search (Question 2 from examples)
17
+ {
18
+ "name": "gwas_search_studies",
19
+ "arguments": {"disease_trait": "type 2 diabetes", "cohort": "UKB", "size": 20},
20
+ },
21
+ # Test SNP search (Question 3 from examples)
22
+ {
23
+ "name": "gwas_search_associations",
24
+ "arguments": {
25
+ "rs_id": "rs1050316",
26
+ "sort": "p_value",
27
+ "direction": "asc",
28
+ "size": 10,
29
+ },
30
+ },
31
+ # Test gene-based SNP search (Question 10 from examples)
32
+ {"name": "gwas_search_snps", "arguments": {"mapped_gene": "HBS1L", "size": 10}},
33
+ # Test specialized tools
34
+ {
35
+ "name": "gwas_get_variants_for_trait",
36
+ "arguments": {"efo_trait": "type 2 diabetes mellitus", "size": 5},
37
+ },
38
+ {
39
+ "name": "gwas_get_associations_for_trait",
40
+ "arguments": {"efo_trait": "type 2 diabetes mellitus", "size": 5},
41
+ },
42
+ {
43
+ "name": "gwas_get_associations_for_snp",
44
+ "arguments": {"rs_id": "rs1050316", "size": 5},
45
+ },
46
+ {
47
+ "name": "gwas_get_studies_for_trait",
48
+ "arguments": {"efo_trait": "type 2 diabetes mellitus", "size": 5},
49
+ },
50
+ {
51
+ "name": "gwas_get_snps_for_gene",
52
+ "arguments": {"mapped_gene": "HBS1L", "size": 5},
53
+ },
54
+ # Test get by ID tools
55
+ {"name": "gwas_get_study_by_id", "arguments": {"study_id": "GCST000001"}},
56
+ {"name": "gwas_get_snp_by_id", "arguments": {"rs_id": "rs429358"}},
57
+ # Test studies with summary statistics (Question 9 from examples)
58
+ {
59
+ "name": "gwas_get_studies_for_trait",
60
+ "arguments": {
61
+ "efo_trait": "type 2 diabetes mellitus",
62
+ "full_pvalue_set": True,
63
+ "size": 5,
64
+ },
65
+ },
66
+ # Test GxE studies (Question 11 from examples)
67
+ {
68
+ "name": "gwas_get_studies_for_trait",
69
+ "arguments": {
70
+ "efo_trait": "total blood protein measurement",
71
+ "gxe": True,
72
+ "size": 5,
73
+ },
74
+ },
75
+ ]
76
+
77
+
78
+ def format_value(value, max_items=10, max_length=5000):
79
+ """Helper function to format output values"""
80
+ if isinstance(value, dict):
81
+ if "error" in value:
82
+ return f"ERROR: {value['error']}"
83
+
84
+ # Show the structure of the response
85
+ if "data" in value and "metadata" in value:
86
+ result = "Response Structure:\n"
87
+ result += f" Data: {len(value['data'])} items\n"
88
+ if value["metadata"]:
89
+ result += f" Metadata: {value['metadata']}\n"
90
+
91
+ # Show first few data items
92
+ if value["data"]:
93
+ result += f"\nFirst {min(max_items, len(value['data']))} data items:\n"
94
+ for i, item in enumerate(value["data"][:max_items]):
95
+ item_str = str(item)
96
+ if len(item_str) > max_length:
97
+ item_str = item_str[:max_length] + "..."
98
+ result += f" [{i+1}] {item_str}\n"
99
+
100
+ if len(value["data"]) > max_items:
101
+ result += f" ... and {len(value['data']) - max_items} more items\n"
102
+
103
+ return result
104
+ else:
105
+ # Fallback for non-structured responses
106
+ dict_str = str(value)
107
+ return f"Dict ({len(dict_str)} chars): {dict_str[:max_length]}{'...' if len(dict_str) > max_length else ''}"
108
+ elif isinstance(value, list):
109
+ if not value:
110
+ return "Empty list"
111
+ items_to_show = value[:max_items]
112
+ items_str = "\n - ".join(
113
+ [
114
+ str(item)[:max_length] + ("..." if len(str(item)) > max_length else "")
115
+ for item in items_to_show
116
+ ]
117
+ )
118
+ remaining = len(value) - max_items
119
+ return f"List with {len(value)} items:\n - {items_str}" + (
120
+ f"\n ... and {remaining} more items" if remaining > 0 else ""
121
+ )
122
+ elif isinstance(value, str):
123
+ return f"String ({len(value)} chars): {value[:max_length]}{'...' if len(value) > max_length else ''}"
124
+ else:
125
+ return f"Type: {type(value)}, Value: {value}"
126
+
127
+
128
+ # Step 3: Run all test queries
129
+ for idx, query in enumerate(test_queries, 1):
130
+ print(
131
+ f"\n{'='*80}\n[{idx}] Running tool: {query['name']} with arguments: {query['arguments']}"
132
+ )
133
+ try:
134
+ result = tooluni.run(query)
135
+ print("✅ Success. Output:")
136
+ print(format_value(result))
137
+ except (ImportError, AttributeError, KeyError, ValueError) as e:
138
+ print(f"❌ Failed. Error: {str(e)}")
139
+ print()