nglviewer / ngl

WebGL protein viewer
http://nglviewer.org/ngl/
MIT License
666 stars 169 forks source link

Asymmetric offsets for double bonds #152

Closed arose closed 8 years ago

arose commented 8 years ago

To draw extra cylinders/lines inside a ring

download

fredludlow commented 8 years ago

I've got an initial commit for this here: fredludlow/ngl@11faf5d3295ca3deb314803f87e5d180079cf313

Looks nice for lines, looks okay for licorice (the cylinders are uncapped - might need to place extra spheres at the ends to round them off?) and looks a bit sketchy for ball+stick mode.

screenshot 3 screenshot 4 screenshot 5

arose commented 8 years ago

Looks great!

Does the amount of "shortening" need to be adjusted for different values of bondSpacing?

the cylinders are uncapped - might need to place extra spheres at the ends to round them off?

Yeah would be nice, but can be done in the future. Either with extra spheres or rounded caps (https://github.com/arose/ngl/issues/187). In both cases it requires some refactoring as the placement of the spheres and the "identity" of the shifted bonds is only known within the getBondData method.

looks a bit sketchy for ball+stick mode.

I guess that is okay. One could change the aspectRatio param for bigger spheres.

fredludlow commented 8 years ago

Thanks!

Does the amount of "shortening" need to be adjusted for different values of bondSpacing?

Probably - actually the parameters need a bit of a think through (I'm currently abusing the bondSpacing parameter because I just wanted a way to play with relative radii in the UI easily without wiring up another parameter).

I think for Balll+Stick the current (symmetric) rendering looks better anyway (it looks a bit more like the plastic molecular modelling kits you can buy) so maybe for that mode at least the current (two smaller symmetric cylinder) mode should be default.

I wasn't sure what the most intuitive set of parameters would be to expose the various options, multipleBond could take values null, symmetric, offset? Or there could be a separate param for offset/asymm? Then the parameters you need internally are a radius scaling factor, a shortening factor and an offset, which of those are independent and exposed to the user and which are calculated from others I don't really have a strong opinion on as long as the defaults look good. Do you have a preference?

arose commented 8 years ago

multipleBond could take values null, symmetric, offset

I like this approach

Do you have a preference?

not really, just not too many :-)

fredludlow commented 8 years ago

Okay, nearly there I think. What I've gone for in terms of parameters is:

When loading a PDB through the webapp menu the default representation for het groups is ball+stick with scale=2.0, I've added values for bondScale and bondSpacing so that if the user subsequently selects either of the multiple-bond modes it looks a bit better.

I'm afraid I've ended up with a fairly monolithic PR with both the ring stuff and this sorry.

arose commented 8 years ago

This is really great!

One little thing regarding bond shortening. Would look a bit better to shorten only one side of the bond for e.g. carbonyls?

screenshot 30

fredludlow commented 8 years ago

Yes - I guess a quick "is it terminal" check would do it. What's the cleanest way to deduce this inside the Structure.getBondData method? (residue type and bondgraph, atom/bond proxy and bondHash, or something else...?)

Even better would be to be aware of the geometry and adjust cutoff accordingly (linear alkynes also look a bit funny at the moment) but that sounds like another level of perception of the molecule

arose commented 8 years ago

Yes - I guess a quick "is it terminal" check would do it. What's the cleanest way to deduce this inside the Structure.getBondData method? (residue type and bondgraph, atom/bond proxy and bondHash, or something else...?)

var isTerminal = bondHash.countArray[ atomIndex ] === 1;
fredludlow commented 8 years ago

Hmm, actually if you have different shortenings on both sides: fredludlow/ngl@39ce713 you end up with with color-changes not quite lining up: screenshot 9

I'm inclined to leave this as is for now, what do you think?

arose commented 8 years ago

... color-changes not quite lining up:

yeah fixing that will cause some headaches, not sure if it is worth it, I would say no. What do you think.

fredludlow commented 8 years ago

Agreed, I'll close this for now. Oops, can't close it, you're the owner!