Graphics commands

The graphics commands create graphical objects that are rendered according to the graphics state at the point in the input file where the command is given. The commands need different arguments, usually an atom or residue selection, and sometimes also some explicit values.


ball-and-stick atom-selection [atom-selection] ;
Draw small spheres and sticks (cylinders) between the selected atoms if they are closer to each other than the value of the bonddistance parameter.

The atom spheres are rendered in the same way as in the cpk command, except that the radii are 1/4 of the atom radii.

If one atom selection is given, then all sticks between atoms within this selection are drawn.

If two atom selections are given, then only sticks connecting an atom in the first selection with an atom in the second selection are drawn, in the same way as for bonds. No spheres are output for any atoms when two atom selections are given.

The stickradius parameter controls the radius of the sticks (cylinders). The colour of the sticks is taken from the planecolour parameter if the colourparts parameter is off, otherwise the atom colours are used for each half of the sticks.

In the PostScript output mode, the sticktaper parameter controls the perspective effect applied to the stick.

Parameters: atomradius, atomcolour, colourparts, planecolour, stickradius, sticktaper, lighting.


bonds atom-selection [atom-selection] ;
Draw lines between the selected atoms if they are closer to each other than the value of the bonddistance parameter. The colour of the lines is given by the parameter linecolour if the parameter colourparts is off, otherwise the atom colours are used.

If one atom selection is given, then all bonds between atoms within this selection are drawn. For those selected atoms that have no bond connecting them to another atom, a cross is drawn instead if the value of the parameter bondcross is non-zero.

If two atom selections are given, then only bonds connecting an atom in the first selection with an atom in the second selection are drawn. This is useful when one single bond distance cutoff is insufficient to give the desired result (for example, the bonds to the Fe atom versus the cross-ring distances in the five-membered rings in heme groups).

Parameters: atomcolour, bondcross, bonddistance, colourparts, depthcue, linecolour, linedash, linewidth, transparency.


cpk atom-selection ;
Draw spheres for the atoms in the selection. The colours and radii of the spheres are taken from the current values for each atom (see parameters atomcolour and atomradius).

For PostScript output, the circle around the sphere is affected by the different line parameters and by the depthcue parameter. The spheres are not actually spheres, but disks. They will therefore not overlap entirely correctly.

For OpenGL output, the quality of the sphere tesselation is affected by the segments parameter.

Parameters: atomradius, atomcolour, colourparts, lighting.


Residue commands

In previous version of MolScript (v1.4 and older), the schematic residue representations could be given only one single colour. In the current, all residue graphics objects (except cylinder) can be coloured on a residue-by-residue basis. The residue colour is set with the residuecolour parameter. The per-residue colouring mode itself is switched on with the colourparts parameter.

All residue commands operate on chains of residues. All of them, except the double-helix command, define a chain of residues as:

  1. Consisting of amino-acid residues
  2. Each residue contains a CA atom
  3. Consecutive residues in a chain are less than 4.2 Ångström apart.
If a selection of residues given to the residue commands contain breaks in the chain, according to the above criteria, then nothing is output for those chain breaks.

The double-helix command operates on nucleotide residues, so the above criteria are different: The residues must be nucleotides, the required atom is P, and the maximum distance is 10.0 Ångström. Otherwise this command works in the same way.

This feature simplifies the creation of residue representations when the coordinates contain chain breaks or missing residues. The output from the MolScript program will be sensible without requiring the user to locate each chain break in a coordinate set.


coil residue-selection ;
Create a smooth coil based on the CA atom positions for the given amino-acid residues. The coil goes through the exact CA positions only at the first and last residues. At least two consecutive CA atoms are needed.

See turn for a variant of coil which does go through each CA position.

The CA coordinates are first copied and smoothed a number of iterations (parameter smoothsteps) using Priestle's algorithm (Priestle 1988). Then a coil with an approximately cylindrical cross-section is created along a curve through the smoothed coordinates.

The radius of the coil is determined by the parameter coilradius. If the value of the coilradius parameter is lower than 0.01, then a curved line is output, which is affected by the different line parameters. The curvature of the coil can be modulated with the splinefactor parameter.

In the PostScript output mode, the coil radius is affected by the depthcue parameter if the slab has been explicitly set.

The colour is taken from the planecolour parameter if the colourparts parameter is switched off, otherwise the residuecolour is used.

Parameters: coilradius, colourparts, linecolour, linedash, linewidth, planecolour, residuecolour, segments, smoothsteps, splinefactor, lighting.


cylinder residue-selection ;
Create a cylinder representation for an alpha-helix. The end-points of the cylinder are computed on the assumption that the selected amino-acid residues form a decent alpha-helix.

At least three consecutive CA atoms are needed. No cylinder is created for shorter polypeptide chains.

The radius is controlled by the cylinderradius parameter. In the current version of MolScript (v2.0.2), it is not possible to colour the cylinder on a residue-by-residue basis. The colour is always taken from the planecolour parameter.

In the PostScript output mode, the subdivision of the cylinder into graphical segments is controlled by the segmentsize parameter.

Parameters: cylinderradius, planecolour, segmentsize, lighting.


double-helix residue-selection ;
Create a smooth coil that goes through the P atom positions for the given nucleotide residues. At least two consecutive P atoms are needed.

The same algorithm is used to create this representation as for the amino-acid residue turn. No smoothing of the P atom positions is done. The coil created by this command therefore goes through the exact P positions.

The radius of the turn is determined by the parameter coilradius. If the value of the coilradius parameter is lower than 0.01, then a curved line is output, which is affected by the different line parameters. The curvature of the turn can be modulated with the splinefactor parameter.

The colour is taken from the planecolour parameter if the colourparts parameter is switched off, otherwise the residuecolour is used.

Parameters: coilradius, colourparts, linecolour, linedash, linewidth, planecolour, residuecolour, segments, splinefactor, lighting.


helix residue-selection ;
Create a smooth helical ribbon through the CA atom positions of the given amino-acid residues. The helixwidth determines the width of the ribbon, which tapers off at the helix terminii to fit the coilradius parameter. Since the helix passes through the CA atom positions, the helix radius cannot be changed.

The helix creation algorithm is optimized for regular alpha-helix, but handles common irregularities like proline bends reasonably well. Only the CA atom coordinates are used to compute the helix.

At least three consecutive CA atoms are needed. No helix is created for shorter polypeptide chains.

The colour of the outer surface of the helix is controlled by the planecolour parameter, while the inner surface uses the plane2colour parameter. If the colourparts parameter is switched on, then the inner and outer surfaces of the helix ribbon are given the same colour for each residue, which is then determined by the residuecolour parameter.

In the PostScript output mode, the shading of the helix ribbon is performed as if the axis of the helix had been rotated into the plane of the paper.

In the Raster3D output mode, the helix has a thickness and a rounded edge controlled by the helixthickness parameter.

Parameters: coilradius, colourparts, helixthickness, helixwidth, planecolour, planecolour, residuecolour, segments, lighting.


strand residue-selection ;
Create a beta-strand arrow that goes through the smoothed CA positions of the selected amino-acid residues. The smoothing of the CA positions is performed in the same way as for coil, and the parameter smoothsteps applies. The strand will not go through the CA positions except at the ends. Only the CA atom coordinates are used for computing the strand position and normal vectors.

At least three consecutive CA atoms are needed. No strand is created for shorter polypeptide chains.

The segments parameter applies, but the actual number of segments created will be (segments / 2) + 1, where the division is integer division. The reason for this is that the curvature for strands is less than for helices, so fewer segments are needed. The strandthickness and strandwidth parameters determine the dimensions of the cross-section of the arrow. If the strandthickness is less than 0.01 Ångström, then an arrow made out of a single surface with no thickness is produced.

The colour of the major strand surface is determined by the planecolour parameter, while the minor strand surface (the arrow side) is controlled by the plane2colour parameter. If the colourparts parameter is switched on, then the major and minor strand surfaces are given the same colour for each residue.

Parameters: coilradius, colourparts, planecolour, planecolour, residuecolour, segments, strandthickness, strandwidth, lighting.


trace residue-selection ;
Draw straight lines between consecutive CA atoms in the polypeptide chain.

The colour is taken from the linecolour parameter if the colourparts parameter is switched off, otherwise from the residuecolour parameter.

Parameters: colourparts, linecolour, linewidth, linedash, depthcue, residuecolour, transparency.


turn residue-selection ;
Create a smooth coil that goes through the CA atom positions for the given amino-acid residues. At least two consecutive CA atoms are needed.

The same algorithm is used to create this representation as for coil, except that no smoothing of the CA positions is performed. The coil created by this command therefore goes through all the exact CA positions.

The radius of the turn is determined by the parameter coilradius. If the value of the coilradius parameter is lower than 0.01, then a curved line is output, which is affected by the different line parameters. The curvature of the turn can be modulated with the splinefactor parameter.

The colour is taken from the planecolour parameter if the colourparts parameter is switched off, otherwise the residuecolour is used.

Parameters: coilradius, colourparts, linecolour, linedash, linewidth, planecolour, residuecolour, segments, splinefactor, lighting.


directionallight vector ;
directionallight from vector to vector ;
Define a directional light source shining in the direction given by the vector, which is either given explicitly, or in the 'from, to' form. The light source has the colour defined by the lightcolour parameter, and the intensity given by the lightintensity parameter.

See the lighting and appearance overview for more information about lighting.

Parameters: lightcolour, lightambientintensity, lightintensity, lighting.


pointlight vector ;
Define a light source with a position, given by the vector, in the coordinate system. The light source has the colour defined by the lightcolour parameter, and the intensity given by the lightintensity parameter. The attenuation function of the light source is determined by the lightattenuation parameter.

See the lighting and appearance overview for more information about lighting.

Parameters: lightambientintensity, lightattenuation, lightcolour, lightintensity, lightradius, lighting.


spotlight vector vector number ;
spotlight vector from vector to vector number ;
Define a light source, a spotlight, with a position and a direction in the coordinate system, emitting a cone of light. The position of the light source is given by the first vector in both forms of the command. The direction of the light is given either by an explicit direction vector (the first form of the command), or by a 'from, to' specification (the second form). The angle of the cone of light is given by the final number, in units of degrees. This must a value in the range 0 to 180.

The light source has the colour defined by the lightcolour parameter, and the intensity given by the lightintensity parameter. The attenuation function of the light source is given by the lightattenuation parameter.

See the lighting and appearance overview for more information about lighting.

Parameters: lightambientintensity, lightattenuation, lightcolour, lightintensity, lightradius, lighting.


anchor string
  [ description string ] [ parameter string ] { basic-commands } ;
The anchor command is relevant only for the VRML 2.0 output mode. It specifies that all the graphics objects created within the curly brackets '{' '}' constitute a Web link for the VRML browser to act upon when the user indicates it (clicks on it, or some other action depending on the browser).

The first string after the anchor keyword is the URL of the Web link. The optional description item is a string that is supposed to be presented in some way by the VRML browser when the user points to, but does not click on, the Web link object. This depends on the browser. The optional parameter item is a string that contains additional information for the browser, such as the name of a frame (a target) for the link contents to be displayed in.

The graphics objects that constitute the Web link are given by the commands within the curly brackets '{' '}'. This is just a way to allow specifying more than one graphical object to form one single Web link. The grouping within the curly brackets '{' '}' in the anchor command has no deeper implication than that. In the other output modes, the commands within the curly brackets '{' '}' are executed as usual, while the anchor keyword and its attendant string values are simply ignored.

Essentially any command is allowed within the curly brackets '{' '}'. The only commands that are disallowed are the light source commands (directionallight, pointlight and spotlight) and the viewpoint command.

Parameters: none


label vector string ;
label atom-selection string ;
The first form of the label command outputs a single label to the given position. The second form of the command outputs labels at the positions of the given atoms in the selection.

The colour of the label characters is determined by the linecolour parameter. In the atom selection variant of the label command, the colours are taken from the atomcolour parameter if the parameter colourparts is switched on.

The size of the label characters is determined by labelsize, which is given in PostScript units. In other output formats, this size is converted into Ångström using a reasonable conversion factor. However, the label size may require adjustment in such cases.

The parameter labelclip determines whether the strings will be hidden by other graphical objects, or will appear as if rendered on top of the rest of the image.

The position of the string can be fine-tuned by the labeloffset parameter. This vector is added to the position (explicit or that of the atoms) before the label is actually put into the image.

In the PostScript output mode, the depthcue parameter applies; labels farther away from the viewer will be smaller. Two other parameters are currently implemented only in the PostScript output mode: The labelcentre parameter defines which point in the string is put at the coordinate: If switched on, the middle of the string is used, otherwise the lower-left point of the string is used. The orientation of the string is controlled by the labelrotation parameter. The labelbackground parameter sets the extent of an area around the edge of the label characters that is filled with the background colour. This makes labels more visible when in cluttered regions.

The string itself is processed in several steps before output as the label. If the command with an atom selection is used, then special format codes in the string are replaced by data from each specified atom. The format codes are:

   %r  name of the residue the atom is in (6 chars)
   %t  type of the residue the atom is in (4 chars)
   %c  one-letter code for res type, X if non-amino acid (1 char)
   %a  atom name (4 chars)
Each of these items can appear only once in the string. The character case of the items are taken as they are in the coordinate file (almost certainly uppercase). This, however, may be changed by the label mask, see below. Any characters that are not format codes in the string will be part of the finally output string, including any space characters. The percent character '%' cannot be output as such in labels generated by the atom selection variant of the label command.

