Search in sources :

Example 1 with XYDataPoint

use of no.uib.jsparklines.data.XYDataPoint in project peptide-shaker by compomics.

the class ProteinStructurePanel method pdbMatchesJTableMouseReleased.

// GEN-LAST:event_peptideTableMouseReleased
/**
 * Update the PDB structure shown in the Jmol panel.
 *
 * @param evt
 */
private void pdbMatchesJTableMouseReleased(java.awt.event.MouseEvent evt) {
    // GEN-FIRST:event_pdbMatchesJTableMouseReleased
    setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
    boolean loadStructure = true;
    if (pdbMatchesJTable.getSelectedRow() != -1 && currentlyDisplayedPdbFile != null) {
        String tempPdbFile = (String) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), pdbMatchesJTable.getColumn("PDB").getModelIndex());
        if (currentlyDisplayedPdbFile.equalsIgnoreCase(tempPdbFile)) {
            loadStructure = false;
        }
    }
    if (loadStructure) {
        // just a trick to make sure that the users cannot select
        // another row until the selection has been updated
        this.setEnabled(false);
        DefaultTableModel dm = (DefaultTableModel) pdbChainsJTable.getModel();
        dm.getDataVector().removeAllElements();
        dm.fireTableDataChanged();
        // clear the peptide to pdb mappings in the peptide table
        for (int i = 0; i < peptideTable.getRowCount(); i++) {
            peptideTable.setValueAt(false, i, peptideTable.getColumn("PDB").getModelIndex());
        }
        // select the peptide in the table again
        int peptideRow = 0;
        long peptideKey = peptideShakerGUI.getSelectedPeptideKey();
        if (peptideKey != NO_KEY) {
            peptideRow = getPeptideRow(peptideKey);
        }
        if (peptideTable.getRowCount() > 0) {
            peptideTable.setRowSelectionInterval(peptideRow, peptideRow);
            peptideTable.scrollRectToVisible(peptideTable.getCellRect(peptideRow, peptideRow, false));
        }
        // empty the jmol panel
        if (jmolStructureShown) {
            jmolPanel = new JmolPanel();
            pdbPanel.removeAll();
            pdbPanel.add(jmolPanel);
            pdbPanel.revalidate();
            pdbPanel.repaint();
            jmolStructureShown = false;
            currentlyDisplayedPdbFile = null;
            ((TitledBorder) pdbOuterPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Structure" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
            pdbOuterPanel.repaint();
        }
        if (pdbMatchesJTable.getSelectedRow() != -1) {
            currentlyDisplayedPdbFile = (String) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), pdbMatchesJTable.getColumn("PDB").getModelIndex());
            // open protein link in web browser
            if (pdbMatchesJTable.getSelectedColumn() == pdbMatchesJTable.getColumn("PDB").getModelIndex() && evt.getButton() == MouseEvent.BUTTON1 && ((String) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), pdbMatchesJTable.getSelectedColumn())).lastIndexOf("<a href=\"") != -1) {
                String temp = currentlyDisplayedPdbFile.substring(currentlyDisplayedPdbFile.indexOf("\"") + 1);
                currentlyDisplayedPdbFile = temp.substring(0, temp.indexOf("\""));
                this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
                BareBonesBrowserLaunch.openURL(currentlyDisplayedPdbFile);
                this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
            }
            // get the pdb file
            int selectedPdbTableIndex = (Integer) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), 0);
            PdbParameter lParam = uniProtPdb.getPdbs().get(selectedPdbTableIndex - 1);
            chains = lParam.getBlocks();
            // get the protein sequence
            SelfUpdatingTableModel proteinTableModel = (SelfUpdatingTableModel) proteinTable.getModel();
            int proteinIndex = proteinTableModel.getViewIndex(proteinTable.getSelectedRow());
            long proteinKey = proteinKeys[proteinIndex];
            ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinKey);
            String proteinSequence = peptideShakerGUI.getSequenceProvider().getSequence(proteinMatch.getLeadingAccession());
            // add the chain information to the table
            for (int j = 0; j < chains.length; j++) {
                XYDataPoint temp = new XYDataPoint(chains[j].getStartProtein(), chains[j].getEndProtein());
                if (chains[j].getStartProtein() != chains[j].getEndProtein()) {
                    ((DefaultTableModel) pdbChainsJTable.getModel()).addRow(new Object[] { (j + 1), chains[j].getBlock(), temp, (((double) chains[j].getEndProtein() - chains[j].getStartProtein()) / proteinSequence.length()) * 100 });
                }
            }
            ((JSparklinesIntervalChartTableCellRenderer) pdbChainsJTable.getColumn("PDB-Protein").getCellRenderer()).setMaxValue(proteinSequence.length());
            if (pdbChainsJTable.getRowCount() > 0) {
                ((TitledBorder) pdbChainsPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Chains (" + pdbChainsJTable.getRowCount() + ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
            } else {
                ((TitledBorder) pdbChainsPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Chains" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
            }
            pdbChainsPanel.repaint();
            if (pdbChainsJTable.getRowCount() > 0) {
                pdbChainsJTable.setRowSelectionInterval(0, 0);
                pdbChainsJTable.scrollRectToVisible(pdbChainsJTable.getCellRect(0, 0, false));
                pdbChainsJTableMouseReleased(null);
            }
        } else {
            ((TitledBorder) pdbChainsPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Chains" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
            pdbChainsPanel.repaint();
        }
        // give the power back to the user ;)
        this.setEnabled(true);
    } else {
        // open protein link in web browser
        if (pdbMatchesJTable.getSelectedColumn() == pdbMatchesJTable.getColumn("PDB").getModelIndex() && evt.getButton() == MouseEvent.BUTTON1 && ((String) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), pdbMatchesJTable.getSelectedColumn())).lastIndexOf("<a href=\"") != -1) {
            String temp = currentlyDisplayedPdbFile.substring(currentlyDisplayedPdbFile.indexOf("\"") + 1);
            currentlyDisplayedPdbFile = temp.substring(0, temp.indexOf("\""));
            this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
            BareBonesBrowserLaunch.openURL(currentlyDisplayedPdbFile);
            this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        }
    }
    setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
}
Also used : DefaultTableModel(javax.swing.table.DefaultTableModel) TitledBorder(javax.swing.border.TitledBorder) XYDataPoint(no.uib.jsparklines.data.XYDataPoint) SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) JSparklinesIntervalChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer) PdbParameter(com.compomics.util.pdbfinder.pdb.PdbParameter) XYDataPoint(no.uib.jsparklines.data.XYDataPoint)

