Last active
November 12, 2015 12:35
-
-
Save filipsPL/5c810a452559a7fcc99e to your computer and use it in GitHub Desktop.
split molecule file to separate components and save to multiple files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### split molecule file to separate components and save to multiple files. | |
import pybel | |
from openbabel import * | |
mol = pybel.readfile('mol2', 'ligand.mol2').next() | |
separated = mol.OBMol.Separate() | |
def writeOut( theConformer, outputPath ): | |
myConversion = OBConversion() | |
outputFormat = myConversion.FormatFromExt( outputPath ) | |
myConversion.SetOutFormat( outputFormat ) | |
myConversion.WriteFile( theConformer, outputPath ) | |
i = 0 | |
for singlemol in separated: | |
i+=1 | |
print "Writing part %i" % (i) | |
writeOut(singlemol, "output-%i.mol2" %(i) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment