Package eu.isas.peptideshaker.myparameters

Examples of eu.isas.peptideshaker.myparameters.PSParameter


                        writer.write("Validation" + SEPARATOR);
                        writer.write("Decoy" + SEPARATOR);

                        writer.write(System.getProperty("line.separator"));

                        PSParameter psParameter = new PSParameter();
                        int psmCounter = 0;

                        HashMap<String, ArrayList<String>> spectrumKeys = identification.getSpectrumIdentificationMap();

                        int fileCounter = 0;

                        for (String spectrumFile : spectrumKeys.keySet()) {

                            progressDialog.setTitle("Loading Spectrum Matches. Please Wait... (" + ++fileCounter + "/" + spectrumKeys.size() + ")");
                            identification.loadSpectrumMatches(spectrumKeys.get(spectrumFile), progressDialog);
                            progressDialog.setTitle("Loading Spectrum Matches Details. Please Wait... (" + fileCounter + "/" + spectrumKeys.size() + ")");
                            identification.loadSpectrumMatchParameters(spectrumKeys.get(spectrumFile), psParameter, progressDialog);
                            progressDialog.setTitle("Copying Spectrum Matches Phospho Details to File. Please Wait... (" + fileCounter + "/" + spectrumKeys.size() + ")");
                            progressDialog.setMaxPrimaryProgressCounter(spectrumKeys.get(spectrumFile).size());
                            progressDialog.setValue(0);

                            for (String psmKey : spectrumKeys.get(spectrumFile)) {

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

                                SpectrumMatch spectrumMatch = identification.getSpectrumMatch(psmKey);
                                psParameter = (PSParameter) identification.getSpectrumMatchParameter(psmKey, psParameter);
                                PeptideAssumption bestAssumption = spectrumMatch.getBestPeptideAssumption();

                                writer.write(++psmCounter + SEPARATOR);

                                String proteinAccessions = "";
                                String proteinDescriptions = "";

                                for (String protein : bestAssumption.getPeptide().getParentProteins(peptideShakerGUI.getSequenceMatchingPreferences())) {
                                    if (!proteinAccessions.equals("")) {
                                        proteinAccessions += ", ";
                                        proteinDescriptions += "; ";
                                    }
                                    proteinAccessions += protein;
                                    proteinDescriptions += sequenceFactory.getHeader(protein).getSimpleProteinDescription();
                                }
                                writer.write(proteinAccessions + SEPARATOR);
                                writer.write(proteinDescriptions + SEPARATOR);
                                String sequence = bestAssumption.getPeptide().getSequence();
                                writer.write(sequence + SEPARATOR);
                                HashMap<String, ArrayList<Integer>> modMap = new HashMap<String, ArrayList<Integer>>();
                                for (ModificationMatch modificationMatch : bestAssumption.getPeptide().getModificationMatches()) {
                                    if (modificationMatch.isVariable()) {
                                        if (!modMap.containsKey(modificationMatch.getTheoreticPtm())) {
                                            modMap.put(modificationMatch.getTheoreticPtm(), new ArrayList<Integer>());
                                        }
                                        modMap.get(modificationMatch.getTheoreticPtm()).add(modificationMatch.getModificationSite());
                                    }
                                }
                                boolean first = true, first2;
                                ArrayList<String> mods = new ArrayList<String>(modMap.keySet());
                                Collections.sort(mods);
                                for (String mod : mods) {
                                    if (first) {
                                        first = false;
                                    } else {
                                        writer.write(", ");
                                    }
                                    first2 = true;
                                    writer.write(mod + "(");
                                    for (int aa : modMap.get(mod)) {
                                        if (first2) {
                                            first2 = false;
                                        } else {
                                            writer.write(", ");
                                        }
                                        writer.write(aa + "");
                                    }
                                    writer.write(")");
                                }
                                writer.write(SEPARATOR);
                                int nPhospho = 0;
                                ArrayList<String> modList = new ArrayList<String>();
                                for (ModificationMatch modificationMatch : bestAssumption.getPeptide().getModificationMatches()) {
                                    if (modificationMatch.isVariable()) {
                                        String ptmName = modificationMatch.getTheoreticPtm();
                                        if (ptmName.contains("phospho")) {
                                            nPhospho++;
                                        }
                                        PTM refPtm = ptmFactory.getPTM(ptmName);
                                        for (String equivalentPtm : ptmProfile.getSimilarNotFixedModifications(refPtm.getMass())) {
                                            if (!modList.contains(equivalentPtm)) {
                                                modList.add(equivalentPtm);
                                            }
                                        }
                                    }
                                }

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

                                for (String mod : modList) {
                                    if (mod.contains("phospho")) {
                                        phosphoNames.add(mod);
                                        if (spectrumMatch.getUrParam(ptmScores) != null) {
                                            ptmScores = (PSPtmScores) spectrumMatch.getUrParam(new PSPtmScores());
                                            if (ptmScores != null && ptmScores.getPtmScoring(mod) != null) {
                                                PtmScoring ptmScoring = ptmScores.getPtmScoring(mod);
                                                ArrayList<Integer> sites = new ArrayList<Integer>(ptmScoring.getProbabilisticSites());
                                                Collections.sort(sites);
                                                for (Integer site : sites) {
                                                    if (probabilisticLocalizations.length() > 0) {
                                                        probabilisticLocalizations.append(", ");
                                                    }
                                                    probabilisticLocalizations.append(site.toString()).append(": ").append(ptmScoring.getProbabilisticScore(site));
                                                }
                                                sites = new ArrayList<Integer>(ptmScoring.getDSites());
                                                Collections.sort(sites);
                                                for (Integer site : sites) {
                                                    if (dLocalizations.length() > 0) {
                                                        dLocalizations.append(", ");
                                                    }
                                                    dLocalizations.append(site.toString()).append(": ").append(ptmScoring.getDeltaScore(site));
                                                }
                                            }
                                        }
                                    }
                                }
                                if (algorithms.size() == 1 && algorithms.get(0) == Advocate.mascot.getIndex()) {
                                    if (!phosphoNames.isEmpty() && spectrumMatch.hasAssumption(Advocate.mascot.getIndex())) {
                                        PeptideAssumption mascotAssumption = null;
                                        double bestScore = 0;
                                        for (ArrayList<SpectrumIdentificationAssumption> peptideAssumptionList : spectrumMatch.getAllAssumptions(Advocate.mascot.getIndex()).values()) {
                                            for (SpectrumIdentificationAssumption assumption : peptideAssumptionList) {
                                                PeptideAssumption peptideAssumption = (PeptideAssumption) assumption;
                                                MascotScore mascotScore = new MascotScore();
                                                mascotScore = (MascotScore) peptideAssumption.getUrParam(mascotScore);
                                                if (mascotScore.getScore() > bestScore) {
                                                    mascotAssumption = peptideAssumption;
                                                    bestScore = mascotScore.getScore();
                                                }
                                            }
                                        }
                                        if (mascotAssumption != null) {
                                            Peptide mascotPeptide = mascotAssumption.getPeptide();
                                            Double score = MDScore.getMDScore(spectrumMatch, mascotPeptide, phosphoNames, peptideShakerGUI.getSequenceMatchingPreferences());
                                            if (score != null) {
                                                mdScore = score.toString();
                                            }
                                            ArrayList<Integer> sites = new ArrayList<Integer>();
                                            for (ModificationMatch modificationMatch : mascotPeptide.getModificationMatches()) {
                                                if (modificationMatch.getTheoreticPtm().contains("phospho")) {
                                                    sites.add(modificationMatch.getModificationSite());
                                                }
                                            }
                                            Collections.sort(sites);
                                            for (int site : sites) {
                                                if (!mdLocation.equals("")) {
                                                    mdLocation += ", ";
                                                }
                                                mdLocation += site;
                                            }
                                        }
                                    }
                                }
                                if (ptmScoringPreferences.isProbabilitsticScoreCalculation()) {
                                    writer.write(probabilisticLocalizations + SEPARATOR);
                                }
                                writer.write(dLocalizations + SEPARATOR);
                                if (algorithms.size() == 1 && algorithms.get(0) == Advocate.mascot.getIndex()) {
                                    writer.write(mdLocation + SEPARATOR);
                                    writer.write(mdScore + SEPARATOR);
                                }
                                writer.write(nPhospho + SEPARATOR);
                                writer.write(nSites + SEPARATOR);
                                writer.write(spectrumFile + SEPARATOR);
                                writer.write(Spectrum.getSpectrumTitle(spectrumMatch.getKey()) + SEPARATOR);
                                Precursor prec = spectrumFactory.getPrecursor(spectrumMatch.getKey());
                                writer.write(prec.getMz() + SEPARATOR);
                                writer.write(bestAssumption.getIdentificationCharge().value + SEPARATOR);
                                writer.write(prec.getRt() + SEPARATOR);
                                writer.write(bestAssumption.getPeptide().getMass() + SEPARATOR);
                                writer.write(bestAssumption.getDeltaMass(prec.getMz(), peptideShakerGUI.getSearchParameters().isPrecursorAccuracyTypePpm()) + SEPARATOR);
                                writer.write(bestAssumption.getIsotopeNumber(prec.getMz()) + SEPARATOR);
                                writer.write(psParameter.getPsmConfidence() + SEPARATOR);
                                MatchValidationLevel matchValidationLevel = psParameter.getMatchValidationLevel();
                                writer.write(matchValidationLevel.toString());
                                if (matchValidationLevel == MatchValidationLevel.doubtful && !psParameter.getReasonDoubtful().equals("")) {
                                    writer.write(" (" + psParameter.getReasonDoubtful() + ")");
                                }
                                writer.write(SEPARATOR);
                                if (bestAssumption.getPeptide().isDecoy(peptideShakerGUI.getSequenceMatchingPreferences())) {
                                    writer.write(1 + SEPARATOR);
                                } else {
                                    writer.write(0 + SEPARATOR);
                                }
                                writer.write(System.getProperty("line.separator"));
                                progressDialog.increasePrimaryProgressCounter();
                            }
                        }
                        writer.close();
                        try {
                            File outputFile = new File(selectedFile.getParent(), reducedName + "_Proteins_phospho.txt");
                            writer = new BufferedWriter(new FileWriter(outputFile));
                        } catch (IOException e) {
                            JOptionPane.showMessageDialog(null, "An error occurred when saving the protein details.", "Saving Failed", JOptionPane.ERROR_MESSAGE);
                            e.printStackTrace();
                            return;
                        }

                        ArrayList<String> targetedPtms = new ArrayList<String>();
                        for (String ptm : ptmProfile.getAllNotFixedModifications()) {
                            if (ptm.contains("phospho")) {
                                targetedPtms.add(ptm);
                            }
                        }

                        writer.write(SEPARATOR);
                        writer.write("Accession" + SEPARATOR);
                        writer.write("Other Protein(s)" + SEPARATOR);
                        writer.write("Protein Inference Class" + SEPARATOR);
                        writer.write("Description" + SEPARATOR);
                        writer.write("Sequence Coverage (%)" + SEPARATOR);
                        writer.write("Observable Coverage (%)" + SEPARATOR);
                        writer.write("Confident Phosphorylation Sites" + SEPARATOR);
                        writer.write("# Confident" + SEPARATOR);
                        writer.write("Other Phosphorylation Sites" + SEPARATOR);
                        writer.write("# Other" + SEPARATOR);
                        writer.write("#Validated Peptides" + SEPARATOR);
                        writer.write("#Validated Spectra" + SEPARATOR);
                        writer.write("NSAF" + SEPARATOR);
                        writer.write("MW (kDa)" + SEPARATOR);
                        writer.write("Confidence" + SEPARATOR);
                        writer.write("Validation" + SEPARATOR);
                        writer.write("Decoy" + SEPARATOR);
                        writer.write(System.getProperty("line.separator"));

                        PSParameter proteinPSParameter = new PSParameter();
                        int proteinCounter = 0;

                        progressDialog.setTitle("Loading Protein Matches. Please Wait...");
                        identification.loadProteinMatches(progressDialog);
                        progressDialog.setTitle("Loading Protein Details. Please Wait...");
                        identification.loadProteinMatchParameters(proteinPSParameter, progressDialog);

                        progressDialog.setPrimaryProgressCounterIndeterminate(false);
                        progressDialog.setMaxPrimaryProgressCounter(identification.getProteinIdentification().size());
                        progressDialog.setValue(0);
                        progressDialog.setTitle("Copying Protein Phospho Details to File. Please Wait...");

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

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

                            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 {
View Full Code Here


                            writer.write("Retained as Main PSM" + SEPARATOR);
                            writer.write("Decoy" + SEPARATOR);
                            writer.write(System.getProperty("line.separator"));
                        }

                        PSParameter psParameter = new PSParameter();
                        int rank, progress = 0;

                        progressDialog.setPrimaryProgressCounterIndeterminate(false);
                        if (psmKeys != null) {
                            progressDialog.setMaxPrimaryProgressCounter(psmKeys.size());
                        } else {
                            progressDialog.setMaxPrimaryProgressCounter(identification.getSpectrumIdentificationSize());
                        }
                        HashMap<String, ArrayList<String>> spectrumKeys = new HashMap<String, ArrayList<String>>();
                        if (psmKeys == null) {
                            spectrumKeys = identification.getSpectrumIdentificationMap();
                        } else {
                            for (String spectrumKey : psmKeys) {
                                String spectrumFile = Spectrum.getSpectrumFile(spectrumKey);
                                if (!spectrumKeys.containsKey(spectrumFile)) {
                                    spectrumKeys.put(spectrumFile, new ArrayList<String>());
                                }
                                spectrumKeys.get(spectrumFile).add(spectrumKey);
                            }
                        }
                        for (String spectrumFile : spectrumKeys.keySet()) {
                            if (psmKeys == null) {
                                identification.loadSpectrumMatches(spectrumFile, progressDialog);
                                identification.loadSpectrumMatchParameters(spectrumFile, psParameter, progressDialog);
                            } else {
                                identification.loadSpectrumMatches(spectrumKeys.get(spectrumFile), progressDialog);
                                identification.loadSpectrumMatchParameters(spectrumKeys.get(spectrumFile), psParameter, progressDialog);
                            }
                            for (String spectrumKey : spectrumKeys.get(spectrumFile)) {

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

                                SpectrumMatch spectrumMatch = identification.getSpectrumMatch(spectrumKey);
                                psParameter = (PSParameter) identification.getSpectrumMatchParameter(spectrumKey, psParameter);

                                if (!onlyValidated || psParameter.getMatchValidationLevel().isValidated()) {
                                    for (int se : spectrumMatch.getAdvocates()) {
                                        ArrayList<Double> eValues = new ArrayList<Double>(spectrumMatch.getAllAssumptions(se).keySet());
                                        Collections.sort(eValues);
                                        rank = 1;
                                        for (double eValue : eValues) {
                                            for (SpectrumIdentificationAssumption assumption : spectrumMatch.getAllAssumptions(se).get(eValue)) {
                                                if (assumption instanceof PeptideAssumption) {
                                                    PeptideAssumption peptideAssumption = (PeptideAssumption) assumption;
                                                    writer.write(Advocate.getAdvocate(se).getName() + SEPARATOR);
                                                    writer.write(rank + SEPARATOR);
                                                    if (accession || proteinDescription) {

                                                        String proteinAccessions = "";
                                                        String proteinDescriptions = "";

                                                        boolean first = true;
                                                        for (String protein : peptideAssumption.getPeptide().getParentProteins(peptideShakerGUI.getSequenceMatchingPreferences())) {
                                                            if (first) {
                                                                first = false;
                                                            } else {
                                                                if (accession) {
                                                                    proteinAccessions += ", ";
                                                                }
                                                                if (proteinDescription) {
                                                                    proteinDescriptions += "; ";
                                                                }
                                                            }
                                                            if (accession) {
                                                                proteinAccessions += protein;
                                                            }
                                                            if (proteinDescription) {
                                                                proteinDescriptions += sequenceFactory.getHeader(protein).getSimpleProteinDescription();
                                                            }
                                                        }
                                                        if (accession) {
                                                            writer.write(proteinAccessions + SEPARATOR);
                                                        }
                                                        if (proteinDescription) {
                                                            writer.write(proteinDescriptions + SEPARATOR);
                                                        }
                                                    }
                                                    if (sequence) {
                                                        writer.write(peptideAssumption.getPeptide().getSequence() + SEPARATOR);
                                                    }
                                                    if (modifications) {
                                                        boolean first = true;
                                                        for (ModificationMatch modificationMatch : peptideAssumption.getPeptide().getModificationMatches()) {
                                                            if (modificationMatch.isVariable()) {
                                                                if (first) {
                                                                    first = false;
                                                                } else {
                                                                    writer.write(", ");
                                                                }
                                                                String modName = modificationMatch.getTheoreticPtm();
                                                                writer.write(modName + "(" + modificationMatch.getModificationSite() + ")");
                                                            }
                                                        }
                                                        writer.write(SEPARATOR);
                                                    }
                                                    if (file) {
                                                        writer.write(Spectrum.getSpectrumFile(spectrumMatch.getKey()) + SEPARATOR);
                                                    }
                                                    if (title) {
                                                        writer.write(Spectrum.getSpectrumTitle(spectrumMatch.getKey()) + SEPARATOR);
                                                    }
                                                    if (precursor) {
                                                        Precursor prec = spectrumFactory.getPrecursor(spectrumMatch.getKey());
                                                        writer.write(prec.getMz() + SEPARATOR);
                                                        writer.write(peptideAssumption.getIdentificationCharge().value + SEPARATOR);
                                                        writer.write(prec.getRt() + SEPARATOR);
                                                        writer.write(peptideAssumption.getPeptide().getMass() + SEPARATOR);
                                                        writer.write(peptideAssumption.getDeltaMass(prec.getMz(),
                                                                peptideShakerGUI.getSearchParameters().isPrecursorAccuracyTypePpm()) + SEPARATOR);
                                                        writer.write(peptideAssumption.getIsotopeNumber(prec.getMz()) + SEPARATOR);
                                                    }
                                                    if (scores) {
                                                        for (Integer advocateIndex : peptideShakerGUI.getProjectDetails().getIdentificationAlgorithms()) {
                                                            if (se == advocateIndex) {
                                                                writer.write("" + eValue);
                                                            }
                                                            writer.write(SEPARATOR);
                                                        }
                                                    }
                                                    if (confidence) {
                                                        psParameter = (PSParameter) peptideAssumption.getUrParam(psParameter);
                                                        writer.write(psParameter.getSearchEngineConfidence() + SEPARATOR);
                                                    }
                                                    if (peptideAssumption.getPeptide().isSameSequenceAndModificationStatus(spectrumMatch.getBestPeptideAssumption().getPeptide(), peptideShakerGUI.getSequenceMatchingPreferences())) {
                                                        writer.write(1 + SEPARATOR);
                                                    } else {
                                                        writer.write(0 + SEPARATOR);
View Full Code Here

                                writer.write("Starred" + SEPARATOR);
                            }
                            writer.write(System.getProperty("line.separator"));
                        }

                        PSParameter proteinPSParameter = new PSParameter();
                        PSParameter peptidePSParameter = new PSParameter();
                        int proteinCounter = 0;

                        progressDialog.setTitle("Loading Protein Matches. Please Wait...");
                        identification.loadProteinMatches(progressDialog);
                        progressDialog.setTitle("Loading Protein Details. Please Wait...");
                        identification.loadProteinMatchParameters(proteinPSParameter, progressDialog);

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

                        for (String proteinKey : proteinKeys) {

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

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

                            if (!ProteinMatch.isDecoy(proteinKey) || !onlyValidated) {
                                if ((onlyValidated && proteinPSParameter.getMatchValidationLevel().isValidated()) || !onlyValidated) {
                                    if ((!includeHidden && !proteinPSParameter.isHidden()) || includeHidden) {
                                        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);

                                                // 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());

View Full Code Here

            BufferedWriter b = new BufferedWriter(f);

            try {
                if (exportType == ExportType.non_validated) {

                    PSParameter psParameter = new PSParameter();
                    identification.loadProteinMatchParameters(psParameter, waitingHandler);

                    for (String accession : sequenceFactory.getAccessions()) {

                        if (!sequenceFactory.isDecoyAccession(accession)) {

                            ArrayList<String> matches = identification.getProteinMap().get(accession);

                            if (matches != null) {
                                boolean validated = false;
                                for (String match : matches) {
                                    psParameter = (PSParameter) identification.getProteinMatchParameter(match, psParameter);
                                    if (psParameter.getMatchValidationLevel().isValidated()) {
                                        validated = true;
                                        break;
                                    }
                                }
                                if (!validated) {
View Full Code Here

            SearchParameters searchParameters, AnnotationPreferences annotationPreferences, TargetDecoyMap targetDecoyMap, double scoreThreshold,
            double confidenceThreshold, boolean noValidated, ArrayList<ProteinFilter> doubtfulMatchFilters,
            String proteinKey) throws SQLException, IOException, ClassNotFoundException, InterruptedException, MzMLUnmarshallerException {

        SequenceFactory sequenceFactory = SequenceFactory.getInstance();
        PSParameter psParameter = new PSParameter();
        psParameter = (PSParameter) identification.getProteinMatchParameter(proteinKey, psParameter);
        psParameter.resetQcResults();

        if (!psParameter.isManualValidation()) {

            if (sequenceFactory.concatenatedTargetDecoy()) {

                if (!noValidated && psParameter.getProteinProbabilityScore() <= scoreThreshold) {
                    String reasonDoubtful = null;
                    boolean filterPassed = true;
                    for (ProteinFilter filter : doubtfulMatchFilters) {
                        boolean validation = filter.isValidated(proteinKey, identification, identificationFeaturesGenerator, searchParameters, annotationPreferences);
                        psParameter.setQcResult(filter.getName(), validation);
                        if (!validation) {
                            filterPassed = false;
                            if (reasonDoubtful == null) {
                                reasonDoubtful = "";
                            } else {
                                reasonDoubtful += ", ";
                            }
                            reasonDoubtful += filter.getDescription();
                        }
                    }
                    boolean confidenceThresholdPassed = psParameter.getProteinConfidence() >= confidenceThreshold; //@TODO: not sure whether we should include all 100% confidence hits by default?
                    if (!confidenceThresholdPassed) {
                        if (reasonDoubtful == null) {
                            reasonDoubtful = "";
                        } else {
                            reasonDoubtful += ", ";
                        }
                        reasonDoubtful += "Low confidence";
                    }
                    boolean enoughHits = targetDecoyMap.getnTargetOnly() > 100;
                    if (!enoughHits) {
                        if (reasonDoubtful == null) {
                            reasonDoubtful = "";
                        } else {
                            reasonDoubtful += ", ";
                        }
                        reasonDoubtful += "Low number of hits";
                    }
                    if (!sequenceFactory.hasEnoughSequences()) {
                        if (reasonDoubtful == null) {
                            reasonDoubtful = "";
                        } else {
                            reasonDoubtful += ", ";
                        }
                        reasonDoubtful += "Database too small";
                    }
                    if (filterPassed && confidenceThresholdPassed && enoughHits && sequenceFactory.hasEnoughSequences()) {
                        psParameter.setMatchValidationLevel(MatchValidationLevel.confident);
                    } else {
                        psParameter.setMatchValidationLevel(MatchValidationLevel.doubtful);
                        if (reasonDoubtful != null) {
                            psParameter.setReasonDoubtful(reasonDoubtful);
                        }
                    }
                } else {
                    psParameter.setMatchValidationLevel(MatchValidationLevel.not_validated);
                }
            } else {
                psParameter.setMatchValidationLevel(MatchValidationLevel.none);
            }

            identification.updateProteinMatchParameter(proteinKey, psParameter);
        }
    }
View Full Code Here

    public static void updatePeptideMatchValidationLevel(Identification identification, IdentificationFeaturesGenerator identificationFeaturesGenerator,
            SearchParameters searchParameters, PeptideSpecificMap peptideMap, String peptideKey)
            throws SQLException, IOException, ClassNotFoundException, InterruptedException, MzMLUnmarshallerException {

        SequenceFactory sequenceFactory = SequenceFactory.getInstance();
        PSParameter psParameter = new PSParameter();
        psParameter = (PSParameter) identification.getPeptideMatchParameter(peptideKey, psParameter);
        psParameter.resetQcResults();

        if (sequenceFactory.concatenatedTargetDecoy()) {
            TargetDecoyMap targetDecoyMap = peptideMap.getTargetDecoyMap(peptideMap.getCorrectedKey(psParameter.getSpecificMapKey()));
            TargetDecoyResults targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
            double peptideThreshold = targetDecoyResults.getScoreLimit();
            double confidenceThreshold = targetDecoyResults.getConfidenceLimit() + targetDecoyMap.getResolution();
            if (confidenceThreshold > 100) {
                confidenceThreshold = 100;
            }
            boolean noValidated = peptideMap.getTargetDecoyMap(peptideMap.getCorrectedKey(psParameter.getSpecificMapKey())).getTargetDecoyResults().noValidated();
            if (!noValidated && psParameter.getPeptideProbabilityScore() <= peptideThreshold) {
                String reasonDoubtful = null;
                boolean filterPassed = true;
                for (PeptideFilter filter : peptideMap.getDoubtfulMatchesFilters()) {
                    boolean validation = filter.isValidated(peptideKey, identification, identificationFeaturesGenerator);
                    psParameter.setQcResult(filter.getName(), validation);
                    if (!validation) {
                        filterPassed = false;
                        if (reasonDoubtful == null) {
                            reasonDoubtful = "";
                        } else {
                            reasonDoubtful += ", ";
                        }
                        reasonDoubtful += filter.getDescription();
                    }
                }
                boolean confidenceThresholdPassed = psParameter.getPeptideConfidence() >= confidenceThreshold; //@TODO: not sure whether we should include all 100% confidence hits by default?
                if (!confidenceThresholdPassed) {
                    if (reasonDoubtful == null) {
                        reasonDoubtful = "";
                    } else {
                        reasonDoubtful += ", ";
                    }
                    reasonDoubtful += "Low confidence";
                }
                boolean enoughHits = targetDecoyMap.getnTargetOnly() > 100;
                if (!enoughHits) {
                    if (reasonDoubtful == null) {
                        reasonDoubtful = "";
                    } else {
                        reasonDoubtful += ", ";
                    }
                    reasonDoubtful += "Low number of hits";
                }
                if (!sequenceFactory.hasEnoughSequences()) {
                    if (reasonDoubtful == null) {
                        reasonDoubtful = "";
                    } else {
                        reasonDoubtful += ", ";
                    }
                    reasonDoubtful += "Database too small";
                }
                if (filterPassed && confidenceThresholdPassed && enoughHits && sequenceFactory.hasEnoughSequences()) {
                    psParameter.setMatchValidationLevel(MatchValidationLevel.confident);
                } else {
                    psParameter.setMatchValidationLevel(MatchValidationLevel.doubtful);
                    if (reasonDoubtful != null) {
                        psParameter.setReasonDoubtful(reasonDoubtful);
                    }
                }
            } else {
                psParameter.setMatchValidationLevel(MatchValidationLevel.not_validated);
            }
        } else {
            psParameter.setMatchValidationLevel(MatchValidationLevel.none);
        }

        identification.updatePeptideMatchParameter(peptideKey, psParameter);
    }
View Full Code Here

                    return false;
                }
            }
        }

        PSParameter psParameter = new PSParameter();
        psParameter = (PSParameter) identification.getProteinMatchParameter(proteinMatchKey, psParameter);

        if (proteinFilter.getPi() != 5) {
            if (proteinFilter.getPiComparison() == ComparisonType.NOT_EQUAL
                    && psParameter.getProteinInferenceClass() == proteinFilter.getPi()) {
                return false;
            } else if (proteinFilter.getPiComparison() == ComparisonType.EQUAL
                    && psParameter.getProteinInferenceClass() != proteinFilter.getPi()) {
                return false;
            }
        }

        if (proteinFilter.getProteinScore() != null) {
            if (proteinFilter.getProteinScoreComparison() == ComparisonType.AFTER) {
                if (psParameter.getProteinScore() <= proteinFilter.getProteinScore()) {
                    return false;
                }
            } else if (proteinFilter.getProteinScoreComparison() == ComparisonType.BEFORE) {
                if (psParameter.getProteinScore() >= proteinFilter.getProteinScore()) {
                    return false;
                }
            } else if (proteinFilter.getProteinScoreComparison() == ComparisonType.EQUAL) {
                if (psParameter.getProteinScore() != proteinFilter.getProteinScore()) {
                    return false;
                }
            } else if (proteinFilter.getProteinScoreComparison() == ComparisonType.NOT_EQUAL) {
                if (psParameter.getProteinScore() == proteinFilter.getProteinScore()) {
                    return false;
                }
            }
        }

        if (proteinFilter.getProteinConfidence() != null) {
            if (proteinFilter.getProteinConfidenceComparison() == ComparisonType.AFTER) {
                if (psParameter.getProteinConfidence() <= proteinFilter.getProteinConfidence()) {
                    return false;
                }
            } else if (proteinFilter.getProteinConfidenceComparison() == ComparisonType.BEFORE) {
                if (psParameter.getProteinConfidence() >= proteinFilter.getProteinConfidence()) {
                    return false;
                }
            } else if (proteinFilter.getProteinConfidenceComparison() == ComparisonType.EQUAL) {
                if (psParameter.getProteinConfidence() != proteinFilter.getProteinConfidence()) {
                    return false;
                }
            } else if (proteinFilter.getProteinConfidenceComparison() == ComparisonType.NOT_EQUAL) {
                if (psParameter.getProteinConfidence() == proteinFilter.getProteinConfidence()) {
                    return false;
                }
            }
        }
View Full Code Here

    public static void updateSpectrumMatchValidationLevel(Identification identification, IdentificationFeaturesGenerator identificationFeaturesGenerator,
            SearchParameters searchParameters, SequenceMatchingPreferences sequenceMatchingPreferences, AnnotationPreferences annotationPreferences, PeptideSpectrumAnnotator peptideSpectrumAnnotator,
            PsmSpecificMap psmMap, String spectrumKey) throws SQLException, IOException, ClassNotFoundException, InterruptedException, MzMLUnmarshallerException {

        SequenceFactory sequenceFactory = SequenceFactory.getInstance();
        PSParameter psParameter = new PSParameter();
        psParameter = (PSParameter) identification.getSpectrumMatchParameter(spectrumKey, psParameter);
        psParameter.resetQcResults();

        if (sequenceFactory.concatenatedTargetDecoy()) {

            Integer charge = new Integer(psParameter.getSpecificMapKey());
            String fileName = Spectrum.getSpectrumFile(spectrumKey);
            TargetDecoyMap targetDecoyMap = psmMap.getTargetDecoyMap(charge, fileName);
            double psmThreshold = 0;
            double confidenceThreshold = 100;
            boolean noValidated = true;

            if (targetDecoyMap != null) {
                TargetDecoyResults targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
                psmThreshold = targetDecoyResults.getScoreLimit();
                confidenceThreshold = targetDecoyResults.getConfidenceLimit() + targetDecoyMap.getResolution();
                if (confidenceThreshold > 100) {
                    confidenceThreshold = 100;
                }
                noValidated = targetDecoyResults.noValidated();
            }

            if (!noValidated && psParameter.getPsmProbabilityScore() <= psmThreshold) {

                String spectrumFile = Spectrum.getSpectrumFile(spectrumKey);
                SpectrumMatch spectrumMatch = identification.getSpectrumMatch(spectrumKey);
                if (spectrumMatch.getBestPeptideAssumption() != null) {
                    // update the annotation preferences for the new psm, mainly the charge
                    annotationPreferences.setCurrentSettings(spectrumMatch.getBestPeptideAssumption(), true, sequenceMatchingPreferences);
                } else if (spectrumMatch.getBestTagAssumption() != null) {
                    charge = spectrumMatch.getBestTagAssumption().getIdentificationCharge().value;
                } else {
                    throw new IllegalArgumentException("No best tag or peptide found for spectrum " + spectrumKey);
                }

                String reasonDoubtful = null;
                boolean filterPassed = true;

                for (PsmFilter filter : psmMap.getDoubtfulMatchesFilters(charge, spectrumFile)) {
                    boolean validated = filter.isValidated(spectrumKey, identification, searchParameters, annotationPreferences, peptideSpectrumAnnotator);
                    psParameter.setQcResult(filter.getName(), validated);
                    if (!validated) {
                        if (filter.getName().toLowerCase().contains("deviation")) {
                            filter.isValidated(spectrumKey, identification, searchParameters, annotationPreferences, peptideSpectrumAnnotator);
                        } else if (filter.getName().toLowerCase().contains("coverage")) {
                            filter.isValidated(spectrumKey, identification, searchParameters, annotationPreferences, peptideSpectrumAnnotator);
                        }
                        filterPassed = false;
                        if (reasonDoubtful == null) {
                            reasonDoubtful = "";
                        } else {
                            reasonDoubtful += ", ";
                        }
                        reasonDoubtful += filter.getDescription();
                    }
                }

                boolean confidenceThresholdPassed = psParameter.getPsmConfidence() >= confidenceThreshold; //@TODO: not sure whether we should include all 100% confidence hits by default?

                if (!confidenceThresholdPassed) {
                    if (reasonDoubtful == null) {
                        reasonDoubtful = "";
                    } else {
                        reasonDoubtful += ", ";
                    }
                    reasonDoubtful += "Low confidence";
                }

                boolean enoughHits = targetDecoyMap.getnTargetOnly() > 100;

                if (!enoughHits) {
                    if (reasonDoubtful == null) {
                        reasonDoubtful = "";
                    } else {
                        reasonDoubtful += ", ";
                    }
                    reasonDoubtful += "Low number of hits";
                }

                if (!sequenceFactory.hasEnoughSequences()) {
                    if (reasonDoubtful == null) {
                        reasonDoubtful = "";
                    } else {
                        reasonDoubtful += ", ";
                    }
                    reasonDoubtful += "Database too small";
                }

                if (filterPassed && confidenceThresholdPassed && enoughHits && sequenceFactory.hasEnoughSequences()) {
                    psParameter.setMatchValidationLevel(MatchValidationLevel.confident);
                } else {
                    psParameter.setMatchValidationLevel(MatchValidationLevel.doubtful);
                    if (reasonDoubtful != null) {
                        psParameter.setReasonDoubtful(reasonDoubtful);
                    }
                }
            } else {
                psParameter.setMatchValidationLevel(MatchValidationLevel.not_validated);
            }
        } else {
            psParameter.setMatchValidationLevel(MatchValidationLevel.none);
        }

        identification.updateSpectrumMatchParameter(spectrumKey, psParameter);
    }
View Full Code Here

    public static void updateTagAssumptionValidationLevel(IdentificationFeaturesGenerator identificationFeaturesGenerator, SearchParameters searchParameters,
            AnnotationPreferences annotationPreferences, InputMap inputMap, String spectrumKey, TagAssumption tagAssumption)
            throws SQLException, IOException, ClassNotFoundException, InterruptedException, MzMLUnmarshallerException {

        SequenceFactory sequenceFactory = SequenceFactory.getInstance();
        PSParameter psParameter = new PSParameter();
        psParameter = (PSParameter) tagAssumption.getUrParam(psParameter);

        if (sequenceFactory.concatenatedTargetDecoy()) {

            TargetDecoyMap targetDecoyMap = inputMap.getTargetDecoyMap(tagAssumption.getAdvocate());
            TargetDecoyResults targetDecoyResults = targetDecoyMap.getTargetDecoyResults();
            double seThreshold = targetDecoyResults.getScoreLimit();
            double confidenceThreshold = targetDecoyResults.getConfidenceLimit() + targetDecoyMap.getResolution();

            if (confidenceThreshold > 100) {
                confidenceThreshold = 100;
            }

            boolean noValidated = targetDecoyResults.noValidated();

            if (!noValidated && tagAssumption.getScore() <= seThreshold) { //@TODO: include ascending/descending scores

                String reasonDoubtful = null;
                boolean filterPassed = true;

                //TODO: implement tag quality filters
//                for (AssumptionFilter filter : inputMap.getDoubtfulMatchesFilters()) {
//                    boolean validated = filter.isValidated(spectrumKey, peptideAssumption, searchParameters, annotationPreferences);
//                    psParameter.setQcResult(filter.getName(), validated);
//                    if (!validated) {
//                        filterPassed = false;
//                        if (reasonDoubtful == null) {
//                            reasonDoubtful = "";
//                        } else {
//                            reasonDoubtful += ", ";
//                        }
//                        reasonDoubtful += filter.getDescription();
//                    }
//                }
                boolean confidenceThresholdPassed = psParameter.getSearchEngineConfidence() >= confidenceThreshold; //@TODO: not sure whether we should include all 100% confidence hits by default?

                if (!confidenceThresholdPassed) {
                    if (reasonDoubtful == null) {
                        reasonDoubtful = "";
                    } else {
                        reasonDoubtful += ", ";
                    }
                    reasonDoubtful += "Low confidence";
                }

                boolean enoughHits = targetDecoyMap.getnTargetOnly() > 100;

                if (!enoughHits) {
                    if (reasonDoubtful == null) {
                        reasonDoubtful = "";
                    } else {
                        reasonDoubtful += ", ";
                    }
                    reasonDoubtful += "Low number of hits";
                }

                if (!sequenceFactory.hasEnoughSequences()) {
                    if (reasonDoubtful == null) {
                        reasonDoubtful = "";
                    } else {
                        reasonDoubtful += ", ";
                    }
                    reasonDoubtful += "Database too small";
                }

                if (filterPassed && confidenceThresholdPassed && enoughHits && sequenceFactory.hasEnoughSequences()) {
                    psParameter.setMatchValidationLevel(MatchValidationLevel.confident);
                } else {
                    psParameter.setMatchValidationLevel(MatchValidationLevel.doubtful);
                    if (reasonDoubtful != null) {
                        psParameter.setReasonDoubtful(reasonDoubtful);
                    }
                }
            } else {
                psParameter.setMatchValidationLevel(MatchValidationLevel.not_validated);
            }
        } else {
            psParameter.setMatchValidationLevel(MatchValidationLevel.none);
        }
    }
View Full Code Here

        waitingHandler.resetPrimaryProgressCounter();
        waitingHandler.setMaxPrimaryProgressCounter(6);
        waitingHandler.increasePrimaryProgressCounter();

        // Batch load data
        PSParameter psParameter = new PSParameter();
        for (String spectrumFile : identification.getOrderedSpectrumFileNames()) {
            identification.loadSpectrumMatches(spectrumFile, null);
            identification.loadSpectrumMatchParameters(spectrumFile, psParameter, null);
        }
View Full Code Here

TOP

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

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.