Search in sources :

Example 1 with NO_KEY

use of com.compomics.util.experiment.personalization.ExperimentObject.NO_KEY in project peptide-shaker by compomics.

the class ProteinStructurePanel method updateSelection.

/**
 * Update the selected protein and peptide.
 *
 * @param scrollToVisible if true the table also scrolls to make the
 * selected row visible
 */
public void updateSelection(boolean scrollToVisible) {
    int proteinRow = 0;
    long proteinKey = peptideShakerGUI.getSelectedProteinKey();
    long peptideKey = peptideShakerGUI.getSelectedPeptideKey();
    String spectrumFile = peptideShakerGUI.getSelectedSpectrumFile();
    String spectrumTitle = peptideShakerGUI.getSelectedSpectrumTitle();
    Identification identification = peptideShakerGUI.getIdentification();
    if (proteinKey == NO_KEY && peptideKey == NO_KEY && spectrumFile != null && spectrumTitle != null) {
        long psmKey = SpectrumMatch.getKey(spectrumFile, spectrumTitle);
        SpectrumMatch spectrumMatch = identification.getSpectrumMatch(psmKey);
        if (spectrumMatch != null && spectrumMatch.getBestPeptideAssumption() != null) {
            Peptide peptide = spectrumMatch.getBestPeptideAssumption().getPeptide();
            peptideKey = peptide.getMatchingKey(peptideShakerGUI.getIdentificationParameters().getSequenceMatchingParameters());
        }
    }
    if (proteinKey == NO_KEY && peptideKey != NO_KEY) {
        final long peptideKeyFinal = peptideKey;
        ProteinMatch tempProteinMatch = identification.getProteinIdentification().parallelStream().map(key -> identification.getProteinMatch(key)).filter(proteinMatch -> Arrays.stream(proteinMatch.getPeptideMatchesKeys()).anyMatch(key -> key == peptideKeyFinal)).findAny().orElse(null);
        if (tempProteinMatch != null) {
            proteinKey = tempProteinMatch.getKey();
            peptideShakerGUI.setSelectedItems(proteinKey, peptideKey, spectrumFile, spectrumTitle);
        }
        if (proteinKey != NO_KEY) {
            proteinRow = getProteinRow(proteinKey);
        }
        if (proteinKeys.length == 0) {
            clearData();
            return;
        }
        if (proteinRow == -1) {
            peptideShakerGUI.resetSelectedItems();
            proteinTableMouseReleased(null);
        } else if (proteinTable.getSelectedRow() != proteinRow) {
            proteinTable.setRowSelectionInterval(proteinRow, proteinRow);
            if (scrollToVisible) {
                proteinTable.scrollRectToVisible(proteinTable.getCellRect(proteinRow, 0, false));
            }
            proteinTableMouseReleased(null);
        }
        int peptideRow = 0;
        if (peptideKey != NO_KEY) {
            peptideRow = getPeptideRow(peptideKey);
        }
        if (peptideTable.getSelectedRow() != peptideRow && peptideRow != -1) {
            peptideTable.setRowSelectionInterval(peptideRow, peptideRow);
            if (scrollToVisible) {
                peptideTable.scrollRectToVisible(peptideTable.getCellRect(peptideRow, 0, false));
            }
            peptideTableMouseReleased(null);
        }
        if (spectrumFile != null && spectrumTitle != null) {
            peptideShakerGUI.setSelectedItems(peptideShakerGUI.getSelectedProteinKey(), peptideShakerGUI.getSelectedPeptideKey(), spectrumFile, spectrumTitle);
        }
    }
}
Also used : Color(java.awt.Color) PsPeptideFeature(com.compomics.util.io.export.features.peptideshaker.PsPeptideFeature) PsProteinFeature(com.compomics.util.io.export.features.peptideshaker.PsProteinFeature) Arrays(java.util.Arrays) JSparklinesArrayListBarChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesArrayListBarChartTableCellRenderer) NO_KEY(com.compomics.util.experiment.personalization.ExperimentObject.NO_KEY) IdentificationFeaturesGenerator(com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator) FileAndFileFilter(com.compomics.util.gui.file_handling.FileAndFileFilter) BareBonesBrowserLaunch(com.compomics.util.examples.BareBonesBrowserLaunch) JSparklinesBarChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesBarChartTableCellRenderer) FileChooserUtil(com.compomics.util.gui.file_handling.FileChooserUtil) JTableHeader(javax.swing.table.JTableHeader) ProteinInferencePeptideLevelDialog(eu.isas.peptideshaker.gui.protein_inference.ProteinInferencePeptideLevelDialog) PeptideShakerGUI(eu.isas.peptideshaker.gui.PeptideShakerGUI) MouseAdapter(java.awt.event.MouseAdapter) TitledBorder(javax.swing.border.TitledBorder) JSparklinesIntegerIconTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntegerIconTableCellRenderer) TableProperties(com.compomics.util.gui.TableProperties) SpectrumCountingMethod(com.compomics.util.experiment.quantification.spectrumcounting.SpectrumCountingMethod) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) TableModelEvent(javax.swing.event.TableModelEvent) ExportScheme(com.compomics.util.io.export.ExportScheme) DefaultTableModel(javax.swing.table.DefaultTableModel) TrueFalseIconRenderer(no.uib.jsparklines.extra.TrueFalseIconRenderer) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) PSExportFactory(eu.isas.peptideshaker.export.PSExportFactory) SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel) Util(com.compomics.util.Util) KeyEvent(java.awt.event.KeyEvent) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) GuiUtilities(com.compomics.util.gui.GuiUtilities) DisplayParameters(eu.isas.peptideshaker.preferences.DisplayParameters) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) Dimension(java.awt.Dimension) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) SimpleFileWriter(com.compomics.util.io.flat.SimpleFileWriter) Graphics(java.awt.Graphics) Toolkit(java.awt.Toolkit) IntStream(java.util.stream.IntStream) Rectangle(java.awt.Rectangle) FindPdbForUniprotAccessions(com.compomics.util.pdbfinder.FindPdbForUniprotAccessions) HelpDialog(com.compomics.util.gui.error_handlers.HelpDialog) PdbParameter(com.compomics.util.pdbfinder.pdb.PdbParameter) HashMap(java.util.HashMap) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) PlotOrientation(org.jfree.chart.plot.PlotOrientation) TableModelListener(javax.swing.event.TableModelListener) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) ArrayList(java.util.ArrayList) JSparklinesIntervalChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer) JSparklinesMultiIntervalChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesMultiIntervalChartTableCellRenderer) JSparklinesIntegerColorTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntegerColorTableCellRenderer) XYPlottingDialog(com.compomics.util.gui.XYPlottingDialog) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) ProteinTableModel(eu.isas.peptideshaker.gui.tablemodels.ProteinTableModel) JmolAdapter(org.jmol.api.JmolAdapter) XYDataPoint(no.uib.jsparklines.data.XYDataPoint) ProteinInferenceDialog(eu.isas.peptideshaker.gui.protein_inference.ProteinInferenceDialog) MatchValidationLevel(com.compomics.util.experiment.identification.validation.MatchValidationLevel) BufferedWriter(java.io.BufferedWriter) FileWriter(java.io.FileWriter) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) ExportFeature(com.compomics.util.io.export.ExportFeature) Identification(com.compomics.util.experiment.identification.Identification) IOException(java.io.IOException) JmolViewer(org.jmol.api.JmolViewer) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) ExportGraphicsDialog(com.compomics.util.gui.export.graphics.ExportGraphicsDialog) PdbBlock(com.compomics.util.pdbfinder.pdb.PdbBlock) MouseEvent(java.awt.event.MouseEvent) File(java.io.File) ExportFormat(com.compomics.util.io.export.ExportFormat) HtmlLinksRenderer(no.uib.jsparklines.extra.HtmlLinksRenderer) SmarterJmolAdapter(org.jmol.adapter.smarter.SmarterJmolAdapter) GeneDetailsDialog(com.compomics.util.gui.genes.GeneDetailsDialog) StartIndexes(no.uib.jsparklines.data.StartIndexes) ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) javax.swing(javax.swing) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) Identification(com.compomics.util.experiment.identification.Identification) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) XYDataPoint(no.uib.jsparklines.data.XYDataPoint)

Example 2 with NO_KEY

use of com.compomics.util.experiment.personalization.ExperimentObject.NO_KEY in project peptide-shaker by compomics.

the class OverviewPanel method updateSpectrum.

/**
 * Update the spectrum to the currently selected PSM.
 *
 * @param row the row index of the PSM
 * @param resetMzRange if true the mz range is reset, if false the current
 * zoom range is kept
 */
private void updateSpectrum(int row, boolean resetMzRange) {
    if (row != -1) {
        this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
        SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) psmTable.getModel();
        int psmIndex = tableModel.getViewIndex(row);
        long spectrumMatchKey = psmKeys[psmIndex];
        if (displaySpectrum) {
            SpectrumProvider spectrumProvider = peptideShakerGUI.getSpectrumProvider();
            SpectrumMatch spectrumMatch = peptideShakerGUI.getIdentification().getSpectrumMatch(spectrumMatchKey);
            String spectrumFile = spectrumMatch.getSpectrumFile();
            String spectrumTitle = spectrumMatch.getSpectrumTitle();
            Spectrum currentSpectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
            if (currentSpectrum != null && currentSpectrum.getNPeaks() > 0) {
                boolean newMax = false;
                if (resetMzRange) {
                    lastMzMaximum = 0;
                }
                if (peptideShakerGUI.getSelectedPeptideKey() != NO_KEY) {
                    double newMaximum = currentSpectrum.getMaxMz();
                    if (lastMzMaximum < newMaximum) {
                        lastMzMaximum = newMaximum;
                        newMax = true;
                    }
                }
                double lowerMzZoomRange = 0;
                double upperMzZoomRange = lastMzMaximum;
                if (spectrumPanel != null && spectrumPanel.getXAxisZoomRangeLowerValue() != 0 && !newMax) {
                    // @TODO: sometimes the range is reset when is should not be...
                    lowerMzZoomRange = spectrumPanel.getXAxisZoomRangeLowerValue();
                    upperMzZoomRange = spectrumPanel.getXAxisZoomRangeUpperValue();
                }
                // add the data to the spectrum panel
                Precursor precursor = currentSpectrum.getPrecursor();
                spectrumPanel = new SpectrumPanel(currentSpectrum.mz, currentSpectrum.intensity, precursor.mz, Charge.toString(spectrumMatch.getBestPeptideAssumption().getIdentificationCharge()), "", 40, false, false, false, 2, false);
                spectrumPanel.setKnownMassDeltas(peptideShakerGUI.getCurrentMassDeltas());
                spectrumPanel.setDeltaMassWindow(peptideShakerGUI.getIdentificationParameters().getAnnotationParameters().getFragmentIonAccuracy());
                spectrumPanel.setBorder(null);
                spectrumPanel.setDataPointAndLineColor(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedPeakColor(), 0);
                spectrumPanel.setPeakWaterMarkColor(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumBackgroundPeakColor());
                spectrumPanel.setPeakWidth(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedPeakWidth());
                spectrumPanel.setBackgroundPeakWidth(peptideShakerGUI.getUtilitiesUserParameters().getSpectrumBackgroundPeakWidth());
                // get the spectrum annotations
                PeptideAssumption peptideAssumption = spectrumMatch.getBestPeptideAssumption();
                Peptide currentPeptide = peptideAssumption.getPeptide();
                PeptideSpectrumAnnotator spectrumAnnotator = new PeptideSpectrumAnnotator();
                AnnotationParameters annotationParameters = peptideShakerGUI.getIdentificationParameters().getAnnotationParameters();
                SequenceProvider sequenceProvider = peptideShakerGUI.getSequenceProvider();
                IdentificationParameters identificationParameters = peptideShakerGUI.getIdentificationParameters();
                ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
                SequenceMatchingParameters modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
                SpecificAnnotationParameters specificAnnotationParameters = peptideShakerGUI.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, peptideAssumption);
                IonMatch[] annotations = spectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, spectrumFile, spectrumTitle, currentSpectrum, currentPeptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
                // @TODO: the selection of the peak to annotate should be done outside the spectrum panel
                spectrumPanel.setAnnotations(SpectrumAnnotator.getSpectrumAnnotation(annotations), annotationParameters.getTiesResolution() == SpectrumAnnotator.TiesResolution.mostIntense);
                spectrumPanel.rescale(lowerMzZoomRange, upperMzZoomRange);
                // show all or just the annotated peaks
                spectrumPanel.showAnnotatedPeaksOnly(!annotationParameters.showAllPeaks());
                spectrumPanel.setYAxisZoomExcludesBackgroundPeaks(annotationParameters.yAxisZoomExcludesBackgroundPeaks());
                Integer forwardIon = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getForwardIons().get(0);
                Integer rewindIon = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getRewindIons().get(0);
                // add de novo sequencing
                spectrumPanel.addAutomaticDeNovoSequencing(currentPeptide, annotations, forwardIon, rewindIon, annotationParameters.getDeNovoCharge(), annotationParameters.showForwardIonDeNovoTags(), annotationParameters.showRewindIonDeNovoTags(), false, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
                // add the spectrum panel to the frame
                spectrumJPanel.removeAll();
                spectrumJPanel.add(spectrumPanel);
                spectrumJPanel.revalidate();
                spectrumJPanel.repaint();
                // create and display the fragment ion table
                ArrayList<IonMatch[]> allAnnotations = getAnnotationsForAllSelectedSpectra();
                DisplayParameters displayParameters = peptideShakerGUI.getDisplayParameters();
                if (!displayParameters.useIntensityIonTable()) {
                    fragmentIonsJScrollPane.setViewportView(new FragmentIonTable(currentPeptide, allAnnotations, specificAnnotationParameters.getFragmentIonTypes(), specificAnnotationParameters.getNeutralLossesMap(), specificAnnotationParameters.getSelectedCharges().contains(1), specificAnnotationParameters.getSelectedCharges().contains(2), modificationParameters, sequenceProvider, modificationSequenceMatchingParameters));
                } else {
                    ArrayList<Spectrum> spectra = Arrays.stream(getSelectedPsmKeys()).mapToObj(key -> peptideShakerGUI.getIdentification().getSpectrumMatch(key)).map(selectedMatch -> spectrumProvider.getSpectrum(selectedMatch.getSpectrumFile(), selectedMatch.getSpectrumTitle())).collect(Collectors.toCollection(ArrayList::new));
                    fragmentIonsJScrollPane.setViewportView(new FragmentIonTable(currentPeptide, allAnnotations, spectra, specificAnnotationParameters.getFragmentIonTypes(), specificAnnotationParameters.getNeutralLossesMap(), specificAnnotationParameters.getSelectedCharges().contains(1), specificAnnotationParameters.getSelectedCharges().contains(2), modificationParameters, sequenceProvider, modificationSequenceMatchingParameters));
                }
                // create the sequence fragment ion view
                secondarySpectrumPlotsJPanel.removeAll();
                sequenceFragmentationPanel = new SequenceFragmentationPanel(peptideShakerGUI.getDisplayFeaturesGenerator().getTaggedPeptideSequence(spectrumMatch, false, false, true), annotations, true, peptideShakerGUI.getIdentificationParameters().getSearchParameters().getModificationParameters(), forwardIon, rewindIon);
                sequenceFragmentationPanel.setMinimumSize(new Dimension(sequenceFragmentationPanel.getPreferredSize().width, sequenceFragmentationPanel.getHeight()));
                sequenceFragmentationPanel.setOpaque(true);
                sequenceFragmentationPanel.setBackground(Color.WHITE);
                secondarySpectrumPlotsJPanel.add(sequenceFragmentationPanel);
                // create the intensity histograms
                intensityHistogram = new IntensityHistogram(annotations, currentSpectrum, annotationParameters.getAnnotationIntensityLimit());
                secondarySpectrumPlotsJPanel.add(intensityHistogram);
                // create the miniature mass error plot
                massErrorPlot = new MassErrorPlot(annotations, currentSpectrum, specificAnnotationParameters.getFragmentIonAccuracy(), peptideShakerGUI.getIdentificationParameters().getSearchParameters().getFragmentAccuracyType() == SearchParameters.MassAccuracyType.PPM);
                if (massErrorPlot.getNumberOfDataPointsInPlot() > 0) {
                    secondarySpectrumPlotsJPanel.add(massErrorPlot);
                }
                // update the UI
                secondarySpectrumPlotsJPanel.revalidate();
                secondarySpectrumPlotsJPanel.repaint();
                // update the bubble plot
                updateBubblePlot();
                // disable the spectrum tab if more than two psms are selected
                spectrumJTabbedPane.setEnabledAt(2, psmTable.getSelectedRowCount() <= 2);
                peptideShakerGUI.enableSpectrumExport(psmTable.getSelectedRowCount() <= 2);
                // move to the bubble plot tab if more than two psms are selected and the spectrum tab was selected
                if (psmTable.getSelectedRowCount() > 2 && spectrumJTabbedPane.getSelectedIndex() == 2) {
                    spectrumJTabbedPane.setSelectedIndex(1);
                }
                if (psmTable.getSelectedRowCount() > 2) {
                    spectrumJTabbedPane.setToolTipTextAt(2, "Available for single or double spectrum selection only");
                } else {
                    spectrumJTabbedPane.setToolTipTextAt(2, null);
                }
                // update the panel border title
                updateSpectrumPanelBorderTitle(currentSpectrum);
                spectrumMainPanel.revalidate();
                spectrumMainPanel.repaint();
            }
        }
        this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    } else {
        // nothing to display, empty previous results
        spectrumJPanel.removeAll();
        spectrumJPanel.revalidate();
        spectrumJPanel.repaint();
        secondarySpectrumPlotsJPanel.removeAll();
        secondarySpectrumPlotsJPanel.revalidate();
        secondarySpectrumPlotsJPanel.repaint();
        fragmentIonsJScrollPane.setViewportView(null);
        fragmentIonsJScrollPane.revalidate();
        fragmentIonsJScrollPane.repaint();
        bubbleJPanel.removeAll();
        bubbleJPanel.revalidate();
        bubbleJPanel.repaint();
        ((TitledBorder) spectrumMainPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Spectrum & Fragment Ions" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
        spectrumMainPanel.repaint();
    }
}
Also used : MatchType(eu.isas.peptideshaker.gui.MatchValidationDialog.MatchType) PsPeptideFeature(com.compomics.util.io.export.features.peptideshaker.PsPeptideFeature) PsProteinFeature(com.compomics.util.io.export.features.peptideshaker.PsProteinFeature) NO_KEY(com.compomics.util.experiment.personalization.ExperimentObject.NO_KEY) IdentificationFeaturesGenerator(com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator) JSparklinesDataSeries(no.uib.jsparklines.data.JSparklinesDataSeries) FileAndFileFilter(com.compomics.util.gui.file_handling.FileAndFileFilter) BareBonesBrowserLaunch(com.compomics.util.examples.BareBonesBrowserLaunch) FileChooserUtil(com.compomics.util.gui.file_handling.FileChooserUtil) JTableHeader(javax.swing.table.JTableHeader) ProteinInferencePeptideLevelDialog(eu.isas.peptideshaker.gui.protein_inference.ProteinInferencePeptideLevelDialog) PeptideShakerGUI(eu.isas.peptideshaker.gui.PeptideShakerGUI) SpecificAnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.SpecificAnnotationParameters) SpectrumAnnotator(com.compomics.util.experiment.identification.spectrum_annotation.SpectrumAnnotator) MouseAdapter(java.awt.event.MouseAdapter) TitledBorder(javax.swing.border.TitledBorder) JSparklinesDataset(no.uib.jsparklines.data.JSparklinesDataset) SpectrumProvider(com.compomics.util.experiment.mass_spectrometry.SpectrumProvider) PeptideTableModel(eu.isas.peptideshaker.gui.tablemodels.PeptideTableModel) Variant(com.compomics.util.experiment.biology.variants.Variant) TableProperties(com.compomics.util.gui.TableProperties) SpectrumCountingMethod(com.compomics.util.experiment.quantification.spectrumcounting.SpectrumCountingMethod) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) ProteinSequencePanelParent(eu.isas.peptideshaker.gui.protein_sequence.ProteinSequencePanelParent) PSModificationScores(com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores) Clipboard(java.awt.datatransfer.Clipboard) TableModelEvent(javax.swing.event.TableModelEvent) ExportScheme(com.compomics.util.io.export.ExportScheme) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption) DefaultTableModel(javax.swing.table.DefaultTableModel) TrueFalseIconRenderer(no.uib.jsparklines.extra.TrueFalseIconRenderer) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) PSExportFactory(eu.isas.peptideshaker.export.PSExportFactory) SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel) Util(com.compomics.util.Util) KeyEvent(java.awt.event.KeyEvent) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) com.compomics.util.experiment.identification.matches(com.compomics.util.experiment.identification.matches) GuiUtilities(com.compomics.util.gui.GuiUtilities) DisplayParameters(eu.isas.peptideshaker.preferences.DisplayParameters) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) ProteinSequencePanel(eu.isas.peptideshaker.gui.protein_sequence.ProteinSequencePanel) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) CategoryPlot(org.jfree.chart.plot.CategoryPlot) ArrayUtil(com.compomics.util.ArrayUtil) Precursor(com.compomics.util.experiment.mass_spectrometry.spectra.Precursor) MatchValidationDialog(eu.isas.peptideshaker.gui.MatchValidationDialog) IntStream(java.util.stream.IntStream) java.util(java.util) SpectrumIdentificationAssumption(com.compomics.util.experiment.identification.SpectrumIdentificationAssumption) HelpDialog(com.compomics.util.gui.error_handlers.HelpDialog) ChromosomeTableCellRenderer(no.uib.jsparklines.extra.ChromosomeTableCellRenderer) PeptideUtils(com.compomics.util.experiment.identification.utils.PeptideUtils) NonSymmetricalNormalDistribution(com.compomics.util.math.statistics.distributions.NonSymmetricalNormalDistribution) PlotOrientation(org.jfree.chart.plot.PlotOrientation) TableModelListener(javax.swing.event.TableModelListener) XYPlottingDialog(com.compomics.util.gui.XYPlottingDialog) ModificationUtils(com.compomics.util.experiment.identification.utils.ModificationUtils) ProteinTableModel(eu.isas.peptideshaker.gui.tablemodels.ProteinTableModel) StringSelection(java.awt.datatransfer.StringSelection) PsmTableModel(eu.isas.peptideshaker.gui.tablemodels.PsmTableModel) Spectrum(com.compomics.util.experiment.mass_spectrometry.spectra.Spectrum) ProteinInferenceDialog(eu.isas.peptideshaker.gui.protein_inference.ProteinInferenceDialog) MatchValidationLevel(com.compomics.util.experiment.identification.validation.MatchValidationLevel) BufferedWriter(java.io.BufferedWriter) FileWriter(java.io.FileWriter) DecimalFormat(java.text.DecimalFormat) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) ExportFeature(com.compomics.util.io.export.ExportFeature) Identification(com.compomics.util.experiment.identification.Identification) ResidueAnnotation(eu.isas.peptideshaker.gui.protein_sequence.ResidueAnnotation) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) ExportGraphicsDialog(com.compomics.util.gui.export.graphics.ExportGraphicsDialog) PSMaps(eu.isas.peptideshaker.scoring.PSMaps) AnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters) MouseEvent(java.awt.event.MouseEvent) File(java.io.File) ChartChangeEvent(org.jfree.chart.event.ChartChangeEvent) PeptideSpectrumAnnotator(com.compomics.util.experiment.identification.spectrum_annotation.spectrum_annotators.PeptideSpectrumAnnotator) ExportFormat(com.compomics.util.io.export.ExportFormat) java.awt(java.awt) Charge(com.compomics.util.experiment.biology.ions.Charge) HtmlLinksRenderer(no.uib.jsparklines.extra.HtmlLinksRenderer) com.compomics.util.gui.spectrum(com.compomics.util.gui.spectrum) GeneDetailsDialog(com.compomics.util.gui.genes.GeneDetailsDialog) no.uib.jsparklines.renderers(no.uib.jsparklines.renderers) Range(org.jfree.data.Range) org.jfree.chart(org.jfree.chart) ChartChangeListener(org.jfree.chart.event.ChartChangeListener) ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) javax.swing(javax.swing) SpecificAnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.SpecificAnnotationParameters) AnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters) DisplayParameters(eu.isas.peptideshaker.preferences.DisplayParameters) SpecificAnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.SpecificAnnotationParameters) TitledBorder(javax.swing.border.TitledBorder) Precursor(com.compomics.util.experiment.mass_spectrometry.spectra.Precursor) Spectrum(com.compomics.util.experiment.mass_spectrometry.spectra.Spectrum) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) SpectrumProvider(com.compomics.util.experiment.mass_spectrometry.SpectrumProvider) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption) java.awt(java.awt) PeptideSpectrumAnnotator(com.compomics.util.experiment.identification.spectrum_annotation.spectrum_annotators.PeptideSpectrumAnnotator)

Example 3 with NO_KEY

use of com.compomics.util.experiment.personalization.ExperimentObject.NO_KEY in project peptide-shaker by compomics.

the class JumpToPanel method inputTxtKeyReleased.

// </editor-fold>//GEN-END:initComponents
/**
 * Update the jump to filter.
 *
 * @param evt the key event
 */
private void inputTxtKeyReleased(java.awt.event.KeyEvent evt) {
    // GEN-FIRST:event_inputTxtKeyReleased
    indexLabel.setText("Typing...");
    final KeyEvent event = evt;
    newInput = true;
    new Thread("FindThread") {

        @Override
        public synchronized void run() {
            try {
                searchMutex.acquire();
                newInput = false;
                try {
                    wait(500);
                } catch (InterruptedException e) {
                // Ignore
                }
                Identification identification = peptideShakerGUI.getIdentification();
                if (identification != null && !newInput) {
                    indexLabel.setText("Searching...");
                    if (!inputTxt.getText().equalsIgnoreCase(welcomeText.get(selectedJumpType))) {
                        inputTxt.setForeground(Color.black);
                    } else {
                        inputTxt.setForeground(new Color(204, 204, 204));
                    }
                    if (event.getKeyCode() == KeyEvent.VK_UP && previousButton.isEnabled()) {
                        previousButtonActionPerformed(null);
                    } else if (event.getKeyCode() == KeyEvent.VK_DOWN && nextButton.isEnabled()) {
                        nextButtonActionPerformed(null);
                    } else {
                        possibilities.get(selectedJumpType).clear();
                        currentSelection.put(selectedJumpType, 0);
                        EnumMap<JumpType, Boolean> reinitializedMap = new EnumMap<>(JumpType.class);
                        for (JumpType jumpType : JumpType.values()) {
                            reinitializedMap.put(jumpType, jumpType == selectedJumpType);
                        }
                        String doubleString, inputLowerCase = inputTxt.getText().trim().toLowerCase(), inputUpperCase = inputLowerCase.toUpperCase();
                        if (!inputLowerCase.equals("")) {
                            peptideShakerGUI.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
                            inputTxt.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
                            boolean proteinFound = false;
                            boolean peptidefound = false;
                            if (selectedJumpType == JumpType.protein || selectedJumpType == JumpType.peptide) {
                                // See if the input is contained by a protein accession or description
                                TreeSet<Long> proteinKeysFound = new TreeSet<>();
                                TreeSet<Long> peptideKeysFound = new TreeSet<>();
                                for (long proteinKey : peptideShakerGUI.getIdentificationFeaturesGenerator().getProcessedProteinKeys(null, peptideShakerGUI.getFilterParameters())) {
                                    if (newInput) {
                                        peptideShakerGUI.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
                                        inputTxt.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
                                        inputTxt.requestFocus();
                                        return;
                                    }
                                    ProteinMatch proteinMatch = identification.getProteinMatch(proteinKey);
                                    if (!proteinMatch.isDecoy()) {
                                        if (Arrays.stream(proteinMatch.getAccessions()).map(accession -> accession.toLowerCase()).anyMatch(accession -> accession.contains(inputLowerCase)) || Arrays.stream(proteinMatch.getAccessions()).map(accession -> peptideShakerGUI.getProteinDetailsProvider().getDescription(accession)).map(description -> description.toLowerCase()).anyMatch(description -> description.contains(inputLowerCase))) {
                                            proteinFound = true;
                                            proteinKeysFound.add(proteinKey);
                                            for (long peptideKey : proteinMatch.getPeptideMatchesKeys()) {
                                                peptideKeysFound.add(peptideKey);
                                            }
                                        }
                                    }
                                }
                                if (proteinFound) {
                                    lastInput.put(JumpType.protein, inputLowerCase);
                                    if (!reinitializedMap.get(JumpType.protein)) {
                                        possibilities.get(JumpType.protein).clear();
                                        currentSelection.put(JumpType.protein, 0);
                                    }
                                    for (long proteinKey : proteinKeysFound) {
                                        Object[] keys = new Object[3];
                                        Arrays.fill(keys, NO_KEY);
                                        keys[0] = proteinKey;
                                        possibilities.get(JumpType.protein).add(keys);
                                    }
                                    lastInput.put(JumpType.peptide, inputLowerCase);
                                    if (!reinitializedMap.get(JumpType.peptide)) {
                                        possibilities.get(JumpType.peptide).clear();
                                        currentSelection.put(JumpType.peptide, 0);
                                    }
                                    for (long peptideKey : peptideKeysFound) {
                                        Object[] keys = new Object[3];
                                        Arrays.fill(keys, NO_KEY);
                                        keys[1] = peptideKey;
                                        possibilities.get(JumpType.peptide).add(keys);
                                    }
                                } else {
                                    // See if the input is contained by a peptide sequence or is a modification
                                    boolean validPeptideSequence = inputUpperCase.chars().allMatch(aa -> AminoAcid.isAa(aa));
                                    boolean possibleMod = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getModificationParameters().getAllModifications().stream().anyMatch(modName -> modName.toLowerCase().contains(inputLowerCase));
                                    if (validPeptideSequence || possibleMod) {
                                        String matchingInput = AminoAcid.getMatchingSequence(inputUpperCase, peptideShakerGUI.getIdentificationParameters().getSequenceMatchingParameters());
                                        TreeMap<Long, TreeSet<Long>> sequencesMatchesMap = new TreeMap<>();
                                        TreeMap<Long, TreeSet<Long>> modificationsMatchesMap = new TreeMap<>();
                                        for (long peptideKey : identification.getPeptideIdentification()) {
                                            if (newInput) {
                                                peptideShakerGUI.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
                                                inputTxt.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
                                                inputTxt.requestFocus();
                                                return;
                                            }
                                            PeptideMatch peptideMatch = identification.getPeptideMatch(peptideKey);
                                            PSParameter psParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
                                            if (!psParameter.getHidden()) {
                                                Peptide peptide = peptideMatch.getPeptide();
                                                String matchingSequence = AminoAcid.getMatchingSequence(peptide.getSequence(), peptideShakerGUI.getIdentificationParameters().getSequenceMatchingParameters());
                                                boolean sequenceMatch = validPeptideSequence && matchingSequence.contains(matchingInput);
                                                boolean modMatch = possibleMod && Arrays.stream(peptideMatch.getPeptide().getVariableModifications()).map(ModificationMatch::getModification).anyMatch(modName -> modName.contains(matchingInput));
                                                if (sequenceMatch || modMatch) {
                                                    peptidefound = true;
                                                    TreeSet<Long> proteinKeys = identification.getProteinMatches(peptideKey);
                                                    for (long proteinKey : proteinKeys) {
                                                        ProteinMatch proteinMatch = identification.getProteinMatch(proteinKey);
                                                        if (!proteinMatch.isDecoy()) {
                                                            if (sequenceMatch) {
                                                                TreeSet<Long> peptideKeys = sequencesMatchesMap.get(proteinKey);
                                                                if (peptideKeys == null) {
                                                                    peptideKeys = new TreeSet<>();
                                                                    sequencesMatchesMap.put(proteinKey, peptideKeys);
                                                                }
                                                                peptideKeys.add(peptideKey);
                                                            }
                                                            if (modMatch) {
                                                                TreeSet<Long> peptideKeys = modificationsMatchesMap.get(proteinKey);
                                                                if (peptideKeys == null) {
                                                                    peptideKeys = new TreeSet<>();
                                                                    modificationsMatchesMap.put(proteinKey, peptideKeys);
                                                                }
                                                                peptideKeys.add(peptideKey);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        TreeMap<Long, TreeSet<Long>> itemsMap = !modificationsMatchesMap.isEmpty() ? modificationsMatchesMap : sequencesMatchesMap;
                                        lastInput.put(JumpType.protein, inputLowerCase);
                                        if (!reinitializedMap.get(JumpType.protein)) {
                                            possibilities.get(JumpType.protein).clear();
                                            currentSelection.put(JumpType.protein, 0);
                                        }
                                        for (Entry<Long, TreeSet<Long>> entry : itemsMap.entrySet()) {
                                            long proteinKey = entry.getKey();
                                            for (long peptideKey : entry.getValue()) {
                                                Object[] keys = new Object[3];
                                                Arrays.fill(keys, NO_KEY);
                                                keys[0] = proteinKey;
                                                keys[1] = peptideKey;
                                                possibilities.get(JumpType.protein).add(keys);
                                            }
                                        }
                                        lastInput.put(JumpType.peptide, inputLowerCase);
                                        if (!reinitializedMap.get(JumpType.peptide)) {
                                            possibilities.get(JumpType.peptide).clear();
                                            currentSelection.put(JumpType.peptide, 0);
                                        }
                                        itemsMap.values().stream().flatMapToLong(set -> set.stream().mapToLong(a -> a)).distinct().sorted().forEach(peptideKey -> {
                                            Object[] keys = new Object[3];
                                            Arrays.fill(keys, NO_KEY);
                                            keys[1] = peptideKey;
                                            possibilities.get(JumpType.peptide).add(keys);
                                        });
                                    }
                                }
                            }
                            if (selectedJumpType == JumpType.psm || !proteinFound && !peptidefound) {
                                // See if the input is contained by a spectrum title or corresponds to a precursor mass or RT
                                TreeSet<String> spectrumTitles = new TreeSet<>();
                                SpectrumProvider spectrumProvider = peptideShakerGUI.getSpectrumProvider();
                                String[] spectrumFiles = spectrumfile == null ? spectrumProvider.getOrderedFileNamesWithoutExtensions() : new String[] { spectrumfile };
                                for (String fileNameWithoutExtension : spectrumFiles) {
                                    for (String spectrumTitle : spectrumProvider.getSpectrumTitles(fileNameWithoutExtension)) {
                                        if (newInput) {
                                            peptideShakerGUI.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
                                            inputTxt.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
                                            inputTxt.requestFocus();
                                            return;
                                        }
                                        if (spectrumTitle.toLowerCase().contains(inputLowerCase) || fileNameWithoutExtension.toLowerCase().contains(inputLowerCase)) {
                                            spectrumTitles.add(fileNameWithoutExtension + SPECTRUM_FILENAME_SPLITTER + spectrumTitle);
                                        } else {
                                            double precusorMz = spectrumProvider.getPrecursorMz(fileNameWithoutExtension, spectrumTitle);
                                            doubleString = Double.toString(precusorMz);
                                            if (doubleString.startsWith(inputLowerCase)) {
                                                spectrumTitles.add(fileNameWithoutExtension + SPECTRUM_FILENAME_SPLITTER + spectrumTitle);
                                            } else {
                                                double precusorRt = spectrumProvider.getPrecursorRt(fileNameWithoutExtension, spectrumTitle);
                                                doubleString = Double.toString(precusorRt);
                                                if (doubleString.startsWith(inputLowerCase)) {
                                                    spectrumTitles.add(fileNameWithoutExtension + SPECTRUM_FILENAME_SPLITTER + spectrumTitle);
                                                }
                                            }
                                        }
                                    }
                                    if (!spectrumTitles.isEmpty()) {
                                        for (JumpType jumpType : JumpType.values()) {
                                            ArrayList<Object[]> currentPossibilities = possibilities.get(jumpType);
                                            Object[] sample = currentPossibilities.isEmpty() ? new Object[] { NO_KEY, NO_KEY, NO_KEY } : currentPossibilities.get(0);
                                            if (jumpType == JumpType.psm || ((Long) sample[0] == NO_KEY && (Long) sample[1] == NO_KEY)) {
                                                if (!reinitializedMap.get(jumpType)) {
                                                    possibilities.get(jumpType).clear();
                                                    currentSelection.put(jumpType, 0);
                                                }
                                                for (String spectrumTitle : spectrumTitles) {
                                                    Object[] keys = new Object[3];
                                                    Arrays.fill(keys, NO_KEY);
                                                    keys[2] = spectrumTitle;
                                                    possibilities.get(jumpType).add(keys);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if (possibilities.get(selectedJumpType).size() > 0) {
                                if (possibilities.get(selectedJumpType).size() > 1) {
                                    previousButton.setEnabled(true);
                                    nextButton.setEnabled(true);
                                } else {
                                    // possibilities.size() == 1
                                    previousButton.setEnabled(false);
                                    nextButton.setEnabled(false);
                                }
                                updateSelectionInTab();
                            } else {
                                previousButton.setEnabled(false);
                                nextButton.setEnabled(false);
                                if (!inputLowerCase.equalsIgnoreCase(welcomeText.get(selectedJumpType))) {
                                    indexLabel.setText("(no matches)");
                                } else {
                                    indexLabel.setText("");
                                }
                            }
                            peptideShakerGUI.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
                            inputTxt.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
                            inputTxt.requestFocus();
                        } else {
                            indexLabel.setText("");
                            previousButton.setEnabled(false);
                            nextButton.setEnabled(false);
                            inputTxt.setText(welcomeText.get(selectedJumpType));
                            inputTxt.selectAll();
                            inputTxt.requestFocus();
                        }
                    }
                    lastLabel.put(selectedJumpType, indexLabel.getText());
                }
            } catch (Exception e) {
                peptideShakerGUI.catchException(e);
            } finally {
                searchMutex.release();
            }
        }
    }.start();
}
Also used : ModificationMatch(com.compomics.util.experiment.identification.matches.ModificationMatch) Color(java.awt.Color) Arrays(java.util.Arrays) NO_KEY(com.compomics.util.experiment.personalization.ExperimentObject.NO_KEY) EnumMap(java.util.EnumMap) Identification(com.compomics.util.experiment.identification.Identification) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) KeyEvent(java.awt.event.KeyEvent) ProteinDetailsProvider(com.compomics.util.experiment.io.biology.protein.ProteinDetailsProvider) SimpleSemaphore(com.compomics.util.threading.SimpleSemaphore) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) TreeMap(java.util.TreeMap) Entry(java.util.Map.Entry) SpectrumProvider(com.compomics.util.experiment.mass_spectrometry.SpectrumProvider) AminoAcid(com.compomics.util.experiment.biology.aminoacids.AminoAcid) ModificationMatch(com.compomics.util.experiment.identification.matches.ModificationMatch) Identification(com.compomics.util.experiment.identification.Identification) KeyEvent(java.awt.event.KeyEvent) TreeSet(java.util.TreeSet) EnumMap(java.util.EnumMap) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) Color(java.awt.Color) TreeMap(java.util.TreeMap) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) SpectrumProvider(com.compomics.util.experiment.mass_spectrometry.SpectrumProvider)

Example 4 with NO_KEY

use of com.compomics.util.experiment.personalization.ExperimentObject.NO_KEY in project peptide-shaker by compomics.

the class OverviewPanel method updateSelection.

/**
 * Update the selected protein and peptide.
 *
 * @param scrollToVisible if true the table also scrolls to make the
 * selected row visible
 */
public void updateSelection(boolean scrollToVisible) {
    int proteinRow = 0;
    Identification identification = peptideShakerGUI.getIdentification();
    long proteinKey = peptideShakerGUI.getSelectedProteinKey();
    long peptideKey = peptideShakerGUI.getSelectedPeptideKey();
    String spectrumFile = peptideShakerGUI.getSelectedSpectrumFile();
    String spectrumTitle = peptideShakerGUI.getSelectedSpectrumTitle();
    if (proteinKey == NO_KEY && peptideKey == NO_KEY && spectrumFile != null && spectrumTitle != null) {
        long psmKey = SpectrumMatch.getKey(spectrumFile, spectrumTitle);
        SpectrumMatch spectrumMatch = identification.getSpectrumMatch(psmKey);
        if (spectrumMatch != null && spectrumMatch.getBestPeptideAssumption() != null) {
            Peptide peptide = spectrumMatch.getBestPeptideAssumption().getPeptide();
            peptideKey = peptide.getMatchingKey(peptideShakerGUI.getIdentificationParameters().getSequenceMatchingParameters());
        }
    }
    if (proteinKey == NO_KEY && peptideKey != NO_KEY) {
        final long peptideKeyFinal = peptideKey;
        ProteinMatch tempProteinMatch = identification.getProteinIdentification().parallelStream().map(key -> identification.getProteinMatch(key)).filter(proteinMatch -> Arrays.stream(proteinMatch.getPeptideMatchesKeys()).anyMatch(key -> key == peptideKeyFinal)).findAny().orElse(null);
        if (tempProteinMatch != null) {
            proteinKey = tempProteinMatch.getKey();
            peptideShakerGUI.setSelectedItems(proteinKey, peptideKey, spectrumFile, spectrumTitle);
        }
    }
    if (proteinKey != NO_KEY) {
        proteinRow = getProteinRow(proteinKey);
    }
    if (proteinKeys.length == 0) {
        clearData();
        return;
    }
    if (proteinRow == -1) {
        peptideShakerGUI.resetSelectedItems();
        proteinTableMouseReleased(null);
    } else if (proteinTable.getSelectedRow() != proteinRow) {
        proteinTable.setRowSelectionInterval(proteinRow, proteinRow);
        if (scrollToVisible) {
            proteinTable.scrollRectToVisible(proteinTable.getCellRect(proteinRow, 0, false));
        }
        proteinTableMouseReleased(null);
    }
    int peptideRow = 0;
    if (peptideKey != NO_KEY) {
        peptideRow = getPeptideRow(peptideKey);
    }
    if (peptideTable.getSelectedRow() != peptideRow && peptideRow != -1) {
        peptideTable.setRowSelectionInterval(peptideRow, peptideRow);
        if (scrollToVisible) {
            peptideTable.scrollRectToVisible(peptideTable.getCellRect(peptideRow, 0, false));
        }
        peptideTableMouseReleased(null);
    }
    int psmRow = 0;
    if (spectrumFile != null && spectrumTitle != null) {
        long psmKey = SpectrumMatch.getKey(spectrumFile, spectrumTitle);
        psmRow = getPsmRow(psmKey);
    }
    if (psmTable.getSelectedRow() != psmRow && psmRow != -1 && psmRow < psmTable.getRowCount()) {
        psmTable.setRowSelectionInterval(psmRow, psmRow);
        if (scrollToVisible) {
            psmTable.scrollRectToVisible(psmTable.getCellRect(psmRow, 0, false));
        }
        psmTableMouseReleased(null);
    }
}
Also used : MatchType(eu.isas.peptideshaker.gui.MatchValidationDialog.MatchType) PsPeptideFeature(com.compomics.util.io.export.features.peptideshaker.PsPeptideFeature) PsProteinFeature(com.compomics.util.io.export.features.peptideshaker.PsProteinFeature) NO_KEY(com.compomics.util.experiment.personalization.ExperimentObject.NO_KEY) IdentificationFeaturesGenerator(com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator) JSparklinesDataSeries(no.uib.jsparklines.data.JSparklinesDataSeries) FileAndFileFilter(com.compomics.util.gui.file_handling.FileAndFileFilter) BareBonesBrowserLaunch(com.compomics.util.examples.BareBonesBrowserLaunch) FileChooserUtil(com.compomics.util.gui.file_handling.FileChooserUtil) JTableHeader(javax.swing.table.JTableHeader) ProteinInferencePeptideLevelDialog(eu.isas.peptideshaker.gui.protein_inference.ProteinInferencePeptideLevelDialog) PeptideShakerGUI(eu.isas.peptideshaker.gui.PeptideShakerGUI) SpecificAnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.SpecificAnnotationParameters) SpectrumAnnotator(com.compomics.util.experiment.identification.spectrum_annotation.SpectrumAnnotator) MouseAdapter(java.awt.event.MouseAdapter) TitledBorder(javax.swing.border.TitledBorder) JSparklinesDataset(no.uib.jsparklines.data.JSparklinesDataset) SpectrumProvider(com.compomics.util.experiment.mass_spectrometry.SpectrumProvider) PeptideTableModel(eu.isas.peptideshaker.gui.tablemodels.PeptideTableModel) Variant(com.compomics.util.experiment.biology.variants.Variant) TableProperties(com.compomics.util.gui.TableProperties) SpectrumCountingMethod(com.compomics.util.experiment.quantification.spectrumcounting.SpectrumCountingMethod) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) ProteinSequencePanelParent(eu.isas.peptideshaker.gui.protein_sequence.ProteinSequencePanelParent) PSModificationScores(com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores) Clipboard(java.awt.datatransfer.Clipboard) TableModelEvent(javax.swing.event.TableModelEvent) ExportScheme(com.compomics.util.io.export.ExportScheme) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption) DefaultTableModel(javax.swing.table.DefaultTableModel) TrueFalseIconRenderer(no.uib.jsparklines.extra.TrueFalseIconRenderer) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) PSExportFactory(eu.isas.peptideshaker.export.PSExportFactory) SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel) Util(com.compomics.util.Util) KeyEvent(java.awt.event.KeyEvent) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) com.compomics.util.experiment.identification.matches(com.compomics.util.experiment.identification.matches) GuiUtilities(com.compomics.util.gui.GuiUtilities) DisplayParameters(eu.isas.peptideshaker.preferences.DisplayParameters) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) ProteinSequencePanel(eu.isas.peptideshaker.gui.protein_sequence.ProteinSequencePanel) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) CategoryPlot(org.jfree.chart.plot.CategoryPlot) ArrayUtil(com.compomics.util.ArrayUtil) Precursor(com.compomics.util.experiment.mass_spectrometry.spectra.Precursor) MatchValidationDialog(eu.isas.peptideshaker.gui.MatchValidationDialog) IntStream(java.util.stream.IntStream) java.util(java.util) SpectrumIdentificationAssumption(com.compomics.util.experiment.identification.SpectrumIdentificationAssumption) HelpDialog(com.compomics.util.gui.error_handlers.HelpDialog) ChromosomeTableCellRenderer(no.uib.jsparklines.extra.ChromosomeTableCellRenderer) PeptideUtils(com.compomics.util.experiment.identification.utils.PeptideUtils) NonSymmetricalNormalDistribution(com.compomics.util.math.statistics.distributions.NonSymmetricalNormalDistribution) PlotOrientation(org.jfree.chart.plot.PlotOrientation) TableModelListener(javax.swing.event.TableModelListener) XYPlottingDialog(com.compomics.util.gui.XYPlottingDialog) ModificationUtils(com.compomics.util.experiment.identification.utils.ModificationUtils) ProteinTableModel(eu.isas.peptideshaker.gui.tablemodels.ProteinTableModel) StringSelection(java.awt.datatransfer.StringSelection) PsmTableModel(eu.isas.peptideshaker.gui.tablemodels.PsmTableModel) Spectrum(com.compomics.util.experiment.mass_spectrometry.spectra.Spectrum) ProteinInferenceDialog(eu.isas.peptideshaker.gui.protein_inference.ProteinInferenceDialog) MatchValidationLevel(com.compomics.util.experiment.identification.validation.MatchValidationLevel) BufferedWriter(java.io.BufferedWriter) FileWriter(java.io.FileWriter) DecimalFormat(java.text.DecimalFormat) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) ExportFeature(com.compomics.util.io.export.ExportFeature) Identification(com.compomics.util.experiment.identification.Identification) ResidueAnnotation(eu.isas.peptideshaker.gui.protein_sequence.ResidueAnnotation) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) ExportGraphicsDialog(com.compomics.util.gui.export.graphics.ExportGraphicsDialog) PSMaps(eu.isas.peptideshaker.scoring.PSMaps) AnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters) MouseEvent(java.awt.event.MouseEvent) File(java.io.File) ChartChangeEvent(org.jfree.chart.event.ChartChangeEvent) PeptideSpectrumAnnotator(com.compomics.util.experiment.identification.spectrum_annotation.spectrum_annotators.PeptideSpectrumAnnotator) ExportFormat(com.compomics.util.io.export.ExportFormat) java.awt(java.awt) Charge(com.compomics.util.experiment.biology.ions.Charge) HtmlLinksRenderer(no.uib.jsparklines.extra.HtmlLinksRenderer) com.compomics.util.gui.spectrum(com.compomics.util.gui.spectrum) GeneDetailsDialog(com.compomics.util.gui.genes.GeneDetailsDialog) no.uib.jsparklines.renderers(no.uib.jsparklines.renderers) Range(org.jfree.data.Range) org.jfree.chart(org.jfree.chart) ChartChangeListener(org.jfree.chart.event.ChartChangeListener) ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) javax.swing(javax.swing) Identification(com.compomics.util.experiment.identification.Identification) Peptide(com.compomics.util.experiment.biology.proteins.Peptide)

