datreant.data make_filepath?

6 views
Skip to first unread message

Oliver Beckstein

unread,
Aug 2, 2016, 1:43:57 PM8/2/16
to datreant
I inherited some old MDSynthesis scripts which contain "data.make_filepath":


fig.savefig(sim.data.make_filepath('Structure.MembraneMovement_AA/{}'.format(chain), sim.name + '_timeserieshist.pdf'))

MDS 0.6.1 throws an error AttributeError: 'Data' object has no attribute 'make_filepath' – what should I use instead?


--
Oliver Beckstein, DPhil * oliver.b...@asu.edu
http://becksteinlab.physics.asu.edu/

Assistant Professor of Physics
Arizona State University
Center for Biological Physics and Department of Physics
Tempe, AZ 85287-1504
USA

Office: PSF 348
Phone: +1 (480) 727-9765
FAX: +1 (480) 965-4669

Department of Physics: https://physics.asu.edu/content/oliver-beckstein
Center for Biological Physics: http://biophysics.asu.edu/faculty/oliver-beckstein










David Dotson

unread,
Aug 2, 2016, 6:31:59 PM8/2/16
to datreant
Oliver,

You can use the now more-general behavior of the Sim itself to build desired filepaths. In this case, to achieve the same result I would do:

fig.savefig(sim['Structure.MembraneMovement_AA/{}/'.format(chain)][sim.name + '_timeserieshist.pdf'].abspath)

Basically, you can build any filepath as a Tree or Leaf object using a Sim's `__getitem__` behavior, and calling abspath on one of these objects gives the absolute path to it, whether or not the path points to an existing directory or file, respectively.

Does that help?

David 

Oliver Beckstein

unread,
Aug 3, 2016, 5:49:59 AM8/3/16
to datreant

> On 2 Aug, 2016, at 15:31, David Dotson <dot...@gmail.com> wrote:
>
> You can use the now more-general behavior of the Sim itself to build desired filepaths. In this case, to achieve the same result I would do:
>
> fig.savefig(sim['Structure.MembraneMovement_AA/{}/'.format(chain)][sim.name + '_timeserieshist.pdf'].abspath)
>
> Basically, you can build any filepath as a Tree or Leaf object using a Sim's `__getitem__` behavior, and calling abspath on one of these objects gives the absolute path to it, whether or not the path points to an existing directory or file, respectively.
>
> Does that help?

Yes, thanks, but I still needed to make sure that the directory exists:

datapath = 'domains/centerofmass/{}/'.format(chain)
sim[datapath].path.mkdir(exist_ok=True)
fig.savefig(sim[datapath][sim.name + '_timeserieshist.pdf'].abspath)

Is there a more concise way?

--
Oliver Beckstein * orbe...@gmx.net
skype: orbeckst * orbe...@gmail.com

Reply all
Reply to author
Forward
0 new messages