openmm / openmm

OpenMM is a toolkit for molecular simulation using high performance GPU code.
1.42k stars 505 forks source link

Recommended approach to writing out a subset of atoms with XTCReporter/DCDReporter? #4564

Open sukritsingh opened 1 week ago

sukritsingh commented 1 week ago

I was going through the docs about XTCReporter and DCDReporter and I realized there's not really a well-documented way to use these reporters to save out a subset of atoms (or maybe I'm missing it somewhere else?).

Is there a general recommended way to achieve this "writing out a subset of atoms" if we're writing out into XTC or DCD files? I'm imagining a basic scenario where it is known which atom indicies are desired to be saved, but the rest do not need to be written out. I'm currently envisioning having to write some kind of subsetXTCReporter or the like - would this be the best way to go about this?Just looking for any guidance here!

Addendum: You can do this subsetting of atoms using the XTCReporter and DCDReporter in MDTraj - I'm just wondering if there are alternative approaches now that OpenMM has it's own native XTCReporter

peastman commented 1 week ago

It's not just a question of documentation. They don't provide any easy way to do that. PDBReporter does have an atomSubset option, but DCDReporter and XTCReporter don't. That would be a useful option to add.

sukritsingh commented 6 days ago

It's not just a question of documentation. They don't provide any easy way to do that.

Ah ok! I was worried I was missing something lol.

They don't provide any easy way to do that. PDBReporter does have an atomSubset option, but DCDReporter and XTCReporter don't. That would be a useful option to add.

I assume the addition of the atomSubset option for DCDReporter and XTCReporter should look identical to PDBReporter?

I know this would be useful for @Justin-J-Miller so depending on constraints/priorities, I'm happy to work with you on a PR for this, Justin!

peastman commented 6 days ago

That would be great. Yes, the implementation can be copied directly.

sef43 commented 6 days ago

also see here if you want to save atom selections to trajectories using mdanalysis https://github.com/sef43/openmm-mdanalysis-reporter