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

hotfix greater than/less than operations in pdb_manager #408

Merged
merged 7 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ looseversion
matplotlib>=3.4.3
multipledispatch
networkx
numpy
numpy<2
pandas
plotly
pydantic
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#### Bugfixes

* Hotfix greater than/less than operations in PDBManager oligmer selection to include equality. [#408](https://github.com/a-r-j/graphein/pull/408).
* Fixes progress bar for `download_pdb_multiprocessing`. [#394](https://github.com/a-r-j/graphein/pull/394)
* Add support for DSSP >4. Backwards compatibility is still supported. [#355](https://github.com/a-r-j/graphein/pull/355). Fixes [#353](https://github.com/a-r-j/graphein/issues/353).
* Fixes bug where RSA features are missing from nodes with insertion codes. [#355](https://github.com/a-r-j/graphein/pull/355). Fixes [#354](https://github.com/a-r-j/graphein/issues/353).
Expand Down
20 changes: 12 additions & 8 deletions graphein/ml/datasets/pdb_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def __init__(
).name

self.list_columns = ["ligands"]
self.labels = labels

# Data
self.download_metadata()
Expand Down Expand Up @@ -166,10 +165,9 @@ def download_metadata(self):
self._download_entry_metadata()
self._download_exp_type()
self._download_pdb_availability()
if self.labels:
self._download_pdb_chain_cath_uniprot_map()
self._download_cath_id_cath_code_map()
self._download_pdb_chain_ec_number_map()
self._download_pdb_chain_cath_uniprot_map()
self._download_cath_id_cath_code_map()
self._download_pdb_chain_ec_number_map()

def get_unavailable_pdb_files(
self, splits: Optional[List[str]] = None
Expand Down Expand Up @@ -645,12 +643,15 @@ def _parse_cath_code(self) -> Dict[str, str]:
with gzip.open(
self.root_dir / self.cath_id_cath_code_filename, "rt"
) as f:
print(f)
for line in f:
print(line)
try:
cath_id, cath_version, cath_code, cath_segment = (
line.strip().split()
)
cath_mapping[cath_id] = cath_code
print(cath_id, cath_code)
except ValueError:
continue
return cath_mapping
Expand Down Expand Up @@ -1085,7 +1086,10 @@ def oligomeric(
update: bool = False,
) -> pd.DataFrame:
"""Select molecules with a given oligmeric length.
I.e. ``df.n_chains ==/</> oligomer``
I.e. ``df.n_chains ==/ =< / >= oligomer``

N.b. the `comparison` arguments for `"greater"` and `"less"` are
`>=` and `=<` respectively.

:param length: Oligomeric length of molecule, defaults to ``1``.
:type length: int
Expand All @@ -1106,9 +1110,9 @@ def oligomeric(
if comparison == "equal":
df = splits_df.loc[splits_df.n_chains == oligomer]
elif comparison == "less":
df = splits_df.loc[splits_df.n_chains < oligomer]
df = splits_df.loc[splits_df.n_chains <= oligomer]
elif comparison == "greater":
df = splits_df.loc[splits_df.n_chains > oligomer]
df = splits_df.loc[splits_df.n_chains >= oligomer]
else:
raise ValueError(
"Comparison must be one of 'equal', 'less', or 'greater'."
Expand Down
6 changes: 4 additions & 2 deletions tests/protein/tensor/test_angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_torsion_to_rad():

delta = ((delta + 2 * np.pi) / np.pi) % 2
np.testing.assert_allclose(
delta, torch.zeros_like(delta), atol=1e-4, rtol=1e-4
delta, torch.zeros_like(delta), atol=1e-3, rtol=1e-3
)


Expand Down Expand Up @@ -126,7 +126,9 @@ def test_dihedrals_to_rad():
delta[delta.nonzero()] = torch.abs(delta[torch.nonzero(delta)] - 2 * np.pi)

delta = ((delta + 2 * np.pi) / np.pi) % 2
np.testing.assert_allclose(delta, torch.zeros_like(delta), atol=1e-5)
np.testing.assert_allclose(
delta, torch.zeros_like(delta), atol=1e-4, rtol=1e-4
)


@pytest.mark.skipif(not TORCH_AVAIL, reason="PyTorch not available")
Expand Down
Loading