论坛: 公开讨论 (Thread #34462)

color specific amino acid (2013-08-30 06:04 by skumar #70111)

Hi,

I have used this link to show structure on browser and it is working fine.
http://webglmol.sfjp.jp/glmol/viewer.html?pdb:2HDB

But is there any way to show specific amino acids in different color.

thanks
sonu

RE: color specific amino acid (2013-09-03 17:55 by biochem_fan #70163)

Hi,

Sorry, there is no user interface for it, but you can do it easily by simple coding
if you are going to embed GLmol in your Web page.
回复到 #70111

RE: color specific amino acid (2013-09-04 04:04 by skumar #70165)

Now I have embedded the pdb structure in my web page using this code:
But this structure is coming outside canvas instead within canvas....Is there any problem in my code?

Please let me know!!

Glmol
<div id="glmol01" style="width: 500px; height: 400px; background-color: black;"><canvas width="500" height="400" style="width: 100%; height: 100%;"></canvas></div> <textarea id="glmol01_src" style="display: none;"></textarea>

<script src="{{=URL('static','js/jquery-1.7.min.js')}}"></script>
<script src="{{=URL('static','js/Three49custom.js')}}"></script>
<script src="{{=URL('static','js/GLmol.js')}}"></script>

<script type="text/javascript">
var glmol01 = new GLmol('glmol01', true);
glmol01.defineRepresentation = function() {
var all = this.getAllAtoms();
var hetatm = this.removeSolvents(this.getHetatms(all));
this.colorByAtom(all, {});
this.colorByChain(all);
var asu = new THREE.Object3D();

this.drawBondsAsStick(asu, hetatm, this.cylinderRadius, this.cylinderRadius);
this.drawBondsAsStick(asu, this.getResiduesById(this.getSidechains(this.getChain(all, ['A'])), [58, 87]), this.cylinderRadius, this.cylinderRadius);
this.drawBondsAsStick(asu, this.getResiduesById(this.getSidechains(this.getChain(all, ['B'])), [63, 92]), this.cylinderRadius, this.cylinderRadius);
this.drawCartoon(asu, all, this.curveWidth, this.thickness);

this.drawSymmetryMates2(this.modelGroup, asu, this.protein.biomtMatrices);
this.modelGroup.add(asu);
};
$.get("http://www.pdb.org/pdb/files/1A85.pdb", function(ret) {
$("#glmol01_src").val(ret);
glmol01.loadMolecule();
});
</script>

thanks
回复到 #70111

RE: color specific amino acid (2013-09-04 09:14 by biochem_fan #70166)

Hi,

You don't need a CANVAS tag within DIV; GLmol generates by itself.

<div id="glmol01" style="width: 500px; height: 400px; background-color: black;"></div>


To color specific amino acids, use colorByResidue() function in defineRepresentation.
For example,

this.colorByResidue(all, {"ARG": 0x0000FF, "ASP": 0xFF0000}); // color ARG in blue, ASP in red
回复到 #70165

RE: color specific amino acid (2013-09-05 05:06 by skumar #70169)

Thank you so much.
Now everything is working fine. I need some additional help if possible please suggest me.
I would like to create button and then by clicking I want to display glmol structure on same page or different page.

here is my code:

<button onclick="glmol(pdb_id)">Display GLmol</button>

<div id="glmol01" style="width: 500px; height: 400px; background-color: black;"></div> <textarea id="glmol01_src" style="display: none;"></textarea>

<script src="{{=URL('static','js/jquery-1.7.min.js')}}"></script>
<script src="{{=URL('static','js/Three49custom.js')}}"></script>
<script src="{{=URL('static','js/GLmol.js')}}"></script>

<script type="text/javascript">
var glmol01 = new GLmol('glmol01', true);
glmol01.defineRepresentation = function() {
var all = this.getAllAtoms();
var hetatm = this.removeSolvents(this.getHetatms(all));
this.colorByAtom(all, {});
this.colorByChain(all);
var asu = new THREE.Object3D();

this.drawBondsAsStick(asu, hetatm, this.cylinderRadius, this.cylinderRadius);
this.drawBondsAsStick(asu, this.getResiduesById(this.getSidechains(this.getChain(all, ['A'])), [58, 87]), this.cylinderRadius, this.cylinderRadius);

};

function glmol(pdbid){
uri = "http://www.pdb.org/pdb/files/" + pdbid + ".pdb";

$.get(uri, function(ret) {
$("#glmol01_src").val(ret);
glmol01.loadMolecule();
});

};

</script>
回复到 #70111

RE: color specific amino acid (2013-09-05 08:55 by biochem_fan #70170)

> I would like to create button and then by clicking I want to display glmol structure on same page or different page.

What do you mean?
Loading another molecule into an existing GLmol instance by clicking a button?

Then, please examine viewer.html for "Load molecule" button.
回复到 #70169

RE: color specific amino acid (2013-09-05 10:10 by skumar #70171)

Sorry for confusion.
I have list of pdb files on my webpage. That is why I want to create button for each pdb file.
When I click this button then pdb should load into GLmol.

thanks
回复到 #70111

RE: color specific amino acid (2013-09-05 10:28 by biochem_fan #70172)

> I have list of pdb files on my webpage. That is why I want to create button for each pdb file.
> When I click this button then pdb should load into GLmol.

Your code looks OK. Doesn't it work? For example, glmol("3EML")?

If errors are shown in the console, please let me know.
回复到 #70171

RE: color specific amino acid (2013-09-14 05:30 by skumar #70218)


Is there way to color residue by their residue number instead of residue name?
One more thing I would like to know that if I want to hide one chain from two chain. How to do this?

Thanks
回复到 #70111

RE: color specific amino acid (2013-09-14 09:29 by biochem_fan #70220)

Use "getChain" and "getResiduesById" to select atoms.
Then you can set "color" attribute of each atom with for-loop.

To draw cartoon for only certain chains, apply "drawCartoon" to only those
atoms selected as above instead of all.
回复到 #70218

RE: color specific amino acid (2013-11-05 05:22 by skumar #70693)

I am not able to color amino acid by their residue id...Please help me out with this problem.

here is my code:

variable P contains list of amino acid id eg: [12,15,18] which I want to make red.

var P = [12,15,18];
var glmol01 = new GLmol('glmol01', true);
glmol01.defineRepresentation = function() {
var all = this.getAllAtoms();
var hetatm = this.removeSolvents(this.getHetatms(all));
this.colorByAtom(all, {});
this.colorByStructure(all);

//this.colorByResidue(this.getResiduesById(this.getSidechains(this.getChain(all, ['A'])), P), 0xFF0033);


var asu = new THREE.Object3D();

this.drawBondsAsStick(asu, hetatm, this.cylinderRadius / 2.0, this.cylinderRadius, true, true, 0.3);
//this.drawBondsAsStick(asu, this.getResiduesById(this.getSidechains(this.getChain(all, ['A'])), P), this.cylinderRadius, this.cylinderRadius);

this.drawCartoon(asu, all, this.curveWidth, this.thickness);

this.drawSymmetryMates2(this.modelGroup, asu, this.protein.biomtMatrices);
this.modelGroup.add(asu);

};

thanks
回复到 #70111

RE: color specific amino acid (2013-11-05 06:17 by biochem_fan #70694)

Your code does looks fine.

Does
this.getResiduesById(this.getSidechains(this.getChain(all, ['A'])), P);
return valid atom ids?

Please also note that to color mainchain (cartoon, ribbon, etc), you have to color CA (alpha carbon) atoms.
That is, you should not use this.getSidechains.
回复到 #70693

RE: color specific amino acid (2013-11-05 07:01 by skumar #70695)

I tried to color by residue id with this code but it is not working..

this.colorByResidue(this.getResiduesById(this.getChain(all, ['A']), P), 0xFF0000);

回复到 #70111

RE: color specific amino acid (2013-11-05 07:17 by skumar #70696)

I have checked
this.getResiduesById(this.getChain(all, ['A']), P)
and it returns correct atom id but somehow problem with coloring.
回复到 #70111

RE: color specific amino acid (2013-11-05 07:54 by skumar #70697)

Thanks..it is working now...
with this code.
this.colorAtoms(this.getResiduesById(this.getChain(all, ['A']), P), 0xFF0000);
回复到 #70111