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

swap ca cb channels #93

Merged
merged 5 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "aposteriori"
version = "2.2.0"
version = "2.3.0"
requires-python = ">= 3.8"
readme = "README.md"
dependencies = [
Expand All @@ -16,4 +16,4 @@ dependencies = [
]

[project.scripts]
make-frame-dataset = "aposteriori.data_prep.cli:cli"
make-frame-dataset = "aposteriori.data_prep.cli:cli"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="aposteriori",
version="2.2.0",
version="2.3.0",
author="Wells Wood Research Group",
author_email="[email protected]",
description="A library for the voxelization of protein structures for protein design.",
Expand Down
25 changes: 13 additions & 12 deletions src/aposteriori/data_prep/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@
@click.option(
"-ae",
"--atom_encoder",
type=click.Choice(["CNO", "CNOCB", "CNOCBCA", "CNOCBCAQ", "CNOCBCAP"]),
type=click.Choice(["CNO", "CNOCB", "CNOCACB", "CNOCACBQ", "CNOCACBP"]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For backwards compatibility, can we add both?

type=click.Choice(["CNO", "CNOCB", "CNOCACB", "CNOCACBQ", "CNOCACBP", "CNOCBCA", "CNOCBCAQ", "CNOCBCAP" ]),

default="CNO",
required=True,
help=(
"Encodes atoms in different channels, depending on atom types. Default is CNO, other options are ´CNOCB´ and `CNOCBCA` to encode the Cb or Cb and Ca in different channels respectively."
"Encodes atoms in different channels, depending on atom types. Default is CNO, other options are ´CNOCB´ and `CNOCACB` to encode the Cb or Cb and Ca in different channels respectively. "
"Charged and polar versions can be used with CNOCACBQ and CNOCACBP respectively."
),
)
@click.option(
Expand Down Expand Up @@ -267,20 +268,20 @@ def cli(
codec = Codec.CNO()
elif atom_encoder == "CNOCB":
codec = Codec.CNOCB()
elif atom_encoder == "CNOCBCA":
codec = Codec.CNOCBCA()
elif atom_encoder == "CNOCBCAQ":
codec = Codec.CNOCBCAQ()
elif atom_encoder == "CNOCBCAP":
codec = Codec.CNOCBCAP()
elif atom_encoder == "CNOCACB":
codec = Codec.CNOCACB()
elif atom_encoder == "CNOCACBQ":
codec = Codec.CNOCACBQ()
elif atom_encoder == "CNOCACBP":
codec = Codec.CNOCACBP()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here maybe let's add both

else:
assert atom_encoder in [
"CNO",
"CNOCB",
"CNOCBCA",
"CNOCBCAQ",
"CNOCBCAP",
], f"Expected encoder to be CNO, CNOCB, CNOCBCA, CNOCBCAQ, CNOCBCAP, but got {atom_encoder}"
"CNOCACB",
"CNOCACBQ",
"CNOCACBP",
], f"Expected encoder to be CNO, CNOCB, CNOCACB, CNOCACBQ, CNOCACBP, but got {atom_encoder}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again here.

I would say let's raise a warning if you are using the old encoders saying they are deprecated and will be removed in future versions.


make_frame_dataset(
structure_files=structure_files,
Expand Down
18 changes: 9 additions & 9 deletions src/aposteriori/data_prep/create_frame_data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ def CNOCB(cls):
return cls(["C", "N", "O", "CB"])

@classmethod
def CNOCBCA(cls):
return cls(["C", "N", "O", "CB", "CA"])
def CNOCACB(cls):
return cls(["C", "N", "O", "CA", "CB"])

@classmethod
def CNOCBCAQ(cls):
return cls(["C", "N", "O", "CB", "CA", "Q"])
def CNOCACBQ(cls):
return cls(["C", "N", "O", "CA", "CB", "Q"])

@classmethod
def CNOCBCAP(cls):
return cls(["C", "N", "O", "CB", "CA", "P"])
def CNOCACBP(cls):
return cls(["C", "N", "O", "CA", "CB", "P"])

def encode_atom(self, atom_label: str) -> np.ndarray:
"""
Expand Down Expand Up @@ -726,13 +726,13 @@ def create_residue_frame(
# Check whether central atom is C:
if "CA" in codec.atomic_labels:
if voxels_as_gaussian:
np.testing.assert_array_less(frame[centre, centre, centre][4], 1)
np.testing.assert_array_less(frame[centre, centre, centre][3], 1)
assert (
0 < frame[centre, centre, centre][4] <= 1
0 < frame[centre, centre, centre][3] <= 1
), f"The central atom value should be between 0 and 1 but was {frame[centre, centre, centre][4]}"
else:
assert (
frame[centre, centre, centre][4] == 1
frame[centre, centre, centre][3] == 1
), f"The central atom should be Carbon, but it is {frame[centre, centre, centre]}."
else:
if voxels_as_gaussian:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_create_frame_data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def test_make_frame_dataset_as_gaussian_cnocacbq():
test_file = TEST_DATA_DIR / "1ubq.pdb"
frame_edge_length = 18.0
voxels_per_side = 31
codec = cfds.Codec.CNOCBCAQ()
codec = cfds.Codec.CNOCACBQ()
ampal_1ubq = ampal.load_pdb(str(test_file))
ampal_1ubq2 = ampal.load_pdb(str(test_file))

Expand Down Expand Up @@ -437,7 +437,7 @@ def test_make_frame_dataset_as_gaussian_cnocacbp():
test_file = TEST_DATA_DIR / "1ubq.pdb"
frame_edge_length = 18.0
voxels_per_side = 31
codec = cfds.Codec.CNOCBCAP()
codec = cfds.Codec.CNOCACBP()

ampal_1ubq = ampal.load_pdb(str(test_file))
ampal_1ubq2 = ampal.load_pdb(str(test_file))
Expand Down Expand Up @@ -544,7 +544,7 @@ def test_cb_atom_filter(residue_number: int):
def test_add_gaussian_at_position():
main_matrix = np.zeros((5, 5, 5, 5), dtype=np.float)
modifiers_triple = (0, 0, 0)
codec = cfds.Codec.CNOCBCA()
codec = cfds.Codec.CNOCACB()

secondary_matrix, atom_idx = codec.encode_gaussian_atom("C", modifiers_triple)
atom_coord = (1, 1, 1)
Expand Down
Loading