Skip to content

Conversation

@GardevoirX
Copy link
Contributor

Closes #358

This PR allows passing a Universe object to the frame parameter of chemiscope.show. It can be checked by running

import chemiscope
import MDAnalysis as mda

u = mda.Universe("./python/examples/data/trajectory.xyz")
chemiscope.show(frames=u, mode="structure")

As mda is usually used in analyzing biosystem-related trajectories, I also tried it on a pdb file containing two peptides, but I found the current representation schemes cannot display the protein well (see below), maybe we can later consider supporting the ribbon diagram representation?
image

@Luthaf
Copy link
Contributor

Luthaf commented Nov 18, 2024

Thanks a lot, this is very nice!

From the screenshot, it looks like the structure is using the wrong unit. Chemiscope/3Dmol.js assumes Angstroms, but I think MDA is using nm. I think there should be at least some automatically guessed bonds in this structure.

As a related point, does MDA add back the implicit H atoms that are often missing in bioinformatics file formats?

maybe we can later consider supporting the ribbon diagram representation?

This is #127, PR welcome! The biggest issue there will be that we will need to add another field to chemiscope's JSON containing information about alpha carbons / some level of pre-computed secondary structure information.

@GardevoirX
Copy link
Contributor Author

GardevoirX commented Nov 18, 2024

From the screenshot, it looks like the structure is using the wrong unit. Chemiscope/3Dmol.js assumes Angstroms, but I think MDA is using nm. I think there should be at least some automatically guessed bonds in this structure.

In this screenshot, I turned off the bond display, otherwise it would be totally a mess 👇 But I agree that there might be a unit issue. I will look at it later.
image

As a related point, does MDA add back the implicit H atoms that are often missing in bioinformatics file formats?

No, it doesn't.

@GardevoirX
Copy link
Contributor Author

Regarding the unit issue, I think mda read the coordinate in the structure file as-is. The real difference comes from the units that are used by different formats (like Å for xyz and nm for pdb, generally speaking). And it might be hard to tell which unit is being using from chemiscope side.

@Luthaf
Copy link
Contributor

Luthaf commented Nov 21, 2024

https://userguide.mdanalysis.org/stable/units.html Looks like everything should be in A. I'm not sure what's happening in the initial screenshot though. Which file did you use for it?

@GardevoirX
Copy link
Contributor Author

Ahh yes, thanks! I used this file. And in the initial screenshot, I toggled off the bond. Perhaps you can take the latter one for your reference.

@PicoCentauri
Copy link
Contributor

What is the status here? Would be still nice to have this feature if possible!

@PicoCentauri
Copy link
Contributor

Once this is merged we can add chemiscope here:

https://www.mdanalysis.org/pages/mdakits/#visualization-tools

Copy link
Contributor

@PicoCentauri PicoCentauri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Instead of passing a universe I would pass an Atomgroup, which can be accessed by universe.atoms. In your code you can get the trajectory by atoms.universe.trajectory.

If we allow passing an atomgroup users can easily subselect atoms.

Copy link
Contributor

@PicoCentauri PicoCentauri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. The tests are not happy though.

@GardevoirX
Copy link
Contributor Author

Nice. The tests are not happy though.

Now good👍

Copy link
Contributor

@PicoCentauri PicoCentauri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. But maybe also we should add some info somewhere in the docs. Probably @Luthaf can show the correct spot.

@GardevoirX
Copy link
Contributor Author

Looks good to me. But maybe also we should add some info somewhere in the docs. Probably @Luthaf can show the correct spot.

Maybe we can add something like this example? but if so, I'd like to merge this PR first and add an example in the following PR about introducing cartoon

@Luthaf
Copy link
Contributor

Luthaf commented Oct 21, 2025

Adding an example later for docs sounds good, although we could update the docstring for create_input, write_input, show (and anything else taking frames) to mention both stk and mda (they currently say "For now, only ase.Atoms objects are supported").

@GardevoirX
Copy link
Contributor Author

Adding an example later for docs sounds good, although we could update the docstring for create_input, write_input, show (and anything else taking frames) to mention both stk and mda (they currently say "For now, only ase.Atoms objects are supported").

I think that's good for finishing this PR. Adding an example can be postponed, but yes it's nice to show others what we can do through chemiscope

@Luthaf Luthaf merged commit c8beb47 into lab-cosmo:main Oct 23, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow passing an MDAnalysis AtomGroup as frames paramater

3 participants