Search in sources :

Example 1 with ModificationFactory

use of com.compomics.util.experiment.biology.modifications.ModificationFactory in project peptide-shaker by compomics.

the class QCPanel method getPeptideModificationEnrichmentSpecificityDataset.

/**
 * Returns the dataset for the peptide modification rate QC plot.
 *
 * @return the dataset for the peptide modification rate QC plot
 */
private DefaultCategoryDataset getPeptideModificationEnrichmentSpecificityDataset() {
    ModificationFactory modificationFactory = ModificationFactory.getInstance();
    Identification identification = peptideShakerGUI.getIdentification();
    SequenceProvider sequenceProvider = peptideShakerGUI.getSequenceProvider();
    IdentificationParameters identificationParameters = peptideShakerGUI.getIdentificationParameters();
    ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
    SequenceMatchingParameters modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
    ArrayList<String> modNames = modificationParameters.getAllNotFixedModifications();
    HashMap<String, Integer> modifiedPeptidesMap = new HashMap<>(modNames.size());
    HashMap<String, Integer> possiblyModifiedPeptidesMap = new HashMap<>(modNames.size());
    progressDialog.setPrimaryProgressCounterIndeterminate(false);
    progressDialog.setMaxPrimaryProgressCounter(identification.getPeptideIdentification().size());
    progressDialog.setValue(0);
    PeptideMatchesIterator peptideMatchesIterator = identification.getPeptideMatchesIterator(progressDialog);
    PeptideMatch peptideMatch;
    while ((peptideMatch = peptideMatchesIterator.next()) != null) {
        PSParameter psParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
        if (psParameter.getMatchValidationLevel().isValidated()) {
            Peptide peptide = peptideMatch.getPeptide();
            for (String modName : modificationParameters.getAllNotFixedModifications()) {
                Modification modification = modificationFactory.getModification(modName);
                int[] possibleSites = ModificationUtils.getPossibleModificationSites(peptide, modification, sequenceProvider, modificationSequenceMatchingParameters);
                if (possibleSites.length != 0) {
                    Integer nPossiblePeptides = possiblyModifiedPeptidesMap.get(modName);
                    if (nPossiblePeptides == null) {
                        possiblyModifiedPeptidesMap.put(modName, 1);
                    } else {
                        possiblyModifiedPeptidesMap.put(modName, nPossiblePeptides + 1);
                    }
                    boolean modified = false;
                    for (ModificationMatch modificationMatch : peptide.getVariableModifications()) {
                        if (modificationMatch.getModification().equals(modName)) {
                            modified = true;
                            break;
                        }
                    }
                    if (modified) {
                        Integer nModifiedPeptides = modifiedPeptidesMap.get(modName);
                        if (nModifiedPeptides == null) {
                            modifiedPeptidesMap.put(modName, 1);
                        } else {
                            modifiedPeptidesMap.put(modName, nModifiedPeptides + 1);
                        }
                    }
                }
            }
        }
        if (progressDialog.isRunCanceled()) {
            break;
        }
        progressDialog.increaseSecondaryProgressCounter();
    }
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (String modName : modificationParameters.getAllNotFixedModifications()) {
        Integer nFound = modifiedPeptidesMap.get(modName);
        if (nFound == null) {
            nFound = 0;
        }
        Integer nPossible = possiblyModifiedPeptidesMap.get(modName);
        Double rate = 0.0;
        if (nPossible != null) {
            rate = (100.0 * nFound) / nPossible;
        }
        dataset.addValue(rate, "Modified", modName);
        double rest = 0.0;
        if (nPossible != null) {
            rest = 100 - rate;
        }
        dataset.addValue(rest, "Not Modified", modName);
    }
    return dataset;
}
Also used : Modification(com.compomics.util.experiment.biology.modifications.Modification) ModificationMatch(com.compomics.util.experiment.identification.matches.ModificationMatch) PeptideMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.PeptideMatchesIterator) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) HashMap(java.util.HashMap) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) Identification(com.compomics.util.experiment.identification.Identification) ModificationFactory(com.compomics.util.experiment.biology.modifications.ModificationFactory) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter)