Example 2 with XYDataPoint

use of no.uib.jsparklines.data.XYDataPoint in project peptide-shaker by compomics.

the class ProteinStructurePanel method copyTableContentToClipboardOrFile.

/**
 * Export the table contents to the clipboard.
 *
 * @param index the table index type
 */
private void copyTableContentToClipboardOrFile(TableIndex index) throws IOException {
    final TableIndex tableIndex = index;
    if (tableIndex == TableIndex.PROTEIN_TABLE || tableIndex == TableIndex.PEPTIDE_TABLE) {
        HashMap<String, ArrayList<ExportFeature>> exportFeatures = new HashMap<>();
        ArrayList<ExportFeature> sectionContent = new ArrayList<>();
        String textFileFilterDescription = "Tab separated text file (.txt)";
        String gzipFileFilterDescription = "Gzipped tab separated text file (.gz)";
        String excelFileFilterDescription = "Excel Workbook (.xls)";
        String lastSelectedFolderPath = peptideShakerGUI.getLastSelectedFolder().getLastSelectedFolder();
        String exportName = "Export";
        switch(tableIndex) {
            case PROTEIN_TABLE:
                exportName = "Protein table";
                break;
            case PEPTIDE_TABLE:
                exportName = "Peptide table";
                break;
            default:
                break;
        }
        FileAndFileFilter selectedFileAndFilter = FileChooserUtil.getUserSelectedFile(this, new String[] { ".xls", ".txt", ".gz" }, new String[] { excelFileFilterDescription, textFileFilterDescription, gzipFileFilterDescription }, "Export Report", lastSelectedFolderPath, exportName, false, true, false, 1);
        if (selectedFileAndFilter != null) {
            final File selectedFile = selectedFileAndFilter.getFile();
            final ExportFormat exportFormat;
            final boolean gzip;
            if (selectedFileAndFilter.getFileFilter().getDescription().equalsIgnoreCase(textFileFilterDescription)) {
                exportFormat = ExportFormat.text;
                gzip = false;
            } else if (selectedFileAndFilter.getFileFilter().getDescription().equalsIgnoreCase(gzipFileFilterDescription)) {
                exportFormat = ExportFormat.text;
                gzip = true;
            } else {
                exportFormat = ExportFormat.excel;
                gzip = false;
            }
            progressDialog = new ProgressDialogX(peptideShakerGUI, Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker.gif")), Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker-orange.gif")), true);
            progressDialog.setTitle("Exporting Data. Please Wait...");
            final String filePath = selectedFile.getPath();
            new Thread(new Runnable() {

                public void run() {
                    try {
                        progressDialog.setVisible(true);
                    } catch (IndexOutOfBoundsException e) {
                    // ignore
                    }
                }
            }, "ProgressDialog").start();
            new Thread("ExportThread") {

                @Override
                public void run() {
                    try {
                        switch(tableIndex) {
                            case PROTEIN_TABLE:
                                sectionContent.add(PsProteinFeature.starred);
                                sectionContent.add(PsProteinFeature.pi);
                                sectionContent.add(PsProteinFeature.accession);
                                sectionContent.add(PsProteinFeature.protein_description);
                                sectionContent.add(PsProteinFeature.protein_group);
                                sectionContent.add(PsProteinFeature.descriptions);
                                sectionContent.add(PsProteinFeature.other_proteins);
                                sectionContent.add(PsProteinFeature.chromosome);
                                sectionContent.add(PsProteinFeature.coverage);
                                sectionContent.add(PsProteinFeature.confident_coverage);
                                sectionContent.add(PsProteinFeature.all_coverage);
                                sectionContent.add(PsProteinFeature.possible_coverage);
                                sectionContent.add(PsProteinFeature.validated_peptides);
                                sectionContent.add(PsProteinFeature.peptides);
                                sectionContent.add(PsProteinFeature.unique_peptides);
                                sectionContent.add(PsProteinFeature.unique_validated_peptides);
                                sectionContent.add(PsProteinFeature.validated_psms);
                                sectionContent.add(PsProteinFeature.psms);
                                sectionContent.add(PsProteinFeature.spectrum_counting_nsaf);
                                sectionContent.add(PsProteinFeature.spectrum_counting_empai);
                                sectionContent.add(PsProteinFeature.spectrum_counting_nsaf_percent);
                                sectionContent.add(PsProteinFeature.spectrum_counting_empai_percent);
                                sectionContent.add(PsProteinFeature.spectrum_counting_nsaf_ppm);
                                sectionContent.add(PsProteinFeature.spectrum_counting_empai_ppm);
                                sectionContent.add(PsProteinFeature.spectrum_counting_nsaf_fmol);
                                sectionContent.add(PsProteinFeature.spectrum_counting_empai_fmol);
                                sectionContent.add(PsProteinFeature.mw);
                                sectionContent.add(PsProteinFeature.confidence);
                                sectionContent.add(PsProteinFeature.validated);
                                exportFeatures.put(PsProteinFeature.type, sectionContent);
                                ExportScheme validatedProteinReport = new ExportScheme("Protein Table", false, exportFeatures, "\t", true, true, 0, false, false, false);
                                PSExportFactory.writeExport(validatedProteinReport, selectedFile, exportFormat, gzip, peptideShakerGUI.getProjectParameters().getProjectUniqueName(), peptideShakerGUI.getProjectDetails(), peptideShakerGUI.getIdentification(), peptideShakerGUI.getIdentificationFeaturesGenerator(), peptideShakerGUI.getGeneMaps(), getDisplayedProteins(), null, null, peptideShakerGUI.getDisplayParameters().getnAASurroundingPeptides(), peptideShakerGUI.getIdentificationParameters(), peptideShakerGUI.getSequenceProvider(), peptideShakerGUI.getProteinDetailsProvider(), peptideShakerGUI.getSpectrumProvider(), peptideShakerGUI.getSpectrumCountingParameters(), progressDialog);
                                break;
                            case PEPTIDE_TABLE:
                                sectionContent.add(PsPeptideFeature.starred);
                                sectionContent.add(PsPeptideFeature.pi);
                                sectionContent.add(PsPeptideFeature.accessions);
                                sectionContent.add(PsPeptideFeature.protein_description);
                                sectionContent.add(PsPeptideFeature.protein_groups);
                                sectionContent.add(PsPeptideFeature.sequence);
                                sectionContent.add(PsPeptideFeature.modified_sequence);
                                sectionContent.add(PsPeptideFeature.position);
                                sectionContent.add(PsPeptideFeature.aaBefore);
                                sectionContent.add(PsPeptideFeature.aaAfter);
                                sectionContent.add(PsPeptideFeature.missed_cleavages);
                                sectionContent.add(PsPeptideFeature.variable_ptms);
                                sectionContent.add(PsPeptideFeature.fixed_ptms);
                                sectionContent.add(PsPeptideFeature.psms);
                                sectionContent.add(PsPeptideFeature.validated_psms);
                                sectionContent.add(PsPeptideFeature.confidence);
                                sectionContent.add(PsPeptideFeature.validated);
                                exportFeatures.put(PsPeptideFeature.type, sectionContent);
                                validatedProteinReport = new ExportScheme("Peptide Table", false, exportFeatures, "\t", true, true, 0, false, false, false);
                                PSExportFactory.writeExport(validatedProteinReport, selectedFile, exportFormat, gzip, peptideShakerGUI.getProjectParameters().getProjectUniqueName(), peptideShakerGUI.getProjectDetails(), peptideShakerGUI.getIdentification(), peptideShakerGUI.getIdentificationFeaturesGenerator(), peptideShakerGUI.getGeneMaps(), null, getDisplayedPeptides(), null, peptideShakerGUI.getDisplayParameters().getnAASurroundingPeptides(), peptideShakerGUI.getIdentificationParameters(), peptideShakerGUI.getSequenceProvider(), peptideShakerGUI.getProteinDetailsProvider(), peptideShakerGUI.getSpectrumProvider(), peptideShakerGUI.getSpectrumCountingParameters(), progressDialog);
                                break;
                            default:
                                break;
                        }
                        boolean processCancelled = progressDialog.isRunCanceled();
                        progressDialog.setRunFinished();
                        if (!processCancelled) {
                            JOptionPane.showMessageDialog(peptideShakerGUI, "Data copied to file:\n" + filePath, "Data Exported", JOptionPane.INFORMATION_MESSAGE);
                        }
                    } catch (FileNotFoundException e) {
                        progressDialog.setRunFinished();
                        JOptionPane.showMessageDialog(peptideShakerGUI, "An error occurred while generating the output. Please make sure " + "that the destination file is not opened by another application.", "Output Error", JOptionPane.ERROR_MESSAGE);
                        e.printStackTrace();
                    } catch (IllegalArgumentException e) {
                        if (e.getMessage().contains("Invalid row number (65536)")) {
                            progressDialog.setRunFinished();
                            JOptionPane.showMessageDialog(peptideShakerGUI, // @TODO: update the excel export library?
                            "An error occurred while generating the output. This format can contain only 65,535 lines.\n" + "Please use a text export instead.", "Output Error", JOptionPane.ERROR_MESSAGE);
                            e.printStackTrace();
                        } else {
                            progressDialog.setRunFinished();
                            JOptionPane.showMessageDialog(peptideShakerGUI, "An error occurred while generating the output.", "Output Error", JOptionPane.ERROR_MESSAGE);
                            e.printStackTrace();
                        }
                    } catch (Exception e) {
                        progressDialog.setRunFinished();
                        JOptionPane.showMessageDialog(peptideShakerGUI, "An error occurred while generating the output.", "Output Error", JOptionPane.ERROR_MESSAGE);
                        e.printStackTrace();
                    }
                }
            }.start();
        }
    } else if (tableIndex == TableIndex.PDB_MATCHES || tableIndex == TableIndex.PDB_CHAINS) {
        // get the file to send the output to
        File selectedFile = peptideShakerGUI.getUserSelectedFile("pdb_details.txt", ".txt", "Tab separated text file (.txt)", "Export...", false);
        if (selectedFile != null) {
            if (tableIndex == TableIndex.PDB_CHAINS) {
                try (SimpleFileWriter writer = new SimpleFileWriter(selectedFile, false)) {
                    writer.writeLine("", "Chain", "PDB-Start", "PDB-End", "Coverage");
                    for (int i = 0; i < pdbChainsJTable.getRowCount(); i++) {
                        XYDataPoint pdbCoverage = (XYDataPoint) pdbChainsJTable.getValueAt(i, 2);
                        writer.writeLine(pdbChainsJTable.getValueAt(i, 0).toString(), pdbChainsJTable.getValueAt(i, 1).toString(), Double.toString(pdbCoverage.getX()), Double.toString(pdbCoverage.getY()), pdbChainsJTable.getValueAt(i, 3).toString());
                    }
                    JOptionPane.showMessageDialog(peptideShakerGUI, "Data copied to file:\n" + selectedFile.getPath(), "Data Exported", JOptionPane.INFORMATION_MESSAGE);
                }
            } else if (tableIndex == TableIndex.PDB_MATCHES) {
                try (BufferedWriter writer = new BufferedWriter(new FileWriter(selectedFile))) {
                    Util.tableToFile(pdbMatchesJTable, "\t", null, true, writer);
                    JOptionPane.showMessageDialog(peptideShakerGUI, "Data copied to file:\n" + selectedFile.getPath(), "Data Exported", JOptionPane.INFORMATION_MESSAGE);
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) SimpleFileWriter(com.compomics.util.io.flat.SimpleFileWriter) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) ExportFormat(com.compomics.util.io.export.ExportFormat) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter) ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) ExportScheme(com.compomics.util.io.export.ExportScheme) ExportFeature(com.compomics.util.io.export.ExportFeature) XYDataPoint(no.uib.jsparklines.data.XYDataPoint) File(java.io.File) SimpleFileWriter(com.compomics.util.io.flat.SimpleFileWriter) FileAndFileFilter(com.compomics.util.gui.file_handling.FileAndFileFilter)

Example 3 with XYDataPoint

use of no.uib.jsparklines.data.XYDataPoint in project peptide-shaker by compomics.

the class FractionDetailsDialog method addData.

/**
 * Add the data to the table.
 */
private void addData() {
    ArrayList<String> fractions = peptideShakerGUI.getIdentification().getFractions();
    HashMap<String, XYDataPoint> expectedMolecularWeightRanges = peptideShakerGUI.getIdentificationParameters().getFractionParameters().getFractionMolecularWeightRanges();
    int lineNumber = 1;
    for (String fraction : fractions) {
        Double lower = 0.0;
        Double upper = 0.0;
        if (expectedMolecularWeightRanges != null) {
            XYDataPoint dataPoint = expectedMolecularWeightRanges.get(fraction);
            if (dataPoint != null) {
                lower = dataPoint.getX();
                upper = dataPoint.getY();
            }
        }
        ((DefaultTableModel) fractionTable.getModel()).addRow(new Object[] { lineNumber++, IoUtil.getFileName(fraction), lower, upper });
    }
}
Also used : DefaultTableModel(javax.swing.table.DefaultTableModel) XYDataPoint(no.uib.jsparklines.data.XYDataPoint) XYDataPoint(no.uib.jsparklines.data.XYDataPoint)

Example 4 with XYDataPoint

