Skip to content
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
54 changes: 33 additions & 21 deletions src/Amber/ParametrizeMoleculeDialog.C
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ ParametrizeMoleculeDialog::ParametrizeMoleculeDialog(QWidget* parent,
setWindowTitle(tr("Parametrize ") + name);

// set up the run button
QPushButton* runButton = m_dialog.buttonBox->button(QDialogButtonBox::Apply);
runButton->setText(tr("Run"));
QPushButton* stopButton = m_dialog.buttonBox->addButton("Stop", QDialogButtonBox::ActionRole);
QPushButton* runButton = m_dialog.runButton;
QPushButton* stopButton = m_dialog.stopButton;
stopButton->setEnabled(false);

// add a spinner
WaitingSpinner* spinner = new WaitingSpinner(this, false, false);
spinner->setRoundness(70.0);
spinner->setMinimumTrailOpacity(15.0);
Expand All @@ -59,8 +59,7 @@ ParametrizeMoleculeDialog::ParametrizeMoleculeDialog(QWidget* parent,
spinner->setLineWidth(2);
spinner->setInnerRadius(3);
spinner->setRevolutionsPerSecond(1);
m_dialog.horizontalLayout->addWidget(spinner);
m_dialog.horizontalLayout->setAlignment(spinner, Qt::AlignLeft);
m_dialog.horizontalLayout->insertWidget(2, spinner);

connect(runButton, &QPushButton::clicked, this, &ParametrizeMoleculeDialog::run);
connect(runButton, &QPushButton::clicked, runButton, [runButton]() { runButton->setEnabled(false); });
Expand Down Expand Up @@ -129,16 +128,21 @@ void ParametrizeMoleculeDialog::runAntechamber()
QString program = QDir(AmberDirectory).filePath("bin/antechamber");
qDebug () << "Antechamber executable location: " << program;

// Set working directory
Layer::System* system(m_molecule->findLayers<Layer::System>(Layer::Parents).first());
antechamber->setWorkingDirectory(system->getFile().absolutePath());
qDebug() << "Antechamber working directory: " << system->getFile().absolutePath();

// Prepare arguments and write the input mol2 file
QString name(m_molecule->text().split(' ').first());
m_molecule->writeToFile(QDir(system->getFile().absolutePath()).filePath(name + "_iqmol" + ".mol2"));
Layer::System* system(m_molecule->findLayers<Layer::System>(Layer::Parents).first());
QString cwd(system->getFile().absolutePath() + QDir::separator() + name);

if (!QDir(cwd).exists()) {
QDir().mkpath(cwd);
}
m_molecule->writeToFile(QDir(cwd).filePath(name + "_iqmol" + ".mol2"));
qDebug() << "charge" << m_molecule->totalCharge() << "multiplicity" << m_molecule->multiplicity() << forceField << name;

// Set working directory
antechamber->setWorkingDirectory(cwd);
qDebug() << "Antechamber working directory: " << cwd;

// Build arguments
QStringList arguments;
arguments << "-i" << name + "_iqmol" + ".mol2"
Expand All @@ -148,8 +152,6 @@ void ParametrizeMoleculeDialog::runAntechamber()
<< "-nc" << QString::number(m_molecule->totalCharge())
<< "-m" << QString::number(m_molecule->multiplicity())
<< "-s" << "2"
<< "-pf" << "yes"
<< "-dr" << "no"
<< "-rn" << name
<< "-at" << forceField
<< "-c" << "bcc";
Expand All @@ -167,7 +169,8 @@ void ParametrizeMoleculeDialog::antechamberFinished(int exitCode, QProcess::Exit
if (exitStatus == QProcess::NormalExit && exitCode == 0) {
qDebug() << "Antechamber finished";
m_dialog.logTextBrowser->append("Antechamber finished normally.\n");
emit m_molecule->parameterFileAvailable(m_molecule->text().split(' ').first() + ".mol2");
QString name(m_molecule->text().split(' ').first());
emit m_molecule->parameterFileAvailable(name + QDir::separator() + name + ".mol2");
runParmchk2();
} else {
qDebug() << "Antechamber crashed";
Expand Down Expand Up @@ -197,19 +200,27 @@ void ParametrizeMoleculeDialog::runParmchk2()
qDebug() << "Parmchk2 executable location: " << program;

// Set working directory
Layer::System* system(m_molecule->findLayers<Layer::System>(Layer::Parents).first());
parmchk2->setWorkingDirectory(system->getFile().absolutePath());
qDebug() << "Parmchk2 working directory: " << system->getFile().absolutePath();

// Prepare arguments
QString name(m_molecule->text().split(' ').first());
Layer::System* system(m_molecule->findLayers<Layer::System>(Layer::Parents).first());
QString cwd(system->getFile().absolutePath() + QDir::separator() + name);
parmchk2->setWorkingDirectory(cwd);
qDebug() << "Parmchk2 working directory: " << cwd;

QString forceFieldOption;
if (forceField == "gaff") {
forceFieldOption = "1";
} else if (forceField == "gaff2") {
forceFieldOption = "2";
} else {
forceFieldOption = "3";
}

// Build arguments
QStringList arguments;
arguments << "-i" << name + ".mol2"
<< "-f" << "mol2"
<< "-o" << name + ".frcmod"
<< "-s" << "2"
<< "-s" << forceFieldOption
<< "-a" << "N"
<< "-w" << "Y";
qDebug() << "Arguments: " << arguments;
Expand All @@ -226,7 +237,8 @@ void ParametrizeMoleculeDialog::parmchk2Finished(int exitCode, QProcess::ExitSta
if (exitStatus == QProcess::NormalExit && exitCode == 0) {
qDebug() << "Parmchk2 finished";
m_dialog.logTextBrowser->append("Parmchk2 finished normally.\n");
emit m_molecule->parameterFileAvailable(m_molecule->text().split(' ').first() + ".frcmod");
QString name(m_molecule->text().split(' ').first());
emit m_molecule->parameterFileAvailable(name + QDir::separator() + name + ".frcmod");
} else {
qDebug() << "Parmchk2 crashed";
m_dialog.logTextBrowser->append("Parmchk2 crashed.\n");
Expand Down
110 changes: 62 additions & 48 deletions src/Amber/ParametrizeMoleculeDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>245</width>
<height>420</height>
<height>461</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -96,32 +96,53 @@
<string notr="true">amber</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">bcc</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">sybyl</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Close</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="runButton">
<property name="text">
<string>Run</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="stopButton">
<property name="text">
<string>Stop</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
Expand All @@ -131,39 +152,32 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Output:</string>
</property>
</widget>
</item>
</layout>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Output:</string>
</property>
</widget>
</item>
<item>
<widget class="QTextBrowser" name="logTextBrowser"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ParametrizeMoleculeDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>122</x>
<y>210</y>
</hint>
<hint type="destinationlabel">
<x>122</x>
<y>115</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
Expand All @@ -172,7 +186,7 @@
<hints>
<hint type="sourcelabel">
<x>122</x>
<y>210</y>
<y>440</y>
</hint>
<hint type="destinationlabel">
<x>122</x>
Expand Down
4 changes: 2 additions & 2 deletions src/Amber/SystemBuilderDialog.C
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ void SystemBuilderDialog::resetTleapInput()
if (atoms.size() > 1) {
QString name((*it)->text().split(' ').first());
addMolecule(*it);
findParameterFile(name + ".mol2");
findParameterFile(name + ".frcmod");
findParameterFile(name + QDir::separator() + name + ".mol2");
findParameterFile(name + QDir::separator() + name + ".frcmod");
}
}

Expand Down