Re: [AMBER] Exceed character limit in bellyrestraint mask selection

From: Jason Swails <>
Date: Tue, 15 Oct 2013 12:34:01 -0400

On Tue, Oct 15, 2013 at 11:29 AM, Mike Limb <> wrote:

> Dear AMBER users,
> I am setting up a QM/MM optimisation for a protein ligand system with
> explicit solvent.
> My QM region consists of 50 atoms (a ligand and two residue side chains)
> and the rest of the system is treated with MM.
> Within the MM region I would like to fix the positions of all the atoms of
> any residues that are not within 10 A of the QM region. To do this I would
> like to use the ibelly restraint. However, the problem arises here, as the
> most economically way I can think to specify the moving atoms (using
> residue numbers) in the bellyrestraint selection mask, still far exceeds
> the 256 character limit imposed for the mask selection.

There is usually a way to beat this limit simply by making your mask
smaller. Adjusting the mask length in the code is not as trivial as it
should be, since it is hard-coded (as 256) in a couple places, most notably
throughout the mask parser.

A couple tips:

1) Use residue ranges when possible. For example,


is equivalent to


but is far shorter ;). You can also do combinations of ranges


2) Use relational operators (!, &, |) . Specifically the 'not' operator is
quite helpful. If you want to select all residues _except_ certain ones,
do something like


Which will match all residues except numbers 1, 2, 3, 4, 5, 6, 8, 9, and 10.

3) Use distance mask selections. If you want to select all residues within
10 Angstroms of a particular atom, do something like this:

(.20 < :10.0)

This will select all residues within 10 angstroms of atom number 20.
 Another example:

(:20 < .10.0)

This will select all atoms within 10 angstroms of residue number 20.

Any and all of these can be combined. For instance,

(.20 < :10) & :WAT

will select all atoms that are in water residues within 10 angstroms of
atom number 20. If there is absolutely no way to shorten your mask, then
see below.

> I have thought about trying to rename all the residues I want to select as
> a separate residue number however,I believe, this would result in errors
> when generating a topology file.

Speaking from experience, you will likely regret this choice. ParmEd
makes it easier and safer (since you can adjust atom and residue names
after tleap has built the topology file, but you will never get this
through tleap, and you never know when a program may require those names be
at least close to correct).

> Looking through the mailing list archive I saw one solution purposed for a
> user with a similar problem where she was instead limited by a restraint
> mask limit was :
> "Use the "old style" restraints, i.e. using the group syntax, without the
> restraintmask"
> but I don't understand what is meant by "using the group syntax, without
> the restraintmask" and whether it is a viable solution to my problem!

Yes, it is a viable solution. It is a different (and older) way of making
atom selections in sander and pmemd. It is actually reasonably powerful
(and allows you to do one or two things that the mask syntax does not, like
apply different restraint weights to different atom selections when using
positional restraints). However, it requires that you learn a new syntax
(and you typically need to know Amber masks when using ptraj or cpptraj,

The syntax for making 'group'-based selections is found as an appendix in
the Amber 12 manual.


Jason M. Swails
Rutgers University
Postdoctoral Researcher
AMBER mailing list
Received on Tue Oct 15 2013 - 10:00:02 PDT
Custom Search