Ngl: Add support for displaying 1-3 residue parts of cartoon representations

Created on 24 Oct 2016  路  12Comments  路  Source: nglviewer/ngl

Currently the spline is calculated only using the selected atoms. However, non-selected atoms should still be used for the spline calculation, just not displayed.

enhancement

Most helpful comment

Or representation.update({color: true}) which will reevaluate the currently assigned color scheme.

All 12 comments

Which file to have a look into? I'll try to fix and PR this.

Just to be sure..: Is there some way to display a cartoon spline longer than 3 residues and coloring each residue individually? Or does this bug need to be fixed for that?

I might not have understood your question, but it is indeed possible to display a cartoon spline longer than 3 residues and color it by residue index, which will provide each residue a color based on its index in the chain. I forked your pen example to show it : https://codepen.io/ppillot/pen/qVpPqj
You can also create a colormaker to create more complex color schemes for your representation.
So if your goal is to color different parts of the same representation in a different way, you'd better use a colormaker to achieve this.

You may have found this already?
http://nglviewer.org/ngl/api/manual/usage/coloring.html#custom-coloring
There's a discussion in #59 about performance of selection schemes vs custom colormakers
Disclaimer: I've never used any of these features!

@moritzschaefer if your main reason to create cartoons <= 3 consecutive residues is coloring, I suggest to go the custom colormaker route. Creating many (hundreds) of cartoon representation with just different colors is needlessly expensive and does not scale well.

Cartoons with three or less residues are not supported because the Spline class does not handle it (see https://github.com/arose/ngl/blob/ts2/src/geometry/spline.js). For a spline you need 4 points, to correctly stitch adjacent cartoons from different representations together you need to take the two preceding and one trailing residues into account. Currently the Spline only takes one preceding residue into account, as far as I recall.

Thanks for your great suggestions! I chose that unperformant solution because it was possible to update the selection of the representation at any time
representation.setSelection(newSelection);
like so.

I didn't find a way to reevaluate the scheme once I changed the residue-to-color array as suggested from you in https://github.com/arose/ngl/issues/59
Is there some practical way to update once the color-residue data has changed?

You can use representation.setColor(newColorScheme)

Or representation.update({color: true}) which will reevaluate the currently assigned color scheme.

@ppillot Generating a new color scheme works perfectly Thank you!
@arose calling update does in fact reevaluate the atomColor-function for each atom, though the updated return-values are not drawn (i.e. the atomColor-function is being run many times when I call representation.update({color: true}) and I made sure, that the function returned different colors than before, though I can't see any visual changes)

@moritzschaefer can you make an CodePen showing this behavior? Would help a lot. Also, does updating the colors like this fail for all representation or just cartoon?

ping @moritzschaefer

Was this page helpful?
0 / 5 - 0 ratings

Related issues

harryjubb picture harryjubb  路  4Comments

iwatobipen picture iwatobipen  路  4Comments

harryjubb picture harryjubb  路  7Comments

arose picture arose  路  3Comments

biharck picture biharck  路  6Comments