<jupyter_start><jupyter_text>Analyze WBO TorsionThis script performs analysis on QCA datasets by finding the torsion barrier from their QCA record and calculating their ELF10 WBO with an AM1 calculation.  Data outputAfter data processing the molecules are stored into an oeb. Each respective OE molecule has the following data stored using datatags:  - tdr_object.id : int (id of the TD record) with datatag "TDid" - dihedral_indices: list (list of atom indices for which torsion is driven in this record) datatag "TDindices" - torsion_barrier: float (torsion barrier energy in KJ/mol, maximum of all the barriers) datatag "TB" - cmiles: str (string for the cmiles of the molecule in canonical_isomeric_explicit_hydrogen_mapped_smiles) datatag "cmiles" - wbo: float (float of the ELF10 wiberg bond order calculated between the central torsion idicies) datatag "wbo" - IDMatch: "IDMatch" that contain the torsion id from .offxml format FF involved in the QCA torsion drive datatag "IDMatch"  Step 1. Generate oeb files for the specific ForceField ***Uncomment lines 26,27 depending on your usage<jupyter_code>ff_name = 'openff_unconstrained-1.3.0.offxml'
folder_name = './FF_1.3.0/'
import os
import errno

TD_datasets = ['Fragment Stability Benchmark',
 'Fragmenter paper',
 'OpenFF DANCE 1 eMolecules t142 v1.0',
 'OpenFF Fragmenter Validation 1.0',
 'OpenFF Full TorsionDrive Benchmark 1',
 'OpenFF Gen 2 Torsion Set 1 Roche',
 'OpenFF Gen 2 Torsion Set 1 Roche 2',
 'OpenFF Gen 2 Torsion Set 2 Coverage',
 'OpenFF Gen 2 Torsion Set 2 Coverage 2',
 'OpenFF Gen 2 Torsion Set 3 Pfizer Discrepancy',
 'OpenFF Gen 2 Torsion Set 3 Pfizer Discrepancy 2',
 'OpenFF Gen 2 Torsion Set 4 eMolecules Discrepancy',
 'OpenFF Gen 2 Torsion Set 4 eMolecules Discrepancy 2',
 'OpenFF Gen 2 Torsion Set 5 Bayer',
 'OpenFF Gen 2 Torsion Set 5 Bayer 2',
 'OpenFF Gen 2 Torsion Set 6 Supplemental',
 'OpenFF Gen 2 Torsion Set 6 Supplemental 2',
 'OpenFF Group1 Torsions',
 'OpenFF Group1 Torsions 2',
 'OpenFF Group1 Torsions 3',
 'OpenFF Primary Benchmark 1 Torsion Set',
 'OpenFF Primary Benchmark 2 Torsion Set',
 'OpenFF Primary TorsionDrive Benchmark 1',
 'OpenFF Rowley Biaryl v1.0',
 'OpenFF Substituted Phenyl Set 1',
 'OpenFF-benchmark-ligand-fragments-v1.0',
 'Pfizer Discrepancy Torsion Dataset 1',
 'SMIRNOFF Coverage Torsion Set 1',
#  'SiliconTX Torsion Benchmark Set 1',
 'TorsionDrive Paper']

error_td = []
count = 0

TD_working_oeb = [folder_name+x+'.oeb' for x in TD_datasets]

for td_name in TD_datasets:
    count += 1
    print(td_name)
    filename = folder_name 
    if not os.path.exists(os.path.dirname(filename)):
        try:
            os.makedirs(os.path.dirname(filename))
        except OSError as exc: # Guard against race condition
            if exc.errno != errno.EEXIST:
                raise
                
    filename = filename + td_name
    
    while True:
        try:
#             genData(td_name, filename, ff_name)
#             genPlots(filename+'.oeb', filename+'.pdf')
            break
        except:
            error_td.append(td_name)
            break<jupyter_output>Fragment Stability Benchmark
Fragmenter paper
OpenFF DANCE 1 eMolecules t142 v1.0
OpenFF Fragmenter Validation 1.0
OpenFF Full TorsionDrive Benchmark 1
OpenFF Gen 2 Torsion Set 1 Roche
OpenFF Gen 2 Torsion Set 1 Roche 2
OpenFF Gen 2 Torsion Set 2 Coverage
OpenFF Gen 2 Torsion Set 2 Coverage 2
OpenFF Gen 2 Torsion Set 3 Pfizer Discrepancy
OpenFF Gen 2 Torsion Set 3 Pfizer Discrepancy 2
OpenFF Gen 2 Torsion Set 4 eMolecules Discrepancy
OpenFF Gen 2 Torsion Set 4 eMolecules Discrepancy 2
OpenFF Gen 2 Torsion Set 5 Bayer
OpenFF Gen 2 Torsion Set 5 Bayer 2
OpenFF Gen 2 Torsion Set 6 Supplemental
OpenFF Gen 2 Torsion Set 6 Supplemental 2
OpenFF Group1 Torsions
OpenFF Group1 Torsions 2
OpenFF Group1 Torsions 3
OpenFF Primary Benchmark 1 Torsion Set
OpenFF Primary Benchmark 2 Torsion Set
OpenFF Primary TorsionDrive Benchmark 1
OpenFF Rowley Biaryl v1.0
OpenFF Substituted Phenyl Set 1
OpenFF-benchmark-ligand-fragments-v1.0
Pfizer Discrepancy Torsion Dataset 1
SMIRNOFF Coverage Torsion Set 1
Tor[...]<jupyter_text>Step 2. Visualize by reading the oeb filesCan use genPlots(), visualize_wbo_correlation_compare() from torsion_anlaysis.py<jupyter_code>#Let's also add the Rowley dataset and compare 
genPlots(folder_name + 'OpenFF Rowley Biaryl v1.0.oeb', folder_name + 'OpenFF Rowley Biaryl v1.0.pdf')<jupyter_output><empty_output><jupyter_text>Plotly plots and saving to a pdf for all datasets by torsion id`tids = ['t43', 't69', 't69a', 't72', 't74', 't96', 't97']for iid in tids:    tmp = plot_tid_for_datasets(TD_working_oeb, t_id=iid)    tmp.write_image(folder_name+"fig_"+str(iid)+".pdf")`<jupyter_code>tig_ids = ['t43', 't69', 't69a', 't72', 't74', 't96', 't97']
# ['TIG0', TIG1', 'TIG2', 'TIG3', 'TIG4', 'TIG5', 'TIG6', 'TIG7', 'TIG8']
for iid in tig_ids:
    tmp = plot_tid_for_datasets(TD_working_oeb, t_id=iid)
    tmp.write_image(folder_name+"fig_"+str(iid)+".pdf")
from smarts_torsions import *
import qcportal as ptl
client = ptl.FractalClient()  
smarts = "[*:1]~[#6X3:2]~[#6X3:3]~[*:4]"
datasets = TD_datasets
tdrs = get_torsiondrives_matching_smarts(smarts, datasets, client)
len(tdrs)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08368280594738849, 'fraction_numerical': 0.03373999237514297, 'mean_word_length': 4.4037075180226575, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '436791', 'license': 'MIT', 'n_tokens_mistral': 1999, 'n_tokens_neox': 1792, 'n_words': 640, 'path': 'Analyze_WBO_Torsion.ipynb', 'repo_name': 'danieljcabrera/wbointerpolation', 'size': '5246'}