completed single row prediction task
package io.github.mzmine.modules.dataprocessing.id_formulaprediction;
+import javafx.application.Platform;
import java.util.Map;
import java.util.logging.Logger;
-import javax.swing.SwingUtilities;
+//import javax.swing.SwingUtilities;
import org.openscience.cdk.formula.MolecularFormulaGenerator;
import org.openscience.cdk.formula.MolecularFormulaRange;
@@ -72,14 +73,14 @@ public class SingleRowPredictionTask extends AbstractTask {
private PeakListRow peakListRow;
private boolean checkIsotopes, checkMSMS, checkRatios, checkRDBE;
private ParameterSet isotopeParameters, msmsParameters, ratiosParameters, rdbeParameters;
+ ResultWindowFX resultWindowFX;
+
/**
*
* @param parameters
- * @param peakList
* @param peakListRow
- * @param peak
- */
+= */
SingleRowPredictionTask(ParameterSet parameters, PeakListRow peakListRow) {
searchedMass = parameters.getParameter(FormulaPredictionParameters.neutralMass).getValue();
@@ -136,10 +137,13 @@ public class SingleRowPredictionTask extends AbstractTask {
setStatus(TaskStatus.PROCESSING);
- resultWindow = new ResultWindow(
+ Platform.runLater(()->{
+ ResultWindowFX rw = new ResultWindowFX(
"Searching for " + MZmineCore.getConfiguration().getMZFormat().format(searchedMass),
peakListRow, searchedMass, charge, this);
- resultWindow.setVisible(true);
+ resultWindowFX = rw;
+ rw.show();
+ });
logger.finest("Starting search for formulas for " + massRange + " Da");
@@ -150,6 +154,9 @@ public class SingleRowPredictionTask extends AbstractTask {
MZmineCore.getDesktop().displayMessage(null, msg);
}
+
+ try {
+
IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();
generator = new MolecularFormulaGenerator(builder, massRange.lowerEndpoint(),
@@ -162,7 +169,7 @@ public class SingleRowPredictionTask extends AbstractTask {
return;
// Mass is ok, so test other constraints
- checkConstraints(cdkFormula);
+ //checkConstraints(cdkFormula);
}
@@ -172,19 +179,24 @@ public class SingleRowPredictionTask extends AbstractTask {
logger.finest(
"Finished formula search for " + massRange + " m/z, found " + foundFormulas + " formulas");
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- resultWindow.setTitle("Finished searching for "
+ Platform.runLater(() -> {
+ resultWindowFX.setTitle("Finished searching for "
+ MZmineCore.getConfiguration().getMZFormat().format(searchedMass) + " amu, "
+ foundFormulas + " formulas found");
-
- }
});
+ }
+ catch (Exception e){
+ e.printStackTrace();
+ setStatus(TaskStatus.ERROR);
+ }
setStatus(TaskStatus.FINISHED);
+
}
+
+
private void checkConstraints(IMolecularFormula cdkFormula) {
// Check elemental ratios
