Hi,
I have a little pybel script for generating Murcko scaffolds, which
works well with 2.3.1, but fails on a few molecules ("Segmentation
fault") with 2.3.2.
Depending on code modifications, the fault raises at different points,
but I have no clue on why the bug is happening.
Below is my code shortened as much as I could.
Regards,
Pascal
#!/usr/bin/env python
# encoding: utf-8
import sys
import os, pybel
import openbabel as ob
def GetMurckoFramework(mol):
haveAtomWithOneNeighbor,atomsWithOneNeighborList =
checkIfIsOnlyOneNeighbor(mol)
while (haveAtomWithOneNeighbor):
for atomToDel in atomsWithOneNeighborList:
mol.OBMol.DeleteAtom(atomToDel) # delete atom which are
not part of a cycle or a linker (terminal atoms)
haveAtomWithOneNeighbor,atomsWithOneNeighborList =
checkIfIsOnlyOneNeighbor(mol)
return mol
def checkIfIsOnlyOneNeighbor(mol):
isAnAtomWithOneNeighbor = 0
atomWithOneNeighborList = []
for atom in ob.OBMolAtomIter(mol.OBMol):
if not atom.IsInRing():
neighborsCount = 0
for neighbor in ob.OBAtomAtomIter(atom):
neighborsCount = neighborsCount + 1
if (neighborsCount <= 1): # It is a terminal atom (only
one neighbor) double bond
atomWithOneNeighborList.append(atom) # will be deleted
isAnAtomWithOneNeighbor = 1
return isAnAtomWithOneNeighbor, atomWithOneNeighborList
def main():
if len(sys.argv) < 2:
print "No input file provided: Murcko.py filetosprocess.smi"
sys.exit(1)
mol1 = pybel.readstring("smi", "C1(=Cc2cn(nc2)CC(=O)N)C(=O)NC(=O)S1")
mol2 = pybel.readstring("smi", "C1(=CC2=C(N=C(C2)C(=O)N)C)C(=O)NC(=O)S1")
li = [mol1, mol2]
for mol in li:
mol = GetMurckoFramework(mol)
print mol
if __name__ == '__main__':
main()
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
OpenBabel-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss