Examples of PeptideSpecificMap


Examples of eu.isas.peptideshaker.scoring.PeptideSpecificMap

        int line = 1;

        for (PsValidationFeature validationFeature : validationFeatures) {
            switch (validationFeature) {
                case peptide_accuracy:
                    PeptideSpecificMap peptideTargetDecoyMap = psMaps.getPeptideSpecificMap();
                    ArrayList<String> peptideKeys = peptideTargetDecoyMap.getKeys();
                    for (String peptideKey : peptideKeys) {
                        if (indexes) {
                            writer.write(line + "");
                            writer.addSeparator();
                        }
                        writer.write(validationFeature.getTitle());
                        writer.addSeparator();
                        double pmin = 0;
                        int nMax = peptideTargetDecoyMap.getTargetDecoyMap(peptideKey).getnMax();
                        if (nMax != 0) {
                            pmin = 100.0 / nMax;
                        }
                        writer.write(Util.roundDouble(pmin, 2) + " %");
                        writer.newLine();
                        line++;
                    }
                    break;
                case peptide_confidence:
                    peptideTargetDecoyMap = psMaps.getPeptideSpecificMap();
                    peptideKeys = peptideTargetDecoyMap.getKeys();
                    for (String peptideKey : peptideKeys) {
                        if (indexes) {
                            writer.write(line + "");
                            writer.addSeparator();
                        }
                        writer.write(validationFeature.getTitle());
                        writer.addSeparator();
                        double result = peptideTargetDecoyMap.getTargetDecoyMap(peptideKey).getTargetDecoyResults().getConfidenceLimit();
                        writer.write(Util.roundDouble(result, 2) + " %");
                        writer.newLine();
                        line++;
                    }
                    break;
                case peptide_fdr:
                    peptideTargetDecoyMap = psMaps.getPeptideSpecificMap();
                    peptideKeys = peptideTargetDecoyMap.getKeys();
                    for (String peptideKey : peptideKeys) {
                        if (indexes) {
                            writer.write(line + "");
                            writer.addSeparator();
                        }
                        writer.write(validationFeature.getTitle());
                        writer.addSeparator();
                        double result = peptideTargetDecoyMap.getTargetDecoyMap(peptideKey).getTargetDecoyResults().getFdrLimit();
                        writer.write(Util.roundDouble(result, 2) + " %");
                        writer.newLine();
                        line++;
                    }
                    break;
                case peptide_fnr:
                    peptideTargetDecoyMap = psMaps.getPeptideSpecificMap();
                    peptideKeys = peptideTargetDecoyMap.getKeys();
                    for (String peptideKey : peptideKeys) {
                        if (indexes) {
                            writer.write(line + "");
                            writer.addSeparator();
                        }
                        writer.write(validationFeature.getTitle());
                        writer.addSeparator();
                        double result = peptideTargetDecoyMap.getTargetDecoyMap(peptideKey).getTargetDecoyResults().getFnrLimit();
                        writer.write(Util.roundDouble(result, 2) + " %");
                        writer.newLine();
                        line++;
                    }
                    break;
                case peptide_pep:
                    peptideTargetDecoyMap = psMaps.getPeptideSpecificMap();
                    peptideKeys = peptideTargetDecoyMap.getKeys();
                    for (String peptideKey : peptideKeys) {
                        if (indexes) {
                            writer.write(line + "");
                            writer.addSeparator();
                        }
                        writer.write(validationFeature.getTitle());
                        writer.addSeparator();
                        double result = 100 - peptideTargetDecoyMap.getTargetDecoyMap(peptideKey).getTargetDecoyResults().getConfidenceLimit();
                        writer.write(Util.roundDouble(result, 2) + " %");
                        writer.newLine();
                        line++;
                    }
                    break;
                case total_peptide:
                    peptideTargetDecoyMap = psMaps.getPeptideSpecificMap();
                    peptideKeys = peptideTargetDecoyMap.getKeys();
                    for (String peptideKey : peptideKeys) {
                        if (indexes) {
                            writer.write(line + "");
                            writer.addSeparator();
                        }
                        writer.write(validationFeature.getTitle());
                        writer.addSeparator();
                        double result = peptideTargetDecoyMap.getTargetDecoyMap(peptideKey).getTargetDecoyResults().getnTPTotal();
                        writer.write(Util.roundDouble(result, 2) + "");
                        writer.newLine();
                        line++;
                    }
                    break;
                case validated_peptide:
                    peptideTargetDecoyMap = psMaps.getPeptideSpecificMap();
                    peptideKeys = peptideTargetDecoyMap.getKeys();
                    for (String peptideKey : peptideKeys) {
                        if (indexes) {
                            writer.write(line + "");
                            writer.addSeparator();
                        }
                        writer.write(validationFeature.getTitle());
                        writer.addSeparator();
                        double result = peptideTargetDecoyMap.getTargetDecoyMap(peptideKey).getTargetDecoyResults().getN();
                        writer.write(Util.roundDouble(result, 0) + "");
                        writer.newLine();
                        line++;
                    }
                    break;
View Full Code Here

Examples of eu.isas.peptideshaker.scoring.PeptideSpecificMap

            PSMaps pSMaps = new PSMaps();
            pSMaps = (PSMaps) identification.getUrParam(pSMaps);
            ProteinMap proteinTargetDecoyMap = pSMaps.getProteinMap();
            PsmSpecificMap psmTargetDecoyMap = pSMaps.getPsmSpecificMap();
            PeptideSpecificMap peptideTargetDecoyMap = pSMaps.getPeptideSpecificMap();

            // get the list of algorithms used
            String searchEngineReport;
            ArrayList<Integer> seList = projectDetails.getIdentificationAlgorithms();
            Collections.sort(seList);
            searchEngineReport = Advocate.getAdvocate(seList.get(0)).getName();

            for (int i = 1; i < seList.size(); i++) {

                if (i == seList.size() - 1) {
                    searchEngineReport += " and ";
                } else {
                    searchEngineReport += ", ";
                }

                searchEngineReport += Advocate.getAdvocate(seList.get(i)).getName();
            }

            searchEngineReport += " post-processed by PeptideShaker v" + peptideShakerVersion;

            for (String spectrumFile : identification.getSpectrumFiles()) {
                identification.loadSpectrumMatches(spectrumFile, null);
            }
            identification.loadPeptideMatches(null);
            identification.loadProteinMatches(null);
            for (String spectrumFile : identification.getSpectrumFiles()) {
                identification.loadSpectrumMatchParameters(spectrumFile, psmProbabilities, null);
            }
            identification.loadPeptideMatchParameters(peptideProbabilities, null);
            identification.loadProteinMatchParameters(proteinProbabilities, null);

            for (String proteinKey : identification.getProteinIdentification()) {

                if (waitingHandler.isRunCanceled()) {
                    break;
                }
                ProteinMatch proteinMatch = identification.getProteinMatch(proteinKey);
                proteinProbabilities = (PSParameter) identification.getProteinMatchParameter(proteinKey, proteinProbabilities);
                double confidenceThreshold;

                br.write(getCurrentTabSpace() + "<GelFreeIdentification>" + System.getProperty("line.separator"));
                tabCounter++;

                // protein accession and database
                br.write(getCurrentTabSpace() + "<Accession>" + proteinMatch.getMainMatch() + "</Accession>" + System.getProperty("line.separator"));
                br.write(getCurrentTabSpace() + "<Database>" + sequenceFactory.getHeader(proteinMatch.getMainMatch()).getDatabaseType() + "</Database>" + System.getProperty("line.separator"));

                identification.loadPeptideMatches(proteinMatch.getPeptideMatchesKeys(), null); // @TODO: should use the progress dialog here, but this messes up the overall progress bar...
                identification.loadPeptideMatchParameters(proteinMatch.getPeptideMatchesKeys(), peptideProbabilities, null);

                for (String peptideKey : proteinMatch.getPeptideMatchesKeys()) {

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

                    PeptideMatch currentMatch = identification.getPeptideMatch(peptideKey);
                    peptideProbabilities = (PSParameter) identification.getPeptideMatchParameter(peptideKey, peptideProbabilities);

                    identification.loadSpectrumMatches(currentMatch.getSpectrumMatches(), null); // @TODO: should use the progress dialog here, but this messes up the overall progress bar...
                    identification.loadSpectrumMatchParameters(currentMatch.getSpectrumMatches(), psmProbabilities, null);

                    for (String spectrumKey : currentMatch.getSpectrumMatches()) {

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

                        psmProbabilities = (PSParameter) identification.getSpectrumMatchParameter(spectrumKey, psmProbabilities);
                        SpectrumMatch spectrumMatch = identification.getSpectrumMatch(spectrumKey);
                        PeptideAssumption bestAssumption = spectrumMatch.getBestPeptideAssumption();
                        Peptide tempPeptide = bestAssumption.getPeptide();

                        // the peptide
                        br.write(getCurrentTabSpace() + "<PeptideItem>" + System.getProperty("line.separator"));
                        tabCounter++;

                        // peptide sequence
                        br.write(getCurrentTabSpace() + "<Sequence>" + tempPeptide.getSequence() + "</Sequence>" + System.getProperty("line.separator"));

                        // peptide start and end
                        String proteinAccession = proteinMatch.getMainMatch();
                        String proteinSequence = sequenceFactory.getProtein(proteinAccession).getSequence();
                        int peptideStart = proteinSequence.lastIndexOf(tempPeptide.getSequence()) + 1; // @TODO: lastIndexOf should be avoided!!
                        br.write(getCurrentTabSpace() + "<Start>" + peptideStart + "</Start>" + System.getProperty("line.separator"));
                        br.write(getCurrentTabSpace() + "<End>" + (peptideStart + tempPeptide.getSequence().length() - 1) + "</End>" + System.getProperty("line.separator"));

                        // spectrum index reference
                        br.write(getCurrentTabSpace() + "<SpectrumReference>" + spectrumIndexes.get(spectrumMatch.getKey()) + "</SpectrumReference>" + System.getProperty("line.separator"));

                        // modifications
                        writePtms(tempPeptide);

                        // fragment ions
                        writeFragmentIons(spectrumMatch);

                        // Get scores
                        HashMap<Integer, Double> eValues = new HashMap<Integer, Double>();
                        Double mascotScore = null, msAmandaScore = null;
                        for (int se : spectrumMatch.getAdvocates()) {
                            for (double eValue : spectrumMatch.getAllAssumptions(se).keySet()) {
                                for (SpectrumIdentificationAssumption assumption : spectrumMatch.getAllAssumptions(se).get(eValue)) {
                                    if (assumption instanceof PeptideAssumption) {
                                        PeptideAssumption peptideAssumption = (PeptideAssumption) assumption;
                                        if (peptideAssumption.getPeptide().isSameSequenceAndModificationStatus(bestAssumption.getPeptide(), sequenceMatchingPreferences)) {
                                            if (!eValues.containsKey(se) || eValues.get(se) > eValue) {
                                                eValues.put(se, eValue);
                                                if (se == Advocate.mascot.getIndex()) {
                                                    mascotScore = ((MascotScore) assumption.getUrParam(new MascotScore(0))).getScore();
                                                } else if (se == Advocate.msAmanda.getIndex()
                                                        && peptideAssumption.getUrParam(new MsAmandaScore()) != null) {
                                                    msAmandaScore = ((MsAmandaScore) assumption.getUrParam(new MsAmandaScore())).getScore();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        // PTM scores
                        ArrayList<String> modifications = new ArrayList<String>();

                        for (ModificationMatch modificationMatch : bestAssumption.getPeptide().getModificationMatches()) {
                            if (modificationMatch.isVariable()) {
                                if (!modifications.contains(modificationMatch.getTheoreticPtm())) {
                                    modifications.add(modificationMatch.getTheoreticPtm());
                                }
                            }
                        }

                        StringBuilder dScore = new StringBuilder();
                        Collections.sort(modifications);
                        PSPtmScores ptmScores = new PSPtmScores();

                        for (String mod : modifications) {

                            if (spectrumMatch.getUrParam(ptmScores) != null) {

                                if (dScore.length() > 0) {
                                    dScore.append(", ");
                                }

                                ptmScores = (PSPtmScores) spectrumMatch.getUrParam(new PSPtmScores());
                                dScore.append(mod).append(" (");

                                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) {
                                            firstSite = false;
                                        } else {
                                            dScore.append(", ");
                                        }
                                        dScore.append(site).append(": ").append(ptmScoring.getDeltaScore(site));
                                    }
                                } else {
                                    dScore.append("Not Scored");
                                }
                                dScore.append(")");
                            }
                        }

                        StringBuilder probabilisticScore = new StringBuilder();

                        if (ptmScoringPreferences.isProbabilitsticScoreCalculation()) {

                            for (String mod : modifications) {

                                if (spectrumMatch.getUrParam(ptmScores) != null) {

                                    if (probabilisticScore.length() > 0) {
                                        probabilisticScore.append(", ");
                                    }

                                    ptmScores = (PSPtmScores) spectrumMatch.getUrParam(new PSPtmScores());
                                    probabilisticScore.append(mod).append(" (");

                                    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 {
                                                probabilisticScore.append(", ");
                                            }
                                            probabilisticScore.append(site).append(": ").append(ptmScoring.getProbabilisticScore(site));
                                        }
                                    } else {
                                        probabilisticScore.append("Not Scored");
                                    }

                                    probabilisticScore.append(")");
                                }
                            }
                        }

                        // @TODO: the line below uses the protein tree, which has to be rebuilt if not available...
                        ArrayList<String> peptideParentProteins = tempPeptide.getParentProteins(sequenceMatchingPreferences);
                        String peptideProteins = "";
                        for (String accession : peptideParentProteins) {
                            if (!peptideProteins.equals("")) {
                                peptideProteins += ", ";
                            }
                            peptideProteins += accession;
                        }

                        // additional peptide id parameters
                        br.write(getCurrentTabSpace() + "<additional>" + System.getProperty("line.separator"));
                        tabCounter++;
                        br.write(getCurrentTabSpace() + "<userParam name=\"Spectrum File\" value=\"" + Spectrum.getSpectrumFile(spectrumKey) + "\" />" + System.getProperty("line.separator"));
                        writeCvTerm(new CvTerm("PSI-MS", "MS:1000796", "Spectrum Title", "" + StringEscapeUtils.escapeHtml4(Spectrum.getSpectrumTitle(spectrumKey))));
                        br.write(getCurrentTabSpace() + "<userParam name=\"Protein Inference\" value=\"" + peptideProteins + "\" />" + System.getProperty("line.separator"));
                        br.write(getCurrentTabSpace() + "<userParam name=\"Peptide Confidence\" value=\"" + Util.roundDouble(peptideProbabilities.getPeptideConfidence(), CONFIDENCE_DECIMALS) + "\" />" + System.getProperty("line.separator"));
                        confidenceThreshold = peptideTargetDecoyMap.getTargetDecoyMap(peptideTargetDecoyMap.getCorrectedKey(peptideProbabilities.getSpecificMapKey())).getTargetDecoyResults().getConfidenceLimit();
                        br.write(getCurrentTabSpace() + "<userParam name=\"Peptide Confidence Threshold\" value=\"" + Util.roundDouble(confidenceThreshold, CONFIDENCE_DECIMALS) + "\" />" + System.getProperty("line.separator"));
                        MatchValidationLevel matchValidationLevel = peptideProbabilities.getMatchValidationLevel();
                        if (matchValidationLevel == MatchValidationLevel.doubtful && !peptideProbabilities.getReasonDoubtful().equals("")) {
                            br.write(getCurrentTabSpace() + "<userParam name=\"Peptide Validation\" value=\"" + matchValidationLevel + " (" + StringEscapeUtils.escapeHtml4(peptideProbabilities.getReasonDoubtful()) + ")" + "\" />" + System.getProperty("line.separator"));
                        } else {
View Full Code Here

Examples of eu.isas.peptideshaker.scoring.PeptideSpecificMap

                    }
                } else if (type == Type.PSM) {

                    PSMaps pSMaps = new PSMaps();
                    pSMaps = (PSMaps) identification.getUrParam(pSMaps);
                    PeptideSpecificMap peptideMap = pSMaps.getPeptideSpecificMap();
                    ProteinMap proteinMap = pSMaps.getProteinMap();
                    SpectrumMatch spectrumMatch = identification.getSpectrumMatch(matchKey);
                    if (spectrumMatch.getBestPeptideAssumption() != null) {
                        Peptide peptide = spectrumMatch.getBestPeptideAssumption().getPeptide();
                        String peptideKey = peptide.getMatchingKey(sequenceMatchingPreferences);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.