Package com.compomics.util.experiment.massspectrometry

Examples of com.compomics.util.experiment.massspectrometry.MSnSpectrum


            spectrumChartJPanel.removeAll();
            spectrumChartJPanel.revalidate();
            spectrumChartJPanel.repaint();

            AnnotationPreferences annotationPreferences = peptideShakerGUI.getAnnotationPreferences();
            MSnSpectrum currentSpectrum = peptideShakerGUI.getSpectrum(spectrumKey);

            if (currentSpectrum != null && currentSpectrum.getMzValuesAsArray().length > 0) {

                Precursor precursor = currentSpectrum.getPrecursor();
                SpectrumMatch spectrumMatch = peptideShakerGUI.getIdentification().getSpectrumMatch(spectrumKey);
                spectrum = new SpectrumPanel(
                        currentSpectrum.getMzValuesAsArray(), currentSpectrum.getIntensityValuesAsArray(),
                        precursor.getMz(), spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().toString(),
                        "", 40, false, false, false, 2, false);
                spectrum.setKnownMassDeltas(peptideShakerGUI.getCurrentMassDeltas());
                spectrum.setDeltaMassWindow(peptideShakerGUI.getAnnotationPreferences().getFragmentIonAccuracy());
                spectrum.setBorder(null);
                spectrum.setDataPointAndLineColor(peptideShakerGUI.getUtilitiesUserPreferences().getSpectrumAnnotatedPeakColor(), 0);
                spectrum.setPeakWaterMarkColor(peptideShakerGUI.getUtilitiesUserPreferences().getSpectrumBackgroundPeakColor());
                spectrum.setPeakWidth(peptideShakerGUI.getUtilitiesUserPreferences().getSpectrumAnnotatedPeakWidth());
                spectrum.setBackgroundPeakWidth(peptideShakerGUI.getUtilitiesUserPreferences().getSpectrumBackgroundPeakWidth());

                // get the spectrum annotations
                PeptideAssumption peptideAssumption = spectrumMatch.getBestPeptideAssumption();
                Peptide peptide = peptideAssumption.getPeptide();
                int identificationCharge = spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().value;
                annotationPreferences.setCurrentSettings(peptideAssumption, !currentSpectrumKey.equalsIgnoreCase(spectrumMatch.getKey()), peptideShakerGUI.getSequenceMatchingPreferences());
                ArrayList<IonMatch> annotations = annotator.getSpectrumAnnotation(annotationPreferences.getIonTypes(),
                        annotationPreferences.getNeutralLosses(),
                        annotationPreferences.getValidatedCharges(),
                        identificationCharge,
                        currentSpectrum, peptide,
                        currentSpectrum.getIntensityLimit(annotationPreferences.getAnnotationIntensityLimit()),
                        annotationPreferences.getFragmentIonAccuracy(), false, annotationPreferences.isHighResolutionAnnotation());
                currentSpectrumKey = spectrumMatch.getKey();

                // add the spectrum annotations
                spectrum.setAnnotations(SpectrumAnnotator.getSpectrumAnnotation(annotations));
View Full Code Here


    public String getSpectrumAsMgf() {

        String spectrumAsMgf = "";
        try {
            for (String spectrumKey : getSelectedPsm()) {
                MSnSpectrum currentSpectrum = peptideShakerGUI.getSpectrum(spectrumKey);
                spectrumAsMgf += currentSpectrum.asMgf() + System.getProperty("line.separator");
            }
            if (!spectrumAsMgf.isEmpty()) {
                return spectrumAsMgf;
            }
        } catch (Exception e) {
View Full Code Here

        if (header) {
            writeHeader();
        }

        MSnSpectrum spectrum = (MSnSpectrum) spectrumFactory.getSpectrum(spectrumMatch.getKey());
        PeptideSpectrumAnnotator spectrumAnnotator = new PeptideSpectrumAnnotator();

        ArrayList<IonMatch> annotations = spectrumAnnotator.getSpectrumAnnotation(annotationPreferences.getIonTypes(),
                annotationPreferences.getNeutralLosses(),
                annotationPreferences.getValidatedCharges(),
                spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().value,
                spectrum,
                spectrumMatch.getBestPeptideAssumption().getPeptide(),
                spectrum.getIntensityLimit(annotationPreferences.getAnnotationIntensityLimit()),
                annotationPreferences.getFragmentIonAccuracy(), false, annotationPreferences.isHighResolutionAnnotation());

        HashMap<Double, ArrayList<IonMatch>> sortedAnnotation = new HashMap<Double, ArrayList<IonMatch>>();
        for (IonMatch ionMatch : annotations) {
            double mz = ionMatch.peak.mz;
View Full Code Here

     */
    private void writeFragmentIons(SpectrumMatch spectrumMatch) throws IOException, MzMLUnmarshallerException, IllegalArgumentException, InterruptedException, FileNotFoundException, ClassNotFoundException, SQLException {

        Peptide peptide = spectrumMatch.getBestPeptideAssumption().getPeptide();
        annotationPreferences.setCurrentSettings(spectrumMatch.getBestPeptideAssumption(), true, sequenceMatchingPreferences);
        MSnSpectrum tempSpectrum = ((MSnSpectrum) spectrumFactory.getSpectrum(spectrumMatch.getKey()));

        ArrayList<IonMatch> annotations = spectrumAnnotator.getSpectrumAnnotation(annotationPreferences.getIonTypes(),
                annotationPreferences.getNeutralLosses(),
                annotationPreferences.getValidatedCharges(),
                spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().value,
                tempSpectrum, peptide,
                tempSpectrum.getIntensityLimit(annotationPreferences.getAnnotationIntensityLimit()),
                annotationPreferences.getFragmentIonAccuracy(), false, annotationPreferences.isHighResolutionAnnotation());

        for (int i = 0; i < annotations.size(); i++) {
            writeFragmentIon(annotations.get(i));
        }
View Full Code Here

                if (waitingHandler.isRunCanceled()) {
                    break;
                }

                String spectrumKey = Spectrum.getSpectrumKey(mgfFile, spectrumTitle);
                MSnSpectrum tempSpectrum = ((MSnSpectrum) spectrumFactory.getSpectrum(spectrumKey));
                if (!tempSpectrum.getPeakList().isEmpty()) {
                    boolean identified = identification.matchExists(spectrumKey);
                    writeSpectrum(tempSpectrum, identified, spectrumCounter);
                    if (identified) {
                        spectrumIndexes.put(spectrumKey, spectrumCounter);
                    }
View Full Code Here

                            if (assumption instanceof PeptideAssumption) {

                                PeptideAssumption peptideAssumption = (PeptideAssumption) assumption;
                                annotationPreferences.setCurrentSettings(peptideAssumption, true, sequenceMatchingPreferences);
                                PSParameter psParameter = new PSParameter();
                                MSnSpectrum spectrum = (MSnSpectrum) spectrumFactory.getSpectrum(spectrumKey);

                                for (int scoreIndex : processingPreferences.getScores(advocateIndex)) {

                                    Peptide peptide = peptideAssumption.getPeptide();
                                    boolean decoy = peptide.isDecoy(sequenceMatchingPreferences);
View Full Code Here

            try {
                spectrumChartPanel.removeAll();

                String key = getSelectedSpectrumKey();
                MSnSpectrum currentSpectrum = peptideShakerGUI.getSpectrum(key);
                SpectrumPanel tempSpectrumPanel = null;
                AnnotationPreferences annotationPreferences = peptideShakerGUI.getAnnotationPreferences();

                if (currentSpectrum != null) {
                    Precursor precursor = currentSpectrum.getPrecursor();
                    String charge;
                    if (identification.matchExists(currentSpectrumKey)) {
                        SpectrumMatch spectrumMatch = identification.getSpectrumMatch(currentSpectrumKey);
                        if (spectrumMatch.getBestPeptideAssumption() != null) {
                            charge = spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().toString();
                        } else if (spectrumMatch.getBestTagAssumption() != null) {
                            charge = spectrumMatch.getBestTagAssumption().getIdentificationCharge().toString();
                        } else {
                            throw new IllegalArgumentException("Best hit not found for spectrum " + key + ".");
                        }
                    } else {
                        charge = precursor.getPossibleChargesAsString();
                    }
                    if (currentSpectrum.getMzValuesAsArray().length > 0 && currentSpectrum.getIntensityValuesAsArray().length > 0) {
                        tempSpectrumPanel = new SpectrumPanel(
                                currentSpectrum.getMzValuesAsArray(), currentSpectrum.getIntensityValuesAsArray(),
                                precursor.getMz(), charge,
                                "", 40, false, false, false, 2, false);
                        tempSpectrumPanel.setKnownMassDeltas(peptideShakerGUI.getCurrentMassDeltas());
                        tempSpectrumPanel.setDeltaMassWindow(annotationPreferences.getFragmentIonAccuracy());
                        tempSpectrumPanel.setBorder(null);
                        tempSpectrumPanel.setDataPointAndLineColor(peptideShakerGUI.getUtilitiesUserPreferences().getSpectrumAnnotatedPeakColor(), 0);
                        tempSpectrumPanel.setPeakWaterMarkColor(peptideShakerGUI.getUtilitiesUserPreferences().getSpectrumBackgroundPeakColor());
                        tempSpectrumPanel.setPeakWidth(peptideShakerGUI.getUtilitiesUserPreferences().getSpectrumAnnotatedPeakWidth());
                        tempSpectrumPanel.setBackgroundPeakWidth(peptideShakerGUI.getUtilitiesUserPreferences().getSpectrumBackgroundPeakWidth());
                    }
                }

                if (identification.matchExists(key)) {

                    SpectrumMatch spectrumMatch = identification.getSpectrumMatch(key);

                    SearchParameters searchParameters = peptideShakerGUI.getSearchParameters();
                    int forwardIon = searchParameters.getIonSearched1();
                    int rewindIon = searchParameters.getIonSearched2();
                    ModificationProfile modificationProfile = searchParameters.getModificationProfile();

                    if (currentSpectrum != null && tempSpectrumPanel != null) {

                        if (currentSpectrum.getMzValuesAsArray().length > 0 && currentSpectrum.getIntensityValuesAsArray().length > 0) {

                            if (searchResultsTable.getSelectedRow() != -1) {
                                SpectrumIdentificationAssumption currentAssumption = currentAssumptionsList.get(searchResultsTable.getSelectedRow());

                                if (currentAssumption != null) {
                                    currentSpectrumKey = spectrumMatch.getKey();
                                    if (currentAssumption instanceof PeptideAssumption) {
                                        PeptideAssumption currentPeptideAssumption = (PeptideAssumption) currentAssumption;
                                        Peptide peptide = currentPeptideAssumption.getPeptide();
                                        annotationPreferences.setCurrentSettings(currentPeptideAssumption, !currentSpectrumKey.equalsIgnoreCase(spectrumMatch.getKey()),
                                                peptideShakerGUI.getSequenceMatchingPreferences());
                                        ArrayList<IonMatch> annotations = specificAnnotator.getSpectrumAnnotation(annotationPreferences.getIonTypes(),
                                                annotationPreferences.getNeutralLosses(),
                                                annotationPreferences.getValidatedCharges(),
                                                currentPeptideAssumption.getIdentificationCharge().value,
                                                currentSpectrum, peptide,
                                                currentSpectrum.getIntensityLimit(annotationPreferences.getAnnotationIntensityLimit()),
                                                annotationPreferences.getFragmentIonAccuracy(), false, annotationPreferences.isHighResolutionAnnotation());

                                        // add the spectrum annotations
                                        tempSpectrumPanel.setAnnotations(SpectrumAnnotator.getSpectrumAnnotation(annotations));
                                        tempSpectrumPanel.showAnnotatedPeaksOnly(!annotationPreferences.showAllPeaks());
                                        tempSpectrumPanel.setYAxisZoomExcludesBackgroundPeaks(annotationPreferences.yAxisZoomExcludesBackgroundPeaks());

                                        // add de novo sequencing
                                        tempSpectrumPanel.addAutomaticDeNovoSequencing(peptide, annotations,
                                                forwardIon, rewindIon, annotationPreferences.getDeNovoCharge(),
                                                annotationPreferences.showForwardIonDeNovoTags(),
                                                annotationPreferences.showRewindIonDeNovoTags());

                                        peptideShakerGUI.updateAnnotationMenus(currentPeptideAssumption.getIdentificationCharge().value, peptide.getModificationMatches());

                                        // update the spectrum title
                                        String modifiedSequence = peptide.getTaggedModifiedSequence(modificationProfile, false, false, true);
                                        ((TitledBorder) spectrumPanel.getBorder()).setTitle(
                                                PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING
                                                + "Spectrum & Fragment Ions (" + modifiedSequence
                                                + "   " + currentPeptideAssumption.getIdentificationCharge().toString() + "   "
                                                + Util.roundDouble(currentSpectrum.getPrecursor().getMz(), 2) + " m/z)"
                                                + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
                                    } else if (currentAssumption instanceof TagAssumption) {
                                        TagAssumption tagAssumption = (TagAssumption) currentAssumption;

                                        // add the annotations
                                        annotationPreferences.setCurrentSettings(tagAssumption, !currentSpectrumKey.equalsIgnoreCase(spectrumMatch.getKey()),
                                                peptideShakerGUI.getSequenceMatchingPreferences());

                                        TagSpectrumAnnotator spectrumAnnotator = new TagSpectrumAnnotator();

                                        ArrayList<IonMatch> annotations = spectrumAnnotator.getSpectrumAnnotation(annotationPreferences.getIonTypes(),
                                                annotationPreferences.getNeutralLosses(),
                                                annotationPreferences.getValidatedCharges(),
                                                tagAssumption.getIdentificationCharge().value,
                                                currentSpectrum, tagAssumption.getTag(),
                                                currentSpectrum.getIntensityLimit(annotationPreferences.getAnnotationIntensityLimit()),
                                                annotationPreferences.getFragmentIonAccuracy(),
                                                false, annotationPreferences.isHighResolutionAnnotation());

                                        // add the spectrum annotations
                                        tempSpectrumPanel.setAnnotations(SpectrumAnnotator.getSpectrumAnnotation(annotations));
                                        tempSpectrumPanel.showAnnotatedPeaksOnly(!annotationPreferences.showAllPeaks());
                                        tempSpectrumPanel.setYAxisZoomExcludesBackgroundPeaks(annotationPreferences.yAxisZoomExcludesBackgroundPeaks());

                                        // add de novo sequencing
                                        tempSpectrumPanel.addAutomaticDeNovoSequencing(tagAssumption.getTag(), annotations,
                                                forwardIon, rewindIon, annotationPreferences.getDeNovoCharge(),
                                                annotationPreferences.showForwardIonDeNovoTags(),
                                                annotationPreferences.showRewindIonDeNovoTags());

                                        // get the modifications for the tag
                                        ArrayList<ModificationMatch> modificationMatches = new ArrayList<ModificationMatch>();

                                        for (TagComponent tagComponent : tagAssumption.getTag().getContent()) {
                                            if (tagComponent instanceof AminoAcidPattern) {
                                                AminoAcidPattern aminoAcidPattern = (AminoAcidPattern) tagComponent;
                                                for (int site = 1; site <= aminoAcidPattern.length(); site++) {
                                                    for (ModificationMatch modificationMatch : aminoAcidPattern.getModificationsAt(site)) {
                                                        modificationMatches.add(modificationMatch);
                                                    }
                                                }
                                            } else if (tagComponent instanceof AminoAcidSequence) {
                                                AminoAcidSequence aminoAcidSequence = (AminoAcidSequence) tagComponent;
                                                for (int site = 1; site <= aminoAcidSequence.length(); site++) {
                                                    for (ModificationMatch modificationMatch : aminoAcidSequence.getModificationsAt(site)) {
                                                        modificationMatches.add(modificationMatch);
                                                    }
                                                }
                                            } else if (tagComponent instanceof MassGap) {
                                                // Nothing to do here
                                            } else {
                                                throw new UnsupportedOperationException("Annotation not supported for the tag component " + tagComponent.getClass() + ".");
                                            }
                                        }

                                        peptideShakerGUI.updateAnnotationMenus(tagAssumption.getIdentificationCharge().value, modificationMatches);

                                        // update the spectrum title
                                        String modifiedSequence = tagAssumption.getTag().getTaggedModifiedSequence(peptideShakerGUI.getSearchParameters().getModificationProfile(), false, false, true, false);
                                        ((TitledBorder) spectrumPanel.getBorder()).setTitle(
                                                PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING
                                                + "Spectrum & Fragment Ions (" + modifiedSequence
                                                + "   " + tagAssumption.getIdentificationCharge().toString() + "   "
                                                + Util.roundDouble(currentSpectrum.getPrecursor().getMz(), 2) + " m/z)"
                                                + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
                                    }

                                    spectrumPanel.repaint();
                                }
                            }
                        }
                    }
                } else {
                    // update the spectrum title
                    ((TitledBorder) spectrumPanel.getBorder()).setTitle(
                            PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING
                            + "Spectrum & Fragment Ions ("
                            + Util.roundDouble(currentSpectrum.getPrecursor().getMz(), 2) + " m/z)"
                            + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
                    spectrumPanel.repaint();
                }

                if (tempSpectrumPanel != null) {
View Full Code Here

     */
    public String getSpectrumAsMgf() {

        if (spectrumTable.getSelectedRow() != -1) {
            String spectrumKey = getSelectedSpectrumKey();
            MSnSpectrum currentSpectrum = peptideShakerGUI.getSpectrum(spectrumKey);

            if (currentSpectrum != null) {
                return currentSpectrum.asMgf();
            }
        }

        return null;
    }
View Full Code Here

                AnnotationPreferences annotationPreferences = peptideShakerGUI.getAnnotationPreferences();

                // iterate the selected psms
                for (String spectrumKey : selectedPsmKeys) {

                    MSnSpectrum currentSpectrum = peptideShakerGUI.getSpectrum(spectrumKey);

                    if (currentSpectrum != null) {
                        SpectrumMatch spectrumMatch = peptideShakerGUI.getIdentification().getSpectrumMatch(spectrumKey);
                        annotationPreferences.setCurrentSettings(
                                spectrumMatch.getBestPeptideAssumption(),
                                !currentSpectrumKey.equalsIgnoreCase(spectrumKey), peptideShakerGUI.getSequenceMatchingPreferences());
                        ArrayList<IonMatch> annotations = miniAnnotator.getSpectrumAnnotation(annotationPreferences.getIonTypes(),
                                annotationPreferences.getNeutralLosses(),
                                annotationPreferences.getValidatedCharges(),
                                spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().value,
                                currentSpectrum,
                                selectedPeptideMatch.getTheoreticPeptide(),
                                currentSpectrum.getIntensityLimit(annotationPreferences.getAnnotationIntensityLimit()),
                                annotationPreferences.getFragmentIonAccuracy(), false,
                                annotationPreferences.isHighResolutionAnnotation());
                        allAnnotations.add(annotations);
                        allSpectra.add(currentSpectrum);
View Full Code Here

            String spectrumKey = psmKeys.get(psmIndex);

            if (displaySpectrum) {

                try {
                    MSnSpectrum currentSpectrum = peptideShakerGUI.getSpectrum(spectrumKey);

                    if (currentSpectrum != null) {

                        Collection<Peak> peaks = currentSpectrum.getPeakList();

                        if (peaks == null || peaks.isEmpty()) {
                            // do nothing, peaks list not found
                        } else {

                            boolean newMax = false;

                            if (resetMzRange) {
                                lastMzMaximum = 0;
                            }

                            if (peptideShakerGUI.getSelectedPeptideKey() != null) {
                                try {
                                    MSnSpectrum tempSpectrum = peptideShakerGUI.getSpectrum(spectrumKey);
                                    if (tempSpectrum.getPeakList() != null) {
                                        double newMaximum = tempSpectrum.getMaxMz();
                                        if (lastMzMaximum < newMaximum) {
                                            lastMzMaximum = tempSpectrum.getMaxMz();
                                            newMax = true;
                                        }
                                    }
                                } catch (Exception e) {
                                    peptideShakerGUI.catchException(e);
View Full Code Here

TOP

Related Classes of com.compomics.util.experiment.massspectrometry.MSnSpectrum

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.