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

Correct the coordinates computation for small residue graohs, and when granularity: centroids #220

Merged
merged 5 commits into from Oct 23, 2022

Conversation

manonreau
Copy link
Contributor

@manonreau manonreau commented Oct 18, 2022

Reference Issues/PRs

Fixes #219

What does this implement/fix? Explain your changes

  • Add conditions to graphein/protein/edges/distance.py not to compute distances and angles on empty dataframes
  • Ensure the good calculation of centroids coordinates by correcting the selection (atoms.groupby("residue_number") -> atoms.groupby(["residue_number","chain_id","residue_name"]))

What testing did you do to verify the changes in this PR?

from graphein.protein.graphs import construct_graph
from graphein.protein.config import ProteinGraphConfig
from graphein.protein.edges.distance import (add_peptide_bonds,
                                             add_hydrogen_bond_interactions,
                                             add_disulfide_interactions,
                                             add_ionic_interactions,
                                             add_aromatic_interactions,
                                             add_aromatic_sulphur_interactions,
                                             add_cation_pi_interactions,
                                             add_distance_threshold
                                            )


new_edge_funcs = {"edge_construction_functions": [add_peptide_bonds,
                                                  add_aromatic_interactions,
                                                  add_hydrogen_bond_interactions,
                                                  add_disulfide_interactions,
                                                  add_ionic_interactions,
                                                  add_aromatic_sulphur_interactions,
                                                  add_cation_pi_interactions,
                                                  partial(add_distance_threshold, long_interaction_threshold=2, threshold=20.)]}

params_to_change = {"granularity": "centroids"}
config = ProteinGraphConfig(**new_edge_funcs, **params_to_change)

pdb_name = 'xxxx.pdb'
g = construct_graph(config=config, pdb_path=pdb_name)
g.coords

Pull Request Checklist

  • Added a note about the modification or contribution to the ./CHANGELOG.md file (if applicable)
  • Added appropriate unit test functions in the ./graphein/tests/* directories (if applicable)
  • Modify documentation in the corresponding Jupyter Notebook under ./notebooks/ (if applicable)
  • Ran python -m py.test tests/ and make sure that all unit tests pass (for small modifications, it might be sufficient to only run the specific test file, e.g., python -m py.test tests/protein/test_graphs.py)
  • Checked for style issues by running black . and isort .

@sonarcloud
Copy link

sonarcloud bot commented Oct 23, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
12.5% 12.5% Duplication

@codecov-commenter
Copy link

Codecov Report

Base: 40.27% // Head: 47.76% // Increases project coverage by +7.49% 🎉

Coverage data is based on head (3eb36cf) compared to base (8123f42).
Patch coverage: 51.86% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #220      +/-   ##
==========================================
+ Coverage   40.27%   47.76%   +7.49%     
==========================================
  Files          48       85      +37     
  Lines        2811     5435    +2624     
==========================================
+ Hits         1132     2596    +1464     
- Misses       1679     2839    +1160     
Impacted Files Coverage Δ
graphein/grn/parse_trrust.py 37.77% <ø> (ø)
graphein/ml/diffusion.py 0.00% <0.00%> (ø)
graphein/ppi/edges.py 100.00% <ø> (ø)
graphein/ppi/graph_metadata.py 0.00% <ø> (ø)
graphein/ppi/graphs.py 54.34% <ø> (ø)
graphein/ppi/parse_biogrid.py 75.00% <ø> (ø)
graphein/ppi/visualisation.py 0.00% <0.00%> (ø)
graphein/protein/analysis.py 0.00% <0.00%> (ø)
graphein/protein/edges/intramolecular.py 22.68% <0.00%> (ø)
graphein/protein/features/sequence/utils.py 28.00% <0.00%> (+3.00%) ⬆️
... and 77 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@a-r-j a-r-j merged commit 71d8657 into a-r-j:master Oct 23, 2022
@a-r-j a-r-j mentioned this pull request Oct 23, 2022
5 tasks
@helder-ribeiro
Copy link

Hi all! Just a comment regarding the updates in the atoms.groupby called inside the centroid calculations. It seems the input list starts with residue_number which makes the centroid data.frame being ordered by the residue_number. In the case we are working with two protein chains, the rows of this data.frame will be different from the G.graph["pdb_df"] called, for instance, inside the add_distance_threshold. Thus, the edges are created between wrong nodes. It seems that just changing the order of the input list for atoms.groupby (starting for instance by chaid_id) could correct this issue, but not sure about downstream impacts of this modification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NaN coordinates when granularity: centroids and on small residue graphs
4 participants