Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle folders with several simulations #61

Closed
kain88-de opened this issue Sep 22, 2016 · 2 comments
Closed

handle folders with several simulations #61

kain88-de opened this issue Sep 22, 2016 · 2 comments

Comments

@kain88-de
Copy link
Contributor

I sometimes get several simulations of colleagues that are all in one folder

sim
+-- foo.01.xtc
+-- foo.02.xtc
+-- foo.03.xtc
+-- foo.pdb

My current approach is to move these into separate folders but I would like it I can also tell a Sim that there is more then one simulation in that folder. All simulations have exactly the same setup so I treat it as an ensemble in my analysis instead of a single simulation.

I know I just copy them to different directories and then create sims in them I'm just curious is such a workflow would be possible with mdsynthesis.

@dotsdl
Copy link
Member

dotsdl commented Sep 22, 2016

A Sim doesn't care where the files live that its UniverseDefinition points to, so you could create a bunch of Sim objects anywhere in your filesystem and then define their universes as normal:

import mdsynthesis as mds

sourcedir = mds.Tree('sim')

for traj in sourcedir.glob(*.xtc):
    s = mds.Sim("sim_{}".format(traj.name.split('.')[1]))
    s.universedef.topology = sourcedir['foo.pdb'].abspath
    s.universedef.trajectory = traj.abspath

This will create sim_01, sim_02, and sim_03 in the current directory, and each one will have its universe definition set up as I think you want.

Although MDS works just fine with this approach, in practice I think it works better when the files for a given simulation all reside in that Sim object's tree, since then it's easier to do things like:

import mdsynthesis as mds
import gromacs

b = mds.discover()

# if the xtc files are inside the top level of each Sim, we could grab them
# all like this
xtcs = b.glob('*.xtc')

# let's make a trajectory for each with a coarser timestep
for xtc in xtcs:
    gromcs.trjconv(f=xtc.abspath,
                            o=xtc.parent["{}_dt1ps.xtc".format(xtc.name.partition('.xtc')[0])],
                            dt=1)

since you don't have to grab these files outside of the tree and make sense of which corresponds to what Sim, but it will all technically still work.

@kain88-de
Copy link
Contributor Author

yup that works thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants