-
Notifications
You must be signed in to change notification settings - Fork 2
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
General way to create trajectory #2
Comments
Unfortunately not. Bonds/angles/dihedrals/grouping (i.e. residues) don't have to be set (like for XYZ inputs), but the number of atoms is static.
Yes that is the case, traversing through a trajectory essentially amounts to iteratively loading coordinates via the reader that the trajectory attribute is connected with (@lilyminium may be better able to expand on this). |
Yeah that's right. Pointing to the next frame pretty much only populates the .positions attribute (and possibly velocities and forces). |
Is there any reason a general trajectory class doesn't exist in MDA? A class that can parse any specific traj file format and describes a trajectory in molecular mechanics? |
Each format has different info and parsing needs, hence the different parser for each format. The "class that can parse any specific traj file format" role is mostly fulfilled by MDAnalysis.core.Universe, which looks for the correct parser for the file format. @orbeckst and @richardjgowers may have more insight into the historical evolution of the structure of MDAnalysis. |
The philosophy (coming from MMTK originally) was that for a system to make sense you need static information ("topology") and dynamic information (coordinates, velocities, forces, lambdas, .... = "trajectory"). The Universe combines them. Ultimately, MDAnalysis takes the view that a trajectory is something that you add to a topology. We don't need a generic trajectory class because trajectory "Readers" are defined by the Trajectory API (which is mostly implemented by deriving specialized readers from the coordinates.base classes. As @lilyminium said, the decision on which Reader to choose is taken by Universe (actually, through a hacky function coordinates.core.get_reader_for() and metaclass magic that registers any Reader... but @richardjgowers needs to explain this). I suppose one could wrap the part that selects the reader into yet another class but for MDAnalysis that does not seem to have any advantages, but I might be wrong. Can you explain your philosophy and use case, @Andrew-AbiMansour ? |
By the way, it is possible to create a bare-bones Universe from a trajectory alone: import MDAnalysis as mda; from MDAnalysisTests import datafiles as data
mda.Universe(data.XTC)
mda.Universe(data.TRR)
mda.Universe(data.XYZ)
mda.Universe(data.DCD) It will just create sequentially numbered atoms but you don't need to supply a topology if you don't have one. Conversely, if you only have a topology, you can add the trajectory later: u = mda.Universe(data.PSF)
u.load_new(data.DCD) |
Thanks for the info. The problem I'm trying to solve in the context of mmic_mda is converting efficiently The class Trajectory(ProtoModel):
top: Optional[Union[Molecule, List[Molecule]]] = Field(
None,
description="A single or list of :class:``Molecule`` objects representing the molecular topology.",
)
frames: List[Frame] = Field(
None, description="A list of :class:``Frame`` objects of length nframes."
)
Ideally, mmic_mda would convert |
Yes, use the MemoryReader, which takes a numpy array. https://docs.mdanalysis.org/stable/documentation_pages/coordinates/memory.html |
Maybe that wasn't super-clear but if you provide a numpy array in Is |
This is a little bit concerning though. If the topology changes you would have to re-create the Universe. |
I think conversion to MDA should fail with a |
Time-dependent/dynamic topologies not being supported in MDA is not a problem, we can just raise a
Could be either. By design, MMElemental is completely agnostic to any MD file format, but for convenience, it can (in runtime) provide read/write capabilities indirectly using mmic_translator, which under the hood would select a specific translator (such as mmic_mda) to read/write a specific file format. The I will keep this issue open until the traj converter is completed in mmic_mda. Thanks for your input everyone. |
We need a general and robust way of creating an MDAnalysis trajectory object from MMSchema for TrajToMdaComponent.
Related issues:
The text was updated successfully, but these errors were encountered: