Package com.compomics.util.experiment.identification.matches

Examples of com.compomics.util.experiment.identification.matches.ProteinMatch


                        if (proteinKey.contains(protein)) {
                            candidate = true;
                        }
                    }
                    if (candidate) {
                        ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinKey);
                        if (proteins.contains(proteinMatch.getMainMatch())) {
                            try {
                                ptmScorer.scorePTMs(identification, proteinMatch, peptideShakerGUI.getSearchParameters(), peptideShakerGUI.getAnnotationPreferences(), false, peptideShakerGUI.getPtmScoringPreferences(), peptideShakerGUI.getSequenceMatchingPreferences());
                            } catch (Exception e) {
                                peptideShakerGUI.catchException(e);
                            }
View Full Code Here


                    ArrayList<String> exported = new ArrayList<String>();

                    for (String matchKey : identificationFeaturesGenerator.getValidatedProteins(waitingHandler, filterPreferences)) {
                        ArrayList<String> accessions = new ArrayList<String>();
                        if (exportType == ExportType.validated_main_accession) {
                            ProteinMatch proteinMatch = identification.getProteinMatch(matchKey);
                            accessions.add(proteinMatch.getMainMatch());
                        } else if (exportType == ExportType.validated_all_accessions) {
                            accessions.addAll(Arrays.asList(ProteinMatch.getAccessions(matchKey)));
                        }
                        for (String accession : accessions) {
                            if (!exported.contains(accession)) {
View Full Code Here

                || proteinFilter.getProteinNSpectra() != null
                || proteinFilter.getProteinNValidatedSpectra() != null
                || proteinFilter.getProteinNConfidentSpectra() != null
                || proteinFilter.getProteinCoverage() != null
                || proteinFilter.getSpectrumCounting() != null) {
            ProteinMatch proteinMatch = identification.getProteinMatch(proteinMatchKey);

            if (proteinFilter.getnPeptides() != null) {
                if (proteinFilter.getnPeptidesComparison() == ComparisonType.AFTER) {
                    if (proteinMatch.getPeptideMatchesKeys().size() <= proteinFilter.getnPeptides()) {
                        return false;
                    }
                } else if (proteinFilter.getnPeptidesComparison() == ComparisonType.BEFORE) {
                    if (proteinMatch.getPeptideMatchesKeys().size() >= proteinFilter.getnPeptides()) {
                        return false;
                    }
                } else if (proteinFilter.getnPeptidesComparison() == ComparisonType.EQUAL) {
                    if (proteinMatch.getPeptideMatchesKeys().size() != proteinFilter.getnPeptides()) {
                        return false;
                    }
                } else if (proteinFilter.getnPeptidesComparison() == ComparisonType.NOT_EQUAL) {
                    if (proteinMatch.getPeptideMatchesKeys().size() == proteinFilter.getnPeptides()) {
                        return false;
                    }
                }
            }
View Full Code Here

                                        if ((onlyStarred && proteinPSParameter.isStarred()) || !onlyStarred) {
                                            if (indexes) {
                                                writer.write(++proteinCounter + SEPARATOR);
                                            }

                                            ProteinMatch proteinMatch = identification.getProteinMatch(proteinKey);
                                            if (mainAccession) {
                                                writer.write(proteinMatch.getMainMatch() + SEPARATOR);
                                            }
                                            if (createMaximalProteinSet && !maximalProteinSet.contains(proteinMatch.getMainMatch())) {
                                                maximalProteinSet.add(proteinMatch.getMainMatch());
                                            }
                                            if (createMaximalProteinSet || otherAccessions) {
                                                boolean first = true;

                                                // sort so that the protein accessions always come in the same order
                                                ArrayList<String> allProteins = proteinMatch.getTheoreticProteinsAccessions();
                                                Collections.sort(allProteins);
                                                StringBuilder completeProteinGroup = new StringBuilder();

                                                for (String otherProtein : allProteins) {
                                                    if (otherAccessions && !otherProtein.equalsIgnoreCase(proteinMatch.getMainMatch())) {
                                                        if (first) {
                                                            first = false;
                                                        } else {
                                                            writer.write(", ");
                                                        }
                                                        writer.write(otherProtein);
                                                    }
                                                    if (createMaximalProteinSet && !maximalProteinSet.contains(otherProtein)) {
                                                        maximalProteinSet.add(otherProtein);
                                                    }

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

                                                    completeProteinGroup.append(otherProtein);
                                                }

                                                if (otherAccessions) {
                                                    writer.write(SEPARATOR);
                                                    writer.write(completeProteinGroup.toString());
                                                    writer.write(SEPARATOR);
                                                }
                                            }
                                            if (piDetails) {
                                                writer.write(proteinPSParameter.getProteinInferenceClassAsString() + SEPARATOR);
                                            }
                                            if (description) {
                                                try {
                                                    writer.write(sequenceFactory.getHeader(proteinMatch.getMainMatch()).getSimpleProteinDescription() + SEPARATOR);
                                                } catch (Exception e) {
                                                    writer.write("error: " + e.getLocalizedMessage() + SEPARATOR);
                                                }
                                            }

                                            // gene name and chromosome number
                                            String tempGeneName = null;
                                            if (geneName || chromosomeNumber) {
                                                tempGeneName = sequenceFactory.getHeader(proteinMatch.getMainMatch()).getGeneName();
                                            }
                                            if (geneName) {
                                                if (tempGeneName != null && !identification.getProteinMatch(proteinKey).isDecoy()) {
                                                    writer.write(tempGeneName);
                                                }
                                                writer.write(SEPARATOR);
                                            }
                                            if (chromosomeNumber) {
                                                String chromosomeNumber = geneFactory.getChromosomeForGeneName(tempGeneName);
                                                if (chromosomeNumber != null && !identification.getProteinMatch(proteinKey).isDecoy()) {
                                                    writer.write(chromosomeNumber);
                                                }
                                                writer.write(SEPARATOR);
                                            }

                                            if (sequenceCoverage) {
                                                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());
                                                    Double validatedCoverage = sequenceCoverageConfident + sequenceCoverageDoubtful;
                                                    writer.write(validatedCoverage + SEPARATOR);
                                                    writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getObservableCoverage(proteinKey) * 100 + SEPARATOR);
                                                } catch (Exception e) {
                                                    writer.write("error: " + e.getLocalizedMessage() + SEPARATOR);
                                                }
                                            }
                                            if (showNonEnzymaticPeptidesColumn) {

                                                ArrayList<String> peptideKeys = proteinMatch.getPeptideMatchesKeys();
                                                Protein currentProtein = sequenceFactory.getProtein(proteinMatch.getMainMatch());
                                                boolean allPeptidesEnzymatic = true;

                                                identification.loadPeptideMatches(peptideKeys, null);
                                                identification.loadPeptideMatchParameters(peptideKeys, peptidePSParameter, null);

                                                // see if we have non-tryptic peptides
                                                for (String peptideKey : peptideKeys) {

                                                    String peptideSequence = identification.getPeptideMatch(peptideKey).getTheoreticPeptide().getSequence();
                                                    peptidePSParameter = (PSParameter) identification.getPeptideMatchParameter(peptideKey, peptidePSParameter);

                                                    if (peptidePSParameter.getMatchValidationLevel().isValidated()) {

                                                        boolean isEnzymatic = currentProtein.isEnzymaticPeptide(peptideSequence,
                                                                peptideShakerGUI.getSearchParameters().getEnzyme(),
                                                                peptideShakerGUI.getSequenceMatchingPreferences());

                                                        if (!isEnzymatic) {
                                                            allPeptidesEnzymatic = false;
                                                            break;
                                                        }
                                                    }
                                                }

                                                writer.write(!allPeptidesEnzymatic + SEPARATOR);
                                            }
                                            if (ptmSummary) {
                                                try {
                                                    writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getConfidentPtmSites(proteinKey) + SEPARATOR);
                                                    writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getAmbiguousPtmSites(proteinKey) + SEPARATOR);
                                                } catch (Exception e) {
                                                    writer.write("error: " + e.getLocalizedMessage() + SEPARATOR);
                                                }
                                            }

                                            if (nPeptides) {
                                                try {
                                                    writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getNValidatedPeptides(proteinKey) + SEPARATOR);
                                                } catch (Exception e) {
                                                    peptideShakerGUI.catchException(e);
                                                    writer.write(Double.NaN + SEPARATOR);
                                                }
                                            }
                                            if (nSpectra) {
                                                try {
                                                    writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getNValidatedSpectra(proteinKey) + SEPARATOR);
                                                } catch (Exception e) {
                                                    peptideShakerGUI.catchException(e);
                                                    writer.write(Double.NaN + SEPARATOR);
                                                }
                                            }
                                            if (emPAI) {
                                                try {
                                                    writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getSpectrumCounting(proteinKey,
                                                            SpectrumCountingPreferences.SpectralCountingMethod.EMPAI) + SEPARATOR);
                                                } catch (Exception e) {
                                                    writer.write("error: " + e.getLocalizedMessage() + SEPARATOR);
                                                }
                                            }
                                            if (nsaf) {
                                                try {
                                                    writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getSpectrumCounting(proteinKey,
                                                            SpectrumCountingPreferences.SpectralCountingMethod.NSAF) + SEPARATOR);
                                                } catch (Exception e) {
                                                    writer.write("error: " + e.getLocalizedMessage() + SEPARATOR);
                                                }
                                            }
                                            if (mw) {
                                                Double proteinMW = sequenceFactory.computeMolecularWeight(proteinMatch.getMainMatch());
                                                writer.write(proteinMW + SEPARATOR);
                                            }
                                            if (score) {
                                                writer.write(proteinPSParameter.getProteinScore() + SEPARATOR);
                                            }
View Full Code Here

        createProteinHeader();

        for (String proteinKey : proteinKeys) {

            // get the protein match
            ProteinMatch proteinMatch = identification.getProteinMatch(proteinKey);

            // insert the protein details
            insertProteinDetails(proteinMatch.getMainMatch());

            // create peptide header row
            createPeptideHeader();

            // batch load the peptides
            identification.loadPeptideMatches(proteinMatch.getPeptideMatchesKeys(), null);

            int proteinStartRow = currentRow;

            // print the peptide details
            for (String peptideKey : proteinMatch.getPeptideMatchesKeys()) {

                // insert peptide data
                insertPeptideData(peptideKey);

                if (waitingHandler.isRunCanceled()) {
View Full Code Here

                        PSParameter peptidePSParameter = new PSParameter();
                        PSParameter secondaryPSParameter = new PSParameter();
                        int peptideCounter = 0;
                        HashMap<String, HashMap<Integer, String[]>> surroundingAAs = new HashMap<String, HashMap<Integer, String[]>>();
                        ProteinMatch proteinMatch = null;
                        ModificationProfile ptmProfile = peptideShakerGUI.getSearchParameters().getModificationProfile();

                        // @TODO: try to batch load the spectra? as this would speed up the export...
                        progressDialog.setTitle("Loading Peptide Matches. Please Wait...");
                        identification.loadPeptideMatches(progressDialog);
                        progressDialog.setTitle("Loading Peptide Details. Please Wait...");
                        identification.loadPeptideMatchParameters(peptidePSParameter, progressDialog);

                        progressDialog.setPrimaryProgressCounterIndeterminate(false);
                        progressDialog.setMaxPrimaryProgressCounter(peptideKeys.size());
                        progressDialog.setValue(0);
                        progressDialog.setTitle("Copying to File. Please Wait...");

                        for (String peptideKey : peptideKeys) {

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

                            boolean shared = false;
                            PeptideMatch peptideMatch = identification.getPeptideMatch(peptideKey);
                            peptidePSParameter = (PSParameter) identification.getPeptideMatchParameter(peptideKey, peptidePSParameter);

                            if (!peptideMatch.getTheoreticPeptide().isDecoy(peptideShakerGUI.getSequenceMatchingPreferences()) || !onlyValidated) {
                                if ((onlyValidated && peptidePSParameter.getMatchValidationLevel().isValidated()) || !onlyValidated) {
                                    if ((!includeHidden && !peptidePSParameter.isHidden()) || includeHidden) {
                                        if ((onlyStarred && peptidePSParameter.isStarred()) || !onlyStarred) {

                                            Peptide peptide = peptideMatch.getTheoreticPeptide();
                                            ArrayList<String> possibleProteins = new ArrayList<String>();
                                            ArrayList<String> orderedProteinsKeys = new ArrayList<String>(); // @TODO: could be merged with one of the other maps perhaps?

                                            if (accession || proteinDescription || surroundings || location || uniqueOnly) {
                                                if (proteinKey == null) {
                                                    for (String parentProtein : peptide.getParentProteins(peptideShakerGUI.getSequenceMatchingPreferences())) {
                                                        ArrayList<String> parentProteins = identification.getProteinMap().get(parentProtein);
                                                        if (parentProteins != null) {
                                                            for (String proteinKey : parentProteins) {
                                                                if (!possibleProteins.contains(proteinKey)) {
                                                                    try {
                                                                        proteinMatch = identification.getProteinMatch(proteinKey);
                                                                        if (proteinMatch.getPeptideMatchesKeys().contains(peptideKey)) {
                                                                            possibleProteins.add(proteinKey);
                                                                        }
                                                                    } catch (Exception e) {
                                                                        // protein deleted due to protein inference issue and not deleted from the map in versions earlier than 0.14.6
                                                                        System.out.println("Non-existing protein key in protein map: " + proteinKey);
                                                                        e.printStackTrace();
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                    shared = possibleProteins.size() > 1;
                                                    proteinMatch = identification.getProteinMatch(possibleProteins.get(0));
                                                } else {
                                                    proteinMatch = identification.getProteinMatch(proteinKey);
                                                }
                                            }

                                            if (shared && uniqueOnly) {
                                                // these will be ignored as the user requested unique only
                                            } else {

                                                if (indexes) {
                                                    writer.write(++peptideCounter + SEPARATOR);
                                                }

                                                if (accession || proteinDescription) {
                                                    String mainMatch, secondaryProteins = "", peptideProteins = "";
                                                    String mainMatchDescription, secondaryProteinsDescriptions = "", peptideProteinDescriptions = "";
                                                    ArrayList<String> accessions = new ArrayList<String>();

                                                    mainMatch = proteinMatch.getMainMatch();
                                                    mainMatchDescription = sequenceFactory.getHeader(mainMatch).getSimpleProteinDescription();
                                                    boolean first = true;

                                                    if (!shared) {
                                                        orderedProteinsKeys.add(mainMatch);
                                                    }

                                                    accessions.addAll(proteinMatch.getTheoreticProteinsAccessions());
                                                    Collections.sort(accessions);
                                                    for (String key : accessions) {
                                                        if (!key.equals(mainMatch)) {
                                                            if (first) {
                                                                first = false;
                                                            } else {
                                                                secondaryProteins += "; ";
                                                                secondaryProteinsDescriptions += "; ";
                                                            }
                                                            secondaryProteins += key;
                                                            secondaryProteinsDescriptions += sequenceFactory.getHeader(key).getSimpleProteinDescription();
                                                            orderedProteinsKeys.add(key);
                                                        }
                                                    }

                                                    if (shared) {
                                                        mainMatch = "shared peptide";
                                                        mainMatchDescription = "shared peptide";
                                                    }

                                                    first = true;
                                                    ArrayList<String> peptideAccessions = new ArrayList<String>(peptide.getParentProteins(peptideShakerGUI.getSequenceMatchingPreferences()));
                                                    Collections.sort(peptideAccessions);
                                                    for (String key : peptideAccessions) {
                                                        if (shared || !accessions.contains(key)) {
                                                            if (first) {
                                                                first = false;
                                                            } else {
                                                                peptideProteins += "; ";
                                                                peptideProteinDescriptions += "; ";
                                                            }
                                                            peptideProteins += key;
                                                            peptideProteinDescriptions += sequenceFactory.getHeader(key).getSimpleProteinDescription();
                                                            orderedProteinsKeys.add(key);
                                                        }
                                                    }

                                                    if (accession) {
                                                        writer.write(mainMatch + SEPARATOR);
                                                        writer.write(secondaryProteins + SEPARATOR);
                                                        writer.write(peptideProteins + SEPARATOR);
                                                    }
                                                    if (proteinDescription) {
                                                        writer.write(mainMatchDescription + SEPARATOR);
                                                        writer.write(secondaryProteinsDescriptions + SEPARATOR);
                                                        writer.write(peptideProteinDescriptions + SEPARATOR);
                                                    }
                                                }

                                                if (proteinInferenceType) {
                                                    writer.write(peptidePSParameter.getProteinInferenceClassAsString() + SEPARATOR);
                                                }

                                                if (location || surroundings) {
                                                    for (String proteinAccession : orderedProteinsKeys) {
                                                        surroundingAAs.put(proteinAccession,
                                                                sequenceFactory.getProtein(proteinAccession).getSurroundingAA(peptide.getSequence(),
                                                                        peptideShakerGUI.getDisplayPreferences().getnAASurroundingPeptides(),
                                                                        peptideShakerGUI.getSequenceMatchingPreferences()));
                                                    }
                                                }

                                                if (surroundings) {

                                                    String subSequence = "";

                                                    for (String proteinAccession : orderedProteinsKeys) {
                                                        ArrayList<Integer> starts = new ArrayList<Integer>(surroundingAAs.get(proteinAccession).keySet());
                                                        Collections.sort(starts);
                                                        boolean first = true;
                                                        for (int start : starts) {
                                                            if (first) {
                                                                first = false;
                                                            } else {
                                                                subSequence += ", ";
                                                            }
                                                            subSequence += surroundingAAs.get(proteinAccession).get(start)[0];
                                                        }

                                                        subSequence += "; ";
                                                    }

                                                    subSequence = subSequence.substring(0, subSequence.length() - 1);

                                                    writer.write(subSequence + SEPARATOR);
                                                }

                                                if (sequence) {
                                                    writer.write(peptide.getSequence() + SEPARATOR);
                                                    writer.write(peptide.getTaggedModifiedSequence(peptideShakerGUI.getSearchParameters().getModificationProfile(),
                                                            false, false, true) + SEPARATOR);
                                                }

                                                if (surroundings) {

                                                    String subSequence = "";

                                                    for (String proteinAccession : orderedProteinsKeys) {
                                                        ArrayList<Integer> starts = new ArrayList<Integer>(surroundingAAs.get(proteinAccession).keySet());
                                                        Collections.sort(starts);
                                                        boolean first = true;
                                                        for (int start : starts) {
                                                            if (first) {
                                                                first = false;
                                                            } else {
                                                                subSequence += ", ";
                                                            }
                                                            subSequence += surroundingAAs.get(proteinAccession).get(start)[1];
                                                        }
                                                        subSequence += "; ";
                                                    }

                                                    subSequence = subSequence.substring(0, subSequence.length() - 1);

                                                    writer.write(subSequence + SEPARATOR);
                                                }

                                                if (enzymatic) {
                                                    boolean isEnzymatic = sequenceFactory.getProtein(proteinMatch.getMainMatch()).isEnzymaticPeptide(peptide.getSequence(),
                                                            peptideShakerGUI.getSearchParameters().getEnzyme(), peptideShakerGUI.getSequenceMatchingPreferences());

                                                    writer.write(isEnzymatic + SEPARATOR);
                                                }
View Full Code Here

                            proteinPSParameter = (PSParameter) identification.getProteinMatchParameter(proteinKey, proteinPSParameter);

                            writer.write(++proteinCounter + SEPARATOR);

                            ProteinMatch proteinMatch = identification.getProteinMatch(proteinKey);
                            String accession = proteinMatch.getMainMatch();
                            writer.write(accession + SEPARATOR);
                            boolean first = true;
                            for (String otherProtein : proteinMatch.getTheoreticProteinsAccessions()) {
                                if (!otherProtein.equals(accession)) {
                                    if (first) {
                                        first = false;
                                    } else {
                                        writer.write(", ");
                                    }
                                    writer.write(otherProtein);
                                }
                            }
                            writer.write(SEPARATOR);
                            writer.write(proteinPSParameter.getProteinInferenceClassAsString() + SEPARATOR);
                            try {
                                writer.write(sequenceFactory.getHeader(proteinMatch.getMainMatch()).getSimpleProteinDescription() + SEPARATOR);
                            } catch (Exception e) {
                                writer.write("error: " + e.getLocalizedMessage() + SEPARATOR);
                            }

                            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());
                                Double validatedCoverage = sequenceCoverageConfident + sequenceCoverageDoubtful;
                                writer.write(validatedCoverage + SEPARATOR);
                            } catch (Exception e) {
                                writer.write("error: " + e.getLocalizedMessage() + SEPARATOR);
                            }
                            try {
                                writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getObservableCoverage(proteinKey) * 100 + SEPARATOR);
                            } catch (Exception e) {
                                writer.write("error: " + e.getLocalizedMessage() + SEPARATOR);
                            }
                            try {
                                writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getConfidentPtmSites(proteinKey, targetedPtms) + SEPARATOR);
                            } catch (Exception e) {
                                writer.write("error: " + e.getLocalizedMessage() + SEPARATOR);
                            }
                            try {
                                writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getAmbiguousPtmSites(proteinKey, targetedPtms) + SEPARATOR);
                            } catch (Exception e) {
                                writer.write("error: " + e.getLocalizedMessage() + SEPARATOR);
                            }
                            try {
                                writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getNValidatedPeptides(proteinKey) + SEPARATOR);
                            } catch (Exception e) {
                                peptideShakerGUI.catchException(e);
                                writer.write(Double.NaN + SEPARATOR);
                            }
                            try {
                                writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getNValidatedSpectra(proteinKey) + SEPARATOR);
                            } catch (Exception e) {
                                peptideShakerGUI.catchException(e);
                                writer.write(Double.NaN + SEPARATOR);
                            }
                            try {
                                writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getSpectrumCounting(proteinKey,
                                        SpectrumCountingPreferences.SpectralCountingMethod.NSAF) + SEPARATOR);
                            } catch (Exception e) {
                                writer.write("error: " + e.getLocalizedMessage() + SEPARATOR);
                            }
                            try {
                                Double proteinMW = sequenceFactory.computeMolecularWeight(proteinMatch.getMainMatch());
                                writer.write(proteinMW + SEPARATOR);
                            } catch (Exception e) {
                                writer.write("error: " + e.getLocalizedMessage() + SEPARATOR);
                            }
                            writer.write(proteinPSParameter.getProteinConfidence() + SEPARATOR);
                            MatchValidationLevel matchValidationLevel = proteinPSParameter.getMatchValidationLevel();
                            writer.write(matchValidationLevel.toString());
                            if (matchValidationLevel == MatchValidationLevel.doubtful && !proteinPSParameter.getReasonDoubtful().equals("")) {
                                writer.write(" (" + proteinPSParameter.getReasonDoubtful() + ")");
                            }
                            writer.write(SEPARATOR);
                            if (proteinMatch.isDecoy()) {
                                writer.write(1 + SEPARATOR);
                            } else {
                                writer.write(0 + SEPARATOR);
                            }
                            writer.newLine();
View Full Code Here

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

                        ProteinMatch proteinMatch = identification.getProteinMatch(proteinKey);
                        boolean peptideSurvived = false;

                        identification.loadPeptideMatches(proteinMatch.getPeptideMatchesKeys(), null);
                        identification.loadPeptideMatchParameters(proteinMatch.getPeptideMatchesKeys(), psParameter, null);

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

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

                            PeptideMatch peptideMatch = identification.getPeptideMatch(peptideKey);
                            boolean psmSurvived = false;

                            identification.loadSpectrumMatchParameters(peptideMatch.getSpectrumMatches(), psParameter, null);

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

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

                                psParameter = (PSParameter) identification.getSpectrumMatchParameter(spectrumKey, psParameter);

                                if (isPsmHidden(spectrumKey)) {
                                    psParameter.setHidden(true);
                                } else {
                                    psParameter.setHidden(false);
                                    psmSurvived = true;
                                }

                                psParameter.setStarred(isPsmStarred(spectrumKey));
                                identification.updateSpectrumMatchParameter(spectrumKey, psParameter);
                            }

                            psParameter = (PSParameter) identification.getPeptideMatchParameter(peptideKey, psParameter);

                            if (!psmSurvived) {
                                psParameter.setHidden(true);
                            } else if (isPeptideHidden(peptideKey)) {
                                psParameter.setHidden(true);
                            } else {
                                psParameter.setHidden(false);
                                peptideSurvived = true;
                            }

                            psParameter.setStarred(isPeptideStarred(peptideKey));

                            identification.updatePeptideMatchParameter(peptideKey, psParameter);
                        }

                        psParameter = (PSParameter) identification.getProteinMatchParameter(proteinKey, psParameter);

                        if (!peptideSurvived) {
                            psParameter.setHidden(true);
                        } else {
                            psParameter.setHidden(isProteinHidden(proteinKey));
                        }

                        psParameter.setStarred(isProteinStarred(proteinKey));

                        identification.updateProteinMatchParameter(proteinKey, psParameter);


                        // update the observed fractional molecular weights per fraction
                        if (!psParameter.isHidden() && psParameter.getMatchValidationLevel().isValidated() && !proteinMatch.isDecoy()) {

                            Double proteinMW = sequenceFactory.computeMolecularWeight(proteinMatch.getMainMatch());

                            for (String fraction : psParameter.getFractions()) {

                                // set the fraction molecular weights
                                if (psParameter.getFractionConfidence(fraction) > peptideShakerGUI.getProcessingPreferences().getProteinConfidenceMwPlots()) {
View Full Code Here

                                        if ((onlyStarred && proteinPSParameter.isStarred()) || !onlyStarred) {
                                            if (indexes) {
                                                writer.write(++proteinCounter + SEPARATOR);
                                            }

                                            ProteinMatch proteinMatch = identification.getProteinMatch(proteinKey);
                                            if (mainAccession) {
                                                writer.write(proteinMatch.getMainMatch() + SEPARATOR);
                                            }
                                            if (otherAccessions) {
                                                boolean first = true;
                                                for (String otherProtein : proteinMatch.getTheoreticProteinsAccessions()) {
                                                    if (!otherProtein.equals(proteinMatch.getMainMatch())) {
                                                        if (first) {
                                                            first = false;
                                                        } else {
                                                            writer.write(", ");
                                                        }
                                                        writer.write(otherProtein);
                                                    }
                                                }
                                                writer.write(SEPARATOR);
                                            }
                                            if (piDetails) {
                                                writer.write(proteinPSParameter.getProteinInferenceClassAsString() + SEPARATOR);
                                            }
                                            if (description) {
                                                try {
                                                    writer.write(sequenceFactory.getHeader(proteinMatch.getMainMatch()).getSimpleProteinDescription() + SEPARATOR);
                                                } catch (Exception e) {
                                                    writer.write("error: " + e.getLocalizedMessage() + SEPARATOR);
                                                }
                                            }
                                            if (mw) {
                                                Double proteinMW = sequenceFactory.computeMolecularWeight(proteinMatch.getMainMatch());
                                                writer.write(proteinMW + SEPARATOR);
                                            }
                                            if (nPeptides) {
                                                try {
                                                    writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getNValidatedPeptides(proteinKey) + SEPARATOR);
                                                } catch (Exception e) {
                                                    peptideShakerGUI.catchException(e);
                                                    writer.write(Double.NaN + SEPARATOR);
                                                }
                                            }
                                            if (nSpectra) {
                                                try {
                                                    writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getNValidatedSpectra(proteinKey) + SEPARATOR);
                                                } catch (Exception e) {
                                                    peptideShakerGUI.catchException(e);
                                                    writer.write(Double.NaN + SEPARATOR);
                                                }
                                            }
                                            if (sequenceCoverage) {
                                                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());
                                                    Double validatedCoverage = sequenceCoverageConfident + sequenceCoverageDoubtful;
                                                    writer.write(validatedCoverage + SEPARATOR);
                                                    writer.write(peptideShakerGUI.getIdentificationFeaturesGenerator().getObservableCoverage(proteinKey) * 100 + SEPARATOR);
                                                } catch (Exception e) {
                                                    writer.write("error: " + e.getLocalizedMessage() + SEPARATOR);
                                                }
                                            }

                                            if (nPeptidesPerFraction) {
                                                for (String fraction : fractionFileNames) {
                                                    if (proteinPSParameter.getFractions() != null && proteinPSParameter.getFractions().contains(fraction)
                                                            && proteinPSParameter.getFractionValidatedPeptides(fraction) != null) {
                                                        writer.write(proteinPSParameter.getFractionValidatedPeptides(fraction) + SEPARATOR);
                                                    } else {
                                                        writer.write("0.0" + SEPARATOR);
                                                    }
                                                }
                                            }
                                            if (nSpectraPerFraction) {
                                                for (String fraction : fractionFileNames) {
                                                    if (proteinPSParameter.getFractions() != null && proteinPSParameter.getFractions().contains(fraction)
                                                            && proteinPSParameter.getFractionValidatedSpectra(fraction) != null) {
                                                        writer.write(proteinPSParameter.getFractionValidatedSpectra(fraction) + SEPARATOR);
                                                    } else {
                                                        writer.write("0.0" + SEPARATOR);
                                                    }
                                                }
                                            }
                                            if (precursorIntensities) {
                                                for (String fraction : fractionFileNames) {
                                                    if (proteinPSParameter.getFractions() != null && proteinPSParameter.getFractions().contains(fraction)
                                                            && proteinPSParameter.getPrecursorIntensityAveragePerFraction(fraction) != null) {
                                                        writer.write(proteinPSParameter.getPrecursorIntensityAveragePerFraction(fraction) + SEPARATOR);
                                                    } else {
                                                        writer.write("0.0" + SEPARATOR);
                                                    }
                                                }
                                            }
                                            if (fractionSpread) {

                                                double maxMwRangePeptides = Double.MIN_VALUE;
                                                double minMwRangePeptides = Double.MAX_VALUE;

                                                for (String fraction : fractionFileNames) {
                                                    if (proteinPSParameter.getFractions() != null && proteinPSParameter.getFractions().contains(fraction)
                                                            && proteinPSParameter.getFractionValidatedPeptides(fraction) != null
                                                            && proteinPSParameter.getFractionValidatedPeptides(fraction) > 0) {

                                                        HashMap<String, XYDataPoint> expectedMolecularWeightRanges
                                                                = peptideShakerGUI.getSearchParameters().getFractionMolecularWeightRanges();

                                                        if (expectedMolecularWeightRanges != null && expectedMolecularWeightRanges.get(fraction) != null) {

                                                            double lower = expectedMolecularWeightRanges.get(fraction).getX();
                                                            double upper = expectedMolecularWeightRanges.get(fraction).getY();

                                                            if (lower < minMwRangePeptides) {
                                                                minMwRangePeptides = lower;
                                                            }
                                                            if (upper > maxMwRangePeptides) {
                                                                maxMwRangePeptides = upper;
                                                            }
                                                        }
                                                    }
                                                }

                                                if (maxMwRangePeptides != Double.MIN_VALUE && minMwRangePeptides != Double.MAX_VALUE) {
                                                    writer.write(minMwRangePeptides + SEPARATOR + maxMwRangePeptides + SEPARATOR);
                                                } else {
                                                    writer.write("N/A" + SEPARATOR + "N/A" + SEPARATOR);
                                                }

                                                double maxMwRangeSpectra = Double.MIN_VALUE;
                                                double minMwRangeSpectra = Double.MAX_VALUE;

                                                for (String fraction : fractionFileNames) {
                                                    if (proteinPSParameter.getFractions() != null && proteinPSParameter.getFractions().contains(fraction)
                                                            && proteinPSParameter.getFractionValidatedSpectra(fraction) != null
                                                            && proteinPSParameter.getFractionValidatedSpectra(fraction) > 0) {

                                                        HashMap<String, XYDataPoint> expectedMolecularWeightRanges
                                                                = peptideShakerGUI.getSearchParameters().getFractionMolecularWeightRanges();

                                                        if (expectedMolecularWeightRanges != null && expectedMolecularWeightRanges.get(fraction) != null) {

                                                            double lower = expectedMolecularWeightRanges.get(fraction).getX();
                                                            double upper = expectedMolecularWeightRanges.get(fraction).getY();

                                                            if (lower < minMwRangeSpectra) {
                                                                minMwRangeSpectra = lower;
                                                            }
                                                            if (upper > maxMwRangeSpectra) {
                                                                maxMwRangeSpectra = upper;
                                                            }
                                                        }
                                                    }
                                                }

                                                if (maxMwRangeSpectra != Double.MIN_VALUE && minMwRangeSpectra != Double.MAX_VALUE) {
                                                    writer.write(minMwRangeSpectra + SEPARATOR + maxMwRangeSpectra + SEPARATOR);
                                                } else {
                                                    writer.write("N/A" + SEPARATOR + "N/A" + SEPARATOR);
                                                }
                                            }
                                            if (showNonEnzymaticPeptidesColumn) {

                                                ArrayList<String> peptideKeys = proteinMatch.getPeptideMatchesKeys();
                                                Protein currentProtein = sequenceFactory.getProtein(proteinMatch.getMainMatch());
                                                boolean allPeptidesEnzymatic = true;

                                                identification.loadPeptideMatches(peptideKeys, null);
                                                identification.loadPeptideMatchParameters(peptideKeys, peptidePSParameter, null);

View Full Code Here

            }
        }

        String minimalKey = null;
        if (keys.size() > 1) {
            ProteinMatch match = identification.getProteinMatch(sharedKey);
            HashMap<String, Integer> preferenceReason = new HashMap<String, Integer>();
            for (String key1 : keys) {
                for (String accession1 : ProteinMatch.getAccessions(key1)) {
                    if (minimalKey == null) {
                        preferenceReason = new HashMap<String, Integer>();
View Full Code Here

TOP

Related Classes of com.compomics.util.experiment.identification.matches.ProteinMatch

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.