I am trying to superimpose a PDB file into a 3D plot of points extracted from the PDB model, while making the PDB somewhat transparent for easy viewing of plotted points.
My problems are as follows.
-The scale of the PDB does not match my 3D plot range (RescalingTransform
did not seem to work on the PDB object).
-Opacity
does not seem to work on the PDB object.
My code first plots the data points extracted from the position of 3 atoms (the XYZ coordinates are take directly from the .pdb file.
(* Atom Positions *)
DNA1 := {0.107, 9.352, -1.508}
DNA2 := {-0.696, 12.374, 138.546}
DNA3 := {-5.485, 1.769, 200.290}
DNApoints = {DNA1, DNA2, DNA3};
Each point represents the atoms at which a Dye label with a 6 carbon linker strand is attached to a real physical DNA strand matching this .pdb sequence. This linker molecule is flexible enough to allow the Dye label to potentially occupy multiple positions around the DNA atom to which it is attached. To represent this, I added some pretty spheres that enclose the space the label might be able to occupy.
(* Generate Sphere of Points and List of Colors to be used later*)
lColrs = {Darker[Magenta], Darker[Green], Darker[Red]};
lp := Normalize /@ RandomReal[{-1, 1}, {1*10^3, 3}];
I then use the above to generate a Graphics3D object out of several primitives. The three atom positions extracted from the PDB, three pretty spheres of points centered at each atom position and scaled to the length of a 6 carbon alkane chain. And finally, a triangle between the points to aid the eye.
DNAPntsTh := Graphics3D[
{
{Opacity[0.15, Magenta], Translate[Point[7*lp], DNA1]},
{Opacity[0.1, Darker[Green]], Translate[Point[7*lp], DNA2]},
{Opacity[0.1, Red], Translate[Point[7*lp], DNA3]},
{Opacity[0.06, Blue], Polygon[{DNA1, DNA2, DNA3}]},
Thread[{lColrs, Point /@ DNApoints}, Antialiasing -> True]}
}, Axes -> True, AxesLabel -> {"X", Y, Z}
];
I then load the .pdb file
DNApdb = Import["https://pastebin.com/raw/UPk5Gf1z",
{"PDB", "Graphics3D"}, "Rendering" -> "BallAndStick"]
Okay, now for the issue at hand...
When I look at the .pdb by plotting or by using AbsoluteOptions[DNApdb, PlotRange]
, I find that the scale is waaayy off. So I attempted to use Rescaling transform to match up the ranges (not ideal in the first place as the atom positions from the 3D plot are not located at the extremes of the pdb and so therefore will not automatically match up without extra adjustment.)
Anyhow, the command does not seem to scale the image. I use AbsoluteOptions
to get the two data ranges and then attempt to scale the .pdb to the data points.
AbsoluteOptions[DNAPntsTh, PlotRange]
AbsoluteOptions[DNApdb, PlotRange]
PntsThRsc =
RescalingTransform[{{-1086.3, 1004.0}, {-1070.6, 1979.4}, {-161.6,
20161.9}}, {{-5.485, 0.107}, {1.769, 12.374}, {-1.508, 200.29}}];
RescaledPDB = PntsThRsc[DNApdb];
Show[RescaledPDB]
I hope I'm just using RescalingTransform
incorrectly.
Also, attempts to make the pdb graphic object transparent using Opacity[]
has failed to work in the way I am trying to implement it. I am also hoping that I am just trying to use it incorrectly.
Here is an example,
Show[{Opacity[0.3], DNApdb}]
Which will return an error saying that Opacity
is not a Graphic Object. However attempting to combine this command with the .pdb using Graphics3D
also returns an error.
I am grateful for whatever help I can get.
RescalingTransform
andOpacity
to DNApdb the way you do. DNApdb is a Graphics3D object, so you have to do the modifications "inside" it ... I'll give more explanations soon. But first, I don't understand why you try to rescale your dna molecule ? Do your 3 atoms coordinates (DNApoints) correspond exactly to 3 particular atoms in the pdb molecule ? Could you explain better "The Scale of the PDB does not match my 3D plot range" ? $\endgroup$:=
in most places you used it ... $\endgroup$