Example 2 with ModificationFactory

use of com.compomics.util.experiment.biology.modifications.ModificationFactory in project peptide-shaker by compomics.

the class QCPanel method getPeptideModificationEfficiencyDataset.

/**
 * Returns the dataset for the peptide modification efficiency QC plot.
 *
 * @return the dataset for the peptide modification efficiency QC plot
 */
private DefaultCategoryDataset getPeptideModificationEfficiencyDataset() {
    ModificationFactory modificationFactory = ModificationFactory.getInstance();
    Identification identification = peptideShakerGUI.getIdentification();
    SequenceProvider sequenceProvider = peptideShakerGUI.getSequenceProvider();
    IdentificationParameters identificationParameters = peptideShakerGUI.getIdentificationParameters();
    ModificationParameters modificationParameters = identificationParameters.getSearchParameters().getModificationParameters();
    SequenceMatchingParameters modificationSequenceMatchingPreferences = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
    ArrayList<String> modNames = modificationParameters.getAllNotFixedModifications();
    HashMap<String, Integer> modifiedSitesMap = new HashMap<>(modNames.size());
    HashMap<String, Integer> possibleSitesMap = new HashMap<>(modNames.size());
    PSParameter psParameter = new PSParameter();
    progressDialog.setPrimaryProgressCounterIndeterminate(false);
    progressDialog.setMaxPrimaryProgressCounter(identification.getPeptideIdentification().size());
    progressDialog.setValue(0);
    PeptideMatchesIterator peptideMatchesIterator = identification.getPeptideMatchesIterator(progressDialog);
    PeptideMatch peptideMatch;
    while ((peptideMatch = peptideMatchesIterator.next()) != null) {
        psParameter = (PSParameter) peptideMatch.getUrParam(psParameter);
        if (psParameter.getMatchValidationLevel().isValidated()) {
            Peptide peptide = peptideMatch.getPeptide();
            HashMap<String, Integer> peptideModificationsMap = new HashMap<>(peptide.getVariableModifications().length);
            for (ModificationMatch modificationMatch : peptide.getVariableModifications()) {
                String modName = modificationMatch.getModification();
                Integer occurrence = peptideModificationsMap.get(modName);
                if (occurrence == null) {
                    peptideModificationsMap.put(modName, 1);
                } else {
                    peptideModificationsMap.put(modName, occurrence + 1);
                }
            }
            for (String modName : modificationParameters.getAllNotFixedModifications()) {
                Modification modification = modificationFactory.getModification(modName);
                int[] possibleSites = ModificationUtils.getPossibleModificationSites(peptide, modification, sequenceProvider, modificationSequenceMatchingPreferences);
                if (possibleSites.length != 0) {
                    Integer occurrencePeptide = peptideModificationsMap.get(modName);
                    if (occurrencePeptide != null) {
                        Integer occurrenceDataset = modifiedSitesMap.get(modName);
                        if (occurrenceDataset == null) {
                            modifiedSitesMap.put(modName, occurrencePeptide);
                        } else {
                            modifiedSitesMap.put(modName, occurrenceDataset + occurrencePeptide);
                        }
                    }
                    Integer possibleSitesDataset = possibleSitesMap.get(modName);
                    if (possibleSitesDataset == null) {
                        possibleSitesMap.put(modName, possibleSites.length);
                    } else {
                        possibleSitesMap.put(modName, possibleSitesDataset + possibleSites.length);
                    }
                }
            }
        }
        if (progressDialog.isRunCanceled()) {
            break;
        }
        progressDialog.increaseSecondaryProgressCounter();
    }
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (String modName : modificationParameters.getAllNotFixedModifications()) {
        Integer nFound = modifiedSitesMap.get(modName);
        if (nFound == null) {
            nFound = 0;
        }
        Integer nPossible = possibleSitesMap.get(modName);
        Double rate = 0.0;
        if (nPossible != null) {
            rate = (100.0 * nFound) / nPossible;
        }
        dataset.addValue(rate, "Modified", modName);
        double rest = 100 - rate;
        dataset.addValue(rest, "Not Modified", modName);
    }
    return dataset;
}
Also used : Modification(com.compomics.util.experiment.biology.modifications.Modification) ModificationMatch(com.compomics.util.experiment.identification.matches.ModificationMatch) PeptideMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.PeptideMatchesIterator) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) HashMap(java.util.HashMap) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) Identification(com.compomics.util.experiment.identification.Identification) ModificationFactory(com.compomics.util.experiment.biology.modifications.ModificationFactory) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter)

