# Import necessary modules
from utils import *
from py3Dmol_utils import MolTo3DView
from utils import CIRconvert
from nbo_parser import nbo_parser
import pandas as pd
import autode as ade
import os
# Get the dataframe from task0
task_0_df = pd.read_csv('task_0_20220125_16_04.csv')
# Let's focus on Tyrosine, since it should be able to exhibity both conjugation and hyperconjugation
# We will re-optimize the configuration from task_0 with xtb (coarse-grained), then ORCA HF-3c level of theory and
# finally perform a single point with a more robust level of theory (hybrid functional)
HF_3c_opt_nbo_orca = ade.methods.ORCA()
HF_3c_opt_nbo_orca.keywords.opt = ade.OptKeywords(['HF-3c', 'NBO'])
PBE0_sp_nbo_orca = ade.methods.ORCA()
PBE0_sp_nbo_orca.keywords.sp = ade.SinglePointKeywords(['PBE0', 'NBO', 'def2-SV(P)', 'def2/J', 'D3BJ', 'RIJCOSX'])
def run_xtb_HF_3c_opt_PBE0_sp_nbo_orca(name, smiles):
amino_acid = ade.Molecule(name = name, smiles = smiles)
amino_acid.optimise(method=ade.methods.XTB()) # coarse-grained
amino_acid.optimise(method=HF_3c_opt_nbo_orca) # HF
amino_acid.single_point(method=PBE0_sp_nbo_orca) # Hybrid
print(name, amino_acid.energy)
# Call the optimization function
# smiles = task_0_df[task_0_df['amino acid name'] == "Tyrosine"]['non_canonical_SMILES_L_amino_acid'].iloc[0]
# name_label = "Tyrosine_hw1"
# run_xtb_HF_3c_opt_PBE0_sp_nbo_orca(name=name_label, smiles=smiles)
# From the Tyrosine_hw1_sp_orca.out file, we can see in the
hyperconjugation_types_examples_mols_id = [0, 1, 2]
hyperconjugation_types_examples_mols_names = ['ethane', 'methyl_amine', 'methyl_borane']
hyperconjugation_types_examples_mols_smiles = ['CC', 'CN', 'CB']
for i in hyperconjugation_types_examples_mols_id:
run_xtb_HF_3c_opt_PBE0_sp_nbo_orca(hyperconjugation_types_examples_mols_names[i], hyperconjugation_types_examples_mols_smiles[i])
conjugation_types_examples_mols_id = [0, 1, 2]
conjugation_types_examples_mols_names = ['ethene', 'MA_conj', 'MB_conj']
conjugation_types_examples_mols_smiles = ['C=C', 'C=[N+]', 'C=[B+]']
for i in conjugation_types_examples_mols_id:
run_xtb_HF_3c_opt_PBE0_sp_nbo_orca(conjugation_types_examples_mols_names[i], conjugation_types_examples_mols_smiles[i])
# start your answer here