Fix backbone dihedral feature calculation#11
Open
Zhangke123jimu wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Thank you for releasing the MapDiff implementation. While studying and reproducing the model, I noticed several issues in the backbone dihedral feature calculation in get_node_features() in dataloader/cath_dataset.py.
This PR proposes a small geometry-correctness fix for the node dihedral features. The main changes are:
1.Convert dihedral angles from degrees to radians before applying np.sin and np.cos.$C_{i-1}-N_i-CA_i-C_i$ .$C_i-N_{i+1}$ distance.
2.Correct the definition of the phi angle for residue i to
3.Minor: Avoid computing peptide-bond-related dihedral features across likely chain breaks or non-connected adjacent residues by checking the
Motivation
In the original implementation, the dihedral angles returned by dihedral() appear to be measured in degrees, but they are directly passed to np.sin and np.cos. Since these functions expect radians, this may result in a distorted geometric encoding.
In addition, the original phi-angle calculation uses:
dihedral(c_coords[i], n_coords[i], c_alpha_coords[i], n_coords[i + 1])
whereas the standard backbone phi angle for residue i is defined by:$C_{i-1}-N_i-CA_i-C_i$ .
Finally, dihedral features involving adjacent residues are meaningful only when the corresponding residues are connected by a peptide bond. To make the feature calculation more robust to chain breaks or missing residues, this PR checks peptide-bond connectivity using the$C_i-N_{i+1}$ distance. Undefined torsions at termini or chain breaks are encoded as (sin, cos) = (0, 0).
Validation
I compared the original implementation and the geometry-fixed version under the same setting:
Dataset: CATH 4.2
Prior: marginal prior
Hardware: 2 × A100 GPUs
Per-GPU batch size: 4
Other settings: unchanged from the original configuration
Results:
The improvement is small, so I would not interpret this as a major performance-oriented modification. The main motivation of this PR is to make the geometric node features biologically more consistent and avoid potentially misleading dihedral encodings.