Repository navigation
Description
Setup
This is an enhancement request. I am using Biopython version, Python version, and operating
system as follows:
3.7.2 (default, Jan 13 2019, 12:50:01)
[Clang 10.0.0 (clang-1000.11.45.5)]
CPython
Darwin-18.2.0-x86_64-i386-64bit
1.74.dev0 (I fixed mine already)
Desired behaviour
The 4-character idCode (PDBID) is a unique reference for a specific structure within the PDB. See PDB format docs. Sources such as the Biopython tutorial pass this as an argument to PDBParser as id, 'the id that will be used for the structure'. For bulk processing of lists of PDB files it would be nice to have it inside the data structure if it is available.
Actual behaviour
The idCode is not part of the header dictionary when loaded by PDBParser()
Steps to reproduce
PDB_parser = PDBParser(PERMISSIVE=False, QUIET=True)
structure = PDB_parser.get_structure('prot', f)
for k,v in structure.header.items():
print(k,v)
Fix
The following diff adds what I believe is the desired behaviour to PDB/parse_pdb_header.py:
diff --git a/Bio/PDB/parse_pdb_header.py b/Bio/PDB/parse_pdb_header.py
index 9d86c039d..1166ac4d7 100644
--- a/Bio/PDB/parse_pdb_header.py
+++ b/Bio/PDB/parse_pdb_header.py
@@ -183,6 +183,7 @@ def _parse_pdb_header_list(header):
dict = {
'name': "",
'head': '',
+ 'idcode': '',
'deposition_date': "1909-01-08",
'release_date': "1909-01-08",
'structure_method': "unknown",
@@ -219,6 +220,9 @@ def _parse_pdb_header_list(header):
rr = re.search(r"\d\d-\w\w\w-\d\d", tail)
if rr is not None:
dict['deposition_date'] = _format_date(_nice_case(rr.group()))
+ rr = re.search(r"\s+\w\w\w\w\s*\Z",tail)
+ if rr is not None:
+ dict['idcode'] = rr.group(0)
head = _chop_end_misc(tail).lower()
dict['head'] = head
elif key == "COMPND":
This is also available on my rtm-pic branch, but seems a bit small for a pull request.
Activity
peterjc commentedon Feb 12, 2019
What do you think @lennax, @etal, etc - is this a sensible addition?
peterjc commentedon Feb 12, 2019
@rob-miller As a former
Bio.PDBuser, I can see this being useful - I'm hoping to get input from one of our active PDB maintainers, but if no one is available I would be willing to review a pull request for this.Extract PDB ID in Bio/PDB/parse_pdb_header.py (#1933)
peterjc commentedon Feb 21, 2019
Closed via #1933, thank you!