use of com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator in project peptide-shaker by compomics.
the class OverviewPanel method updatePsmSelection.
/**
* Update the PSM selection according to the currently selected peptide.
*
* @param row the row index of the selected peptide
* @param forcePsmOrderUpdate if true, the sorted listed is recreated even
* if not needed
*/
private void updatePsmSelection(int row, boolean forcePsmOrderUpdate) {
if (row != -1) {
this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
Identification identification = peptideShakerGUI.getIdentification();
IdentificationFeaturesGenerator identificationFeaturesGenerator = peptideShakerGUI.getIdentificationFeaturesGenerator();
SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) peptideTable.getModel();
int peptideIndex = tableModel.getViewIndex(row);
long peptideKey = peptideKeys[peptideIndex];
psmKeys = identificationFeaturesGenerator.getSortedPsmKeys(peptideKey, peptideShakerGUI.getUtilitiesUserParameters().getSortPsmsOnRt(), forcePsmOrderUpdate);
// clear the selection in case more than one row was selected for the last peptide
psmTable.clearSelection();
// update the table model
if (psmTable.getModel() instanceof PsmTableModel && ((PsmTableModel) psmTable.getModel()).isInstantiated()) {
((PsmTableModel) psmTable.getModel()).updateDataModel(identification, peptideShakerGUI.getDisplayFeaturesGenerator(), peptideShakerGUI.getIdentificationParameters(), psmKeys);
((PsmTableModel) psmTable.getModel()).setSelfUpdating(true);
((PsmTableModel) psmTable.getModel()).resetSorting(new ProgressDialogX(peptideShakerGUI, Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker.gif")), Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker-orange.gif")), true));
} else {
PsmTableModel psmTableModel = new PsmTableModel(identification, peptideShakerGUI.getDisplayFeaturesGenerator(), peptideShakerGUI.getSpectrumProvider(), peptideShakerGUI.getIdentificationParameters(), psmKeys, peptideShakerGUI.getDisplayParameters().showScores(), peptideShakerGUI.getExceptionHandler());
psmTable.setModel(psmTableModel);
}
setPsmTableProperties();
showSparkLines(peptideShakerGUI.showSparklines());
int nValidatedPsms = identificationFeaturesGenerator.getNValidatedSpectraForPeptide(peptideKey);
int nConfidentPsms = identificationFeaturesGenerator.getNConfidentSpectraForPeptide(peptideKey);
int nPsms = psmTable.getRowCount();
String title = PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Peptide Spectrum Matches (";
if (nConfidentPsms > 0) {
title += nValidatedPsms + "/" + nPsms + " - " + nConfidentPsms + " confident, " + (nValidatedPsms - nConfidentPsms) + " doubtful";
} else {
title += nValidatedPsms + "/" + nPsms;
}
title += ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING;
((TitledBorder) psmsPanel.getBorder()).setTitle(title);
psmsPanel.repaint();
updateSelection(true);
newItemSelection();
// update the sequence coverage map
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
int proteinIndex, selectedProteinRow = proteinTable.getSelectedRow();
if (selectedProteinRow != -1) {
SelfUpdatingTableModel proteinTableModel = (SelfUpdatingTableModel) proteinTable.getModel();
proteinIndex = proteinTableModel.getViewIndex(selectedProteinRow);
} else {
proteinIndex = 0;
}
long proteinKey = proteinKeys[proteinIndex];
ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinKey);
updateSequenceCoverage(proteinKey, proteinMatch.getLeadingAccession());
} catch (Exception e) {
peptideShakerGUI.catchException(e);
}
}
});
this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
}
}
use of com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator in project peptide-shaker by compomics.
the class ProteinStructurePanel method updatedPeptideSelection.
/**
* Updates the peptide selection according to the currently selected
* protein.
*
* @param proteinIndex the row index of the protein
*/
private void updatedPeptideSelection(int proteinIndex) {
if (proteinIndex != -1) {
this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
DefaultTableModel dm = (DefaultTableModel) peptideTable.getModel();
dm.getDataVector().removeAllElements();
dm.fireTableDataChanged();
long proteinMatchKey = proteinKeys[proteinIndex];
ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinMatchKey);
String proteinAccession = proteinMatch.getLeadingAccession();
peptideTableMap = new HashMap<>();
int index = 0;
long[] peptideKeys = peptideShakerGUI.getIdentificationFeaturesGenerator().getSortedPeptideKeys(proteinMatchKey);
for (long peptideKey : peptideKeys) {
PeptideMatch peptideMatch = peptideShakerGUI.getIdentification().getPeptideMatch(peptideKey);
PSParameter psParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
if (!psParameter.getHidden()) {
// find and add the peptide start and end indexes
StartIndexes startIndexes = new StartIndexes(Arrays.stream(peptideMatch.getPeptide().getProteinMapping().get(proteinAccession)).map(site -> site + 1).boxed().collect(Collectors.toCollection(ArrayList::new)));
int proteinInferenceType = psParameter.getProteinInferenceGroupClass();
// @TODO: should be replaced by a table model!!!
((DefaultTableModel) peptideTable.getModel()).addRow(new Object[] { index + 1, psParameter.getStarred(), proteinInferenceType, peptideShakerGUI.getDisplayFeaturesGenerator().getTaggedPeptideSequence(peptideMatch, true, true, true), startIndexes, false, psParameter.getMatchValidationLevel().getIndex() });
peptideTableMap.put(index + 1, peptideKey);
index++;
}
}
((DefaultTableModel) peptideTable.getModel()).fireTableDataChanged();
String title = PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Peptides (";
IdentificationFeaturesGenerator identificationFeaturesGenerator = peptideShakerGUI.getIdentificationFeaturesGenerator();
int nValidatedPeptides = identificationFeaturesGenerator.getNValidatedPeptides(proteinMatchKey);
int nConfidentPeptides = identificationFeaturesGenerator.getNConfidentPeptides(proteinMatchKey);
int nPeptides = proteinMatch.getPeptideCount();
if (nConfidentPeptides > 0) {
title += nValidatedPeptides + "/" + nPeptides + " - " + nConfidentPeptides + " confident, " + (nValidatedPeptides - nConfidentPeptides) + " doubtful";
} else {
title += nValidatedPeptides + "/" + nPeptides;
}
title += ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING;
((TitledBorder) peptidesPanel.getBorder()).setTitle(title);
peptidesPanel.repaint();
String proteinSequence = peptideShakerGUI.getSequenceProvider().getSequence(proteinAccession);
peptideTable.getColumn("Start").setCellRenderer(new JSparklinesMultiIntervalChartTableCellRenderer(PlotOrientation.HORIZONTAL, (double) proteinSequence.length(), ((double) proteinSequence.length()) / 50, peptideShakerGUI.getSparklineColor()));
((JSparklinesMultiIntervalChartTableCellRenderer) peptideTable.getColumn("Start").getCellRenderer()).showReferenceLine(true, 0.02, Color.BLACK);
((JSparklinesMultiIntervalChartTableCellRenderer) peptideTable.getColumn("Start").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 10);
// select the peptide in the table
if (peptideTable.getRowCount() > 0) {
int peptideRow = 0;
long peptideKey = peptideShakerGUI.getSelectedPeptideKey();
if (peptideKey != NO_KEY) {
peptideRow = getPeptideRow(peptideKey);
}
if (peptideRow != -1) {
peptideTable.setRowSelectionInterval(peptideRow, peptideRow);
peptideTable.scrollRectToVisible(peptideTable.getCellRect(peptideRow, 0, false));
peptideTableKeyReleased(null);
}
}
this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
}
}
use of com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator in project peptide-shaker by compomics.
the class PsdbParent method loadPsdbFile.
/**
* Loads the information from a psdb file.
*
* @param dbFolder the folder where to untar the project
* @param waitingHandler a waiting handler displaying feedback to the user.
* Ignored if null
* @param openFromZip flag determining if pdsb file was opened from a zip
* file
*
* @throws IOException thrown of IOException occurs exception thrown
* whenever an error occurred while reading or writing a file
*/
public void loadPsdbFile(File dbFolder, WaitingHandler waitingHandler, boolean openFromZip) throws IOException {
// close any open connection to an identification database
if (identification != null) {
identification.close(false);
}
// create the matches folder if it does not exist
if (!dbFolder.exists()) {
if (!dbFolder.mkdirs()) {
throw new IOException("Impossible to create folder " + dbFolder.getAbsolutePath() + ".");
}
}
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd-HHmmss");
String dbName = "tempDB-" + df.format(new Date()) + ".psdb";
File destinationFile = new File(dbFolder.getAbsolutePath(), dbName);
IoUtil.copyFile(psdbFile, destinationFile);
// GzUtils.gunzipFile(psdbFile, destinationFile, false); // @TODO: re-add when the zipping works
ObjectsDB objectsDB = new ObjectsDB(dbFolder.getAbsolutePath(), destinationFile.getName(), false);
// get the PeptideShaker parameters
PeptideShakerParameters psParameters = (PeptideShakerParameters) objectsDB.retrieveObject(PeptideShakerParameters.KEY);
identificationParameters = psParameters.getIdentificationParameters();
spectrumCountingParameters = psParameters.getSpectrumCountingPreferences();
projectDetails = psParameters.getProjectDetails();
metrics = psParameters.getMetrics();
geneMaps = psParameters.getGeneMaps();
filterParameters = psParameters.getFilterParameters();
displayParameters = psParameters.getDisplayParameters();
sequenceProvider = psParameters.getSequenceProvider();
proteinDetailsProvider = psParameters.getProteinDetailsProvider();
projectType = psParameters.getProjectType();
// find or create the fm index
FMIndex fmIndex = null;
if (openFromZip) {
File fmPath = new File(Paths.get(psdbFile.getParentFile().getAbsolutePath(), "data").toString());
for (File file : fmPath.listFiles()) {
if (file.getAbsoluteFile().toString().toLowerCase().endsWith(".fasta")) {
fmIndex = new FMIndex(file, psParameters.getIdentificationParameters().getFastaParameters(), waitingHandler, true, psParameters.getIdentificationParameters().getPeptideVariantsParameters(), psParameters.getIdentificationParameters().getSearchParameters());
break;
}
}
} else {
boolean fastaFileFound = false;
try {
FastaSummary fastaSummary = loadFastaFile(waitingHandler);
if (fastaSummary != null) {
fastaFileFound = true;
}
} catch (IOException e) {
fastaFileFound = false;
}
if (fastaFileFound) {
File fastaFile = new File(psParameters.getProjectDetails().getFastaFile());
fmIndex = new FMIndex(fastaFile, psParameters.getIdentificationParameters().getFastaParameters(), waitingHandler, true, psParameters.getIdentificationParameters().getPeptideVariantsParameters(), psParameters.getIdentificationParameters().getSearchParameters());
} else {
throw new IOException("FASTA file not found " + psParameters.getProjectDetails().getFastaFile() + ".");
}
}
psParameters.setSequenceProvider(fmIndex);
psParameters.setProteinDetailsProvider(fmIndex);
sequenceProvider = fmIndex;
proteinDetailsProvider = fmIndex;
objectsDB.updateObject(PeptideShakerParameters.KEY, psParameters);
projectParameters = (ProjectParameters) objectsDB.retrieveObject(ProjectParameters.key);
identification = new Identification(objectsDB);
// load identification attributes
IdentificationKeys identificationKeys = (IdentificationKeys) objectsDB.retrieveObject(IdentificationKeys.KEY);
identification.setIdentificationKeys(identificationKeys);
PSMaps psMaps = new PSMaps();
psMaps = (PSMaps) objectsDB.retrieveObject(psMaps.getParameterKey());
identification.addUrParam(psMaps);
// set up the spectrum provider
msFileHandler = new MsFileHandler();
// set up caches
identificationFeaturesGenerator = new IdentificationFeaturesGenerator(identification, identificationParameters, sequenceProvider, msFileHandler, metrics, spectrumCountingParameters);
IdentificationFeaturesCache identificationFeaturesCache = psParameters.getIdentificationFeaturesCache();
if (identificationFeaturesCache != null) {
identificationFeaturesGenerator.setIdentificationFeaturesCache(psParameters.getIdentificationFeaturesCache());
identificationFeaturesCache.setReadOnly(false);
}
if (waitingHandler != null && waitingHandler.isRunCanceled()) {
waitingHandler.setRunFinished();
return;
}
loadUserParameters();
userPreferences.addRecentProject(psdbFile);
saveUserParameters();
}
use of com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator 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);
}
}
}
Aggregations