I have added four string functions and refer to this now as 11.1.16
capabilities.
Jmol Users -- initial documentation for new 11.1.16 capabilities are
given here. Part III.
The new syntax for Jmol scripting "molecular math" allows selection of
sets of atoms and bonds using {...}. By itself, this is not particularly
useful. Yes, you can "save" sets of atoms for later use, and you can
know how many atoms or bonds are there. But the real power of this
syntax comes from what you can do with it on the back end, with the "."
operator, which I will call the "modifier" operator.
First, a few practical examples; then the full list. Note that these
modifiers cannot be used in the SELECT command. They are specifically
for doing operations on the resultant selections. Basically, you can
think of {....} itself as a localized "select" that is used as a basis
for the modifiers.
Examples only:
x = {C10}.ident # the identity of C10 in a standard format
x = {C*}.size # the number of atoms with names starting with C
x = {*}.bondcount # the average bond count
x = {35}.structure # the structure of residue 35
(turn = 1, sheet = 2, helix = 3, unspecified = 0)
set bondmode OR;x = {C10}.bonds #the bonds to carbon 10
Here's the full list, sorted by the TYPE OF VARIABLE they operate on
(before the ".") and, within that grouping, the type of return value:
ATOM SETS
---------
integer: .atomID .atomIndex .atomno .bondcount .elemno
.element .file .formalCharge .groupID
.model .molecule .occupancy .polymerLength .resno
.site .size .structure .symop
decimal: .atomX .atomY .atomZ .distance() .radius .partialCharge
.phi .psi .surfacedistance .temperature .x .y .z
string: .ident .label()
point: .xyz
set of atoms: .max .min
set of bonds: .bonds
Many of these are the same as the atom properties that can be used in
the SELECT command:
select atomno < 3 and atomX > 4.0
x = {atomno < 3}
y = {atomX > 4.0}
All "." operators operate by measuring a quantity for each atom
individually in the atom set.
A few are new:
.distance(x) the (average) distance in Angstroms to point x
x can be anything that can be evaluated to be a point or atom set center:
d = {molecule=1}.distance({0 0 0})
gives the AVERAGE distance of the atoms in molecule 1 to the origin.
d = {molecule=1}.distance({molecule = 2})
gives the AVERAGE distance of the atoms in molecule 1 to the CENTER of
molecule 2. Note that this different from
d = {molecule=2}.distance({molecule = 1})
which is different from the following, which gives a center-to-center
distance:
d = distance({molecule=1}, {molecule=2})
.x .y .z same as .atomX .atomY .atomZ
.size just gives the overall count of atoms in the set
.min and .max
These two modifiers return atom sets containing just one atom. They
are shortcuts to the first and last elements of the set. They are
used in a variety of contexts.
x = {oxygen}.min # the first oxygen atom, same as {oxygen}[1]
x = {oxygen}.max # the last oxygen atom, same as {oxygen}[{oxygen}]
.ident and .label("formatString")
These two modifiers return string data. ".ident" delivers the default
identity label for atoms. .label("format") delivers a label based
on the format string. Mostly this is the format string used for all
labels in the LABEL command, but with a couple of special options.
%# is the index starting with 1 FOR THIS SET OF ATOMS. So, say you
have a model that has several molecules in it. Then, for example,
if you used:
x = {molecule=1}.label("%# %a")
You would get a list that looks like this:
1 C12
2 C13
3 H33
etc. The first line will start with 1 regardless of the actual atom number.
The other special character is %D, which is very special. It only makes
sense in a very specific bond context, discussed below.
For example, XYZ file format for the selected atoms is simply:
data = "" + {selected}.size + "\n\n"+{selected}.label("%-2e %10.5x
%10.5y %10.5z")
That is, the number of atoms, a blank line, and then one line for each
atom, consisting of the element symbol, x, y, and z coordinates.
The list generated is a new-line character-separated set of information.
.xyz returns the AVERAGE position as a point.
x = {molecule=1}.xyz;
y = {molecule=2}.xyz;
draw line1 @x @y
BOND SETS
---------
Bond sets are created using .bonds on an atom set, from the connected(dMin,
dMax...) function, or by use of an explicit bond selector of the format
[{...}].
integer .size
decimal .length
string .ident .label()
atom set .atoms
bond set .min .max
.size just returns the number of bonds in the set.
.length returns the AVERAGE length of the bond.
.ident and .label("formatString") return formatted strings. The trick
here is that because bonds are assocated with atoms, a bond set retains
information about these atoms. All the atom properties are available, as
for atom format strings. One simply adds "1" or "2" after the format
code to indicate which atom is of interest. In addition, the special
codes %D1 and %D2 give the index of the atom IN THIS SET OF ATOMS. In
addition, the two keywords %ORDER and %LENGTH can be used.
For example, MOL file format is:
x = "line1\nline2\nline3\n"
+(""+{selected}.size)%-3+(""+{selected}.bonds.size)%-3 + " 0 0 0\n"
+ {selected}.labels("%10.4x%10.4y%10.4z %-2e 0 0 0 0 0")
+ {selected}.bonds.labels("%3D1%3D2%3ORDER 0 0 0")
STRING FUNCTIONS
----------------
x.find("...") finds the location of "..." in the string (or strng
equivalent) of x.
x.lines produces a set of strings based on new-line characters
in the string
x.replace(y,z) replaces occurances of y with z in the string x
x.size returns the number of characters in the string.
x.split() splits x into lines based on new-line characters.
x.split(y) splits x into lines by splitting at all occurances of y.
x.trim() trims "white space" off both ends of x.
x.trim(y) trims y off of x on both ends of x.
STRING ARRAYS
-------------
x.lines actually creates an array of strings. These can also be the
basis for .find("...") and .size, in which case .find() returns the set
of lines containing the found information, and .size returns the number
of lines. String arrays can also be created using the following syntax:
x = ["line1", "line2", "line3"]
y = x + ["line4"] + {*}.ident.lines
x.find("...") finds the location of "..." on each line of x and returns
an array containing just those lines.
x.join() joins the lines of x into a string with new-line characters
x.replace(y,z) replaces occurances of y with z on each line of x
x.trim(y) trims y off of each line of x on both ends.
Modifiers of modifiers
----------------------
You can string any number of modifiers together:
x = {*}.bonds.ident.lines.find("C3")
xMax = {*}.bonds.length.max
theLongestBond = {*}.bonds.label("%a1 %a2 %LENGTH").lines.find(xMax)
nMolecules = {*}.molecule.max
Note that, in particular, "max" and "min" can be used as special
modifiers that direct Jmol to return something other than the average
value for any atom property or for bond length.
Bob
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users