Search in sources :

Example 1 with ProjectType

use of com.compomics.util.parameters.peptide_shaker.ProjectType in project peptide-shaker by compomics.

the class PeptideShaker method attachSpectrumProbabilitiesAndBuildPeptidesAndProteins.

/**
 * Attaches the spectrum posterior error probabilities to the spectrum
 * matches and creates peptides and proteins.
 *
 * @param sequenceProvider a protein sequence provider
 * @param sequenceMatchingPreferences the sequence matching preferences
 * @param projectType the project type
 * @param fastaParameters the FASTA parsing parameters
 * @param waitingHandler the handler displaying feedback to the user
 */
private void attachSpectrumProbabilitiesAndBuildPeptidesAndProteins(SequenceProvider sequenceProvider, SequenceMatchingParameters sequenceMatchingPreferences, ProjectType projectType, FastaParameters fastaParameters, WaitingHandler waitingHandler) {
    waitingHandler.setSecondaryProgressCounterIndeterminate(false);
    waitingHandler.setMaxSecondaryProgressCounter(identification.getSpectrumIdentificationSize());
    PeptideAndProteinBuilder peptideAndProteinBuilder = new PeptideAndProteinBuilder(identification);
    identification.getSpectrumIdentification().values().stream().flatMap(keys -> keys.stream()).parallel().map(key -> identification.getSpectrumMatch(key)).forEach(spectrumMatch -> attachSpectrumProbabilitiesAndBuildPeptidesAndProteins(spectrumMatch, peptideAndProteinBuilder, sequenceProvider, sequenceMatchingPreferences, projectType, fastaParameters, waitingHandler));
    waitingHandler.setSecondaryProgressCounterIndeterminate(true);
}
Also used : ModificationFactory(com.compomics.util.experiment.biology.modifications.ModificationFactory) IdentificationFeaturesGenerator(com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator) FractionParameters(com.compomics.util.parameters.identification.advanced.FractionParameters) TimeoutException(java.util.concurrent.TimeoutException) ProteinProcessor(eu.isas.peptideshaker.processing.ProteinProcessor) EnzymeFactory(com.compomics.util.experiment.biology.enzymes.EnzymeFactory) WaitingHandler(com.compomics.util.waiting.WaitingHandler) SpectrumProvider(com.compomics.util.experiment.mass_spectrometry.SpectrumProvider) com.compomics.util.experiment.identification(com.compomics.util.experiment.identification) CompomicsWrapper(com.compomics.software.CompomicsWrapper) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) FastaSummary(com.compomics.util.experiment.io.biology.protein.FastaSummary) IdMatchValidationParameters(com.compomics.util.parameters.identification.advanced.IdMatchValidationParameters) GroupSimplification(eu.isas.peptideshaker.protein_inference.GroupSimplification) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) PsmScorer(eu.isas.peptideshaker.scoring.psm_scoring.PsmScorer) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) ScalingFactorsEstimators(com.compomics.util.experiment.quantification.spectrumcounting.ScalingFactorsEstimators) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) PsmScoringParameters(com.compomics.util.parameters.identification.advanced.PsmScoringParameters) PsmProcessor(eu.isas.peptideshaker.processing.PsmProcessor) FileImporter(eu.isas.peptideshaker.fileimport.FileImporter) ExceptionHandler(com.compomics.util.exceptions.ExceptionHandler) ProteinInference(eu.isas.peptideshaker.protein_inference.ProteinInference) MatchesValidator(eu.isas.peptideshaker.validation.MatchesValidator) Metrics(com.compomics.util.experiment.identification.peptide_shaker.Metrics) UtilitiesUserParameters(com.compomics.util.parameters.UtilitiesUserParameters) PeptideAndProteinBuilder(com.compomics.util.experiment.identification.protein_inference.PeptideAndProteinBuilder) TargetDecoyMap(eu.isas.peptideshaker.scoring.targetdecoy.TargetDecoyMap) ProjectParameters(com.compomics.util.experiment.ProjectParameters) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) ProteinDetailsProvider(com.compomics.util.experiment.io.biology.protein.ProteinDetailsProvider) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) ArrayList(java.util.ArrayList) InputMap(eu.isas.peptideshaker.scoring.maps.InputMap) ProjectType(com.compomics.util.parameters.peptide_shaker.ProjectType) ProcessingParameters(com.compomics.util.parameters.tools.ProcessingParameters) ProjectDetails(eu.isas.peptideshaker.preferences.ProjectDetails) ObjectsDB(com.compomics.util.db.object.ObjectsDB) Duration(com.compomics.util.waiting.Duration) SpectrumCountingParameters(com.compomics.util.parameters.quantification.spectrum_counting.SpectrumCountingParameters) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) PeptideInference(com.compomics.util.experiment.identification.peptide_inference.PeptideInference) IOException(java.io.IOException) PSMaps(eu.isas.peptideshaker.scoring.PSMaps) File(java.io.File) ModificationLocalizationScorer(eu.isas.peptideshaker.ptm.ModificationLocalizationScorer) FastaParameters(com.compomics.util.experiment.io.biology.protein.FastaParameters) GeneMaps(com.compomics.util.experiment.biology.genes.GeneMaps) ModificationLocalizationParameters(com.compomics.util.parameters.identification.advanced.ModificationLocalizationParameters) InputStream(java.io.InputStream) PeptideAndProteinBuilder(com.compomics.util.experiment.identification.protein_inference.PeptideAndProteinBuilder)

