Search in sources :

Example 1 with WaitingHandler

use of com.compomics.util.waiting.WaitingHandler in project peptide-shaker by compomics.

the class ModificationLocalizationScorer method scorePTMs.

/**
 * Scores PTMs in a protein match.
 *
 * @param identification The identification object containing the matches.
 * @param proteinMatch The protein match.
 * @param identificationParameters The identification parameters.
 * @param scorePeptides If true, peptides will be scored as well.
 * @param modificationProvider The modification provider to use.
 * @param waitingHandler The waiting handler to sue, ignored if null.
 */
public void scorePTMs(Identification identification, ProteinMatch proteinMatch, IdentificationParameters identificationParameters, boolean scorePeptides, ModificationProvider modificationProvider, WaitingHandler waitingHandler) {
    HashMap<Integer, ArrayList<String>> confidentSites = new HashMap<>();
    HashMap<Integer, HashMap<Integer, HashSet<String>>> ambiguousSites = new HashMap<>();
    for (long peptideKey : proteinMatch.getPeptideMatchesKeys()) {
        PeptideMatch peptideMatch = identification.getPeptideMatch(peptideKey);
        Peptide peptide = peptideMatch.getPeptide();
        PSParameter psParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
        if (psParameter.getMatchValidationLevel().isValidated() && peptide.getNVariableModifications() > 0) {
            PSModificationScores peptideScores = (PSModificationScores) peptideMatch.getUrParam(PSModificationScores.dummy);
            if (peptideScores == null || scorePeptides) {
                scorePTMs(identification, peptideMatch, identificationParameters, modificationProvider, waitingHandler);
                peptideScores = (PSModificationScores) peptideMatch.getUrParam(PSModificationScores.dummy);
            }
            if (peptideScores != null) {
                int[] peptideStart = peptide.getProteinMapping().get(proteinMatch.getLeadingAccession());
                for (int confidentSite : peptideScores.getConfidentSites()) {
                    for (int peptideTempStart : peptideStart) {
                        int siteOnProtein = peptideTempStart + confidentSite - 1;
                        ArrayList<String> modificationsAtSite = confidentSites.get(siteOnProtein);
                        if (modificationsAtSite == null) {
                            modificationsAtSite = new ArrayList<>();
                            confidentSites.put(siteOnProtein, modificationsAtSite);
                        }
                        for (String modName : peptideScores.getConfidentModificationsAt(confidentSite)) {
                            if (!modificationsAtSite.contains(modName)) {
                                modificationsAtSite.add(modName);
                            }
                        }
                    }
                }
                for (int representativeSite : peptideScores.getRepresentativeSites()) {
                    HashMap<Integer, HashSet<String>> peptideAmbiguousSites = peptideScores.getAmbiguousModificationsAtRepresentativeSite(representativeSite);
                    for (int peptideTempStart : peptideStart) {
                        int proteinRepresentativeSite = peptideTempStart + representativeSite - 1;
                        HashMap<Integer, HashSet<String>> proteinAmbiguousSites = ambiguousSites.get(proteinRepresentativeSite);
                        if (proteinAmbiguousSites == null) {
                            proteinAmbiguousSites = new HashMap<>(peptideAmbiguousSites.size());
                            ambiguousSites.put(proteinRepresentativeSite, proteinAmbiguousSites);
                        }
                        for (int peptideSite : peptideAmbiguousSites.keySet()) {
                            int siteOnProtein = peptideTempStart + peptideSite - 1;
                            proteinAmbiguousSites.put(siteOnProtein, peptideAmbiguousSites.get(peptideSite));
                        }
                    }
                }
            }
        }
    }
    // remove ambiguous sites where a confident was found and merge overlapping groups
    PSModificationScores proteinScores = new PSModificationScores();
    ArrayList<Integer> representativeSites = new ArrayList<>(ambiguousSites.keySet());
    Collections.sort(representativeSites);
    for (Integer representativeSite : representativeSites) {
        HashMap<Integer, HashSet<String>> secondarySitesMap = ambiguousSites.get(representativeSite);
        ArrayList<Integer> secondarySites = new ArrayList<>(secondarySitesMap.keySet());
        for (int secondarySite : secondarySites) {
            ArrayList<String> confidentModifications = confidentSites.get(secondarySite);
            if (confidentModifications != null) {
                boolean sameModification = confidentModifications.stream().map(modName -> modificationProvider.getModification(modName)).anyMatch(confidentModification -> secondarySitesMap.get(secondarySite).stream().map(modName -> modificationProvider.getModification(modName)).anyMatch(secondaryModification -> secondaryModification.getMass() == confidentModification.getMass()));
                if (sameModification) {
                    ambiguousSites.remove(representativeSite);
                    break;
                }
            }
            if (secondarySite != representativeSite) {
                ArrayList<Integer> tempRepresentativeSites = new ArrayList<>(ambiguousSites.keySet());
                Collections.sort(tempRepresentativeSites);
                for (Integer previousSite : tempRepresentativeSites) {
                    if (previousSite >= representativeSite) {
                        break;
                    }
                    if (previousSite == secondarySite) {
                        HashMap<Integer, HashSet<String>> previousSites = ambiguousSites.get(previousSite);
                        HashSet<String> previousModifications = previousSites.get(previousSite);
                        boolean sameModification = previousModifications.stream().map(modName -> modificationProvider.getModification(modName)).anyMatch(previousModification -> secondarySitesMap.get(secondarySite).stream().map(modName -> modificationProvider.getModification(modName)).anyMatch(secondaryModification -> secondaryModification.getMass() == previousModification.getMass()));
                        if (sameModification) {
                            for (int tempSecondarySite : secondarySitesMap.keySet()) {
                                if (!previousSites.containsKey(secondarySite)) {
                                    previousSites.put(tempSecondarySite, secondarySitesMap.get(tempSecondarySite));
                                }
                            }
                            ambiguousSites.remove(representativeSite);
                        }
                    }
                }
            }
        }
    }
    for (int confidentSite : confidentSites.keySet()) {
        for (String modName : confidentSites.get(confidentSite)) {
            proteinScores.addConfidentModificationSite(modName, confidentSite);
        }
    }
    for (int representativeSite : ambiguousSites.keySet()) {
        proteinScores.addAmbiguousModificationSites(representativeSite, ambiguousSites.get(representativeSite));
    }
    proteinMatch.addUrParam(proteinScores);
}
Also used : ModificationMatch(com.compomics.util.experiment.identification.matches.ModificationMatch) ModificationFactory(com.compomics.util.experiment.biology.modifications.ModificationFactory) Arrays(java.util.Arrays) ModificationType(com.compomics.util.experiment.biology.modifications.ModificationType) HashMap(java.util.HashMap) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) ModificationScoring(com.compomics.util.experiment.identification.peptide_shaker.ModificationScoring) TreeSet(java.util.TreeSet) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Modification(com.compomics.util.experiment.biology.modifications.Modification) WaitingHandler(com.compomics.util.waiting.WaitingHandler) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) ModificationUtils(com.compomics.util.experiment.identification.utils.ModificationUtils) SpecificAnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.SpecificAnnotationParameters) SpectrumProvider(com.compomics.util.experiment.mass_spectrometry.SpectrumProvider) PhosphoRS(com.compomics.util.experiment.identification.modification.scores.PhosphoRS) ModificationProvider(com.compomics.util.experiment.biology.modifications.ModificationProvider) Spectrum(com.compomics.util.experiment.mass_spectrometry.spectra.Spectrum) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) PSModificationScores(com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) ExperimentObject(com.compomics.util.experiment.personalization.ExperimentObject) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) Set(java.util.Set) Identification(com.compomics.util.experiment.identification.Identification) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) ModificationLocalizationScore(com.compomics.util.experiment.identification.modification.ModificationLocalizationScore) Collectors(java.util.stream.Collectors) AnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) PeptideSpectrumAnnotator(com.compomics.util.experiment.identification.spectrum_annotation.spectrum_annotators.PeptideSpectrumAnnotator) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) List(java.util.List) Stream(java.util.stream.Stream) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) TreeMap(java.util.TreeMap) Entry(java.util.Map.Entry) Collections(java.util.Collections) ModificationLocalizationParameters(com.compomics.util.parameters.identification.advanced.ModificationLocalizationParameters) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PSModificationScores(com.compomics.util.experiment.identification.peptide_shaker.PSModificationScores) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) HashSet(java.util.HashSet)

Example 2 with WaitingHandler

use of com.compomics.util.waiting.WaitingHandler in project peptide-shaker by compomics.

the class ProteinProcessor method processProteins.

/**
 * Scores the PTMs of all protein matches contained in an identification
 * object, estimates spectrum counting and summary statistics.
 *
 * @param modificationLocalizationScorer The modification localization
 * scorer to use.
 * @param metrics If provided, metrics on proteins will be saved while
 * iterating the matches.
 * @param modificationProvider The modification provider to use.
 * @param waitingHandler The handler displaying feedback to the user.
 * @param exceptionHandler The exception handler to use.
 * @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 processProteins(ModificationLocalizationScorer modificationLocalizationScorer, Metrics metrics, ModificationProvider modificationProvider, WaitingHandler waitingHandler, ExceptionHandler exceptionHandler, ProcessingParameters processingParameters) throws InterruptedException, TimeoutException {
    waitingHandler.setWaitingText("Scoring Protein Modification Localization. Please Wait...");
    int max = identification.getProteinIdentification().size();
    waitingHandler.setSecondaryProgressCounterIndeterminate(false);
    waitingHandler.setMaxSecondaryProgressCounter(max);
    // validate the proteins
    ExecutorService pool = Executors.newFixedThreadPool(processingParameters.getnThreads());
    ProteinMatchesIterator proteinMatchesIterator = identification.getProteinMatchesIterator(waitingHandler);
    ArrayList<ProteinRunnable> runnables = new ArrayList<>(processingParameters.getnThreads());
    for (int i = 1; i <= processingParameters.getnThreads(); i++) {
        ProteinRunnable runnable = new ProteinRunnable(proteinMatchesIterator, modificationLocalizationScorer, modificationProvider, waitingHandler, exceptionHandler);
        pool.submit(runnable);
        runnables.add(runnable);
    }
    if (waitingHandler.isRunCanceled()) {
        pool.shutdownNow();
    }
    pool.shutdown();
    if (!pool.awaitTermination(identification.getProteinIdentification().size(), TimeUnit.MINUTES)) {
        throw new InterruptedException("Protein matches validation timed out. Please contact the developers.");
    }
    waitingHandler.setSecondaryProgressCounterIndeterminate(true);
    if (metrics != null) {
        metrics.setMaxSpectrumCounting(runnables.stream().mapToDouble(ProteinRunnable::getMaxSpectrumCounting).sum());
        metrics.setnValidatedProteins(runnables.stream().mapToInt(ProteinRunnable::getnValidatedProteins).sum());
        metrics.setnConfidentProteins(runnables.stream().mapToInt(ProteinRunnable::getnConfidentProteins).sum());
        metrics.setMaxNPeptides(runnables.stream().mapToInt(ProteinRunnable::getMaxPeptides).max().orElse(0));
        metrics.setMaxNPsms(runnables.stream().mapToInt(ProteinRunnable::getMaxPsms).max().orElse(0));
        metrics.setMaxMW(runnables.stream().mapToDouble(ProteinRunnable::getMaxMW).max().orElse(0.0));
        metrics.setMaxProteinAccessionLength(runnables.stream().mapToInt(ProteinRunnable::getMaxProteinAccessionLength).max().orElse(0));
        TreeMap<Double, TreeMap<Integer, TreeMap<Integer, TreeSet<Long>>>> orderMap1 = new TreeMap<>();
        for (int i = 0; i < runnables.size(); i++) {
            HashMap<Double, HashMap<Integer, HashMap<Integer, HashSet<Long>>>> threadMap1 = runnables.get(i).getOrderMap();
            for (Entry<Double, HashMap<Integer, HashMap<Integer, HashSet<Long>>>> entry1 : threadMap1.entrySet()) {
                double key1 = entry1.getKey();
                HashMap<Integer, HashMap<Integer, HashSet<Long>>> threadMap2 = entry1.getValue();
                TreeMap<Integer, TreeMap<Integer, TreeSet<Long>>> orderMap2 = orderMap1.get(key1);
                if (orderMap2 == null) {
                    orderMap2 = new TreeMap<>();
                    orderMap1.put(key1, orderMap2);
                }
                for (Entry<Integer, HashMap<Integer, HashSet<Long>>> entry2 : threadMap2.entrySet()) {
                    int key2 = entry2.getKey();
                    HashMap<Integer, HashSet<Long>> threadMap3 = entry2.getValue();
                    TreeMap<Integer, TreeSet<Long>> orderMap3 = orderMap2.get(key2);
                    if (orderMap3 == null) {
                        orderMap3 = new TreeMap<>();
                        orderMap2.put(key2, orderMap3);
                    }
                    for (Entry<Integer, HashSet<Long>> entry3 : threadMap3.entrySet()) {
                        int key3 = entry3.getKey();
                        HashSet<Long> threadSet = entry3.getValue();
                        TreeSet<Long> orderedSet = orderMap3.get(key3);
                        if (orderedSet == null) {
                            orderedSet = new TreeSet<>();
                            orderMap3.put(key3, orderedSet);
                        }
                        orderedSet.addAll(threadSet);
                    }
                }
            }
        }
        long[] proteinKeys = orderMap1.values().stream().flatMap(map -> map.values().stream()).flatMap(map -> map.values().stream()).flatMap(set -> set.stream()).mapToLong(a -> a).toArray();
        metrics.setProteinKeys(proteinKeys);
    }
}
Also used : Arrays(java.util.Arrays) IdentificationFeaturesGenerator(com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator) TimeoutException(java.util.concurrent.TimeoutException) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) WaitingHandler(com.compomics.util.waiting.WaitingHandler) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) ProteinMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.ProteinMatchesIterator) ProcessingParameters(com.compomics.util.parameters.tools.ProcessingParameters) ModificationProvider(com.compomics.util.experiment.biology.modifications.ModificationProvider) ExecutorService(java.util.concurrent.ExecutorService) MatchValidationLevel(com.compomics.util.experiment.identification.validation.MatchValidationLevel) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) Identification(com.compomics.util.experiment.identification.Identification) Executors(java.util.concurrent.Executors) TimeUnit(java.util.concurrent.TimeUnit) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) ModificationLocalizationScorer(eu.isas.peptideshaker.ptm.ModificationLocalizationScorer) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) TreeMap(java.util.TreeMap) Entry(java.util.Map.Entry) ProteinUtils(com.compomics.util.experiment.identification.utils.ProteinUtils) ExceptionHandler(com.compomics.util.exceptions.ExceptionHandler) Metrics(com.compomics.util.experiment.identification.peptide_shaker.Metrics) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TreeSet(java.util.TreeSet) ProteinMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.ProteinMatchesIterator) HashSet(java.util.HashSet) TreeMap(java.util.TreeMap) ExecutorService(java.util.concurrent.ExecutorService)

Example 3 with WaitingHandler

use of com.compomics.util.waiting.WaitingHandler in project peptide-shaker by compomics.

the class GroupSimplification method removeRedundantGroups.

/**
 * Remove groups that can be explained by a simpler group.
 *
 * @param identification the identification class containing all
 * identification matches
 * @param identificationParameters the identification parameters
 * @param sequenceProvider the sequence provider
 * @param proteinDetailsProvider the protein details provider
 * @param waitingHandler the handler displaying feedback to the user
 */
public void removeRedundantGroups(Identification identification, IdentificationParameters identificationParameters, SequenceProvider sequenceProvider, ProteinDetailsProvider proteinDetailsProvider, WaitingHandler waitingHandler) {
    int max = identification.getProteinIdentification().size();
    if (waitingHandler != null) {
        waitingHandler.setWaitingText("Symplifying Protein Groups. Please Wait...");
        waitingHandler.setSecondaryProgressCounterIndeterminate(false);
        waitingHandler.setMaxSecondaryProgressCounter(max);
    }
    HashSet<Long> proteinGroupKeys = identification.getProteinIdentification();
    HashSet<Long> toDelete = new HashSet<>();
    HashMap<Long, long[]> processedKeys = new HashMap<>();
    SimpleSemaphore mutex = new SimpleSemaphore(1);
    proteinGroupKeys.stream().filter(key -> !processedKeys.containsKey(key)).map(key -> identification.getProteinMatch(key)).filter(proteinMatch -> proteinMatch.getNProteins() > 1).forEach(proteinSharedGroup -> removeRedundantGroups(identification, identificationParameters, sequenceProvider, proteinDetailsProvider, proteinSharedGroup, processedKeys, toDelete, mutex, waitingHandler));
    int totalSimplified = Arrays.stream(nDeleted).sum();
    if (totalSimplified > 0) {
        if (waitingHandler != null) {
            waitingHandler.appendReport(toDelete.size() + " unlikely protein mappings found:", true, true);
            String padding = "    ";
            for (int i = 0; i < ProteinInference.GroupSimplificationOption.values().length; i++) {
                int iSimplified = nDeleted[i];
                if (iSimplified > 0) {
                    ProteinInference.GroupSimplificationOption option = ProteinInference.GroupSimplificationOption.values()[i];
                    waitingHandler.appendReport(padding + "- " + iSimplified + " " + option.description + ".", true, true);
                }
            }
            waitingHandler.setSecondaryProgressCounterIndeterminate(false);
            waitingHandler.setMaxSecondaryProgressCounter(toDelete.size());
        }
        toDelete.stream().forEach(key -> {
            identification.removeObject(key);
            if (waitingHandler != null) {
                if (waitingHandler.isRunCanceled()) {
                    return;
                }
                waitingHandler.increaseSecondaryProgressCounter();
            }
        });
    }
}
Also used : Arrays(java.util.Arrays) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) Identification(com.compomics.util.experiment.identification.Identification) PeptideUtils(com.compomics.util.experiment.identification.utils.PeptideUtils) HashMap(java.util.HashMap) DigestionParameters(com.compomics.util.parameters.identification.search.DigestionParameters) ProteinDetailsProvider(com.compomics.util.experiment.io.biology.protein.ProteinDetailsProvider) SimpleSemaphore(com.compomics.util.threading.SimpleSemaphore) Collectors(java.util.stream.Collectors) ProteinInferenceParameters(com.compomics.util.parameters.identification.advanced.ProteinInferenceParameters) Sets(com.google.common.collect.Sets) KEYWORDS_UNCHARACTERIZED(eu.isas.peptideshaker.protein_inference.ProteinInference.KEYWORDS_UNCHARACTERIZED) HashSet(java.util.HashSet) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) WaitingHandler(com.compomics.util.waiting.WaitingHandler) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) SimpleSemaphore(com.compomics.util.threading.SimpleSemaphore) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 4 with WaitingHandler

use of com.compomics.util.waiting.WaitingHandler 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 5 with WaitingHandler

use of com.compomics.util.waiting.WaitingHandler in project peptide-shaker by compomics.

the class PsAnnotationSection method writeSection.

/**
 * Writes the desired section.
 *
 * @param annotationPreferences the annotation preferences of the project
 * @param waitingHandler the waiting handler
 *
 * @throws IOException exception thrown whenever an error occurred while
 * writing the file.
 */
public void writeSection(AnnotationParameters annotationPreferences, WaitingHandler waitingHandler) throws IOException {
    if (waitingHandler != null) {
        waitingHandler.setSecondaryProgressCounterIndeterminate(true);
    }
    if (header) {
        if (indexes) {
            writer.writeHeaderText("");
            writer.addSeparator();
        }
        writer.writeHeaderText("Parameter");
        writer.addSeparator();
        writer.writeHeaderText("Value");
        writer.newLine();
    }
    int line = 1;
    for (ExportFeature exportFeature : annotationFeatures) {
        if (indexes) {
            writer.write(Integer.toString(line));
            writer.addSeparator();
        }
        writer.write(exportFeature.getTitle());
        writer.addSeparator();
        PsAnnotationFeature annotationFeature = (PsAnnotationFeature) exportFeature;
        switch(annotationFeature) {
            case automatic_annotation:
                if (annotationPreferences.isAutomaticAnnotation()) {
                    writer.write("Yes");
                } else {
                    writer.write("No");
                }
                break;
            case fragment_ion_accuracy:
                writer.write(Double.toString(annotationPreferences.getFragmentIonAccuracy()));
                break;
            case intensity_limit:
                writer.write(Double.toString(annotationPreferences.getAnnotationIntensityLimit()));
                break;
            case neutral_losses:
                String neutralLosses = annotationPreferences.getNeutralLosses().stream().map(neutralLoss -> neutralLoss.name).collect(Collectors.joining(", "));
                writer.write(neutralLosses);
                break;
            case neutral_losses_sequence_dependence:
                String value = annotationPreferences.areNeutralLossesSequenceAuto() ? "Yes" : "No";
                writer.write(value);
                break;
            case selected_ions:
                String ions = annotationPreferences.getFragmentIonTypes().stream().map(fragmentType -> PeptideFragmentIon.getSubTypeAsString(fragmentType)).collect(Collectors.joining(", "));
                writer.write(ions);
                break;
            default:
                writer.write("Not implemented");
        }
        writer.newLine();
        line++;
    }
}
Also used : WaitingHandler(com.compomics.util.waiting.WaitingHandler) ExportWriter(com.compomics.util.io.export.ExportWriter) PeptideFragmentIon(com.compomics.util.experiment.biology.ions.impl.PeptideFragmentIon) ExportFeature(com.compomics.util.io.export.ExportFeature) PsAnnotationFeature(com.compomics.util.io.export.features.peptideshaker.PsAnnotationFeature) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) AnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters) EnumSet(java.util.EnumSet) ArrayList(java.util.ArrayList) ExportFeature(com.compomics.util.io.export.ExportFeature) PsAnnotationFeature(com.compomics.util.io.export.features.peptideshaker.PsAnnotationFeature)

Aggregations

WaitingHandler (com.compomics.util.waiting.WaitingHandler)16 Identification (com.compomics.util.experiment.identification.Identification)12 SequenceProvider (com.compomics.util.experiment.io.biology.protein.SequenceProvider)12 ArrayList (java.util.ArrayList)12 Collectors (java.util.stream.Collectors)12 PSParameter (com.compomics.util.experiment.identification.peptide_shaker.PSParameter)11 IdentificationParameters (com.compomics.util.parameters.identification.IdentificationParameters)11 Arrays (java.util.Arrays)9 HashSet (java.util.HashSet)9 ProteinMatch (com.compomics.util.experiment.identification.matches.ProteinMatch)8 HashMap (java.util.HashMap)8 TreeMap (java.util.TreeMap)8 TreeSet (java.util.TreeSet)8 SpectrumMatch (com.compomics.util.experiment.identification.matches.SpectrumMatch)7 ProteinDetailsProvider (com.compomics.util.experiment.io.biology.protein.ProteinDetailsProvider)7 SpectrumProvider (com.compomics.util.experiment.mass_spectrometry.SpectrumProvider)7 IOException (java.io.IOException)7 Peptide (com.compomics.util.experiment.biology.proteins.Peptide)6 IdentificationFeaturesGenerator (com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator)6 PeptideAssumption (com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption)6