Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Depracated action tracking #1160

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! FIELDS time b.lessthan brf.lessthan br.lessthan p.lessthan prf.lessthan pr.lessthan sum
#! FIELDS time b_lessthan brf_lessthan br_lessthan p_lessthan prf_lessthan pr_lessthan sum
0.000000 0.0607 0.1654 0.1654 0.2681 0.1425 0.1425 0.3287
0.050000 0.0000 42.5600 42.5600 14.6579 4.1424 4.1424 14.6579
0.100000 0.0188 34.0262 34.0262 13.0049 3.2851 3.2851 13.0238
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! FIELDS time b.lessthan brf.lessthan br.lessthan p.lessthan prf.lessthan pr.lessthan sum @8.bias @8.force2
#! FIELDS time b_lessthan brf_lessthan br_lessthan p_lessthan prf_lessthan pr_lessthan sum r.bias r.force2
0.000000 -0.3893763023 -0.1653910914 -0.1653910914 -0.5967893540 -0.1425260828 -0.1425260828 -0.3287218854 0.0000000000 0.0000000000
0.050000 -14.6578542139 -42.5600014141 -42.5600014141 -29.3157084279 -4.1424316083 -4.1424316083 -14.6578542139 0.0000000000 0.0000000000
0.100000 -13.0426114706 -34.0261914601 -34.0261914601 -26.0287209912 -3.2850812434 -3.2850812434 -13.0237774873 0.0000000000 0.0000000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ PARABETARMSD RESIDUES=all TYPE=OPTIMAL-FAST STRANDS_CUTOFF=1.0 LESS_THAN={RATION
PARABETARMSD RESIDUES=all TYPE=OPTIMAL STRANDS_CUTOFF=1.0 LESS_THAN={RATIONAL R_0=0.1 NN=8 MM=12 NOSTRETCH} LABEL=pr
COMBINE ARG=b.lessthan,p.lessthan PERIODIC=NO LABEL=sum

RESTRAINT ARG=b.*,brf.*,br.*,p.*,prf.*,pr.*,sum KAPPA=1.,1.,1.,1,1,1,1 AT=0,0,0,0,0,0,0 SLOPE=0,0,0,0,0,0,0
r: RESTRAINT ARG=b.*,brf.*,br.*,p.*,prf.*,pr.*,sum KAPPA=1.,1.,1.,1,1,1,1 AT=0,0,0,0,0,0,0 SLOPE=0,0,0,0,0,0,0

DUMPFORCES ARG=* FILE=forces STRIDE=1
DUMPFORCES ARG=b.*,brf.*,br.*,p.*,prf.*,pr.*,sum,r.* FILE=forces STRIDE=1

PRINT ARG=b.*,brf.*,br.*,p.*,prf.*,pr.*,sum STRIDE=1 FILE=colvar FMT=%8.4f

10 changes: 10 additions & 0 deletions src/cltools/GenJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@
// Now output keyword information
Keywords keys; actionRegister().getKeywords( action_names[i], keys );
std::cout<<" \"displayname\" : \""<<keys.getDisplayName()<<"\",\n";
// This is used for noting actions that have been deprecated
std::string replacement = keys.getReplacementAction();
if( replacement!="none" ) {
bool found=false;

Check notice

Code scanning / CodeQL

Declaration hides variable Note

Variable found hides another variable of the same name (on
line 117
).
for(unsigned j=0; j<action_names.size(); ++j) {
if( action_names[j]==replacement ) { found=true; break; }
}
if( !found ) error("could not find action named " + replacement + " that is supposed to be used to replace " + action_names[i] );
}
std::cout<<" \"replacement\" : \""<<replacement<<"\",\n";
std::cout<<" \"syntax\" : {"<<std::endl;
for(unsigned j=0; j<keys.size(); ++j) {
std::string defa = "", desc = keys.getKeywordDescription( keys.getKeyword(j) );
Expand Down
7 changes: 4 additions & 3 deletions src/core/ActionRegister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ std::unique_ptr<Action> ActionRegister::create(const std::vector<void*> & images

auto content=get(images,ao.line[0]);
Keywords keys; keys.thisactname = ao.line[0];
content.keys(keys);
keys.replaceaction = "none"; content.keys(keys);
ActionOptions nao( ao,keys );
auto fullPath=getFullPath(images,ao.line[0]);
nao.setFullPath(fullPath);
Expand Down Expand Up @@ -79,7 +79,7 @@ bool ActionRegister::printTemplate(const std::string& action, bool include_optio
//no need to insert the try/catch block: check will ensure that action is known
if( check(action) ) {
Keywords keys; keys.thisactname = action;
get(action).keys(keys);
keys.replaceaction = "none"; get(action).keys(keys);
keys.print_template(action, include_optional);
return true;
} else {
Expand All @@ -101,14 +101,15 @@ bool ActionRegister::getKeywords(const std::string& action, Keywords& keys) {
//no need to insert the try/catch block: check will ensure that action is known
if(check(action)) {
keys.thisactname = action;
keys.replaceaction = "none";
get(action).keys(keys);
return true;
}
return false;
}

void ActionRegister::getKeywords(const std::vector<void*> & images, const std::string& action, Keywords& keys) {
auto content=get(images,action); keys.thisactname = action; content.keys(keys);
auto content=get(images,action); keys.thisactname = action; keys.replaceaction = "none"; content.keys(keys);
}

}
1 change: 1 addition & 0 deletions src/multicolvar/DumpMultiColvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ PLUMED_REGISTER_ACTION(DumpMultiColvar,"DUMPMULTICOLVAR")

void DumpMultiColvar::registerKeywords(Keywords& keys) {
ActionShortcut::registerKeywords( keys );
keys.setDeprecated("DUMPATOMS");
keys.add("compulsory","DATA","the vector you wish to transform");
keys.add("compulsory","FILE","the file that you would like to output the data to");
keys.remove("HAS_VALUES"); keys.needsAction("DUMPATOMS");
Expand Down
1 change: 1 addition & 0 deletions src/multicolvar/MFilterLess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ PLUMED_REGISTER_ACTION(MFilterLess,"MFILTER_LESS")

void MFilterLess::registerKeywords(Keywords& keys) {
ActionShortcut::registerKeywords( keys );
keys.setDeprecated("LESS_THAN");
keys.add("compulsory","DATA","the vector you wish to transform");
keys.add("compulsory","SWITCH","the switching function that transform");
keys.setValueDescription("vector","a vector that has the same dimension as the input vector with elements equal to one if the corresponding component of the vector is less than a tolerance and zero otherwise");
Expand Down
1 change: 1 addition & 0 deletions src/multicolvar/MFilterMore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ PLUMED_REGISTER_ACTION(MFilterMore,"MFILTER_MORE")

void MFilterMore::registerKeywords(Keywords& keys) {
ActionShortcut::registerKeywords( keys );
keys.setDeprecated("MORE_THAN");
keys.add("compulsory","DATA","the vector you wish to transform");
keys.add("compulsory","SWITCH","the switching function that transform");
keys.addFlag("LOWMEM",false,"this flag does nothing and is present only to ensure back-compatibility");
Expand Down
1 change: 1 addition & 0 deletions src/multicolvar/UWalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ PLUMED_REGISTER_ACTION(UWalls,"UWALLS")

void UWalls::registerKeywords(Keywords& keys) {
ActionShortcut::registerKeywords( keys );
keys.setDeprecated("UPPER_WALLS");
keys.add("compulsory","DATA","the values you want to restrain");
keys.add("compulsory","AT","the radius of the sphere");
keys.add("compulsory","KAPPA","the force constant for the wall. The k_i in the expression for a wall.");
Expand Down
9 changes: 9 additions & 0 deletions src/tools/Keywords.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,4 +776,13 @@ std::string Keywords::getDisplayName() const {
return thisactname;
}

void Keywords::setDeprecated( const std::string& name ) {
replaceaction = name;
}

std::string Keywords::getReplacementAction() const {
return replaceaction;
}


}
6 changes: 6 additions & 0 deletions src/tools/Keywords.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class Keywords {
bool isatoms;
/// The name of the action that has this set of keywords
std::string thisactname;
/// The action to use in place of this deprecated action
std::string replaceaction;
/// The names of the allowed keywords
std::vector<std::string> keys;
/// The names of the reserved keywords
Expand Down Expand Up @@ -217,6 +219,10 @@ class Keywords {
std::string getDisplayName() const ;
/// Set the display name
void setDisplayName( const std::string& name );
/// Get the action that should be used to replace this one if action has been deprecated
std::string getReplacementAction() const ;
/// Note that this action has been deprecated
void setDeprecated( const std::string& name );
};

}
Expand Down
Loading