# Generating Canonical AM1-BCC Charges¶

## Problem¶

You want to generate general, canonical AM1-BCC charges from just one input structure. The atomic partial charges need to be appropriate for a wide spectrum of energy-based methods including minimization, posing in an active site, SZMAP, EON, or molecular dynamics.

## Ingredients¶

 OEChem TK - cheminformatics toolkit Quacpac TK - tautomers & charges toolkit Omega TK - conformer generation toolkit

## Difficulty level¶

can_am1_bcc.py

## Solution¶

The script below allows us to avoid the two big problems that easily happen from AM1-BCC charging a single structure: asymmetric charges and distorted charges (due to short-range polar interactions). In this recipe, 800 conformations are generated, and then the best one is chosen automatically and used to generate well-behaved, symmetric AM1-BCC charges. The input structure is then written out with these atomic partial charges, ready for use.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 def main(argv=[__name__]): if len(argv) != 3: oechem.OEThrow.Usage("%s " % argv[0]) ifs = oechem.oemolistream() if not ifs.open(argv[1]): oechem.OEThrow.Fatal("Unable to open %s for reading" % argv[1]) if not oechem.OEIs3DFormat(ifs.GetFormat()): oechem.OEThrow.Fatal("Invalid input format: need 3D coordinates") ofs = oechem.oemolostream() if not ofs.open(argv[2]): oechem.OEThrow.Fatal("Unable to open %s for writing" % argv[2]) if ofs.GetFormat() not in [oechem.OEFormat_MOL2, oechem.OEFormat_OEB]: oechem.OEThrow.Error("MOL2 or OEB output file is required!") omega = oeomega.OEOmega() omega.SetIncludeInput(True) omega.SetCanonOrder(False) omega.SetSampleHydrogens(True) eWindow = 15.0 omega.SetEnergyWindow(eWindow) omega.SetMaxConfs(800) omega.SetRMSThreshold(1.0) for mol in ifs.GetOEMols(): if omega(mol): oequacpac.OEAssignCharges(mol, oequacpac.OEAM1BCCELF10Charges()) conf = mol.GetConf(oechem.OEHasConfIdx(0)) absFCharge = 0 sumFCharge = 0 sumPCharge = 0.0 for atm in mol.GetAtoms(): sumFCharge += atm.GetFormalCharge() absFCharge += abs(atm.GetFormalCharge()) sumPCharge += atm.GetPartialCharge() print("{}: {} formal charges give total charge {}" "; sum of partial charges {:5.4f}".format(mol.GetTitle(), absFCharge, sumFCharge, sumPCharge)) oechem.OEWriteMolecule(ofs, conf) else: print("Failed to generate conformation(s) for molecule %s" % mol.GetTitle()) return 0 

## Usage¶

Usage

can_am1_bcc.py with charges.mol2 supporting data file

prompt > python3 can_am1_bcc.py charges.mol2 cancharges.mol2


Running the above command will generate the following output:

residue 'BFS': 0 formal charges give total charge 0 ; Sum of Partial Charges -0.0000
ceftolozane: 4 formal charges give total charge 0 ; Sum of Partial Charges -0.0000
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.2294304519891739, "perplexity": 10867.377207960762}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2019-13/segments/1552912202642.32/warc/CC-MAIN-20190322094932-20190322120932-00483.warc.gz"}