Example 3 with ModificationFactory

use of com.compomics.util.experiment.biology.modifications.ModificationFactory in project peptide-shaker by compomics.

the class PsmImportRunnable method importAssumptions.

/**
 * Import the assumptions. Maps algorithm specific modifications to the
 * generic objects. Relocates aberrant modifications and removes assumptions
 * where not all modifications are mapped. Verifies whether there is a best
 * match for the spectrum according to the search engine score.
 *
 * @param spectrumMatch the spectrum match to import
 * @param assumptions the assumptions to import
 * @param peptideSpectrumAnnotator the spectrum annotator to use to annotate
 * spectra
 * @param waitingHandler waiting handler to display progress and allow
 * canceling the import
 */
private void importAssumptions(SpectrumMatch spectrumMatch) {
    PeptideAssumptionFilter peptideAssumptionFilter = identificationParameters.getPeptideAssumptionFilter();
    SequenceMatchingParameters sequenceMatchingParameters = identificationParameters.getSequenceMatchingParameters();
    SequenceMatchingParameters modificationSequenceMatchingParameters = identificationParameters.getModificationLocalizationParameters().getSequenceMatchingParameters();
    SearchParameters searchParameters = identificationParameters.getSearchParameters();
    HashMap<Integer, TreeMap<Double, ArrayList<PeptideAssumption>>> peptideAssumptions = spectrumMatch.getPeptideAssumptionsMap();
    for (Map.Entry<Integer, TreeMap<Double, ArrayList<PeptideAssumption>>> entry : peptideAssumptions.entrySet()) {
        int advocateId = entry.getKey();
        if (advocateId == Advocate.xtandem.getIndex()) {
            PsmImporter.verifyXTandemModifications(identificationParameters);
        }
        TreeMap<Double, ArrayList<PeptideAssumption>> assumptionsForAdvocate = entry.getValue();
        TreeSet<Double> scores = new TreeSet<>(assumptionsForAdvocate.keySet());
        for (double score : scores) {
            ArrayList<PeptideAssumption> oldAssumptions = assumptionsForAdvocate.get(score);
            ArrayList<PeptideAssumption> newAssumptions = new ArrayList<>(oldAssumptions.size());
            nPeptideAssumptionsTotal += oldAssumptions.size();
            for (PeptideAssumption peptideAssumption : oldAssumptions) {
                Peptide peptide = peptideAssumption.getPeptide();
                String peptideSequence = peptide.getSequence();
                // Ignore peptides that are too long or too short
                if (peptideSequence.length() >= peptideAssumptionFilter.getMinPepLength() && peptideSequence.length() <= peptideAssumptionFilter.getMaxPepLength()) {
                    // Map peptide to protein
                    proteinMapping(peptide);
                    // map the algorithm-specific modifications to utilities modifications
                    // If there are not enough sites to put them all on the sequence, add an unknown modification
                    // Note: this needs to be done for tag based assumptions as well since the protein mapping can
                    // return erroneous modifications for some pattern based modifications
                    ModificationParameters modificationParameters = searchParameters.getModificationParameters();
                    ModificationMatch[] modificationMatches = peptide.getVariableModifications();
                    HashMap<Integer, ArrayList<String>> expectedNames = new HashMap<>(modificationMatches.length);
                    HashMap<ModificationMatch, ArrayList<String>> modNames = new HashMap<>(modificationMatches.length);
                    for (ModificationMatch modMatch : modificationMatches) {
                        HashMap<Integer, HashSet<String>> tempNames = ModificationNameMapper.getPossibleModificationNames(peptide, modMatch, fileReader, searchParameters, modificationSequenceMatchingParameters, sequenceProvider, modificationFactory);
                        HashSet<String> allNames = tempNames.values().stream().flatMap(nameList -> nameList.stream()).collect(Collectors.toCollection(HashSet::new));
                        modNames.put(modMatch, new ArrayList<>(allNames));
                        for (int pos : tempNames.keySet()) {
                            ArrayList<String> namesAtPosition = expectedNames.get(pos);
                            if (namesAtPosition == null) {
                                namesAtPosition = new ArrayList<>(2);
                                expectedNames.put(pos, namesAtPosition);
                            }
                            for (String modName : tempNames.get(pos)) {
                                if (!namesAtPosition.contains(modName)) {
                                    namesAtPosition.add(modName);
                                }
                            }
                        }
                    }
                    if (peptide.getVariableModifications().length > 0) {
                        ModificationLocalizationMapper.modificationLocalization(peptide, expectedNames, modNames, identificationParameters, fileReader, modificationFactory);
                    }
                    if (peptideAssumptionFilter.validateModifications(peptide, sequenceMatchingParameters, modificationSequenceMatchingParameters, searchParameters.getModificationParameters())) {
                        // Set peptide key
                        peptide.setKey(Peptide.getKey(peptide.getSequence(), peptide.getVariableModifications()));
                        // Estimate mass
                        peptide.getMass(modificationParameters, sequenceProvider, modificationSequenceMatchingParameters);
                        // Add new assumption
                        newAssumptions.add(peptideAssumption);
                        // Get protein count
                        for (String protein : peptide.getProteinMapping().navigableKeySet()) {
                            Integer count = proteinCount.get(protein);
                            if (count != null) {
                                proteinCount.put(protein, count + 1);
                            } else {
                                proteinCount.put(protein, 1);
                            }
                        }
                    } else {
                        modificationIssue++;
                    }
                } else {
                    peptideIssue++;
                }
            }
            if (!newAssumptions.isEmpty()) {
                assumptionsForAdvocate.put(score, newAssumptions);
            } else {
                assumptionsForAdvocate.remove(score);
            }
        }
    }
}
Also used : ModificationMatch(com.compomics.util.experiment.identification.matches.ModificationMatch) IntStream(java.util.stream.IntStream) PeptideVariantMatches(com.compomics.util.experiment.identification.matches.PeptideVariantMatches) ModificationFactory(com.compomics.util.experiment.biology.modifications.ModificationFactory) Arrays(java.util.Arrays) FastaMapper(com.compomics.util.experiment.identification.protein_inference.FastaMapper) IdfileReader(com.compomics.util.experiment.io.identification.IdfileReader) TagAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.TagAssumption) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) WaitingHandler(com.compomics.util.waiting.WaitingHandler) Map(java.util.Map) Advocate(com.compomics.util.experiment.identification.Advocate) PeptideAssumptionFilter(com.compomics.util.experiment.identification.filtering.PeptideAssumptionFilter) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) Identification(com.compomics.util.experiment.identification.Identification) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) Collectors(java.util.stream.Collectors) File(java.io.File) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) PeptideProteinMapping(com.compomics.util.experiment.identification.protein_inference.PeptideProteinMapping) TreeMap(java.util.TreeMap) ModificationLocalizationMapper(com.compomics.util.experiment.identification.modification.mapping.ModificationLocalizationMapper) ModificationNameMapper(com.compomics.util.experiment.identification.modification.mapping.ModificationNameMapper) ExceptionHandler(com.compomics.util.exceptions.ExceptionHandler) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) ModificationMatch(com.compomics.util.experiment.identification.matches.ModificationMatch) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) TreeSet(java.util.TreeSet) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) HashSet(java.util.HashSet) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) TreeMap(java.util.TreeMap) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) PeptideAssumptionFilter(com.compomics.util.experiment.identification.filtering.PeptideAssumptionFilter)