Example 5 with NO_KEY

use of com.compomics.util.experiment.personalization.ExperimentObject.NO_KEY in project peptide-shaker by compomics.

the class ProteinFractionsPanel method updateSelection.

/**
 * Update the selected protein and peptide.
 */
public void updateSelection() {
    int proteinRow = 0;
    long proteinKey = peptideShakerGUI.getSelectedProteinKey();
    long peptideKey = peptideShakerGUI.getSelectedPeptideKey();
    String spectrumFile = peptideShakerGUI.getSelectedSpectrumFile();
    String spectrumTitle = peptideShakerGUI.getSelectedSpectrumTitle();
    Identification identification = peptideShakerGUI.getIdentification();
    if (proteinKey == NO_KEY && peptideKey == NO_KEY && spectrumFile != null && spectrumTitle != null) {
        long psmKey = SpectrumMatch.getKey(spectrumFile, spectrumTitle);
        SpectrumMatch spectrumMatch = (SpectrumMatch) peptideShakerGUI.getIdentification().retrieveObject(psmKey);
        if (spectrumMatch != null && spectrumMatch.getBestPeptideAssumption() != null) {
            Peptide peptide = spectrumMatch.getBestPeptideAssumption().getPeptide();
            peptideKey = peptide.getMatchingKey(peptideShakerGUI.getIdentificationParameters().getSequenceMatchingParameters());
        }
    }
    if (proteinKey == NO_KEY && peptideKey != NO_KEY) {
        final long peptideKeyFinal = peptideKey;
        ProteinMatch tempProteinMatch = identification.getProteinIdentification().parallelStream().map(key -> identification.getProteinMatch(key)).filter(proteinMatch -> Arrays.stream(proteinMatch.getPeptideMatchesKeys()).anyMatch(key -> key == peptideKeyFinal)).findAny().orElse(null);
        if (tempProteinMatch != null) {
            peptideShakerGUI.setSelectedItems(tempProteinMatch.getKey(), peptideKey, spectrumFile, spectrumTitle);
        }
    }
    if (proteinKey != NO_KEY) {
        proteinRow = getProteinRow(proteinKey);
    }
    if (proteinKeys.length == 0) {
        clearData();
        return;
    }
    if (proteinRow == -1) {
        peptideShakerGUI.resetSelectedItems();
    } else if (proteinTable.getSelectedRow() != proteinRow) {
        proteinTable.setRowSelectionInterval(proteinRow, proteinRow);
        proteinTable.scrollRectToVisible(proteinTable.getCellRect(proteinRow, 0, false));
        proteinTableKeyReleased(null);
    }
}
Also used : PsProteinFeature(com.compomics.util.io.export.features.peptideshaker.PsProteinFeature) Arrays(java.util.Arrays) JSparklinesArrayListBarChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesArrayListBarChartTableCellRenderer) NO_KEY(com.compomics.util.experiment.personalization.ExperimentObject.NO_KEY) JSparklinesDataSeries(no.uib.jsparklines.data.JSparklinesDataSeries) FileAndFileFilter(com.compomics.util.gui.file_handling.FileAndFileFilter) ChartPanelTableCellRenderer(no.uib.jsparklines.extra.ChartPanelTableCellRenderer) BareBonesBrowserLaunch(com.compomics.util.examples.BareBonesBrowserLaunch) JSparklinesBarChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesBarChartTableCellRenderer) FileChooserUtil(com.compomics.util.gui.file_handling.FileChooserUtil) JTableHeader(javax.swing.table.JTableHeader) PeptideShakerGUI(eu.isas.peptideshaker.gui.PeptideShakerGUI) TitledBorder(javax.swing.border.TitledBorder) JSparklinesDataset(no.uib.jsparklines.data.JSparklinesDataset) ProteinSequencePanelParent(eu.isas.peptideshaker.gui.protein_sequence.ProteinSequencePanelParent) TableModelEvent(javax.swing.event.TableModelEvent) ExportScheme(com.compomics.util.io.export.ExportScheme) DefaultTableModel(javax.swing.table.DefaultTableModel) PSExportFactory(eu.isas.peptideshaker.export.PSExportFactory) SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel) GuiUtilities(com.compomics.util.gui.GuiUtilities) ChartFactory(org.jfree.chart.ChartFactory) ProteinSequencePanel(eu.isas.peptideshaker.gui.protein_sequence.ProteinSequencePanel) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) ChartPanel(org.jfree.chart.ChartPanel) BoxAndWhiskerToolTipGenerator(org.jfree.chart.labels.BoxAndWhiskerToolTipGenerator) IntStream(java.util.stream.IntStream) ChartMouseEvent(org.jfree.chart.ChartMouseEvent) HelpDialog(com.compomics.util.gui.error_handlers.HelpDialog) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) PeptideUtils(com.compomics.util.experiment.identification.utils.PeptideUtils) HashMap(java.util.HashMap) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) PlotOrientation(org.jfree.chart.plot.PlotOrientation) TableModelListener(javax.swing.event.TableModelListener) org.jfree.chart.renderer.category(org.jfree.chart.renderer.category) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) ArrayList(java.util.ArrayList) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) FractionDetailsDialog(eu.isas.peptideshaker.gui.FractionDetailsDialog) ProteinTableModel(eu.isas.peptideshaker.gui.tablemodels.ProteinTableModel) JFreeChart(org.jfree.chart.JFreeChart) ExportFeature(com.compomics.util.io.export.ExportFeature) Identification(com.compomics.util.experiment.identification.Identification) ResidueAnnotation(eu.isas.peptideshaker.gui.protein_sequence.ResidueAnnotation) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) DigestionParameters(com.compomics.util.parameters.identification.search.DigestionParameters) ExportGraphicsDialog(com.compomics.util.gui.export.graphics.ExportGraphicsDialog) MouseEvent(java.awt.event.MouseEvent) File(java.io.File) ExportFormat(com.compomics.util.io.export.ExportFormat) java.awt(java.awt) GeneDetailsDialog(com.compomics.util.gui.genes.GeneDetailsDialog) StandardCategoryToolTipGenerator(org.jfree.chart.labels.StandardCategoryToolTipGenerator) ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) javax.swing(javax.swing) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) Identification(com.compomics.util.experiment.identification.Identification) Peptide(com.compomics.util.experiment.biology.proteins.Peptide)

