Search in sources :

Example 1 with PSModificationScores

use of com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores in project peptide-shaker by compomics.

the class ModificationLocalizationScorer method attachDeltaScore.

/**
 * Scores the modification locations using the delta score.
 *
 * @param identification Identification object containing the matches.
 * @param spectrumMatch The spectrum match of interest.
 * @param sequenceMatchingParameters The sequence matching preferences.
 * @param modificationProvider The modification provider to use.
 */
public void attachDeltaScore(Identification identification, SpectrumMatch spectrumMatch, SequenceMatchingParameters sequenceMatchingParameters, ModificationProvider modificationProvider) {
    PSModificationScores modificationScores = (PSModificationScores) spectrumMatch.getUrParam(PSModificationScores.dummy);
    if (modificationScores == null) {
        modificationScores = new PSModificationScores();
        spectrumMatch.addUrParam(modificationScores);
    }
    Peptide psPeptide = spectrumMatch.getBestPeptideAssumption().getPeptide();
    HashMap<Integer, TreeMap<Double, ArrayList<PeptideAssumption>>> assumptions = spectrumMatch.getPeptideAssumptionsMap();
    String mainSequence = psPeptide.getSequence();
    HashMap<String, List<Integer>> modificationParameters = Arrays.stream(psPeptide.getVariableModifications()).collect(Collectors.groupingBy(ModificationMatch::getModification, HashMap::new, Collectors.mapping(ModificationMatch::getSite, Collectors.toList())));
    for (Entry<String, List<Integer>> entry : modificationParameters.entrySet()) {
        String modName = entry.getKey();
        List<Integer> sites = entry.getValue();
        Modification modification1 = modificationProvider.getModification(modName);
        for (int modSite : sites) {
            double refP = 1, secondaryP = 1;
            for (TreeMap<Double, ArrayList<PeptideAssumption>> algorithmAssumptions : assumptions.values()) {
                for (ArrayList<PeptideAssumption> assumptionsAtScore : algorithmAssumptions.values()) {
                    for (PeptideAssumption peptideAssumption : assumptionsAtScore) {
                        if (peptideAssumption.getPeptide().getSequence().equals(mainSequence)) {
                            boolean modificationAtSite = false, modificationFound = false;
                            Peptide peptide = peptideAssumption.getPeptide();
                            for (ModificationMatch modMatch : peptide.getVariableModifications()) {
                                Modification modification2 = modificationProvider.getModification(modMatch.getModification());
                                if (modification1.getMass() == modification2.getMass()) {
                                    modificationFound = true;
                                    PSParameter psParameter = (PSParameter) peptideAssumption.getUrParam(PSParameter.dummy);
                                    double p = psParameter.getProbability();
                                    if (modMatch.getSite() == modSite) {
                                        modificationAtSite = true;
                                        if (p < refP) {
                                            refP = p;
                                        }
                                    }
                                }
                            }
                            if (!modificationAtSite && modificationFound) {
                                PSParameter psParameter = (PSParameter) peptideAssumption.getUrParam(PSParameter.dummy);
                                double p = psParameter.getProbability();
                                if (p < secondaryP) {
                                    secondaryP = p;
                                }
                            }
                        }
                    }
                }
            }
            ModificationScoring modificationScoring = modificationScores.getModificationScoring(modName);
            if (modificationScoring == null) {
                modificationScoring = new ModificationScoring(modName);
                modificationScores.addModificationScoring(modName, modificationScoring);
            }
            if (secondaryP < refP) {
                secondaryP = refP;
            }
            double deltaScore = (secondaryP - refP) * 100;
            modificationScoring.setDeltaScore(modSite, deltaScore);
        }
        identification.updateObject(spectrumMatch.getKey(), spectrumMatch);
    }
}
Also used : Modification(com.compomics.util.experiment.biology.modifications.Modification) ModificationMatch(com.compomics.util.experiment.identification.matches.ModificationMatch) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) ModificationScoring(com.compomics.util.experiment.identification.peptide_shaker.ModificationScoring) ArrayList(java.util.ArrayList) List(java.util.List) PSModificationScores(com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter)

Example 2 with PSModificationScores

use of com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores 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 3 with PSModificationScores

use of com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores in project peptide-shaker by compomics.

the class ModificationLocalizationScorer method attachProbabilisticScore.

/**
 * Attaches the selected probabilistic modification score.
 *
 * @param spectrumMatch The spectrum match studied, the score will be
 * calculated for the best assumption only.
 * @param sequenceProvider The protein sequence provider to use.
 * @param spectrumProvider The spectrum provider to use.
 * @param modificationProvider The modification provider to use.
 * @param identificationParameters The identification parameters.
 * @param peptideSpectrumAnnotator The peptide spectrum annotator to use.
 * @param identification The identification object containing the matches.
 */
private void attachProbabilisticScore(SpectrumMatch spectrumMatch, SequenceProvider sequenceProvider, SpectrumProvider spectrumProvider, ModificationProvider modificationProvider, IdentificationParameters identificationParameters, PeptideSpectrumAnnotator peptideSpectrumAnnotator, Identification identification) {
    SearchParameters searchParameters = identificationParameters.getSearchParameters();
    AnnotationParameters annotationParameters = identificationParameters.getAnnotationParameters();
    ModificationLocalizationParameters scoringParameters = identificationParameters.getModificationLocalizationParameters();
    SequenceMatchingParameters sequenceMatchingParameters = identificationParameters.getSequenceMatchingParameters();
    SequenceMatchingParameters modificationSequenceMatchingParameters = scoringParameters.getSequenceMatchingParameters();
    ModificationParameters modificationParameters = searchParameters.getModificationParameters();
    PSModificationScores modificationScores = (PSModificationScores) spectrumMatch.getUrParam(PSModificationScores.dummy);
    if (modificationScores != null) {
        modificationScores = new PSModificationScores();
        spectrumMatch.addUrParam(modificationScores);
    }
    HashMap<Double, ArrayList<Modification>> modificationsMap = new HashMap<>(1);
    HashMap<Double, Integer> nMod = new HashMap<>(1);
    PeptideAssumption bestPeptideAssumption = spectrumMatch.getBestPeptideAssumption();
    Peptide peptide = bestPeptideAssumption.getPeptide();
    for (ModificationMatch modificationMatch : peptide.getVariableModifications()) {
        Modification refMod = modificationProvider.getModification(modificationMatch.getModification());
        double modMass = refMod.getMass();
        if (!modificationsMap.containsKey(modMass)) {
            ArrayList<Modification> modifications = modificationFactory.getSameMassNotFixedModifications(modMass, searchParameters).stream().map(modification -> modificationProvider.getModification(modification)).collect(Collectors.toCollection(ArrayList::new));
            modificationsMap.put(modMass, modifications);
            nMod.put(modMass, 1);
        } else {
            nMod.put(modMass, nMod.get(modMass) + 1);
        }
    }
    if (!modificationsMap.isEmpty()) {
        String spectrumFile = spectrumMatch.getSpectrumFile();
        String spectrumTitle = spectrumMatch.getSpectrumTitle();
        Spectrum spectrum = spectrumProvider.getSpectrum(spectrumFile, spectrumTitle);
        SpecificAnnotationParameters specificAnnotationParameters = annotationParameters.getSpecificAnnotationParameters(spectrumFile, spectrumTitle, bestPeptideAssumption, modificationParameters, sequenceProvider, modificationSequenceMatchingParameters, peptideSpectrumAnnotator);
        for (double modMass : modificationsMap.keySet()) {
            HashMap<Integer, Double> scores = null;
            if (scoringParameters.getSelectedProbabilisticScore() == ModificationLocalizationScore.PhosphoRS) {
                scores = PhosphoRS.getSequenceProbabilities(peptide, modificationsMap.get(modMass), modificationParameters, spectrum, sequenceProvider, annotationParameters, specificAnnotationParameters, scoringParameters.isProbabilisticScoreNeutralLosses(), sequenceMatchingParameters, modificationSequenceMatchingParameters, peptideSpectrumAnnotator);
                if (scores == null) {
                    throw new IllegalArgumentException("An error occurred while scoring spectrum " + spectrumTitle + " of file " + spectrumFile + " with PhosphoRS.");
                // Most likely a compatibility issue with utilities
                }
            }
            if (scores != null) {
                // remap to searched modifications
                Modification mappedModification = null;
                String peptideSequence = peptide.getSequence();
                for (int site : scores.keySet()) {
                    if (site == 0) {
                        // N-term mod
                        for (Modification modification : modificationsMap.get(modMass)) {
                            if (modification.getModificationType().isNTerm()) {
                                mappedModification = modification;
                                break;
                            }
                        }
                        if (mappedModification == null) {
                            throw new IllegalArgumentException("Could not map the PTM of mass " + modMass + " on the N-terminus of the peptide " + peptideSequence + ".");
                        }
                    } else if (site == peptideSequence.length() + 1) {
                        // C-term mod
                        for (Modification modification : modificationsMap.get(modMass)) {
                            if (modification.getModificationType().isCTerm()) {
                                mappedModification = modification;
                                break;
                            }
                        }
                        if (mappedModification == null) {
                            throw new IllegalArgumentException("Could not map the PTM of mass " + modMass + " on the C-terminus of the peptide " + peptideSequence + ".");
                        }
                    } else {
                        for (Modification modification : modificationsMap.get(modMass)) {
                            mappedModification = modification;
                            break;
                        }
                        if (mappedModification == null) {
                            throw new IllegalArgumentException("Could not map the PTM of mass " + modMass + " at site " + site + " in peptide " + peptide.getSequence() + ".");
                        }
                    }
                    String modName = mappedModification.getName();
                    ModificationScoring modificationScoring = modificationScores.getModificationScoring(modName);
                    if (modificationScoring == null) {
                        modificationScoring = new ModificationScoring(modName);
                        modificationScores.addModificationScoring(modName, modificationScoring);
                    }
                    modificationScoring.setProbabilisticScore(site, scores.get(site));
                }
            }
        }
        identification.updateObject(spectrumMatch.getKey(), spectrumMatch);
    }
}
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) Modification(com.compomics.util.experiment.biology.modifications.Modification) ModificationMatch(com.compomics.util.experiment.identification.matches.ModificationMatch) HashMap(java.util.HashMap) SpecificAnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.SpecificAnnotationParameters) AnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters) ArrayList(java.util.ArrayList) SpecificAnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.SpecificAnnotationParameters) Spectrum(com.compomics.util.experiment.mass_spectrometry.spectra.Spectrum) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) ModificationScoring(com.compomics.util.experiment.identification.peptide_shaker.ModificationScoring) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) ModificationLocalizationParameters(com.compomics.util.parameters.identification.advanced.ModificationLocalizationParameters) PSModificationScores(com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption)

Example 4 with PSModificationScores

use of com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores in project peptide-shaker by compomics.

the class ModificationLocalizationScorer method modificationSiteInference.

/**
 * Infers the modification site of the best peptide assumption of the given
 * spectrum match.
 *
 * @param spectrumMatch The spectrum match.
 * @param sequenceProvider The sequence provider to use.
 * @param modificationProvider The modification provider to use.
 * @param identificationParameters The identification parameters.
 */
public void modificationSiteInference(SpectrumMatch spectrumMatch, SequenceProvider sequenceProvider, ModificationProvider modificationProvider, IdentificationParameters identificationParameters) {
    Peptide peptide = spectrumMatch.getBestPeptideAssumption().getPeptide();
    int nVariableModifications = peptide.getNVariableModifications();
    if (nVariableModifications > 0) {
        SearchParameters searchParameters = identificationParameters.getSearchParameters();
        PSModificationScores modificationScores = (PSModificationScores) spectrumMatch.getUrParam(PSModificationScores.dummy);
        HashMap<Double, ArrayList<ModificationMatch>> modMatchesMap = new HashMap<>(nVariableModifications);
        HashMap<Double, HashMap<Integer, String>> possiblePositions = new HashMap<>(nVariableModifications);
        HashMap<Double, HashMap<Integer, ArrayList<String>>> confidentSites = new HashMap<>(nVariableModifications);
        for (ModificationMatch modificationMatch : peptide.getVariableModifications()) {
            String modName = modificationMatch.getModification();
            Modification modification = modificationProvider.getModification(modName);
            double modMass = modification.getMass();
            ArrayList<ModificationMatch> modOccurence = modMatchesMap.get(modMass);
            if (modOccurence == null) {
                modOccurence = new ArrayList<>(1);
                modMatchesMap.put(modMass, modOccurence);
            }
            HashMap<Integer, String> modPossibleSites = possiblePositions.get(modMass);
            if (modPossibleSites == null) {
                modPossibleSites = new HashMap<>(1);
                possiblePositions.put(modMass, modPossibleSites);
            }
            boolean maybeNotTerminal = modification.getModificationType() == ModificationType.modaa;
            if (!maybeNotTerminal) {
                ArrayList<String> expectedModifications = modificationFactory.getExpectedVariableModifications(searchParameters);
                for (String otherModName : expectedModifications) {
                    if (!otherModName.equals(modName)) {
                        Modification otherModification = modificationProvider.getModification(otherModName);
                        if (otherModification.getMass() == modMass && modification.getModificationType() != otherModification.getModificationType()) {
                            maybeNotTerminal = true;
                            break;
                        }
                    }
                }
            }
            if (maybeNotTerminal) {
                modOccurence.add(modificationMatch);
                for (String similarModName : modificationFactory.getSameMassNotFixedModifications(modMass, searchParameters)) {
                    Modification similarModification = modificationProvider.getModification(similarModName);
                    if (modification.getMass() == modMass) {
                        int[] possibleSites = ModificationUtils.getPossibleModificationSites(peptide, similarModification, sequenceProvider, identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters());
                        for (int pos : possibleSites) {
                            modPossibleSites.put(pos, similarModName);
                        }
                    }
                }
            } else {
                ModificationScoring modificationScoring = modificationScores.getModificationScoring(modName);
                if (modificationScoring == null) {
                    modificationScoring = new ModificationScoring(modName);
                    modificationScores.addModificationScoring(modName, modificationScoring);
                }
                modificationScoring.setSiteConfidence(modificationMatch.getSite(), ModificationScoring.VERY_CONFIDENT);
                modificationMatch.setConfident(true);
                HashMap<Integer, ArrayList<String>> modificationSites = confidentSites.get(modification.getMass());
                if (modificationSites == null) {
                    modificationSites = new HashMap<>(1);
                    confidentSites.put(modMass, modificationSites);
                }
                int site = modificationMatch.getSite();
                ArrayList<String> modNames = modificationSites.get(site);
                if (modNames == null) {
                    modNames = new ArrayList<>(1);
                    modificationSites.put(site, modNames);
                }
                modNames.add(modName);
            }
        }
        ModificationLocalizationParameters modificationScoringParameters = identificationParameters.getModificationLocalizationParameters();
        Set<Double> modMasses = modMatchesMap.keySet();
        // p score -> d-score -> Map mod mass -> site -> list of modifications
        TreeMap<Double, TreeMap<Double, TreeMap<Double, HashMap<Integer, HashSet<String>>>>> ambiguousScoreToSiteMap = new TreeMap<>();
        HashMap<Double, Integer> nRepresentativesMap = new HashMap<>(modMasses.size());
        ArrayList<ModificationMatch> assignedModifications = new ArrayList<>(peptide.getNVariableModifications());
        // p-score -> d-score -> mod mass -> list of posssible sites
        TreeMap<Double, TreeMap<Double, TreeMap<Double, TreeSet<Integer>>>> scoreToSiteMap = new TreeMap<>();
        for (double modMass : modMasses) {
            ArrayList<ModificationMatch> modificationMatches = modMatchesMap.get(modMass);
            int nMods = modificationMatches.size();
            HashMap<Integer, String> modificationPossibleSites = possiblePositions.get(modMass);
            int nPossibleSites = modificationPossibleSites.size();
            HashMap<Integer, ArrayList<String>> modificationConfidentSites = confidentSites.get(modMass);
            if (modificationConfidentSites == null) {
                modificationConfidentSites = new HashMap<>(1);
                confidentSites.put(modMass, modificationConfidentSites);
            }
            if (nPossibleSites < nMods) {
                throw new IllegalArgumentException("The occurence of modification of mass " + modMass + " (" + modificationMatches.size() + ") is higher than the number of possible sites (" + modificationPossibleSites.size() + ") on sequence " + peptide.getSequence() + " in spectrum " + spectrumMatch.getKey() + ".");
            } else if (modificationPossibleSites.size() == modificationMatches.size()) {
                for (ModificationMatch modMatch : modificationMatches) {
                    String modName = modMatch.getModification();
                    int site = modMatch.getSite();
                    ModificationScoring modificationScoring = modificationScores.getModificationScoring(modName);
                    if (modificationScoring == null) {
                        modificationScoring = new ModificationScoring(modName);
                        modificationScores.addModificationScoring(modName, modificationScoring);
                    }
                    modificationScoring.setSiteConfidence(site, ModificationScoring.VERY_CONFIDENT);
                    modMatch.setConfident(true);
                    ArrayList<String> modificationsAtAA = modificationConfidentSites.get(site);
                    if (modificationsAtAA == null) {
                        modificationsAtAA = new ArrayList<>(1);
                        modificationConfidentSites.put(site, modificationsAtAA);
                    }
                    modificationsAtAA.add(modName);
                    assignedModifications.add(modMatch);
                }
            } else if (!modificationScoringParameters.isProbabilisticScoreCalculation()) {
                // no probabilistic score in that case
                double pScore = 0;
                for (ModificationMatch modificationMatch : modificationMatches) {
                    String modName = modificationMatch.getModification();
                    ModificationScoring modificationScoring = modificationScores.getModificationScoring(modName);
                    int site = modificationMatch.getSite();
                    Double dScore = modificationScoring.getDeltaScore(site);
                    if (dScore == 0.0) {
                        modificationScoring.setSiteConfidence(site, ModificationScoring.RANDOM);
                        modificationMatch.setConfident(false);
                    } else if (dScore <= 95) {
                        modificationScoring.setSiteConfidence(site, ModificationScoring.DOUBTFUL);
                        modificationMatch.setConfident(false);
                    } else {
                        modificationScoring.setSiteConfidence(site, ModificationScoring.CONFIDENT);
                        modificationMatch.setConfident(true);
                        ArrayList<String> modificationsAtAA = modificationConfidentSites.get(site);
                        if (modificationsAtAA == null) {
                            modificationsAtAA = new ArrayList<>(1);
                            modificationConfidentSites.put(site, modificationsAtAA);
                        }
                        modificationsAtAA.add(modName);
                    }
                    if (!modificationMatch.getConfident()) {
                        TreeMap<Double, TreeMap<Double, HashMap<Integer, HashSet<String>>>> pScoreAmbiguousMap = ambiguousScoreToSiteMap.get(pScore);
                        if (pScoreAmbiguousMap == null) {
                            pScoreAmbiguousMap = new TreeMap<>();
                            ambiguousScoreToSiteMap.put(pScore, pScoreAmbiguousMap);
                        }
                        TreeMap<Double, HashMap<Integer, HashSet<String>>> dScoreAmbiguousMap = pScoreAmbiguousMap.get(dScore);
                        if (dScoreAmbiguousMap == null) {
                            dScoreAmbiguousMap = new TreeMap<>();
                            pScoreAmbiguousMap.put(dScore, dScoreAmbiguousMap);
                        }
                        HashMap<Integer, HashSet<String>> massAmbiguousMap = dScoreAmbiguousMap.get(modMass);
                        if (massAmbiguousMap == null) {
                            massAmbiguousMap = new HashMap<>(nPossibleSites);
                            dScoreAmbiguousMap.put(modMass, massAmbiguousMap);
                        }
                        HashSet<String> modifications = massAmbiguousMap.get(site);
                        if (modifications == null) {
                            modifications = new HashSet<>(1);
                            massAmbiguousMap.put(site, modifications);
                        }
                        modifications.add(modName);
                    }
                    assignedModifications.add(modificationMatch);
                }
            } else {
                for (int site : modificationPossibleSites.keySet()) {
                    String modName = modificationPossibleSites.get(site);
                    ModificationScoring modificationScoring = modificationScores.getModificationScoring(modName);
                    double pScore = 0;
                    double dScore = 0;
                    if (modificationScoring != null) {
                        pScore = modificationScoring.getProbabilisticScore(site);
                        dScore = modificationScoring.getDeltaScore(site);
                    }
                    TreeMap<Double, TreeMap<Double, TreeSet<Integer>>> pScoreMap = scoreToSiteMap.get(pScore);
                    if (pScoreMap == null) {
                        pScoreMap = new TreeMap<>();
                        scoreToSiteMap.put(pScore, pScoreMap);
                    }
                    TreeMap<Double, TreeSet<Integer>> dScoreMap = pScoreMap.get(dScore);
                    if (dScoreMap == null) {
                        dScoreMap = new TreeMap<>();
                        pScoreMap.put(dScore, dScoreMap);
                    }
                    TreeSet<Integer> dScoreSites = dScoreMap.get(modMass);
                    if (dScoreSites == null) {
                        dScoreSites = new TreeSet<>();
                        dScoreMap.put(modMass, dScoreSites);
                    }
                    dScoreSites.add(site);
                }
            }
        }
        // Assign modifications to the sites passing the threshold.
        if (!scoreToSiteMap.isEmpty()) {
            HashMap<Double, Integer> processedSitesMap = new HashMap<>(modMasses.size());
            for (Entry<Double, TreeMap<Double, TreeMap<Double, TreeSet<Integer>>>> entry1 : scoreToSiteMap.descendingMap().entrySet()) {
                double pScore = entry1.getKey();
                TreeMap<Double, TreeMap<Double, TreeSet<Integer>>> pScoreMap = entry1.getValue();
                for (Entry<Double, TreeMap<Double, TreeSet<Integer>>> entry2 : pScoreMap.descendingMap().entrySet()) {
                    double dScore = entry2.getKey();
                    TreeMap<Double, TreeSet<Integer>> dScoreMap = entry2.getValue();
                    for (Entry<Double, TreeSet<Integer>> entry : dScoreMap.entrySet()) {
                        double modificationMass = entry.getKey();
                        ArrayList<ModificationMatch> modificationMatches = modMatchesMap.get(modificationMass);
                        HashMap<Integer, String> modificationPossibleSites = possiblePositions.get(modificationMass);
                        HashMap<Integer, ArrayList<String>> modificationConfidentSites = confidentSites.get(modificationMass);
                        int nMods = modificationMatches.size();
                        int nPossibleSites = modificationPossibleSites.size();
                        double randomScoreThreshold = modificationScoringParameters.getSelectedProbabilisticScore().getRandomThreshold(nMods, nPossibleSites);
                        double confidenceThreshold = modificationScoringParameters.getProbabilisticScoreThreshold();
                        TreeSet<Integer> sites = dScoreMap.get(modificationMass);
                        Integer nAssignedSites = processedSitesMap.get(modificationMass);
                        if (nAssignedSites == null) {
                            nAssignedSites = 0;
                        }
                        for (int site : sites) {
                            String modName = modificationPossibleSites.get(site);
                            ModificationScoring modificationScoring = modificationScores.getModificationScoring(modName);
                            if (modificationScoring == null) {
                                modificationScoring = new ModificationScoring(modName);
                                modificationScores.addModificationScoring(modName, modificationScoring);
                            }
                            ModificationMatch modificationMatch = null;
                            if (nAssignedSites < nMods) {
                                boolean alreadyOccupied = false;
                                for (ModificationMatch assignedMatch : assignedModifications) {
                                    if (assignedMatch.getSite() == site) {
                                        alreadyOccupied = true;
                                        break;
                                    }
                                }
                                if (!alreadyOccupied) {
                                    if (pScore >= confidenceThreshold) {
                                        modificationMatch = modificationMatches.get(nAssignedSites);
                                        modificationMatch.setSite(site);
                                        modificationMatch.setModification(modName);
                                        assignedModifications.add(modificationMatch);
                                        modificationScoring.setSiteConfidence(site, ModificationScoring.VERY_CONFIDENT);
                                        modificationMatch.setConfident(true);
                                        ArrayList<String> modificationsAtAA = modificationConfidentSites.get(site);
                                        if (modificationsAtAA == null) {
                                            modificationsAtAA = new ArrayList<>(1);
                                            modificationConfidentSites.put(site, modificationsAtAA);
                                        }
                                        modificationsAtAA.add(modName);
                                        nAssignedSites++;
                                        processedSitesMap.put(modificationMass, nAssignedSites);
                                    } else if (pScore > randomScoreThreshold) {
                                        modificationScoring.setSiteConfidence(site, ModificationScoring.DOUBTFUL);
                                    } else {
                                        modificationScoring.setSiteConfidence(site, ModificationScoring.RANDOM);
                                    }
                                }
                            }
                            if (modificationMatch == null) {
                                TreeMap<Double, TreeMap<Double, HashMap<Integer, HashSet<String>>>> pScoreAmbiguousMap = ambiguousScoreToSiteMap.get(pScore);
                                if (pScoreAmbiguousMap == null) {
                                    pScoreAmbiguousMap = new TreeMap<>();
                                    ambiguousScoreToSiteMap.put(pScore, pScoreAmbiguousMap);
                                }
                                TreeMap<Double, HashMap<Integer, HashSet<String>>> dScoreAmbiguousMap = pScoreAmbiguousMap.get(dScore);
                                if (dScoreAmbiguousMap == null) {
                                    dScoreAmbiguousMap = new TreeMap<>();
                                    pScoreAmbiguousMap.put(dScore, dScoreAmbiguousMap);
                                }
                                HashMap<Integer, HashSet<String>> massAmbiguousMap = dScoreAmbiguousMap.get(modificationMass);
                                if (massAmbiguousMap == null) {
                                    massAmbiguousMap = new HashMap<>(nPossibleSites);
                                    dScoreAmbiguousMap.put(modificationMass, massAmbiguousMap);
                                }
                                HashSet<String> modifications = massAmbiguousMap.get(site);
                                if (modifications == null) {
                                    modifications = new HashSet<>(1);
                                    massAmbiguousMap.put(site, modifications);
                                }
                                modifications.add(modName);
                            }
                        }
                    }
                }
            }
        }
        // See whether there are sites that are not confidently assigned.
        for (double modMass : confidentSites.keySet()) {
            HashMap<Integer, ArrayList<String>> modConfidentSitesMap = confidentSites.get(modMass);
            ArrayList<Integer> modConfidentSites = new ArrayList<>(modConfidentSitesMap.keySet());
            int nConfident = 0;
            for (int site : modConfidentSites) {
                ArrayList<String> modifications = modConfidentSitesMap.get(site);
                for (String modName : modifications) {
                    modificationScores.addConfidentModificationSite(modName, site);
                }
                nConfident += modifications.size();
            }
            modConfidentSites.size();
            ArrayList<ModificationMatch> modificationMatches = modMatchesMap.get(modMass);
            int nMods = modificationMatches.size();
            if (nConfident < nMods) {
                int nRepresentatives = nMods - nConfident;
                if (nRepresentatives > 0) {
                    nRepresentativesMap.put(modMass, nRepresentatives);
                }
            }
        }
        // Create ambiguous site groups and assign the remaining modifications to the best scoring sites.
        if (!nRepresentativesMap.isEmpty()) {
            HashMap<Double, HashMap<Integer, HashMap<Integer, HashSet<String>>>> representativeToSecondaryMap = getRepresentativeToSecondaryMap(ambiguousScoreToSiteMap, nRepresentativesMap);
            for (Entry<Double, HashMap<Integer, HashMap<Integer, HashSet<String>>>> entry1 : representativeToSecondaryMap.entrySet()) {
                double modMass = entry1.getKey();
                HashMap<Integer, HashMap<Integer, HashSet<String>>> massMap = entry1.getValue();
                ArrayList<ModificationMatch> modificationMatches = modMatchesMap.get(modMass);
                int nMods = modificationMatches.size();
                int nRepresentativeSites = nRepresentativesMap.get(modMass);
                if (nRepresentativeSites != massMap.size()) {
                    throw new IllegalArgumentException("Unexpected number of representative sites.");
                }
                int nConfident = nMods - nRepresentativeSites;
                int modMatchIndex = nConfident;
                for (Entry<Integer, HashMap<Integer, HashSet<String>>> entry : massMap.entrySet()) {
                    int representativeSite = entry.getKey();
                    HashMap<Integer, HashSet<String>> sites = entry.getValue();
                    modificationScores.addAmbiguousModificationSites(representativeSite, sites);
                    ModificationMatch modificationMatch = modificationMatches.get(modMatchIndex);
                    String modName = null;
                    for (String possibleModName : sites.get(representativeSite)) {
                        Modification possibleModification = modificationProvider.getModification(possibleModName);
                        if (possibleModification.getMass() == modMass) {
                            modName = possibleModName;
                            break;
                        }
                    }
                    if (modName == null) {
                        throw new IllegalArgumentException("No candidate modification of mass " + modMass + " found at site " + representativeSite + " on peptide " + peptide.getSequence() + ".");
                    }
                    modificationMatch.setModification(modName);
                    modificationMatch.setSite(representativeSite);
                    modificationMatch.setConfident(false);
                    modMatchIndex++;
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TreeSet(java.util.TreeSet) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) HashSet(java.util.HashSet) ModificationLocalizationParameters(com.compomics.util.parameters.identification.advanced.ModificationLocalizationParameters) PSModificationScores(com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores) Modification(com.compomics.util.experiment.biology.modifications.Modification) ModificationMatch(com.compomics.util.experiment.identification.matches.ModificationMatch) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) ModificationScoring(com.compomics.util.experiment.identification.peptide_shaker.ModificationScoring) TreeMap(java.util.TreeMap)

Example 5 with PSModificationScores

use of com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores in project peptide-shaker by compomics.

the class OverviewPanel method updatePtmCoveragePlot.

/**
 * Update the protein coverage PTM plot.
 *
 * @param proteinAccession the protein accession
 */
private void updatePtmCoveragePlot(String proteinAccession) {
    if (proteinTable.getSelectedRow() != -1) {
        try {
            SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) proteinTable.getModel();
            long proteinKey = proteinKeys[tableModel.getViewIndex(proteinTable.getSelectedRow())];
            // get the ptms
            ArrayList<JSparklinesDataSeries> sparkLineDataSeriesPtm = new ArrayList<>();
            HashMap<Integer, ArrayList<ResidueAnnotation>> proteinTooltips = new HashMap<>();
            // we need to add a first empty filler as the coverage table starts at 0
            ArrayList<Double> data = new ArrayList<>();
            data.add(Double.valueOf(0));
            JSparklinesDataSeries sparklineDataseriesPtm = new JSparklinesDataSeries(data, new Color(0, 0, 0, 0), null);
            sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
            Identification identification = peptideShakerGUI.getIdentification();
            ProteinMatch proteinMatch = identification.getProteinMatch(proteinKey);
            PSModificationScores psPtmScores = (PSModificationScores) proteinMatch.getUrParam(PSModificationScores.dummy);
            String sequence = peptideShakerGUI.getSequenceProvider().getSequence(proteinAccession);
            int unmodifiedCounter = 0;
            // get the fixed ptms
            // @TODO: note that this only supports one fixed ptm per residue
            HashMap<Integer, String> fixedPtms = new HashMap<>();
            DisplayParameters displayParameters = peptideShakerGUI.getDisplayParameters();
            // see if fixed ptms are displayed
            if (displayParameters.getDisplayedModifications().size() != peptideShakerGUI.getIdentificationParameters().getSearchParameters().getModificationParameters().getVariableModifications().size()) {
                for (long peptideKey : peptideKeys) {
                    PeptideMatch peptideMatch = identification.getPeptideMatch(peptideKey);
                    Peptide peptide = peptideMatch.getPeptide();
                    int[] indexesOnProtein = peptide.getProteinMapping().get(proteinAccession);
                    String[] fixedModifications = peptide.getFixedModifications(peptideShakerGUI.getIdentificationParameters().getSearchParameters().getModificationParameters(), peptideShakerGUI.getSequenceProvider(), peptideShakerGUI.getIdentificationParameters().getModificationLocalizationParameters().getSequenceMatchingParameters());
                    for (int site = 0; site < fixedModifications.length; site++) {
                        String modName = fixedModifications[site];
                        if (modName != null && displayParameters.isDisplayedPTM(modName)) {
                            for (int index : indexesOnProtein) {
                                if (site == 0) {
                                    fixedPtms.put(site + index, modName);
                                } else if (site == peptide.getSequence().length() + 1) {
                                    fixedPtms.put(site + index - 2, modName);
                                } else {
                                    fixedPtms.put(site + index - 1, modName);
                                }
                            }
                        }
                    }
                }
            }
            for (int aa = 0; aa < sequence.length(); aa++) {
                String modName = fixedPtms.get(aa);
                for (String variablePTM : psPtmScores.getModificationsAtRepresentativeSite(aa)) {
                    if (displayParameters.isDisplayedPTM(variablePTM)) {
                        modName = variablePTM;
                        break;
                    }
                }
                for (String variablePTM : psPtmScores.getConfidentModificationsAt(aa)) {
                    if (displayParameters.isDisplayedPTM(variablePTM)) {
                        modName = variablePTM;
                        break;
                    }
                }
                if (modName != null) {
                    // add the non-modified area
                    if (unmodifiedCounter > 0) {
                        data = new ArrayList<>(1);
                        data.add(Double.valueOf(unmodifiedCounter));
                        sparklineDataseriesPtm = new JSparklinesDataSeries(data, new Color(0, 0, 0, 0), null);
                        sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
                    }
                    // @TODO: what about multiple ptms on the same residue..?
                    // if (psPtmScores.getMainModificationsAt(aa).size() > 1) {
                    // for (int i=0; i<psPtmScores.getMainModificationsAt(aa).size(); i++) {
                    // psPtmScores.getMainModificationsAt(aa).get(i);
                    // }
                    // }
                    Color ptmColor = new Color(peptideShakerGUI.getIdentificationParameters().getSearchParameters().getModificationParameters().getColor(modName));
                    if (ptmColor == null) {
                        ptmColor = Color.lightGray;
                    }
                    ArrayList<ResidueAnnotation> annotations = new ArrayList<>(1);
                    // @TODO: note that terminal ptms are annotated one residue too early or too late...
                    annotations.add(new ResidueAnnotation(modName + " (" + (aa + 1) + ")", 0l, false));
                    proteinTooltips.put(sparkLineDataSeriesPtm.size(), annotations);
                    data = new ArrayList<>(1);
                    data.add(Double.valueOf(1));
                    sparklineDataseriesPtm = new JSparklinesDataSeries(data, ptmColor, null);
                    sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
                    // reset the non-modified area counter
                    unmodifiedCounter = 0;
                } else {
                    unmodifiedCounter++;
                }
            }
            if (unmodifiedCounter > 0) {
                // add the remaining non-modified area
                data = new ArrayList<>();
                data.add(Double.valueOf(unmodifiedCounter));
                sparklineDataseriesPtm = new JSparklinesDataSeries(data, new Color(0, 0, 0, 0), null);
                sparkLineDataSeriesPtm.add(sparklineDataseriesPtm);
            }
            ptmSequencePanel = new ProteinSequencePanel(Color.WHITE);
            ptmChart = ptmSequencePanel.getSequencePlot(this, new JSparklinesDataset(sparkLineDataSeriesPtm), proteinTooltips, false, false);
            sequencePtmsPanel.removeAll();
            sequencePtmsPanel.add(ptmChart);
            sequencePtmsPanel.revalidate();
            sequencePtmsPanel.repaint();
        } catch (ClassCastException e) {
        // ignore   @TODO: this should not happen, but can happen if the table does not update fast enough for the filtering
        }
    }
}
Also used : JSparklinesDataset(no.uib.jsparklines.data.JSparklinesDataset) ResidueAnnotation(eu.isas.peptideshaker.gui.protein_sequence.ResidueAnnotation) DisplayParameters(eu.isas.peptideshaker.preferences.DisplayParameters) Identification(com.compomics.util.experiment.identification.Identification) SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) JSparklinesDataSeries(no.uib.jsparklines.data.JSparklinesDataSeries) ProteinSequencePanel(eu.isas.peptideshaker.gui.protein_sequence.ProteinSequencePanel) PSModificationScores(com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores)

Aggregations

PSModificationScores (com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores)18 Peptide (com.compomics.util.experiment.biology.proteins.Peptide)13 ModificationScoring (com.compomics.util.experiment.identification.peptide_shaker.ModificationScoring)11 ModificationParameters (com.compomics.util.parameters.identification.search.ModificationParameters)8 ArrayList (java.util.ArrayList)8 TreeMap (java.util.TreeMap)8 Modification (com.compomics.util.experiment.biology.modifications.Modification)7 SequenceMatchingParameters (com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters)7 TreeSet (java.util.TreeSet)7 PSParameter (com.compomics.util.experiment.identification.peptide_shaker.PSParameter)6 SequenceProvider (com.compomics.util.experiment.io.biology.protein.SequenceProvider)6 IdentificationParameters (com.compomics.util.parameters.identification.IdentificationParameters)6 HashMap (java.util.HashMap)6 Identification (com.compomics.util.experiment.identification.Identification)5 ModificationMatch (com.compomics.util.experiment.identification.matches.ModificationMatch)5 SpectrumMatch (com.compomics.util.experiment.identification.matches.SpectrumMatch)5 PeptideAssumption (com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption)5 HashSet (java.util.HashSet)5 PeptideMatch (com.compomics.util.experiment.identification.matches.PeptideMatch)4 ProteinMatch (com.compomics.util.experiment.identification.matches.ProteinMatch)4