Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 70 additions & 9 deletions doc/cpptraj.lyx
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ numlist} e.g.
\begin_inset space ~
\end_inset

op><distance> Selection by distance, see below.
operator><distance> Selection by distance, see below.
\end_layout

\begin_layout Standard
Expand Down Expand Up @@ -1667,14 +1667,72 @@ More examples:
Distance-based Masks
\end_layout

\begin_layout Description
<mask><distance
\begin_inset space ~
\end_inset

operator><distance>
\end_layout

\begin_deeper
\begin_layout Description
<mask> Atoms to consider.
\end_layout

\begin_layout Description
<distance
\begin_inset space ~
\end_inset

operator> Distance operator.

\family typewriter
{<|>}{@|:|;|^}
\end_layout

\begin_deeper
\begin_layout Description
< Distances less than <distance> will be selected.
\end_layout

\begin_layout Description
> Distances greater than or equal to <distance> will be selected.
\end_layout

\begin_layout Description
@ Any atom.
\end_layout

\begin_layout Description
: Any atom within a residue.
\end_layout

\begin_layout Description
; Residue geometric center.
\end_layout

\begin_layout Description
^ Any atom within a molecule.
\end_layout

\end_deeper
\begin_layout Description
<distance> The distance criteria in Angstroms.
\end_layout

\end_deeper
\begin_layout Standard
There are two very important things to keep in mind when using distance
based masks:
\end_layout

\begin_layout Enumerate
Distance-based masks that update each frame are currently only supported
by the
Distance-based masks that
\bar under
update each frame
\bar default
are currently only supported by the
\series bold
\shape italic
mask
Expand Down Expand Up @@ -1744,7 +1802,7 @@ The syntax for selection by distance is a
\series bold
:
\series default
' (residues), or '
' (residues), ';' (residue centers), or '
\series bold
@
\series default
Expand All @@ -1762,9 +1820,11 @@ residues within 3.0 Angstroms
\end_inset

etc.
For residue- and molecule-based distance selection, if any atom in that
residue/molecule matches the given distance criterion, the entire residue/molec
ule is selected.
For ':' residue- and '^' molecule-based distance selection, if any atom
in that residue/molecule meets the given distance criterion, the entire
residue/molecule is selected.
For ';' residue center, the geometric center of the residue must meet the
given distance criterion in order to be selected.
\end_layout

\begin_layout Standard
Expand Down Expand Up @@ -27367,8 +27427,9 @@ Determine hydrogen bonds in each coordinate frame using simple geometric
criteria.
A hydrogen bond is defined as being between an acceptor heavy atom A, a
donor hydrogen atom H, and a donor heavy atom D.
If the A to D distance is less than the distance cutoff and the A-H-D angle
is greater than the angle cutoff a hydrogen bond is considered formed.
If the A to D distance is less than or equal to the distance cutoff and
the A-H-D angle is greater than or equal to the angle cutoff a hydrogen
bond is considered formed.
Imaging of distances/angles is not performed by default, but can be turned
on using the
\series bold
Expand Down
4 changes: 3 additions & 1 deletion src/Exec_Help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ int Exec_Help::Masks(ArgList& argIn) const {
" >@ means 'atoms outside of'\n"
" <: means 'residues within'\n"
" >: means 'residues outside of'\n"
" <; means 'residue centers within'\n"
" >; means 'residue centers outside of'\n"
" <^ means 'molecules within'\n"
" >^ means 'molecules outside of'\n"
" <distance> : Cutoff for distance operator.\n"
" <distance> : Cutoff for distance operator (in Ang.).\n"
" E.g. ':11-17<@2.4' means 'select atoms within 2.4 Ang. distance of atoms\n"
" selected by ':11-17' (residues numbered 11 through 17).\n"
" *** Operators ***\n"
Expand Down
56 changes: 52 additions & 4 deletions src/MaskToken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ int MaskToken::SetToken( MaskTokenType typeIn, std::string const& tokenString )
return 0;
}

