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
11 changes: 10 additions & 1 deletion doc/cpptraj.lyx
Original file line number Diff line number Diff line change
Expand Up @@ -15596,7 +15596,7 @@ Options for pdb format
\end_layout

\begin_layout LyX-Code
[include_ep] [conect] [keepext] [usecol21]
[include_ep] [conect] [conectmode <m>] [keepext] [usecol21]
\end_layout

\begin_layout LyX-Code
Expand Down Expand Up @@ -15698,6 +15698,15 @@ include_ep Include extra points.
conect Write CONECT records for all bonds.
\end_layout

\begin_layout Description
conectmode
\begin_inset space ~
\end_inset

<m> Write CONECT records for <m>='all' (all bonds), 'het' (HETATM only),
'none' (no CONECT).
\end_layout

\begin_layout Description
keepext Keep filename extension; write '<name>.<num>.<ext>' instead (implies
'multi').
Expand Down
24 changes: 21 additions & 3 deletions src/Traj_PDBfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ void Traj_PDBfile::WriteHelp() {
"\tchainid <c> : Write character 'c' in chain ID column.\n"
"\tsg <group> : Space group for CRYST1 record, only if box coordinates written.\n"
"\tinclude_ep : Include extra points.\n"
"\tconect : Write CONECT records using bond information.\n"
"\tconect : Write CONECT records using bond information (if 'pdbres', only for HETATM).\n"
"\tconectmode <m> : Write CONECT records for <m>='all' (all bonds), 'het' (HETATM only), 'none' (no CONECT).\n"
"\tkeepext : Keep filename extension; write '<name>.<num>.<ext>' instead (implies 'multi').\n"
"\tusecol21 : Use column 21 for 4-letter residue names.\n"
"\tbfacdefault <#> : Default value to use in B-factor column (default 0).\n"
Expand Down Expand Up @@ -291,6 +292,20 @@ int Traj_PDBfile::processWriteArgs(ArgList& argIn, DataSetList const& DSLin) {
conectMode_ = HETATM_ONLY;
else
conectMode_ = NO_CONECT;
// Override conect mode
std::string conectmode = argIn.GetStringKey("conectmode");
if (!conectmode.empty()) {
if (conectmode == "all")
conectMode_ = ALL_BONDS;
else if (conectmode == "het")
conectMode_ = HETATM_ONLY;
else if (conectmode == "none")
conectMode_ = NO_CONECT;
else {
mprinterr("Error: Unrecognized keyword for 'conectmode': %s\n", conectmode.c_str());
return 1;
}
}
prependExt_ = argIn.hasKey("keepext"); // Implies MULTI
if (prependExt_) pdbWriteMode_ = MULTI;
space_group_ = argIn.GetStringKey("sg");
Expand Down Expand Up @@ -472,7 +487,7 @@ int Traj_PDBfile::setupTrajout(FileName const& fname, Topology* trajParm,
resIsHet_.reserve( trajParm->Nres() );
ss_residues_.clear();
ss_atoms_.clear();
if (pdbres_) {
if (pdbres_ || conectMode_ == HETATM_ONLY) {
Iarray cys_idxs_; ///< Hold CYS residue indices
for (Topology::res_iterator res = trajParm->ResStart();
res != trajParm->ResEnd(); ++res)
Expand Down Expand Up @@ -536,7 +551,10 @@ int Traj_PDBfile::setupTrajout(FileName const& fname, Topology* trajParm,
else if (rname[0] == 'C') rname=" DC ";
}
}
resNames_.push_back( rname );
if (pdbres_)
resNames_.push_back( rname );
else
resNames_.push_back( res->Name() );
// Any non-standard residue should get HETATM
if ( rname == "CYS " )
// NOTE: Comparing to CYS works here since HETATM_ONLY is only active
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 "V4.29.6"
#define CPPTRAJ_INTERNAL_VERSION "V4.29.7"
/// PYTRAJ relies on this
#define CPPTRAJ_VERSION_STRING CPPTRAJ_INTERNAL_VERSION
#endif
4 changes: 3 additions & 1 deletion test/Test_PDB/RunTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

CleanFiles pdb.in test.pdb tz2.pqr.gb.pdb tz2.pqr.parse.pdb \
tz2.pqr.vdw.pdb chainA.dat oresnum.dat tz2.plain.pdb \
2b5t.fromparm.pdb altloca.pdb
2b5t.fromparm.pdb altloca.pdb tz2.het.pdb

INPUT="-i pdb.in"

Expand Down Expand Up @@ -40,12 +40,14 @@ trajout tz2.pqr.parse.pdb parse # PARSE radii
trajout tz2.pqr.vdw.pdb dumpr* # VDW radii
# Test default chain ID write
trajout tz2.plain.pdb pdbres
trajout tz2.het.pdb conectmode het
EOF
RunCpptraj "$UNITNAME"
DoTest tz2.pqr.gb.pdb.save tz2.pqr.gb.pdb
DoTest tz2.pqr.parse.pdb.save tz2.pqr.parse.pdb
DoTest tz2.pqr.vdw.pdb.save tz2.pqr.vdw.pdb
DoTest tz2.plain.pdb.save tz2.plain.pdb
DoTest tz2.het.pdb.save tz2.het.pdb
fi
}

Expand Down
Loading