Search in sources :

Example 1 with PeptideMatch

use of com.compomics.util.experiment.identification.matches.PeptideMatch in project peptide-shaker by compomics.

the class ProteinStructurePanel method peptideTableMouseMoved.

// GEN-LAST:event_peptideTableMouseExited
/**
 * Changes the cursor into a hand cursor if the table cell contains an HTML
 * link. Or shows a tooltip with modification details is over the sequence
 * column.
 *
 * @param evt
 */
private void peptideTableMouseMoved(java.awt.event.MouseEvent evt) {
    // GEN-FIRST:event_peptideTableMouseMoved
    int row = peptideTable.rowAtPoint(evt.getPoint());
    int column = peptideTable.columnAtPoint(evt.getPoint());
    if (peptideTable.getValueAt(row, column) != null) {
        if (column == peptideTable.getColumn("PI").getModelIndex()) {
            this.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
            peptideTable.setToolTipText(null);
        } else if (column == peptideTable.getColumn("Sequence").getModelIndex()) {
            this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
            // check if we ought to show a tooltip with mod details
            String sequence = (String) peptideTable.getValueAt(row, column);
            if (sequence.contains("<span")) {
                long peptideKey = peptideTableMap.get(getPeptideIndex(row));
                PeptideMatch peptideMatch = peptideShakerGUI.getIdentification().getPeptideMatch(peptideKey);
                String tooltip = peptideShakerGUI.getDisplayFeaturesGenerator().getPeptideModificationTooltipAsHtml(peptideMatch);
                peptideTable.setToolTipText(tooltip);
            } else {
                peptideTable.setToolTipText(null);
            }
        } else {
            this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
            peptideTable.setToolTipText(null);
        }
    } else {
        this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        peptideTable.setToolTipText(null);
    }
}
Also used : PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) XYDataPoint(no.uib.jsparklines.data.XYDataPoint)

Example 2 with PeptideMatch

use of com.compomics.util.experiment.identification.matches.PeptideMatch in project peptide-shaker by compomics.

the class ProteinStructurePanel method peptideTableMouseReleased.

// GEN-LAST:event_proteinTableMouseReleased
/**
 * Updates the PDB structure.
 *
 * @param evt
 */
private void peptideTableMouseReleased(java.awt.event.MouseEvent evt) {
    // GEN-FIRST:event_peptideTableMouseReleased
    setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
    if (evt != null) {
        peptideShakerGUI.setSelectedItems(peptideShakerGUI.getSelectedProteinKey(), NO_KEY, null, null);
    }
    int row = peptideTable.getSelectedRow();
    int column = peptideTable.getSelectedColumn();
    if (row != -1) {
        if (pdbMatchesJTable.getSelectedRow() != -1) {
            updatePeptideToPdbMapping();
        }
        // remember the selection
        newItemSelection();
        if (column == peptideTable.getColumn("  ").getModelIndex()) {
            long peptideKey = peptideTableMap.get(getPeptideIndex(row));
            PeptideMatch peptideMatch = peptideShakerGUI.getIdentification().getPeptideMatch(peptideKey);
            PSParameter psParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
            if (!psParameter.getStarred()) {
                peptideShakerGUI.getStarHider().starPeptide(peptideKey);
            } else {
                peptideShakerGUI.getStarHider().unStarPeptide(peptideKey);
            }
            peptideShakerGUI.setDataSaved(false);
        }
        // open the protein inference at the petide level dialog
        if (column == peptideTable.getColumn("PI").getModelIndex() && evt != null && evt.getButton() == MouseEvent.BUTTON1) {
            SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) proteinTable.getModel();
            int proteinIndex = tableModel.getViewIndex(proteinTable.getSelectedRow());
            long proteinKey = proteinKeys[proteinIndex];
            long peptideKey = peptideTableMap.get(getPeptideIndex(row));
            new ProteinInferencePeptideLevelDialog(peptideShakerGUI, true, peptideKey, proteinKey, peptideShakerGUI.getGeneMaps());
        }
    }
    setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
}
Also used : PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel) ProteinInferencePeptideLevelDialog(eu.isas.peptideshaker.gui.protein_inference.ProteinInferencePeptideLevelDialog) XYDataPoint(no.uib.jsparklines.data.XYDataPoint) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter)

Example 3 with PeptideMatch

use of com.compomics.util.experiment.identification.matches.PeptideMatch in project peptide-shaker by compomics.

the class ModificationLocalizationScorer method scorePTMs.

/**
 * Scores PTMs in a protein match.
 *
 * @param identification The identification object containing the matches.
 * @param proteinMatch The protein match.
 * @param identificationParameters The identification parameters.
 * @param scorePeptides If true, peptides will be scored as well.
 * @param modificationProvider The modification provider to use.
 * @param waitingHandler The waiting handler to sue, ignored if null.
 */
public void scorePTMs(Identification identification, ProteinMatch proteinMatch, IdentificationParameters identificationParameters, boolean scorePeptides, ModificationProvider modificationProvider, WaitingHandler waitingHandler) {
    HashMap<Integer, ArrayList<String>> confidentSites = new HashMap<>();
    HashMap<Integer, HashMap<Integer, HashSet<String>>> ambiguousSites = new HashMap<>();
    for (long peptideKey : proteinMatch.getPeptideMatchesKeys()) {
        PeptideMatch peptideMatch = identification.getPeptideMatch(peptideKey);
        Peptide peptide = peptideMatch.getPeptide();
        PSParameter psParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
        if (psParameter.getMatchValidationLevel().isValidated() && peptide.getNVariableModifications() > 0) {
            PSModificationScores peptideScores = (PSModificationScores) peptideMatch.getUrParam(PSModificationScores.dummy);
            if (peptideScores == null || scorePeptides) {
                scorePTMs(identification, peptideMatch, identificationParameters, modificationProvider, waitingHandler);
                peptideScores = (PSModificationScores) peptideMatch.getUrParam(PSModificationScores.dummy);
            }
            if (peptideScores != null) {
                int[] peptideStart = peptide.getProteinMapping().get(proteinMatch.getLeadingAccession());
                for (int confidentSite : peptideScores.getConfidentSites()) {
                    for (int peptideTempStart : peptideStart) {
                        int siteOnProtein = peptideTempStart + confidentSite - 1;
                        ArrayList<String> modificationsAtSite = confidentSites.get(siteOnProtein);
                        if (modificationsAtSite == null) {
                            modificationsAtSite = new ArrayList<>();
                            confidentSites.put(siteOnProtein, modificationsAtSite);
                        }
                        for (String modName : peptideScores.getConfidentModificationsAt(confidentSite)) {
                            if (!modificationsAtSite.contains(modName)) {
                                modificationsAtSite.add(modName);
                            }
                        }
                    }
                }
                for (int representativeSite : peptideScores.getRepresentativeSites()) {
                    HashMap<Integer, HashSet<String>> peptideAmbiguousSites = peptideScores.getAmbiguousModificationsAtRepresentativeSite(representativeSite);
                    for (int peptideTempStart : peptideStart) {
                        int proteinRepresentativeSite = peptideTempStart + representativeSite - 1;
                        HashMap<Integer, HashSet<String>> proteinAmbiguousSites = ambiguousSites.get(proteinRepresentativeSite);
                        if (proteinAmbiguousSites == null) {
                            proteinAmbiguousSites = new HashMap<>(peptideAmbiguousSites.size());
                            ambiguousSites.put(proteinRepresentativeSite, proteinAmbiguousSites);
                        }
                        for (int peptideSite : peptideAmbiguousSites.keySet()) {
                            int siteOnProtein = peptideTempStart + peptideSite - 1;
                            proteinAmbiguousSites.put(siteOnProtein, peptideAmbiguousSites.get(peptideSite));
                        }
                    }
                }
            }
        }
    }
    // remove ambiguous sites where a confident was found and merge overlapping groups
    PSModificationScores proteinScores = new PSModificationScores();
    ArrayList<Integer> representativeSites = new ArrayList<>(ambiguousSites.keySet());
    Collections.sort(representativeSites);
    for (Integer representativeSite : representativeSites) {
        HashMap<Integer, HashSet<String>> secondarySitesMap = ambiguousSites.get(representativeSite);
        ArrayList<Integer> secondarySites = new ArrayList<>(secondarySitesMap.keySet());
        for (int secondarySite : secondarySites) {
            ArrayList<String> confidentModifications = confidentSites.get(secondarySite);
            if (confidentModifications != null) {
                boolean sameModification = confidentModifications.stream().map(modName -> modificationProvider.getModification(modName)).anyMatch(confidentModification -> secondarySitesMap.get(secondarySite).stream().map(modName -> modificationProvider.getModification(modName)).anyMatch(secondaryModification -> secondaryModification.getMass() == confidentModification.getMass()));
                if (sameModification) {
                    ambiguousSites.remove(representativeSite);
                    break;
                }
            }
            if (secondarySite != representativeSite) {
                ArrayList<Integer> tempRepresentativeSites = new ArrayList<>(ambiguousSites.keySet());
                Collections.sort(tempRepresentativeSites);
                for (Integer previousSite : tempRepresentativeSites) {
                    if (previousSite >= representativeSite) {
                        break;
                    }
                    if (previousSite == secondarySite) {
                        HashMap<Integer, HashSet<String>> previousSites = ambiguousSites.get(previousSite);
                        HashSet<String> previousModifications = previousSites.get(previousSite);
                        boolean sameModification = previousModifications.stream().map(modName -> modificationProvider.getModification(modName)).anyMatch(previousModification -> secondarySitesMap.get(secondarySite).stream().map(modName -> modificationProvider.getModification(modName)).anyMatch(secondaryModification -> secondaryModification.getMass() == previousModification.getMass()));
                        if (sameModification) {
                            for (int tempSecondarySite : secondarySitesMap.keySet()) {
                                if (!previousSites.containsKey(secondarySite)) {
                                    previousSites.put(tempSecondarySite, secondarySitesMap.get(tempSecondarySite));
                                }
                            }
                            ambiguousSites.remove(representativeSite);
                        }
                    }
                }
            }
        }
    }
    for (int confidentSite : confidentSites.keySet()) {
        for (String modName : confidentSites.get(confidentSite)) {
            proteinScores.addConfidentModificationSite(modName, confidentSite);
        }
    }
    for (int representativeSite : ambiguousSites.keySet()) {
        proteinScores.addAmbiguousModificationSites(representativeSite, ambiguousSites.get(representativeSite));
    }
    proteinMatch.addUrParam(proteinScores);
}
Also used : ModificationMatch(com.compomics.util.experiment.identification.matches.ModificationMatch) ModificationFactory(com.compomics.util.experiment.biology.modifications.ModificationFactory) Arrays(java.util.Arrays) ModificationType(com.compomics.util.experiment.biology.modifications.ModificationType) HashMap(java.util.HashMap) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) ModificationScoring(com.compomics.util.experiment.identification.peptide_shaker.ModificationScoring) TreeSet(java.util.TreeSet) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Modification(com.compomics.util.experiment.biology.modifications.Modification) WaitingHandler(com.compomics.util.waiting.WaitingHandler) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) ModificationUtils(com.compomics.util.experiment.identification.utils.ModificationUtils) SpecificAnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.SpecificAnnotationParameters) SpectrumProvider(com.compomics.util.experiment.mass_spectrometry.SpectrumProvider) PhosphoRS(com.compomics.util.experiment.identification.modification.scores.PhosphoRS) ModificationProvider(com.compomics.util.experiment.biology.modifications.ModificationProvider) Spectrum(com.compomics.util.experiment.mass_spectrometry.spectra.Spectrum) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) PSModificationScores(com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) ExperimentObject(com.compomics.util.experiment.personalization.ExperimentObject) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) Set(java.util.Set) Identification(com.compomics.util.experiment.identification.Identification) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) ModificationLocalizationScore(com.compomics.util.experiment.identification.modification.ModificationLocalizationScore) Collectors(java.util.stream.Collectors) AnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) PeptideSpectrumAnnotator(com.compomics.util.experiment.identification.spectrum_annotation.spectrum_annotators.PeptideSpectrumAnnotator) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) List(java.util.List) Stream(java.util.stream.Stream) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) TreeMap(java.util.TreeMap) Entry(java.util.Map.Entry) Collections(java.util.Collections) ModificationLocalizationParameters(com.compomics.util.parameters.identification.advanced.ModificationLocalizationParameters) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PSModificationScores(com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) HashSet(java.util.HashSet)

