Skip to content

Commit

Permalink
Fix for newer versions of Pandas
Browse files Browse the repository at this point in the history
  • Loading branch information
samgelman committed Jan 5, 2024
1 parent 92d26ba commit 0aab9f4
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions code/gen_structure_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,14 @@ def cbeta_distance_matrix(pdb_fn, start=0, end=None):
ppdb = PandasPdb().read_pdb(pdb_fn)

# group by residue number
grouped = ppdb.df["ATOM"].groupby(["residue_number"])
grouped = ppdb.df["ATOM"].groupby("residue_number")

# a list of coords for the cbeta or calpha of each residue
coords = []

# loop through each residue and find the coordinates of cbeta
for i, (residue_number, values) in enumerate(grouped):

# later versions of biopandas are returning the residue_number
# as a tuple, so convert it to a single integer
if isinstance(residue_number, tuple) and len(residue_number) == 1:
residue_number = residue_number[0]

# skip residues not in the range
end_index = (len(grouped) if end is None else end)
if i not in range(start, end_index):
Expand Down

0 comments on commit 0aab9f4

Please sign in to comment.