Search in sources :

Example 1 with SpectrumPanel

use of com.compomics.util.gui.spectrum.SpectrumPanel in project peptide-shaker by compomics.

the class SpectrumIdentificationPanel method updateSpectrum.

/**
 * Update the spectrum based on the currently selected PSM.
 */
public void updateSpectrum() {
    if (spectrumTable.getSelectedRow() != -1) {
        spectrumChartPanel.removeAll();
        String spectrumTitle = getSelectedSpectrumTitle();
        Spectrum currentSpectrum = peptideShakerGUI.getSpectrumProvider().getSpectrum(fileSelected, spectrumTitle);
        AnnotationParameters annotationParameters = peptideShakerGUI.getIdentificationParameters().getAnnotationParameters();
        long spectrumMatchKey = SpectrumMatch.getKey(fileSelected, spectrumTitle);
        SpectrumMatch spectrumMatch = identification.getSpectrumMatch(spectrumMatchKey);
        // get the selected spectrum
        if (currentSpectrum != null && currentSpectrum.getNPeaks() > 0) {
            Precursor precursor = currentSpectrum.getPrecursor();
            String chargeAsString = "";
            if (spectrumMatch != null) {
                if (spectrumMatch.getBestPeptideAssumption() != null) {
                    chargeAsString = Charge.toString(spectrumMatch.getBestPeptideAssumption().getIdentificationCharge());
                } else if (spectrumMatch.getBestTagAssumption() != null) {
                    chargeAsString = Charge.toString(spectrumMatch.getBestTagAssumption().getIdentificationCharge());
                }
            } else {
                chargeAsString = precursor.getPossibleChargesAsString();
            }
            double[] intensitiesAsArray = searchResultsTable.getSelectedRowCount() == 1 ? currentSpectrum.intensity : ArrayUtil.scaleToMax(currentSpectrum.intensity);
            spectrumPanel = new SpectrumPanel(currentSpectrum.mz, intensitiesAsArray, precursor.mz, chargeAsString, "", 40, false, false, false, 2, false);
            spectrumPanel.setKnownMassDeltas(peptideShakerGUI.getCurrentMassDeltas());
            spectrumPanel.setDeltaMassWindow(annotationParameters.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());
            // add the mirrored spectrum
            if (searchResultsTable.getSelectedRowCount() == 2) {
                spectrumPanel.addMirroredSpectrum(currentSpectrum.mz, ArrayUtil.scaleToMax(currentSpectrum.intensity), precursor.mz, chargeAsString, "", false, peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedMirroredPeakColor(), peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedMirroredPeakColor());
            }
        }
        // add spectrum annotations
        if (spectrumMatch != null) {
            SequenceProvider sequenceProvider = peptideShakerGUI.getSequenceProvider();
            IdentificationParameters identificationParameters = peptideShakerGUI.getIdentificationParameters();
            ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
            SequenceMatchingParameters modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
            SearchParameters searchParameters = identificationParameters.getSearchParameters();
            DisplayParameters displayParameters = peptideShakerGUI.getDisplayParameters();
            int forwardIon = searchParameters.getForwardIons().get(0);
            int rewindIon = searchParameters.getRewindIons().get(0);
            if (currentSpectrum != null && spectrumPanel != null) {
                if (currentSpectrum.getNPeaks() > 0) {
                    int maxPrecursorCharge = 1;
                    String modifiedSequence = "";
                    HashSet<String> allModifications = new HashSet<>();
                    ArrayList<IonMatch[]> allAnnotations = new ArrayList<>();
                    ArrayList<Spectrum> allSpectra = new ArrayList<>();
                    ArrayList<String> selectedIndexes = new ArrayList<>();
                    SpecificAnnotationParameters specificAnnotationParameters = null;
                    for (int i = 0; i < searchResultsTable.getSelectedRowCount(); i++) {
                        SpectrumIdentificationAssumption currentAssumption = currentAssumptionsList.get(searchResultsTable.getSelectedRows()[i]);
                        if (currentAssumption != null) {
                            selectedIndexes.add((i + 1) + " " + Charge.toString(currentAssumption.getIdentificationCharge()));
                            if (currentAssumption instanceof PeptideAssumption) {
                                PeptideAssumption currentPeptideAssumption = (PeptideAssumption) currentAssumption;
                                Peptide peptide = currentPeptideAssumption.getPeptide();
                                PeptideSpectrumAnnotator peptideSpectrumAnnotator = new PeptideSpectrumAnnotator();
                                specificAnnotationParameters = peptideShakerGUI.getSpecificAnnotationParameters(fileSelected, spectrumTitle, currentPeptideAssumption);
                                IonMatch[] annotations = peptideSpectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, fileSelected, spectrumTitle, currentSpectrum, peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
                                allAnnotations.add(annotations);
                                allSpectra.add(currentSpectrum);
                                // add the spectrum annotations
                                if (i == 0) {
                                    // @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);
                                    // add de novo sequencing
                                    spectrumPanel.addAutomaticDeNovoSequencing(peptide, annotations, forwardIon, rewindIon, annotationParameters.getDeNovoCharge(), annotationParameters.showForwardIonDeNovoTags(), annotationParameters.showRewindIonDeNovoTags(), false, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
                                } else {
                                    spectrumPanel.setAnnotationsMirrored(SpectrumAnnotator.getSpectrumAnnotation(annotations));
                                    // add de novo sequencing
                                    spectrumPanel.addAutomaticDeNovoSequencing(peptide, annotations, forwardIon, rewindIon, annotationParameters.getDeNovoCharge(), annotationParameters.showForwardIonDeNovoTags(), annotationParameters.showRewindIonDeNovoTags(), true, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
                                }
                                if (currentPeptideAssumption.getIdentificationCharge() > maxPrecursorCharge) {
                                    maxPrecursorCharge = currentPeptideAssumption.getIdentificationCharge();
                                }
                                if (!modifiedSequence.isEmpty()) {
                                    modifiedSequence += " vs. ";
                                }
                                modifiedSequence += peptide.getTaggedModifiedSequence(modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, false, false, true, displayParameters.getDisplayedModifications());
                                allModifications.addAll(ModificationUtils.getAllModifications(peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters));
                            } else if (currentAssumption instanceof TagAssumption) {
                                TagAssumption tagAssumption = (TagAssumption) currentAssumption;
                                TagSpectrumAnnotator spectrumAnnotator = new TagSpectrumAnnotator();
                                specificAnnotationParameters = peptideShakerGUI.getSpecificAnnotationParameters(fileSelected, spectrumTitle, tagAssumption);
                                IonMatch[] annotations = spectrumAnnotator.getSpectrumAnnotation(annotationParameters, modificationParameters, modificationSequenceMatchingParameters, specificAnnotationParameters, fileSelected, spectrumTitle, currentSpectrum, tagAssumption.getTag());
                                // add the spectrum annotations
                                // @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);
                                // add de novo sequencing
                                spectrumPanel.addAutomaticDeNovoSequencing(tagAssumption.getTag(), annotations, forwardIon, rewindIon, annotationParameters.getDeNovoCharge(), annotationParameters.showForwardIonDeNovoTags(), annotationParameters.showRewindIonDeNovoTags(), false);
                                // get the modifications for the tag
                                allModifications.addAll(ModificationUtils.getAllModifications(tagAssumption.getTag(), modificationParameters, modificationSequenceMatchingParameters));
                                if (tagAssumption.getIdentificationCharge() > maxPrecursorCharge) {
                                    maxPrecursorCharge = tagAssumption.getIdentificationCharge();
                                }
                                if (!modifiedSequence.isEmpty()) {
                                    modifiedSequence += " vs. ";
                                }
                                modifiedSequence += tagAssumption.getTag().getTaggedModifiedSequence(modificationParameters, false, false, true, false, modificationSequenceMatchingParameters, displayParameters.getDisplayedModifications());
                            } else {
                                throw new UnsupportedOperationException("Spectrum annotation not implemented for identification assumption of type " + currentAssumption.getClass() + ".");
                            }
                        }
                    }
                    spectrumPanel.showAnnotatedPeaksOnly(!annotationParameters.showAllPeaks());
                    spectrumPanel.setYAxisZoomExcludesBackgroundPeaks(annotationParameters.yAxisZoomExcludesBackgroundPeaks());
                    peptideShakerGUI.updateAnnotationMenus(specificAnnotationParameters, maxPrecursorCharge, allModifications);
                    // update the spectrum title
                    if (searchResultsTable.getSelectedRowCount() == 1) {
                        ((TitledBorder) spectrumPanelPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Spectrum & Fragment Ions (" + modifiedSequence + "   " + maxPrecursorCharge + "   " + Util.roundDouble(currentSpectrum.getPrecursor().mz, 2) + " m/z)" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
                    } else if (searchResultsTable.getSelectedRowCount() == 2) {
                        ((TitledBorder) spectrumPanelPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Spectrum & Fragment Ions (" + modifiedSequence + ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
                    } else if (searchResultsTable.getSelectedRowCount() > 2) {
                        ((TitledBorder) spectrumPanelPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Spectrum & Fragment Ions (" + searchResultsTable.getSelectedRowCount() + " PSMs)" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
                    }
                    spectrumPanelPanel.repaint();
                    if (searchResultsTable.getSelectedRowCount() > 2) {
                        SearchParameters.MassAccuracyType fragmentAccuracyType = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getFragmentAccuracyType();
                        double bubbleScale = annotationParameters.getFragmentIonAccuracy() * 10 * peptideShakerGUI.getBubbleScale();
                        DisplayParameters displayPreferences = peptideShakerGUI.getDisplayParameters();
                        MassErrorBubblePlot massErrorBubblePlot = new MassErrorBubblePlot(selectedIndexes, allAnnotations, allSpectra, annotationParameters.getFragmentIonAccuracy(), bubbleScale, selectedIndexes.size() == 1, displayPreferences.showBars(), fragmentAccuracyType == SearchParameters.MassAccuracyType.PPM);
                        // hide the legend if selecting more than 20 spectra // @TODO: 20 should not be hardcoded here..
                        if (selectedIndexes.size() > 20) {
                            massErrorBubblePlot.getChartPanel().getChart().getLegend().setVisible(false);
                        }
                        // hide the outline
                        massErrorBubblePlot.getChartPanel().getChart().getPlot().setOutlineVisible(false);
                        spectrumChartPanel.add(massErrorBubblePlot);
                    }
                }
            }
            if (searchResultsTable.getSelectedRowCount() <= 2) {
                spectrumChartPanel.add(spectrumPanel);
            }
        } else {
            // update the spectrum title
            ((TitledBorder) spectrumPanelPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Spectrum & Fragment Ions (" + Util.roundDouble(currentSpectrum.getPrecursor().mz, 2) + " m/z)" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
            if (currentSpectrum.getNPeaks() > 0) {
                spectrumChartPanel.add(spectrumPanel);
            }
            spectrumPanelPanel.repaint();
        }
    }
    spectrumChartPanel.revalidate();
    spectrumChartPanel.repaint();
}
Also used : MassErrorBubblePlot(com.compomics.util.gui.spectrum.MassErrorBubblePlot) SpecificAnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.SpecificAnnotationParameters) AnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters) DisplayParameters(eu.isas.peptideshaker.preferences.DisplayParameters) ArrayList(java.util.ArrayList) 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) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) TagAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.TagAssumption) IonMatch(com.compomics.util.experiment.identification.matches.IonMatch) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) TagSpectrumAnnotator(com.compomics.util.experiment.identification.spectrum_annotation.spectrum_annotators.TagSpectrumAnnotator) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) HashSet(java.util.HashSet) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) SpectrumIdentificationAssumption(com.compomics.util.experiment.identification.SpectrumIdentificationAssumption) SpectrumPanel(com.compomics.util.gui.spectrum.SpectrumPanel) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption) PeptideSpectrumAnnotator(com.compomics.util.experiment.identification.spectrum_annotation.spectrum_annotators.PeptideSpectrumAnnotator)

Example 2 with SpectrumPanel

use of com.compomics.util.gui.spectrum.SpectrumPanel in project COSS by compomics.

the class MainFrameController method spectrumDisplay.

/**
 * display color raster of the whole spectra in the target dataset
 */
/**
 * visual spectrum display of a selected query spectrum at the position
 * specIndex
 *
 * @param specIndex position of the spectrum to be visualized
 */
public void spectrumDisplay(int specIndex) throws JMzReaderException {
    // targetView.pnlVizSpectrum.removeAll();
    mainView.pnlQuerySpecViz.removeAll();
    // SpecPanel spec = new SpecPanel(null);
    double[] mz = new double[0];
    double[] intensity = new double[0];
    double precMass = 0;
    String precCharge = "";
    String name = "";
    SpectrumPanel spanel = new SpectrumPanel(mz, intensity, precMass, precCharge, name);
    Spectrum tSpec = new Spectrum();
    if (configData.getExpSpectraIndex() != null || configData.getEbiReader() != null) {
        if (configData.getExpFileformat().equals("ms2io")) {
            tSpec = configData.getExpSpecReader().readAt(configData.getExpSpectraIndex().get(specIndex).getPos());
        } else if (configData.getExpFileformat().equals("ebi")) {
            JMzReader redr = configData.getEbiReader();
            uk.ac.ebi.pride.tools.jmzreader.model.Spectrum jmzSpec = redr.getSpectrumByIndex(specIndex + 1);
            String fileType = FilenameUtils.getExtension(configData.getExperimentalSpecFile().getName());
            MappingJmzSpectrum jmzMap = new MappingJmzSpectrum(fileType);
            tSpec = jmzMap.getMappedSpectrum(jmzSpec);
        }
        ArrayList<Peak> peaks = tSpec.getPeakList();
        try {
            int lenPeaks = peaks.size();
            mz = new double[lenPeaks];
            intensity = new double[lenPeaks];
            precMass = tSpec.getPCMass();
            precCharge = tSpec.getCharge_asStr();
            name = tSpec.getTitle();
            int c = 0;
            for (Peak p : peaks) {
                mz[c] = p.getMz();
                intensity[c] = p.getIntensity();
                c++;
            }
            spanel = new SpectrumPanel(mz, intensity, precMass, precCharge, name);
        } catch (Exception ex) {
            System.out.println(ex);
        }
    }
    mainView.pnlQuerySpecViz.add(spanel);
    mainView.pnlQuerySpecViz.repaint();
    mainView.pnlQuerySpecViz.revalidate();
}
Also used : JMzReaderException(uk.ac.ebi.pride.tools.jmzreader.JMzReaderException) CancellationException(java.util.concurrent.CancellationException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) Spectrum(com.compomics.ms2io.model.Spectrum) SpectrumPanel(com.compomics.util.gui.spectrum.SpectrumPanel) Peak(com.compomics.ms2io.model.Peak) JMzReader(uk.ac.ebi.pride.tools.jmzreader.JMzReader)

Example 3 with SpectrumPanel

use of com.compomics.util.gui.spectrum.SpectrumPanel in project COSS by compomics.

the class TestFrame method jButton1MouseClicked.

// </editor-fold>//GEN-END:initComponents
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
    // GEN-FIRST:event_jButton1MouseClicked
    // TODO add your handling code here:
    double[] mz = { 1, 2, 3, 4, 5, 6 };
    double[] intensity = { 100, 130, 140, 213, 50, 180 };
    double pcMass = 6;
    String charge = "+1";
    SpectrumPanel spanel = new SpectrumPanel(mz, intensity, pcMass, charge, "test spec");
    this.pnlviz.add(spanel);
    this.pnlviz.repaint();
    this.pnlviz.revalidate();
}
Also used : SpectrumPanel(com.compomics.util.gui.spectrum.SpectrumPanel)

Example 4 with SpectrumPanel

use of com.compomics.util.gui.spectrum.SpectrumPanel in project peptide-shaker by compomics.

the class ModificationsPanel method updateSpectrum.

/**
 * Update the spectra according to the currently selected PSM.
 *
 * @param spectrumMatchKey the main spectrum match key
 * @param secondSpectrumMatchKey the secondary spectrum key
 */
public void updateSpectrum(long spectrumMatchKey, Long secondSpectrumMatchKey) {
    SpectrumProvider spectrumProvider = peptideShakerGUI.getSpectrumProvider();
    spectrumChartJPanel.removeAll();
    spectrumChartJPanel.revalidate();
    spectrumChartJPanel.repaint();
    SequenceProvider sequenceProvider = peptideShakerGUI.getSequenceProvider();
    IdentificationParameters identificationParameters = peptideShakerGUI.getIdentificationParameters();
    AnnotationParameters annotationParameters = identificationParameters.getAnnotationParameters();
    ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
    SequenceMatchingParameters modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
    SpectrumMatch spectrumMatch = identification.getSpectrumMatch(spectrumMatchKey);
    String spectrumFile = spectrumMatch.getSpectrumFile();
    String spectrumTitle = spectrumMatch.getSpectrumTitle();
    Spectrum currentSpectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
    SpectrumMatch secondSpectrumMatch = null;
    if (currentSpectrum != null && currentSpectrum.mz.length > 0) {
        Precursor precursor = currentSpectrum.getPrecursor();
        double[] intensityArray = secondSpectrumMatchKey == null ? currentSpectrum.intensity : ArrayUtil.scaleToMax(currentSpectrum.intensity);
        spectrumPanel = new SpectrumPanel(currentSpectrum.mz, intensityArray, 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());
        int identificationChargeFirstPsm = 0;
        int identificationChargeSecondPsm = 0;
        HashSet<String> allModifications = new HashSet<>(2);
        // get the spectrum annotations
        PeptideAssumption peptideAssumption = spectrumMatch.getBestPeptideAssumption();
        Peptide peptide = peptideAssumption.getPeptide();
        identificationChargeFirstPsm = spectrumMatch.getBestPeptideAssumption().getIdentificationCharge();
        allModifications.addAll(ModificationUtils.getAllModifications(peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters));
        PeptideSpectrumAnnotator spectrumAnnotator = new PeptideSpectrumAnnotator();
        SpecificAnnotationParameters specificAnnotationParameters = peptideShakerGUI.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, peptideAssumption);
        IonMatch[] annotations = spectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, spectrumFile, spectrumTitle, currentSpectrum, peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
        // add the spectrum annotations
        // @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.showAnnotatedPeaksOnly(!annotationParameters.showAllPeaks());
        spectrumPanel.setYAxisZoomExcludesBackgroundPeaks(annotationParameters.yAxisZoomExcludesBackgroundPeaks());
        // add de novo sequencing
        SearchParameters searchParameters = peptideShakerGUI.getIdentificationParameters().getSearchParameters();
        Integer forwardIon = searchParameters.getForwardIons().get(0);
        Integer rewindIon = searchParameters.getRewindIons().get(0);
        spectrumPanel.addAutomaticDeNovoSequencing(peptide, annotations, forwardIon, rewindIon, annotationParameters.getDeNovoCharge(), annotationParameters.showForwardIonDeNovoTags(), annotationParameters.showRewindIonDeNovoTags(), false, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
        // see if a second mirrored spectrum is to be added
        if (secondSpectrumMatchKey != null) {
            secondSpectrumMatch = identification.getSpectrumMatch(secondSpectrumMatchKey);
            spectrumFile = spectrumMatch.getSpectrumFile();
            spectrumTitle = spectrumMatch.getSpectrumTitle();
            currentSpectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
            if (currentSpectrum != null && currentSpectrum.mz.length > 0) {
                precursor = currentSpectrum.getPrecursor();
                spectrumPanel.addMirroredSpectrum(currentSpectrum.mz, ArrayUtil.scaleToMax(currentSpectrum.intensity), currentSpectrum.getPrecursor().mz, Charge.toString(secondSpectrumMatch.getBestPeptideAssumption().getIdentificationCharge()), "", false, peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedMirroredPeakColor(), peptideShakerGUI.getUtilitiesUserParameters().getSpectrumAnnotatedMirroredPeakColor());
                // get the spectrum annotations
                peptideAssumption = secondSpectrumMatch.getBestPeptideAssumption();
                peptide = peptideAssumption.getPeptide();
                identificationChargeSecondPsm = secondSpectrumMatch.getBestPeptideAssumption().getIdentificationCharge();
                allModifications.addAll(ModificationUtils.getAllModifications(peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters));
                specificAnnotationParameters = peptideShakerGUI.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, peptideAssumption);
                annotations = spectrumAnnotator.getSpectrumAnnotation(annotationParameters, specificAnnotationParameters, spectrumFile, spectrumTitle, currentSpectrum, peptide, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
                spectrumPanel.setAnnotationsMirrored(SpectrumAnnotator.getSpectrumAnnotation(annotations));
                // add de novo sequencing
                spectrumPanel.addAutomaticDeNovoSequencing(peptide, annotations, forwardIon, rewindIon, annotationParameters.getDeNovoCharge(), annotationParameters.showForwardIonDeNovoTags(), annotationParameters.showRewindIonDeNovoTags(), true, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
                spectrumPanel.rescale(0.0, spectrumPanel.getMaxXAxisValue());
            }
        }
        spectrumChartJPanel.add(spectrumPanel);
        peptideShakerGUI.updateAnnotationMenus(specificAnnotationParameters, Math.max(identificationChargeFirstPsm, identificationChargeSecondPsm), allModifications);
        String modifiedSequence = peptideShakerGUI.getDisplayFeaturesGenerator().getTaggedPeptideSequence(spectrumMatch, false, false, true);
        if (secondSpectrumMatchKey != null) {
            modifiedSequence += " vs. " + peptideShakerGUI.getDisplayFeaturesGenerator().getTaggedPeptideSequence(secondSpectrumMatch, false, false, true);
        }
        ((TitledBorder) spectrumAndFragmentIonPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Spectrum & Fragment Ions (" + modifiedSequence + ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
        spectrumAndFragmentIonPanel.revalidate();
        spectrumAndFragmentIonPanel.repaint();
    }
    spectrumChartJPanel.revalidate();
    spectrumChartJPanel.repaint();
}
Also used : SpecificAnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.SpecificAnnotationParameters) AnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) 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) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) IonMatch(com.compomics.util.experiment.identification.matches.IonMatch) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) SpectrumPanel(com.compomics.util.gui.spectrum.SpectrumPanel) 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) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) HashSet(java.util.HashSet) PeptideSpectrumAnnotator(com.compomics.util.experiment.identification.spectrum_annotation.spectrum_annotators.PeptideSpectrumAnnotator)

Example 5 with SpectrumPanel

use of com.compomics.util.gui.spectrum.SpectrumPanel in project COSS by compomics.

the class MainFrameController method displayResult.

/**
 * Displays the comparison result visually on the result panel
 */
private void displayResult() {
    int c = 0;
    try {
        if (result != null && !result.isEmpty() && result.get(targSpectrumNum).getMatchedLibSpec() != null && !result.get(targSpectrumNum).getMatchedLibSpec().isEmpty()) {
            ComparisonResult res = result.get(targSpectrumNum);
            Spectrum targSpec = res.getEspSpectrum();
            if (this.resultNumber < 0) {
                this.resultNumber = 0;
            }
            Spectrum matchedSpec = res.getMatchedLibSpec().get(resultNumber).getSpectrum();
            double precMass_tar = targSpec.getPCMass();
            double precMass_match = matchedSpec.getPCMass();
            String targCharge = targSpec.getCharge_asStr();
            String matchedCharge = matchedSpec.getCharge_asStr();
            String tarName = targSpec.getTitle();
            String matchedName = matchedSpec.getTitle();
            ArrayList<Peak> peaks = targSpec.getPeakList();
            double[] mz_tar = new double[peaks.size()];
            double[] int_tar = new double[peaks.size()];
            c = 0;
            for (Peak p : peaks) {
                mz_tar[c] = p.getMz();
                int_tar[c] = p.getIntensity();
                c++;
            }
            peaks = matchedSpec.getPeakList();
            double[] mz_matched = new double[peaks.size()];
            double[] int_matched = new double[peaks.size()];
            c = 0;
            for (Peak p : peaks) {
                mz_matched[c] = p.getMz();
                int_matched[c] = p.getIntensity();
                c++;
            }
            SpectrumPanel spanel = new SpectrumPanel(mz_tar, int_tar, precMass_tar, targCharge, tarName);
            spanel.addMirroredSpectrum(mz_matched, int_matched, precMass_match, matchedCharge, matchedName, false, java.awt.Color.blue, java.awt.Color.cyan);
            mainView.pnlResultSpec.removeAll();
            mainView.pnlResultSpec.add(spanel);
        // mainView.pnlVisualResult.removeAll();
        // mainView.pnlVisualResult.add(spanel);
        } else {
            mainView.pnlResultSpec.removeAll();
        }
    } catch (Exception exception) {
        LOG.error(exception + " target spectrum number: " + Integer.toString(this.resultNumber + c));
    }
    mainView.pnlResultSpec.revalidate();
    mainView.pnlResultSpec.repaint();
}
Also used : SpectrumPanel(com.compomics.util.gui.spectrum.SpectrumPanel) Peak(com.compomics.ms2io.model.Peak) ComparisonResult(com.compomics.coss.model.ComparisonResult) JMzReaderException(uk.ac.ebi.pride.tools.jmzreader.JMzReaderException) CancellationException(java.util.concurrent.CancellationException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) Spectrum(com.compomics.ms2io.model.Spectrum)

Aggregations

SpectrumPanel (com.compomics.util.gui.spectrum.SpectrumPanel)5 Peak (com.compomics.ms2io.model.Peak)2 Spectrum (com.compomics.ms2io.model.Spectrum)2 Peptide (com.compomics.util.experiment.biology.proteins.Peptide)2 IonMatch (com.compomics.util.experiment.identification.matches.IonMatch)2 SpectrumMatch (com.compomics.util.experiment.identification.matches.SpectrumMatch)2 AnnotationParameters (com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters)2 SpecificAnnotationParameters (com.compomics.util.experiment.identification.spectrum_annotation.SpecificAnnotationParameters)2 PeptideSpectrumAnnotator (com.compomics.util.experiment.identification.spectrum_annotation.spectrum_annotators.PeptideSpectrumAnnotator)2 PeptideAssumption (com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption)2 SequenceProvider (com.compomics.util.experiment.io.biology.protein.SequenceProvider)2 Precursor (com.compomics.util.experiment.mass_spectrometry.spectra.Precursor)2 Spectrum (com.compomics.util.experiment.mass_spectrometry.spectra.Spectrum)2 IdentificationParameters (com.compomics.util.parameters.identification.IdentificationParameters)2 SequenceMatchingParameters (com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters)2 ModificationParameters (com.compomics.util.parameters.identification.search.ModificationParameters)2 SearchParameters (com.compomics.util.parameters.identification.search.SearchParameters)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 CancellationException (java.util.concurrent.CancellationException)2