Snippets

Dénes Türei arrange atoms in canonical order with pybel

Created by Dénes Türei
#!/usr/bin/env python

# Denes Turei EMBL 2018
# turei.denes@gmail.com

# converts set of structures to canonical order

import pybel

molecules = list(
    pybel.readfile(
        'pdb',
        # test file
        # find at:
        # https://www.ebi.ac.uk/~denes/54b510889336eb2591d8beff/
        # 00127_0a949dbfc5df14c6619e5acf726e0d11_16.pdb.txt
        '00127_0a949dbfc5df14c6619e5acf726e0d11_16.pdb'
    )
)

for mol in molecules:
    
    _ = pybel.ob.OBOp_FindType('canonical').Do(mol.OBMol)

for i, mol in enumerate(molecules):
    
    mol.write('pdb', 'pybel-canonical-test-%u.pdb' % i)

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.