Hi everyone, 

I'm trying to do some distance extraction of hetero atoms in pdbs. I've got 

    for model in pdb_obj.hierarchy.models():
      for chain in model.chains():
        for rg in chain.residue_groups():
          for ag in rg.atom_groups():
            for atom in ag.atoms():
              if atom.hetero == True:
                print  atom.distance(atom)

Which prints out 0.0 as expected. But I can't figure out how to, say, measure the distance to an atom in the previous residue (if there is a previous residue). 


I also noticed something weird in this tutorial: 
http://cctbx.sourceforge.net/sbgrid2008/tutorial.html
They truncate a non-standard amino acid to the beta-carbon but this only works because there's an alternate conformation with a standard amino acid (Cys). So it wouldn't work with a seleno-met for instance (I know there's a convert-to-ala function in mmtbx - I said it was weird, not terrible). 

Anyway, I hope someone can explain the distances thing for me. I'm sure there are multiple ways of doing it (should I just do a selection of "hetatm" and iterate over them and try to get some distanes?). 

Cheers,
Morten