Permalink
Browse files

Use SeqUtils.seq1() instead of SCOP.to_one_letter_code().

  • Loading branch information...
1 parent f8aee4d commit e08ae4383d1c9cdc324380892aee8e7026f3cfa1 @cbrueffer cbrueffer committed with bow Dec 10, 2012
Showing with 6 additions and 8 deletions.
  1. +6 −8 Bio/SeqIO/PdbIO.py
View
@@ -22,9 +22,8 @@ def PdbSeqresIterator(handle):
See: http://www.wwpdb.org/documentation/format23/sect3.html
"""
- # Late-binding import to avoid circular dependency on SeqIO in Bio.SCOP
- # TODO - swap in Bow's SeqUtils.seq1 once that's merged
- from Bio.SCOP.three_to_one_dict import to_one_letter_code
+ # Late-binding import to avoid circular dependency on SeqIO in Bio.SeqUtils
+ from Bio.SeqUtils import seq1
chains = collections.defaultdict(list)
metadata = collections.defaultdict(list)
@@ -42,8 +41,7 @@ def PdbSeqresIterator(handle):
chn_id = line[11]
# Number of residues in the chain (repeated on every record)
# num_res = int(line[13:17])
- residues = [to_one_letter_code.get(res, 'X')
- for res in line[19:].split()]
+ residues = [seq1(res) for res in line[19:].split()]
chains[chn_id].extend(residues)
elif rec_name == 'DBREF':
# ID code of this entry (PDB ID)
@@ -124,14 +122,14 @@ def PdbAtomIterator(handle):
"""
# Only import PDB when needed, to avoid/delay NumPy dependency in SeqIO
from Bio.PDB import PDBParser
- from Bio.SCOP.three_to_one_dict import to_one_letter_code
+ from Bio.SeqUtils import seq1
def restype(residue):
"""Return a residue's type as a one-letter code.
Non-standard residues (e.g. CSD, ANP) are returned as 'X'.
"""
- return to_one_letter_code.get(residue.resname, 'X')
+ return seq1(residue.resname)
# Deduce the PDB ID from the PDB header
# ENH: or filename?
@@ -149,7 +147,7 @@ def restype(residue):
for chn_id, chain in sorted(model.child_dict.iteritems()):
# HETATM mod. res. policy: remove mod if in sequence, else discard
residues = [res for res in chain.get_unpacked_list()
- if res.get_resname().upper() in to_one_letter_code]
+ if seq1(res.get_resname().upper()) != "X"]
if not residues:
continue
# Identify missing residues in the structure

0 comments on commit e08ae43

Please sign in to comment.