From: Michael Kreim (mkreim_at_keychem.de)
Date: Tue Jul 21 2009 - 06:49:44 CDT

Hello,

I have (again) some trouble in using python 2.2.3 inside vmd 1.8.6.

I want to save each segment of a pdb file in an own pdb file. I am doing
this using this function:

def split_PDB_into_Segments(pdb):
    import Molecule
    import atomsel
    mid=Molecule.Molecule()
    mid.load(pdb, filetype='pdb', first=0, last=-1, step=1, waitfor=-1)
    sorted_segnames = _uniq(atomsel.atomsel("all").get("segname"))
    for seg in sorted_segnames:
        segstr = "segname " + seg
        sel_seg = atomsel.atomsel(segstr)
        mid.save(seg+".pdb", filetype='pdb', first=0, last=-1, step=1,
waitfor=-1, sel=sel_seg)
    mid.delete()

(_uniq() is a small function that works similar as the unix uniq command)

If I run this code, I get the following error:

Traceback (most recent call last):
  File "VMD", line 30, in ?
  File "/x/x.py", line 45, in split_PDB_into_Segments
    mid.save(seg+".pdb", filetype='pdb', first=0, last=-1, step=1,
waitfor=-1, sel=sel_seg)
  File "/x/vmd/linux/vmd_amd64/lib/vmd/scripts/python/Molecule.py", line
121, in save
    if isinstance(sel, VMD.AtomSel.AtomSel):
AttributeError: 'module' object has no attribute 'AtomSel'

Maybe somebody can help me in how to use the Molecule.save() routine
correctly. I followed the documentation given by help(Molecule).

Thanks a lot.

Best regards,

Michael