use of no.uib.jsparklines.data.XYDataPoint in project peptide-shaker by compomics.

the class FractionDetailsDialog method importFractionRangesButtonActionPerformed.

// GEN-LAST:event_fractionTableMouseReleased
/**
 * Import the fraction ranges from file.
 *
 * @param evt the action event
 */
private void importFractionRangesButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_importFractionRangesButtonActionPerformed
    // get the file to get the fraction ranges from
    final File selectedFile = peptideShakerGUI.getUserSelectedFile(null, ".txt", "Tab separated text file (.txt)", "Import...", true);
    if (selectedFile != null) {
        ArrayList<XYDataPoint> lowerAndUpper = new ArrayList<>();
        try {
            FileReader r = new FileReader(selectedFile);
            BufferedReader br = new BufferedReader(r);
            String line = br.readLine();
            while (line != null) {
                String[] values = line.split("\\t");
                lowerAndUpper.add(new XYDataPoint(Double.valueOf(values[0]), Double.valueOf(values[1])));
                line = br.readLine();
            }
            br.close();
            r.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(this, "Could not find the file \'" + selectedFile.getAbsolutePath() + "\'.", "File Not Found", JOptionPane.WARNING_MESSAGE);
        } catch (IOException e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(this, "An error occurred when parsing the file \'" + selectedFile.getAbsolutePath() + "\'.", "File Error", JOptionPane.ERROR_MESSAGE);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(this, "One of the values in the file is not a number.\nPlease include tab separated values only.", "File Error", JOptionPane.WARNING_MESSAGE);
        }
        if (lowerAndUpper.size() > fractionTable.getRowCount()) {
            JOptionPane.showMessageDialog(this, "There are more values in the file than there are rows in the table!\nSome rows will be ignored.", "File Error", JOptionPane.WARNING_MESSAGE);
        }
        for (int i = 0; i < lowerAndUpper.size(); i++) {
            ((DefaultTableModel) fractionTable.getModel()).setValueAt(lowerAndUpper.get(i).getX(), i, 2);
            ((DefaultTableModel) fractionTable.getModel()).setValueAt(lowerAndUpper.get(i).getY(), i, 3);
        }
    }
}
Also used : DefaultTableModel(javax.swing.table.DefaultTableModel) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) XYDataPoint(no.uib.jsparklines.data.XYDataPoint) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) XYDataPoint(no.uib.jsparklines.data.XYDataPoint) File(java.io.File)

