use of net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibrarySubmitIonParameters in project mzmine2 by mzmine.
the class LibrarySubmitTask method run.
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
for (Entry<LibrarySubmitIonParameters, DataPoint[]> e : map.entrySet()) {
LibrarySubmitIonParameters param = e.getKey();
DataPoint[] dps = e.getValue();
// at least 2 data points
if (dps != null && dps.length > 2) {
// export / submit json?
if (fileJson != null || submitGNPS) {
String json = GnpsJsonGenerator.generateJSON(param, dps);
log.info(json);
if (saveLocal && fileJson != null) {
if (writeToLocalGnpsJsonFile(fileJson, json))
writeResults("GNPS json entry successfully writen" + fileJson.getAbsolutePath(), Result.SUCCED);
else
writeResults("Error while writing GNPS json entry to " + fileJson.getAbsolutePath(), Result.ERROR);
}
if (submitGNPS)
submitGNPS(json);
}
// export msp?
if (fileMSP != null) {
if (writeToLocalMSPFIle(fileMSP, param, dps))
writeResults("MSP entry successfully writen to " + fileMSP.getAbsolutePath(), Result.SUCCED);
else
writeResults("Error while writing msp entry to " + fileMSP.getAbsolutePath(), Result.ERROR);
}
}
done++;
}
setStatus(TaskStatus.FINISHED);
}
use of net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibrarySubmitIonParameters in project mzmine2 by mzmine.
the class MSMSLibrarySubmissionWindow method createIonParameters.
/**
* The full set of parameters for the submission/creation of one library entry
*
* @param paramSubmit
* @param paramMeta
* @param ion
* @return
*/
private LibrarySubmitIonParameters createIonParameters(LibrarySubmitParameters paramSubmit, LibraryMetaDataParameters paramMeta, ScanSelectPanel ion) {
LibrarySubmitIonParameters ionParam = new LibrarySubmitIonParameters();
ionParam.getParameter(LibrarySubmitIonParameters.META_PARAM).setValue(paramMeta);
ionParam.getParameter(LibrarySubmitIonParameters.SUBMIT_PARAM).setValue(paramSubmit);
if (isFragmentScan) {
String adduct = ion.getAdduct();
double precursorMZ = ion.getPrecursorMZ();
int charge = ion.getPrecursorCharge();
ionParam.getParameter(LibrarySubmitIonParameters.ADDUCT).setValue(adduct == null || adduct.isEmpty() ? null : adduct);
ionParam.getParameter(LibrarySubmitIonParameters.CHARGE).setValue(charge == 0 ? null : charge);
ionParam.getParameter(LibrarySubmitIonParameters.MZ).setValue(precursorMZ == 0d ? null : precursorMZ);
} else {
// MS1
ionParam.getParameter(LibrarySubmitIonParameters.ADDUCT).setValue(null);
ionParam.getParameter(LibrarySubmitIonParameters.CHARGE).setValue(null);
ionParam.getParameter(LibrarySubmitIonParameters.MZ).setValue(null);
}
return (LibrarySubmitIonParameters) ionParam.cloneParameterSet();
}
use of net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibrarySubmitIonParameters 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