Example 4 with PeptideMatch

use of com.compomics.util.experiment.identification.matches.PeptideMatch in project peptide-shaker by compomics.

the class QCPanel method getPeptideDataset.

/**
 * Returns the dataset to use for the peptide QC plot.
 */
private void getPeptideDataset() {
    maxValue = Double.MIN_VALUE;
    SequenceProvider sequenceProvider = peptideShakerGUI.getSequenceProvider();
    if (peptideValidatedPsmsJRadioButton.isSelected()) {
        progressDialog.setPrimaryProgressCounterIndeterminate(false);
        progressDialog.setMaxPrimaryProgressCounter(peptideShakerGUI.getIdentification().getPeptideIdentification().size());
        progressDialog.setValue(0);
        // values for the number of validated PSMs
        validatedValues = new ArrayList<>();
        validatedDoubtfulValues = new ArrayList<>();
        nonValidatedValues = new ArrayList<>();
        validatedDecoyValues = new ArrayList<>();
        nonValidatedDecoyValues = new ArrayList<>();
        PeptideMatchesIterator peptideMatchesIterator = peptideShakerGUI.getIdentification().getPeptideMatchesIterator(progressDialog);
        PeptideMatch peptideMatch;
        while ((peptideMatch = peptideMatchesIterator.next()) != null) {
            if (progressDialog.isRunCanceled()) {
                break;
            }
            double value = 0;
            for (long spectrumMatchKey : peptideMatch.getSpectrumMatchesKeys()) {
                if (progressDialog.isRunCanceled()) {
                    break;
                }
                SpectrumMatch spectrumMatch = peptideShakerGUI.getIdentification().getSpectrumMatch(spectrumMatchKey);
                PSParameter spectrumParameter = (PSParameter) spectrumMatch.getUrParam(PSParameter.dummy);
                if (spectrumParameter.getMatchValidationLevel().isValidated() && !spectrumParameter.getHidden()) {
                    value = value + 1;
                }
            }
            if (value > maxValue) {
                maxValue = value;
            }
            PSParameter peptideParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
            if (!peptideParameter.getHidden()) {
                if (!PeptideUtils.isDecoy(peptideMatch.getPeptide(), sequenceProvider)) {
                    if (peptideParameter.getMatchValidationLevel().isValidated()) {
                        if (peptideParameter.getMatchValidationLevel() == MatchValidationLevel.confident) {
                            validatedValues.add(value);
                        } else {
                            validatedDoubtfulValues.add(value);
                        }
                    } else {
                        nonValidatedValues.add(value);
                    }
                } else if (peptideParameter.getMatchValidationLevel().isValidated()) {
                    validatedDecoyValues.add(value);
                } else {
                    nonValidatedDecoyValues.add(value);
                }
            }
            progressDialog.increasePrimaryProgressCounter();
        }
    } else if (peptideMissedCleavagesJRadioButton.isSelected()) {
        progressDialog.setPrimaryProgressCounterIndeterminate(false);
        progressDialog.setMaxPrimaryProgressCounter(peptideShakerGUI.getIdentification().getPeptideIdentification().size());
        progressDialog.setValue(0);
        // Values for the missed cleavages
        validatedValues = new ArrayList<>();
        validatedDoubtfulValues = new ArrayList<>();
        nonValidatedValues = new ArrayList<>();
        validatedDecoyValues = new ArrayList<>();
        nonValidatedDecoyValues = new ArrayList<>();
        PeptideMatchesIterator peptideMatchesIterator = peptideShakerGUI.getIdentification().getPeptideMatchesIterator(progressDialog);
        PeptideMatch peptideMatch;
        while ((peptideMatch = peptideMatchesIterator.next()) != null) {
            if (progressDialog.isRunCanceled()) {
                break;
            }
            PSParameter peptideParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
            if (!peptideParameter.getHidden()) {
                Double value = null;
                DigestionParameters digestionParameters = peptideShakerGUI.getIdentificationParameters().getSearchParameters().getDigestionParameters();
                if (digestionParameters.getCleavageParameter() == DigestionParameters.CleavageParameter.enzyme) {
                    for (Enzyme enzyme : digestionParameters.getEnzymes()) {
                        int enzymeMissedCelavages = enzyme.getNmissedCleavages(peptideMatch.getPeptide().getSequence());
                        if (value == null || enzymeMissedCelavages < value) {
                            value = Double.valueOf(enzymeMissedCelavages);
                        }
                    }
                }
                if (value == null) {
                    value = 0.0;
                }
                if (value > 0) {
                    if (value > maxValue) {
                        maxValue = value;
                    }
                }
                if (!PeptideUtils.isDecoy(peptideMatch.getPeptide(), sequenceProvider)) {
                    if (peptideParameter.getMatchValidationLevel().isValidated()) {
                        if (peptideParameter.getMatchValidationLevel() == MatchValidationLevel.confident) {
                            validatedValues.add(value);
                        } else {
                            validatedDoubtfulValues.add(value);
                        }
                    } else {
                        nonValidatedValues.add(value);
                    }
                } else if (peptideParameter.getMatchValidationLevel().isValidated()) {
                    validatedDecoyValues.add(value);
                } else {
                    nonValidatedDecoyValues.add(value);
                }
            }
            progressDialog.increasePrimaryProgressCounter();
        }
    } else if (peptideLengthJRadioButton.isSelected()) {
        progressDialog.setPrimaryProgressCounterIndeterminate(false);
        progressDialog.setMaxPrimaryProgressCounter(peptideShakerGUI.getIdentification().getPeptideIdentification().size());
        progressDialog.setValue(0);
        // values for the peptide length
        validatedValues = new ArrayList<>();
        validatedDoubtfulValues = new ArrayList<>();
        nonValidatedValues = new ArrayList<>();
        validatedDecoyValues = new ArrayList<>();
        nonValidatedDecoyValues = new ArrayList<>();
        PeptideMatchesIterator peptideMatchesIterator = peptideShakerGUI.getIdentification().getPeptideMatchesIterator(progressDialog);
        PeptideMatch peptideMatch;
        while ((peptideMatch = peptideMatchesIterator.next()) != null) {
            if (progressDialog.isRunCanceled()) {
                break;
            }
            PSParameter peptideParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
            if (!peptideParameter.getHidden()) {
                double length = peptideMatch.getPeptide().getSequence().length();
                if (length > 0) {
                    if (length > maxValue) {
                        maxValue = length;
                    }
                }
                if (!PeptideUtils.isDecoy(peptideMatch.getPeptide(), sequenceProvider)) {
                    if (peptideParameter.getMatchValidationLevel().isValidated()) {
                        if (peptideParameter.getMatchValidationLevel() == MatchValidationLevel.confident) {
                            validatedValues.add(length);
                        } else {
                            validatedDoubtfulValues.add(length);
                        }
                    } else {
                        nonValidatedValues.add(length);
                    }
                } else if (peptideParameter.getMatchValidationLevel().isValidated()) {
                    validatedDecoyValues.add(length);
                } else {
                    nonValidatedDecoyValues.add(length);
                }
            }
            progressDialog.increasePrimaryProgressCounter();
        }
    }
}
Also used : SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) DigestionParameters(com.compomics.util.parameters.identification.search.DigestionParameters) PeptideMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.PeptideMatchesIterator) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) Enzyme(com.compomics.util.experiment.biology.enzymes.Enzyme) ArrayList(java.util.ArrayList) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter)

