""" Test script for RDKit tools. This script tests the functionality of the RDKit tools implemented in the sci_mcp/chemistry_mcp/rdkit_tools module. """ import sys import os # Add the project root directory to the Python path sys.path.append('/home/ubuntu/sas0/lzy/multi_mcp_server') from sci_mcp.chemistry_mcp.rdkit_tools.rdkit_tools import ( calculate_molecular_properties, calculate_drug_likeness, calculate_topological_descriptors, generate_molecular_fingerprints, calculate_molecular_similarity, analyze_molecular_structure, generate_molecular_conformer, identify_scaffolds, convert_between_chemical_formats, standardize_molecule, enumerate_stereoisomers, perform_substructure_search ) def test_molecular_properties(): """Test the calculation of molecular properties.""" print("Testing calculate_molecular_properties...") # Aspirin smiles = "CC(=O)OC1=CC=CC=C1C(=O)O" result = calculate_molecular_properties(smiles) print(result) print("-" * 80) def test_drug_likeness(): """Test the calculation of drug-likeness properties.""" print("Testing calculate_drug_likeness...") # Aspirin smiles = "CC(=O)OC1=CC=CC=C1C(=O)O" result = calculate_drug_likeness(smiles) print(result) print("-" * 80) def test_topological_descriptors(): """Test the calculation of topological descriptors.""" print("Testing calculate_topological_descriptors...") # Aspirin smiles = "CC(=O)OC1=CC=CC=C1C(=O)O" result = calculate_topological_descriptors(smiles) print(result) print("-" * 80) def test_molecular_fingerprints(): """Test the generation of molecular fingerprints.""" print("Testing generate_molecular_fingerprints...") # Aspirin smiles = "CC(=O)OC1=CC=CC=C1C(=O)O" result = generate_molecular_fingerprints(smiles, fingerprint_type="morgan") print(result) print("-" * 80) def test_molecular_similarity(): """Test the calculation of molecular similarity.""" print("Testing calculate_molecular_similarity...") # Aspirin and Ibuprofen smiles1 = "CC(=O)OC1=CC=CC=C1C(=O)O" # Aspirin smiles2 = "CC(C)CC1=CC=C(C=C1)C(C)C(=O)O" # Ibuprofen result = calculate_molecular_similarity(smiles1, smiles2) print(result) print("-" * 80) def test_molecular_structure(): """Test the analysis of molecular structure.""" print("Testing analyze_molecular_structure...") # Aspirin smiles = "CC(=O)OC1=CC=CC=C1C(=O)O" result = analyze_molecular_structure(smiles) print(result) print("-" * 80) def test_molecular_conformer(): """Test the generation of molecular conformers.""" print("Testing generate_molecular_conformer...") # Aspirin smiles = "CC(=O)OC1=CC=CC=C1C(=O)O" result = generate_molecular_conformer(smiles) print(result) print("-" * 80) def test_scaffolds(): """Test the identification of molecular scaffolds.""" print("Testing identify_scaffolds...") # Aspirin smiles = "CC(=O)OC1=CC=CC=C1C(=O)O" result = identify_scaffolds(smiles) print(result) print("-" * 80) def test_format_conversion(): """Test the conversion between chemical formats.""" print("Testing convert_between_chemical_formats...") # Aspirin smiles = "CC(=O)OC1=CC=CC=C1C(=O)O" result = convert_between_chemical_formats(smiles, "smiles", "inchi") print(result) print("-" * 80) def test_standardize_molecule(): """Test the standardization of molecules.""" print("Testing standardize_molecule...") # Betaine with charges smiles = "C[N+](C)(C)CC(=O)[O-]" result = standardize_molecule(smiles) print(result) print("-" * 80) def test_stereoisomers(): """Test the enumeration of stereoisomers.""" print("Testing enumerate_stereoisomers...") # 3-penten-2-ol (has both a stereocenter and a stereobond) smiles = "CC(O)C=CC" result = enumerate_stereoisomers(smiles) print(result) print("-" * 80) def test_substructure_search(): """Test the substructure search.""" print("Testing perform_substructure_search...") # Aspirin, search for carboxylic acid group smiles = "CC(=O)OC1=CC=CC=C1C(=O)O" pattern = "C(=O)O" result = perform_substructure_search(smiles, pattern) print(result) print("-" * 80) def main(): """Run all tests.""" print("Testing RDKit tools...\n") # Uncomment the tests you want to run test_molecular_properties() test_drug_likeness() test_topological_descriptors() test_molecular_fingerprints() test_molecular_similarity() test_molecular_structure() test_molecular_conformer() test_scaffolds() test_format_conversion() test_standardize_molecule() test_stereoisomers() test_substructure_search() print("All tests completed.") if __name__ == "__main__": main()