Package eu.isas.peptideshaker.myparameters

Examples of eu.isas.peptideshaker.myparameters.PSPtmScores


    private void updateSequenceLabel() {
        try {
            DisplayPreferences displayPreferences = peptideShakerGUI.getDisplayPreferences();
            ModificationProfile modificationProfile = peptideShakerGUI.getSearchParameters().getModificationProfile();
            Peptide peptide = peptideMatch.getTheoreticPeptide();
            PSPtmScores ptmScores = new PSPtmScores();
            ptmScores = (PSPtmScores) peptideMatch.getUrParam(ptmScores);
            HashMap<Integer, ArrayList<String>> fixedModifications = DisplayFeaturesGenerator.getFilteredModifications(peptide.getIndexedFixedModifications(), displayPreferences.getDisplayedPtms());
            HashMap<Integer, ArrayList<String>> confidentLocations = DisplayFeaturesGenerator.getFilteredConfidentModificationsSites(ptmScores, displayPreferences.getDisplayedPtms());
            HashMap<Integer, ArrayList<String>> representativeAmbiguousLocations = DisplayFeaturesGenerator.getFilteredAmbiguousModificationsRepresentativeSites(ptmScores, displayPreferences.getDisplayedPtms());
            HashMap<Integer, ArrayList<String>> secondaryAmbiguousLocations = DisplayFeaturesGenerator.getFilteredAmbiguousModificationsRepresentativeSites(ptmScores, displayPreferences.getDisplayedPtms());
View Full Code Here


            try {
                if (column == 0) {
                    return row + 1;
                } else {
                    int psmNumber = row;
                    PSPtmScores psmScores = (PSPtmScores) psms.get(psmNumber).getUrParam(new PSPtmScores());
                    if (psmScores != null) {
                        PtmScoring psmScoring = psmScores.getPtmScoring(ptm.getName());
                        if (psmScoring != null) {
                            int site = column;
                            if (psmScoring.getConfidentPtmLocations().contains(site)) {
                                return psmScoring.getLocalizationConfidence(site);
                            } else {
View Full Code Here

                                                                }
                                                            }
                                                        }
                                                    }
                                                    Collections.sort(modList);
                                                    PSPtmScores ptmScores = new PSPtmScores();
                                                    boolean first = true;
                                                    for (String mod : modList) {
                                                        if (spectrumMatch.getUrParam(ptmScores) != null) {
                                                            if (first) {
                                                                first = false;
                                                            } else {
                                                                writer.write(", ");
                                                            }
                                                            ptmScores = (PSPtmScores) spectrumMatch.getUrParam(new PSPtmScores());
                                                            writer.write(mod + " (");
                                                            if (ptmScores != null && ptmScores.getPtmScoring(mod) != null) {
                                                                PtmScoring ptmScoring = ptmScores.getPtmScoring(mod);
                                                                boolean firstSite = true;
                                                                for (int site : ptmScoring.getOrderedPtmLocations()) {
                                                                    if (firstSite) {
                                                                        firstSite = false;
                                                                    } else {
                                                                        writer.write(", ");
                                                                    }
                                                                    int ptmConfidence = ptmScoring.getLocalizationConfidence(site);
                                                                    if (ptmConfidence == PtmScoring.NOT_FOUND) {
                                                                        writer.write(site + ": Not Scored"); // Well this should not happen
                                                                    } else if (ptmConfidence == PtmScoring.RANDOM) {
                                                                        writer.write(site + ": Random");
                                                                    } else if (ptmConfidence == PtmScoring.DOUBTFUL) {
                                                                        writer.write(site + ": Doubtfull");
                                                                    } else if (ptmConfidence == PtmScoring.CONFIDENT) {
                                                                        writer.write(site + ": Confident");
                                                                    } else if (ptmConfidence == PtmScoring.VERY_CONFIDENT) {
                                                                        writer.write(site + ": Very Confident");
                                                                    }
                                                                }
                                                            } else {
                                                                writer.write("Not Scored");
                                                            }
                                                            writer.write(")");
                                                        }
                                                    }
                                                    writer.write(SEPARATOR);
                                                    if (ptmScoringPreferences.isProbabilitsticScoreCalculation()) {
                                                        first = true;
                                                        for (String mod : modList) {
                                                            if (spectrumMatch.getUrParam(ptmScores) != null) {
                                                                if (first) {
                                                                    first = false;
                                                                } else {
                                                                    writer.write(", ");
                                                                }
                                                                ptmScores = (PSPtmScores) spectrumMatch.getUrParam(new PSPtmScores());
                                                                writer.write(mod + " (");
                                                                if (ptmScores != null && ptmScores.getPtmScoring(mod) != null) {
                                                                    PtmScoring ptmScoring = ptmScores.getPtmScoring(mod);
                                                                    boolean firstSite = true;
                                                                    ArrayList<Integer> sites = new ArrayList<Integer>(ptmScoring.getProbabilisticSites());
                                                                    Collections.sort(sites);
                                                                    for (int site : sites) {
                                                                        if (firstSite) {
                                                                            firstSite = false;
                                                                        } else {
                                                                            writer.write(", ");
                                                                        }
                                                                        writer.write(site + ": " + ptmScoring.getProbabilisticScore(site));
                                                                    }
                                                                } else {
                                                                    writer.write("Not Scored");
                                                                }
                                                                writer.write(")");
                                                            }
                                                        }
                                                    }
                                                    writer.write(SEPARATOR);
                                                    first = true;
                                                    for (String mod : modList) {
                                                        if (spectrumMatch.getUrParam(ptmScores) != null) {
                                                            if (first) {
                                                                first = false;
                                                            } else {
                                                                writer.write(", ");
                                                            }
                                                            ptmScores = (PSPtmScores) spectrumMatch.getUrParam(new PSPtmScores());
                                                            writer.write(mod + " (");
                                                            if (ptmScores != null && ptmScores.getPtmScoring(mod) != null) {
                                                                PtmScoring ptmScoring = ptmScores.getPtmScoring(mod);
                                                                boolean firstSite = true;
                                                                ArrayList<Integer> sites = new ArrayList<Integer>(ptmScoring.getDSites());
                                                                Collections.sort(sites);
                                                                for (int site : sites) {
                                                                    if (firstSite) {
View Full Code Here

                                        }
                                    }
                                }

                                Collections.sort(modList);
                                PSPtmScores ptmScores = new PSPtmScores();
                                first = true;
                                StringBuilder dLocalizations = new StringBuilder();
                                StringBuilder probabilisticLocalizations = new StringBuilder();
                                String mdLocation = "";
                                String mdScore = "";
                                String[] split = sequence.split("[STY]");
                                int nSites = split.length - 1;
                                ArrayList<String> phosphoNames = new ArrayList<String>();

                                for (String mod : modList) {
                                    if (mod.contains("phospho")) {
                                        phosphoNames.add(mod);
                                        if (spectrumMatch.getUrParam(ptmScores) != null) {
                                            ptmScores = (PSPtmScores) spectrumMatch.getUrParam(new PSPtmScores());
                                            if (ptmScores != null && ptmScores.getPtmScoring(mod) != null) {
                                                PtmScoring ptmScoring = ptmScores.getPtmScoring(mod);
                                                ArrayList<Integer> sites = new ArrayList<Integer>(ptmScoring.getProbabilisticSites());
                                                Collections.sort(sites);
                                                for (Integer site : sites) {
                                                    if (probabilisticLocalizations.length() > 0) {
                                                        probabilisticLocalizations.append(", ");
View Full Code Here

            if (first) {
                first = false;
            } else {
                result += ", ";
            }
            PSPtmScores ptmScores = (PSPtmScores) peptideMatch.getUrParam(new PSPtmScores());
            result += mod + " (";
            if (ptmScores != null && ptmScores.getPtmScoring(mod) != null) {
                PtmScoring ptmScoring = ptmScores.getPtmScoring(mod);
                boolean firstSite = true;
                for (int site : ptmScoring.getOrderedPtmLocations()) {
                    if (firstSite) {
                        firstSite = false;
                    } else {
View Full Code Here

            writeCvTerm(new CvTerm("PSI-MS", "MS:1002467", "PeptideShaker PSM confidence", Double.toString(Util.roundDouble(psmParameter.getPsmConfidence(), CONFIDENCE_DECIMALS))));

            if (mzidVersion1_2) {

                PeptideMatch peptideMatch = identification.getPeptideMatch(bestPeptideKey);
                PSPtmScores psPtmScores = (PSPtmScores) spectrumMatch.getUrParam(new PSPtmScores());
                if (psPtmScores != null) {
                    int modMatchIndex = 0;
                    for (ModificationMatch modMatch : bestPeptideAssumption.getPeptide().getModificationMatches()) {
                        PtmScoring ptmScoring = psPtmScores.getPtmScoring(modMatch.getTheoreticPtm());
                        if (ptmScoring != null) {
                            int site = modMatch.getModificationSite();
                            if (ptmScoringPreferences.isProbabilitsticScoreCalculation()) {
                                double score = ptmScoring.getProbabilisticScore(site);
                                String valid = "true";
                                if (score < ptmScoringPreferences.getProbabilisticScoreThreshold()) {
                                    valid = "false";
                                }
                                writeCvTerm(new CvTerm("PSI-MS", "MS:100XXX",
                                        ptmScoringPreferences.getSelectedProbabilisticScore().getName(),
                                        modMatchIndex + ":" + score + ":" + site + ":" + valid)); // @TODO: add correct cv term!
                            }
                            double score = ptmScoring.getDeltaScore(site);
                            String valid = "true";
                            if (score < 95) { //@TODO: avoid this hard coded value
                                valid = "false";
                            }
                            writeCvTerm(new CvTerm("PSI-MS", "MS:100XXX", "D-score",
                                    modMatchIndex + ":" + score + ":" + site + ":" + valid)); // @TODO: add correct cv term!
                        }
                        modMatchIndex++;
                    }
                }

                PSParameter peptideParameter = (PSParameter) identification.getPeptideMatchParameter(bestPeptideKey, psmParameter);
                writeCvTerm(new CvTerm("PSI-MS", "MS:100XXX", "peptide: Confidence", peptideParameter.getPeptideConfidence() + "")); // @TODO: add correct cv term!
                writeCvTerm(new CvTerm("PSI-MS", "MS:1002489", "peptide: Score", peptideParameter.getPeptideScore() + ""));
                writeCvTerm(new CvTerm("PSI-MS", "MS:1002500", "peptide passes threshold", peptideParameter.getMatchValidationLevel().isValidated() + ""));

                psPtmScores = (PSPtmScores) peptideMatch.getUrParam(new PSPtmScores());
                if (psPtmScores != null) {
                    int modMatchIndex = 0;
                    for (ModificationMatch modMatch : peptideMatch.getTheoreticPeptide().getModificationMatches()) {
                        PtmScoring ptmScoring = psPtmScores.getPtmScoring(modMatch.getTheoreticPtm());
                        if (ptmScoring != null) {
                            int site = modMatch.getModificationSite();
                            if (ptmScoringPreferences.isProbabilitsticScoreCalculation()) {
                                double score = ptmScoring.getProbabilisticScore(site);
                                String valid = "true";
View Full Code Here

     * reading/writing the an identification match
     */
    public void attachDeltaScore(Identification identification, SpectrumMatch spectrumMatch, SequenceMatchingPreferences sequenceMatchingPreferences) throws Exception {

        HashMap<String, ArrayList<Integer>> modificationProfiles = new HashMap<String, ArrayList<Integer>>();
        PSPtmScores ptmScores = new PSPtmScores();

        if (spectrumMatch.getUrParam(new PSPtmScores()) != null) {
            ptmScores = (PSPtmScores) spectrumMatch.getUrParam(new PSPtmScores());
        }

        PSParameter psParameter = new PSParameter();
        double p1 = 1;
        Peptide psPeptide = spectrumMatch.getBestPeptideAssumption().getPeptide();
        for (SpectrumIdentificationAssumption assumption : spectrumMatch.getAllAssumptions()) {
            if (assumption instanceof PeptideAssumption) {
                PeptideAssumption peptideAssumption = (PeptideAssumption) assumption;
                Peptide sePeptide = peptideAssumption.getPeptide();
                if (psPeptide.isSameSequence(sePeptide, sequenceMatchingPreferences) && psPeptide.sameModificationsAs(sePeptide)) {
                    psParameter = (PSParameter) peptideAssumption.getUrParam(psParameter);
                    double ptemp = psParameter.getSearchEngineProbability();
                    if (ptemp < p1) {
                        p1 = ptemp;
                    }
                }
            }
        }

        String mainSequence = psPeptide.getSequence();
        ArrayList<String> modifications = new ArrayList<String>();

        for (ModificationMatch modificationMatch : psPeptide.getModificationMatches()) {
            if (modificationMatch.isVariable()) {
                String modificationName = modificationMatch.getTheoreticPtm();
                if (!modifications.contains(modificationName)) {
                    modifications.add(modificationName);
                    modificationProfiles.put(modificationName, new ArrayList<Integer>());
                }
                modificationProfiles.get(modificationName).add(modificationMatch.getModificationSite());
            }
        }

        if (!modifications.isEmpty()) {

            for (String modName : modifications) {

                PTM ptm1 = ptmFactory.getPTM(modName);

                for (int modSite : modificationProfiles.get(modName)) {

                    double refP = 1, secondaryP = 1;

                    for (SpectrumIdentificationAssumption assumption : spectrumMatch.getAllAssumptions()) {

                        if (assumption instanceof PeptideAssumption) {

                            PeptideAssumption peptideAssumption = (PeptideAssumption) assumption;

                            if (peptideAssumption.getPeptide().getSequence().equals(mainSequence)) {

                                boolean modificationAtSite = false, modificationFound = false;

                                for (ModificationMatch modMatch : peptideAssumption.getPeptide().getModificationMatches()) {

                                    PTM ptm2 = ptmFactory.getPTM(modMatch.getTheoreticPtm());

                                    if (ptm1.getMass() == ptm2.getMass()) {

                                        modificationFound = true;
                                        psParameter = (PSParameter) peptideAssumption.getUrParam(psParameter);
                                        double p = psParameter.getSearchEngineProbability();

                                        if (modMatch.getModificationSite() == modSite) {

                                            modificationAtSite = true;

                                            if (p < refP) {
                                                refP = p;
                                            }
                                        }
                                    }
                                }

                                if (!modificationAtSite && modificationFound) {
                                    psParameter = (PSParameter) peptideAssumption.getUrParam(psParameter);
                                    double p = psParameter.getSearchEngineProbability();
                                    if (p < secondaryP) {
                                        secondaryP = p;
                                    }
                                }
                            }
                        }
                    }

                    PtmScoring ptmScoring = ptmScores.getPtmScoring(modName);
                    if (ptmScoring == null) {
                        ptmScoring = new PtmScoring(modName);
                        ptmScores.addPtmScoring(modName, ptmScoring);
                    }

                    if (secondaryP < refP) {
                        secondaryP = refP;
                    }
View Full Code Here

     * @return a string with the HTML tooltip for the peptide
     */
    public String getPeptideModificationTooltipAsHtml(SpectrumMatch spectrumMatch) {
        try {
            Peptide peptide = spectrumMatch.getBestPeptideAssumption().getPeptide();
            PSPtmScores ptmScores = new PSPtmScores();
            ptmScores = (PSPtmScores) spectrumMatch.getUrParam(ptmScores);
            return getPeptideModificationTooltipAsHtml(peptide, ptmScores);
        } catch (Exception e) {
            exceptionHandler.catchException(e);
            return "Error";
View Full Code Here

     * @return a string with the HTML tooltip for the peptide
     */
    public String getPeptideModificationTooltipAsHtml(PeptideMatch peptideMatch) {
        try {
            Peptide peptide = peptideMatch.getTheoreticPeptide();
            PSPtmScores ptmScores = new PSPtmScores();
            ptmScores = (PSPtmScores) peptideMatch.getUrParam(ptmScores);
            return getPeptideModificationTooltipAsHtml(peptide, ptmScores);
        } catch (Exception e) {
            exceptionHandler.catchException(e);
            return "Error";
View Full Code Here

    private void attachProbabilisticScore(Identification identification, SpectrumMatch spectrumMatch, SearchParameters searchParameters,
            AnnotationPreferences annotationPreferences, PTMScoringPreferences scoringPreferences, SequenceMatchingPreferences sequenceMatchingPreferences) throws Exception {

        ModificationProfile ptmProfile = searchParameters.getModificationProfile();

        PSPtmScores ptmScores = new PSPtmScores();
        if (spectrumMatch.getUrParam(new PSPtmScores()) != null) {
            ptmScores = (PSPtmScores) spectrumMatch.getUrParam(new PSPtmScores());
        }

        HashMap<Double, ArrayList<PTM>> modifications = new HashMap<Double, ArrayList<PTM>>();
        HashMap<Double, Integer> nMod = new HashMap<Double, Integer>();
        HashMap<Double, ModificationMatch> modificationMatches = new HashMap<Double, ModificationMatch>();
        Peptide peptide = spectrumMatch.getBestPeptideAssumption().getPeptide();

        for (ModificationMatch modificationMatch : peptide.getModificationMatches()) {
            if (modificationMatch.isVariable()) {
                PTM refPTM = ptmFactory.getPTM(modificationMatch.getTheoreticPtm());
                double ptmMass = refPTM.getMass();
                if (!modifications.containsKey(ptmMass)) {
                    ArrayList<PTM> ptms = new ArrayList<PTM>();
                    for (String ptm : ptmProfile.getSimilarNotFixedModifications(ptmMass)) {
                        ptms.add(ptmFactory.getPTM(ptm));
                    }
                    modifications.put(ptmMass, ptms);
                    nMod.put(ptmMass, 1);
                } else {
                    nMod.put(ptmMass, nMod.get(ptmMass) + 1);
                }
                modificationMatches.put(ptmMass, modificationMatch);
            }
        }

        if (!modifications.isEmpty()) {

            MSnSpectrum spectrum = (MSnSpectrum) spectrumFactory.getSpectrum(spectrumMatch.getKey());
            annotationPreferences.setCurrentSettings(spectrumMatch.getBestPeptideAssumption(), true, sequenceMatchingPreferences);

            for (Double ptmMass : modifications.keySet()) {
                HashMap<Integer, Double> scores = null;
                if (scoringPreferences.getSelectedProbabilisticScore() == PtmScore.AScore && nMod.get(ptmMass) == 1) {
                    scores = AScore.getAScore(peptide, modifications.get(ptmMass), spectrum, annotationPreferences.getIonTypes(),
                            annotationPreferences.getNeutralLosses(), annotationPreferences.getValidatedCharges(),
                            spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().value,
                            searchParameters.getFragmentIonAccuracy(), scoringPreferences.isProbabilisticScoreNeutralLosses(), sequenceMatchingPreferences, peptideSpectrumAnnotator, roundingDecimal);
                } else if (scoringPreferences.getSelectedProbabilisticScore() == PtmScore.PhosphoRS) {
                    scores = PhosphoRS.getSequenceProbabilities(peptide, modifications.get(ptmMass), spectrum, annotationPreferences.getIonTypes(),
                            annotationPreferences.getNeutralLosses(), annotationPreferences.getValidatedCharges(),
                            spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().value,
                            searchParameters.getFragmentIonAccuracy(), scoringPreferences.isProbabilisticScoreNeutralLosses(),
                            sequenceMatchingPreferences, peptideSpectrumAnnotator, roundingDecimal);
                }
                if (scores != null) {
                    // remap to searched PTMs
                    PTM mappedModification = null;
                    String peptideSequence = peptide.getSequence();
                    for (int site : scores.keySet()) {
                        if (site == 0) {
                            // N-term ptm
                            for (PTM ptm : modifications.get(ptmMass)) {
                                if (ptm.isNTerm() && peptide.getPotentialModificationSites(ptm, sequenceMatchingPreferences).contains(1)) {
                                    mappedModification = ptm;
                                    break;
                                }
                            }
                            if (mappedModification == null) {
                                throw new IllegalArgumentException("Could not map the PTM of mass " + ptmMass + " on the N-terminus of the peptide " + peptideSequence + ".");
                            }
                        } else if (site == peptideSequence.length() + 1) {
                            // C-term ptm
                            for (PTM ptm : modifications.get(ptmMass)) {
                                if (ptm.isCTerm() && peptide.getPotentialModificationSites(ptm, sequenceMatchingPreferences).contains(peptideSequence.length())) {
                                    mappedModification = ptm;
                                    break;
                                }
                            }
                            if (mappedModification == null) {
                                throw new IllegalArgumentException("Could not map the PTM of mass " + ptmMass + " on the C-terminus of the peptide " + peptideSequence + ".");
                            }
                        } else {
                            for (PTM ptm : modifications.get(ptmMass)) {
                                if (peptide.getPotentialModificationSites(ptm, sequenceMatchingPreferences).contains(site)) {
                                    mappedModification = ptm;
                                    break;
                                }
                            }
                            if (mappedModification == null) {
                                throw new IllegalArgumentException("Could not map the PTM of mass " + ptmMass + " at site " + site + " in peptide " + peptide.getSequence() + ".");
                            }
                        }

                        String ptmName = mappedModification.getName();

                        PtmScoring ptmScoring = ptmScores.getPtmScoring(ptmName);

                        if (ptmScoring == null) {
                            ptmScoring = new PtmScoring(ptmName);
                            ptmScores.addPtmScoring(ptmName, ptmScoring);
                        }

                        ptmScoring.setProbabilisticScore(site, scores.get(site));
                    }
                }
View Full Code Here

TOP

Related Classes of eu.isas.peptideshaker.myparameters.PSPtmScores

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