Example 5 with XYDataPoint

use of no.uib.jsparklines.data.XYDataPoint in project peptide-shaker by compomics.

the class FractionDetailsDialog method okButtonActionPerformed.

// GEN-LAST:event_fractionTableKeyReleased
/**
 * Save the order of the fractions and close the dialog.
 *
 * @param evt the action event
 */
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_okButtonActionPerformed
    ArrayList<String> spectrumFiles = new ArrayList<>();
    HashMap<String, XYDataPoint> fractionRanges = new HashMap<>();
    for (int i = 0; i < fractionTable.getRowCount(); i++) {
        String fileName = (String) fractionTable.getValueAt(i, fractionTable.getColumn("Fraction").getModelIndex());
        spectrumFiles.add(IoUtil.removeExtension(fileName));
        Double lower = (Double) fractionTable.getValueAt(i, fractionTable.getColumn("Lower Range (kDa)").getModelIndex());
        Double upper = (Double) fractionTable.getValueAt(i, fractionTable.getColumn("Upper Range (kDa)").getModelIndex());
        fractionRanges.put(fileName, new XYDataPoint(lower, upper));
    }
    peptideShakerGUI.setUpdated(PeptideShakerGUI.PROTEIN_FRACTIONS_TAB_INDEX, false);
    if (peptideShakerGUI.getSelectedTab() == PeptideShakerGUI.PROTEIN_FRACTIONS_TAB_INDEX) {
        peptideShakerGUI.getProteinFractionsPanel().displayResults();
    }
    peptideShakerGUI.getIdentification().setFractions(spectrumFiles);
    peptideShakerGUI.getIdentificationParameters().getFractionParameters().setFractionMolecularWeightRanges(fractionRanges);
    this.setVisible(false);
    this.dispose();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) XYDataPoint(no.uib.jsparklines.data.XYDataPoint) XYDataPoint(no.uib.jsparklines.data.XYDataPoint)