/** Distance by distance. [<|>][@|:|^]<dist> */
/** Distance by distance. [<|>][@|:|;|^]<dist> */
int MaskToken::SetDistance(std::string const& distop) {
if (distop.empty()) return 1;
type_ = OP_DIST;
Expand All @@ -151,11 +151,13 @@ int MaskToken::SetDistance(std::string const& distop) {
mprinterr("Error: Malformed distance operator: expected '<' or '>' (%c)\n",distop[0]);
return 1;
}
// 2nd char indidcates atoms (@), residues (:), or molecules (^)
// 2nd char indidcates atoms (@), residues (:), molecules (^), residue centers (;)
if (distop[1]=='@')
distOp_ = BY_ATOM;
else if (distop[1]==':')
distOp_ = BY_RES;
else if (distop[1]==';')
distOp_ = BY_RESCENTER;
else if (distop[1]=='^')
distOp_ = BY_MOL;
else {
Expand Down Expand Up @@ -278,14 +280,14 @@ int MaskTokenArray::Tokenize() {
}

infix += *p;

// Distance-based masks
if ( *p == '>' || *p == '<' ) {
buffer.assign("([");
buffer += *p;
++p;
buffer += *p;
flag = 3;
if ( *p != ':' && *p != '@' && *p != '^' ) {
if ( *p != ':' && *p != '@' && *p != '^' && *p != ';' ) {
--p;
mprinterr("Error: Tokenize: Wrong syntax for distance mask [%c]\n",*p);
return 1;
Expand Down Expand Up @@ -837,6 +839,52 @@ int MaskTokenArray::SelectDistance(const double* REF, char *mask,
} // END loop over all residues
# ifdef _OPENMP
} // END pragma omp parallel
# endif
} else if (token.DistOp() == MaskToken::BY_RESCENTER) {
// Select by residue center
int n_of_res = (int)residues.size();
int resi;
// Loop over all residues
# ifdef _OPENMP
# pragma omp parallel private(resi)
{
# pragma omp for
# endif
for (resi = 0; resi < n_of_res; resi++) {
// Initial state
char schar = char0;
int atomi = residues[resi].FirstAtom();
const double* i_crd = REF + (atomi * 3);
double resxyz[3];
resxyz[0] = 0;
resxyz[1] = 0;
resxyz[2] = 0;
// Loop over residue atoms
for (; atomi != residues[resi].LastAtom(); atomi++, i_crd += 3) {
resxyz[0] += i_crd[0];
resxyz[1] += i_crd[1];
resxyz[2] += i_crd[2];
}
double nresatoms = (double)residues[resi].NumAtoms();
resxyz[0] /= nresatoms;
resxyz[1] /= nresatoms;
resxyz[2] /= nresatoms;
// Loop over initially selected atoms
for (Uarray::const_iterator idx = Idx.begin(); idx != Idx.end(); ++idx) {
double d2 = DIST2_NoImage(resxyz, REF + *idx);
if (d2 < dcut2) {
// State changes
schar = char1;
break;
}
} // END loop over initially selected atoms
// Set residue selection status
for (atomi = residues[resi].FirstAtom();
atomi != residues[resi].LastAtom(); atomi++)
mask[atomi] = schar;
} // END loop over all residues
# ifdef _OPENMP
} // END pragma omp parallel
# endif
} else {
// Select by molecule
Expand Down
2 changes: 1 addition & 1 deletion src/MaskToken.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MaskToken {
MolNum,
SelectAll, OP_AND, OP_OR, OP_NEG, OP_DIST
};
enum DistOpType { BY_ATOM = 0, BY_RES, BY_MOL };
enum DistOpType { BY_ATOM = 0, BY_RES, BY_MOL, BY_RESCENTER };
MaskToken();
const char *TypeName() const;
void Print() const;
Expand Down
2 changes: 1 addition & 1 deletion src/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Whenever a number that precedes <revision> is incremented, all subsequent
* numbers should be reset to 0.
*/
#define CPPTRAJ_INTERNAL_VERSION "V6.0.0"
#define CPPTRAJ_INTERNAL_VERSION "V6.0.1"
/// PYTRAJ relies on this
#define CPPTRAJ_VERSION_STRING CPPTRAJ_INTERNAL_VERSION
#endif
125 changes: 125 additions & 0 deletions test/Test_DistBasedMask/Eighth.pdb.1.save
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
ATOM 1 N GLU 5 -2.795 4.872 -1.106 1.00 0.00 N
ATOM 2 H GLU 5 -2.278 5.708 -1.339 1.00 0.00 H
ATOM 3 CA GLU 5 -2.535 3.723 -1.950 1.00 0.00 C
ATOM 4 HA GLU 5 -3.007 2.948 -1.346 1.00 0.00 H
ATOM 5 CB GLU 5 -3.413 3.524 -3.183 1.00 0.00 C
ATOM 6 HB2 GLU 5 -3.139 4.141 -4.038 1.00 0.00 H
ATOM 7 HB3 GLU 5 -4.386 3.787 -2.767 1.00 0.00 H
ATOM 8 CG GLU 5 -3.470 2.108 -3.748 1.00 0.00 C
ATOM 9 HG2 GLU 5 -2.447 1.793 -3.953 1.00 0.00 H
ATOM 10 HG3 GLU 5 -4.039 2.425 -4.623 1.00 0.00 H
ATOM 11 CD GLU 5 -4.189 1.123 -2.837 1.00 0.00 C
ATOM 12 OE1 GLU 5 -3.803 0.771 -1.702 1.00 0.00 O
ATOM 13 OE2 GLU 5 -5.263 0.601 -3.207 1.00 0.00 O
ATOM 14 C GLU 5 -1.058 3.518 -2.255 1.00 0.00 C
ATOM 15 O GLU 5 -0.301 4.414 -2.619 1.00 0.00 O
ATOM 16 N ASN 6 -0.668 2.265 -2.009 1.00 0.00 N
ATOM 17 H ASN 6 -1.323 1.656 -1.539 1.00 0.00 H
ATOM 18 CA ASN 6 0.639 1.696 -2.267 1.00 0.00 C
ATOM 19 HA ASN 6 1.239 2.453 -2.772 1.00 0.00 H
ATOM 20 CB ASN 6 1.412 1.366 -0.993 1.00 0.00 C
ATOM 21 HB2 ASN 6 2.224 0.703 -1.291 1.00 0.00 H
ATOM 22 HB3 ASN 6 0.712 0.882 -0.311 1.00 0.00 H
ATOM 23 CG ASN 6 2.154 2.550 -0.391 1.00 0.00 C
ATOM 24 OD1 ASN 6 2.809 3.347 -1.058 1.00 0.00 O
ATOM 25 ND2 ASN 6 2.359 2.519 0.928 1.00 0.00 N
ATOM 26 HD21 ASN 6 1.869 1.897 1.556 1.00 0.00 H
ATOM 27 HD22 ASN 6 3.024 3.196 1.272 1.00 0.00 H
ATOM 28 C ASN 6 0.509 0.488 -3.185 1.00 0.00 C
ATOM 29 O ASN 6 -0.457 -0.250 -3.004 1.00 0.00 O
ATOM 30 N GLY 7 1.463 0.247 -4.087 1.00 0.00 N
ATOM 31 H GLY 7 2.372 0.658 -3.932 1.00 0.00 H
ATOM 32 CA GLY 7 1.399 -0.902 -4.967 1.00 0.00 C
ATOM 33 HA2 GLY 7 2.180 -0.882 -5.728 1.00 0.00 H
ATOM 34 HA3 GLY 7 0.501 -0.799 -5.576 1.00 0.00 H
ATOM 35 C GLY 7 1.448 -2.275 -4.313 1.00 0.00 C
ATOM 36 O GLY 7 0.727 -2.576 -3.364 1.00 0.00 O
ATOM 37 N LYS 8 2.361 -3.118 -4.801 1.00 0.00 N
ATOM 38 H LYS 8 3.080 -2.784 -5.426 1.00 0.00 H
ATOM 39 CA LYS 8 2.541 -4.514 -4.458 1.00 0.00 C
ATOM 40 HA LYS 8 1.627 -5.015 -4.138 1.00 0.00 H
ATOM 41 CB LYS 8 3.123 -5.283 -5.641 1.00 0.00 C
ATOM 42 HB2 LYS 8 2.435 -5.243 -6.486 1.00 0.00 H
ATOM 43 HB3 LYS 8 3.335 -6.318 -5.372 1.00 0.00 H
ATOM 44 CG LYS 8 4.416 -4.746 -6.248 1.00 0.00 C
ATOM 45 HG2 LYS 8 5.308 -4.960 -5.660 1.00 0.00 H
ATOM 46 HG3 LYS 8 4.393 -3.674 -6.439 1.00 0.00 H
ATOM 47 CD LYS 8 4.726 -5.503 -7.536 1.00 0.00 C
ATOM 48 HD2 LYS 8 3.992 -5.272 -8.308 1.00 0.00 H
ATOM 49 HD3 LYS 8 4.584 -6.543 -7.241 1.00 0.00 H
ATOM 50 CE LYS 8 6.148 -5.338 -8.066 1.00 0.00 C
ATOM 51 HE2 LYS 8 6.521 -6.290 -8.444 1.00 0.00 H
ATOM 52 HE3 LYS 8 6.848 -5.025 -7.290 1.00 0.00 H
ATOM 53 NZ LYS 8 6.177 -4.420 -9.214 1.00 0.00 N
ATOM 54 HZ1 LYS 8 6.046 -3.547 -8.722 1.00 0.00 H
ATOM 55 HZ2 LYS 8 7.131 -4.392 -9.546 1.00 0.00 H
ATOM 56 HZ3 LYS 8 5.471 -4.550 -9.925 1.00 0.00 H
ATOM 57 C LYS 8 3.512 -4.519 -3.286 1.00 0.00 C
ATOM 58 O LYS 8 4.624 -5.042 -3.286 1.00 0.00 O
ATOM 59 N TRP 9 2.925 -4.256 -2.116 1.00 0.00 N
ATOM 60 H TRP 9 2.010 -3.879 -2.316 1.00 0.00 H
ATOM 61 CA TRP 9 3.341 -4.262 -0.728 1.00 0.00 C
ATOM 62 HA TRP 9 4.410 -4.045 -0.724 1.00 0.00 H
ATOM 63 CB TRP 9 2.625 -3.068 -0.104 1.00 0.00 C
ATOM 64 HB2 TRP 9 1.589 -3.294 0.148 1.00 0.00 H
ATOM 65 HB3 TRP 9 2.835 -2.194 -0.721 1.00 0.00 H
ATOM 66 CG TRP 9 3.288 -2.462 1.091 1.00 0.00 C
ATOM 67 CD1 TRP 9 2.925 -2.436 2.393 1.00 0.00 C
ATOM 68 HD1 TRP 9 1.949 -2.799 2.678 1.00 0.00 H
ATOM 69 NE1 TRP 9 3.855 -1.845 3.224 1.00 0.00 N
ATOM 70 HE1 TRP 9 3.885 -1.848 4.234 1.00 0.00 H
ATOM 71 CE2 TRP 9 4.827 -1.303 2.408 1.00 0.00 C
ATOM 72 CZ2 TRP 9 5.911 -0.471 2.714 1.00 0.00 C
ATOM 73 HZ2 TRP 9 6.139 -0.156 3.721 1.00 0.00 H
ATOM 74 CH2 TRP 9 6.841 -0.141 1.722 1.00 0.00 C
ATOM 75 HH2 TRP 9 7.725 0.405 2.018 1.00 0.00 H
ATOM 76 CZ3 TRP 9 6.584 -0.590 0.421 1.00 0.00 C
ATOM 77 HZ3 TRP 9 7.231 -0.235 -0.368 1.00 0.00 H
ATOM 78 CE3 TRP 9 5.424 -1.297 0.082 1.00 0.00 C
ATOM 79 HE3 TRP 9 5.139 -1.465 -0.946 1.00 0.00 H
ATOM 80 CD2 TRP 9 4.479 -1.620 1.069 1.00 0.00 C
ATOM 81 C TRP 9 2.945 -5.593 -0.105 1.00 0.00 C
ATOM 82 O TRP 9 3.022 -6.675 -0.682 1.00 0.00 O
ATOM 83 N THR 10 2.531 -5.609 1.164 1.00 0.00 N
ATOM 84 H THR 10 2.711 -4.794 1.731 1.00 0.00 H
ATOM 85 CA THR 10 2.254 -6.874 1.815 1.00 0.00 C
ATOM 86 HA THR 10 2.982 -7.667 1.644 1.00 0.00 H
ATOM 87 CB THR 10 2.207 -6.622 3.320 1.00 0.00 C
ATOM 88 HB THR 10 1.722 -5.667 3.526 1.00 0.00 H
ATOM 89 CG2 THR 10 1.456 -7.659 4.149 1.00 0.00 C
ATOM 90 HG21 THR 10 1.581 -7.464 5.214 1.00 0.00 H
ATOM 91 HG22 THR 10 0.402 -7.468 3.946 1.00 0.00 H
ATOM 92 HG23 THR 10 1.725 -8.640 3.755 1.00 0.00 H
ATOM 93 OG1 THR 10 3.460 -6.501 3.954 1.00 0.00 O
ATOM 94 HG1 THR 10 3.385 -6.097 4.822 1.00 0.00 H
ATOM 95 C THR 10 0.889 -7.354 1.344 1.00 0.00 C
ATOM 96 O THR 10 -0.172 -6.760 1.524 1.00 0.00 O
ATOM 97 N LYS 12 -2.344 -9.326 0.949 1.00 0.00 N
ATOM 98 H LYS 12 -2.456 -8.339 0.770 1.00 0.00 H
ATOM 99 CA LYS 12 -3.470 -9.926 1.636 1.00 0.00 C
ATOM 100 HA LYS 12 -3.097 -10.439 2.522 1.00 0.00 H
ATOM 101 CB LYS 12 -4.384 -8.814 2.142 1.00 0.00 C
ATOM 102 HB2 LYS 12 -5.389 -9.112 2.440 1.00 0.00 H
ATOM 103 HB3 LYS 12 -4.439 -8.009 1.409 1.00 0.00 H
ATOM 104 CG LYS 12 -3.799 -8.092 3.352 1.00 0.00 C
ATOM 105 HG2 LYS 12 -2.889 -7.566 3.064 1.00 0.00 H
ATOM 106 HG3 LYS 12 -3.691 -8.724 4.233 1.00 0.00 H
ATOM 107 CD LYS 12 -4.848 -7.024 3.650 1.00 0.00 C
ATOM 108 HD2 LYS 12 -5.691 -7.411 4.222 1.00 0.00 H
ATOM 109 HD3 LYS 12 -5.130 -6.495 2.740 1.00 0.00 H
ATOM 110 CE LYS 12 -4.108 -6.019 4.529 1.00 0.00 C
ATOM 111 HE2 LYS 12 -3.183 -5.635 4.099 1.00 0.00 H
ATOM 112 HE3 LYS 12 -3.885 -6.553 5.452 1.00 0.00 H
ATOM 113 NZ LYS 12 -4.877 -4.802 4.829 1.00 0.00 N
ATOM 114 HZ1 LYS 12 -5.132 -4.305 3.987 1.00 0.00 H
ATOM 115 HZ2 LYS 12 -5.718 -4.968 5.362 1.00 0.00 H
ATOM 116 HZ3 LYS 12 -4.250 -4.263 5.410 1.00 0.00 H
ATOM 117 C LYS 12 -4.395 -10.778 0.779 1.00 0.00 C
ATOM 118 O LYS 12 -4.483 -11.939 1.172 1.00 0.00 O
ATOM 119 N NME 13 -4.832 -10.202 -0.344 1.00 0.00 N
ATOM 120 H NME 13 -4.647 -9.239 -0.587 1.00 0.00 H
ATOM 121 CH3 NME 13 -5.720 -10.866 -1.277 1.00 0.00 C
ATOM 122 HH31 NME 13 -5.591 -11.946 -1.340 1.00 0.00 H
ATOM 123 HH32 NME 13 -6.757 -10.886 -0.942 1.00 0.00 H
ATOM 124 HH33 NME 13 -5.777 -10.358 -2.240 1.00 0.00 H
END
Loading