Search in sources :

Example 6 with KovatsIndex

use of net.sf.mzmine.modules.tools.kovats.KovatsValues.KovatsIndex in project mzmine2 by mzmine.

the class KovatsIndexExtractionDialog method handleKovatsSelectionChange.

/**
 * Kovats list selection has changed
 */
private void handleKovatsSelectionChange() {
    updateParameterSetFromComponents();
    // keep rt values
    StringBuilder s = new StringBuilder();
    int i = 0;
    double lastRT = 0;
    for (KovatsIndex ki : selectedKovats) {
        Double rt = lastRT + 1;
        if (parsedValues != null)
            rt = parsedValues.getOrDefault(ki, rt);
        s.append(ki.name() + ":" + rtFormat.format(rt) + ",");
        i++;
        lastRT = rt;
    }
    valuesComponent.setText(s.toString());
    kovatsValuesChanged();
}
Also used : KovatsIndex(net.sf.mzmine.modules.tools.kovats.KovatsValues.KovatsIndex)

Example 7 with KovatsIndex

use of net.sf.mzmine.modules.tools.kovats.KovatsValues.KovatsIndex in project mzmine2 by mzmine.

the class KovatsIndexExtractionDialog method saveToFile.

private synchronized void saveToFile() {
    // need to parse
    if (!parseValues()) {
        logger.log(Level.WARNING, "Parsing of Kovats values failed (text box). Maybe you have to select more markers: " + MIN_MARKERS + " (at least)");
        return;
    }
    final TreeMap<KovatsIndex, Double> values = parsedValues;
    File lastFile = parameterSet.getParameter(KovatsIndexExtractionParameters.lastSavedFile).getValue();
    JFileChooser chooser = new JFileChooser();
    FileNameExtensionFilter ff = new FileNameExtensionFilter("Comma-separated values", "csv");
    chooser.addChoosableFileFilter(ff);
    chooser.setFileFilter(ff);
    if (lastFile != null)
        chooser.setSelectedFile(lastFile);
    if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
        File f = chooser.getSelectedFile();
        // set last file
        setLastFile(f);
        f = FileAndPathUtil.getRealFilePath(f, "csv");
        try {
            // save to file in GNPS GC format
            String exp = getCsvTable(values);
            if (TxtWriter.write(exp, f, false))
                saveFileListener.accept(f);
        } catch (Exception e) {
            logger.log(Level.WARNING, "Error while saving Kovats file to " + f.getAbsolutePath(), e);
        }
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) KovatsIndex(net.sf.mzmine.modules.tools.kovats.KovatsValues.KovatsIndex) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) File(java.io.File) IOException(java.io.IOException)

Aggregations

KovatsIndex (net.sf.mzmine.modules.tools.kovats.KovatsValues.KovatsIndex)7 File (java.io.File)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 JFileChooser (javax.swing.JFileChooser)3 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)3 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)3 Font (java.awt.Font)2 DecimalFormat (java.text.DecimalFormat)2 TreeMap (java.util.TreeMap)2 Range (com.google.common.collect.Range)1 Files (com.google.common.io.Files)1 BasicStroke (java.awt.BasicStroke)1 BorderLayout (java.awt.BorderLayout)1 Color (java.awt.Color)1 Dimension (java.awt.Dimension)1 FlowLayout (java.awt.FlowLayout)1 GridLayout (java.awt.GridLayout)1 Image (java.awt.Image)1 Stroke (java.awt.Stroke)1