Aggregations

Peptide (com.compomics.util.experiment.biology.proteins.Peptide)6 Identification (com.compomics.util.experiment.identification.Identification)6 PSParameter (com.compomics.util.experiment.identification.peptide_shaker.PSParameter)6 NO_KEY (com.compomics.util.experiment.personalization.ExperimentObject.NO_KEY)6 BareBonesBrowserLaunch (com.compomics.util.examples.BareBonesBrowserLaunch)5 GuiUtilities (com.compomics.util.gui.GuiUtilities)5 HelpDialog (com.compomics.util.gui.error_handlers.HelpDialog)5 ExportGraphicsDialog (com.compomics.util.gui.export.graphics.ExportGraphicsDialog)5 FileAndFileFilter (com.compomics.util.gui.file_handling.FileAndFileFilter)5 FileChooserUtil (com.compomics.util.gui.file_handling.FileChooserUtil)5 GeneDetailsDialog (com.compomics.util.gui.genes.GeneDetailsDialog)5 SelfUpdatingTableModel (com.compomics.util.gui.tablemodels.SelfUpdatingTableModel)5 ProgressDialogX (com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX)5 ExportFeature (com.compomics.util.io.export.ExportFeature)5 ExportFormat (com.compomics.util.io.export.ExportFormat)5 ExportScheme (com.compomics.util.io.export.ExportScheme)5 PsProteinFeature (com.compomics.util.io.export.features.peptideshaker.PsProteinFeature)5 PSExportFactory (eu.isas.peptideshaker.export.PSExportFactory)5 PeptideShakerGUI (eu.isas.peptideshaker.gui.PeptideShakerGUI)5 ProteinTableModel (eu.isas.peptideshaker.gui.tablemodels.ProteinTableModel)5