import pickle
from dp5.run.data_structures import Molecule
from dp5.nmr_processing.proton import integrate
from rdkit import Chem
from rdkit.Chem import AllChem
import os

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'


mol = Chem.MolFromMolFile('/home/rk582/DP5/test/tegan_mosher.mol')
mol_h = Chem.AddHs(mol, addCoords=True)


with open('/home/rk582/DP5/test/tps-1-14.preint', 'rb') as f:
    data = pickle.load(f)

# currently crashes in integrate_sim_regions - verify correct arguments are passed
# fails due to lack of grouping???? check remove_impurities
# integration is odd, numpy refuses to filter peaks
result = integrate.find_integrals(mol_h, data.protondata["peak_regions"],
                                  data.protondata["grouped_peaks"],
                                  data.protondata["sim_regions"],
                                  data.protondata["picked_peaks"],
                                  data.protondata["params"],
                                  data.protondata["ydata"],)

_ = result
