use of net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.LibrarySubmitTask in project mzmine2 by mzmine.
the class MSMSLibrarySubmissionWindow method submitSpectra.
/**
* Submit. Checks parameters and adduct for each selected ion
*/
private void submitSpectra() {
if (checkParameters()) {
// check number of ions
int ions = countSelectedIons();
// for ms level >1 (fragmentation scan MS/MS)
int mslevel = paramMeta.getParameter(LibraryMetaDataParameters.MS_LEVEL).getValue();
if (mslevel == 1)
paramSubmit.getParameter(LibrarySubmitParameters.SUBMIT_GNPS).setValue(false);
else {
int adducts = countSelectedAdducts();
// every valid selected ion needs an adduct for MS2
if (ions != adducts) {
MZmineCore.getDesktop().displayErrorMessage(this, "ERROR", MessageFormat.format("Not all adducts are set: {0} ion spectra selected and only {1} adducts set", ions, adducts));
return;
}
}
//
if (ions == 0) {
log.info("No MS/MS spectrum selected or valid");
DialogLoggerUtil.showMessageDialogForTime(this, "Error", "No MS/MS spectrum selected or valid", 1500);
} else {
String message = ions + " MS/MS spectra were selected. Submit?";
if (mslevel > 1) {
message += " (" + streamSelection().filter(pn -> pn.isValidAndSelected() && pn.hasAdduct()).map(ScanSelectPanel::getAdduct).collect(Collectors.joining(", ")) + ")";
} else {
message += " (MS1)";
}
// show accept dialog
if (DialogLoggerUtil.showDialogYesNo(this, "Submission?", message)) {
// create library / submit to GNPS
HashMap<LibrarySubmitIonParameters, DataPoint[]> map = new HashMap<>(ions);
for (ScanSelectPanel ion : pnScanSelect) {
if (ion.isValidAndSelected()) {
// create ion param
LibrarySubmitIonParameters ionParam = createIonParameters(paramSubmit, paramMeta, ion);
DataPoint[] dps = ion.getFilteredDataPoints();
// submit and save locally
map.put(ionParam, dps);
}
}
// start task
log.info("Added task to export library entries: " + ions + " MS/MS spectra were selected");
LibrarySubmitTask task = new LibrarySubmitTask(this, map);
MZmineCore.getTaskController().addTask(task);
}
}
}
}
Aggregations