diff --git a/src/Amber/ParametrizeMoleculeDialog.C b/src/Amber/ParametrizeMoleculeDialog.C index f15eabb..bcfdb9c 100644 --- a/src/Amber/ParametrizeMoleculeDialog.C +++ b/src/Amber/ParametrizeMoleculeDialog.C @@ -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); @@ -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); }); @@ -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::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::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" @@ -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"; @@ -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"; @@ -197,19 +200,27 @@ void ParametrizeMoleculeDialog::runParmchk2() qDebug() << "Parmchk2 executable location: " << program; // Set working directory - Layer::System* system(m_molecule->findLayers(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::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; @@ -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"); diff --git a/src/Amber/ParametrizeMoleculeDialog.ui b/src/Amber/ParametrizeMoleculeDialog.ui index 82bd308..dbb1d17 100644 --- a/src/Amber/ParametrizeMoleculeDialog.ui +++ b/src/Amber/ParametrizeMoleculeDialog.ui @@ -7,7 +7,7 @@ 0 0 245 - 420 + 461 @@ -96,32 +96,53 @@ amber - - - bcc - - - - - sybyl - - - - - Qt::Horizontal - - - QDialogButtonBox::Apply|QDialogButtonBox::Close - - - false - - + + + + + Run + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Stop + + + + @@ -131,39 +152,32 @@ - - - - - Output: - - - - + + + Output: + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + false + + + - - buttonBox - accepted() - ParametrizeMoleculeDialog - accept() - - - 122 - 210 - - - 122 - 115 - - - buttonBox rejected() @@ -172,7 +186,7 @@ 122 - 210 + 440 122 diff --git a/src/Amber/SystemBuilderDialog.C b/src/Amber/SystemBuilderDialog.C index b268c9f..2e46f76 100644 --- a/src/Amber/SystemBuilderDialog.C +++ b/src/Amber/SystemBuilderDialog.C @@ -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"); } }