Math behind the Ribbon

Moderators: Site Moderators, FAHC Science Team

Post Reply
ChristianVirtual
Posts: 1596
Joined: Tue May 28, 2013 12:14 pm
Location: Tokyo

Math behind the Ribbon

Post by ChristianVirtual »

On my journey to understand better how to visualize protein based on the trajectories we get from client/core I run into questions my limited and very rusty school math from some decades ago are a roadblock. :oops:

I managed to create a smooth backbone based on Hermite Splines; running through all relevant atoms (N-C-C-...). Looks ok for now. Further I have some first wireframe/solid rendering of segments along that spline to extrude the back chain and give it a shape.

Next steps: nice tubing and ribbon for a-helix and b-sheets.

I tried to get some hints via Google but failed to find good material to answer the following questions:

1) How to orientate the tube and ribbon around the spline ? While drawing the tube I run in situations where the tube twist over to the "other" side of the spline. Leaving some bad looking marks on the back chain.

2) Sometimes segments of the tube are not fully orthogonal to the inner spline; they are flipped a bit away on one of three axis. Any hint on how to properly calculate the rotation for the segments of a 3D tube ? Regular vector/matrix operation or quaternions ?

3) What orientations points should be used (e.g. O from the carboxyl group ?) and eventually how to determine the normal and binormal vectors for proper calculation; specially for ribbons.

4) How can one identity there is a a-helix or a b-sheet ? I understand roughly that they are build by bridges made of additional H-bonds. Is there an efficient way to identify those ? What would be the "business rules" behind ?

Sure; I could download some of the software and try to copy/paste. Beside being mostly against the licenses it also prevent me from learning.
Is there any public material from Stanford (or others) related to Bioinformatics/Computer Graphics which I could use to learn further from ? :egeek:

Thanks in advance !
ImageImage
Please contribute your logs to http://ppd.fahmm.net
Jesse_V
Site Moderator
Posts: 2851
Joined: Mon Jul 18, 2011 4:44 am
Hardware configuration: OS: Windows 10, Kubuntu 19.04
CPU: i7-6700k
GPU: GTX 970, GTX 1080 TI
RAM: 24 GB DDR4
Location: Western Washington

Re: Math behind the Ribbon

Post by Jesse_V »

I wish I had answers for you, but I don't know the answers to those questions either. I do however recognize that you're taking your viewer much farther than I even considered taking mine, I'm really impressed!

While I don't know the math involved in professional molecular rendering tools, we might be able to help if we had some pictures to look at. Could you upload some screenshots to Imgur and then post the link to them here? I'm interested in helping you diagnose, but I'm not fully visualizing the issues from your descriptions. Pictures would really help if you could get some.
F@h is now the top computing platform on the planet and nothing unites people like a dedicated fight against a common enemy. This virus affects all of us. Lets end it together.
ChristianVirtual
Posts: 1596
Joined: Tue May 28, 2013 12:14 pm
Location: Tokyo

Re: Math behind the Ribbon

Post by ChristianVirtual »

thanks for the quick and kind response. And here some attempts to show my issues; a bit difficult to get the right screenshots (clipping hit too early when zooming in)

The twist in the tube: see at top left in the yellow and green segments; looks like chain of sausage
http://imagizer.imageshack.us/v2/800x60 ... VdGc2i.png

here as wireframe (see the yellow part left side with the little dent on top)
http://imagizer.imageshack.us/v2/800x60 ... ZatHWx.png

here with a reduced number of segments on the tube; good to see in the center that the wire crossing the spline; I'm sure the the corner indices for the the wireframe is correct; like 0,1,2,3 connected to 4,5,6,7 of two squares. Problem is that one square is rotated more around the spline and "pulling" the wried to cross the spline.
http://imagizer.imageshack.us/v2/800x60 ... 24o7Bt.png


In the lower part of the screen you can see a rather flat tube; reason is that the supposed to be orthogonal segment is laying on the spline (but I have all kind of angles between orthogonal and flat)
http://imagizer.imageshack.us/v2/800x60 ... 4EaCRr.png
ImageImage
Please contribute your logs to http://ppd.fahmm.net
Jesse_V
Site Moderator
Posts: 2851
Joined: Mon Jul 18, 2011 4:44 am
Hardware configuration: OS: Windows 10, Kubuntu 19.04
CPU: i7-6700k
GPU: GTX 970, GTX 1080 TI
RAM: 24 GB DDR4
Location: Western Washington

