Skip to content

Commit

Permalink
temporary fix for figdir issue which should currently be a positional…
Browse files Browse the repository at this point in the history
… argument, but would require redundant rewrite of workflows base module, pending issue #244
  • Loading branch information
cadeduckworth committed Apr 15, 2023
1 parent 83c4c63 commit 60636b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
5 changes: 2 additions & 3 deletions mdpow/tests/test_workflows_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,14 @@ def test_project_paths_csv_input(self, csv_input_data):

pd.testing.assert_frame_equal(project_paths, csv_df)

def test_automated_project_analysis(self, SM_tmp_dir, project_paths_data, caplog):
def test_automated_project_analysis(self, project_paths_data, caplog):
project_paths = project_paths_data
# change resname to match topology (every SAMPL7 resname is 'UNK')
# only necessary for this dataset, not necessary for normal use
project_paths['resname'] = 'UNK'

base.automated_project_analysis(project_paths, solvents=('water',),
ensemble_analysis='DihedralAnalysis',
figdir=SM_tmp_dir)
ensemble_analysis='DihedralAnalysis')

assert 'all analyses completed' in caplog.text, ('automated_dihedral_analysis '
'did not iteratively run to completion for the provided project')
Expand Down
23 changes: 12 additions & 11 deletions mdpow/workflows/dihedrals.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def build_svg(mol, molname, ab_pairs, atom_group_selection,

return fig

def plot_dihedral_violins(df, resname, mol, ab_pairs, figdir, molname=None,
def plot_dihedral_violins(df, resname, mol, ab_pairs, figdir=None, molname=None,
width=0.9, plot_pdf_width=PLOT_WIDTH_DEFAULT, solvents=SOLVENTS_DEFAULT):
'''Coordinates plotting and saving figures for all dihedral atom groups.
Expand Down Expand Up @@ -691,22 +691,23 @@ def plot_dihedral_violins(df, resname, mol, ab_pairs, figdir, molname=None,
newdir = os.path.join(figdir, subdir)
os.mkdir(newdir)

section = df.groupby(by="selection")
section = df.groupby(by="selection")

plot_pdf_width_px = plot_pdf_width * 3.7795275591
plot_pdf_width_px = plot_pdf_width * 3.7795275591

for name in section:
for name in section:

fig = build_svg(mol=mol, molname=molname, atom_group_selection=name, ab_pairs=ab_pairs,
solvents=solvents, width=width)
fig = build_svg(mol=mol, molname=molname, atom_group_selection=name, ab_pairs=ab_pairs,
solvents=solvents, width=width)

figfile = pathlib.Path(newdir) / f"{molname}_{name[0]}_violins.pdf"
plot_pdf = cairosvg.svg2pdf(bytestring=fig.tostr(), write_to=str(figfile),
output_width=plot_pdf_width_px)
figfile = pathlib.Path(newdir) / f"{molname}_{name[0]}_violins.pdf"
if figdir is not None:
plot_pdf = cairosvg.svg2pdf(bytestring=fig.tostr(), write_to=str(figfile),
output_width=plot_pdf_width_px)

logger.info(f"Figure saved as {figfile}")
logger.info(f"Figure saved as {figfile}")

logger.info(f"All figures generated and saved in {figdir}")
logger.info(f"All figures generated and saved in {figdir}")

return None

Expand Down

0 comments on commit 60636b4

Please sign in to comment.