@@ -66,6 +66,9 @@ class Protein:
6666 Class Attributes:
6767 ELEMENT_COLORS: Default color mapping for chemical elements.
6868 CHAIN_COLORS: Default color mapping for protein chains.
69+ PDB_CHAIN_ID_INDEX: Index of chain ID in PDB file line.
70+ PDB_START_RESIDUE_INDICES: Indices of start-of-helix residue in PDB file line.
71+ PDB_END_RESIDUE_INDICES: Indices of end-of-helix residue in PDB file line.
6972 """
7073
7174 ELEMENT_COLORS = {
@@ -90,6 +93,10 @@ class Protein:
9093 "H" : color .rgb (1 , 0 , 1 ),
9194 }
9295
96+ PDB_CHAIN_ID_INDEX = 19
97+ PDB_START_RESIDUE_INDICES = (21 , 25 )
98+ PDB_END_RESIDUE_INDICES = (33 , 37 )
99+
93100 def __init__ (
94101 self ,
95102 pdb_filepath : str ,
@@ -368,9 +375,21 @@ def get_helices(self, pdb_filepath: str) -> dict[str, list[tuple[int]]]:
368375 with open (pdb_filepath , "r" ) as pdb_file :
369376 for line in pdb_file :
370377 if line .startswith ("HELIX" ):
371- chain_id = line [19 ].strip ()
372- start_residue = int (line [21 :25 ].strip ())
373- end_residue = int (line [33 :37 ].strip ())
378+ chain_id = line [Protein .PDB_CHAIN_ID_INDEX ]
379+ start_residue = int (
380+ line [
381+ Protein .PDB_START_RESIDUE_INDICES [
382+ 0
383+ ] : Protein .PDB_START_RESIDUE_INDICES [1 ]
384+ ].strip ()
385+ )
386+ end_residue = int (
387+ line [
388+ Protein .PDB_END_RESIDUE_INDICES [
389+ 0
390+ ] : Protein .PDB_END_RESIDUE_INDICES [1 ]
391+ ].strip ()
392+ )
374393
375394 if chain_id in helices :
376395 helices [chain_id ].append ((start_residue , end_residue ))
0 commit comments