diff --git a/doc/CpptrajManual.pdf b/doc/CpptrajManual.pdf index eb693da4e6..ebd8248f35 100644 Binary files a/doc/CpptrajManual.pdf and b/doc/CpptrajManual.pdf differ diff --git a/doc/DocumentChecksums.txt b/doc/DocumentChecksums.txt index 1bfbe455d4..0390cc2257 100644 --- a/doc/DocumentChecksums.txt +++ b/doc/DocumentChecksums.txt @@ -1,3 +1,3 @@ f6f8cb1a79951d80a9d2656fd9c30f55 CpptrajDevelopmentGuide.lyx -676d7874e4942cf94f91fee003cf3c28 cpptraj.lyx +fb6089fe17cca73c0a3b8914a5590a22 cpptraj.lyx 5d9b5b5ed47a3ded57b6464df99b3585 CpptrajManual.lyx diff --git a/doc/cpptraj.lyx b/doc/cpptraj.lyx index a57985356d..43c6ecee0a 100644 --- a/doc/cpptraj.lyx +++ b/doc/cpptraj.lyx @@ -16345,7 +16345,7 @@ The following topology related commands are available: \begin_layout Standard \align center \begin_inset Tabular - + @@ -16545,6 +16545,26 @@ Print dihedral info for selected atoms. \begin_inset Text +\begin_layout Plain Layout +fixatomnames +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +Attempt to fix duplicate atom names in residues. +\end_layout + +\end_inset + + + + +\begin_inset Text + \begin_layout Plain Layout hmassrepartition \end_layout @@ -16818,7 +16838,8 @@ timap \begin_inset Text \begin_layout Plain Layout -Map a residue onto a user template and write a sorted Amber OFF library; optional dual-topology TI pair. +Map a residue onto a user template and write a sorted Amber OFF library; + optional dual-topology TI pair. \end_layout \end_inset @@ -18063,6 +18084,80 @@ If 4 masks are given instead of 1, and fourth atom in . \end_layout +\begin_layout Subsection +fixatomnames +\end_layout + +\begin_layout LyX-Code +fixatomnames { parm | parmindex <#> | crdset } [] +\end_layout + +\begin_deeper +\begin_layout Description +parm +\begin_inset space ~ +\end_inset + + +\begin_inset space ~ +\end_inset + +| +\begin_inset space ~ +\end_inset + +parmindex +\begin_inset space ~ +\end_inset + +<#> +\begin_inset space ~ +\end_inset + +| +\begin_inset space ~ +\end_inset + +<#> +\begin_inset space ~ +\end_inset + +| +\begin_inset space ~ +\end_inset + +crdset +\begin_inset space ~ +\end_inset + + Topology to change. +\end_layout + +\end_deeper +\begin_layout Standard + +\series bold +WARNING: + THIS COMMAND IS STILL EXPERIMENTAL. + USE AT YOUR OWN RISK. +\end_layout + +\begin_layout Standard +Attempt to fix duplicated atom names in the residues of the specified topology. + If no mask is given, + all residues will be checked. + The algorithm used is extremely simple. + When an atom is found with a duplicated name, + if it has a digit that digit will be incremented. + If multiple digits are present (e.g. + H1N1) the right-most digit will be incremented first. + If no digits are present one will be appended. +\end_layout + \begin_layout Subsection hmassrepartition \end_layout @@ -19418,32 +19513,36 @@ Align atoms in topology tiout \series default is given. - This is intended for preparing residue libraries for thermodynamic integration (TI) of nucleic acids, amino acids, and small molecules, + This is intended for preparing residue libraries for thermodynamic integration (TI) of nucleic acids, + amino acids, + and small molecules, where two (or more) end states must list common atoms in the same order. - For a series of analogs with no predetermined parent, + For a series of analogs with no predetermined parent, + \series bold series \series default - auto-selects a minimum parent that shares the most with the rest, then maps every analog onto it. + auto-selects a minimum parent that shares the most with the rest, + then maps every analog onto it. Unlike \series bold atommap \series default -, a one-to-one correspondence is not required: extra atoms on the target are insertions. +, + a one-to-one correspondence is not required: + extra atoms on the target are insertions. Partial maps are expected and useful. \end_layout \begin_layout Standard -The template atom order -\series emph -is -\series default - the shared-atom order used for mapping. - Any topology can be a template (mol2, Amber OFF unit loaded with +The template atom order is the shared-atom order used for mapping. + Any topology can be a template (mol2, + Amber OFF unit loaded with \series bold readdata \series default -, and so on). +, + and so on). Example ModXNA fragments used by the tests live in \series bold test/Test_TIMap/ @@ -19461,16 +19560,14 @@ template \begin_inset space ~ \end_inset - Parent topology whose -\series emph -current -\series default - atom order is the shared-atom order. - If omitted, + Parent topology whose current atom order is the shared-atom order. + If omitted, + \series bold \series default - is mapped to itself; combine with + is mapped to itself; + combine with \series bold naorder \series default @@ -19491,7 +19588,8 @@ out \series bold maponly \series default - is not given): + is not given): + \series bold .sorted.lib \series default @@ -19503,7 +19601,10 @@ mapout \begin_inset space ~ \end_inset - Write the atom map (output index, target atom, template atom, insertion flag). + Write the atom map (output index, + target atom, + template atom, + insertion flag). \end_layout \begin_layout Description @@ -19519,7 +19620,8 @@ maponly Write the map (and \series bold tiout \series default - files, if requested) but do not write the default aligned + files, + if requested) but do not write the default aligned \series bold .lib \series default @@ -19572,7 +19674,8 @@ naorder Walk the template as P \end_inset O3' . - No parent is required: + No parent is required: + \series bold \series default @@ -19581,7 +19684,9 @@ naorder Walk the template as P \series bold template \series default - is also given, that parent is walked instead, then + is also given, + that parent is walked instead, + then \series bold \series default @@ -19593,11 +19698,13 @@ aaorder Walk \series bold \series default - (or the template, if given) in ff19SB + (or the template, + if given) in ff19SB \series bold amino19.lib \series default - order: N + order: + N \begin_inset Formula $\rightarrow$ \end_inset @@ -19613,7 +19720,9 @@ amino19.lib \begin_inset Formula $\rightarrow$ \end_inset - side chain from CB (each heavy atom, then its hydrogens; smaller branch first) + side chain from CB (each heavy atom, + then its hydrogens; + smaller branch first) \begin_inset Formula $\rightarrow$ \end_inset @@ -19630,7 +19739,8 @@ amino19.lib \begin_inset Formula $\rightarrow$ \end_inset - ... + ... + \begin_inset Formula $\rightarrow$ \end_inset @@ -19653,7 +19763,8 @@ amino19.lib .lib \series default into the same shared-atom order as Amber ff19SB for TI. - The walk is built into the command; it does not read + The walk is built into the command; + it does not read \series bold amino19.lib \series default @@ -19671,7 +19782,9 @@ seed How the correspondence is started. \series bold auto \series default - (default) uses nucleic-acid scaffold roles when they are detected, otherwise amino-acid N/CA/C/O/CB when a peptide motif is found, otherwise unique atom names. + (default) uses nucleic-acid scaffold roles when they are detected, + otherwise amino-acid N/CA/C/O/CB when a peptide motif is found, + otherwise unique atom names. \series bold names @@ -19723,7 +19836,8 @@ tiout \series bold .0.lib \series default -, +, + \series bold .1.mol2 \series default @@ -19731,16 +19845,21 @@ tiout \series bold .1.lib \series default -, +, + \series bold .scmask \series default - (pmemd scmask1 / scmask2), and + (pmemd scmask1 / scmask2), + and \series bold .atoms \series default . - Dummy atoms copy the partner's name and coordinates, have charge 0, mass 0, and Amber type DUM. + Dummy atoms copy the partner's name and coordinates, + have charge 0, + mass 0, + and Amber type DUM. Does not suppress the default aligned \series bold .lib @@ -19766,14 +19885,19 @@ series \begin_inset space ~ \end_inset - ... List two or more analog topologies. - Chooses one parent that shares the most with the rest, then maps every listed analog onto that parent (star topology for TI). + ... + List two or more analog topologies. + Chooses one parent that shares the most with the rest, + then maps every listed analog onto that parent (star topology for TI). Do not combine with \series bold template \series default . - Parent selection: maximize the sum of mapped atoms when every other member is matched onto the candidate; on ties prefer the fewest atoms, then a leadopt-style similarity sum + Parent selection: + maximize the sum of mapped atoms when every other member is matched onto the candidate; + on ties prefer the fewest atoms, + then a leadopt-style similarity sum \begin_inset Formula $\sum_{j}\exp(-0.1\cdot(\mathrm{insertions}_{j}+\mathrm{unmapped}_{j}))$ \end_inset @@ -19782,15 +19906,9 @@ template \series bold util/leadopt/similarity.py \series default - ( -\series emph -exp_delta -\series default - / -\series emph -by_heavy_atom_count -\series default -; Summa Lab / Jonathan Redmann & Christopher Summa, University of New Orleans). + (exp_delta / by_heavy_atom_count; + Summa Lab / Jonathan Redmann & Christopher Summa, + University of New Orleans). The common substructure is approximated by \series bold TIMatch @@ -19799,11 +19917,13 @@ TIMatch \series bold util/leadopt/mcs.py \series default -, +, + \series bold rule.py \series default -, +, + \series bold graph.py \series default @@ -19829,11 +19949,13 @@ outprefix \series bold series \series default -, write each aligned OFF library as +, + write each aligned OFF library as \series bold .sorted.lib \series default - (default: + (default: + \series bold .sorted.lib \series default @@ -19849,15 +19971,18 @@ tioutprefix \series bold series \series default -, write dual-topology TI files for every non-parent member as +, + write dual-topology TI files for every non-parent member as \series bold .{0,1}.{mol2,lib} \series default -, +, + \series bold .scmask \series default -, and +, + and \series bold .atoms \series default @@ -19873,7 +19998,8 @@ mapoutprefix \series bold series \series default -, write each atom map as +, + write each atom map as \series bold .map \series default @@ -19889,10 +20015,12 @@ parentout \series bold series \series default -, write the selected parent name and per-candidate scores. +, + write the selected parent name and per-candidate scores. \end_layout \begin_layout Standard + \series bold Generating your own templates \series default @@ -19901,8 +20029,10 @@ Generating your own templates \series bold template \series default - is given, that parent's current atom order is used. - If it is omitted, + is given, + that parent's current atom order is used. + If it is omitted, + \series bold naorder \series default @@ -19918,19 +20048,25 @@ aaorder \end_layout \begin_layout LyX-Code -# 1. Parent given: analog is sorted to that residue's atom order. +# 1. + Parent given: + analog is sorted to that residue's atom order. \end_layout \begin_layout LyX-Code -# 2. No parent: naorder / aaorder invents Amber's canonical walk on the analog. +# 2. + No parent: + naorder / aaorder invents Amber's canonical walk on the analog. \end_layout \begin_layout LyX-Code -# 3. Optional tiout writes dual-topology TI files. +# 3. + Optional tiout writes dual-topology TI files. \end_layout \begin_layout Standard -Canonical NA order, no parent (sort this residue the way Amber walks a nucleotide). +Canonical NA order, + no parent (sort this residue the way Amber walks a nucleotide). \end_layout \begin_layout LyX-Code @@ -19946,9 +20082,13 @@ Canonical NA order, no parent (sort this residue the way Amber walks a nucleotid \end_layout \begin_layout Standard -Nucleic acids onto a parent (example: FLE = unmodified rA onto ERN = unmodified dA). - Shared atoms keep the dA indices; the 2'-OH is an insertion next to C2'; dA H2'' is unmatched on the template. - Default: write FLE in ERN atom order as an OFF library. +Nucleic acids onto a parent (example: + FLE = unmodified rA onto ERN = unmodified dA). + Shared atoms keep the dA indices; + the 2'-OH is an insertion next to C2'; + dA H2'' is unmatched on the template. + Default: + write FLE in ERN atom order as an OFF library. \end_layout \begin_layout LyX-Code @@ -19984,8 +20124,11 @@ tiout \end_layout \begin_layout Standard -Small molecules (example: phenol onto benzene). - The ring maps by unique names; OH inserts after C1; benzene H1 is unmatched. +Small molecules (example: + phenol onto benzene). + The ring maps by unique names; + OH inserts after C1; + benzene H1 is unmatched. \end_layout \begin_layout LyX-Code @@ -20005,14 +20148,17 @@ Small molecules (example: phenol onto benzene). \end_layout \begin_layout Standard -Amino acids (example: selenocysteine onto cysteine). +Amino acids (example: + selenocysteine onto cysteine). Use Amber OFF so selenium is \series bold elmnt 34 \series default . Mol2 atom name SE is read as sulfur. - Backbone names map; SE is an insertion at CB; cysteine SG is unmatched. + Backbone names map; + SE is an insertion at CB; + cysteine SG is unmatched. \end_layout \begin_layout LyX-Code @@ -20032,7 +20178,8 @@ elmnt 34 \end_layout \begin_layout Standard -Canonical amino-acid order, no parent (sort a noncanonical +Canonical amino-acid order, + no parent (sort a noncanonical \series bold .lib \series default @@ -20052,8 +20199,12 @@ Canonical amino-acid order, no parent (sort a noncanonical \end_layout \begin_layout Standard -Series of analogs (auto-select parent, then map each onto it for TI). - Example: phenol and benzene; benzene is chosen (same mapped total, fewer atoms). +Series of analogs (auto-select parent, + then map each onto it for TI). + Example: + phenol and benzene; + benzene is chosen (same mapped total, + fewer atoms). \end_layout \begin_layout LyX-Code @@ -20077,14 +20228,14 @@ How the nucleic-acid walk was chosen \end_layout \begin_layout Standard -ModXNA ( -https://github.com/modna-ff -) is the baseline chemistry for +ModXNA (https://github.com/modna-ff) is the baseline chemistry for \series bold naorder \series default . - It parameterizes nucleic acids as fragments (nucleobase, sugar, backbone) rather than as whole residues. + It parameterizes nucleic acids as fragments (nucleobase, + sugar, + backbone) rather than as whole residues. Combining those fragments into one \series bold .lib @@ -20094,24 +20245,34 @@ naorder \series bold nastruct \series default - to treat as nucleotides, because + to treat as nucleotides, + because \series bold nastruct \series default - identifies sugars and bases from connectivity and Amber-like names (C1', N9/N1, and so on), not from file order. + identifies sugars and bases from connectivity and Amber-like names (C1', + N9/N1, + and so on), + not from file order. \end_layout \begin_layout Standard The walk is therefore not copied from any one ModXNA file. - The fragment library was grouped by chemical class (backbone with or without phosphate, purine vs pyrimidine base, 2' pattern of the sugar). - One consensus parent was kept for each class; those 11 example fragments are in + The fragment library was grouped by chemical class (backbone with or without phosphate, + purine vs pyrimidine base, + 2' pattern of the sugar). + One consensus parent was kept for each class; + those 11 example fragments are in \series bold test/Test_TIMap/ \series default (see PARENTS.txt). - They are test data, not installed with cpptraj. + They are test data, + not installed with cpptraj. Each parent's atom list is the recommended shared-atom order for mapping other members of that class. - Combined nucleotides are a separate case: they are mapped to a user residue (for example unmodified rA onto dA), not to those fragments. + Combined nucleotides are a separate case: + they are mapped to a user residue (for example unmodified rA onto dA), + not to those fragments. \end_layout \begin_layout Standard @@ -20123,12 +20284,17 @@ naorder \begin_inset Formula $\rightarrow$ \end_inset - 3' sugar-phosphate traversal chosen so that (1) the shared scaffold is a fixed prefix independent of how the file was written, (2) chemical insertions sit next to their attachment atom (nucleobase analogs after the glycosidic nitrogen + 3' sugar-phosphate traversal chosen so that (1) the shared scaffold is a fixed prefix independent of how the file was written, + (2) chemical insertions sit next to their attachment atom (nucleobase analogs after the glycosidic nitrogen \begin_inset Formula $\chi$ \end_inset -, 2'-OH / OMe / F after C2'), and (3) the 3' linker O3' remains last among scaffold atoms so unmatched leftovers can be placed just before it. - Hydrogens follow their heavy atom, sorted by name, matching Amber convention. +, + 2'-OH / OMe / F after C2'), + and (3) the 3' linker O3' remains last among scaffold atoms so unmatched leftovers can be placed just before it. + Hydrogens follow their heavy atom, + sorted by name, + matching Amber convention. \end_layout \begin_layout LyX-Code @@ -20136,7 +20302,8 @@ P -> OP (name-sorted) -> O5' -> C5' -> C4' -> O4' -> C1' -> \end_layout \begin_layout LyX-Code - base (BFS from chi, never recrossing C1') -> C3' -> C2' + 2' substituents -> O3' + base (BFS from chi, + never recrossing C1') -> C3' -> C2' + 2' substituents -> O3' \end_layout \begin_layout Standard @@ -20149,15 +20316,13 @@ naorder template \series default is given (the residue is walked as itself). - When a ModXNA parent -\series emph -is -\series default - given, + When a ModXNA parent is given, + \series bold timap \series default - uses that parent's current atom order instead; those files were already written in the class order above. + uses that parent's current atom order instead; + those files were already written in the class order above. The amino-acid walk ( \series bold aaorder @@ -20170,7 +20335,8 @@ amino19.lib \end_layout \begin_layout Standard -Alias: +Alias: + \series bold timatch \series default @@ -20178,7 +20344,6 @@ timatch \end_layout \end_deeper - \begin_layout Subsection updateparameters \end_layout @@ -26352,35 +26517,6 @@ Calculate the number of waters in the first and second solvation shells based on \end_layout -\end_inset - - - - -\begin_inset Text - -\begin_layout Plain Layout -xtalsymm -\end_layout - -\end_inset - - -\begin_inset Text - -\begin_layout Plain Layout -Re-image coordinates based on crystal space group symmetry operations and asymmetric unit volume. -\end_layout - -\end_inset - - -\begin_inset Text - -\begin_layout Plain Layout -X -\end_layout - \end_inset diff --git a/src/Command.cpp b/src/Command.cpp index bddaf600ab..afffe64f1b 100644 --- a/src/Command.cpp +++ b/src/Command.cpp @@ -77,6 +77,7 @@ #include "Exec_Top.h" #include "Exec_UpdateParameters.h" #include "Exec_Desc.h" +#include "Exec_FixAtomNames.h" // ----- ACTION ---------------------------------------------------------------- #include "Action_Angle.h" #include "Action_Distance.h" @@ -317,6 +318,7 @@ void Command::Init() { Command::AddCmd( new Exec_CompareTop(), Cmd::EXE, 1, "comparetop" ); Command::AddCmd( new Exec_Desc(), Cmd::EXE, 1, "desc" ); // HIDDEN Command::AddCmd( new Exec_DihedralInfo(),Cmd::EXE, 3,"dihedrals","dihedralinfo","printdihedrals"); + Command::AddCmd( new Exec_FixAtomNames(), Cmd::EXE, 1, "fixatomnames"); Command::AddCmd( new Exec_HmassRepartition(),Cmd::EXE, 1, "hmassrepartition" ); Command::AddCmd( new Exec_ImproperInfo(),Cmd::EXE, 3,"impropers","improperinfo","printimpropers"); Command::AddCmd( new Exec_MassInfo(), Cmd::EXE, 1, "mass" ); diff --git a/src/Exec_FixAtomNames.cpp b/src/Exec_FixAtomNames.cpp new file mode 100644 index 0000000000..2aa199d687 --- /dev/null +++ b/src/Exec_FixAtomNames.cpp @@ -0,0 +1,267 @@ +#include "Exec_FixAtomNames.h" +#include "CpptrajStdio.h" +#include "StringRoutines.h" // convertToInteger +#include // isalpha, isdigit + +// ----------------------------------------------------------------------------- +/** \return name width in characters */ +int Exec_FixAtomNames::AtomName::NameWidth() const { + int width = 0; + for (NameTokenArray::const_iterator it = tokens_.begin(); it != tokens_.end(); ++it) + { + if (it->TokenType() == NameToken::INT) + width += DigitWidth( it->Ival() ); + else + width += it->Sval().size(); + } + return width; +} + +/** Print name to stdout */ +void Exec_FixAtomNames::AtomName::PrintName() const { + mprintf("\t Current Name: "); + for (NameTokenArray::const_iterator it = tokens_.begin(); it != tokens_.end(); ++it) { + if (it->TokenType() == NameToken::INT) + mprintf("%i", it->Ival()); + else + mprintf("%s", it->Sval().c_str()); + } + mprintf(" (%i)\n", NameWidth()); + + for (NameTokenArray::const_iterator it = tokens_.begin(); it != tokens_.end(); ++it) { + switch (it->TokenType()) { + case NameToken::INT : mprintf("\t INTEGER : %i\n", it->Ival()); break; + case NameToken::STRING : mprintf("\t STRING : %s\n", it->Sval().c_str()); break; + case NameToken::OTHER : mprintf("\t OTHER : %s\n", it->Sval().c_str()); break; + default: break; + } + } +} + +/** Convert to a string */ +std::string Exec_FixAtomNames::AtomName::NameString() const { + std::string aname; + for (NameTokenArray::const_iterator it = tokens_.begin(); it != tokens_.end(); ++it) { + if (it->TokenType() == NameToken::INT) + aname.append( integerToString(it->Ival()) ); + else + aname.append( it->Sval() ); + } + return aname; +} + +/** \return Token type from character */ +Exec_FixAtomNames::NameToken::Type Exec_FixAtomNames::get_type(char cIn) +{ + if (isalpha(cIn)) return NameToken::STRING; + else if (isdigit(cIn)) return NameToken::INT; + else return NameToken::OTHER; +} + +/** Dissect name into an array of tokens (AtomName) */ +int Exec_FixAtomNames::AtomName::DissectName(NameType const& anameIn) +{ + std::string aname = anameIn.Truncated(); + std::string currentToken; + tokens_.clear(); + // Sanity check + if (aname.empty()) { + mprinterr("Internal Error: Exec_FixAtomNames::AtomName::DissectName(): Atom name is empty.\n"); + return 1; + } + // Figure out the type of the first token + std::string::const_iterator it = aname.begin(); + NameToken::Type currentType = get_type( *it ); + for (std::string::const_iterator it = aname.begin(); it != aname.end(); ++it) + { + currentToken.push_back( *it ); + // If the next char is a different token type or the end, add the token + NameToken::Type nextType = NameToken::UNKNOWN; + bool push_token = false; + if ( (it+1) == aname.end()) + push_token = true; + else { + nextType = get_type( *(it+1) ); + if (nextType != currentType) + push_token = true; + } + if (push_token) { + if (currentType == NameToken::STRING) + tokens_.push_back( NameToken( currentToken ) ); + else if (currentType == NameToken::INT) + tokens_.push_back( NameToken( convertToInteger(currentToken) ) ); + else + tokens_.push_back( NameToken( NameToken::OTHER, currentToken ) ); + currentToken.clear(); + } + // Update the curren type with next type + currentType = nextType; + } + return 0; +} + +/** Naively increment the atom name. */ +int Exec_FixAtomNames::AtomName::IncrementName(int maxWidth) { + int currentWidth = NameWidth(); + int errval = 1; + // If we have no integer token, add one before any OTHER tokens. + bool has_int = false; + for (NameTokenArray::const_iterator it = tokens_.begin(); it != tokens_.end(); ++it) { + if (it->TokenType() == NameToken::INT) { + has_int = true; + break; + } + } + if (!has_int) { + //FIXME shouldnt put this after a prime + if (currentWidth == maxWidth) { + mprinterr("Error: Name %s is already at max width (%i), cannot add digit.\n", NameString().c_str(), maxWidth); + return 1; + } + tokens_.push_back( NameToken(1) ); + return 0; + } + + // Start at the last token and work up + for (NameTokenArray::reverse_iterator rit = tokens_.rbegin(); rit != tokens_.rend(); ++rit) + { + if ( rit->TokenType() == NameToken::INT) { + // What is the max digit width we can accomodate? + int digitWidth = DigitWidth( rit->Ival() ); + int otherWidth = currentWidth - digitWidth; + int availableWidth = maxWidth - otherWidth; + int maxDigit = pow(10, availableWidth) - 1; + //mprintf("DEBUG: digit=%i MaxDigit = %i\n", rit->Ival(), maxDigit); + int newDigit = rit->Ival() + 1; + if (newDigit <= maxDigit) { + // Increment should be ok. Can bail out now. + rit->SetIval( newDigit ); + errval = 0; + break; + } else { + // Reset to 1. Have to increment something else. + rit->SetIval( 1 ); + } + } + } + + return errval; +} + +// ----------------------------------------------------------------------------- + +static inline void WARNING() { + mprintf("WARNING: THIS COMMAND IS STILL EXPERIMENTAL. USE AT YOUR OWN RISK.\n"); +} + +// Exec_FixAtomNames::Help() +void Exec_FixAtomNames::Help() const +{ + mprintf("\t{ %s | crdset } []\n" + " Attempt to fix duplicated atom names in residues of the specified topology.\n", + DataSetList::TopArgs); + WARNING(); +} + +// Exec_FixAtomNames::Execute() +Exec::RetType Exec_FixAtomNames::Execute(CpptrajState& State, ArgList& argIn) +{ + // Are we doing a COORDS set or a topology? + Topology* parm = 0; + std::string crdset = argIn.GetStringKey("crdset"); + if (!crdset.empty()) { + DataSet_Coords* cset = (DataSet_Coords*)State.DSL().FindSetOfGroup( crdset, DataSet::COORDINATES ); + if (cset == 0) { + mprinterr("Error: No COORDS set with name '%s' found.\n", crdset.c_str()); + return CpptrajState::ERR; + } + parm = cset->TopPtr(); + mprintf("\tUsing topology from COORDS set '%s'\n", cset->legend()); + } else { + parm = State.DSL().GetTopology( argIn ); + mprintf("\tUsing topology: %s\n", parm->c_str()); + } + if (parm == 0) return CpptrajState::ERR; + WARNING(); + + Topology const& currentTop = static_cast(*parm); + // Select residues to check + std::string maskStr = argIn.GetStringKey("mask"); + AtomMask mask; + if (mask.SetMaskString( maskStr )) { + mprinterr("Error: Invalid mask string '%s'\n", maskStr.c_str()); + return CpptrajState::ERR; + } + if (currentTop.SetupIntegerMask( mask )) { + mprinterr("Error: Could not set up mask '%s'\n", mask.MaskString()); + return CpptrajState::ERR; + } + mask.MaskInfo(); + + std::vector resnums = currentTop.ResnumsSelectedBy( mask ); + + for (std::vector::const_iterator rnum = resnums.begin(); rnum != resnums.end(); ++rnum) + { + Residue const& res = currentTop.Res(*rnum); + std::set anames; + for (int iat = res.FirstAtom(); iat != res.LastAtom(); iat++) + { + std::pair::iterator, bool> ret = anames.insert( currentTop[iat].Name() ); + if (!ret.second) { + mprintf("Warning: '%s': In residue %s duplicate atom name detected: %s\n", + currentTop.c_str(), currentTop.TruncResNameNum(*rnum).c_str(), *(currentTop[iat].Name()) ); + if (fixDuplicate(*parm, iat, *rnum)) { + mprinterr("Error: Could not fix duplicated name %s\n", *(*(ret.first))); + return CpptrajState::ERR; + } + // Add the fixed (not duplicated) name + anames.insert( currentTop[iat].Name() ); + } + } + // DEBUG TEST dissect all names +// for (std::set::const_iterator it = anames.begin(); it != anames.end(); ++it) { +// AtomName atomName; +// if (atomName.DissectName( *it )) return CpptrajState::ERR; +// atomName.PrintName(); +// } + } + + return CpptrajState::OK; +} + +/** Given the index of an atom that has a duplicated name in a reside, change + * it to a unique name in that residue. + */ +int Exec_FixAtomNames::fixDuplicate(Topology& topIn, int duplicateIdx, int rnum) +const +{ + Residue const& res = topIn.Res(rnum); + // Dissect this name. + AtomName duplicateName; + if (duplicateName.DissectName( topIn[duplicateIdx].Name() )) return 1; + // DEBUG + duplicateName.PrintName(); + // Create a set of current atom names in the residue. They will all be unique. + std::set anames; + for (int iat = res.FirstAtom(); iat != res.LastAtom(); iat++) + anames.insert( topIn[iat].Name() ); + // Try to increment the name until we do not get a clash + bool tryNewNames = true; + while (tryNewNames) { + if (duplicateName.IncrementName(4) != 0) { + mprinterr("Error: Ran out of names to increment for %s.\n", topIn.AtomMaskName(duplicateIdx).c_str()); + return 1; + } + NameType newName( duplicateName.NameString() ); + std::set::iterator it = anames.find( newName ); + if (it == anames.end()) { + // Name is no longer duplicated! + mprintf("\tNew name: %s\n", *newName); + topIn.SetAtom(duplicateIdx).SetName( newName ); + tryNewNames = false; + } else + mprintf("\tName %s already exists.\n", *newName); + } + + return 0; +} diff --git a/src/Exec_FixAtomNames.h b/src/Exec_FixAtomNames.h new file mode 100644 index 0000000000..535d44b0af --- /dev/null +++ b/src/Exec_FixAtomNames.h @@ -0,0 +1,61 @@ +#ifndef INC_EXEC_FIXATOMNAMES_H +#define INC_EXEC_FIXATOMNAMES_H +#include "Exec.h" +//#incl ude +/// Fix topology so all atom names in residues are unique. +class Exec_FixAtomNames : public Exec { + public: + Exec_FixAtomNames() : Exec(PARM) {} + void Help() const; + DispatchObject* Alloc() const { return (DispatchObject*)new Exec_FixAtomNames(); } + RetType Execute(CpptrajState&, ArgList&); + private: +/* typedef std::pair NamePair; + typedef std::map NameMap; + typedef std::pair ResPair; + typedef std::map ResMap; + + ResMap resMap_; ///< Hold a map of residues that have had their atom names changed*/ + /// Hold a part of an atom name + class NameToken { + public: + enum Type { STRING = 0, ///< A letter (A-Z, a-z) + INT, ///< A digit (0-9) + OTHER, ///< Any other character. Will not change. + UNKNOWN }; + NameToken(std::string const& s) : ival_(-1), sval_(s), type_(STRING) {} + NameToken(int i) : ival_(i), sval_(""), type_(INT) {} + NameToken(Type t, std::string const& s) : ival_(-1), sval_(s), type_(t) {} + + int Ival() const { return ival_; } + std::string const& Sval() const { return sval_; } + Type TokenType() const { return type_; } + + void SetIval(int i) { ival_ = i; } + private: + int ival_; + std::string sval_; + Type type_; + }; + /// Hold all parts that make up an atom name + class AtomName { + public: + AtomName() {} + //void AddToken(NameToken const& n) { tokens_.push_back( n ); } + void PrintName() const; + std::string NameString() const; + int DissectName(NameType const&); + int NameWidth() const; + /// Naively increment the name + int IncrementName(int); + private: + typedef std::vector NameTokenArray; + NameTokenArray tokens_; + }; + + static inline NameToken::Type get_type(char); + + int fixDuplicate(Topology&, int, int) const; + +}; +#endif diff --git a/src/Mol2File.cpp b/src/Mol2File.cpp index fa1ebca3bd..2effdc01eb 100644 --- a/src/Mol2File.cpp +++ b/src/Mol2File.cpp @@ -107,10 +107,20 @@ bool Mol2File::ReadMolecule( ) { mprintf("\tMol2 #atoms: %i\n",mol2atoms_); mprintf("\tMol2 #bonds: %i\n",mol2bonds_); } + // Scan molecule type + if ( Gets(linebuffer_, BUF_SIZE) ) return true; + moltype_.assign( NoTrailingWhitespace(linebuffer_) ); + // Scan charges type + if ( Gets(linebuffer_, BUF_SIZE) ) return true; + chargetype_.assign( NoTrailingWhitespace(linebuffer_) ); + if (mol2debug_>0) { + mprintf("\tMolecule type : %s\n", moltype_.c_str()); + mprintf("\tCharge type : %s\n", chargetype_.c_str()); + } return false; } -bool Mol2File::WriteMolecule(bool hasCharges, int mol2res) { +bool Mol2File::WriteMolecule(bool hasCharges, int mol2res, std::string const& mtype, std::string const& ctype) { Printf("%s\n", TRIPOSTAGTEXT[MOLECULE]); // mol_name // num_atoms [num_bonds [num_subst [num_feat [num_sets]]]] @@ -120,10 +130,16 @@ bool Mol2File::WriteMolecule(bool hasCharges, int mol2res) { // [mol_comment]] Printf("%s\n", mol2title_.c_str()); Printf("%5i %5i %5i %5i %5i\n", mol2atoms_, mol2bonds_, mol2res, 0, 0); - Printf("SMALL\n"); // May change this later - if ( hasCharges ) - Printf("USER_CHARGES\n"); // May change this later + if (mtype.empty()) + Printf("SMALL\n"); // May change this later else + Printf("%s\n", mtype.c_str()); + if ( hasCharges ) { + if (ctype.empty()) + Printf("USER_CHARGES\n"); // May change this later + else + Printf("%s\n", ctype.c_str()); + } else Printf("NO_CHARGES\n"); Printf("\n\n"); return false; diff --git a/src/Mol2File.h b/src/Mol2File.h index a61fccea68..cd5fa47b19 100644 --- a/src/Mol2File.h +++ b/src/Mol2File.h @@ -23,7 +23,7 @@ class Mol2File : private CpptrajFile { /// Check for modXNA info in the title ModXNA_Info* CheckForModxna(); /// Write Mol2 info - bool WriteMolecule(bool,int); + bool WriteMolecule(bool,int,std::string const&,std::string const&); //// Used to only read # atoms in next MOLECULE record. int NextMolecule(); /// Read in the next Mol2 BOND line. Get the indices of the bonded atoms. @@ -50,6 +50,8 @@ class Mol2File : private CpptrajFile { int Mol2Natoms() const { return mol2atoms_; } int Mol2Nbonds() const { return mol2bonds_; } std::string const& Mol2Title() const { return mol2title_; } + std::string const& MolType() const { return moltype_; } + std::string const& ChargeType() const { return chargetype_; } // CpptrajFile functions that should be accessible. using CpptrajFile::SetupRead; using CpptrajFile::SetupWrite; @@ -66,6 +68,8 @@ class Mol2File : private CpptrajFile { int mol2atoms_; int mol2bonds_; std::string mol2title_; + std::string moltype_; + std::string chargetype_; //typedef std::map AtypeMap; typedef std::map AtypeMap; AtypeMap Atype_to_Sybyl_; ///< Map Amber type name to SYBYL type name. diff --git a/src/Parm_Mol2.cpp b/src/Parm_Mol2.cpp index b5e90e4403..7a8747bf3d 100644 --- a/src/Parm_Mol2.cpp +++ b/src/Parm_Mol2.cpp @@ -24,6 +24,8 @@ int Parm_Mol2::ReadParm(FileName const& fname, Topology &parmOut) { delete modxna; } parmOut.SetParmName( infile.Mol2Title(), infile.Filename() ); + parmOut.SetMolType( infile.MolType() ); + parmOut.SetChargeType( infile.ChargeType() ); // Get @ATOM information if (infile.ScanTo( Mol2File::ATOM)) return 1; diff --git a/src/Topology.h b/src/Topology.h index 63d3bfcb6d..35b0ab8cb4 100644 --- a/src/Topology.h +++ b/src/Topology.h @@ -23,6 +23,8 @@ class Topology { void SetIpol(int iIn) { ipol_ = iIn; } void SetPindex(int pIn) { pindex_ = pIn; } void SetGBradiiSet(std::string const& s) { radius_set_ = s; } + void SetMolType(std::string const& m) { mol_type_ = m; } + void SetChargeType(std::string const& c) { charge_type_ = c; } void CopyTopMetadata(Topology const&); void SetParmTitle(std::string const&); void SetParmName(std::string const&, FileName const&); @@ -43,6 +45,8 @@ class Topology { std::string const& ParmName() const { return parmName_; } FileName const& OriginalFilename() const { return fileName_; } std::string const& GBradiiSet() const { return radius_set_; } + std::string const& MoleculeType() const { return mol_type_; } + std::string const& ChargeType() const { return charge_type_; } const char *c_str() const; //FIXME rename // ---- Atom-specific routines --------------- typedef std::vector::const_iterator atom_iterator; @@ -376,6 +380,8 @@ class Topology { FileName fileName_; std::string parmName_; std::string radius_set_; + std::string mol_type_; + std::string charge_type_; BondArray bonds_; BondArray bondsh_; diff --git a/src/Traj_Mol2File.cpp b/src/Traj_Mol2File.cpp index 4786b82f04..462a32415f 100644 --- a/src/Traj_Mol2File.cpp +++ b/src/Traj_Mol2File.cpp @@ -226,7 +226,7 @@ int Traj_Mol2File::writeFrame(int set, Frame const& frameOut) { if (file_.OpenWriteNumbered( set + 1, prependExt_ )) return 1; } //@MOLECULE section - file_.WriteMolecule( hasCharges_, mol2Top_->Nres() ); + file_.WriteMolecule( hasCharges_, mol2Top_->Nres(), mol2Top_->MoleculeType(), mol2Top_->ChargeType() ); //@ATOM section file_.WriteHeader(Mol2File::ATOM); const double *Xptr = frameOut.xAddress(); diff --git a/src/Version.h b/src/Version.h index 5f787e234e..31cb21ff7c 100644 --- a/src/Version.h +++ b/src/Version.h @@ -12,7 +12,7 @@ * Whenever a number that precedes is incremented, all subsequent * numbers should be reset to 0. */ -#define CPPTRAJ_INTERNAL_VERSION "V7.12.6" +#define CPPTRAJ_INTERNAL_VERSION "V7.13.0" /// PYTRAJ relies on this #define CPPTRAJ_VERSION_STRING CPPTRAJ_INTERNAL_VERSION #endif diff --git a/src/cpptrajdepend b/src/cpptrajdepend index 4c418b2919..d907569172 100644 --- a/src/cpptrajdepend +++ b/src/cpptrajdepend @@ -196,7 +196,7 @@ CmapParmHolder.o : CmapParmHolder.cpp CmapParmHolder.h Constants.h CpptrajStdio. Cmd.o : Cmd.cpp Cmd.h DispatchObject.h CmdInput.o : CmdInput.cpp CmdInput.h StringRoutines.h CmdList.o : CmdList.cpp Cmd.h CmdList.h DispatchObject.h -Command.o : Command.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h ActionTopWriter.h Action_AddAtom.h Action_Align.h Action_Angle.h Action_AreaPerMol.h Action_AtomMap.h Action_AtomicCorr.h Action_AtomicFluct.h Action_AutoImage.h Action_Average.h Action_AvgBox.h Action_Bounds.h Action_Box.h Action_Center.h Action_Channel.h Action_CheckChirality.h Action_CheckStructure.h Action_Closest.h Action_ClusterDihedral.h Action_Contacts.h Action_ConvertToFrac.h Action_CreateCrd.h Action_CreateReservoir.h Action_DNAionTracker.h Action_DSSP.h Action_Density.h Action_Diffusion.h Action_Dihedral.h Action_DihedralRMS.h Action_Dipole.h Action_DistRmsd.h Action_Distance.h Action_EneDecomp.h Action_Energy.h Action_Esander.h Action_FilterByData.h Action_FixAtomOrder.h Action_FixImagedBonds.h Action_GIST.h Action_Grid.h Action_GridFreeEnergy.h Action_HydrogenBond.h Action_Image.h Action_InfraredSpectrum.h Action_Jcoupling.h Action_Keep.h Action_LESsplit.h Action_LIE.h Action_LipidOrder.h Action_MakeStructure.h Action_Mask.h Action_Matrix.h Action_MinImage.h Action_MinMaxDist.h Action_Molsurf.h Action_MultiDihedral.h Action_MultiPucker.h Action_MultiVector.h Action_NAstruct.h Action_NMRrst.h Action_NativeContacts.h Action_OrderParameter.h Action_Outtraj.h Action_PairDist.h Action_Pairwise.h Action_Principal.h Action_Projection.h Action_Pucker.h Action_Radgyr.h Action_Radial.h Action_RandomizeIons.h Action_Remap.h Action_ReplicateCell.h Action_Rmsd.h Action_Rotate.h Action_RunningAvg.h Action_STFC_Diffusion.h Action_Scale.h Action_SetVelocity.h Action_Spam.h Action_Strip.h Action_Surf.h Action_SurfaceTension.h Action_SymmetricRmsd.h Action_Temperature.h Action_Test.h Action_Time.h Action_ToroidalDiffusion.h Action_Translate.h Action_Unstrip.h Action_Unwrap.h Action_Vector.h Action_VelocityAutoCorr.h Action_Volmap.h Action_Volume.h Action_Watershell.h Action_XtalSymm.h Analysis.h AnalysisList.h AnalysisState.h Analysis_AmdBias.h Analysis_AutoCorr.h Analysis_Average.h Analysis_CalcDiffusion.h Analysis_Clustering.h Analysis_ConstantPHStats.h Analysis_Corr.h Analysis_CrankShaft.h Analysis_CrdFluct.h Analysis_CrossCorr.h Analysis_CurveFit.h Analysis_Divergence.h Analysis_EvalPlateau.h Analysis_FFT.h Analysis_HausdorffDistance.h Analysis_Hist.h Analysis_IRED.h Analysis_Integrate.h Analysis_KDE.h Analysis_Lifetime.h Analysis_LowestCurve.h Analysis_Matrix.h Analysis_MeltCurve.h Analysis_Modes.h Analysis_MultiHist.h Analysis_Multicurve.h Analysis_Overlap.h Analysis_PhiPsi.h Analysis_Project.h Analysis_Regression.h Analysis_RemLog.h Analysis_Rms2d.h Analysis_RmsAvgCorr.h Analysis_Rotdif.h Analysis_RunningAvg.h Analysis_Slope.h Analysis_Spline.h Analysis_State.h Analysis_Statistics.h Analysis_TI.h Analysis_TICA.h Analysis_Timecorr.h Analysis_VectorMath.h Analysis_Wavelet.h ArgList.h Array1D.h ArrayIterator.h AssociatedData.h Atom.h AtomMap.h AtomMask.h AxisType.h BaseIOtype.h Box.h BoxArgs.h BufferedLine.h CharMask.h Cluster/Algorithm.h Cluster/BestReps.h Cluster/CentroidArray.h Cluster/Cframes.h Cluster/Control.h Cluster/DrawGraph.h Cluster/List.h Cluster/Metric.h Cluster/MetricArray.h Cluster/Node.h Cluster/Sieve.h Cluster/Silhouette.h ClusterMap.h Cmd.h CmdInput.h CmdList.h Command.h CompactFrameArray.h ComplexArray.h Constants.h Constraints.h ControlBlock.h ControlBlock_For.h CoordinateInfo.h Corr.h Cph.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_CRD.h DataSet_Coords_REF.h DataSet_GridFlt.h DataSet_MatrixDbl.h DataSet_MatrixFlt.h DataSet_Mesh.h DataSet_Modes.h DataSet_RemLog.h DataSet_Vector.h DataSet_double.h DataSet_float.h DataSet_integer.h DataSet_integer_mem.h DataSet_pH.h DataSet_string.h Deprecated.h DiffusionResults.h DihedralSearch.h Dimension.h DispatchObject.h Energy.h Energy/Ecalc_Nonbond.h Energy/EnergyDecomposer.h Energy/ErfcFxn.h Energy/EwaldParams.h Energy/PME_RecipParams.h Energy/VDW_LongRange_Correction.h Energy_Sander.h EnsembleIn.h EnsembleOutList.h EwaldOptions.h ExclusionArray.h Exec.h Exec_AddMissingRes.h Exec_Analyze.h Exec_Build.h Exec_Calc.h Exec_CatCrd.h Exec_Change.h Exec_ClusterMap.h Exec_CombineCoords.h Exec_Commands.h Exec_CompareClusters.h Exec_CompareEnergy.h Exec_CompareTop.h Exec_CrdAction.h Exec_CrdOut.h Exec_CrdTransform.h Exec_CreateSet.h Exec_DataFile.h Exec_DataFilter.h Exec_DataSetCmd.h Exec_Desc.h Exec_Emin.h Exec_ExtendedComparison.h Exec_Flatten.h Exec_Flush.h Exec_GenerateAmberRst.h Exec_Graft.h Exec_Help.h Exec_HmassRepartition.h Exec_LoadCrd.h Exec_LoadTraj.h Exec_Mutate.h Exec_ParallelAnalysis.h Exec_ParmBox.h Exec_ParmSolvent.h Exec_ParmStrip.h Exec_ParmWrite.h Exec_ParseTiming.h Exec_PermuteDihedrals.h Exec_Precision.h Exec_PrepareForLeap.h Exec_PrintData.h Exec_Random.h Exec_ReadData.h Exec_ReadEnsembleData.h Exec_ReadInput.h Exec_RotateDihedral.h Exec_RunAnalysis.h Exec_ScaleDihedralK.h Exec_Sequence.h Exec_SequenceAlign.h Exec_Set.h Exec_Show.h Exec_SortEnsembleData.h Exec_Source.h Exec_SplitCoords.h Exec_System.h Exec_TIMap.h Exec_Top.h Exec_Traj.h Exec_UpdateParameters.h Exec_ViewRst.h Exec_Zmatrix.h ExtendedSimilarity.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h GIST_PME.h Grid.h GridAction.h GridBin.h GridMover.h HistBin.h Hungarian.h ImageOption.h ImageTypes.h InputTrajCommon.h InteractionData.h MapAtom.h MaskArray.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h ModXNA_Info.h Molecule.h NC_Routines.h NameType.h NetcdfFile.h OnlineVarT.h OutputTrajCommon.h PDBfile.h PairList.h Parallel.h ParallelSetFrameNum.h ParameterTypes.h Parm/GB_Params.h PubFFT.h Pucker.h Pucker_PuckerMask.h Pucker_PuckerSearch.h Pucker_PuckerToken.h RPNcalc.h Random.h Range.h ReferenceAction.h ReferenceFrame.h RemdReservoirNC.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h Spline.h SplineFxnTable.h Structure/LeastSquaresPlane.h Structure/RingFinder.h StructureCheck.h SymbolExporting.h SymmetricRmsdCalc.h TIMatch.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h Trajout_Single.h Unit.h Vec3.h cuda_kernels/GistCudaSetup.cuh helpme_standalone.h molsurf.h +Command.o : Command.cpp Action.h ActionFrameCounter.h ActionList.h ActionState.h ActionTopWriter.h Action_AddAtom.h Action_Align.h Action_Angle.h Action_AreaPerMol.h Action_AtomMap.h Action_AtomicCorr.h Action_AtomicFluct.h Action_AutoImage.h Action_Average.h Action_AvgBox.h Action_Bounds.h Action_Box.h Action_Center.h Action_Channel.h Action_CheckChirality.h Action_CheckStructure.h Action_Closest.h Action_ClusterDihedral.h Action_Contacts.h Action_ConvertToFrac.h Action_CreateCrd.h Action_CreateReservoir.h Action_DNAionTracker.h Action_DSSP.h Action_Density.h Action_Diffusion.h Action_Dihedral.h Action_DihedralRMS.h Action_Dipole.h Action_DistRmsd.h Action_Distance.h Action_EneDecomp.h Action_Energy.h Action_Esander.h Action_FilterByData.h Action_FixAtomOrder.h Action_FixImagedBonds.h Action_GIST.h Action_Grid.h Action_GridFreeEnergy.h Action_HydrogenBond.h Action_Image.h Action_InfraredSpectrum.h Action_Jcoupling.h Action_Keep.h Action_LESsplit.h Action_LIE.h Action_LipidOrder.h Action_MakeStructure.h Action_Mask.h Action_Matrix.h Action_MinImage.h Action_MinMaxDist.h Action_Molsurf.h Action_MultiDihedral.h Action_MultiPucker.h Action_MultiVector.h Action_NAstruct.h Action_NMRrst.h Action_NativeContacts.h Action_OrderParameter.h Action_Outtraj.h Action_PairDist.h Action_Pairwise.h Action_Principal.h Action_Projection.h Action_Pucker.h Action_Radgyr.h Action_Radial.h Action_RandomizeIons.h Action_Remap.h Action_ReplicateCell.h Action_Rmsd.h Action_Rotate.h Action_RunningAvg.h Action_STFC_Diffusion.h Action_Scale.h Action_SetVelocity.h Action_Spam.h Action_Strip.h Action_Surf.h Action_SurfaceTension.h Action_SymmetricRmsd.h Action_Temperature.h Action_Test.h Action_Time.h Action_ToroidalDiffusion.h Action_Translate.h Action_Unstrip.h Action_Unwrap.h Action_Vector.h Action_VelocityAutoCorr.h Action_Volmap.h Action_Volume.h Action_Watershell.h Action_XtalSymm.h Analysis.h AnalysisList.h AnalysisState.h Analysis_AmdBias.h Analysis_AutoCorr.h Analysis_Average.h Analysis_CalcDiffusion.h Analysis_Clustering.h Analysis_ConstantPHStats.h Analysis_Corr.h Analysis_CrankShaft.h Analysis_CrdFluct.h Analysis_CrossCorr.h Analysis_CurveFit.h Analysis_Divergence.h Analysis_EvalPlateau.h Analysis_FFT.h Analysis_HausdorffDistance.h Analysis_Hist.h Analysis_IRED.h Analysis_Integrate.h Analysis_KDE.h Analysis_Lifetime.h Analysis_LowestCurve.h Analysis_Matrix.h Analysis_MeltCurve.h Analysis_Modes.h Analysis_MultiHist.h Analysis_Multicurve.h Analysis_Overlap.h Analysis_PhiPsi.h Analysis_Project.h Analysis_Regression.h Analysis_RemLog.h Analysis_Rms2d.h Analysis_RmsAvgCorr.h Analysis_Rotdif.h Analysis_RunningAvg.h Analysis_Slope.h Analysis_Spline.h Analysis_State.h Analysis_Statistics.h Analysis_TI.h Analysis_TICA.h Analysis_Timecorr.h Analysis_VectorMath.h Analysis_Wavelet.h ArgList.h Array1D.h ArrayIterator.h AssociatedData.h Atom.h AtomMap.h AtomMask.h AxisType.h BaseIOtype.h Box.h BoxArgs.h BufferedLine.h CharMask.h Cluster/Algorithm.h Cluster/BestReps.h Cluster/CentroidArray.h Cluster/Cframes.h Cluster/Control.h Cluster/DrawGraph.h Cluster/List.h Cluster/Metric.h Cluster/MetricArray.h Cluster/Node.h Cluster/Sieve.h Cluster/Silhouette.h ClusterMap.h Cmd.h CmdInput.h CmdList.h Command.h CompactFrameArray.h ComplexArray.h Constants.h Constraints.h ControlBlock.h ControlBlock_For.h CoordinateInfo.h Corr.h Cph.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataFilter.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_3D.h DataSet_Coords.h DataSet_Coords_CRD.h DataSet_Coords_REF.h DataSet_GridFlt.h DataSet_MatrixDbl.h DataSet_MatrixFlt.h DataSet_Mesh.h DataSet_Modes.h DataSet_RemLog.h DataSet_Vector.h DataSet_double.h DataSet_float.h DataSet_integer.h DataSet_integer_mem.h DataSet_pH.h DataSet_string.h Deprecated.h DiffusionResults.h DihedralSearch.h Dimension.h DispatchObject.h Energy.h Energy/Ecalc_Nonbond.h Energy/EnergyDecomposer.h Energy/ErfcFxn.h Energy/EwaldParams.h Energy/PME_RecipParams.h Energy/VDW_LongRange_Correction.h Energy_Sander.h EnsembleIn.h EnsembleOutList.h EwaldOptions.h ExclusionArray.h Exec.h Exec_AddMissingRes.h Exec_Analyze.h Exec_Build.h Exec_Calc.h Exec_CatCrd.h Exec_Change.h Exec_ClusterMap.h Exec_CombineCoords.h Exec_Commands.h Exec_CompareClusters.h Exec_CompareEnergy.h Exec_CompareTop.h Exec_CrdAction.h Exec_CrdOut.h Exec_CrdTransform.h Exec_CreateSet.h Exec_DataFile.h Exec_DataFilter.h Exec_DataSetCmd.h Exec_Desc.h Exec_Emin.h Exec_ExtendedComparison.h Exec_FixAtomNames.h Exec_Flatten.h Exec_Flush.h Exec_GenerateAmberRst.h Exec_Graft.h Exec_Help.h Exec_HmassRepartition.h Exec_LoadCrd.h Exec_LoadTraj.h Exec_Mutate.h Exec_ParallelAnalysis.h Exec_ParmBox.h Exec_ParmSolvent.h Exec_ParmStrip.h Exec_ParmWrite.h Exec_ParseTiming.h Exec_PermuteDihedrals.h Exec_Precision.h Exec_PrepareForLeap.h Exec_PrintData.h Exec_Random.h Exec_ReadData.h Exec_ReadEnsembleData.h Exec_ReadInput.h Exec_RotateDihedral.h Exec_RunAnalysis.h Exec_ScaleDihedralK.h Exec_Sequence.h Exec_SequenceAlign.h Exec_Set.h Exec_Show.h Exec_SortEnsembleData.h Exec_Source.h Exec_SplitCoords.h Exec_System.h Exec_TIMap.h Exec_Top.h Exec_Traj.h Exec_UpdateParameters.h Exec_ViewRst.h Exec_Zmatrix.h ExtendedSimilarity.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h GIST_PME.h Grid.h GridAction.h GridBin.h GridMover.h HistBin.h Hungarian.h ImageOption.h ImageTypes.h InputTrajCommon.h InteractionData.h MapAtom.h MaskArray.h MaskToken.h Matrix.h Matrix_3x3.h MetaData.h ModXNA_Info.h Molecule.h NC_Routines.h NameType.h NetcdfFile.h OnlineVarT.h OutputTrajCommon.h PDBfile.h PairList.h Parallel.h ParallelSetFrameNum.h ParameterTypes.h Parm/GB_Params.h PubFFT.h Pucker.h Pucker_PuckerMask.h Pucker_PuckerSearch.h Pucker_PuckerToken.h RPNcalc.h Random.h Range.h ReferenceAction.h ReferenceFrame.h RemdReservoirNC.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h Spline.h SplineFxnTable.h Structure/LeastSquaresPlane.h Structure/RingFinder.h StructureCheck.h SymbolExporting.h SymmetricRmsdCalc.h TIMatch.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h TrajectoryFile.h Trajin.h TrajinList.h TrajoutList.h Trajout_Single.h Unit.h Vec3.h cuda_kernels/GistCudaSetup.cuh helpme_standalone.h molsurf.h CompactFrameArray.o : CompactFrameArray.cpp Box.h CompactFrameArray.h CoordinateInfo.h CpptrajStdio.h Matrix_3x3.h Parallel.h ReplicaDimArray.h Vec3.h ComplexArray.o : ComplexArray.cpp ArrayIterator.h ComplexArray.h Constraints.o : Constraints.cpp ArgList.h Atom.h AtomMask.h Box.h CharMask.h Constants.h Constraints.h CoordinateInfo.h CpptrajStdio.h FileName.h Frame.h MaskToken.h Matrix_3x3.h ModXNA_Info.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReplicaDimArray.h Residue.h Segment.h SymbolExporting.h Topology.h Unit.h Vec3.h @@ -342,6 +342,7 @@ Exec_DataSetCmd.o : Exec_DataSetCmd.cpp Action.h ActionList.h ActionState.h Anal Exec_Desc.o : Exec_Desc.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Desc.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h ModXNA_Info.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h Unit.h Vec3.h Exec_Emin.o : Exec_Emin.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h BaseIOtype.h Box.h CharMask.h Constants.h Constraints.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnergyArray.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Emin.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MdOpts.h MetaData.h Minimize_SteepestDescent.h ModXNA_Info.h Molecule.h NameType.h Parallel.h ParameterTypes.h PotentialFunction.h PotentialTerm.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h Unit.h Vec3.h Exec_ExtendedComparison.o : Exec_ExtendedComparison.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_ExtendedComparison.h ExtendedSimilarity.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h ModXNA_Info.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h Unit.h Vec3.h +Exec_FixAtomNames.o : Exec_FixAtomNames.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_FixAtomNames.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h ModXNA_Info.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h StringRoutines.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h Unit.h Vec3.h Exec_Flatten.o : Exec_Flatten.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_1D.h DataSet_2D.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Flatten.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h ModXNA_Info.h Molecule.h NameType.h OnlineVarT.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h Unit.h Vec3.h Exec_Flush.o : Exec_Flush.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_Flush.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h ModXNA_Info.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h Unit.h Vec3.h Exec_GenerateAmberRst.o : Exec_GenerateAmberRst.cpp Action.h ActionList.h ActionState.h Analysis.h AnalysisList.h AnalysisState.h ArgList.h AssociatedData.h Atom.h AtomMask.h BaseIOtype.h Box.h Constants.h CoordinateInfo.h CpptrajFile.h CpptrajState.h CpptrajStdio.h DataFile.h DataFileList.h DataSet.h DataSetList.h DataSet_Coords.h DataSet_Coords_REF.h Dimension.h DispatchObject.h DistRoutines.h EnsembleIn.h EnsembleOutList.h Exec.h Exec_GenerateAmberRst.h FileIO.h FileName.h FileTypes.h Frame.h FramePtrArray.h ImageOption.h InputTrajCommon.h MaskToken.h Matrix_3x3.h MetaData.h ModXNA_Info.h Molecule.h NameType.h Parallel.h ParameterTypes.h Range.h ReferenceFrame.h ReplicaDimArray.h ReplicaInfo.h Residue.h Segment.h SymbolExporting.h TextFormat.h Timer.h Topology.h TorsionRoutines.h TrajFrameCounter.h Trajin.h TrajinList.h TrajoutList.h Unit.h Vec3.h diff --git a/src/cpptrajfiles b/src/cpptrajfiles index d3bcea38a8..cda713abdf 100644 --- a/src/cpptrajfiles +++ b/src/cpptrajfiles @@ -295,6 +295,7 @@ COMMON_SOURCES= \ Exec_Desc.cpp \ Exec_Emin.cpp \ Exec_ExtendedComparison.cpp \ + Exec_FixAtomNames.cpp \ Exec_Flatten.cpp \ Exec_Flush.cpp \ Exec_GenerateAmberRst.cpp \ diff --git a/test/Makefile b/test/Makefile index d4ed89f4ed..c492031026 100644 --- a/test/Makefile +++ b/test/Makefile @@ -578,6 +578,9 @@ test.build: test.modxna: @-cd Test_ModXNA && ./RunTest.sh $(OPT) +test.fixatomnames: + @-cd Test_FixAtomNames && ./RunTest.sh $(OPT) + # Only GPU-specific tests should go here GPUTESTS=test.closest \ test.solvent \ @@ -767,7 +770,8 @@ COMPLETETESTS=test.general \ test.watershellclosest \ test.mutate \ test.build \ - test.modxna + test.modxna \ + test.fixatomnames test.all: $(MAKE) test.complete summary diff --git a/test/Test_FixAtomNames/IB1.mol2 b/test/Test_FixAtomNames/IB1.mol2 new file mode 100644 index 0000000000..4a6cb4b2af --- /dev/null +++ b/test/Test_FixAtomNames/IB1.mol2 @@ -0,0 +1,60 @@ +@MOLECULE +modXNA-fragment:IB1:HEAD01:@P:HEAD01STRIP:@O3',C3,H31,H32,H33:TAIL01:@O5':TAIL01STRIP:@C5',H5'1,H5'2,H5'3 + 25 24 1 0 0 +SMALL +USER_CHARGES + + +@ATOM + 1 P -0.6540 -0.2310 0.2980 P 1 IB1 1.093427 + 2 OP1 -0.7140 -0.9040 1.5850 O2 1 IB1 -0.689124 + 3 C2 0.8550 -0.5030 -0.6600 CT 1 IB1 -0.455618 + 4 O5' -0.8770 1.3380 0.4530 OS 1 IB1 -0.427575 + 5 C5' -1.0610 2.2400 -0.6180 CT 1 IB1 0.016905 + 6 H5'1 -1.7920 1.8640 -1.3210 H1 1 IB1 0.076577 + 7 H5'2 -0.1250 2.4230 -1.1300 H1 1 IB1 0.076577 + 8 O3' -1.7670 -0.6790 -0.7510 OS 1 IB1 -0.427575 + 9 C3 -3.0780 -1.0140 -0.3160 CT 1 IB1 0.016905 + 10 H5'3 -1.4150 3.1650 -0.1880 H1 1 IB1 0.076577 + 11 H31 -3.6080 -1.3720 -1.1860 H1 1 IB1 0.076577 + 12 H32 -3.5800 -0.1400 0.0810 H1 1 IB1 0.076577 + 13 H33 -3.0370 -1.7820 0.4410 H1 1 IB1 0.076577 + 14 H7 0.8690 0.1600 -1.5210 HC 1 IB1 0.103543 + 15 H8 0.7550 -1.5100 -1.0540 HC 1 IB1 0.103543 + 16 C9 2.1690 -0.3920 0.1390 CT 1 IB1 0.571278 + 17 C9 3.3280 -0.9310 -0.7040 CT 1 IB1 -0.481884 + 18 H10 2.0680 -1.0200 1.0190 HC 1 IB1 -0.039521 + 19 C11 2.4590 1.0380 0.6050 CT 1 IB1 -0.481884 + 20 H10 4.2590 -0.8950 -0.1460 HC 1 IB1 0.106352 + 21 H11 3.4620 -0.3420 -1.6080 HC 1 IB1 0.106352 + 22 H12 3.1590 -1.9610 -0.9990 HC 1 IB1 0.106352 + 23 H13 3.3960 1.0740 1.1510 HC 1 IB1 0.106352 + 24 H14 1.6830 1.4200 1.2570 HC 1 IB1 0.106352 + 25 H15 2.5500 1.7120 -0.2440 HC 1 IB1 0.106352 +@BOND + 1 1 2 1 + 2 1 3 1 + 3 1 4 1 + 4 1 8 1 + 5 3 16 1 + 6 4 5 1 + 7 8 9 1 + 8 16 17 1 + 9 16 19 1 + 10 3 14 1 + 11 3 15 1 + 12 5 6 1 + 13 5 7 1 + 14 5 10 1 + 15 9 11 1 + 16 9 12 1 + 17 9 13 1 + 18 16 18 1 + 19 17 20 1 + 20 17 21 1 + 21 17 22 1 + 22 19 23 1 + 23 19 24 1 + 24 19 25 1 +@SUBSTRUCTURE + 1 IB1 1 **** 0 **** **** diff --git a/test/Test_FixAtomNames/RunTest.sh b/test/Test_FixAtomNames/RunTest.sh new file mode 100755 index 0000000000..ebe6b25b6e --- /dev/null +++ b/test/Test_FixAtomNames/RunTest.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +. ../MasterTest.sh + +TESTNAME='Fix atom names test' + +CleanFiles fix.in fixed.mol2 +INPUT='-i fix.in' + +UNITNAME='Simple duplicate atom name fix test' +cat > fix.in <MOLECULE +modXNA-fragment:IB1:HEAD01:@P:HEAD01STRIP:@O3',C3,H31,H32,H33:TAIL01:@O5':TAIL01STRIP:@C5',H5'1,H5'2,H5'3 + 25 24 1 0 0 +SMALL +USER_CHARGES + + +@ATOM + 1 P -0.6540 -0.2310 0.2980 P 1 IB1 1.093427 + 2 OP1 -0.7140 -0.9040 1.5850 O2 1 IB1 -0.689124 + 3 C2 0.8550 -0.5030 -0.6600 CT 1 IB1 -0.455618 + 4 O5' -0.8770 1.3380 0.4530 OS 1 IB1 -0.427575 + 5 C5' -1.0610 2.2400 -0.6180 CT 1 IB1 0.016905 + 6 H5'1 -1.7920 1.8640 -1.3210 H1 1 IB1 0.076577 + 7 H5'2 -0.1250 2.4230 -1.1300 H1 1 IB1 0.076577 + 8 O3' -1.7670 -0.6790 -0.7510 OS 1 IB1 -0.427575 + 9 C3 -3.0780 -1.0140 -0.3160 CT 1 IB1 0.016905 + 10 H5'3 -1.4150 3.1650 -0.1880 H1 1 IB1 0.076577 + 11 H31 -3.6080 -1.3720 -1.1860 H1 1 IB1 0.076577 + 12 H32 -3.5800 -0.1400 0.0810 H1 1 IB1 0.076577 + 13 H33 -3.0370 -1.7820 0.4410 H1 1 IB1 0.076577 + 14 H7 0.8690 0.1600 -1.5210 HC 1 IB1 0.103543 + 15 H8 0.7550 -1.5100 -1.0540 HC 1 IB1 0.103543 + 16 C9 2.1690 -0.3920 0.1390 CT 1 IB1 0.571278 + 17 C10 3.3280 -0.9310 -0.7040 CT 1 IB1 -0.481884 + 18 H10 2.0680 -1.0200 1.0190 HC 1 IB1 -0.039521 + 19 C11 2.4590 1.0380 0.6050 CT 1 IB1 -0.481884 + 20 H16 4.2590 -0.8950 -0.1460 HC 1 IB1 0.106352 + 21 H11 3.4620 -0.3420 -1.6080 HC 1 IB1 0.106352 + 22 H12 3.1590 -1.9610 -0.9990 HC 1 IB1 0.106352 + 23 H13 3.3960 1.0740 1.1510 HC 1 IB1 0.106352 + 24 H14 1.6830 1.4200 1.2570 HC 1 IB1 0.106352 + 25 H15 2.5500 1.7120 -0.2440 HC 1 IB1 0.106352 +@BOND + 1 1 2 1 + 2 1 3 1 + 3 1 4 1 + 4 1 8 1 + 5 3 16 1 + 6 4 5 1 + 7 8 9 1 + 8 16 17 1 + 9 16 19 1 + 10 3 14 1 + 11 3 15 1 + 12 5 6 1 + 13 5 7 1 + 14 5 10 1 + 15 9 11 1 + 16 9 12 1 + 17 9 13 1 + 18 16 18 1 + 19 17 20 1 + 20 17 21 1 + 21 17 22 1 + 22 19 23 1 + 23 19 24 1 + 24 19 25 1 +@SUBSTRUCTURE + 1 IB1 1 **** 0 **** **** diff --git a/test/Test_Mol2/L01.mol2.1.save b/test/Test_Mol2/L01.mol2.1.save index d54c8619ee..74bbe1a75f 100644 --- a/test/Test_Mol2/L01.mol2.1.save +++ b/test/Test_Mol2/L01.mol2.1.save @@ -2,7 +2,7 @@ MOL 24 25 1 0 0 SMALL -USER_CHARGES +bcc @ATOM