Giter Club home page Giter Club logo

Comments (7)

lohedges avatar lohedges commented on August 26, 2024

It looks like FESetup uses OpenBabel (along with other things) to compute the formal charge. If this isn't something that we want to support in BioSimSpace at present, then the PDB files for all of the ligands in the D3R2018 challenge set will need to be updated with the correct charge.

For reference, here's some adapted code from FESetup that shows how to use OpenBabel to calculate the formal charge. This gives a value of +2 |e| for all ligands in the D3R2018 data set.

# formal_charge.py

import openbabel as ob
import sys

# Get the name of the PDB file.
file = sys.argv[1]

# Read the ligand PDB into an OpenBabel molecule.
# The PDB file has no formal charge information.
conv = ob.OBConversion()
mol = ob.OBMol()
conv.ReadFile(mol, file)

# Define some variables from FESetup's "const.py" file.
_phospho = '[#15D4](~[OD1])(~[OD1])(~[OD2])~[OD2]'
_sulfonyl = '[#16](~[OD1])(~[OD1])'

# Again, below is taken from "const.py"
# FIXME: this compensates for missing charge determination by Openbabel, so
#        will fail to detect charges in cases not covered here'; relies on
#        explicit hydrogens!
CHARGE_SMARTS = (
    ('[#16;$([#16D4](~[OD1])(~[OD1])~[OD1])]', -1),  # sulfates, Sac
    ('[#16;$([#16D3](~[OD1])~[OD1])]', -1),  # sulfonates, Sac
    ('[#15;$([#15D4](~[OD1])(~[OD1])~[OD1])]', -2),  # phosphates, Pac
    ('[#15;$([#15D3](~[OD1])~[OD1])]', -2),  # phosphonates, Pac
    ('[#15;$(%s)]' % _phospho, -1),     # polyphosphates or phosphate diesters
    ('[CD3](~[NH2])(~[NH2])~[NH]', +1), # guanidinium
    ('O=C~[CD3,ND2]~C=O', -1),          # beta-dicarbonyls, imides
    ('%s~[ND2]~C(=O)~[NH]' % _sulfonyl, -1), # sulfonylureas
    ('%s~[ND2]~C(=O)~[#6]' % _sulfonyl, -1), # (sulfon)imides
    ('%s~[ND2]~c' % _sulfonyl, -1),     # N-aryl sulfonamides
    ('{0}~[ND2]~{0}'.format(_sulfonyl), -1), # sulfonimides 2
    ('[#6][ND3]([#6])~[#6H]~[ND3]([#6])[#6]', +1), # formamidiniums
    ('C(~[OD1])~[OD1]', -1),            # carbonates, Cac in atomtyp.txt
    ('[#6][#16D1]', -1),                # thiolates
    ('[#6][#8D1]', -1),                 # alkoxides (alcoholates)
    ('[#7D4]', +1),                     # atomtyp.txt checks for [#7X4]
    ('{0}~[ND3](~{0})~[CD3](~{0})~{0}'.format('[#6,#1]'), +1),  # imines
    )

# Zero the total formal charge.
formal_charge = 0

# Initialise the smarts pattern object.
sm = ob.OBSmartsPattern()

# Loop over all smarts strings / formal charge pairs. 
for smarts, fchg in CHARGE_SMARTS:
    sm.Init(smarts)
    
    # Does the molecule match this string.
    # If so, update the formal charge.
    if sm.Match(mol):
        m = list(sm.GetUMapList() )
        formal_charge += fchg * len(m)

# Print the total formal charge.
print(file, formal_charge)

And run from the command-line, sitting in the top-level of the D3R2018 repositiory:

for i in $(ls CatS/BSS/ligands_aligned/*pdb); do
    python formal_charge.py $i
done

Output:

CatS/BSS/ligands_aligned/CatS_122.pdb 2
CatS/BSS/ligands_aligned/CatS_127.pdb 2
CatS/BSS/ligands_aligned/CatS_130.pdb 2
CatS/BSS/ligands_aligned/CatS_131.pdb 2
CatS/BSS/ligands_aligned/CatS_132.pdb 2
CatS/BSS/ligands_aligned/CatS_139.pdb 2
CatS/BSS/ligands_aligned/CatS_141.pdb 2
CatS/BSS/ligands_aligned/CatS_142.pdb 2
CatS/BSS/ligands_aligned/CatS_144.pdb 2
CatS/BSS/ligands_aligned/CatS_153.pdb 2
CatS/BSS/ligands_aligned/CatS_155.pdb 2
CatS/BSS/ligands_aligned/CatS_157.pdb 2
CatS/BSS/ligands_aligned/CatS_160.pdb 2
CatS/BSS/ligands_aligned/CatS_162.pdb 2
CatS/BSS/ligands_aligned/CatS_165.pdb 2
CatS/BSS/ligands_aligned/CatS_167.pdb 2
CatS/BSS/ligands_aligned/CatS_172.pdb 2
CatS/BSS/ligands_aligned/CatS_174.pdb 2
CatS/BSS/ligands_aligned/CatS_176.pdb 2
CatS/BSS/ligands_aligned/CatS_177.pdb 2
CatS/BSS/ligands_aligned/CatS_178.pdb 2
CatS/BSS/ligands_aligned/CatS_180.pdb 2
CatS/BSS/ligands_aligned/CatS_181.pdb 2
CatS/BSS/ligands_aligned/CatS_184.pdb 2
CatS/BSS/ligands_aligned/CatS_185.pdb 2
CatS/BSS/ligands_aligned/CatS_186.pdb 2
CatS/BSS/ligands_aligned/CatS_191.pdb 2
CatS/BSS/ligands_aligned/CatS_195.pdb 2
CatS/BSS/ligands_aligned/CatS_252.pdb 2
CatS/BSS/ligands_aligned/CatS_253.pdb 2
CatS/BSS/ligands_aligned/CatS_255.pdb 2
CatS/BSS/ligands_aligned/CatS_29.pdb 2
CatS/BSS/ligands_aligned/CatS_30.pdb 2
CatS/BSS/ligands_aligned/CatS_4.pdb 2
CatS/BSS/ligands_aligned/CatS_52.pdb 2
CatS/BSS/ligands_aligned/CatS_76.pdb 2
CatS/BSS/ligands_aligned/CatS_79.pdb 2
CatS/BSS/ligands_aligned/CatS_84.pdb 2
CatS/BSS/ligands_aligned/CatS_9.pdb 2

from biosimspace.

lohedges avatar lohedges commented on August 26, 2024

All of the ligands in this directory have the correct formal charge listed in the PDB file, i.e. there are two N1+ atoms, giving an overall formal charge of +2|e|. BioSimSpace can correctly read/write this information.

It looks like the formal charge must have been lost along the way during the preparation stage, perhaps when using FKCOMBU to align them. I'll see if it's easy to re-add the missing information in the prepared input files.

from biosimspace.

lohedges avatar lohedges commented on August 26, 2024

I've managed to edit all of the ligand PDB files by hand. I'll now re-parameterise them all with GAFF2 to correct the charges. It would be good to have write access to the D3R2018 repo so I can update the files once I'm done.

from biosimspace.

ppxasjsm avatar ppxasjsm commented on August 26, 2024

I assume you realised you already had write access?

from biosimspace.

lohedges avatar lohedges commented on August 26, 2024

Strange, when I tried pushing it said "access denied". Will try again tomorrow.

from biosimspace.

lohedges avatar lohedges commented on August 26, 2024

Worked this time, how bizarre. Perhaps there was a network issue when I last tried.

from biosimspace.

ppxasjsm avatar ppxasjsm commented on August 26, 2024

Glad it did!

from biosimspace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.