Examples of PSParameter


Examples of eu.isas.peptideshaker.myparameters.PSParameter

     */
    private void writePsms(ProgressDialogX progressDialog) throws IOException, MzMLUnmarshallerException {

        try {
            SequenceFactory sequenceFactory = SequenceFactory.getInstance();
            PSParameter proteinProbabilities = new PSParameter();
            PSParameter peptideProbabilities = new PSParameter();
            PSParameter psmProbabilities = new PSParameter();

            progressDialog.setTitle("Creating PRIDE XML File. Please Wait...  (Part 2 of 2: Exporting IDs)");
            long increment = totalProgress / (2 * identification.getProteinIdentification().size());

            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 {
                            br.write(getCurrentTabSpace() + "<userParam name=\"Peptide Validation\" value=\"" + matchValidationLevel + "\" />" + System.getProperty("line.separator"));
                        }
                        br.write(getCurrentTabSpace() + "<userParam name=\"PSM Confidence\" value=\"" + Util.roundDouble(psmProbabilities.getPsmConfidence(), CONFIDENCE_DECIMALS) + "\" />" + System.getProperty("line.separator"));
                        Integer charge = new Integer(psmProbabilities.getSpecificMapKey());
                        String fileName = Spectrum.getSpectrumFile(spectrumKey);
                        confidenceThreshold = psmTargetDecoyMap.getTargetDecoyMap(charge, fileName).getTargetDecoyResults().getConfidenceLimit();
                        br.write(getCurrentTabSpace() + "<userParam name=\"PSM Confidence Threshold\" value=\"" + Util.roundDouble(confidenceThreshold, CONFIDENCE_DECIMALS) + "\" />" + System.getProperty("line.separator"));
                        matchValidationLevel = psmProbabilities.getMatchValidationLevel();
                        if (matchValidationLevel == MatchValidationLevel.doubtful && !psmProbabilities.getReasonDoubtful().equals("")) {
                            br.write(getCurrentTabSpace() + "<userParam name=\"PSM Validation\" value=\"" + matchValidationLevel + " (" + StringEscapeUtils.escapeHtml4(psmProbabilities.getReasonDoubtful()) + ")" + "\" />" + System.getProperty("line.separator"));
                        } else {
                            br.write(getCurrentTabSpace() + "<userParam name=\"PSM Validation\" value=\"" + matchValidationLevel + "\" />" + System.getProperty("line.separator"));
                        }

                        writeCvTerm(new CvTerm("PSI-MS", "MS:1000041", "Charge State", "" + bestAssumption.getIdentificationCharge().value)); // @TODO: is 2+ etc supported?
                        //br.write(getCurrentTabSpace() + "<userParam name=\"Identified Charge\" value=\"" + bestAssumption.getIdentificationCharge().value + "\" />" + System.getProperty("line.separator"));

                        // search engine specific parameters
                        ArrayList<Integer> searchEngines = new ArrayList<Integer>(eValues.keySet());
                        Collections.sort(searchEngines);

                        // add the search engine e-values
                        ArrayList<Integer> algorithms = new ArrayList<Integer>(eValues.keySet());
                        Collections.sort(algorithms);
                        for (int tempAdvocate : algorithms) {
                            double eValue = eValues.get(tempAdvocate);
                            if (tempAdvocate == Advocate.msgf.getIndex()) {
                                writeCvTerm(new CvTerm("PSI-MS", "MS:1002052", "MS-GF:SpecEValue", Double.toString(eValue)));
                            } else if (tempAdvocate == Advocate.mascot.getIndex()) {
                                writeCvTerm(new CvTerm("PSI-MS", "MS:1001172", "Mascot:expectation value", Double.toString(eValue)));
                            } else if (tempAdvocate == Advocate.omssa.getIndex()) {
                                writeCvTerm(new CvTerm("PSI-MS", "MS:1001328", "OMSSA:evalue", Double.toString(eValue)));
                            } else if (tempAdvocate == Advocate.xtandem.getIndex()) {
                                writeCvTerm(new CvTerm("PSI-MS", "MS:1001330", "X!Tandem:expect", Double.toString(eValue)));
                            } else if (tempAdvocate == Advocate.comet.getIndex()) {
                                writeCvTerm(new CvTerm("PSI-MS", "MS:1002257", "Comet:expectation value", Double.toString(eValue)));
                            } else {
                                br.write(getCurrentTabSpace() + "<userParam name=\"" + Advocate.getAdvocate(tempAdvocate).getName()
                                        + " e-value\" value=\"" + eValue + "\" />" + System.getProperty("line.separator"))// @TODO: add cv params for the other new advocates
                            }
                           
                            // @TODO: add scores for MyriMatch!

                            // @TODO: add generic e-value for user algorithms?
                        }

                        // add the additional search engine scores
                        if (mascotScore != null) {
                            writeCvTerm(new CvTerm("PSI-MS", "MS:1001171", "Mascot:score", "" + mascotScore));
                        }
                        if (msAmandaScore != null) {
                            writeCvTerm(new CvTerm("PSI-MS", "MS:1002319", "Amanda:AmandaScore", "" + msAmandaScore));
                        }

                        // @TODO: add additional scores for OMSSA and X!Tandem as well
                        // "MS:1001329", "OMSSA:pvalue"
                        // "PRIDE:0000182","X|Tandem Z score"
                        // "MS:1001331", "X!Tandem:hyperscore"
                        // PTM scoring
                        if (dScore.length() > 0) {
                            br.write(getCurrentTabSpace() + "<userParam name=\"PTM D-score\" value=\"" + dScore + "\" />" + System.getProperty("line.separator"));
                        }
                        if (ptmScoringPreferences.isProbabilitsticScoreCalculation() && probabilisticScore.length() > 0) {
                            br.write(getCurrentTabSpace() + "<userParam name=\"PTM "
                                    + ptmScoringPreferences.getSelectedProbabilisticScore().getName()
                                    + "\" value=\"" + probabilisticScore + "\" />" + System.getProperty("line.separator"));
                        }
                        tabCounter--;
                        br.write(getCurrentTabSpace() + "</additional>" + System.getProperty("line.separator"));
                        tabCounter--;
                        br.write(getCurrentTabSpace() + "</PeptideItem>" + System.getProperty("line.separator"));
                    }
                }

                // additional protein id parameters
                br.write(getCurrentTabSpace() + "<additional>" + System.getProperty("line.separator"));
                tabCounter++;
                if (ProteinMatch.isDecoy(proteinKey)) {
                    br.write(getCurrentTabSpace() + "<userParam name=\"Decoy\" value=\"1\" />" + System.getProperty("line.separator"));
                } else {
                    br.write(getCurrentTabSpace() + "<userParam name=\"Decoy\" value=\"0\" />" + System.getProperty("line.separator"));
                }
                try {
                    if (spectrumCountingPreferences.getSelectedMethod() == SpectrumCountingPreferences.SpectralCountingMethod.EMPAI) {
                        writeCvTerm(new CvTerm("PSI-MS", "MS:1001905", "emPAI value", "" + identificationFeaturesGenerator.getSpectrumCounting(proteinKey)));
                    } else {
                        br.write(getCurrentTabSpace() + "<userParam name=\"NSAF+\" value=\""
                                + identificationFeaturesGenerator.getSpectrumCounting(proteinKey) + "\" />" + System.getProperty("line.separator"));
                    }
                } catch (Exception e) {
                    e.printStackTrace(); // @TODO: add better error handling
                }
                MatchValidationLevel matchValidationLevel = psmProbabilities.getMatchValidationLevel();
                if (matchValidationLevel == MatchValidationLevel.doubtful && !proteinProbabilities.getReasonDoubtful().equals("")) {
                    br.write(getCurrentTabSpace() + "<userParam name=\"Protein Validation\" value=\"" + matchValidationLevel + " (" + StringEscapeUtils.escapeHtml4(proteinProbabilities.getReasonDoubtful()) + ")" + "\" />" + System.getProperty("line.separator"));
                } else {
                    br.write(getCurrentTabSpace() + "<userParam name=\"Protein Validation\" value=\"" + matchValidationLevel + "\" />" + System.getProperty("line.separator"));
                }
View Full Code Here

Examples of eu.isas.peptideshaker.myparameters.PSParameter

        @Override
        public Object getValueAt(int row, int column) {
            try {
                String proteinKey = identification.getProteinIdentification().get(row);
                PSParameter psParameter;
                ProteinMatch proteinMatch;

                switch (column) {
                    case 0:
                        return row + 1;
                    case 1:
                        psParameter = (PSParameter) identification.getProteinMatchParameter(proteinKey, new PSParameter());
                        return psParameter.isStarred();
                    case 2:
                        psParameter = (PSParameter) identification.getProteinMatchParameter(proteinKey, new PSParameter());
                        return psParameter.isHidden();
                    case 3:
                        psParameter = (PSParameter) identification.getProteinMatchParameter(proteinKey, new PSParameter());
                        return psParameter.getProteinInferenceClass();
                    case 4:
                        proteinMatch = identification.getProteinMatch(proteinKey);
                        return proteinMatch.getMainMatch();
                    case 5:
                        String otherAccessions = "";
                        proteinMatch = identification.getProteinMatch(proteinKey);
                        for (String accession : ProteinMatch.getAccessions(proteinKey)) {
                            if (!accession.equals(proteinMatch.getMainMatch())) {
                                otherAccessions += accession + " ";
                            }
                        }
                        return otherAccessions;
                    case 6:
                        proteinMatch = identification.getProteinMatch(proteinKey);
                        return sequenceFactory.getHeader(proteinMatch.getMainMatch()).getSimpleProteinDescription().toLowerCase();
                    case 7:
                        Double coverage;
                        try {
                            HashMap<Integer, Double> sequenceCoverage;
                            try {
                                sequenceCoverage = peptideShakerGUI.getIdentificationFeaturesGenerator().getSequenceCoverage(proteinKey);
                            } catch (Exception e) {
                                peptideShakerGUI.catchException(e);
                                sequenceCoverage = new HashMap<Integer, Double>();
                            }
                            Double sequenceCoverageConfident = 100 * sequenceCoverage.get(MatchValidationLevel.confident.getIndex());
                            Double sequenceCoverageDoubtful = 100 * sequenceCoverage.get(MatchValidationLevel.doubtful.getIndex());
                            coverage = sequenceCoverageConfident + sequenceCoverageDoubtful;
                        } catch (Exception e) {
                            peptideShakerGUI.catchException(e);
                            coverage = Double.NaN;
                        }
                        return coverage;
                    case 8:
                        proteinMatch = identification.getProteinMatch(proteinKey);
                        return proteinMatch.getPeptideCount();
                    case 9:
                        proteinMatch = identification.getProteinMatch(proteinKey);
                        int cpt = 0;
                        PeptideMatch peptideMatch;
                        identification.loadPeptideMatches(proteinMatch.getPeptideMatchesKeys(), null);
                        for (String peptideKey : proteinMatch.getPeptideMatchesKeys()) {
                            peptideMatch = identification.getPeptideMatch(peptideKey);
                            cpt += peptideMatch.getSpectrumCount();
                        }
                        return cpt;
                    case 10:
                        try {
                            return peptideShakerGUI.getIdentificationFeaturesGenerator().getSpectrumCounting(proteinKey);
                        } catch (Exception e) {
                            peptideShakerGUI.catchException(e);
                            return Double.NaN;
                        }
                    case 11:
                        psParameter = (PSParameter) identification.getProteinMatchParameter(proteinKey, new PSParameter());
                        return psParameter.getProteinScore();
                    case 12:
                        psParameter = (PSParameter) identification.getProteinMatchParameter(proteinKey, new PSParameter());
                        return psParameter.getProteinConfidence();
                    default:
                        return "";
                }
            } catch (Exception e) {
                peptideShakerGUI.catchException(e);
View Full Code Here

Examples of eu.isas.peptideshaker.myparameters.PSParameter

        @Override
        public Object getValueAt(int row, int column) {
            try {
                String peptideKey = identification.getPeptideIdentification().get(row);
                PSParameter psParameter;
                PeptideMatch peptideMatch;
                switch (column) {
                    case 0:
                        return row + 1;
                    case 1:
                        psParameter = (PSParameter) identification.getPeptideMatchParameter(peptideKey, new PSParameter());
                        return psParameter.isStarred();
                    case 2:
                        psParameter = (PSParameter) identification.getPeptideMatchParameter(peptideKey, new PSParameter());
                        return psParameter.isHidden();
                    case 3:
                        psParameter = (PSParameter) identification.getPeptideMatchParameter(peptideKey, new PSParameter());
                        return psParameter.getProteinInferenceClass();
                    case 4:
                        peptideMatch = identification.getPeptideMatch(peptideKey);
                        String accessions = "";
                        for (String accession : peptideMatch.getTheoreticPeptide().getParentProteins(peptideShakerGUI.getSequenceMatchingPreferences())) {
                            accessions += accession + " ";
                        }
                        return accessions;
                    case 5:
                        peptideMatch = identification.getPeptideMatch(peptideKey);
                        String descriptions = "";
                        for (String accession : peptideMatch.getTheoreticPeptide().getParentProteins(peptideShakerGUI.getSequenceMatchingPreferences())) {
                            descriptions += sequenceFactory.getHeader(accession).getSimpleProteinDescription() + " ";
                        }
                        return descriptions;
                    case 6:
                        peptideMatch = identification.getPeptideMatch(peptideKey);
                        return peptideShakerGUI.getDisplayFeaturesGenerator().getTaggedPeptideSequence(peptideMatch, true, true, true);
                    case 7:
                        peptideMatch = identification.getPeptideMatch(peptideKey);
                        return peptideMatch.getSpectrumCount();
                    case 8:
                        psParameter = (PSParameter) identification.getPeptideMatchParameter(peptideKey, new PSParameter());
                        return psParameter.getPeptideScore();
                    case 9:
                        psParameter = (PSParameter) identification.getPeptideMatchParameter(peptideKey, new PSParameter());
                        return psParameter.getPeptideConfidence();
                    case 10:
                        return peptideKey;
                    default:
                        return "";
                }
View Full Code Here

Examples of eu.isas.peptideshaker.myparameters.PSParameter

            try {
                String spectrumKey = getSpectrumKey(row);
                if (spectrumKey == null) {
                    return "";
                }
                PSParameter psParameter;
                SpectrumMatch spectrumMatch;
                Precursor precursor;
                switch (column) {
                    case 0:
                        return row + 1;
                    case 1:
                        psParameter = (PSParameter) identification.getSpectrumMatchParameter(spectrumKey, new PSParameter());
                        return psParameter.isStarred();
                    case 2:
                        psParameter = (PSParameter) identification.getSpectrumMatchParameter(spectrumKey, new PSParameter());
                        return psParameter.isHidden();
                    case 3:
                        return Spectrum.getSpectrumFile(spectrumKey);
                    case 4:
                        return Spectrum.getSpectrumTitle(spectrumKey);
                    case 5:
                        precursor = peptideShakerGUI.getPrecursor(spectrumKey);
                        return precursor.getRt();
                    case 6:
                        precursor = peptideShakerGUI.getPrecursor(spectrumKey);
                        return precursor.getMz();
                    case 7:
                        spectrumMatch = identification.getSpectrumMatch(spectrumKey);
                        if (spectrumMatch.getBestPeptideAssumption() != null) {
                            return spectrumMatch.getBestPeptideAssumption().getIdentificationCharge().value;
                        } else if (spectrumMatch.getBestTagAssumption() != null) {
                            return spectrumMatch.getBestTagAssumption().getIdentificationCharge().value;
                        } else {
                            throw new IllegalArgumentException("No best assumption found for spectrum " + spectrumKey + ".");
                        }
                    case 8:
                        spectrumMatch = identification.getSpectrumMatch(spectrumKey);
                        precursor = peptideShakerGUI.getPrecursor(spectrumKey);
                        if (spectrumMatch.getBestPeptideAssumption() != null) {
                            return Math.abs(spectrumMatch.getBestPeptideAssumption().getDeltaMass(precursor.getMz(), peptideShakerGUI.getSearchParameters().isPrecursorAccuracyTypePpm()));
                        } else if (spectrumMatch.getBestTagAssumption() != null) {
                            return Math.abs(spectrumMatch.getBestTagAssumption().getDeltaMass(precursor.getMz(), peptideShakerGUI.getSearchParameters().isPrecursorAccuracyTypePpm()));
                        } else {
                            throw new IllegalArgumentException("No best assumption found for spectrum " + spectrumKey + ".");
                        }
                    case 9:
                        psParameter = (PSParameter) identification.getSpectrumMatchParameter(spectrumKey, new PSParameter());
                        return psParameter.getPsmConfidence();
                    default:
                        return "";
                }
            } catch (Exception e) {
                peptideShakerGUI.catchException(e);
View Full Code Here

Examples of eu.isas.peptideshaker.myparameters.PSParameter

            for (String fileName : peptideShakerGUI.getIdentification().getOrderedSpectrumFileNames()) {
                fileNames.add(fileName);
            }

            PSParameter psParameter = new PSParameter();
            DefaultCategoryDataset peptidePlotDataset = new DefaultCategoryDataset();
            DefaultCategoryDataset spectrumPlotDataset = new DefaultCategoryDataset();
            DefaultCategoryDataset intensityPlotDataset = new DefaultCategoryDataset();

            int[] selectedRows = proteinTable.getSelectedRows();

            // disable the coverage tab if more than one protein is selected
            plotsTabbedPane.setEnabledAt(2, selectedRows.length == 1);

            if (selectedRows.length > 1 && plotsTabbedPane.getSelectedIndex() == 2) {
                plotsTabbedPane.setSelectedIndex(5);
            }

            for (int row = 0; row < selectedRows.length; row++) {

                int currentRow = selectedRows[row];
                SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) proteinTable.getModel();
                int proteinIndex = tableModel.getViewIndex(currentRow);
                String proteinKey = proteinKeys.get(proteinIndex);
                ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinKey);

                try {
                    peptideKeys = peptideShakerGUI.getIdentificationFeaturesGenerator().getSortedPeptideKeys(proteinKey);
                } catch (Exception e) {
                    peptideShakerGUI.catchException(e);
                    try {
                        // Let's try without order
                        peptideKeys = proteinMatch.getPeptideMatchesKeys();
                    } catch (Exception e1) {
                        peptideShakerGUI.catchException(e1);
                        // ok you are really unlucky... Just hope the GUI holds...
                        peptideKeys = new ArrayList<String>();
                    }
                }

                // get the current protein and protein sequence
                Protein currentProtein = sequenceFactory.getProtein(proteinMatch.getMainMatch());
                String currentProteinSequence = sequenceFactory.getProtein(proteinMatch.getMainMatch()).getSequence();

                int[][] coverage = new int[fileNames.size()][currentProteinSequence.length() + 1];

                // get the chart data
                for (int i = 0; i < fileNames.size(); i++) {

                    String fraction = fileNames.get(i);

                    for (int j = 0; j < peptideKeys.size(); j++) {

                        String peptideKey = peptideKeys.get(j);

                        try {
                            psParameter = (PSParameter) peptideShakerGUI.getIdentification().getPeptideMatchParameter(peptideKey, psParameter);

                            if (psParameter.getFractions() != null && psParameter.getFractions().contains(fraction)) {
                                if (psParameter.getMatchValidationLevel().isValidated()) {

                                    String peptideSequence = Peptide.getSequence(peptideKey);

                                    boolean includePeptide = false;

                                    if (coverageShowAllPeptidesJRadioButtonMenuItem.isSelected()) {
                                        includePeptide = true;
                                    } else if (coverageShowEnzymaticPeptidesOnlyJRadioButtonMenuItem.isSelected()) {
                                        includePeptide = currentProtein.isEnzymaticPeptide(peptideSequence,
                                                peptideShakerGUI.getSearchParameters().getEnzyme(),
                                                peptideShakerGUI.getSequenceMatchingPreferences());
                                    } else if (coverageShowTruncatedPeptidesOnlyJRadioButtonMenuItem.isSelected()) {
                                        includePeptide = !currentProtein.isEnzymaticPeptide(peptideSequence,
                                                peptideShakerGUI.getSearchParameters().getEnzyme(),
                                                peptideShakerGUI.getSequenceMatchingPreferences());
                                    }

                                    if (includePeptide && selectedRows.length == 1) {

                                        AminoAcidPattern aminoAcidPattern = new AminoAcidPattern(peptideSequence);
                                        for (int startIndex : aminoAcidPattern.getIndexes(currentProteinSequence, peptideShakerGUI.getSequenceMatchingPreferences())) {
                                            int peptideTempStart = startIndex -1;
                                            int peptideTempEnd = peptideTempStart + peptideSequence.length();
                                            for (int k = peptideTempStart; k < peptideTempEnd; k++) {
                                                coverage[i][k]++;
                                            }
                                        }
                                    }
                                }
                            }
                        } catch (Exception e) {
                            peptideShakerGUI.catchException(e);
                        }
                    }
                }

                psParameter = new PSParameter();
                psParameter = (PSParameter) peptideShakerGUI.getIdentification().getProteinMatchParameter(proteinKey, psParameter);

                for (int i = 0; i < fileNames.size(); i++) {
                    String fraction = fileNames.get(i);
                    psParameter = (PSParameter) peptideShakerGUI.getIdentification().getProteinMatchParameter(proteinKey, psParameter);

                    if (selectedRows.length == 1) {
                        peptidePlotDataset.addValue(psParameter.getFractionValidatedPeptides(fraction), "Validated Peptides", "" + (i + 1));
                    } else {
                        peptidePlotDataset.addValue(psParameter.getFractionValidatedPeptides(fraction), proteinMatch.getMainMatch()
                                + ": " + sequenceFactory.getHeader(proteinMatch.getMainMatch()).getSimpleProteinDescription(), "" + (i + 1));
                    }
                }

                double longestFileName = "Fraction".length();

                // update the coverage table
                if (selectedRows.length == 1) {

                    DefaultTableModel coverageTableModel = (DefaultTableModel) coverageTable.getModel();
                    coverageTableModel.getDataVector().removeAllElements();

                    for (int i = 0; i < fileNames.size(); i++) {

                        // create the coverage plot
                        ArrayList<JSparklinesDataSeries> sparkLineDataSeriesCoverage = new ArrayList<JSparklinesDataSeries>();

                        for (int j = 0; j < currentProteinSequence.length(); j++) {

                            boolean covered = coverage[i][j] > 0;

                            int sequenceCounter = 1;

                            if (covered) {
                                while (j + 1 < coverage[0].length && coverage[i][j + 1] > 0) {
                                    sequenceCounter++;
                                    j++;
                                }
                            } else {
                                while (j + 1 < coverage[0].length && coverage[i][j + 1] == 0) {
                                    sequenceCounter++;
                                    j++;
                                }
                            }

                            ArrayList<Double> data = new ArrayList<Double>();
                            data.add(new Double(sequenceCounter));

                            JSparklinesDataSeries sparklineDataseries;

                            if (covered) {
                                sparklineDataseries = new JSparklinesDataSeries(data, peptideShakerGUI.getSparklineColor(), null);
                            } else {
                                sparklineDataseries = new JSparklinesDataSeries(data, new Color(0, 0, 0, 0), null);
                            }

                            sparkLineDataSeriesCoverage.add(sparklineDataseries);
                        }

                        ChartPanel coverageChart = new ProteinSequencePanel(Color.WHITE).getSequencePlot(this, new JSparklinesDataset(sparkLineDataSeriesCoverage),
                                new HashMap<Integer, ArrayList<ResidueAnnotation>>(), true, true);

                        ((DefaultTableModel) coverageTable.getModel()).addRow(new Object[]{(i + 1), fileNames.get(i), coverageChart});

                        if (fileNames.get(i).length() > longestFileName) {
                            longestFileName = fileNames.get(i).length();
                        }
                    }
                }

                // set the preferred size of the fraction name column in the coverage table
                Integer width = peptideShakerGUI.getPreferredColumnWidth(coverageTable, coverageTable.getColumn("Fraction").getModelIndex(), 6);

                if (width != null) {
                    coverageTable.getColumn("Fraction").setMinWidth(width);
                    coverageTable.getColumn("Fraction").setMaxWidth(width);
                } else {
                    coverageTable.getColumn("Fraction").setMinWidth(15);
                    coverageTable.getColumn("Fraction").setMaxWidth(Integer.MAX_VALUE);
                }

                // get the psms per fraction
                for (int i = 0; i < fileNames.size(); i++) {
                    String fraction = fileNames.get(i);
                    psParameter = (PSParameter) peptideShakerGUI.getIdentification().getProteinMatchParameter(proteinKey, psParameter);

                    if (selectedRows.length == 1) {
                        spectrumPlotDataset.addValue(psParameter.getFractionValidatedSpectra(fraction), "Validated Spectra", "" + (i + 1));
                        intensityPlotDataset.addValue(psParameter.getPrecursorIntensitySummedPerFraction(fraction), "Summed Intensity", "" + (i + 1));
                    } else {
                        spectrumPlotDataset.addValue(psParameter.getFractionValidatedSpectra(fraction), proteinMatch.getMainMatch()
                                + ": " + sequenceFactory.getHeader(proteinMatch.getMainMatch()).getSimpleProteinDescription(), "" + (i + 1));
                        intensityPlotDataset.addValue(psParameter.getPrecursorIntensitySummedPerFraction(fraction), proteinMatch.getMainMatch()
                                + ": " + sequenceFactory.getHeader(proteinMatch.getMainMatch()).getSimpleProteinDescription(), "" + (i + 1));
                    }
                }
            }
View Full Code Here

Examples of eu.isas.peptideshaker.myparameters.PSParameter

                String proteinMatchKey = proteinKeys.get(proteinIndex);
                ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinMatchKey);
                peptideTableMap = new HashMap<Integer, String>();

                PSParameter probabilities = new PSParameter();
                int index = 0;

                ArrayList<String> peptideKeys;
                try {
                    peptideKeys = peptideShakerGUI.getIdentificationFeaturesGenerator().getSortedPeptideKeys(proteinMatchKey);
                } catch (Exception e) {
                    peptideShakerGUI.catchException(e);
                    try {
                        // Let's try without order
                        peptideKeys = proteinMatch.getPeptideMatchesKeys();
                    } catch (Exception e1) {
                        peptideShakerGUI.catchException(e1);
                        // ok you are really unlucky... Just hope the GUI holds...
                        peptideKeys = new ArrayList<String>();
                    }
                }

                for (String peptideKey : peptideKeys) {
                    PeptideMatch currentMatch = peptideShakerGUI.getIdentification().getPeptideMatch(peptideKey);
                    probabilities = (PSParameter) peptideShakerGUI.getIdentification().getPeptideMatchParameter(peptideKey, probabilities);

                    if (!probabilities.isHidden()) {

                        // find and add the peptide start and end indexes
                        int peptideStart = 0;
                        String peptideSequence = currentMatch.getTheoreticPeptide().getSequence();

                        try {
                            String proteinAccession = proteinMatch.getMainMatch();
                            String tempProteinSequence = sequenceFactory.getProtein(proteinAccession).getSequence();
                            peptideStart = tempProteinSequence.lastIndexOf(peptideSequence) + 1; //@TODO: allow multiple start indexes and use amino acid matching
                        } catch (Exception e) {
                            peptideShakerGUI.catchException(e);
                            e.printStackTrace();
                        }
                        int proteinInferenceType = probabilities.getProteinInferenceClass();

                        // @TODO: should be replaced by a table model!!!
                        ((DefaultTableModel) peptideTable.getModel()).addRow(new Object[]{
                            index + 1,
                            probabilities.isStarred(),
                            proteinInferenceType,
                            peptideShakerGUI.getDisplayFeaturesGenerator().getTaggedPeptideSequence(currentMatch, true, true, true),
                            peptideStart,
                            false,
                            probabilities.getMatchValidationLevel().getIndex()
                        });

                        peptideTableMap.put(index + 1, currentMatch.getKey());
                        index++;
                    }
View Full Code Here

Examples of eu.isas.peptideshaker.myparameters.PSParameter

                this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

                if (column == proteinTable.getColumn("  ").getModelIndex()) {
                    try {
                        PSParameter psParameter = (PSParameter) peptideShakerGUI.getIdentification().getProteinMatchParameter(proteinKey, new PSParameter());
                        if (!psParameter.isStarred()) {
                            peptideShakerGUI.getStarHider().starProtein(proteinKey);
                        } else {
                            peptideShakerGUI.getStarHider().unStarProtein(proteinKey);
                        }
                    } catch (Exception e) {
View Full Code Here

Examples of eu.isas.peptideshaker.myparameters.PSParameter

    private void selectAllMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectAllMenuItemActionPerformed
        for (int i = 0; i < proteinTable.getRowCount(); i++) {
            proteinTable.setValueAt(true, i, proteinTable.getColumn("  ").getModelIndex());

            String key = proteinKeys.get(i);
            PSParameter psParameter = new PSParameter();
            try {
                psParameter = (PSParameter) peptideShakerGUI.getIdentification().getProteinMatchParameter(key, psParameter);
                psParameter.setStarred(true);
                peptideShakerGUI.getIdentification().updateProteinMatchParameter(key, psParameter);
            } catch (Exception e) {
                peptideShakerGUI.catchException(e);
            }
        }
View Full Code Here

Examples of eu.isas.peptideshaker.myparameters.PSParameter

    private void deselectAllMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deselectAllMenuItemActionPerformed
        for (int i = 0; i < proteinTable.getRowCount(); i++) {
            proteinTable.setValueAt(false, i, proteinTable.getColumn("  ").getModelIndex());

            String proteinKey = proteinKeys.get(i);
            PSParameter psParameter = new PSParameter();
            try {
                psParameter = (PSParameter) peptideShakerGUI.getIdentification().getProteinMatchParameter(proteinKey, psParameter);
                psParameter.setStarred(false);
                peptideShakerGUI.getIdentification().updateProteinMatchParameter(proteinKey, psParameter);
            } catch (Exception e) {
                peptideShakerGUI.catchException(e);
            }
        }
View Full Code Here

Examples of eu.isas.peptideshaker.myparameters.PSParameter

        super(parent, true);
        initComponents();
        setUpGui();

        this.matchKey = proteinMatchKey;
        psParameter = (PSParameter) identification.getProteinMatchParameter(proteinMatchKey, new PSParameter());
        this.exceptionHandler = exceptionHandler;
        this.identification = identification;
        this.identificationFeaturesGenerator = identificationFeaturesGenerator;
        this.searchParameters = searchParameters;
        this.annotationPreferences = annotationPreferences;
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.