Skip to content

Commit

Permalink
Fixed multiple bugs; added author information
Browse files Browse the repository at this point in the history
  • Loading branch information
chemsh committed Aug 6, 2019
1 parent b3accc6 commit 38ac049
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 66 deletions.
4 changes: 4 additions & 0 deletions src/plugins/tool_chemshell/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This plugin was written by You Lu, Aug. 2019
# [email protected]


# Meta-Objects
set(chemshelltool_MOC_HDRS
chemshelltool.hui
Expand Down
37 changes: 21 additions & 16 deletions src/plugins/tool_chemshell/chemshelltool.hui
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
/*
*** ChemShell Tool Plugin
*** src/plugins/tool_chemshell/chemshelltool.hui
Copyright T. Youngs 2016-2018
*** Py-ChemShell Tool Plugin
*** src/plugins/tool_chemshell/chemshelltool.hui
Copyright T. Youngs 2016-2019
Copyright Y. Lu 2019

This file is part of Aten.
This file is part of Aten.

Aten is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Aten is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Aten. If not, see <http://www.gnu.org/licenses/>.
Aten is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Aten is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Aten. If not, see <http://www.gnu.org/licenses/>.
*/
/*
This plugin was written by You Lu, Aug. 2019
[email protected]
*/

#ifndef ATEN_CHEMSHELLPLUGIN_H
Expand Down
115 changes: 69 additions & 46 deletions src/plugins/tool_chemshell/chemshelltool_funcs.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
/*
*** ChemShell Tool Functions
*** src/plugins/tool_chemshell/chemshelltool_funcs.cpp
Copyright T. Youngs 2016-2018
This file is part of Aten.
Aten is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Aten is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Aten. If not, see <http://www.gnu.org/licenses/>.
*** Py-ChemShell Tool Functions
*** src/plugins/tool_chemshell/chemshelltool_funcs.cpp
Copyright T. Youngs 2016-2019
Copyright Y. Lu 2019
This file is part of Aten.
Aten is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Aten is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Aten. If not, see <http://www.gnu.org/licenses/>.
*/
/*
This plugin was written by You Lu, Aug. 2019
[email protected]
*/

#include "plugins/tool_chemshell/chemshelltool.hui"
#include "plugins/io_chemshell/chemshell.hui"
#include "plugins/tool_chemshell/chemshelltooldialog.h"
#include "gui/qcustomplot/qcustomplot.hui"
#include "model/model.h"
#include "model/clipboard.h"
#include "base/pattern.h"
Expand All @@ -37,6 +42,7 @@ ChemShellToolPlugin::ChemShellToolPlugin() {
// Setup plugin options
pluginOptions_.add("selected_as_qm", "true");
pluginOptions_.add("replace_suffix", "true");
pluginOptions_.add("_punch_saved" , "false");


// Create dialog if the tool has one
Expand Down Expand Up @@ -171,26 +177,27 @@ bool ChemShellToolPlugin::showDialog() {
}


// YL 06/08/2019: not in use as not suitable to select atoms in plugin
// Select by QM/MM region number ('selecttype <el> <typedesc>')
bool Commands::function_SelectRegion(CommandNode* c, Bundle& obj, ReturnValue& rv)
{
if (obj.notifyNull(Bundle::ModelPointer)) return false;
int nselected = obj.rs()->nSelected();

QRegExp re("*["+c->argc(0)+"]");
re.setPatternSyntax(QRegExp::Wildcard);

obj.rs()->beginUndoState("Select atoms by QM/MM region number");
for (Atom* i = obj.rs()->atoms(); i != NULL; i = i->next)
{
if (!i->type()) continue;
if (re.exactMatch(i->type()->name())) obj.rs()->selectAtom(i);
}
obj.rs()->endUndoState();

rv.set(obj.rs()->nSelected() - nselected);
return true;
}
//bool Commands::function_SelectRegion(CommandNode* c, Bundle& obj, ReturnValue& rv)
//{
// if (obj.notifyNull(Bundle::ModelPointer)) return false;
// int nselected = obj.rs()->nSelected();
//
// QRegExp re("*["+c->argc(0)+"]");
// re.setPatternSyntax(QRegExp::Wildcard);
//
// obj.rs()->beginUndoState("Select atoms by QM/MM region number");
// for (Atom* i = obj.rs()->atoms(); i != NULL; i = i->next)
// {
// if (!i->type()) continue;
// if (re.exactMatch(i->type()->name())) obj.rs()->selectAtom(i);
// }
// obj.rs()->endUndoState();
//
// rv.set(obj.rs()->nSelected() - nselected);
// return true;
//}

void ChemShellToolPlugin::renameKeywords() {
if(pluginOptions_.value("qm_theory") == "GAMESS-UK") {
Expand Down Expand Up @@ -300,6 +307,10 @@ bool ChemShellToolPlugin::runTool() {

for (RefListItem<Model,bool>* ri = targets.first(); ri != NULL; ri = ri->next) {
Model* sourceModel = ri->item;

// start of undo
sourceModel->beginUndoState("Relabel selected atoms");

const int nselected = sourceModel->nSelected();
Atom* selected[nselected];
if(nselected == 0) {
Expand Down Expand Up @@ -341,6 +352,9 @@ bool ChemShellToolPlugin::runTool() {
}
}

// end of undo
sourceModel->endUndoState();

// write to punch
const FilePluginInterface* plugin = pluginStore_->findFilePluginByNickname(PluginTypes::ModelFilePlugin, PluginTypes::ExportPlugin, QString("chemshell"));
if(plugin != NULL) {
Expand All @@ -362,6 +376,7 @@ bool ChemShellToolPlugin::runTool() {
}
}
}
pluginOptions_.add("_punch_saved", "true");
// Update the display
emit(updateWidgets(0));
return true;
Expand Down Expand Up @@ -423,7 +438,13 @@ bool ChemShellToolPlugin::runTool() {

// fragment
QString frag_strbuff = "";
frag_strbuff.append(QString("my_frag = Fragment(coords='%1')\n\n").arg(pluginOptions_.value("new_punch")));
// use new punch file
if(pluginOptions_.value("_punch_saved") == "true") {
frag_strbuff.append(QString("my_frag = Fragment(coords='%1')\n\n").arg(pluginOptions_.value("new_punch")));
// use old punch file
} else {
frag_strbuff.append(QString("my_frag = Fragment(coords='%1')\n\n").arg(sourceModel->filename()));
}
// pass to io_chemshell
IOPluginOptions.add("_frag", frag_strbuff);

Expand Down Expand Up @@ -452,19 +473,21 @@ bool ChemShellToolPlugin::runTool() {

// MM
QString mm_method_strbuff = "";
if(pluginOptions_.value("mm_ff_custom") == "false" && pluginOptions_.value("theory") != "QM") {
strbuff.append(QString("my_ff = DL_FIELD(ff='%1')\n\n").arg(pluginOptions_.value("mm_ff")));
mm_method_strbuff.append(QString("my_ff"));
} else {
mm_method_strbuff.append(pluginOptions_.value("mm_ff"));
if(pluginOptions_.value("theory") != "QM") {
if(pluginOptions_.value("mm_ff_custom") == "false") {
strbuff.append(QString("my_ff = DL_FIELD(ff='%1')\n\n").arg(pluginOptions_.value("mm_ff")));
mm_method_strbuff.append(QString("my_ff"));
} else {
mm_method_strbuff.append(QString("'%1'").arg(pluginOptions_.value("mm_ff")));
}
}

//
QString my_theory = "";
if(pluginOptions_.value("theory") == "QM/MM") {
my_theory.append("my_qmmm");
strbuff.append(QString("my_qm = %1(method=%2").arg(pluginOptions_.value("qm_theory")).arg(qm_method_strbuff));
strbuff.append(QString("my_mm = %1(ff='%2')\n\n").arg(pluginOptions_.value("mm_theory")).arg(pluginOptions_.value("mm_ff")));
strbuff.append(QString("my_mm = %1(ff=%2)\n\n").arg(pluginOptions_.value("mm_theory")).arg(mm_method_strbuff));
strbuff.append("my_qmmm = QMMM(frag=my_frag,\n");
strbuff.append(" qm_regiom=qm_region,\n");
strbuff.append(" qm=my_qm,\n");
Expand All @@ -481,7 +504,7 @@ bool ChemShellToolPlugin::runTool() {
strbuff.append(QString("my_qm = %1(method=%2").arg(pluginOptions_.value("qm_theory")).arg(qm_method_strbuff));
} else if(pluginOptions_.value("theory") == "MM") {
my_theory.append("my_mm");
strbuff.append(QString("my_mm = %1(ff='%2')\n\n").arg(pluginOptions_.value("mm_theory")).arg(mm_method_strbuff));
strbuff.append(QString("my_mm = %1(ff=%2)\n\n").arg(pluginOptions_.value("mm_theory")).arg(mm_method_strbuff));
}
// pass to io_chemshell
IOPluginOptions.add("_theory", strbuff);
Expand Down
9 changes: 7 additions & 2 deletions src/plugins/tool_chemshell/chemshelltooldialog.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*
*** ChemShell Tool Dialog
*** Py-ChemShell Tool Dialog
*** src/plugins/tool_chemshell/chemshelltooldialog.h
Copyright T. Youngs 2007-2018
Copyright T. Youngs 2007-2019
Copyright Y. Lu 2019
This file is part of Aten.
Expand All @@ -18,6 +19,10 @@
You should have received a copy of the GNU General Public License
along with Aten. If not, see <http://www.gnu.org/licenses/>.
*/
/*
This plugin was written by You Lu, Aug. 2019
[email protected]
*/

#ifndef ATEN_RINGSTOOLDIALOG_H
#define ATEN_RINGSTOOLDIALOG_H
Expand Down
15 changes: 15 additions & 0 deletions src/plugins/tool_chemshell/chemshelltooldialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
<property name="text">
<string>my_input.py</string>
</property>
<property name="ToolTip">
<string>Input a desired filename.</string>
</property>
</widget>
</item>
<item row="1" column="0">
Expand Down Expand Up @@ -449,6 +452,9 @@
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContentsOnFirstShow</enum>
</property>
<property name="ToolTip">
<string>Default orgin: centroid of the whole fragment. Edit the generated input script to change to, e.g., an atom's index.</string>
</property>
</widget>
</item>
<item row="12" column="1" colspan="1">
Expand All @@ -468,13 +474,19 @@
<property name="text">
<string>Selected atoms</string>
</property>
<property name="ToolTip">
<string>Selected atoms are used for QM region.</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="labelled_as_qm">
<property name="text">
<string>Atoms labelled with</string>
</property>
<property name="ToolTip">
<string>Atoms labelled with given suffix are used as QM region (e.g., all O2 atoms given 2).</string>
</property>
</widget>
</item>
<item>
Expand All @@ -501,6 +513,9 @@
<property name="text">
<string>Atoms within radius (a.u.)</string>
</property>
<property name="ToolTip">
<string>Default orgin: centroid of the whole fragment. Edit the generated input script to change to, e.g., an atom's index.</string>
</property>
</widget>
</item>
<item>
Expand Down
9 changes: 7 additions & 2 deletions src/plugins/tool_chemshell/chemshelltooldialog_funcs.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*
*** SPRings Tool Dialog Functions
*** Py-ChemShell Tool Dialog Functions
*** src/gui/tool_chemshell/chemshelltooldialog_funcs.cpp
Copyright T. Youngs 2007-2018
Copyright T. Youngs 2007-2019
Copyright Y. Lu 2019
This file is part of Aten.
Expand All @@ -18,6 +19,10 @@
You should have received a copy of the GNU General Public License
along with Aten. If not, see <http://www.gnu.org/licenses/>.
*/
/*
This plugin was written by You Lu, Aug. 2019
[email protected]
*/

#include "plugins/tool_chemshell/chemshelltooldialog.h"
#include "gui/qcustomplot/qcustomplot.hui"
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/tool_chemshell/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 38ac049

Please sign in to comment.