Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify graphs.py to handle insertions when {'insertions': True} #223

Merged
merged 12 commits into from
Dec 8, 2022
Prev Previous commit
Next Next commit
[pre-commit.ci] auto fixes from pre-commit.com hooks
  • Loading branch information
pre-commit-ci[bot] committed Dec 7, 2022
commit cec18d6a660cc90f2160d66ab5c1c44c2a6cba1c
1 change: 0 additions & 1 deletion graphein/protein/edges/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ def add_disulfide_interactions(
)



def add_hydrogen_bond_interactions(
G: nx.Graph, rgroup_df: Optional[pd.DataFrame] = None
):
Expand Down
4 changes: 2 additions & 2 deletions graphein/protein/features/nodes/amino_acid.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def hydrogen_bond_donor(
try:
features = HYDROGEN_BOND_DONORS[res][atom]
except KeyError:
try: # Handle insertions
try: # Handle insertions
atom = node_id[-2]
features = HYDROGEN_BOND_DONORS[res][atom]
except KeyError:
Expand Down Expand Up @@ -254,7 +254,7 @@ def hydrogen_bond_acceptor(
try:
features = HYDROGEN_BOND_ACCEPTORS[res][atom]
except KeyError:
try: # Handle insertions
try: # Handle insertions
atom = node_id[-2]
features = HYDROGEN_BOND_ACCEPTORS[res][atom]
except KeyError:
Expand Down
8 changes: 6 additions & 2 deletions graphein/protein/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ def sort_dataframe(df: pd.DataFrame) -> pd.DataFrame:
:return: Sorted protein dataframe.
:rtype: pd.DataFrame
"""
return df.sort_values(by=["chain_id", "residue_number", "atom_number", "insertion"])
return df.sort_values(
by=["chain_id", "residue_number", "atom_number", "insertion"]
)


def assign_node_id_to_dataframe(
Expand Down Expand Up @@ -584,7 +586,9 @@ def calculate_centroid_positions(
:rtype: pd.DataFrame
"""
centroids = (
atoms.groupby(["residue_number","chain_id","residue_name", "insertion"])
atoms.groupby(
["residue_number", "chain_id", "residue_name", "insertion"]
)
.mean()[["x_coord", "y_coord", "z_coord"]]
.reset_index()
)
Expand Down