Search in sources :

Example 1 with SpectrumMatchesIterator

use of com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator in project peptide-shaker by compomics.

the class QCPanel method getPsmDataset.

/**
 * Returns the dataset to use for the PSM QC plot.
 */
private void getPsmDataset() {
    progressDialog.setPrimaryProgressCounterIndeterminate(false);
    progressDialog.setMaxPrimaryProgressCounter(peptideShakerGUI.getIdentification().getSpectrumIdentificationSize());
    progressDialog.setValue(0);
    maxValue = Double.MIN_VALUE;
    if (psmPrecursorMassErrorJRadioButton.isSelected()) {
        // values for the precursor mass deviation
        validatedValues = new ArrayList<>();
        validatedDoubtfulValues = new ArrayList<>();
        nonValidatedValues = new ArrayList<>();
        validatedDecoyValues = new ArrayList<>();
        nonValidatedDecoyValues = new ArrayList<>();
        SpectrumMatchesIterator psmIterator = peptideShakerGUI.getIdentification().getSpectrumMatchesIterator(progressDialog);
        SpectrumMatch spectrumMatch;
        while ((spectrumMatch = psmIterator.next()) != null) {
            if (progressDialog.isRunCanceled()) {
                break;
            }
            PSParameter psmParameter = (PSParameter) spectrumMatch.getUrParam(PSParameter.dummy);
            if (!psmParameter.getHidden() && spectrumMatch.getBestPeptideAssumption() != null) {
                String spectrumFile = spectrumMatch.getSpectrumFile();
                String spectrumTitle = spectrumMatch.getSpectrumTitle();
                double precursorMz = peptideShakerGUI.getSpectrumProvider().getPrecursorMz(spectrumFile, spectrumTitle);
                SearchParameters searchParameters = peptideShakerGUI.getIdentificationParameters().getSearchParameters();
                double value = spectrumMatch.getBestPeptideAssumption().getDeltaMz(precursorMz, searchParameters.isPrecursorAccuracyTypePpm(), searchParameters.getMinIsotopicCorrection(), searchParameters.getMaxIsotopicCorrection());
                if (value > maxValue) {
                    maxValue = value;
                }
                if (!PeptideUtils.isDecoy(spectrumMatch.getBestPeptideAssumption().getPeptide(), peptideShakerGUI.getSequenceProvider())) {
                    if (psmParameter.getMatchValidationLevel().isValidated()) {
                        if (psmParameter.getMatchValidationLevel() == MatchValidationLevel.confident) {
                            validatedValues.add(value);
                        } else {
                            validatedDoubtfulValues.add(value);
                        }
                    } else {
                        nonValidatedValues.add(value);
                    }
                } else if (psmParameter.getMatchValidationLevel().isValidated()) {
                    validatedDecoyValues.add(value);
                } else {
                    nonValidatedDecoyValues.add(value);
                }
            }
            progressDialog.increasePrimaryProgressCounter();
        }
    } else if (psmPrecursorChargeJRadioButton.isSelected()) {
        // values for the precursor charge
        validatedValues = new ArrayList<>();
        validatedDoubtfulValues = new ArrayList<>();
        nonValidatedValues = new ArrayList<>();
        validatedDecoyValues = new ArrayList<>();
        nonValidatedDecoyValues = new ArrayList<>();
        SpectrumMatchesIterator psmIterator = peptideShakerGUI.getIdentification().getSpectrumMatchesIterator(progressDialog);
        SpectrumMatch spectrumMatch;
        while ((spectrumMatch = psmIterator.next()) != null) {
            if (progressDialog.isRunCanceled()) {
                break;
            }
            PSParameter psmParameter = (PSParameter) spectrumMatch.getUrParam(PSParameter.dummy);
            if (!psmParameter.getHidden() && spectrumMatch.getBestPeptideAssumption() != null) {
                double value = spectrumMatch.getBestPeptideAssumption().getIdentificationCharge();
                if (value > maxValue) {
                    maxValue = value;
                }
                if (!PeptideUtils.isDecoy(spectrumMatch.getBestPeptideAssumption().getPeptide(), peptideShakerGUI.getSequenceProvider())) {
                    if (psmParameter.getMatchValidationLevel().isValidated()) {
                        if (psmParameter.getMatchValidationLevel() == MatchValidationLevel.confident) {
                            validatedValues.add(value);
                        } else {
                            validatedDoubtfulValues.add(value);
                        }
                    } else {
                        nonValidatedValues.add(value);
                    }
                } else if (psmParameter.getMatchValidationLevel().isValidated()) {
                    validatedDecoyValues.add(value);
                } else {
                    nonValidatedDecoyValues.add(value);
                }
            }
            progressDialog.increasePrimaryProgressCounter();
        }
    }
}
Also used : SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) ArrayList(java.util.ArrayList) SpectrumMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter)

Example 2 with SpectrumMatchesIterator

use of com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator in project peptide-shaker by compomics.

the class PsmScorer method estimateIntermediateScores.

/**
 * Scores the PSMs contained in an identification object.
 *
 * @param identification the object containing the identification matches
 * @param inputMap the input map scores
 * @param processingParameters the processing preferences
 * @param identificationParameters identification parameters used
 * @param waitingHandler the handler displaying feedback to the user
 * @param exceptionHandler a handler for exceptions
 *
 * @throws java.lang.InterruptedException exception thrown if a thread is
 * interrupted
 * @throws java.util.concurrent.TimeoutException exception thrown if the
 * process times out
 */
public void estimateIntermediateScores(Identification identification, InputMap inputMap, ProcessingParameters processingParameters, IdentificationParameters identificationParameters, WaitingHandler waitingHandler, ExceptionHandler exceptionHandler) throws InterruptedException, TimeoutException {
    // Remove the intensity filter during scoring
    AnnotationParameters annotationSettings = identificationParameters.getAnnotationParameters();
    double intensityThreshold = annotationSettings.getAnnotationIntensityLimit();
    annotationSettings.setIntensityLimit(0);
    waitingHandler.setWaitingText("Scoring PSMs. Please Wait...");
    waitingHandler.setSecondaryProgressCounterIndeterminate(false);
    waitingHandler.setMaxSecondaryProgressCounter(identification.getSpectrumIdentificationSize());
    ExecutorService pool = Executors.newFixedThreadPool(processingParameters.getnThreads());
    SpectrumMatchesIterator psmIterator = identification.getSpectrumMatchesIterator(null);
    ArrayList<PsmScorerRunnable> psmScorerRunnables = new ArrayList<>(processingParameters.getnThreads());
    for (int i = 1; i <= processingParameters.getnThreads() && !waitingHandler.isRunCanceled(); i++) {
        PsmScorerRunnable runnable = new PsmScorerRunnable(psmIterator, identification, inputMap, identificationParameters, waitingHandler, exceptionHandler);
        psmScorerRunnables.add(runnable);
        pool.submit(runnable);
    }
    if (waitingHandler.isRunCanceled()) {
        pool.shutdownNow();
        return;
    }
    pool.shutdown();
    if (!pool.awaitTermination(identification.getSpectrumIdentificationSize(), TimeUnit.MINUTES)) {
        throw new TimeoutException("PSM scoring timed out. Please contact the developers.");
    }
    ArrayList<HashMap<Double, Integer>> aHistograms = new ArrayList<>(processingParameters.getnThreads());
    ArrayList<HashMap<Double, Integer>> bHistograms = new ArrayList<>(processingParameters.getnThreads());
    HashMap<Long, ArrayList<Integer>> missingValuesMap = new HashMap<>();
    for (PsmScorerRunnable runnable : psmScorerRunnables) {
        HashMap<Long, ArrayList<Integer>> currentMissingValuesMap = runnable.getMissingEValues();
        missingValuesMap.putAll(currentMissingValuesMap);
        HyperScore hyperScore = runnable.getHyperScore();
        aHistograms.add(hyperScore.getAs());
        bHistograms.add(hyperScore.getBs());
    }
    if (!missingValuesMap.isEmpty()) {
        HashMap<Double, Integer> aHistogram = HistogramUtils.mergeHistograms(aHistograms);
        HashMap<Double, Integer> bHistogram = HistogramUtils.mergeHistograms(bHistograms);
        double defaultA = aHistogram.isEmpty() ? Double.NaN : HistogramUtils.getMedianValue(aHistogram);
        double defaultB = bHistogram.isEmpty() ? Double.NaN : HistogramUtils.getMedianValue(bHistogram);
        long[] spectrumKeys = missingValuesMap.keySet().stream().mapToLong(Long::longValue).toArray();
        psmIterator = identification.getSpectrumMatchesIterator(spectrumKeys, null);
        pool = Executors.newFixedThreadPool(processingParameters.getnThreads());
        for (int i = 1; i <= processingParameters.getnThreads() && !waitingHandler.isRunCanceled(); i++) {
            MissingEValueEstimatorRunnable runnable = new MissingEValueEstimatorRunnable(missingValuesMap, defaultA, defaultB, psmIterator, inputMap, identificationParameters, waitingHandler, exceptionHandler);
            pool.submit(runnable);
        }
        if (waitingHandler.isRunCanceled()) {
            pool.shutdownNow();
            return;
        }
        pool.shutdown();
        if (!pool.awaitTermination(identification.getSpectrumIdentificationSize(), TimeUnit.MINUTES)) {
            throw new TimeoutException("PSM scoring timed out. Please contact the developers.");
        }
    }
    waitingHandler.setSecondaryProgressCounterIndeterminate(true);
    // Restaure intensity threshold
    annotationSettings.setIntensityLimit(intensityThreshold);
}
Also used : HyperScore(com.compomics.util.experiment.identification.psm_scoring.psm_scores.HyperScore) HashMap(java.util.HashMap) SpecificAnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.SpecificAnnotationParameters) AnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters) ArrayList(java.util.ArrayList) SpectrumMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator) ExecutorService(java.util.concurrent.ExecutorService) TimeoutException(java.util.concurrent.TimeoutException)

Example 3 with SpectrumMatchesIterator

use of com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator in project peptide-shaker by compomics.

the class PsmScorer method scorePsms.

/**
 * Attaches a score to the PSMs.
 *
 * @param identification the object containing the identification matches
 * @param inputMap the input map scores
 * @param processingPreferences the processing preferences
 * @param identificationParameters the identification parameters
 * @param waitingHandler the handler displaying feedback to the user
 */
public void scorePsms(Identification identification, InputMap inputMap, ProcessingParameters processingPreferences, IdentificationParameters identificationParameters, WaitingHandler waitingHandler) {
    waitingHandler.setSecondaryProgressCounterIndeterminate(false);
    waitingHandler.setMaxSecondaryProgressCounter(identification.getSpectrumIdentificationSize());
    PsmScoringParameters psmScoringPreferences = identificationParameters.getPsmScoringParameters();
    PSParameter psParameter = new PSParameter();
    SpectrumMatchesIterator psmIterator = identification.getSpectrumMatchesIterator(waitingHandler);
    SpectrumMatch spectrumMatch;
    while ((spectrumMatch = psmIterator.next()) != null) {
        String spectrumFile = spectrumMatch.getSpectrumFile();
        HashMap<Integer, TreeMap<Double, ArrayList<PeptideAssumption>>> assumptions = spectrumMatch.getPeptideAssumptionsMap();
        for (Entry<Integer, TreeMap<Double, ArrayList<PeptideAssumption>>> entry1 : assumptions.entrySet()) {
            int advocateIndex = entry1.getKey();
            if (psmScoringPreferences.isScoringNeeded(advocateIndex)) {
                HashSet<Integer> scoresForAdvocate = psmScoringPreferences.getScoreForAlgorithm(advocateIndex);
                if (!scoresForAdvocate.isEmpty()) {
                    TreeMap<Double, ArrayList<PeptideAssumption>> advocateAssumptions = entry1.getValue();
                    for (double eValue : advocateAssumptions.keySet()) {
                        for (SpectrumIdentificationAssumption assumption : advocateAssumptions.get(eValue)) {
                            if (assumption instanceof PeptideAssumption) {
                                psParameter = (PSParameter) assumption.getUrParam(psParameter);
                                double score = 1.0;
                                if (scoresForAdvocate.size() == 1 || !fastaParameters.isTargetDecoy()) {
                                    score = psParameter.getIntermediateScore(scoresForAdvocate.iterator().next());
                                } else {
                                    for (int scoreIndex : scoresForAdvocate) {
                                        TargetDecoyMap targetDecoyMap = inputMap.getIntermediateScoreMap(spectrumFile, advocateIndex, scoreIndex);
                                        Double intermediateScore = psParameter.getIntermediateScore(scoreIndex);
                                        if (intermediateScore != null) {
                                            double p = targetDecoyMap.getProbability(intermediateScore);
                                            score *= (1.0 - p);
                                        }
                                    }
                                    score = 1 - score;
                                }
                                assumption.setScore(score);
                                PeptideAssumption peptideAssumption = (PeptideAssumption) assumption;
                                Peptide peptide = peptideAssumption.getPeptide();
                                boolean decoy = PeptideUtils.isDecoy(peptide, sequenceProvider);
                                inputMap.addEntry(advocateIndex, spectrumFile, assumption.getScore(), decoy);
                            }
                        }
                    }
                }
            }
        }
        if (waitingHandler.isRunCanceled()) {
            return;
        }
        waitingHandler.increaseSecondaryProgressCounter();
        identification.updateObject(spectrumMatch.getKey(), spectrumMatch);
    }
    waitingHandler.setSecondaryProgressCounterIndeterminate(true);
}
Also used : ArrayList(java.util.ArrayList) SpectrumIdentificationAssumption(com.compomics.util.experiment.identification.SpectrumIdentificationAssumption) TreeMap(java.util.TreeMap) SpectrumMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator) TargetDecoyMap(eu.isas.peptideshaker.scoring.targetdecoy.TargetDecoyMap) PsmScoringParameters(com.compomics.util.parameters.identification.advanced.PsmScoringParameters) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter)

Example 4 with SpectrumMatchesIterator

use of com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator in project peptide-shaker by compomics.

the class PsIdentificationAlgorithmMatchesSection method writeSection.

/**
 * Writes the desired section. Exports all algorithm assumptions including
 * the decoy and non-validated matches.
 *
 * @param identification The identification of the project.
 * @param identificationFeaturesGenerator The identification features
 * generator of the project.
 * @param sequenceProvider The sequence provider.
 * @param proteinDetailsProvider The protein details provider.
 * @param spectrumProvider The spectrum provider.
 * @param identificationParameters The identification parameters.
 * @param keys The keys of the spectrum matches to output.
 * @param linePrefix The line prefix.
 * @param nSurroundingAA The number of surrounding amino acids to export.
 * @param waitingHandler The waiting handler.
 *
 * @throws IOException exception thrown whenever an error occurred while
 * interacting with a file
 */
public void writeSection(Identification identification, IdentificationFeaturesGenerator identificationFeaturesGenerator, SequenceProvider sequenceProvider, ProteinDetailsProvider proteinDetailsProvider, SpectrumProvider spectrumProvider, IdentificationParameters identificationParameters, long[] keys, String linePrefix, int nSurroundingAA, WaitingHandler waitingHandler) throws IOException {
    if (waitingHandler != null) {
        waitingHandler.setSecondaryProgressCounterIndeterminate(true);
    }
    if (header) {
        writeHeader();
    }
    PSParameter psParameter = new PSParameter();
    int line = 1;
    int totalSize = identification.getNumber(SpectrumMatch.class);
    if (waitingHandler != null) {
        waitingHandler.setWaitingText("Exporting. Please Wait...");
        waitingHandler.resetSecondaryProgressCounter();
        waitingHandler.setMaxSecondaryProgressCounter(totalSize);
    }
    SpectrumMatchesIterator psmIterator = identification.getSpectrumMatchesIterator(waitingHandler);
    SpectrumMatch spectrumMatch;
    while ((spectrumMatch = psmIterator.next()) != null) {
        if (waitingHandler != null) {
            if (waitingHandler.isRunCanceled()) {
                return;
            }
            waitingHandler.increaseSecondaryProgressCounter();
        }
        HashMap<Integer, TreeMap<Double, ArrayList<PeptideAssumption>>> peptideAssumptions = spectrumMatch.getPeptideAssumptionsMap();
        for (int advocateId : peptideAssumptions.keySet()) {
            TreeMap<Double, ArrayList<PeptideAssumption>> advocateAssumptions = peptideAssumptions.get(advocateId);
            ArrayList<Double> scores = new ArrayList<>(advocateAssumptions.keySet());
            Collections.sort(scores);
            for (double score : scores) {
                for (SpectrumIdentificationAssumption assumption : advocateAssumptions.get(score)) {
                    boolean firstFeature = true;
                    if (indexes) {
                        if (linePrefix != null) {
                            writer.write(linePrefix);
                        }
                        writer.write(Integer.toString(line));
                        firstFeature = false;
                    }
                    for (PsIdentificationAlgorithmMatchesFeature identificationAlgorithmMatchesFeature : matchExportFeatures) {
                        if (!firstFeature) {
                            writer.addSeparator();
                        } else {
                            firstFeature = false;
                        }
                        psParameter = (PSParameter) assumption.getUrParam(psParameter);
                        PeptideAssumption peptideAssumption = (PeptideAssumption) assumption;
                        String feature = getPeptideAssumptionFeature(identification, identificationFeaturesGenerator, sequenceProvider, proteinDetailsProvider, spectrumProvider, identificationParameters, linePrefix, nSurroundingAA, peptideAssumption, spectrumMatch.getSpectrumFile(), spectrumMatch.getSpectrumTitle(), psParameter, identificationAlgorithmMatchesFeature, waitingHandler);
                        writer.write(feature);
                    }
                    writer.addSeparator();
                    if (fragmentSection != null) {
                        String fractionPrefix = "";
                        if (linePrefix != null) {
                            fractionPrefix += linePrefix;
                        }
                        fractionPrefix += line + ".";
                        fragmentSection.writeSection(spectrumMatch.getSpectrumFile(), spectrumMatch.getSpectrumTitle(), assumption, sequenceProvider, spectrumProvider, identificationParameters, fractionPrefix, null);
                    }
                    line++;
                    writer.newLine();
                }
            }
        }
        HashMap<Integer, TreeMap<Double, ArrayList<TagAssumption>>> tagAssumptions = spectrumMatch.getTagAssumptionsMap();
        for (int advocateId : tagAssumptions.keySet()) {
            TreeMap<Double, ArrayList<TagAssumption>> advocateAssumptions = tagAssumptions.get(advocateId);
            ArrayList<Double> scores = new ArrayList<>(advocateAssumptions.keySet());
            Collections.sort(scores);
            for (double score : scores) {
                for (SpectrumIdentificationAssumption assumption : advocateAssumptions.get(score)) {
                    boolean firstFeature = true;
                    if (indexes) {
                        if (linePrefix != null) {
                            writer.write(linePrefix);
                        }
                        writer.write(Integer.toString(line));
                        firstFeature = false;
                    }
                    for (PsIdentificationAlgorithmMatchesFeature identificationAlgorithmMatchesFeature : matchExportFeatures) {
                        if (!firstFeature) {
                            writer.addSeparator();
                        } else {
                            firstFeature = false;
                        }
                        psParameter = (PSParameter) assumption.getUrParam(psParameter);
                        TagAssumption tagAssumption = (TagAssumption) assumption;
                        String feature = getTagAssumptionFeature(identification, identificationFeaturesGenerator, spectrumProvider, identificationParameters, linePrefix, tagAssumption, spectrumMatch.getSpectrumFile(), spectrumMatch.getSpectrumTitle(), psParameter, identificationAlgorithmMatchesFeature, waitingHandler);
                        writer.write(feature);
                    }
                    writer.addSeparator();
                    if (fragmentSection != null) {
                        String fractionPrefix = "";
                        if (linePrefix != null) {
                            fractionPrefix += linePrefix;
                        }
                        fractionPrefix += line + ".";
                        fragmentSection.writeSection(spectrumMatch.getSpectrumFile(), spectrumMatch.getSpectrumTitle(), assumption, sequenceProvider, spectrumProvider, identificationParameters, fractionPrefix, null);
                    }
                    line++;
                    writer.newLine();
                }
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) SpectrumIdentificationAssumption(com.compomics.util.experiment.identification.SpectrumIdentificationAssumption) PsIdentificationAlgorithmMatchesFeature(com.compomics.util.io.export.features.peptideshaker.PsIdentificationAlgorithmMatchesFeature) TreeMap(java.util.TreeMap) SpectrumMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator) TagAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.TagAssumption) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter)

Example 5 with SpectrumMatchesIterator

use of com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator in project peptide-shaker by compomics.

the class PsPsmSection method writeSection.

/**
 * Writes the desired section.
 *
 * @param identification The identification of the project.
 * @param identificationFeaturesGenerator The identification features
 * generator of the project.
 * @param sequenceProvider The sequence provider.
 * @param proteinDetailsProvider The protein details provider.
 * @param spectrumProvider The spectrum provider.
 * @param identificationParameters The identification parameters.
 * @param keys The keys of the PSM matches to output.
 * @param linePrefix The line prefix.
 * @param nSurroundingAA The number of surrounding amino acids to export.
 * @param validatedOnly Whether only validated matches should be exported.
 * @param decoys Whether decoy matches should be exported as well.
 * @param waitingHandler The waiting handler.
 *
 * @throws java.io.IOException exception thrown if an error occurred while
 * writing to the file.
 */
public void writeSection(Identification identification, IdentificationFeaturesGenerator identificationFeaturesGenerator, SequenceProvider sequenceProvider, ProteinDetailsProvider proteinDetailsProvider, SpectrumProvider spectrumProvider, IdentificationParameters identificationParameters, long[] keys, String linePrefix, int nSurroundingAA, boolean validatedOnly, boolean decoys, WaitingHandler waitingHandler) throws IOException {
    if (waitingHandler != null) {
        waitingHandler.setSecondaryProgressCounterIndeterminate(true);
    }
    if (header) {
        writeHeader();
    }
    int line = 1;
    int totalSize = identification.getNumber(SpectrumMatch.class);
    if (waitingHandler != null) {
        waitingHandler.setWaitingText("Exporting. Please Wait...");
        waitingHandler.resetSecondaryProgressCounter();
        waitingHandler.setMaxSecondaryProgressCounter(totalSize);
    }
    SpectrumMatchesIterator psmIterator = identification.getSpectrumMatchesIterator(keys, waitingHandler);
    SpectrumMatch spectrumMatch;
    while ((spectrumMatch = psmIterator.next()) != null) {
        if (waitingHandler != null) {
            if (waitingHandler.isRunCanceled()) {
                return;
            }
            waitingHandler.increaseSecondaryProgressCounter();
        }
        String spectrumFile = spectrumMatch.getSpectrumFile();
        String spectrumTitle = spectrumMatch.getSpectrumTitle();
        PSParameter psParameter = (PSParameter) spectrumMatch.getUrParam(PSParameter.dummy);
        if (!validatedOnly || psParameter.getMatchValidationLevel().isValidated()) {
            PeptideAssumption peptideAssumption = spectrumMatch.getBestPeptideAssumption();
            TagAssumption tagAssumption = spectrumMatch.getBestTagAssumption();
            if (peptideAssumption != null || tagAssumption != null) {
                if (decoys || (peptideAssumption != null && !PeptideUtils.isDecoy(peptideAssumption.getPeptide(), sequenceProvider)) || // @TODO: check whether the tag is a decoy..?
                (tagAssumption != null)) {
                    boolean first = true;
                    if (indexes) {
                        if (linePrefix != null) {
                            writer.write(linePrefix);
                        }
                        writer.write(Integer.toString(line));
                        first = false;
                    }
                    for (PsIdentificationAlgorithmMatchesFeature identificationAlgorithmMatchesFeature : identificationAlgorithmMatchesFeatures) {
                        if (!first) {
                            writer.addSeparator();
                        } else {
                            first = false;
                        }
                        String feature;
                        if (peptideAssumption != null) {
                            feature = PsIdentificationAlgorithmMatchesSection.getPeptideAssumptionFeature(identification, identificationFeaturesGenerator, sequenceProvider, proteinDetailsProvider, spectrumProvider, identificationParameters, linePrefix, nSurroundingAA, peptideAssumption, spectrumFile, spectrumTitle, psParameter, identificationAlgorithmMatchesFeature, waitingHandler);
                        } else if (tagAssumption != null) {
                            feature = PsIdentificationAlgorithmMatchesSection.getTagAssumptionFeature(identification, identificationFeaturesGenerator, spectrumProvider, identificationParameters, linePrefix, tagAssumption, spectrumFile, spectrumTitle, psParameter, identificationAlgorithmMatchesFeature, waitingHandler);
                        } else {
                            throw new IllegalArgumentException("No best match found for spectrum " + spectrumTitle + " in " + spectrumFile + ".");
                        }
                        writer.write(feature);
                    }
                    for (PsPsmFeature psmFeature : psmFeatures) {
                        if (!first) {
                            writer.addSeparator();
                        } else {
                            first = false;
                        }
                        writer.write(getFeature(identification, identificationFeaturesGenerator, identificationParameters, linePrefix, spectrumMatch, psParameter, psmFeature, validatedOnly, decoys, waitingHandler));
                    }
                    writer.newLine();
                    if (fragmentSection != null) {
                        StringBuilder fractionPrefix = new StringBuilder();
                        if (linePrefix != null) {
                            fractionPrefix.append(linePrefix);
                        }
                        fractionPrefix.append(line).append(".");
                        writer.increaseDepth();
                        if (peptideAssumption != null) {
                            fragmentSection.writeSection(spectrumFile, spectrumTitle, peptideAssumption, sequenceProvider, spectrumProvider, identificationParameters, fractionPrefix.toString(), null);
                        } else if (tagAssumption != null) {
                            fragmentSection.writeSection(spectrumFile, spectrumTitle, tagAssumption, sequenceProvider, spectrumProvider, identificationParameters, fractionPrefix.toString(), null);
                        }
                        writer.decreseDepth();
                    }
                    line++;
                }
            }
        }
    }
}
Also used : TagAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.TagAssumption) PsPsmFeature(com.compomics.util.io.export.features.peptideshaker.PsPsmFeature) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) PsIdentificationAlgorithmMatchesFeature(com.compomics.util.io.export.features.peptideshaker.PsIdentificationAlgorithmMatchesFeature) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption) SpectrumMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter)

Aggregations

SpectrumMatchesIterator (com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator)13 SpectrumMatch (com.compomics.util.experiment.identification.matches.SpectrumMatch)11 PSParameter (com.compomics.util.experiment.identification.peptide_shaker.PSParameter)8 ArrayList (java.util.ArrayList)7 PeptideAssumption (com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption)6 Peptide (com.compomics.util.experiment.biology.proteins.Peptide)4 ModificationFactory (com.compomics.util.experiment.biology.modifications.ModificationFactory)3 SpectrumIdentificationAssumption (com.compomics.util.experiment.identification.SpectrumIdentificationAssumption)3 PeptideMatch (com.compomics.util.experiment.identification.matches.PeptideMatch)3 SimpleFileWriter (com.compomics.util.io.flat.SimpleFileWriter)3 SimpleSemaphore (com.compomics.util.threading.SimpleSemaphore)3 HashSet (java.util.HashSet)3 Identification (com.compomics.util.experiment.identification.Identification)2 ProteinMatch (com.compomics.util.experiment.identification.matches.ProteinMatch)2 PeptideMatchesIterator (com.compomics.util.experiment.identification.matches_iterators.PeptideMatchesIterator)2 AnnotationParameters (com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters)2 TagAssumption (com.compomics.util.experiment.identification.spectrum_assumptions.TagAssumption)2 SequenceProvider (com.compomics.util.experiment.io.biology.protein.SequenceProvider)2 SpectrumProvider (com.compomics.util.experiment.mass_spectrometry.SpectrumProvider)2 PsIdentificationAlgorithmMatchesFeature (com.compomics.util.io.export.features.peptideshaker.PsIdentificationAlgorithmMatchesFeature)2