Re: Math behind the Ribbon

Post by Jesse_V »

It's hard to see in a 2D screenshot, but I think I see what you're saying. The trouble is that you need to determine rotation on the ends of your tube segment, because if they aren't rotated uniformally you can get the ends twisted out of sync with each other, leading to the tube twisting and narrowing in the middle. Likewise if two neighboring tubes don't line up you'll have the sausage effect. If I understand you correctly, this is what you're describing for #1 and #2.

I think you can solved them, but you need to do it one tube segment at a time down the spline. Things are easier because the spline isn't a smooth curve but rather a set of 3D line segments. I'd recommend keeping that approach; you can just increase resolution to give the impression of smoothness, that generally works will for polygon-based rendering. Anyway, for each spline segment you need a tube around it, some radius away from it. Calculate the spline segment vector, call this X = <a, b, c>. You know that you need to find some vector Y that is orthogonal to X, in other words the dot product of X and Y is exactly zero. However, Y is in 3D space so there's a rotational component. On the first segment it doesn't matter, pick some rotation. Build your tube segment around that. So then you will have a box around the first spline segment down the length of the segment. Each face is perpendicular to the spline, expect for the ones on the outside that are parallel to the spline and never intersect it, so there are no twists here.

Next, move to the next spline segment. Again find the vector and find the orthogonal vector, but this time the rotation matters. You need the rotation to be such that when you build your box around it, there is a line segment on the outside of the box (the ones parallel to the spline vector) that intersects with one of the outside line segments on the previous box. It there is an intersection point in 3D space, the two boxes are aligned to each other without twists. If your spline curves (as it most likely does) you'll have a valley in 3D space, but there is some corner of both boxes that are touching each other. Continue orienting each box with respect to the previous box in this way until you're done with the spline.

You will be left with a model that has no twists or deformations, but the corners aren't smooth so it'll look a bit like a sausage link chain. The final step is to bridge between each neighboring pair of tubes with some outward-facing planes that span between the respective ends of the tubes. This will fill in the gaps. Finally, increase the resolution of both the spline and the boxes around them. Eventually you will have a smooth-looking curve that has a round-looking pipe down it.
F@h is now the top computing platform on the planet and nothing unites people like a dedicated fight against a common enemy. This virus affects all of us. Lets end it together.
kyleb
Pande Group Member
Posts: 272
Joined: Fri Mar 12, 2010 8:53 pm

Re: Math behind the Ribbon

Post by kyleb »

The visualiation packages that we use are Pymol and VMD. I think both have source code available. We also have some visualization software in house that you might be able to use for inspiration, which is based on JSMol--see the video here: http://mdtraj.org/latest/
ChristianVirtual
Posts: 1596
Joined: Tue May 28, 2013 12:14 pm
Location: Tokyo

Re: Math behind the Ribbon

Post by ChristianVirtual »

Thanks Jesse, will cross check your explanation with the code I have; I certainly see some points you made nit in my code.

Thanks kyleb for the pointer/link. The inspirational way will help. Glanced through some source files and reading the comments and references will help to get more knowledge about the underlaying concepts. Seems something for the long winter nights coming soon.
ImageImage
Please contribute your logs to http://ppd.fahmm.net
PS3EdOlkkola
Posts: 184
Joined: Tue Aug 26, 2014 9:48 pm
Hardware configuration: 10 SMP folding slots on Intel Phi "Knights Landing" system, configured as 24 CPUs/slot
9 AMD GPU folding slots
31 Nvidia GPU folding slots
50 total folding slots
Average PPD/slot = 459,500
Location: Dallas, TX

Re: Math behind the Ribbon

Post by PS3EdOlkkola »

ChristianVirtual, I'm truly looking forward to what you come up with. You seem to have quite a gift for taking complex concepts inherent in folding and reducing them to a graphical illustration for us mere mortals!

I take my hat off to you for your tenacity and prodigious technical ability.
Image
Hardware config viewtopic.php?f=66&t=17997&p=277235#p277235
Post Reply