lorenzo-rovigatti / oxDNA

A new version of the code to simulate the oxDNA/oxRNA models, now equipped with Python bindings
https://dna.physics.ox.ac.uk/
GNU General Public License v3.0
38 stars 26 forks source link

Import oxDNA to Blender using Molecular Nodes #80

Closed BradyAJohnston closed 7 months ago

BradyAJohnston commented 7 months ago

I've had an initial go at adding support for import oxDNA topology / trajectory files to into Blender using Molecular Nodes (PR). There isn't a discussion tab so I thought I'd open this up to try and get some feedback on it.

It is so far working pretty well, importing single timepoints and trajectories, as curves. After import I can then build different meshes on top using Molecular Nodes / Geometry Nodes.

https://github.com/BradyAJohnston/MolecularNodes/assets/36021261/71e50c2b-b134-494f-9c7f-44d6a6534e74

I'm wondering if anyone could give me some more details on any 'gotchas' to look out for, or some specific smaller trajectories that I can use for unit testing etc. I don't currently work in DNA origami at all, so all of the formats are new to me, and would welcome any guidance with improving it.

ErikPoppleton commented 7 months ago

Hi Brady, super excited to hear that oxDNA support is coming to Molecular Nodes! It will be super nice to now have to export to PDB when loading into Blender.

Probably the biggest thing to watch for is that there are two different topology files, the “original” one in which nucleotides are listed backwards (3’-5’), and the “new” one added in the last release which has a different format to enable DNA/RNA hybrid simulations and has the strands in the normal direction (5’-3’).

The other thing to note is that the positions recorded in the configuration file represents the center of mass of the nucleotide, the backbone and base sites are offset from the backbone based on DNA/RNA model and the a1/3 vectors.

You’ve probably already found it, but there is a documentation page on file formats. You also might find it useful to look at the topology parser for oxDNA analysis tools, which can be found here. The configuration parser, unfortunately, is in Cython and doesn’t deal with the backbone vs base sites, but you can see how we did it in oxView here (sorry it’s in Typescript).

BradyAJohnston commented 7 months ago

Hi @ErikPoppleton, thanks for the extra info! Yes I chatted to a number of DNA origami people at the Synthetic Biology Australia conference, and I figured it should be doable without too much trouble (managed to get it together over the weekend). I have so far just done the old style topology, but the new style should be straight forward to add as well. A question around this, will the trajectory be in the same 5' -> 3' as the newer topology? So the trajectory / topologies won't be usable with each other?

For the offsets from the centre of mass, are you saying that:

backbone_position = centre_of_mass - 1/3 * base_vector
base_position = centre_of_mass + 1/3 * base_vector

Then the base_normal gives the rotation? I did go through the documentation page, but couldn't find anything about how the backbone / base is calculated from centre_of_mass.

lorenzo-rovigatti commented 7 months ago

Yes, exactly, nucleotides in trajectories and configurations are listed 3'->5' with old topologies and 5'->3' with new topologies. There is a script to convert between the two (utils/convert.py). As for the documentation, note that the page linked by Erik contains the following information, which, if I understand correctly, is what you need:

Screenshot_20231120_135233

BradyAJohnston commented 7 months ago

@lorenzo-rovigatti ah yes apologies, I had gone through the page but not realised that part was what I was after. Should be able to finish off the rest of the implementation.

The two different oxDNA1 / oxDNA2, is this for old / new topology system, or is this another spec?

zoombya commented 7 months ago

Hi Brady, another thing to whatch out is that strands can diffuse through the periodic boundary, our python reader handles it in the following way https://github.com/lorenzo-rovigatti/oxDNA/blob/master/analysis/src/oxDNA_analysis_tools/UTILS/RyeReader.py#L426 Your video looks really cool!

zoombya commented 7 months ago

oxDNA1 vs oxDNA2 are 2 different force fields, new vs old topology is independent of the force field.

lorenzo-rovigatti commented 7 months ago

Just to chime in, most people use oxDNA2, which features the major minor groove that your video (which btw is great!) seems to be missing. I think using the oxDNA2 positions makes the most sense.

BradyAJohnston commented 7 months ago

Okay thanks for all of the extra information everyone. I'm now correctly using the base_normal and base_vector to position the backbone and align the bases (previous videos was just drawing backbone through centre_of_mass), so it now has the major & minor grooves as it should.

CleanShot 2023-11-21 at 09 58 42@2x

Am I correct that there are sometimes connecting segments, that don't have bases but are still part of the 'strand'? For the icosahderon example there are lots of long connectors that don't show any base information but you still use them in the simulations? I just want to know if I should be doing anything special with them. Again, unfamiliar with the data formats so thanks for answering all of my naive questions!

BradyAJohnston commented 7 months ago

Additionally, are there some small trajectories that I could use for running unit tests? I've grabbed some .top / .oxdna from the examples in this repo and oxdna viewer, but they all seem to be either start or final frames of the trajectories.

sulcgroup commented 7 months ago

Hi Brady,

Each base is a part of a DNA strand, but some bases are not part of a duplex (they are in a single-stranded region). When a structure is imported into oxDNA from CADNANO, a popular DNA nanotech design tool, the single-stranded regions are not represented there, and it might also result into some bases being far away from their correct physical position. Once the sturcture is relaxed and ran in oxDNA simulation, these nucleotides are assigned physically sensible 3D position and you should no longer see such long stretches. If you still do, there is some problem with the oxDNA configuration import.

As for the short trajectory, the RNA tile here could be a good one (it is in oxRNA, but close enough to oxDNA, format is very similar): https://github.com/sulcgroup/oxdna-viewer/tree/master/examples

Other option is to run the Holliday junction (also available in the examples) for 1 hour on oxDNA.org, and the trajectory should be short and sufficient to play with.

BradyAJohnston commented 7 months ago

Thanks @sulcgroup for the additional details! I'll run a short sim and use some frames for testing.

BradyAJohnston commented 7 months ago

It is now part of the main release (https://github.com/BradyAJohnston/MolecularNodes/releases) if anyone would like to try it out. I am yet to write documentation for the oxDNA specific import, but it follows similar approach to the other data formats. If you would like to give Blender a try then I'd love any feedback anyone has about it.