Aggregations

XYDataPoint (no.uib.jsparklines.data.XYDataPoint)6 DefaultTableModel (javax.swing.table.DefaultTableModel)4 ArrayList (java.util.ArrayList)3 ProteinMatch (com.compomics.util.experiment.identification.matches.ProteinMatch)2 ProgressDialogX (com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 GeneMaps (com.compomics.util.experiment.biology.genes.GeneMaps)1 GoDomains (com.compomics.util.experiment.biology.genes.go.GoDomains)1 GoMapping (com.compomics.util.experiment.biology.genes.go.GoMapping)1 SpeciesFactory (com.compomics.util.experiment.biology.taxonomy.SpeciesFactory)1 Identification (com.compomics.util.experiment.identification.Identification)1 ProteinMatchesIterator (com.compomics.util.experiment.identification.matches_iterators.ProteinMatchesIterator)1 PSParameter (com.compomics.util.experiment.identification.peptide_shaker.PSParameter)1 FastaSummary (com.compomics.util.experiment.io.biology.protein.FastaSummary)1 FileAndFileFilter (com.compomics.util.gui.file_handling.FileAndFileFilter)1 BackgroundSpeciesDialog (com.compomics.util.gui.parameters.identification.advanced.BackgroundSpeciesDialog)1 SelfUpdatingTableModel (com.compomics.util.gui.tablemodels.SelfUpdatingTableModel)1