Example 4 with ModificationFactory

use of com.compomics.util.experiment.biology.modifications.ModificationFactory in project peptide-shaker by compomics.

the class DeepLcExport method deepLcExport.

/**
 * Exports a DeepLC training file for the given spectrum file.
 *
 * @param destinationFile The file where to write the export.
 * @param confidentHitsDestinationFile The file where to write the export
 * for confident hits.
 * @param keys The keys of the spectrum matches.
 * @param identification The identification object containing the matches.
 * @param modificationParameters The modification parameters.
 * @param sequenceMatchingParameters The sequence matching parameters.
 * @param sequenceProvider The sequence provider.
 * @param spectrumProvider The spectrum provider.
 * @param waitingHandler The waiting handler.
 */
public static void deepLcExport(File destinationFile, File confidentHitsDestinationFile, HashSet<Long> keys, Identification identification, ModificationParameters modificationParameters, SequenceMatchingParameters sequenceMatchingParameters, SequenceProvider sequenceProvider, SpectrumProvider spectrumProvider, WaitingHandler waitingHandler) {
    ModificationFactory modificationFactory = ModificationFactory.getInstance();
    HashSet<Long> processedPeptideKeys = new HashSet<>();
    SimpleSemaphore writingSemaphore = new SimpleSemaphore(1);
    try (SimpleFileWriter writer = new SimpleFileWriter(destinationFile, true)) {
        writer.writeLine("seq,modifications,tr");
        try (SimpleFileWriter writerConfident = new SimpleFileWriter(confidentHitsDestinationFile, true)) {
            writerConfident.writeLine("seq,modifications,tr");
            long[] spectrumKeys = keys.stream().mapToLong(a -> a).toArray();
            SpectrumMatchesIterator spectrumMatchesIterator = identification.getSpectrumMatchesIterator(spectrumKeys, waitingHandler);
            SpectrumMatch spectrumMatch;
            while ((spectrumMatch = spectrumMatchesIterator.next()) != null) {
                // Display progress
                if (waitingHandler != null) {
                    waitingHandler.increaseSecondaryProgressCounter();
                    if (waitingHandler.isRunCanceled()) {
                        return;
                    }
                }
                // Measured retention time
                String spectrumFile = spectrumMatch.getSpectrumFile();
                String spectrumTitle = spectrumMatch.getSpectrumTitle();
                Precursor precursor = spectrumProvider.getPrecursor(spectrumFile, spectrumTitle);
                double retentionTime = precursor.rt;
                // Export all candidate peptides
                spectrumMatch.getAllPeptideAssumptions().parallel().forEach(peptideAssumption -> writePeptideCandidate(peptideAssumption, retentionTime, modificationParameters, sequenceProvider, sequenceMatchingParameters, modificationFactory, processedPeptideKeys, writingSemaphore, writer));
                // Check whether the spectrum yielded a confident peptide
                if (spectrumMatch.getBestPeptideAssumption() != null && ((PSParameter) spectrumMatch.getUrParam(PSParameter.dummy)).getMatchValidationLevel().isValidated()) {
                    // Export the confident peptide to the confident peptides file
                    writePeptideCandidate(spectrumMatch.getBestPeptideAssumption(), retentionTime, modificationParameters, sequenceProvider, sequenceMatchingParameters, modificationFactory, processedPeptideKeys, writingSemaphore, writerConfident);
                }
            }
        }
    }
}
Also used : ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) ModificationFactory(com.compomics.util.experiment.biology.modifications.ModificationFactory) PeptideAssumption(com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption) SpectrumMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator) DeepLcUtils(eu.isas.peptideshaker.utils.DeepLcUtils) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) Identification(com.compomics.util.experiment.identification.Identification) HashMap(java.util.HashMap) SimpleSemaphore(com.compomics.util.threading.SimpleSemaphore) Collectors(java.util.stream.Collectors) File(java.io.File) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) WaitingHandler(com.compomics.util.waiting.WaitingHandler) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) SimpleFileWriter(com.compomics.util.io.flat.SimpleFileWriter) SpectrumProvider(com.compomics.util.experiment.mass_spectrometry.SpectrumProvider) Precursor(com.compomics.util.experiment.mass_spectrometry.spectra.Precursor) Precursor(com.compomics.util.experiment.mass_spectrometry.spectra.Precursor) SpectrumMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator) ModificationFactory(com.compomics.util.experiment.biology.modifications.ModificationFactory) SimpleSemaphore(com.compomics.util.threading.SimpleSemaphore) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) SimpleFileWriter(com.compomics.util.io.flat.SimpleFileWriter) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) HashSet(java.util.HashSet)