Example 2 with ProjectType

use of com.compomics.util.parameters.peptide_shaker.ProjectType in project peptide-shaker by compomics.

the class NewDialog method loadButtonActionPerformed.

// </editor-fold>//GEN-END:initComponents
/**
 * Tries to process the identification files, closes the dialog and then
 * opens the results in the main frame.
 *
 * @param evt
 */
private void loadButtonActionPerformed(java.awt.event.ActionEvent evt) {
    if (validateUserInput()) {
        if (welcomeDialog != null) {
            welcomeDialog.setVisible(false);
        }
        this.setVisible(false);
        peptideShakerGUI.setVisible(true);
        ProjectType projectType = ProjectType.getProjectType(typeCmb.getSelectedItem().toString());
        peptideShakerGUI.setIdentificationParameters(identificationParameters);
        peptideShakerGUI.setProcessingParameters(processingParameters);
        peptideShakerGUI.setDisplayParameters(displayPreferences);
        projectDetails = new ProjectDetails();
        projectDetails.setCreationDate(new Date());
        projectDetails.setPeptideShakerVersion(new eu.isas.peptideshaker.utils.Properties().getVersion());
        projectDetails.setFastaFile(fastaFile);
        peptideShakerGUI.setProjectDetails(projectDetails);
        peptideShakerGUI.setCurentNotes(new ArrayList<>());
        peptideShakerGUI.updateNotesNotificationCounter();
        peptideShakerGUI.resetDisplayFeaturesGenerator();
        peptideShakerGUI.setSpectrumCountingParameters(spectrumCountingPreferences);
        peptideShakerGUI.setMsFileHandler(msFileHandler);
        ProjectParameters projectParameters = new ProjectParameters(projectNameIdTxt.getText().trim());
        // incrementing the counter for a new PeptideShaker start run via GUI
        if (peptideShakerGUI.getUtilitiesUserParameters().isAutoUpdate()) {
            Util.sendGAUpdate("UA-36198780-1", "startrun-gui", "peptide-shaker-" + PeptideShaker.getVersion());
        }
        peptideShaker = new PeptideShaker(projectParameters);
        ArrayList<String> tips;
        try {
            tips = Tips.getTips();
        } catch (Exception e) {
            tips = new ArrayList<>();
        // Do something here?
        }
        WaitingDialog waitingDialog = new WaitingDialog(peptideShakerGUI, Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker.gif")), Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker-orange.gif")), true, tips, "Importing Data", "PeptideShaker", PeptideShaker.getVersion(), true);
        waitingDialog.setCloseDialogWhenImportCompletes(true, true);
        int progressCounter = idFiles.size() + spectrumFiles.size();
        // establishing the database connection
        progressCounter++;
        // the FASTA file
        progressCounter++;
        // the peptide to protein map
        progressCounter++;
        // computing probabilities etc
        progressCounter += 6;
        if (identificationParameters.getProteinInferenceParameters().getSimplifyGroups()) {
            // simplify protein groups
            progressCounter++;
        }
        // resolving protein inference
        progressCounter++;
        // Correcting protein probabilities, Validating identifications at 1% FDR, Scoring PTMs in peptides, Scoring PTMs in proteins.
        progressCounter += 4;
        // Scoring PTMs in PSMs. Estimating PTM FLR.
        progressCounter += 2;
        if (identificationParameters.getModificationLocalizationParameters().getAlignNonConfidentModifications()) {
            // Peptide inference
            progressCounter++;
        }
        // add one more just to not start at 0%
        progressCounter++;
        waitingDialog.setMaxPrimaryProgressCounter(progressCounter);
        // just to not start at 0%
        waitingDialog.increasePrimaryProgressCounter();
        boolean needDialog = false;
        // load the identification files
        if (idFiles.size() > 0) {
            needDialog = true;
            new Thread(new Runnable() {

                public void run() {
                    ExceptionHandler exceptionHandler = new WaitingDialogExceptionHandler((WaitingDialog) waitingDialog, "https://github.com/compomics/peptide-shaker/issues");
                    try {
                        int outcome = peptideShaker.importFiles(waitingDialog, idFiles, msFileHandler, identificationParameters, projectDetails, processingParameters, exceptionHandler);
                        if (outcome == 0) {
                            peptideShaker.createProject(identificationParameters, processingParameters, spectrumCountingPreferences, msFileHandler, projectDetails, projectType, waitingDialog, true, exceptionHandler);
                        } else {
                            waitingDialog.setRunCanceled();
                        }
                    } catch (Exception e) {
                        exceptionHandler.catchException(e);
                        waitingDialog.setRunCanceled();
                        waitingDialog.setWaitingText("Failed to import data or create the project!");
                    }
                }
            }, "Import data and create project").start();
        }
        if (needDialog) {
            try {
                waitingDialog.setVisible(true);
            } catch (IndexOutOfBoundsException e) {
            // ignore
            }
            this.dispose();
        }
        if (!needDialog || !waitingDialog.isRunCanceled()) {
            peptideShakerGUI.setProject(projectParameters);
            peptideShakerGUI.setIdentification(peptideShaker.getIdentification());
            peptideShakerGUI.setMetrics(peptideShaker.getMetrics());
            peptideShakerGUI.setGeneMaps(peptideShaker.getGeneMaps());
            peptideShakerGUI.setProjectType(projectType);
            peptideShakerGUI.setSequenceProvider(peptideShaker.getSequenceProvider());
            peptideShakerGUI.setProteinDetailsProvider(peptideShaker.getProteinDetailsProvider());
            peptideShakerGUI.resetDisplayFeaturesGenerator();
            peptideShakerGUI.setIdentificationFeaturesGenerator(peptideShaker.getIdentificationFeaturesGenerator());
            peptideShakerGUI.displayResults();
            // display the overview tab
            peptideShakerGUI.initiateDisplay();
            peptideShakerGUI.getProjectDetails().setReport(waitingDialog.getReport(null));
            this.dispose();
        } else if (waitingDialog.isRunCanceled()) {
            // close the database
            try {
                peptideShaker.getIdentification().close(false);
            } catch (Exception e) {
                System.out.println("Failed to close the database!");
                e.printStackTrace();
            }
        }
    }
}
Also used : ProjectDetails(eu.isas.peptideshaker.preferences.ProjectDetails) ArrayList(java.util.ArrayList) WaitingDialog(com.compomics.util.gui.waiting.waitinghandlers.WaitingDialog) WaitingDialogExceptionHandler(com.compomics.util.exceptions.exception_handlers.WaitingDialogExceptionHandler) Date(java.util.Date) WaitingDialogExceptionHandler(com.compomics.util.exceptions.exception_handlers.WaitingDialogExceptionHandler) ExceptionHandler(com.compomics.util.exceptions.ExceptionHandler) ProjectParameters(com.compomics.util.experiment.ProjectParameters) ProjectType(com.compomics.util.parameters.peptide_shaker.ProjectType) PeptideShaker(eu.isas.peptideshaker.PeptideShaker)

Example 3 with ProjectType

use of com.compomics.util.parameters.peptide_shaker.ProjectType in project peptide-shaker by compomics.

the class MatchesValidator method validateIdentifications.

/**
 * This method validates the identification matches of an identification
 * object. Target Decoy thresholds must be set.
 *
 * @param identification The identification class containing the matches to
 * validate.
 * @param metrics If provided, metrics on fractions will be saved while
 * iterating the matches.
 * @param geneMaps The gene maps.
 * @param inputMap The target decoy map of all search engine scores.
 * @param waitingHandler The waiting handler displaying progress to the user
 * and allowing canceling the process.
 * @param exceptionHandler The handler for exceptions.
 * @param identificationFeaturesGenerator The identification features
 * generator computing information about the identification matches.
 * @param sequenceProvider The protein sequence provider.
 * @param proteinDetailsProvider The protein details provider.
 * @param spectrumProvider The spectrum provider.
 * @param identificationParameters The identification parameters.
 * @param projectType The project type.
 * @param processingParameters The processing parameters.
 *
 * @throws java.lang.InterruptedException exception thrown if a thread gets
 * interrupted
 * @throws java.util.concurrent.TimeoutException exception thrown if the
 * operation times out
 */
public void validateIdentifications(Identification identification, Metrics metrics, InputMap inputMap, WaitingHandler waitingHandler, ExceptionHandler exceptionHandler, IdentificationFeaturesGenerator identificationFeaturesGenerator, SequenceProvider sequenceProvider, ProteinDetailsProvider proteinDetailsProvider, SpectrumProvider spectrumProvider, GeneMaps geneMaps, IdentificationParameters identificationParameters, ProjectType projectType, ProcessingParameters processingParameters) throws InterruptedException, TimeoutException {
    IdMatchValidationParameters validationParameters = identificationParameters.getIdValidationParameters();
    waitingHandler.setWaitingText("Finding FDR Thresholds. Please Wait...");
    for (int algorithm : inputMap.getInputAlgorithms()) {
        TargetDecoyMap targetDecoyMap = inputMap.getTargetDecoyMap(algorithm);
        TargetDecoyResults currentResults = targetDecoyMap.getTargetDecoyResults();
        currentResults.setInputType(1);
        currentResults.setUserInput(validationParameters.getDefaultPsmFDR());
        currentResults.setFdrLimit(validationParameters.getDefaultPsmFDR());
        targetDecoyMap.getTargetDecoySeries().getFDRResults(currentResults);
    }
    TargetDecoyResults currentResults = psmMap.getTargetDecoyResults();
    currentResults.setInputType(1);
    currentResults.setUserInput(validationParameters.getDefaultPsmFDR());
    currentResults.setFdrLimit(validationParameters.getDefaultPsmFDR());
    psmMap.getTargetDecoySeries().getFDRResults(currentResults);
    waitingHandler.setSecondaryProgressCounterIndeterminate(false);
    currentResults = peptideMap.getTargetDecoyResults();
    currentResults.setInputType(1);
    currentResults.setUserInput(validationParameters.getDefaultPeptideFDR());
    currentResults.setFdrLimit(validationParameters.getDefaultPeptideFDR());
    peptideMap.getTargetDecoySeries().getFDRResults(currentResults);
    currentResults = proteinMap.getTargetDecoyResults();
    currentResults.setInputType(1);
    currentResults.setUserInput(validationParameters.getDefaultProteinFDR());
    currentResults.setFdrLimit(validationParameters.getDefaultProteinFDR());
    proteinMap.getTargetDecoySeries().getFDRResults(currentResults);
    ValidationQcParameters validationQCParameters = validationParameters.getValidationQCParameters();
    waitingHandler.setWaitingText("Match Validation and Quality Control. Please Wait...");
    waitingHandler.setSecondaryProgressCounterIndeterminate(false);
    waitingHandler.resetSecondaryProgressCounter();
    waitingHandler.setMaxSecondaryProgressCounter(identification.getProteinIdentification().size() + identification.getPeptideIdentification().size() + 2 * identification.getSpectrumIdentificationSize());
    // validate the spectrum matches
    if (inputMap != null) {
        inputMap.resetAdvocateContributions();
    }
    AnnotationParameters annotationParameters = identificationParameters.getAnnotationParameters();
    double intensityLimit = annotationParameters.getAnnotationIntensityLimit();
    annotationParameters.setIntensityLimit(0);
    ExecutorService pool = Executors.newFixedThreadPool(processingParameters.getnThreads());
    SpectrumMatchesIterator psmIterator = identification.getSpectrumMatchesIterator(waitingHandler);
    ArrayList<PsmValidatorRunnable> psmRunnables = new ArrayList<>(processingParameters.getnThreads());
    for (int i = 1; i <= processingParameters.getnThreads(); i++) {
        PsmValidatorRunnable runnable = new PsmValidatorRunnable(psmIterator, identification, identificationFeaturesGenerator, sequenceProvider, proteinDetailsProvider, spectrumProvider, geneMaps, identificationParameters, waitingHandler, exceptionHandler, inputMap, false, true);
        pool.submit(runnable);
        psmRunnables.add(runnable);
    }
    if (waitingHandler.isRunCanceled()) {
        pool.shutdownNow();
        return;
    }
    pool.shutdown();
    if (!pool.awaitTermination(identification.getSpectrumIdentificationSize(), TimeUnit.MINUTES)) {
        throw new TimeoutException("Spectrum matches validation timed out. Please contact the developers.");
    }
    // combine the precursor mz deviations from the different threads into one map
    HashMap<String, ArrayList<Double>> precursorMzDeviations = new HashMap<>(identification.getSpectrumIdentification().size());
    for (PsmValidatorRunnable runnable : psmRunnables) {
        for (String spectrumFileName : runnable.getThreadPrecursorMzDeviations().keySet()) {
            ArrayList<Double> threadPrecursorMzDeviations = runnable.getThreadPrecursorMzDeviations().get(spectrumFileName);
            ArrayList<Double> filePrecursorMzDeviations = precursorMzDeviations.get(spectrumFileName);
            if (filePrecursorMzDeviations != null) {
                filePrecursorMzDeviations.addAll(threadPrecursorMzDeviations);
            } else {
                precursorMzDeviations.put(spectrumFileName, threadPrecursorMzDeviations);
            }
        }
    }
    for (String spectrumFileName : precursorMzDeviations.keySet()) {
        double[] precursorMzDeviationsFile = precursorMzDeviations.get(spectrumFileName).stream().mapToDouble(a -> a).toArray();
        if (precursorMzDeviationsFile.length >= 100) {
            Arrays.sort(precursorMzDeviationsFile);
            identificationFeaturesGenerator.setMassErrorDistribution(spectrumFileName, precursorMzDeviationsFile);
        } else {
            // There are not enough precursors, disable probabilistic precursor filter
            if (validationQCParameters.getPsmFilters() != null) {
                for (Filter filter : validationQCParameters.getPsmFilters()) {
                    PsmFilter psmFilter = (PsmFilter) filter;
                    if (psmFilter.getItemsNames().contains(AssumptionFilterItem.precrusorMzErrorStat.name)) {
                        psmFilter.removeFilterItem(AssumptionFilterItem.precrusorMzErrorStat.name);
                        SearchParameters searchParameters = identificationParameters.getSearchParameters();
                        if (searchParameters.isPrecursorAccuracyTypePpm()) {
                            psmFilter.setFilterItem(AssumptionFilterItem.precrusorMzErrorPpm.name, FilterItemComparator.lowerOrEqual, searchParameters.getPrecursorAccuracy());
                        } else {
                            psmFilter.setFilterItem(AssumptionFilterItem.precrusorMzErrorDa.name, FilterItemComparator.lowerOrEqual, searchParameters.getPrecursorAccuracy());
                        }
                    }
                    AssumptionFilter assumptionFilter = psmFilter.getAssumptionFilter();
                    if (assumptionFilter.getItemsNames().contains(AssumptionFilterItem.precrusorMzErrorStat.name)) {
                        assumptionFilter.removeFilterItem(AssumptionFilterItem.precrusorMzErrorStat.name);
                        SearchParameters searchParameters = identificationParameters.getSearchParameters();
                        if (searchParameters.isPrecursorAccuracyTypePpm()) {
                            assumptionFilter.setFilterItem(AssumptionFilterItem.precrusorMzErrorPpm.name, FilterItemComparator.lowerOrEqual, searchParameters.getPrecursorAccuracy());
                        } else {
                            assumptionFilter.setFilterItem(AssumptionFilterItem.precrusorMzErrorDa.name, FilterItemComparator.lowerOrEqual, searchParameters.getPrecursorAccuracy());
                        }
                    }
                }
            }
        }
    }
    pool = Executors.newFixedThreadPool(processingParameters.getnThreads());
    psmIterator = identification.getSpectrumMatchesIterator(waitingHandler);
    for (int i = 1; i <= processingParameters.getnThreads(); i++) {
        PsmValidatorRunnable runnable = new PsmValidatorRunnable(psmIterator, identification, identificationFeaturesGenerator, sequenceProvider, proteinDetailsProvider, spectrumProvider, geneMaps, identificationParameters, waitingHandler, exceptionHandler, inputMap, true, false);
        pool.submit(runnable);
    }
    if (waitingHandler.isRunCanceled()) {
        pool.shutdownNow();
        return;
    }
    pool.shutdown();
    if (!pool.awaitTermination(identification.getSpectrumIdentificationSize(), TimeUnit.MINUTES)) {
        throw new TimeoutException("Spectrum matches validation timed out. Please contact the developers.");
    }
    annotationParameters.setIntensityLimit(intensityLimit);
    if (projectType == ProjectType.peptide || projectType == ProjectType.protein) {
        // validate the peptides
        pool = Executors.newFixedThreadPool(processingParameters.getnThreads());
        ArrayList<PeptideValidatorRunnable> peptideRunnables = new ArrayList<>(processingParameters.getnThreads());
        PeptideMatchesIterator peptideMatchesIterator = identification.getPeptideMatchesIterator(waitingHandler);
        for (int i = 1; i <= processingParameters.getnThreads(); i++) {
            PeptideValidatorRunnable runnable = new PeptideValidatorRunnable(peptideMatchesIterator, identification, identificationFeaturesGenerator, sequenceProvider, proteinDetailsProvider, spectrumProvider, geneMaps, identificationParameters, waitingHandler, exceptionHandler, metrics);
            pool.submit(runnable);
            peptideRunnables.add(runnable);
        }
        if (waitingHandler.isRunCanceled()) {
            pool.shutdownNow();
            return;
        }
        pool.shutdown();
        if (!pool.awaitTermination(identification.getPeptideIdentification().size(), TimeUnit.MINUTES)) {
            throw new InterruptedException("Peptide matches validation timed out. Please contact the developers.");
        }
        HashMap<String, Integer> validatedTotalPeptidesPerFraction = new HashMap<>();
        ArrayList<Double> validatedPeptideLengths = new ArrayList<>();
        for (PeptideValidatorRunnable runnable : peptideRunnables) {
            HashMap<String, Integer> threadValidatedTotalPeptidesPerFraction = runnable.getValidatedTotalPeptidesPerFraction();
            for (String fraction : threadValidatedTotalPeptidesPerFraction.keySet()) {
                Integer nValidated = validatedTotalPeptidesPerFraction.get(fraction);
                if (nValidated == null) {
                    nValidated = 0;
                }
                nValidated += threadValidatedTotalPeptidesPerFraction.get(fraction);
                validatedTotalPeptidesPerFraction.put(fraction, nValidated);
            }
            validatedPeptideLengths.addAll(runnable.getValidatedPeptideLengths());
        }
        if (validatedPeptideLengths.size() >= 100) {
            NonSymmetricalNormalDistribution lengthDistribution = NonSymmetricalNormalDistribution.getRobustNonSymmetricalNormalDistribution(validatedPeptideLengths);
            metrics.setPeptideLengthDistribution(lengthDistribution);
        }
        metrics.setTotalPeptidesPerFraction(validatedTotalPeptidesPerFraction);
        if (projectType == ProjectType.protein) {
            // validate the proteins
            pool = Executors.newFixedThreadPool(processingParameters.getnThreads());
            ProteinMatchesIterator proteinMatchesIterator = identification.getProteinMatchesIterator(waitingHandler);
            ArrayList<ProteinValidatorRunnable> proteinRunnables = new ArrayList<>(processingParameters.getnThreads());
            for (int i = 1; i <= processingParameters.getnThreads(); i++) {
                ProteinValidatorRunnable runnable = new ProteinValidatorRunnable(proteinMatchesIterator, identification, identificationFeaturesGenerator, sequenceProvider, proteinDetailsProvider, spectrumProvider, geneMaps, metrics, identificationParameters, waitingHandler, exceptionHandler);
                pool.submit(runnable);
                proteinRunnables.add(runnable);
            }
            if (waitingHandler.isRunCanceled()) {
                pool.shutdownNow();
                return;
            }
            pool.shutdown();
            if (!pool.awaitTermination(identification.getProteinIdentification().size(), TimeUnit.MINUTES)) {
                throw new InterruptedException("Protein matches validation timed out. Please contact the developers.");
            }
            long[] validatedTargetProteinKeys = proteinRunnables.stream().flatMap(runnable -> runnable.getValidatedProteinMatches().stream()).mapToLong(a -> a).toArray();
            metrics.setValidatedTargetProteinKeys(validatedTargetProteinKeys);
        }
    }
}
Also used : Arrays(java.util.Arrays) IdentificationFeaturesGenerator(com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator) SpectrumMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator) FractionParameters(com.compomics.util.parameters.identification.advanced.FractionParameters) TimeoutException(java.util.concurrent.TimeoutException) PsmFilter(com.compomics.util.experiment.identification.filtering.PsmFilter) WaitingHandler(com.compomics.util.waiting.WaitingHandler) ProteinFilterItem(com.compomics.util.experiment.identification.filtering.items.ProteinFilterItem) TargetDecoyResults(eu.isas.peptideshaker.scoring.targetdecoy.TargetDecoyResults) SpectrumProvider(com.compomics.util.experiment.mass_spectrometry.SpectrumProvider) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption) Set(java.util.Set) IdMatchValidationParameters(com.compomics.util.parameters.identification.advanced.IdMatchValidationParameters) Collectors(java.util.stream.Collectors) ProteinFilter(com.compomics.util.experiment.identification.filtering.ProteinFilter) Executors(java.util.concurrent.Executors) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) ExceptionHandler(com.compomics.util.exceptions.ExceptionHandler) Metrics(com.compomics.util.experiment.identification.peptide_shaker.Metrics) ModificationMatch(com.compomics.util.experiment.identification.matches.ModificationMatch) PeptideFilter(com.compomics.util.experiment.identification.filtering.PeptideFilter) SpectrumIdentificationAssumption(com.compomics.util.experiment.identification.SpectrumIdentificationAssumption) TargetDecoyMap(eu.isas.peptideshaker.scoring.targetdecoy.TargetDecoyMap) PeptideUtils(com.compomics.util.experiment.identification.utils.PeptideUtils) HashMap(java.util.HashMap) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) NonSymmetricalNormalDistribution(com.compomics.util.math.statistics.distributions.NonSymmetricalNormalDistribution) ProteinDetailsProvider(com.compomics.util.experiment.io.biology.protein.ProteinDetailsProvider) TreeSet(java.util.TreeSet) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) ValidationQcParameters(com.compomics.util.parameters.identification.advanced.ValidationQcParameters) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) ProteinMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.ProteinMatchesIterator) InputMap(eu.isas.peptideshaker.scoring.maps.InputMap) ProjectType(com.compomics.util.parameters.peptide_shaker.ProjectType) ProcessingParameters(com.compomics.util.parameters.tools.ProcessingParameters) FilterItemComparator(com.compomics.util.experiment.filtering.FilterItemComparator) PeptideFilterItem(com.compomics.util.experiment.identification.filtering.items.PeptideFilterItem) ExecutorService(java.util.concurrent.ExecutorService) AssumptionFilter(com.compomics.util.experiment.identification.filtering.AssumptionFilter) MatchValidationLevel(com.compomics.util.experiment.identification.validation.MatchValidationLevel) AssumptionFilterItem(com.compomics.util.experiment.identification.filtering.items.AssumptionFilterItem) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) Identification(com.compomics.util.experiment.identification.Identification) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) PeptideMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.PeptideMatchesIterator) AnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters) TimeUnit(java.util.concurrent.TimeUnit) TreeMap(java.util.TreeMap) FastaParameters(com.compomics.util.experiment.io.biology.protein.FastaParameters) ProteinUtils(com.compomics.util.experiment.identification.utils.ProteinUtils) Filter(com.compomics.util.experiment.filtering.Filter) GeneMaps(com.compomics.util.experiment.biology.genes.GeneMaps) IdMatchValidationParameters(com.compomics.util.parameters.identification.advanced.IdMatchValidationParameters) HashMap(java.util.HashMap) AnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters) ArrayList(java.util.ArrayList) TargetDecoyMap(eu.isas.peptideshaker.scoring.targetdecoy.TargetDecoyMap) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) ValidationQcParameters(com.compomics.util.parameters.identification.advanced.ValidationQcParameters) TargetDecoyResults(eu.isas.peptideshaker.scoring.targetdecoy.TargetDecoyResults) ProteinMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.ProteinMatchesIterator) TimeoutException(java.util.concurrent.TimeoutException) NonSymmetricalNormalDistribution(com.compomics.util.math.statistics.distributions.NonSymmetricalNormalDistribution) PeptideMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.PeptideMatchesIterator) AssumptionFilter(com.compomics.util.experiment.identification.filtering.AssumptionFilter) SpectrumMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator) PsmFilter(com.compomics.util.experiment.identification.filtering.PsmFilter) ProteinFilter(com.compomics.util.experiment.identification.filtering.ProteinFilter) PeptideFilter(com.compomics.util.experiment.identification.filtering.PeptideFilter) AssumptionFilter(com.compomics.util.experiment.identification.filtering.AssumptionFilter) Filter(com.compomics.util.experiment.filtering.Filter) ExecutorService(java.util.concurrent.ExecutorService) PsmFilter(com.compomics.util.experiment.identification.filtering.PsmFilter)

Aggregations

ExceptionHandler (com.compomics.util.exceptions.ExceptionHandler)3 ProjectType (com.compomics.util.parameters.peptide_shaker.ProjectType)3 ProjectParameters (com.compomics.util.experiment.ProjectParameters)2 GeneMaps (com.compomics.util.experiment.biology.genes.GeneMaps)2 IdentificationFeaturesGenerator (com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator)2 SpectrumMatch (com.compomics.util.experiment.identification.matches.SpectrumMatch)2 Metrics (com.compomics.util.experiment.identification.peptide_shaker.Metrics)2 PSParameter (com.compomics.util.experiment.identification.peptide_shaker.PSParameter)2 FastaParameters (com.compomics.util.experiment.io.biology.protein.FastaParameters)2 ProteinDetailsProvider (com.compomics.util.experiment.io.biology.protein.ProteinDetailsProvider)2 SequenceProvider (com.compomics.util.experiment.io.biology.protein.SequenceProvider)2 SpectrumProvider (com.compomics.util.experiment.mass_spectrometry.SpectrumProvider)2 IdentificationParameters (com.compomics.util.parameters.identification.IdentificationParameters)2 ArrayList (java.util.ArrayList)2 CompomicsWrapper (com.compomics.software.CompomicsWrapper)1 ObjectsDB (com.compomics.util.db.object.ObjectsDB)1 WaitingDialogExceptionHandler (com.compomics.util.exceptions.exception_handlers.WaitingDialogExceptionHandler)1 EnzymeFactory (com.compomics.util.experiment.biology.enzymes.EnzymeFactory)1 ModificationFactory (com.compomics.util.experiment.biology.modifications.ModificationFactory)1 Peptide (com.compomics.util.experiment.biology.proteins.Peptide)1