When I import protein and ligand from two PDB files and display them together using Show I cannot see the ligand since it is tiny in comparison with protein. How can I zoom the MoleculePlot on ligand automatically?
-
Can you provide example code so that people who want to answer don't have to make up an example on their own? Otherwise, MoleculePlot returns a Graphics object, so the same solutions you use for zooming in a Graphics object can be used here as well. – bobthechemist Dec 09 '22 at 13:05
-
have you tried Magnify, Magnification ? – nufaie Dec 09 '22 at 13:55
-
I cannot provide an example since I cannot attach two large files in pdb format – Филипп Цветков Dec 09 '22 at 15:02
-
Magnify, Magnification does not work in this case – Филипп Цветков Dec 09 '22 at 15:06
1 Answers
Clear["Global`*"]
Without a minimal example to work with, I can only suggest a general direction.
img = Import[
"http://www.rcsb.org/pdb/download/downloadFile.do?fileFormat=pdb&\
compression=NO&structureId=1tf6", "PDB", ImageSize -> Large]
EDIT: Added control labels and axes and box ratio controls
{{xmin, xmax}, {ymin, ymax}, {zmin, zmax}} =
Round[Values@AbsoluteOptions[img, PlotRange][[1]]];
Manipulate[
Show[
img,
PlotRange -> {xint, yint, zint},
ImageSize -> Large,
SphericalRegion -> True,
Axes -> axes,
AxesLabel -> (Style[#, 14] & /@ {x, y, z}),
Boxed -> axes,
BoxRatios -> br],
{{xint, {xmin, xmax}, "x interval"}, xmin, xmax, Round[(xmax - xmin)/100],
ControlType -> IntervalSlider,
ImageSize -> Large,
Appearance -> "Labeled"},
Row[{
Control[
{{yint, {ymin, ymax}, "y interval"}, ymin, ymax,
Round[(ymax - ymin)/100],
ControlType -> IntervalSlider,
ImageSize -> Large,
Appearance -> "Labeled"}],
Spacer[20],
Control[
{{br, Automatic, "Box\nRatio"}, {Automatic, {1, 1, 1}}}]}],
Row[{
Control[
{{zint, {zmin, zmax}, "z interval"}, zmin, zmax,
Round[(zmax - zmin)/100],
ControlType -> IntervalSlider,
ImageSize -> Large,
Appearance -> "Labeled"}],
Spacer[40],
Control[
{{axes, False}, {True, False}}]}],
SynchronousUpdating -> False,
TrackedSymbols :> All]
- 157,611
- 7
- 77
- 198
-
Unfortunately, this code just cut the molecule, but not zoom on it. I need to enlarge the particular region centered to the ligand. – Филипп Цветков Dec 12 '22 at 14:38
-
I don't understand your comment. As the plot range is reduced the remaining image is enlarged, i.e., zoomed in on. – Bob Hanlon Dec 12 '22 at 14:55