Example 5 with ModificationFactory

use of com.compomics.util.experiment.biology.modifications.ModificationFactory in project peptide-shaker by compomics.

the class Ms2PipExport method ms2pipExport.

/**
 * Exports a ms2pip training file for the given spectrum file.
 *
 * @param peprecFile The file where to write the export.
 * @param identification The identification object containing the matches.
 * @param modificationParameters The modification parameters.
 * @param sequenceMatchingParameters The sequence matching parameters.
 * @param sequenceProvider The sequence provider.
 * @param spectrumProvider The spectrum provider.
 * @param waitingHandler The waiting handler.
 */
public static void ms2pipExport(File peprecFile, Identification identification, ModificationParameters modificationParameters, SequenceMatchingParameters sequenceMatchingParameters, SequenceProvider sequenceProvider, SpectrumProvider spectrumProvider, WaitingHandler waitingHandler) {
    ModificationFactory modificationFactory = ModificationFactory.getInstance();
    try (SimpleFileWriter writer = new SimpleFileWriter(peprecFile, true)) {
        writer.writeLine("spec_id modifications peptide charge");
        SpectrumMatchesIterator spectrumMatchesIterator = identification.getSpectrumMatchesIterator(waitingHandler);
        HashSet<Long> processedPeptideKeys = new HashSet<>();
        SimpleSemaphore writingSemaphore = new SimpleSemaphore(1);
        SpectrumMatch spectrumMatch;
        while ((spectrumMatch = spectrumMatchesIterator.next()) != null) {
            // Display progress
            if (waitingHandler != null) {
                waitingHandler.increaseSecondaryProgressCounter();
                if (waitingHandler.isRunCanceled()) {
                    return;
                }
            }
            // Export all candidate peptides
            spectrumMatch.getAllPeptideAssumptions().parallel().forEach(peptideAssumption -> writePeptideCandidate(peptideAssumption, modificationParameters, sequenceProvider, sequenceMatchingParameters, modificationFactory, processedPeptideKeys, writingSemaphore, writer));
        }
    }
}
Also used : ModificationFactory(com.compomics.util.experiment.biology.modifications.ModificationFactory) SimpleSemaphore(com.compomics.util.threading.SimpleSemaphore) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) SimpleFileWriter(com.compomics.util.io.flat.SimpleFileWriter) SpectrumMatchesIterator(com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator) HashSet(java.util.HashSet)

