Search in sources :

Example 1 with ProgressDialogX

use of com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX in project peptide-shaker by compomics.

the class ValidationPanel method displayResults.

// End of variables declaration//GEN-END:variables
/**
 * This method displays results in the panel.
 */
public void displayResults() {
    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.setPrimaryProgressCounterIndeterminate(true);
    progressDialog.setTitle("Updating Validation Data. Please Wait...");
    new Thread(new Runnable() {

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

        @Override
        public void run() {
            groupSelectionTable.setEnabled(true);
            // empty the group table
            DefaultTableModel dm = (DefaultTableModel) groupSelectionTable.getModel();
            dm.getDataVector().removeAllElements();
            dm.fireTableDataChanged();
            PSMaps pSMaps = new PSMaps();
            pSMaps = (PSMaps) peptideShakerGUI.getIdentification().getUrParam(pSMaps);
            int cpt = 0;
            if (null != peptideShakerGUI.getProjectType()) {
                switch(peptideShakerGUI.getProjectType()) {
                    case protein:
                        modifiedMaps.put("Proteins", false);
                        ((DefaultTableModel) groupSelectionTable.getModel()).addRow(new Object[] { cpt + 1, "Proteins" });
                        TargetDecoyMap targetDecoyMap = pSMaps.getProteinMap();
                        TargetDecoyResults targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
                        originalThresholdTypes.put("Proteins", targetDecoyResults.getInputType());
                        originalThresholds.put("Proteins", targetDecoyResults.getUserInput());
                        cpt++;
                        modifiedMaps.put("Peptides", false);
                        ((DefaultTableModel) groupSelectionTable.getModel()).addRow(new Object[] { cpt + 1, "Peptides" });
                        targetDecoyMap = pSMaps.getPeptideMap();
                        targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
                        originalThresholdTypes.put("Peptides", targetDecoyResults.getInputType());
                        originalThresholds.put("Peptides", targetDecoyResults.getUserInput());
                        cpt++;
                        modifiedMaps.put("PSMs", false);
                        ((DefaultTableModel) groupSelectionTable.getModel()).addRow(new Object[] { cpt + 1, "PSMs" });
                        targetDecoyMap = pSMaps.getPsmMap();
                        targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
                        originalThresholdTypes.put("PSMs", targetDecoyResults.getInputType());
                        originalThresholds.put("PSMs", targetDecoyResults.getUserInput());
                        break;
                    case peptide:
                        modifiedMaps.put("Peptides", false);
                        ((DefaultTableModel) groupSelectionTable.getModel()).addRow(new Object[] { cpt + 1, "Peptides" });
                        targetDecoyMap = pSMaps.getPeptideMap();
                        targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
                        originalThresholdTypes.put("Peptides", targetDecoyResults.getInputType());
                        originalThresholds.put("Peptides", targetDecoyResults.getUserInput());
                        cpt++;
                        modifiedMaps.put("PSMs", false);
                        ((DefaultTableModel) groupSelectionTable.getModel()).addRow(new Object[] { cpt + 1, "PSMs" });
                        targetDecoyMap = pSMaps.getPsmMap();
                        targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
                        originalThresholdTypes.put("PSMs", targetDecoyResults.getInputType());
                        originalThresholds.put("PSMs", targetDecoyResults.getUserInput());
                        break;
                    case psm:
                        modifiedMaps.put("PSMs", false);
                        ((DefaultTableModel) groupSelectionTable.getModel()).addRow(new Object[] { cpt + 1, "PSMs" });
                        targetDecoyMap = pSMaps.getPsmMap();
                        targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
                        originalThresholdTypes.put("PSMs", targetDecoyResults.getInputType());
                        originalThresholds.put("PSMs", targetDecoyResults.getUserInput());
                        break;
                    default:
                        break;
                }
            }
            if (groupSelectionTable.getRowCount() > 0) {
                groupSelectionTable.setRowSelectionInterval(0, 0);
            }
            if (!progressDialog.isRunCanceled()) {
                groupSelectionChanged();
                // enable the contextual export options
                confidencePlotExportJButton.setEnabled(true);
                fdrFnrPlotExportJButton.setEnabled(true);
                costBenefitPlotExportJButton.setEnabled(true);
                tabInitiated = true;
            }
            progressDialog.setRunFinished();
        }
    }.start();
}
Also used : ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) TargetDecoyMap(eu.isas.peptideshaker.scoring.targetdecoy.TargetDecoyMap) PSMaps(eu.isas.peptideshaker.scoring.PSMaps) DefaultTableModel(javax.swing.table.DefaultTableModel) TargetDecoyResults(eu.isas.peptideshaker.scoring.targetdecoy.TargetDecoyResults)

Example 2 with ProgressDialogX

use of com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX in project peptide-shaker by compomics.

the class ProteinStructurePanel method updatePdbTable.

/**
 * Update the PDB table according to the selected protein in the protein
 * table.
 *
 * @param proteinKey the current protein key
 */
private void updatePdbTable(long aProteinKey) {
    final long proteinKey = aProteinKey;
    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.setPrimaryProgressCounterIndeterminate(true);
    new Thread(new Runnable() {

        public void run() {
            progressDialog.setTitle("Getting PDB Data. Please Wait...");
            try {
                progressDialog.setVisible(true);
            } catch (IndexOutOfBoundsException e) {
            // ignore
            }
        }
    }, "ProgressDialog").start();
    new Thread("ExtractThread") {

        @Override
        public void run() {
            try {
                // get the accession number of the main match
                ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinKey);
                String tempAccession = proteinMatch.getLeadingAccession();
                // find the pdb matches
                // @TODO: make it possible to cancel this process...
                uniProtPdb = new FindPdbForUniprotAccessions(tempAccession, progressDialog);
                // delete the previous matches
                DefaultTableModel dm = (DefaultTableModel) pdbMatchesJTable.getModel();
                dm.getDataVector().removeAllElements();
                dm.fireTableDataChanged();
                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() && !progressDialog.isRunCanceled(); i++) {
                    peptideTable.setValueAt(false, i, peptideTable.getColumn("PDB").getModelIndex());
                }
                int maxNumberOfChains = 1;
                // add the new matches to the pdb table
                for (int i = 0; i < uniProtPdb.getPdbs().size() && !progressDialog.isRunCanceled(); i++) {
                    PdbParameter lParam = uniProtPdb.getPdbs().get(i);
                    ((DefaultTableModel) pdbMatchesJTable.getModel()).addRow(new Object[] { i + 1, addPdbDatabaseLink(lParam.getPdbaccession()), lParam.getTitle(), lParam.getExperiment_type(), lParam.getBlocks().length });
                    if (lParam.getBlocks().length > maxNumberOfChains) {
                        maxNumberOfChains = lParam.getBlocks().length;
                    }
                }
                if (!progressDialog.isRunCanceled()) {
                    ((JSparklinesBarChartTableCellRenderer) pdbMatchesJTable.getColumn("Chains").getCellRenderer()).setMaxValue(maxNumberOfChains);
                    if (!uniProtPdb.urlWasRead()) {
                        ((TitledBorder) pdbMatchesPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Matches - Not Available Without Internet Connection!" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
                    } else {
                        ((TitledBorder) pdbMatchesPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Matches (" + pdbMatchesJTable.getRowCount() + ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
                    }
                    pdbMatchesPanel.repaint();
                    ((TitledBorder) pdbChainsPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Chains" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
                    pdbChainsPanel.repaint();
                }
                progressDialog.setRunFinished();
            } catch (Exception e) {
                progressDialog.setRunFinished();
                peptideShakerGUI.catchException(e);
            }
        }
    }.start();
}
Also used : FindPdbForUniprotAccessions(com.compomics.util.pdbfinder.FindPdbForUniprotAccessions) DefaultTableModel(javax.swing.table.DefaultTableModel) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) PdbParameter(com.compomics.util.pdbfinder.pdb.PdbParameter)

Example 3 with ProgressDialogX

use of com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX in project peptide-shaker by compomics.

the class ProteinStructurePanel method displayResults.

/**
 * Displays the results in the result tables.
 */
public void displayResults() {
    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.setPrimaryProgressCounterIndeterminate(true);
    progressDialog.setTitle("Updating Data. Please Wait...");
    new Thread(new Runnable() {

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

        @Override
        public void run() {
            try {
                peptideShakerGUI.getIdentificationFeaturesGenerator().setProteinKeys(peptideShakerGUI.getMetrics().getProteinKeys());
                proteinKeys = peptideShakerGUI.getIdentificationFeaturesGenerator().getProcessedProteinKeys(progressDialog, peptideShakerGUI.getFilterParameters());
                setTableProperties();
                // update the table model
                if (proteinTable.getModel() instanceof ProteinTableModel && ((ProteinTableModel) proteinTable.getModel()).isInstantiated()) {
                    ((ProteinTableModel) proteinTable.getModel()).updateDataModel(peptideShakerGUI.getIdentification(), peptideShakerGUI.getIdentificationFeaturesGenerator(), peptideShakerGUI.getProteinDetailsProvider(), peptideShakerGUI.getSequenceProvider(), peptideShakerGUI.getGeneMaps(), peptideShakerGUI.getDisplayFeaturesGenerator(), proteinKeys);
                } else {
                    ProteinTableModel proteinTableModel = new ProteinTableModel(peptideShakerGUI.getIdentification(), peptideShakerGUI.getIdentificationFeaturesGenerator(), peptideShakerGUI.getProteinDetailsProvider(), peptideShakerGUI.getSequenceProvider(), peptideShakerGUI.getGeneMaps(), peptideShakerGUI.getDisplayFeaturesGenerator(), peptideShakerGUI.getExceptionHandler(), proteinKeys);
                    proteinTable.setModel(proteinTableModel);
                }
                setTableProperties();
                showSparkLines(peptideShakerGUI.showSparklines());
                ((DefaultTableModel) proteinTable.getModel()).fireTableDataChanged();
                // update spectrum counting column header tooltip
                if (peptideShakerGUI.getSpectrumCountingParameters().getSelectedMethod() == SpectrumCountingMethod.EMPAI) {
                    proteinTableToolTips.set(proteinTable.getColumn("MS2 Quant.").getModelIndex(), "Protein MS2 Quantification - emPAI");
                } else if (peptideShakerGUI.getSpectrumCountingParameters().getSelectedMethod() == SpectrumCountingMethod.NSAF) {
                    proteinTableToolTips.set(proteinTable.getColumn("MS2 Quant.").getModelIndex(), "Protein MS2 Quantification - NSAF");
                } else {
                    proteinTableToolTips.set(proteinTable.getColumn("MS2 Quant.").getModelIndex(), "Protein MS2 Quantification");
                }
                if (peptideShakerGUI.getDisplayParameters().showScores()) {
                    proteinTableToolTips.set(proteinTable.getColumnCount() - 2, "Protein Score");
                } else {
                    proteinTableToolTips.set(proteinTable.getColumnCount() - 2, "Protein Confidence");
                }
                String title = PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Proteins (";
                int nValidated = peptideShakerGUI.getIdentificationFeaturesGenerator().getNValidatedProteins();
                int nConfident = peptideShakerGUI.getIdentificationFeaturesGenerator().getNConfidentProteins();
                int nProteins = proteinTable.getRowCount();
                if (nConfident > 0) {
                    title += nValidated + "/" + nProteins + " - " + nConfident + " confident, " + (nValidated - nConfident) + " doubtful";
                } else {
                    title += nValidated + "/" + nProteins;
                }
                title += ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING;
                ((TitledBorder) proteinsPanel.getBorder()).setTitle(title);
                proteinsPanel.repaint();
                updateProteinTableCellRenderers();
                // enable the contextual export options
                exportProteinsJButton.setEnabled(true);
                exportPdbMatchesJButton.setEnabled(true);
                exportPdbChainsJButton.setEnabled(true);
                exportPeptidesJButton.setEnabled(true);
                exportPdbStructureJButton.setEnabled(true);
                peptideShakerGUI.setUpdated(PeptideShakerGUI.STRUCTURES_TAB_INDEX, true);
                progressDialog.setPrimaryProgressCounterIndeterminate(true);
                progressDialog.setTitle("Preparing 3D Structure Tab. Please Wait...");
                peptideShakerGUI.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
                progressDialog.setRunFinished();
                new Thread(new Runnable() {

                    public void run() {
                        long proteinKey = peptideShakerGUI.getSelectedProteinKey();
                        long peptideKey = peptideShakerGUI.getSelectedPeptideKey();
                        String spectrumFile = peptideShakerGUI.getSelectedSpectrumFile();
                        String spectrumTitle = peptideShakerGUI.getSelectedSpectrumTitle();
                        proteinTableMouseReleased(null);
                        peptideShakerGUI.setSelectedItems(proteinKey, peptideKey, spectrumFile, spectrumTitle);
                        updateSelection(true);
                        proteinTable.requestFocus();
                    }
                }, "UpdateSelectionThread").start();
            } catch (Exception e) {
                progressDialog.setRunFinished();
                peptideShakerGUI.catchException(e);
            }
        }
    }.start();
}
Also used : ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) ProteinTableModel(eu.isas.peptideshaker.gui.tablemodels.ProteinTableModel) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Example 4 with ProgressDialogX

use of com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX in project peptide-shaker by compomics.

the class QCPanel method updatePeptideQCPlot.

/**
 * Updates the peptide QC plot.
 */
private void updatePeptideQCPlot() {
    // see if we need to update
    if ((peptideValidatedPsmsJRadioButton.isSelected() && currentPeptidePlotType != PlotType.Peptide_Validated_PSMs) || (peptideMissedCleavagesJRadioButton.isSelected() && currentPeptidePlotType != PlotType.Peptide_Missed_Cleavages) || (peptideLengthJRadioButton.isSelected() && currentPeptidePlotType != PlotType.Peptide_Length) || (peptideModificationsJRadioButton.isSelected() && currentPeptidePlotType != PlotType.Peptide_Modifications) || (peptideModificationEfficiencyJRadioButton.isSelected() && currentPeptidePlotType != PlotType.Peptide_Modification_Efficiency) || (peptideModificationSpecificityJRadioButton.isSelected() && currentPeptidePlotType != PlotType.Peptide_Modification_Specificity)) {
        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.setPrimaryProgressCounterIndeterminate(true);
        progressDialog.setTitle("Loading QC Plot. Please Wait...");
        new Thread(new Runnable() {

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

            @Override
            public void run() {
                progressDialog.setMaxPrimaryProgressCounter(peptideShakerGUI.getIdentification().getPeptideIdentification().size());
                progressDialog.setTitle("Getting Peptide Dataset. Please Wait...");
                getPeptideDataset();
                progressDialog.setTitle("Loading Peptide QC Plots. Please Wait...");
                try {
                    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
                    ArrayList<Double> bins = new ArrayList<>();
                    if (peptideValidatedPsmsJRadioButton.isSelected()) {
                        bins.add(0.0);
                        bins.add(1.0);
                        bins.add(2.0);
                        bins.add(3.0);
                        bins.add(5.0);
                        bins.add(10.0);
                        bins.add(20.0);
                        bins.add(50.0);
                        bins.add(100.0);
                        bins.add(200.0);
                        bins.add(500.0);
                        getBinData(bins, validatedValues, dataset, "Confident", true);
                        getBinData(bins, validatedDoubtfulValues, dataset, "Doubtful", true);
                        getBinData(bins, nonValidatedValues, dataset, "Not Validated", true);
                        currentPeptidePlotType = PlotType.Peptide_Validated_PSMs;
                    } else if (peptideMissedCleavagesJRadioButton.isSelected()) {
                        bins.add(0.0);
                        bins.add(1.0);
                        bins.add(2.0);
                        bins.add(3.0);
                        getBinData(bins, validatedValues, dataset, "Confident", true);
                        getBinData(bins, validatedDoubtfulValues, dataset, "Doubtful", true);
                        getBinData(bins, nonValidatedValues, dataset, "Not Validated", true);
                        currentPeptidePlotType = PlotType.Peptide_Missed_Cleavages;
                    } else if (peptideLengthJRadioButton.isSelected()) {
                        PeptideAssumptionFilter idFilter = peptideShakerGUI.getIdentificationParameters().getPeptideAssumptionFilter();
                        int min = idFilter.getMinPepLength();
                        int max = idFilter.getMaxPepLength();
                        for (int i = min; i < max; i++) {
                            bins.add(Double.valueOf(i));
                        }
                        getBinData(bins, validatedValues, dataset, "Confident", true);
                        getBinData(bins, validatedDoubtfulValues, dataset, "Doubtful", true);
                        getBinData(bins, nonValidatedValues, dataset, "Not Validated", true);
                        currentPeptidePlotType = PlotType.Peptide_Length;
                    } else if (peptideModificationsJRadioButton.isSelected()) {
                        dataset = getPeptideModificationsDataset();
                        currentPeptidePlotType = PlotType.Peptide_Modifications;
                    } else if (peptideModificationEfficiencyJRadioButton.isSelected()) {
                        dataset = getPeptideModificationEfficiencyDataset();
                        currentPeptidePlotType = PlotType.Peptide_Modification_Efficiency;
                    } else if (peptideModificationSpecificityJRadioButton.isSelected()) {
                        dataset = getPeptideModificationEnrichmentSpecificityDataset();
                        currentPeptidePlotType = PlotType.Peptide_Modification_Specificity;
                    }
                    if (!progressDialog.isRunCanceled()) {
                        JFreeChart peptideChart = ChartFactory.createStackedBarChart(null, null, "Number of Peptides", dataset, PlotOrientation.VERTICAL, true, true, true);
                        StackedBarRenderer renderer = new StackedBarRenderer();
                        renderer.setShadowVisible(false);
                        if (peptideModificationEfficiencyJRadioButton.isSelected() || peptideModificationSpecificityJRadioButton.isSelected()) {
                            renderer.setSeriesPaint(0, histogramColors[0]);
                            renderer.setSeriesPaint(1, histogramColors[4]);
                        } else {
                            renderer.setSeriesPaint(0, histogramColors[0]);
                            renderer.setSeriesPaint(1, histogramColors[1]);
                            renderer.setSeriesPaint(2, histogramColors[4]);
                        }
                        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
                        peptideChart.getCategoryPlot().setRenderer(0, renderer);
                        ChartPanel chartPanel = new ChartPanel(peptideChart);
                        if (peptideValidatedPsmsJRadioButton.isSelected()) {
                            peptideChart.getCategoryPlot().getDomainAxis().setLabel("Number of Validated PSMs");
                            peptideChart.setTitle("Peptides QC Plot - Number of Validated PSMs");
                        } else if (peptideMissedCleavagesJRadioButton.isSelected()) {
                            peptideChart.getCategoryPlot().getDomainAxis().setLabel("Missed Cleavages");
                            peptideChart.setTitle("Peptides QC Plot - Missed Cleavages");
                        } else if (peptideLengthJRadioButton.isSelected()) {
                            peptideChart.getCategoryPlot().getRangeAxis().setLabel("Frequency");
                            peptideChart.getCategoryPlot().getDomainAxis().setLabel("Peptide Length");
                            peptideChart.setTitle("Peptides QC Plot - Peptide Length");
                        } else if (peptideModificationsJRadioButton.isSelected()) {
                            peptideChart.getCategoryPlot().getRangeAxis().setLabel("#Peptides with the Modification");
                            peptideChart.setTitle("Peptides QC Plot - Peptide Modifications");
                            peptideChart.getCategoryPlot().getDomainAxis().setMaximumCategoryLabelLines(5);
                        } else if (peptideModificationEfficiencyJRadioButton.isSelected()) {
                            peptideChart.getCategoryPlot().getRangeAxis().setLabel("Share of Modified Sites [%]");
                            peptideChart.setTitle("Peptides QC Plot - Modification Efficiency");
                            peptideChart.getCategoryPlot().getRangeAxis().setRange(0, 100);
                            peptideChart.getCategoryPlot().getDomainAxis().setMaximumCategoryLabelLines(5);
                        } else if (peptideModificationSpecificityJRadioButton.isSelected()) {
                            peptideChart.getCategoryPlot().getRangeAxis().setLabel("Share of Modified Peptides [%]");
                            peptideChart.setTitle("Peptides QC Plot - Modification Specificity");
                            peptideChart.getCategoryPlot().getRangeAxis().setRange(0, 100);
                            peptideChart.getCategoryPlot().getDomainAxis().setMaximumCategoryLabelLines(5);
                        }
                        // set background color
                        peptideChart.getPlot().setBackgroundPaint(Color.WHITE);
                        peptideChart.setBackgroundPaint(Color.WHITE);
                        chartPanel.setBackground(Color.WHITE);
                        // remove space before/after the domain axis
                        peptideChart.getCategoryPlot().getDomainAxis().setUpperMargin(0);
                        peptideChart.getCategoryPlot().getDomainAxis().setLowerMargin(0);
                        // hide the outline
                        peptideChart.getPlot().setOutlineVisible(false);
                        peptideQCPlotPanel.removeAll();
                        peptideQCPlotPanel.add(chartPanel);
                        peptideQCPlotPanel.revalidate();
                        peptideQCPlotPanel.repaint();
                    }
                    progressDialog.setRunFinished();
                } catch (Exception e) {
                    progressDialog.setRunCanceled();
                    progressDialog.setRunFinished();
                    peptideShakerGUI.catchException(e);
                }
            }
        }.start();
    }
}
Also used : StackedBarRenderer(org.jfree.chart.renderer.category.StackedBarRenderer) ChartPanel(org.jfree.chart.ChartPanel) ArrayList(java.util.ArrayList) JFreeChart(org.jfree.chart.JFreeChart) ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) StandardCategoryToolTipGenerator(org.jfree.chart.labels.StandardCategoryToolTipGenerator) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) PeptideAssumptionFilter(com.compomics.util.experiment.identification.filtering.PeptideAssumptionFilter)

Example 5 with ProgressDialogX

use of com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX in project peptide-shaker by compomics.

the class QCPanel method updatePsmQCPlot.

/**
 * Updates the PSM QC plot.
 */
private void updatePsmQCPlot() {
    // see if we need to update
    if ((psmPrecursorMassErrorJRadioButton.isSelected() && currentPsmPlotType != PlotType.PSM_Precursor_Mass_Error) || (psmPrecursorChargeJRadioButton.isSelected() && currentPsmPlotType != PlotType.PSM_Precursor_Charge)) {
        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.setPrimaryProgressCounterIndeterminate(true);
        progressDialog.setTitle("Loading QC Plot. Please Wait...");
        new Thread(new Runnable() {

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

            @Override
            public void run() {
                progressDialog.setMaxPrimaryProgressCounter(peptideShakerGUI.getIdentification().getSpectrumIdentificationSize());
                progressDialog.setTitle("Getting PSM Dataset. Please Wait...");
                getPsmDataset();
                progressDialog.setTitle("Loading PSM QC Plots. Please Wait...");
                DefaultCategoryDataset dataset = new DefaultCategoryDataset();
                ArrayList<Double> bins = new ArrayList<>();
                if (psmPrecursorMassErrorJRadioButton.isSelected()) {
                    double prec = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getPrecursorAccuracy();
                    int nBins = 20;
                    for (int i = -nBins; i <= nBins; i++) {
                        double bin = i * prec / nBins;
                        bins.add(bin);
                    }
                    getBinData(bins, validatedValues, dataset, "Confident", false);
                    getBinData(bins, validatedDoubtfulValues, dataset, "Doubtful", false);
                    getBinData(bins, nonValidatedValues, dataset, "Not Validated", false);
                    currentPsmPlotType = PlotType.PSM_Precursor_Mass_Error;
                } else if (psmPrecursorChargeJRadioButton.isSelected()) {
                    int maxCharge = peptideShakerGUI.getMetrics().getMaxCharge();
                    for (int i = 0; i <= maxCharge; i++) {
                        bins.add((double) i);
                    }
                    getBinData(bins, validatedValues, dataset, "Confident", true);
                    getBinData(bins, validatedDoubtfulValues, dataset, "Doubtful", true);
                    getBinData(bins, nonValidatedValues, dataset, "Not Validated", true);
                    currentPsmPlotType = PlotType.PSM_Precursor_Charge;
                }
                if (!progressDialog.isRunCanceled()) {
                    JFreeChart psmChart = ChartFactory.createStackedBarChart(null, null, "Number of PSMs", dataset, PlotOrientation.VERTICAL, true, true, true);
                    StackedBarRenderer renderer = new StackedBarRenderer();
                    renderer.setShadowVisible(false);
                    renderer.setSeriesPaint(0, histogramColors[0]);
                    renderer.setSeriesPaint(1, histogramColors[1]);
                    renderer.setSeriesPaint(2, histogramColors[4]);
                    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
                    psmChart.getCategoryPlot().setRenderer(0, renderer);
                    ChartPanel chartPanel = new ChartPanel(psmChart);
                    if (psmPrecursorMassErrorJRadioButton.isSelected()) {
                        psmChart.getCategoryPlot().getDomainAxis().setLabel("Precursor m/z Error");
                        psmChart.setTitle("PSMs QC Plot - Precursor m/z Error");
                    } else if (psmPrecursorChargeJRadioButton.isSelected()) {
                        psmChart.getCategoryPlot().getDomainAxis().setLabel("Precursor Charge");
                        psmChart.setTitle("PSMs QC Plot - Precursor Charge");
                    }
                    // set background color
                    psmChart.getPlot().setBackgroundPaint(Color.WHITE);
                    psmChart.setBackgroundPaint(Color.WHITE);
                    chartPanel.setBackground(Color.WHITE);
                    // remove space before/after the domain axis
                    psmChart.getCategoryPlot().getDomainAxis().setUpperMargin(0);
                    psmChart.getCategoryPlot().getDomainAxis().setLowerMargin(0);
                    // rotate the x-axis labels to make sure that they are readable
                    if (psmPrecursorMassErrorJRadioButton.isSelected()) {
                        psmChart.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
                    }
                    // hide the outline
                    psmChart.getPlot().setOutlineVisible(false);
                    psmQCPlotPanel.removeAll();
                    psmQCPlotPanel.add(chartPanel);
                    psmQCPlotPanel.revalidate();
                    psmQCPlotPanel.repaint();
                }
                progressDialog.setRunFinished();
            }
        }.start();
    }
}
Also used : StackedBarRenderer(org.jfree.chart.renderer.category.StackedBarRenderer) ChartPanel(org.jfree.chart.ChartPanel) ArrayList(java.util.ArrayList) JFreeChart(org.jfree.chart.JFreeChart) ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) StandardCategoryToolTipGenerator(org.jfree.chart.labels.StandardCategoryToolTipGenerator) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset)

Aggregations

ProgressDialogX (com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX)69 File (java.io.File)23 ArrayList (java.util.ArrayList)16 IOException (java.io.IOException)13 FileNotFoundException (java.io.FileNotFoundException)11 FileAndFileFilter (com.compomics.util.gui.file_handling.FileAndFileFilter)9 DefaultTableModel (javax.swing.table.DefaultTableModel)9 ExportFormat (com.compomics.util.io.export.ExportFormat)7 ExportScheme (com.compomics.util.io.export.ExportScheme)7 ConnectException (java.net.ConnectException)7 MalformedURLException (java.net.MalformedURLException)7 UnknownHostException (java.net.UnknownHostException)7 MavenJarFile (com.compomics.software.autoupdater.MavenJarFile)6 PSParameter (com.compomics.util.experiment.identification.peptide_shaker.PSParameter)6 BufferedWriter (java.io.BufferedWriter)5 FileWriter (java.io.FileWriter)5 FileFilter (javax.swing.filechooser.FileFilter)5 Identification (com.compomics.util.experiment.identification.Identification)4 PeptideMatch (com.compomics.util.experiment.identification.matches.PeptideMatch)4 ExportFeature (com.compomics.util.io.export.ExportFeature)4