-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
[feat] expose bfactors in protein_to_pyg function #388
Conversation
1d4b17a
to
8fd1eb2
Compare
graphein/protein/tensor/io.py
Outdated
@@ -254,6 +261,10 @@ def protein_to_pyg( | |||
) | |||
if store_het: | |||
out.hetatms = [het_coords] | |||
|
|||
if store_bfactor: | |||
out.bfactor = torch.tensor(df["b_factor"].values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think torch.from_numpy
might be a little better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
62c8719
to
b4bf164
Compare
graphein/protein/tensor/io.py
Outdated
@@ -254,6 +261,10 @@ def protein_to_pyg( | |||
) | |||
if store_het: | |||
out.hetatms = [het_coords] | |||
|
|||
if store_bfactor: | |||
out.bfactor = torch.from_numpy(df["b_factor"].values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be of shape num_atoms x 1
right? I expect this would break batching as all other tensors are of shape n_res x X
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, solved this via a group by now that averages b factors on a per residue basis, consistent with the plddt information in the predicted datasets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran more tests now and everything seems to work in a backward compatible way, lmk if there is anything else that needs to happen before merging @a-r-j
6bfb02e
to
8f0a730
Compare
for more information, see https://pre-commit.ci
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Reference Issues/PRs
What does this implement/fix? Explain your changes
Bfactors are present in df from biopandas, but cannot be saved to pyg object. Now this option is enabled.
What testing did you do to verify the changes in this PR?
Pull Request Checklist
./CHANGELOG.md
file (if applicable)./graphein/tests/*
directories (if applicable)./notebooks/
(if applicable)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
)black .
andisort .