Example 5 with PeptideMatch

use of com.compomics.util.experiment.identification.matches.PeptideMatch in project peptide-shaker by compomics.

the class QCPanel method getPeptideModificationEnrichmentSpecificityDataset.

/**
 * Returns the dataset for the peptide modification rate QC plot.
 *
 * @return the dataset for the peptide modification rate QC plot
 */
private DefaultCategoryDataset getPeptideModificationEnrichmentSpecificityDataset() {
    ModificationFactory modificationFactory = ModificationFactory.getInstance();
    Identification identification = peptideShakerGUI.getIdentification();
    SequenceProvider sequenceProvider = peptideShakerGUI.getSequenceProvider();
    IdentificationParameters identificationParameters = peptideShakerGUI.getIdentificationParameters();
    ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
    SequenceMatchingParameters modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
    ArrayList<String> modNames = modificationParameters.getAllNotFixedModifications();
    HashMap<String, Integer> modifiedPeptidesMap = new HashMap<>(modNames.size());
    HashMap<String, Integer> possiblyModifiedPeptidesMap = new HashMap<>(modNames.size());
    progressDialog.setPrimaryProgressCounterIndeterminate(false);
    progressDialog.setMaxPrimaryProgressCounter(identification.getPeptideIdentification().size());
    progressDialog.setValue(0);
    PeptideMatchesIterator peptideMatchesIterator = identification.getPeptideMatchesIterator(progressDialog);
    PeptideMatch peptideMatch;
    while ((peptideMatch = peptideMatchesIterator.next()) != null) {
        PSParameter psParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
        if (psParameter.getMatchValidationLevel().isValidated()) {
            Peptide peptide = peptideMatch.getPeptide();
            for (String modName : modificationParameters.getAllNotFixedModifications()) {
                Modification modification = modificationFactory.getModification(modName);
                int[] possibleSites = ModificationUtils.getPossibleModificationSites(peptide, modification, sequenceProvider, modificationSequenceMatchingParameters);
                if (possibleSites.length != 0) {
                    Integer nPossiblePeptides = possiblyModifiedPeptidesMap.get(modName);
                    if (nPossiblePeptides == null) {
                        possiblyModifiedPeptidesMap.put(modName, 1);
                    } else {
                        possiblyModifiedPeptidesMap.put(modName, nPossiblePeptides + 1);
                    }
                    boolean modified = false;
                    for (ModificationMatch modificationMatch : peptide.getVariableModifications()) {
                        if (modificationMatch.getModification().equals(modName)) {
                            modified = true;
                            break;
                        }
                    }
                    if (modified) {
                        Integer nModifiedPeptides = modifiedPeptidesMap.get(modName);
                        if (nModifiedPeptides == null) {
                            modifiedPeptidesMap.put(modName, 1);
                        } else {
                            modifiedPeptidesMap.put(modName, nModifiedPeptides + 1);
                        }
                    }
                }
            }
        }
        if (progressDialog.isRunCanceled()) {
            break;
        }
        progressDialog.increaseSecondaryProgressCounter();
    }
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (String modName : modificationParameters.getAllNotFixedModifications()) {
        Integer nFound = modifiedPeptidesMap.get(modName);
        if (nFound == null) {
            nFound = 0;
        }
        Integer nPossible = possiblyModifiedPeptidesMap.get(modName);
        Double rate = 0.0;
        if (nPossible != null) {
            rate = (100.0 * nFound) / nPossible;
        }
        dataset.addValue(rate, "Modified", modName);
        double rest = 0.0;
        if (nPossible != null) {
            rest = 100 - rate;
        }
        dataset.addValue(rest, "Not Modified", modName);
    }
    return dataset;
}
Also used : Modification(com.compomics.util.experiment.biology.modifications.Modification) ModificationMatch(com.compomics.util.experiment.identification.matches.ModificationMatch) PeptideMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.PeptideMatchesIterator) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) HashMap(java.util.HashMap) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) Identification(com.compomics.util.experiment.identification.Identification) ModificationFactory(com.compomics.util.experiment.biology.modifications.ModificationFactory) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter)

Aggregations

PeptideMatch (com.compomics.util.experiment.identification.matches.PeptideMatch)52 PSParameter (com.compomics.util.experiment.identification.peptide_shaker.PSParameter)39 Peptide (com.compomics.util.experiment.biology.proteins.Peptide)16 ProteinMatch (com.compomics.util.experiment.identification.matches.ProteinMatch)16 SpectrumMatch (com.compomics.util.experiment.identification.matches.SpectrumMatch)16 Identification (com.compomics.util.experiment.identification.Identification)15 ArrayList (java.util.ArrayList)15 PeptideMatchesIterator (com.compomics.util.experiment.identification.matches_iterators.PeptideMatchesIterator)14 SequenceProvider (com.compomics.util.experiment.io.biology.protein.SequenceProvider)12 IdentificationParameters (com.compomics.util.parameters.identification.IdentificationParameters)10 HashMap (java.util.HashMap)10 ModificationMatch (com.compomics.util.experiment.identification.matches.ModificationMatch)9 SequenceMatchingParameters (com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters)9 ModificationParameters (com.compomics.util.parameters.identification.search.ModificationParameters)9 DigestionParameters (com.compomics.util.parameters.identification.search.DigestionParameters)8 Arrays (java.util.Arrays)8 HashSet (java.util.HashSet)8 Collectors (java.util.stream.Collectors)8 TreeMap (java.util.TreeMap)7 TreeSet (java.util.TreeSet)7