Aggregations

ModificationFactory (com.compomics.util.experiment.biology.modifications.ModificationFactory)13 Modification (com.compomics.util.experiment.biology.modifications.Modification)8 Peptide (com.compomics.util.experiment.biology.proteins.Peptide)7 SpectrumMatch (com.compomics.util.experiment.identification.matches.SpectrumMatch)7 SequenceProvider (com.compomics.util.experiment.io.biology.protein.SequenceProvider)7 SequenceMatchingParameters (com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters)7 Identification (com.compomics.util.experiment.identification.Identification)6 ModificationMatch (com.compomics.util.experiment.identification.matches.ModificationMatch)6 ModificationParameters (com.compomics.util.parameters.identification.search.ModificationParameters)6 HashMap (java.util.HashMap)6 SimpleFileWriter (com.compomics.util.io.flat.SimpleFileWriter)5 IdentificationParameters (com.compomics.util.parameters.identification.IdentificationParameters)5 ArrayList (java.util.ArrayList)5 Collectors (java.util.stream.Collectors)5 PeptideMatch (com.compomics.util.experiment.identification.matches.PeptideMatch)4 PSParameter (com.compomics.util.experiment.identification.peptide_shaker.PSParameter)4 PeptideAssumption (com.compomics.util.experiment.identification.spectrum_assumptions.PeptideAssumption)4 HashSet (java.util.HashSet)4 SpectrumMatchesIterator (com.compomics.util.experiment.identification.matches_iterators.SpectrumMatchesIterator)3 SimpleSemaphore (com.compomics.util.threading.SimpleSemaphore)3