-
Notifications
You must be signed in to change notification settings - Fork 67
Handle non-contiguous molecules #845
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
Conversation
@hainm I may need your help fixing pytraj on this one. I've got a branch where I'm trying to fix this locally. I first tried to just comment out the Molecule stuff that was removed (BeginAtom(), EndAtom(), etc) figuring that's all low level stuff pytraj shouldn't need anyway, and it compiles, but some tests fail, e.g.:
I don't know why |
@drroe I will take a look. Cheers. |
@hainm Some more info. If I compile libcpptraj with no optimizations the tests fail at a different point:
Interestingly enough, if I run |
@hainm I guess the problem is that pytraj will need to have |
I have not checked the code in detail yet but I got segmentation fault with this simple code:
|
@drroe I've tracked down and this line of code caused the segmentation fault: https://github.com/drroe/pytraj/blob/30fb774d117d4cd5792c36af405282c93a8fbe6c/pytraj/analysis/c_action/c_action.pyx#L207 any idea why? |
By the way, here is how |
@hainm so the issue is that cpptraj now allows molecules to be made up of 1 or more contiguous segments; so there is no longer things like However, I think that internally breaks how pytraj does things with molecules, for example here: https://github.com/drroe/pytraj/blob/1b5699449c8c92ae620483b9ac3e93c7ce8b1a3b/pytraj/topology/topology.pyx#L304-L306 Essentially pytraj needs to be updated to handle the new molecule bookkeeping in cpptraj, and I'm not sure what the best way to do it is. I think that adding a call to the |
@drroe I don't think that relates to the segmentation fault.
|
For updating |
I see the issue now. Currently,
|
@drroe Please try out my branch: https://github.com/hainm/pytraj/tree/cpptrajMolUnit
I don't know how to make
The aim of the test is to convert cpptraj's Topology object to python's dict for serialization. I got more number of molecules after deserializing the data. |
Scratch that. I misunderstood your comment. Fixed now. |
When initially written, cpptraj expected molecules to be contiguous, i.e. all atoms in a given molecule are next to each other in the overall topology sequence. When this was not the case (due to e.g. some moiety later in the Topology sequence being bonded onto an earlier molecule) cpptraj would complain and just not determine molecule information, which would disable things like imaging by molecule etc.
This PR gives cpptraj the ability to handle non-contiguous molecules, by assuming molecules are composed of "segments" which are themselves contiguous. This requires the least amount of memory and code change to implement, and seems to work well in practice. Imaging by molecule is barely slower (1-2%), while unwrapping actually got a decent boost when rewritten (20%). When writing Amber topologies with non-contiguous molecules, try to be as true to the format as possible by writing the ATOMS_PER_MOLECULE field based on segments. I think this should be OK, but a warning is printed anyway.
The
fixatomorder
command can still be used to re-order molecules to be contiguous if desired.