Skip to content

Commit

Permalink
Don't use next as a variable name, it masks the built in iteration fu…
Browse files Browse the repository at this point in the history
…nction on Python 3
  • Loading branch information
peterjc committed Aug 16, 2010
1 parent 5165bf9 commit 1eb48fe
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions Bio/PDB/Polypeptide.py
Expand Up @@ -331,21 +331,21 @@ def build_peptides(self, entity, aa_only=1):
pp_list=[]
for chain in chain_list:
chain_it=iter(chain)
prev=chain_it.next()
prev_res=chain_it.next()
pp=None
for next in chain_it:
if aa_only and not accept(prev):
prev=next
for next_res in chain_it:
if aa_only and not accept(prev_res):
prev_rev=next_res
continue
if is_connected(prev, next):
if is_connected(prev_res, next_res):
if pp is None:
pp=Polypeptide()
pp.append(prev)
pp.append(prev_res)
pp_list.append(pp)
pp.append(next)
pp.append(next_res)
else:
pp=None
prev=next
prev_res=next_res
return pp_list


Expand All @@ -354,12 +354,12 @@ class CaPPBuilder(_PPBuilder):
def __init__(self, radius=4.3):
_PPBuilder.__init__(self, radius)

def _is_connected(self, prev, next):
for r in [prev, next]:
def _is_connected(self, prev_res, next_res):
for r in [prev_res, next_res]:
if not r.has_id("CA"):
return 0
n=next["CA"]
p=prev["CA"]
return False
n=next_res["CA"]
p=prev_res["CA"]
# Unpack disordered
if n.is_disordered():
nlist=n.disordered_get_list()
Expand All @@ -372,23 +372,23 @@ def _is_connected(self, prev, next):
for nn in nlist:
for pp in plist:
if (nn-pp)<self.radius:
return 1
return 0
return True
return False


class PPBuilder(_PPBuilder):
"""Use C--N distance to find polypeptides."""
def __init__(self, radius=1.8):
_PPBuilder.__init__(self, radius)

def _is_connected(self, prev, next):
if not prev.has_id("C"):
return 0
if not next.has_id("N"):
return 0
def _is_connected(self, prev_res, next_res):
if not prev_res.has_id("C"):
return False
if not next_res.has_id("N"):
return False
test_dist=self._test_dist
c=prev["C"]
n=next["N"]
c=prev_res["C"]
n=next_res["N"]
# Test all disordered atom positions!
if c.is_disordered():
clist=c.disordered_get_list()
Expand All @@ -413,8 +413,8 @@ def _is_connected(self, prev, next):
c.disordered_select(c_altloc)
if n.is_disordered():
n.disordered_select(n_altloc)
return 1
return 0
return True
return False

def _test_dist(self, c, n):
"""Return 1 if distance between atoms<radius (PRIVATE)."""
Expand Down

0 comments on commit 1eb48fe

Please sign in to comment.