#!/usr/bin/env python3
"""Test QSPOCDesc class with single SMILES molecules"""

from pathlib import Path
from qspoc.descriptor import QSPOCDesc


def test_single_smiles_with_qspocdesc():
    """Test QSPOCDesc with 4 molecules (similar to test1.py structure)"""

    # Define path to Multiwfn
    Multiwfn_path = Path(__file__).parent.parent / "bin/Multiwfn/Multiwfn_3.8_bin_Linux_noGUI/Multiwfn_noGUI"
    xtb_path = Path(__file__).parent.parent / "bin/xtb-source/xtb/bin/xtb"
    save_dir = Path(__file__).parent / "test_file"

    mmdesc = QSPOCDesc(multiwfn_path=Multiwfn_path, save_dir=save_dir, exe_path_dict={"xtb": xtb_path, "g16": "g16"})
    mmdesc.load_data(
        smiles_list=["CS(=O)C", "CCO", "Cc1ccccc1", "abcdefgh"],  # 4 molecules: DMSO, ethanol, benzene, methane
        atom_lists=[[0], [2], [0], [0]],  # atom indices for each molecule
        bond_lists=[[(0, 1)], [(1, 2)], [(0, 1)], [(0, 1)]],  # bond pairs for each molecule
        angle_lists=[[(0, 1, 2)], [(0, 1, 2)], [(0, 1, 2)], [(0, 1, 2)]],  # angle triples for each molecule
        dihedral_lists=[[(0, 1, 2, 3)], [(0, 1, 2, 3)], [(0, 1, 2, 3)], [(0, 1, 2, 3)]],  # dihedral quads for each molecule
        axis_lists=[(1, 2), (0, 1), (1, 0), (1, 2)],  # axis for each molecule
        name_list=["dimethyl_sulfoxide", "ethanol", "benzene", "Error"],  # names for each molecule
        prop_lists=[(0, 1), (0, 1), (0, 1), (0, 1)],  # properties for each molecule
        drop_duplicates=True,
    )
    mmdesc.get_init_sturct()
    mmdesc.geometric_opt(method="g16", calc_command="b3lyp def2svp")
    mmdesc.singlepoint_energy(method="g16", calc_command="b3lyp def2svp")
    mmdesc.descriptor_calc()

    print("\nTest completed successfully!")


if __name__ == "__main__":
    test_single_smiles_with_qspocdesc()
