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

Exploit MDanalysis capability of reading bond information from tpr files. #129

Closed
DrDomenicoMarson opened this issue Jan 1, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@DrDomenicoMarson
Copy link
Contributor

Happy new year and thank you for quickly addressing the previous issue with the importing of VDW radii!

While importing XTC files with a TPR file as a topology file, MDanalysis also has useful "bonds" information. I noticed the load_trajectory function has include_bonds = False, but it's never used inside the function.

To have the correct bonds information, it's sufficient to change around line 44 to:

    # create the initial model
    if hasattr(univ, 'bonds'):
        bonds = univ.bonds.indices
    else:
        bonds = []
    mol_object = create_object(
        name = name,
        collection = coll_mn(),
        locations = univ.atoms.positions * world_scale, 
        bonds = bonds
    )

By doing so I was able to load a TPR+XTC trajectory of a protein with proper bond data, which is quicker and "more precise" than having to calculate bonds for each frame based on distance.

@BradyAJohnston
Copy link
Owner

Ah excellent! I have been meaning to look into the bonds for the MDAnalysis import, but hadnt spent the time and I didnt realise it would be so simple.

If you want to open a pull request i could accept it through that, or i could make the changes as well. thanks for looking into it!

@BradyAJohnston BradyAJohnston added the enhancement New feature or request label Jan 2, 2023
@BradyAJohnston
Copy link
Owner

Added here: a523d50

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