[BioPython] Bio.PDB: possible to obtain chain identifier for atoms?

Christian Meesters meesters at uni-mainz.de
Thu Aug 16 14:33:56 EDT 2007


Hi All,

I'm trying to build a somewhat bigger app which needs to calculate the
distance distribution function of a protein several times. For this
purpose I re-discovered BioPython today.
Speed is an issue, but since the protein in question isn't too big the
overhead of Python and BioPython might be tolerable.

Still, in order to speed up my code I would need to access the chain
identifier of atoms within a loop. To illustrate my question some
pseudo-code:

atoms = Selection.unfold_entities(structure, 'A')
for i, a in enumerate(atoms):
    for b in atoms[i+1:]:
	# do some calculations here ...

Now, I cannot avoid the double loop, but if I could check somehow
whether atoms a and b belong to the same chain (and which) I would have
to do this awkward looping only once this way.

Does anybody know an approach? As far as I understand the code of the
Atom class, there is no direct way, right?

TIA
Christian


More information about the BioPython mailing list