Skip to content

Commit

Permalink
fix tests to accommodate kwarg updates in dihedrals module
Browse files Browse the repository at this point in the history
  • Loading branch information
cadeduckworth committed Apr 15, 2023
1 parent 97267ac commit a25c97d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 5 additions & 6 deletions mdpow/tests/test_automated_dihedral_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ def mol_sol_data(self, SM25_tmp_dir):
return mol, solute

@pytest.fixture(scope="function")
def atom_indices(self, SM25_tmp_dir, mol_sol_data):
def atom_indices(self, mol_sol_data):
mol, _ = mol_sol_data
atom_group_indices = dihedrals.get_atom_indices(dirname=SM25_tmp_dir, mol=mol)
atom_group_indices = dihedrals.get_atom_indices(mol=mol)

# testing optional user input of alternate SMARTS string
# for automated dihedral atom group selection
atom_group_indices_alt = dihedrals.get_atom_indices(dirname=SM25_tmp_dir, mol=mol,
SMARTS='[!$(*#*)&!D1]-!@[!$(*#*)&!D1]')
atom_group_indices_alt = dihedrals.get_atom_indices(mol=mol, SMARTS='[!$(*#*)&!D1]-!@[!$(*#*)&!D1]')
return atom_group_indices, atom_group_indices_alt
# fixture output, tuple:
# atom_indices[0]=atom_group_indices
Expand Down Expand Up @@ -252,14 +251,14 @@ def test_dihedral_groups_ensemble(self, dihedral_data):

def test_save_df(self, dihedral_data, SM25_tmp_dir):
df, _ = dihedral_data
dihedrals.save_df(df=df, df_save_dir=SM25_tmp_dir, molname='SM25')
dihedrals.save_df(df=df, df_save_dir=SM25_tmp_dir, resname='UNK', molname='SM25')
assert (SM25_tmp_dir / 'SM25' / 'SM25_full_df.csv.bz2').exists(), 'Compressed csv file not saved'

def test_save_df_info(self, dihedral_data, SM25_tmp_dir, caplog):
df, _ = dihedral_data
caplog.clear()
caplog.set_level(logging.INFO, logger='mdpow.workflows.dihedrals')
dihedrals.save_df(df=df, df_save_dir=SM25_tmp_dir, molname='SM25')
dihedrals.save_df(df=df, df_save_dir=SM25_tmp_dir, resname='UNK', molname='SM25')
assert f'Results DataFrame saved as {SM25_tmp_dir}/SM25/SM25_full_df.csv.bz2' in caplog.text, 'Save location not logged or returned'

# the following 'reason' affects every downstream function that relies
Expand Down
5 changes: 3 additions & 2 deletions mdpow/workflows/dihedrals.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ def automated_dihedral_analysis(dirname, figdir, resname,

u = build_universe(dirname=dirname)
mol, solute = rdkit_conversion(u=u, resname=resname)
atom_indices = get_atom_indices(dirname=dirname, mol=mol, SMARTS=SMARTS)
atom_indices = get_atom_indices(mol=mol, SMARTS=SMARTS)
bond_indices = get_bond_indices(mol=mol, atom_indices=atom_indices)
dihedral_groups = get_dihedral_groups(solute=solute, atom_indices=atom_indices)
ab_pairs = get_paired_indices(atom_indices=atom_indices, bond_indices=bond_indices,
Expand All @@ -821,7 +821,7 @@ def automated_dihedral_analysis(dirname, figdir, resname,

else:

df = dihedral_groups_ensemble(atom_indices=atom_indices, dirname=dirname,
df = dihedral_groups_ensemble(dirname=dirname, atom_indices=atom_indices,
solvents=solvents, interactions=interactions,
start=start, stop=stop, step=step)

Expand All @@ -830,6 +830,7 @@ def automated_dihedral_analysis(dirname, figdir, resname,

df_aug = periodic_angle_padding(df, padding=padding)

#kwargs in weird order
plot_dihedral_violins(df_aug, resname=resname, molname=molname, mol=mol, plot_pdf_width=plot_pdf_width,
ab_pairs=ab_pairs, figdir=figdir, width=width, solvents=solvents)

Expand Down

0 comments on commit a25c97d

Please sign in to comment.