Skip to content

Commit

Permalink
Merge pull request #64 from wolberlab/update-black-formatting
Browse files Browse the repository at this point in the history
Update package w.r.t. new black & pandas versions
  • Loading branch information
dominiquesydow authored Apr 10, 2023
2 parents 6cb9e1d + 22cf274 commit 8a64fd7
Show file tree
Hide file tree
Showing 21 changed files with 3 additions and 59 deletions.
2 changes: 1 addition & 1 deletion dynophores/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _update_paths_in_notebook(notebook_path, dyno_path, pdb_path, dcd_path=None)
filedata = f.read()

# Replace the target string
for (search_str, replace_str) in search_replace_tuples:
for search_str, replace_str in search_replace_tuples:
filedata = filedata.replace(search_str, replace_str)

# Write the file out again
Expand Down
1 change: 0 additions & 1 deletion dynophores/core/chemicalfeaturecloud3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class ChemicalFeatureCloud3D:
"""

def __init__(self, center, points, **kwargs):

self.center = center
self.points = [
point
Expand Down
1 change: 0 additions & 1 deletion dynophores/core/chemicalfeaturecloud3dpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class ChemicalFeatureCloud3DPoint:
"""

def __init__(self, x, y, z, frame_ix, weight, **kwargs):

self.x = x
self.y = y
self.z = z
Expand Down
2 changes: 0 additions & 2 deletions dynophores/core/dynophore.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def __init__(
superfeatures,
**kwargs,
):

