ncbi / icn3d

web-based protein structure viewer and analysis tool interactively or in batch mode
https://www.ncbi.nlm.nih.gov/Structure/icn3d
Other
154 stars 42 forks source link

Custom track coloring #38

Closed bha008 closed 3 years ago

bha008 commented 3 years ago

The custom color via the UI is working great. Is there a way to do that using the js library? I am currently using:

ic.opts['color'] = 'align custom';
ic.setColorCls.setColorByOptions(ic.setColorCls.setColorByOptions(ic.opts, ic.hAtoms));
jiywang3 commented 3 years ago

If you check the file setColor.js, there is one line "let b = ic.queryresi2score[chainid][queryresi];".

So basically you need to construct the hash "ic.queryresi2score". The first key is "chainid", which is something like "1KQ2_A". The value is another hash, which has residue number such as 20 as key and a value between 0 and 100 as the value.

You can define "ic.startColor" and "ic.endColor" as one of "red", "green", and "blue". You can also define "ic.midColor" as "white" or "black". These variables are used to set the color gradient.