The string thus produced by replacing format codes (if any) is passed through a step that uses a mask to determine whether to change the case of some characters or not, and if they are to be output as Greek characters. The mask is set by the labelmask parameter, and consists of a string where a flag is set for each character position.

The available label mask flags are:

   r  Roman characters (default)
   g  Greek characters
  ' ' (blank) no change of character case (default)
   l  change character to lowercase
   u  change character to uppercase
The 'r' and 'g' flags are independent of the ' ', 'l' and 'u' flags. When setting the labelmask parameter, note that a character flag has to be in exactly the correct position in the string for correct processing. Note that to get the Greek characters normally used for amino-acid residue atoms, the characters will have to be changed to lowercase as well.

The final processing step consists of squeezing out space characters that were part of the residue name or type, or the atom name, derived from format codes. Note the order of operations: The label mask is applied first, and only afterwards are blanks removed. Otherwise it would be impossible to predict the effect of the label mask.

Two examples of string processing:

  'LABEL'
  'lABEL'   after applying mask 'l'

  '%r.%a'        in an atom selection label command (dot means blank)
  '123....CA..'  after replacing the format codes for an atom
  '123....Ca..'  after applying mask '........l..'
  '123.Ca'       after squeezing out of spaces from format code items

Parameters: atomcolour, colourparts, depthcue, linecolour, labelbackground, labelcentre, labelclip, labelmask, labeloffset, labelrotation, labelsize.


line vector { to vector } ;
Draw a connected line from the first vector to the following vectors. Any number of vectors may be given.

Note that the coordinates will not be transformed in any way; they are in the fixed coordinate space of MolScript. See object for a way of drawing lines that are affected by a given transformation.

In the PostScript output mode, the lines are recursively subdivided into pieces smaller than the value for the segmentsize parameter.

Parameters: linecolour, linedash, linewidth, segmentsize, transparency.


object string ;
object inline ;
The object command is the interface for importing graphical objects into the MolScript image. The graphical objects must be defined using a simple file format.

The first form of the command is for objects specified in an external file, the name of which is given by the string.

The second form allows the objects to be specified in the MolScript input file itself. The format of this inline object specification is the same as for the external object file. Similarly as for the 'inline-PDB' form of the coordinate read command, the usual syntax rules of the MolScript input file are temporarily inhibited until the end of the inline part of the input file. Note that in this form of the command, the semi-colon ';' ending the command itself must appear before the object specifications are given. There is no semi-colon after the final piece of data in the object specification, which for the inline form must be a 'Q' character (see the object file format description).

The graphical objects that may be specified in the object file are: points, lines, triangles, and triangle strips. The format of the object file is described separately.

The point and line objects are affected by the various line parameters: The linewidth parameter determines the size of the points and the width of the lines (if implemented for the output mode). The linedash parameter affects the lines. The linecolour parameter affects the points and lines, unless there are explicit colours specified in the object file.

The triangle and triangle strip objects are double-sided surfaces (i.e. visible from both sides), which may have surface normals and vertex colours defined explicitly. If no explicit colours are defined, then the planecolour parameter is used. The usual lighting parameters apply to these objects, as does the transparency parameter.

If the objecttransform parameter is switched on, then the coordinates of the objects are transformed by the matrix specified in the latest transform command. This is necessary for objects created in the coordinate system of the original atomic coordinates (i.e. almost all objects) to be displayed in a sensible way together with the graphics objects derived from the view-transformed molecule coordinates. For this to work, the view transformation applied to the molecule coordinates must be defined in one single transform command.

In the PostScript output mode, the lines and triangles are recursively subdivided into pieces smaller than the value for the segmentsize parameter.

Parameters: linecolour, linedash, linewidth, objecttransform, segmentsize, transparency, lighting.


viewpoint string from vector to vector [ number ] ;
viewpoint string origin vector number ;
The viewpoint command is relevant only for the VRML 2.0 output mode. It specifies a viewpoint, presented in some way by the VRML browser, that helps the user to navigate through the scene under guidance. The string in both forms of the command is a descriptive designation for the viewpoint, which is presented in some way by the VRML browser.

The first form of the command specifies the viewpoint in terms of the position where the user is located (the 'from' vector), and the position towards which the user looks (the 'to' vector).

The second form of the command specifies a viewpoint where the origin of the fixed coordinate system is in the centre, and the position given by the vector is located between the position of the user and the origin. The viewpoint is located at the distance from the position given by the single number.

There is always a default viewpoint defined, called "overall default". This is defined such that the view direction is along a vector anti-parallel to the z axis of the fixed coordinate system, looking towards the approximate center of the entire set of graphics objects. The position of the viewer is at such a distance so that almost all graphics objects are visible.

Parameters: none


Top page