self.id = id
self.ligand = ligand if isinstance(ligand, Ligand) else Ligand(**ligand)
self.superfeatures = {
Expand Down Expand Up @@ -66,7 +65,6 @@ def from_dir(cls, dynophore_path):
dynophore_path = Path(dynophore_path)

if dynophore_path.is_dir():

# Set JSON path
json_path = list(dynophore_path.glob("*.json"))
if len(json_path) == 1:
Expand Down
1 change: 0 additions & 1 deletion dynophores/core/envpartner.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class EnvPartner:
def __init__(
self, id, residue_name, residue_number, chain, atom_numbers, occurrences, distances
):

if len(occurrences) != len(distances):
raise ValueError("Occurrences and distances must be of same length.")

Expand Down
1 change: 0 additions & 1 deletion dynophores/core/ligand.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def __init__(
atom_serials,
**kwargs,
):

self.name = name
self.smiles = smiles
self.mdl_mol_buffer = mdl_mol_buffer
Expand Down
4 changes: 1 addition & 3 deletions dynophores/core/superfeature.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class SuperFeature:
"""

def __init__(self, id, feature_type, atom_numbers, occurrences, envpartners, color, cloud):

self.id = id
self.feature_type = feature_type
self.atom_numbers = atom_numbers
Expand Down Expand Up @@ -185,7 +184,7 @@ def _count(self, property_envpartners_occurrences):
)
envpartners_count = property_envpartners_occurrences.sum()

return superfeature_count.append(envpartners_count)
return pd.concat([superfeature_count, envpartners_count])

@property
def frequency(self):
Expand Down Expand Up @@ -279,7 +278,6 @@ def _data_collapsed(self):
# For each unique residue ID,
# we want to aggregate data for all environmental partners that belong to the same residue
for residue_id in residue_ids:

# Get all environmental partner IDs that belong to this residue
ids_to_be_collapsed = [_id for _id in ids if _id.startswith(residue_id)]

Expand Down
1 change: 0 additions & 1 deletion dynophores/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def _pml_to_dict(pml_path):

feature_clouds = dynophore3d_xml.findall("featureCloud")
for feature_cloud in feature_clouds:

# Superfeature ID
superfeature_feature_name = feature_cloud.get("name")
superfeature_atom_numbers = feature_cloud.get("involvedAtomSerials")
Expand Down
6 changes: 0 additions & 6 deletions dynophores/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,34 @@

@pytest.fixture(scope="module")
def dynophore():

dynophore = Dynophore.from_dir(PATH_TEST_DATA / "out")
return dynophore


@pytest.fixture(scope="module")
def superfeature(dynophore):

superfeature = dynophore.superfeatures["H[4615,4623,4622,4613,4621,4614]"]
return superfeature


@pytest.fixture(scope="module")
def chemicalfeaturecloud3d(superfeature):

cloud = superfeature.cloud
return cloud


@pytest.fixture(scope="module")
def chemicalfeaturecloud3dpoint(superfeature):

point = next(iter(superfeature.cloud.points))
return point


@pytest.fixture(scope="module")
def envpartner(superfeature):

envpartner = superfeature.envpartners["ILE-10-A[169,171,172]"]
return envpartner


@pytest.fixture(scope="module")
def ligand(dynophore):

return dynophore.ligand
1 change: 0 additions & 1 deletion dynophores/tests/core/test_chemicalfeaturecloud3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class TestsChemicalFeatureCloud3D:
"""

def test_init(self):

dynophore_dict = parsers._json_pml_to_dict(
PATH_TEST_DATA / "out/1KE7_dynophore.json",
PATH_TEST_DATA / "out/1KE7_dynophore.pml",
Expand Down
1 change: 0 additions & 1 deletion dynophores/tests/core/test_chemicalfeaturecloud3dpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class TestsChemicalFeatureCloud3DPoint:
"""

def test_init(self):

dynophore_dict = parsers._json_pml_to_dict(
PATH_TEST_DATA / "out/1KE7_dynophore.json",
PATH_TEST_DATA / "out/1KE7_dynophore.pml",
Expand Down
12 changes: 0 additions & 12 deletions dynophores/tests/core/test_dynophore.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class TestsDynophore:

@pytest.mark.parametrize("id", ["dynophore_1KE7"])
def test_attributes(self, dynophore, id):

dynophore_dict = parsers._json_pml_to_dict(
PATH_TEST_DATA / "out/1KE7_dynophore.json",
PATH_TEST_DATA / "out/1KE7_dynophore.pml",
Expand All @@ -48,12 +47,10 @@ def test_attributes(self, dynophore, id):

@pytest.mark.parametrize("filepath", [PATH_TEST_DATA / "out"])
def test_from_dir(self, filepath):

dynophore = Dynophore.from_dir(filepath)
assert isinstance(dynophore, Dynophore)

def test_clouds_and_cloud_by_superfeature(self, dynophore):

# Property `cloud`
assert isinstance(dynophore.clouds, dict)
assert list(dynophore.clouds.keys()) == list(dynophore.superfeatures.keys())
Expand Down Expand Up @@ -88,7 +85,6 @@ def test_clouds_and_cloud_by_superfeature(self, dynophore):
],
)
def test_superfeatures_occurrences(self, dynophore, column_names, counts_sum):

data = dynophore.superfeatures_occurrences
assert data.columns.to_list() == column_names
assert data.index.to_list() == list(range(0, dynophore.n_frames))
Expand All @@ -115,7 +111,6 @@ def test_superfeatures_occurrences(self, dynophore, column_names, counts_sum):
def test_envpartners_occurrences_and_envpartners_occurrences_by_superfeature(
self, dynophore, counts_sum_dict
):

# Test `envpartners_occurrences`
assert sorted(list(dynophore.envpartners_occurrences.keys())) == sorted(
list(counts_sum_dict.keys())
Expand Down Expand Up @@ -150,7 +145,6 @@ def test_envpartners_occurrences_and_envpartners_occurrences_by_superfeature(
],
)
def test_envpartners_distances(self, dynophore, distances_sum_dict):

assert sorted(list(dynophore.envpartners_distances.keys())) == sorted(
list(distances_sum_dict.keys())
)
Expand All @@ -161,12 +155,10 @@ def test_envpartners_distances(self, dynophore, distances_sum_dict):

@pytest.mark.parametrize("n_superfeatures", [10])
def test_n_superfeatures(self, dynophore, n_superfeatures):

assert dynophore.n_superfeatures == n_superfeatures

@pytest.mark.parametrize("n_frames", [1002])
def test_n_frames(self, dynophore, n_frames):

assert dynophore.n_frames == n_frames

@pytest.mark.parametrize(
Expand Down Expand Up @@ -218,7 +210,6 @@ def test_n_frames(self, dynophore, n_frames):
def test_count_frequency(
self, dynophore, count_sum, frequency_sum, superfeature_ids, envpartner_names
):

# TODO remove this when fixed in DynophoreApp json export
envpartner_names = [i.replace("_", "-") for i in envpartner_names]

Expand All @@ -240,22 +231,19 @@ def test_count_frequency(
def test_raise_keyerror_if_invalid_superfeature_id(
self, dynophore, valid_superfeature, superfeature_id
):

if valid_superfeature:
assert dynophore._raise_keyerror_if_invalid_superfeature_id(superfeature_id) is None
else:
with pytest.raises(KeyError):
dynophore._raise_keyerror_if_invalid_superfeature_id(superfeature_id)

def test_superfeatures_atom_serials(self, dynophore):

atom_serials = dynophore.superfeatures_atom_serials
assert isinstance(atom_serials, dict)
assert list(atom_serials) == list(dynophore.superfeatures)
assert isinstance(next(iter(atom_serials.values()))[0], int)

def test_superfeatures_colors(self, dynophore):

colors = dynophore.superfeatures_colors
assert isinstance(colors, dict)
assert list(colors) == list(dynophore.superfeatures)
Expand Down
2 changes: 0 additions & 2 deletions dynophores/tests/core/test_envpartner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class TestsEnvPartner:
"""

def test_init(self):

dynophore_dict = parsers._json_pml_to_dict(
PATH_TEST_DATA / "out/1KE7_dynophore.json",
PATH_TEST_DATA / "out/1KE7_dynophore.pml",
Expand Down Expand Up @@ -64,7 +63,6 @@ def test_init(self):
],
)
def test_init_raises(self, envpartner_dict):

with pytest.raises(ValueError):
EnvPartner(**envpartner_dict)

Expand Down
1 change: 0 additions & 1 deletion dynophores/tests/core/test_ligand.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class TestsLigand:
"""

def test_init(self):

dynophore_dict = parsers._json_pml_to_dict(
PATH_TEST_DATA / "out/1KE7_dynophore.json",
PATH_TEST_DATA / "out/1KE7_dynophore.pml",
Expand Down
1 change: 0 additions & 1 deletion dynophores/tests/core/test_superfeature.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class TestsSuperFeature:
"""

def test_init(self):

dynophore_dict = parsers._json_pml_to_dict(
PATH_TEST_DATA / "out/1KE7_dynophore.json",
PATH_TEST_DATA / "out/1KE7_dynophore.pml",
Expand Down
1 change: 0 additions & 1 deletion dynophores/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,5 @@ def test_update_paths_in_notebook_raises(notebook_path, dyno_path, pdb_path, dcd
],
)
def test_open_notebook_raises(notebook):

with pytest.raises(RuntimeError):
cli._open_notebook(notebook)
10 changes: 0 additions & 10 deletions dynophores/tests/viz/test_plot_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
],
)
def test_superfeatures_vs_envpartners(dynophore, superfeature_ids, annotate_heatmap):

