1
$\begingroup$

I'm importing a *.pdb file containing a single protein. Mathematica automatically produces a plot of the protein.

I want to specify the color of each residue independently, in this plot. Is this possible?

Additionally, I would like to change the type of plot to "cartoon". How can I do this?

$\endgroup$
  • $\begingroup$ Not sure what you mean by "cartoon", and, sadly, the documentation doesn't seem to give much information on the type of ColorFunction that can be used $\endgroup$ – Jason B. Apr 28 '16 at 13:54
  • $\begingroup$ @JasonB "Cartoon" is the name given in Pymol and VMD (other protein visualization software) to the ribbon diagram, with the alpha-helices and so on. $\endgroup$ – becko Apr 28 '16 at 13:59
  • $\begingroup$ It doesn't appear to be have many options other than Import["ExampleData/1PPT.pdb", "Rendering" -> #] & /@ {"BallAndStick", "Structure", "Wireframe", "Spacefilling"} $\endgroup$ – Jason B. Apr 28 '16 at 14:04
4
$\begingroup$

Okay, so this is what it looks like with standard coloring of the residues:

Import["ExampleData/1PPT.pdb", ColorFunction -> "Residue"]

enter image description here

But now, if we want to change the residue colors, we need to change the value of a certain internal color list called Graphics`MoleculePlotDump`residueColorRules

residuelist = {"Gly", "Pro", "Ser", "Gln", "Pro", "Thr", "Tyr", "Pro",
    "Gly", "Asp", "Asp", "Ala", "Pro", "Val", "Glu", "Asp", "Leu", 
   "Ile", "Arg", "Phe", "Tyr", "Asp", "Asn", "Leu", "Gln", "Gln", 
   "Tyr", "Leu", "Asn", "Val", "Val", "Thr", "Arg", "His", "Arg", 
   "Tyr"};
Graphics`MoleculePlotDump`residueColorRules = 
 Thread[residuelist -> (ColorData[97] /@ Range[36])]

enter image description here

Now when we import the PDB, it uses the new color list,

enter image description here

The definition of Graphics`MoleculePlotDump`residueColorRules will be reset when you restart the kernel.

$\endgroup$
  • $\begingroup$ That's useful, but I don't want to color by residue type. I want to color by residue number. Each residue with a particular color $\endgroup$ – becko Apr 28 '16 at 14:39
  • 1
    $\begingroup$ Good luck, there is like zero documentation on the allowable color functions $\endgroup$ – Jason B. Apr 28 '16 at 14:52
1
$\begingroup$

Here is a very hack-ish way of coloring each residue sequentially. The trick is in constructing a Blend[] function where the color corresponding to each residue appears twice in the first argument. A slight shift is apparently needed to match up the colors, even if only approximately.

n = StringLength[First[Import["ExampleData/1PPT.pdb", "Sequence"]]];
clist = PadRight[{}, n, Values[Association[ColorData[97, "ColorRules"]]]];

Import["ExampleData/1PPT.pdb", 
       ColorFunction -> (Directive[GrayLevel[1/10], Specularity[1/5, 10], 
                                   Glow[Blend[Riffle[clist, clist], # - 1/(2 n)]]] &),
       Lighting -> "Classic"]

candied peptide

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.