From 60636b41bc99a6c2b49b0eeee0e79774ed84282f Mon Sep 17 00:00:00 2001 From: cadeduckworth Date: Sat, 15 Apr 2023 00:09:56 -0700 Subject: [PATCH] temporary fix for figdir issue which should currently be a positional argument, but would require redundant rewrite of workflows base module, pending issue #244 --- mdpow/tests/test_workflows_base.py | 5 ++--- mdpow/workflows/dihedrals.py | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mdpow/tests/test_workflows_base.py b/mdpow/tests/test_workflows_base.py index dcf82993..35b24659 100644 --- a/mdpow/tests/test_workflows_base.py +++ b/mdpow/tests/test_workflows_base.py @@ -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') diff --git a/mdpow/workflows/dihedrals.py b/mdpow/workflows/dihedrals.py index bff213ee..3f6e9615 100644 --- a/mdpow/workflows/dihedrals.py +++ b/mdpow/workflows/dihedrals.py @@ -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. @@ -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