biasmv / pv

WebGL protein viewer
https://pv.readthedocs.org
MIT License
315 stars 85 forks source link

Partial coloring of structure #182

Open lokapal opened 6 years ago

lokapal commented 6 years ago

Hello, Marco! I'm lost (err, again ;) in the documentation of your omnipotent ;) pv. I need in partial coloring of structure. From pv documentation I revealed that I need in something like "Color structure by custom property" i.e. in function pv.color.byResidueProp(), but I don't need in 'funky' colors. I don't need in rainbow and/or gradient. I need in uniform coloring per chain (it's done) while SOME residues have unique colors (I'll handle both list of these residues and colors per residue). Could you enhance the documentation with this kind of example? Thank you in advance! P.S. I've tried to use something like var index = 0; structure.eachResidue(function(r) { var tmpc; if (index==0) { tmpc=9; } else { tmpc=4; } r.setProp('funky', tmpc); index++; });

or var index=0; structure.eachResidue(function(r) { var tmpc; if (index==0) { tmpc='red'; } else { tmpc='blue'; } r.setProp('funky', tmpc); index++; });

Unfortunately it doesn't work.

a-rasimmurat commented 6 years ago

Hi!

Could you find any solution for your problem, I have the same issue.

arthurchipdean commented 5 years ago

A little late here but this is what I did. If you color by chain first you can then select individual atoms or residues by some criteria and overlap the color of your choice on top of the chain coloring. That's what I'm doing here:

//First select the chain
var main_chain = structure.atomSelect(function(atom) {
  return atom._tempFactor >= 10 && atom.residue().chain().name() == options.chain;
});
//Give a tag 'main-chain', and color it
 viewer.cartoon('main-chain', main_chain, {
  color: color.uniform('#d0ffbf')
});
//Select atoms based on some factor.
var lowQualityAtoms = structure.atomSelect(function (atom) {
   return atom._tempFactor != 10;
});
//And color them
viewer.lineTrace('lowQuality', lowQualityAtoms, {color: color.uniform('lightgrey')});
gaiagbola commented 5 years ago

Hello!! I am building a software for drug design purposes and needed a viewer. I tried to input a specific PDB file but it did not seem to work. Can anybody explain why? I added the protein into the pulldown menu of the viewer but still nothing.

Thank you for your attention