# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # INITIAL VALUES bannerMessage2 = "More at MolecularPlayground.Org" # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # INITIALIZE JMOL BEFORE EACH CYCLE OF A SCRIPT # AS THOUGH JMOL WAS JUST INVOKED: # NOTHING SHOULD BE INHERITED FROM THE PREVIOUS SCRIPT CYCLE. # IN PARTICULAR, ECHOS SHOULD BE TURNED OFF, ANIMATION STOPPED, # AND ANTIALIASDISPLAY OFF. function initializeBeforeEachCycle(zapMode) { # 'zap' clears all models, does 'set echo off', 'animation mode once', # 'frame 1', and 'animation off' in Jmol 11.6 and 11.9. if (zapMode != "nozap") { zap } # 'zap' does not restore windowcentered to true in Jmol 11.8.9. set windowcentered true # 'set antialiasdisplay off' is done by 'initialize' in Jmol 11.8. # NB: initialize clears all variables, so they must be defined # afterwards. Since some variables may be defined before this function # is called, best not to use "initialize"! set antialiasdisplay off # SETUP DEFAULT SPINNING (BUT DON'T TURN IT ON) set spinX 0; set spinY 5; set spinZ 0; set spinFps 30; # Typical dimensions for Jmol applet in Proteopedia are 450w x 350h pixels. # Projection is 768 pixels high. # Turning zoomLarge off makes zooms scale to the shortest dimension # of the Jmol rectangle. set zoomLarge off # ALTERNATIVELY (BOB HANSON'S RECOMMENDATION) # Instead of the code above in this function, we could # 'save state initialState' immediately after Jmol invocation and # then 'restore state initialState' before each script cycle. # DEFINE VARIABLES AND VALUES initializeVariables } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function initializeVariables # User-defined variables { # Everything here can be done before the PDB file is loaded. jmolSmall = false echoFontSize = 24 echoColorKeyFontSize = 22 colorKeyTopVertPct = 86 colorKeyLineHeightPct = 4 labelBigFontSize = 24 labelFontSize = 20 bannerSpaces = " " # 20 spaces # The applet is small. By using _height instead of _applet, we can # test the script in a small Jmol application as well as the large one. # BUG: Jmol through 11.8.12 / 11.9.10, "initialize" wipes out _height. # Use _applet for now. #if (_height < 401) if (_applet) { jmolSmall = true echoFontSize = 12 echoColorKeyFontSize = 16 colorKeyTopVertPct = 80 colorKeyLineHeightPct = 6 # labelBigFontSize = 24 labelFontSize = 16 bannerSpaces = " " # 10 spaces } } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function initializeMolecule { # These operations must be done AFTER the PDB file is loaded. colorAllLightCPK } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # DEFINE LIGHT ELEMENT (CPK) COLORS. # Because of the high ambient light in the UMass ISB atrium, lighter # colors show better than do the default Jmol CPK colors. colorCarbon = "[xA8A8A8]" # lighter than Jmol colorNitrogen = "[x5050FF]" # lighter than Jmol colorOxygen = "[xFF3030]" # lighter than Jmol colorSulfur = "[xFFFF30]" # same as Jmol, already light function colorAllLightCPK { select all color carbon @colorCarbon color nitrogen @colorNitrogen color oxygen @colorOxygen color sulfur @colorSulfur } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # TOP BANNER function showBannerAcrossTop(bannerMessage, bannerMessage2) { # Making a full-width white background separate from the text echo # avoids having leading spaces push the text off-center. # WHITE BACKGROUND FULL WIDTH set echo bannerBkg_echo [50 100 %] # top center set echo bannerBkg_echo center font echo @echoFontSize sansserif bold background echo white var spaces4 = bannerSpaces + bannerSpaces + bannerSpaces + bannerSpaces var spaces8 = spaces4 + spaces4 var manySpaces = spaces8 + spaces8 + "|" + spaces4 # cannot concatenate strings in the echo command echo @manySpaces # MESSAGE NOT FULL WIDTH ON TOP OF WHITE BACKGROUND set echo banner_echo [50 100 %] # top center background echo white set echo banner_echo center color echo black font echo @echoFontSize sansserif bold fullMessage = bannerMessage + "|" + bannerMessage2 echo @fullMessage } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function labelAtomWithPointer(theAtom, labelText, labelColor) { select @theAtom # this selects all models set labelGroup color label @labelColor font label @labelFontSize set labelpointer on label @labelText } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - var colorKeyIndex = 1; function elementColorKey(elist) { colorKeyIndex = 1; # used in colorKey() var i = 1; # index of first element in array is 1 # 0th element in array has value of last filled element #while (elist[i] != "") # unfilled elements are blank by default while (i <= elist.size) { if (elist[i] == "C") { colorKey("Carbon", @colorCarbon) } if (elist[i] == "N") { colorKey("Nitrogen", @colorNitrogen) } if (elist[i] == "O") { colorKey("Oxygen", @colorOxygen) } if (elist[i] == "S") { colorKey("Sulfur", @colorSulfur) } i = i + 1 } } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function colorKey(keyText, keyColor) { var vertDrop = colorKeyLineHeightPct * (colorKeyIndex - 1) var vertPct = colorKeyTopVertPct - vertDrop var echoName = "keyEcho" + colorKeyIndex set echo @echoName [0 @vertPct %] # upper left if (backgroundColor == "[x000000]") { background echo black } else { background echo white } background echo translucent 6 color echo @keyColor font echo @echoColorKeyFontSize sansserif bold echo @keyText colorKeyIndex = colorKeyIndex + 1 } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function spinOn { if (@spinDefault) { spin on # reset, rotate turns spin off } } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # NOTE: This function will become unnecessary when Proteopedia is updated # to Jmol 11.8.12 or later. "zoomto 5 [percent-zoom]" is rotatable, and # no longer fights rotation after 11.8.10. function zoomRotatableTo(zoomEnd) # zoomEnd is absolute { var currentZoom = getZoom() var zoomDelta = zoomEnd - currentZoom # in Jmol 11.8.10 try: zoomto 3 @zoomDelta (instead of loops below) if (zoomDelta > 0) { for (zstep = 0; zstep <= @zoomDelta; zstep += 3) { # step <5 makes zoom too slow. zoom +3 # relative zoom delay 0.01 if (jmolSmall && !antialiasdisplay) { delay 0.02 } } } else # negative { for (zstep = 0; zstep >= @zoomDelta; zstep -= 3) { # step <3 makes zoom too slow. zoom -3 # relative zoom delay 0.01 if (jmolSmall && !antialiasdisplay) { delay 0.02 } } } } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function growSpacefill() { spin off for (sfr = 10; sfr < 100; sfr = sfr + 1) { spacefill @sfr % delay 0.015 } spinOn } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function growWireframe(wireMax) { for (var wstep = 0.01; wstep <= @wireMax; wstep += 0.01) { wireframe @wstep spacefill @wstep # for unbonded water oxygen atoms delay 0.04 } } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function getZoom() { return getProperty("orientationInfo.zoom") } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function getY() { return getProperty("orientationInfo.transYPercent") } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Note: this function will become unnecessary when Proteopedia is updated # to Jmol 11.9.10 or later. It can be achieved with zoomto, # without changing zoom, e.g. to slide to x=5 in 3 sec: # zoomto 3 +0 5 0 function slideY(yEnd) { var currentY = getY() if (yEnd > currentY) { for (zstep = currentY; zstep <= @yEnd; zstep += 0.1) { translate y @zstep delay 0.01 if (jmolSmall && !antialiasdisplay) { delay 0.02 } } } else # negative { for (zstep = currentY; zstep >= @yEnd; zstep -= 0.1) { translate y @zstep delay 0.01 if (jmolSmall && !antialiasdisplay) { delay 0.02 } } } } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -