Skip to content

Commit 65b2c11

Browse files
committed
identify and resolve heteroatom issue in distance network
1 parent a00cb04 commit 65b2c11

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

procaliper/_protein.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,13 @@ def get_biopython_residues(self) -> list[Residue]:
299299
raise ValueError("PDB location not set; use `fetch_pdb` first")
300300
p = PDBParser(QUIET=True)
301301
structure = p.get_structure("", self.pdb_location_absolute)
302-
reslist = [res for model in structure for chain in model for res in chain]
302+
reslist = [
303+
res
304+
for model in structure
305+
for chain in model
306+
for res in chain
307+
if res.get_id()[0] == " " # excludes heteroatoms and water
308+
]
303309
return reslist
304310

305311
def get_confidence(self) -> list[float]:

procaliper/network.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ def regulatory_distance_network(protein: Protein) -> nx.Graph:
9696
all_regs = {**ptms, **binding, **active, **regions, **domains}
9797

9898
# residues, excluding heteroatoms and water
99-
protein_residues = [
100-
res for res in protein.get_biopython_residues() if res.get_id()[0] == " "
101-
]
99+
protein_residues = protein.get_biopython_residues()
102100

103101
all_regs_residues = {}
104102
for k, v in all_regs.items():

procaliper/protein_structure/distance.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,13 @@ def distance_matrix(
9191
npt.NDArray[np.float64]: distance matrix with shape nxn where n is the
9292
number of residues in the structure.
9393
"""
94-
residues = [res for model in structure for chain in model for res in chain]
94+
residues = [
95+
res
96+
for model in structure
97+
for chain in model
98+
for res in chain
99+
if res.get_id()[0] == " "
100+
]
95101
residues = list(enumerate(residues))
96102
adj = np.ones((len(residues), len(residues))) * np.inf
97103

tests/test_network.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from procaliper import Protein
2-
from procaliper.network import regulatory_distance_network
2+
from procaliper.network import distance_network, regulatory_distance_network
33

44
INCOMPLETE_PDB_PATH = "tests/test_data/1nhz.pdb"
55
INCOMPLETE_PDB_UNIPROT_ID = "P04150"
@@ -31,5 +31,5 @@ def test_pdb_with_ligand() -> None:
3131
oxu = Protein.from_uniprot_id(LIGAND_PDB_UNIPROT_ID)
3232
oxu.register_local_pdb(path_to_pdb_file=LIGAND_PDB_PATH)
3333

34-
reg = regulatory_distance_network(oxu)
34+
reg = distance_network(oxu)
3535
assert reg is not None

0 commit comments

Comments
 (0)