[Biopython] How to pull out the coordinates for het groups?
Jing Lu
ajingnk at gmail.com
Mon Jun 27 21:53:30 UTC 2011
Hi,
I want to pull out ligand from pdb file, then for each ligand(or het group)
save it as pdb, and keep the header. I have try the following code, but it
didn't return the result I want. Could you please give me some suggestion?
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
for filename in os.listdir(workdir):
print filename
if '.bio' in filename:
parser = PDBParser(PERMISSIVE=1)
structure = parser.get_structure(filename[:4], filename)
structure_copy = copy.deepcopy(structure) # for each ligand
renew the structure
het_id_all = get_het_id(structure_copy) # only return the
ligands of structure
for het_id in het_id_all:
for model in structure_copy:
for chain in model:
for residue in chain:
id = residue.id
if id[0] is not het_id:
chain.detach_child(id)
if len(chain) == 0:
model.detach_child(chain.id)
name = './ligand/' + filename[:9] + '_' + het_id[2:] + '_' +
str(id[1]).zfill(4) + chain.id + '.pdb'
save_structure(structure_copy, name)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
More information about the Biopython
mailing list