Re: [AMBER] closest command in cpptraj

From: Daniel Roe <>
Date: Fri, 21 Aug 2015 15:46:05 -0600


This is certainly an interesting problem! Unfortunately it's not one
that the 'closest' command can currently handle (need to pop another
thing on the to-do list).

However, you might be able to get what you want using two 'closest'
commands and combinecrd. Something like this:

# Load topology, mark A as solvent, get closest 10
parm myparm.parm7
solvent :A
loadcrd ClosestA
crdaction ClosestA closest 10 <mask>

# Reload topology, mark B as solvent, get closest 15
clear parm
parm myparm.parm7
solvent :B
loadcrd ClosestB
crdaction ClosestB closest 15 <mask>
strip <mask>

# Combine COORDS sets, write topology and trajectory
combinecrd ClosestA ClosestB parmname CombinedParm crdname Combined
# parmindex 1 should be the combined parm
parmwrite out Combined.parm7 1
crdout Combined

In this case you should (hopefully) end up with Combined.parm7 and which contains your solute, 10 of A, and 15 of B. Note
that I have not tested this input so I'll be surprised if it works off
the bat, but in theory it should work. Try it on a small subset of
your trajectory (say 10 frames or so) first.

Also note DO NOT use the topology generated this way for anything but
analysis/visualization since 'combinecrd' does not deal with

Hope this helps,


On Fri, Aug 21, 2015 at 1:31 PM, Joseph Baker <> wrote:
> Hi all,
> I have a system with a solute and a two-component solvent (let's say the
> solvent residues are A and B). I'd like to produce a trajectory/topology
> file pair with just the solute and the N closest A molecules and M closest
> B molecules to the solute. It doesn't seem that using the solvent and
> closest commands in cpptraj I am able to get both of these simultaneously
> (note that A and B have different numbers of atoms). Is there some way to
> do this within cpptraj that I am missing?
> Thanks,
> Joe
> --
> Joseph Baker, PhD
> Assistant Professor
> Department of Chemistry
> C101 Science Complex
> The College of New Jersey
> Ewing, NJ 08628
> Phone: (609) 771-3173
> Web:
> <>
> _______________________________________________
> AMBER mailing list

Daniel R. Roe, PhD
Department of Medicinal Chemistry
University of Utah
30 South 2000 East, Room 307
Salt Lake City, UT 84112-5820
(801) 587-9652
(801) 585-6208 (Fax)
AMBER mailing list
Received on Fri Aug 21 2015 - 15:00:03 PDT
Custom Search