fig, ax = plot.static.superfeatures_vs_envpartners(
dynophore, superfeature_ids, annotate_heatmap
)
Expand All @@ -34,7 +33,6 @@ def test_superfeatures_vs_envpartners(dynophore, superfeature_ids, annotate_heat

@pytest.mark.parametrize("superfeature_ids", ["xxx"])
def test_superfeatures_vs_envpartners_raises(dynophore, superfeature_ids):

with pytest.raises(KeyError):
plot.static.superfeatures_vs_envpartners(dynophore, superfeature_ids)

Expand All @@ -58,7 +56,6 @@ def test_superfeatures_vs_envpartners_raises(dynophore, superfeature_ids):
def test_superfeatures_occurrences(
dynophore, superfeature_ids, color_by_feature_type, frames_range, frames_step_size
):

fig, ax = plot.static.superfeatures_occurrences(
dynophore, superfeature_ids, color_by_feature_type, frames_range, frames_step_size
)
Expand All @@ -69,7 +66,6 @@ def test_superfeatures_occurrences(

@pytest.mark.parametrize("superfeature_ids", ["xxx"])
def test_superfeatures_occurrences_raises(dynophore, superfeature_ids):

with pytest.raises(KeyError):
plot.static.superfeatures_occurrences(dynophore, superfeature_ids)

Expand Down Expand Up @@ -105,7 +101,6 @@ def test_superfeatures_occurrences_raises(dynophore, superfeature_ids):
def test_envpartners_occurrences(
dynophore, superfeature_ids, frames_range, frames_step_size, occurrence_min, collapse_residues
):

fig, axes = plot.static.envpartners_occurrences(
dynophore,
superfeature_ids,
Expand All @@ -125,7 +120,6 @@ def test_envpartners_occurrences(

@pytest.mark.parametrize("superfeature_id", ["xxx", ["AR[4605,4607,4603,4606,4604]", "xxx"]])
def test_envpartners_occurrences_raises(dynophore, superfeature_id):

with pytest.raises(KeyError):
plot.static.envpartners_occurrences(dynophore, superfeature_id)

Expand All @@ -139,7 +133,6 @@ def test_envpartners_occurrences_raises(dynophore, superfeature_id):
],
)
def test_envpartners_distances(dynophore, superfeature_ids, kind):

fig, axes = plot.static.envpartners_distances(dynophore, superfeature_ids, kind)
assert isinstance(fig, matplotlib.figure.Figure)
if isinstance(superfeature_ids, str):
Expand All @@ -154,7 +147,6 @@ def test_envpartners_distances(dynophore, superfeature_ids, kind):
"superfeature_id, kind", [("xxx", "line"), ("AR[4605,4607,4603,4606,4604]", "xxx")]
)
def test_envpartner_distances_raises(dynophore, superfeature_id, kind):

with pytest.raises(KeyError):
plot.static.envpartners_distances(dynophore, superfeature_id, kind)

Expand All @@ -167,7 +159,6 @@ def test_envpartner_distances_raises(dynophore, superfeature_id, kind):
],
)
def test_envpartners_all_in_one(dynophore, superfeature_id, frames_range, frames_step_size):

