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

Analysing a trajectory #1

Open
ajasja opened this issue Jun 20, 2018 · 3 comments
Open

Analysing a trajectory #1

ajasja opened this issue Jun 20, 2018 · 3 comments
Labels
enhancement New feature or request

Comments

@ajasja
Copy link

ajasja commented Jun 20, 2018

H!

What's the best way to analyse a trajectory using ampal? Concretely I have dcd MD trajectory and I would like to analyse each frame using ampal.

I realize that a brute force approach is just to split the trajectory into pdbs and load each pdb separately.

Have you considered integration with MDtraj?

Is it perhaps possible to just update each atom coordinates in the ampal object?

@ChrisWellsWood ChrisWellsWood added the enhancement New feature or request label Jun 21, 2018
@ChrisWellsWood
Copy link
Contributor

This is a good question. I've not done a huge amount of analysis of MD trajectories, but when I have, I've taken the approach that you mentioned of splitting it into frames and iterating over the PDB files, which isn't ideal. We have considered MDTraj integration, as it's used pretty heavily within the group, but it's been pretty low priority, mainly because no ones asked for it!

@ajasja
Copy link
Author

ajasja commented Jun 21, 2018

Is the order of the atoms in the ampal object the same as in the PDB file?
I guess one could just iterate over all the atoms in the ampal and replace the _vector property from the coordinates fund in the MDtraj topology.

Although with modern SSDs splitting into PDBs should also work nicely:)

@ajasja
Copy link
Author

ajasja commented Jun 22, 2018

@ChrisWellsWood Here is an update method that works:

import mdtraj as md
import ampal

def update_ampal(assembly, traj_frame):
    """Updates ampal using coordinates from md_traj frame. Update is INPLACE"""
    ampal_atoms = list(assembly.get_atoms())
    assert len(ampal_atoms) == traj_frame.n_atoms, \
        f"Number of atoms in ampal {len(ampal_atoms)} and mdtraj {traj_frame.n_atoms} must be equal!"

    for md_at, amp_at in zip(traj_frame.xyz[0], ampal_atoms):
        # mdtraj converts to nanometers. Convert back to Angstrem.
        amp_at._vector = md_at * 10

    return assembly

Probably needs some test etc... Also haven't tested for multichain assemblies.

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

No branches or pull requests

2 participants