fig, axes = plot.static.envpartners_all_in_one(
dynophore, superfeature_id, frames_range, frames_step_size
)
Expand All @@ -179,6 +170,5 @@ def test_envpartners_all_in_one(dynophore, superfeature_id, frames_range, frames

@pytest.mark.parametrize("superfeature_id", ["xxx"])
def test_envpartners_all_in_one_raises(dynophore, superfeature_id):

with pytest.raises(KeyError):
plot.static.envpartners_all_in_one(dynophore, superfeature_id)
2 changes: 0 additions & 2 deletions dynophores/tests/viz/test_view2d_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ def test_show(dynophore, show_superfeatures, show_pdb_serial_numbers):

@pytest.mark.parametrize("show_pdb_serial_numbers", [False, True])
def test_view2d(self, ligand, show_pdb_serial_numbers):

mol = ligand.view2d(show_pdb_serial_numbers)
assert isinstance(mol, Chem.rdchem.Mol)

@pytest.mark.parametrize("show_pdb_serial_numbers", [False, True])
def test_view2d_superfeatures(self, ligand, show_pdb_serial_numbers):

img = ligand.view2d_superfeatures(show_pdb_serial_numbers)
assert isinstance(img, Image)
1 change: 0 additions & 1 deletion dynophores/tests/viz/test_view3d_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def test_show(
def test_show_raises(
dynophore, pdb_path, dcd_path, visualization_type, color_cloud_by_frame, frame_range
):

with pytest.raises(ValueError):
view3d.show(
dynophore,
Expand Down
Loading

0 comments on commit 8a64fd7

Please sign in to comment.