use of eu.isas.peptideshaker.processing.ProteinProcessor in project peptide-shaker by compomics.
the class PeptideShaker method createProject.
/**
* Creates a PeptideShaker project.
*
* @param waitingHandler the handler displaying feedback to the user
* @param exceptionHandler handler for exceptions
* @param identificationParameters the identification parameters
* @param processingParameters the processing parameters
* @param projectType the project type
* @param spectrumCountingParameters the spectrum counting parameters
* @param spectrumProvider the spectrum provider
* @param setWaitingHandlerFinshedWhenDone if true, the waiting handler is
* set to finished when the project is created
* @param projectDetails the project details
*
* @throws java.lang.InterruptedException exception thrown if a thread gets
* interrupted
* @throws java.util.concurrent.TimeoutException exception thrown if a
* process times out
* @throws java.io.IOException if an exception occurs when parsing files
*/
public void createProject(IdentificationParameters identificationParameters, ProcessingParameters processingParameters, SpectrumCountingParameters spectrumCountingParameters, SpectrumProvider spectrumProvider, ProjectDetails projectDetails, ProjectType projectType, WaitingHandler waitingHandler, boolean setWaitingHandlerFinshedWhenDone, ExceptionHandler exceptionHandler) throws InterruptedException, TimeoutException, IOException {
identification.getObjectsDB().commit();
identificationFeaturesGenerator = new IdentificationFeaturesGenerator(identification, identificationParameters, sequenceProvider, spectrumProvider, metrics, spectrumCountingParameters);
matchesValidator = new MatchesValidator(new TargetDecoyMap(), new TargetDecoyMap(), new TargetDecoyMap());
if (waitingHandler.isRunCanceled()) {
return;
}
PsmScoringParameters psmScoringPreferences = identificationParameters.getPsmScoringParameters();
FastaParameters fastaParameters = identificationParameters.getFastaParameters();
FastaSummary fastaSummary = FastaSummary.getSummary(projectDetails.getFastaFile(), fastaParameters, waitingHandler);
// set the background species
identificationParameters.getGeneParameters().setBackgroundSpeciesFromFastaSummary(fastaSummary);
ArrayList<Integer> usedAlgorithms = projectDetails.getIdentificationAlgorithms();
if (psmScoringPreferences.isScoringNeeded(usedAlgorithms)) {
waitingHandler.appendReport("Estimating PSM scores.", true, true);
PsmScorer psmScorer = new PsmScorer(fastaParameters, sequenceProvider, spectrumProvider);
psmScorer.estimateIntermediateScores(identification, inputMap, processingParameters, identificationParameters, waitingHandler, exceptionHandler);
if (psmScoringPreferences.isTargetDecoyNeededForPsmScoring(usedAlgorithms)) {
if (fastaParameters.isTargetDecoy()) {
waitingHandler.appendReport("Estimating intermediate scores probabilities.", true, true);
psmScorer.estimateIntermediateScoreProbabilities(identification, inputMap, processingParameters, waitingHandler);
} else {
waitingHandler.appendReport("No decoy sequences found. Impossible to " + "estimate intermediate scores probabilities.", true, true);
}
}
waitingHandler.appendReport("Scoring PSMs.", true, true);
psmScorer.scorePsms(identification, inputMap, processingParameters, identificationParameters, waitingHandler);
}
identification.getObjectsDB().commit();
System.gc();
if (fastaParameters.isTargetDecoy()) {
waitingHandler.appendReport("Computing assumptions probabilities.", true, true);
} else {
waitingHandler.appendReport("Importing assumptions scores.", true, true);
}
inputMap.estimateProbabilities(waitingHandler);
waitingHandler.increasePrimaryProgressCounter();
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
waitingHandler.appendReport("Saving assumptions probabilities, selecting best match, scoring modification localization.", true, true);
PsmProcessor psmProcessor = new PsmProcessor(identification);
psmProcessor.processPsms(inputMap, identificationParameters, matchesValidator, modificationLocalizationScorer, sequenceProvider, spectrumProvider, modificationFactory, proteinCount, processingParameters.getnThreads(), waitingHandler, exceptionHandler);
waitingHandler.increasePrimaryProgressCounter();
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
waitingHandler.appendReport("Computing PSM probabilities.", true, true);
matchesValidator.getPsmMap().estimateProbabilities(waitingHandler);
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
if (projectType == ProjectType.peptide || projectType == ProjectType.protein) {
PeptideInference peptideInference = new PeptideInference();
ModificationLocalizationParameters modificationScoringPreferences = identificationParameters.getModificationLocalizationParameters();
if (modificationScoringPreferences.getAlignNonConfidentModifications()) {
waitingHandler.appendReport("Resolving peptide inference issues.", true, true);
peptideInference.peptideInference(identification, identificationParameters, sequenceProvider, modificationFactory, waitingHandler);
waitingHandler.increasePrimaryProgressCounter();
if (waitingHandler.isRunCanceled()) {
return;
}
}
identification.getObjectsDB().commit();
System.gc();
}
String reportTxt = "Saving probabilities";
String waitingTitle = "Saving Probabilities.";
;
switch(projectType) {
case psm:
reportTxt += ".";
break;
case peptide:
reportTxt += ", building peptides.";
waitingTitle += " Building Peptides.";
break;
default:
reportTxt += ", building peptides and proteins.";
waitingTitle += " Building Peptides and Proteins.";
}
waitingHandler.appendReport(reportTxt, true, true);
waitingHandler.setWaitingText(waitingTitle + " Please Wait...");
attachSpectrumProbabilitiesAndBuildPeptidesAndProteins(sequenceProvider, identificationParameters.getSequenceMatchingParameters(), projectType, fastaParameters, waitingHandler);
waitingHandler.increasePrimaryProgressCounter();
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
if (projectType == ProjectType.peptide || projectType == ProjectType.protein) {
waitingHandler.appendReport("Generating peptide map.", true, true);
matchesValidator.fillPeptideMaps(identification, metrics, waitingHandler, identificationParameters, sequenceProvider, spectrumProvider);
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
waitingHandler.appendReport("Computing peptide probabilities.", true, true);
matchesValidator.getPeptideMap().estimateProbabilities(waitingHandler);
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
waitingHandler.appendReport("Saving peptide probabilities.", true, true);
matchesValidator.attachPeptideProbabilities(identification, fastaParameters, waitingHandler);
waitingHandler.increasePrimaryProgressCounter();
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
if (projectType == ProjectType.protein) {
if (identificationParameters.getProteinInferenceParameters().getSimplifyGroups()) {
waitingHandler.appendReport("Simplifying protein groups.", true, true);
GroupSimplification groupSimplification = new GroupSimplification();
groupSimplification.removeRedundantGroups(identification, identificationParameters, sequenceProvider, proteinDetailsProvider, waitingHandler);
waitingHandler.increasePrimaryProgressCounter();
if (waitingHandler.isRunCanceled()) {
return;
}
}
identification.getObjectsDB().commit();
System.gc();
ProteinInference proteinInference = new ProteinInference();
waitingHandler.appendReport("Mapping shared peptides.", true, true);
proteinInference.distributeSharedPeptides(identification, waitingHandler);
waitingHandler.increasePrimaryProgressCounter();
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
waitingHandler.appendReport("Generating protein map.", true, true);
matchesValidator.fillProteinMap(identification, spectrumProvider, waitingHandler);
waitingHandler.increasePrimaryProgressCounter();
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
waitingHandler.appendReport("Selecting leading proteins, inferring peptide and protein inference status.", true, true);
proteinInference.inferPiStatus(identification, metrics, matchesValidator.getProteinMap(), identificationParameters, sequenceProvider, proteinDetailsProvider, waitingHandler);
waitingHandler.increasePrimaryProgressCounter();
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
waitingHandler.appendReport("Computing protein probabilities.", true, true);
matchesValidator.getProteinMap().estimateProbabilities(waitingHandler);
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
waitingHandler.appendReport("Saving protein probabilities.", true, true);
matchesValidator.attachProteinProbabilities(identification, sequenceProvider, fastaParameters, metrics, waitingHandler, identificationParameters.getFractionParameters());
waitingHandler.increasePrimaryProgressCounter();
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
}
}
if (fastaParameters.isTargetDecoy()) {
IdMatchValidationParameters idMatchValidationParameters = identificationParameters.getIdValidationParameters();
if (idMatchValidationParameters.getDefaultPsmFDR() == 1 && idMatchValidationParameters.getDefaultPeptideFDR() == 1 && idMatchValidationParameters.getDefaultProteinFDR() == 1) {
waitingHandler.appendReport("Validating identifications at 1% FDR, quality control of matches.", true, true);
} else {
waitingHandler.appendReport("Validating identifications, quality control of matches.", true, true);
}
} else {
waitingHandler.appendReport("Quality control of matches.", true, true);
}
matchesValidator.validateIdentifications(identification, metrics, inputMap, waitingHandler, exceptionHandler, identificationFeaturesGenerator, sequenceProvider, proteinDetailsProvider, spectrumProvider, geneMaps, identificationParameters, projectType, processingParameters);
waitingHandler.increasePrimaryProgressCounter();
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
if (projectType == ProjectType.peptide || projectType == ProjectType.protein) {
waitingHandler.appendReport("Scoring PTMs in peptides.", true, true);
modificationLocalizationScorer.scorePeptidePtms(identification, modificationFactory, waitingHandler, identificationParameters);
waitingHandler.increasePrimaryProgressCounter();
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
if (projectType == ProjectType.protein) {
waitingHandler.appendReport("Estimating spectrum counting scaling values.", true, true);
ScalingFactorsEstimators scalingFactors = new ScalingFactorsEstimators(spectrumCountingParameters);
scalingFactors.estimateScalingFactors(identification, metrics, sequenceProvider, identificationFeaturesGenerator, waitingHandler, exceptionHandler, processingParameters);
waitingHandler.increasePrimaryProgressCounter();
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
waitingHandler.appendReport("Scoring PTMs in proteins, gathering summary metrics.", true, true);
ProteinProcessor proteinProcessor = new ProteinProcessor(identification, identificationParameters, identificationFeaturesGenerator, sequenceProvider);
proteinProcessor.processProteins(modificationLocalizationScorer, metrics, modificationFactory, waitingHandler, exceptionHandler, processingParameters);
waitingHandler.increasePrimaryProgressCounter();
if (waitingHandler.isRunCanceled()) {
return;
}
identification.getObjectsDB().commit();
System.gc();
}
}
projectCreationDuration.end();
String report = "Identification processing completed (" + projectCreationDuration.toString() + ").";
waitingHandler.appendReport(report, true, true);
waitingHandler.appendReportEndLine();
waitingHandler.appendReportEndLine();
identification.addUrParam(new PSMaps(inputMap, matchesValidator.getPsmMap(), matchesValidator.getPeptideMap(), matchesValidator.getProteinMap()));
if (setWaitingHandlerFinshedWhenDone) {
waitingHandler.setRunFinished();
}
}
use of eu.isas.peptideshaker.processing.ProteinProcessor in project peptide-shaker by compomics.
the class PeptideShakerGUI method validationQcMenuItemActionPerformed.
// GEN-LAST:event_configurationFilesSettingsActionPerformed
/**
* Open the ValidationQCPreferencesDialog.
*
* @param evt
*/
private void validationQcMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_validationQcMenuItemActionPerformed
final IdMatchValidationParameters idValidationParameters = getIdentificationParameters().getIdValidationParameters();
final ValidationQcParameters validationQCParameters = idValidationParameters.getValidationQCParameters();
ValidationQCParametersDialog validationQCParametersDialog = new ValidationQCParametersDialog(this, validationQCParameters, getIdentificationParameters().getSearchParameters().getModificationParameters().getAllModifications(), true);
if (!validationQCParametersDialog.isCanceled()) {
ValidationQcParameters newParameters = validationQCParametersDialog.getValidationQCParameters();
if (!newParameters.isSameAs(validationQCParameters)) {
idValidationParameters.setValidationQCParameters(newParameters);
// Update the assumptions QC filters
for (Filter filter : newParameters.getPsmFilters()) {
PsmFilter psmFilter = (PsmFilter) filter;
AssumptionFilter assumptionFilter = psmFilter.getAssumptionFilter();
assumptionFilter.clear();
for (String itemName : psmFilter.getItemsNames()) {
assumptionFilter.setFilterItem(itemName, psmFilter.getComparatorForItem(itemName), psmFilter.getValue(itemName));
}
}
progressDialog = new ProgressDialogX(PeptideShakerGUI.this, Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker.gif")), Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker-orange.gif")), true);
progressDialog.setTitle("Validating. Please Wait...");
progressDialog.setPrimaryProgressCounterIndeterminate(false);
new Thread(new Runnable() {
public void run() {
try {
progressDialog.setVisible(true);
} catch (IndexOutOfBoundsException e) {
// ignore
}
}
}, "ProgressDialog").start();
new Thread("RecalculateThread") {
@Override
public void run() {
PeptideShakerGUI peptideShakerGUI = PeptideShakerGUI.this;
try {
PSMaps pSMaps = new PSMaps();
pSMaps = (PSMaps) peptideShakerGUI.getIdentification().getUrParam(pSMaps);
MatchesValidator matchesValidator = new MatchesValidator(pSMaps.getPsmMap(), pSMaps.getPeptideMap(), pSMaps.getProteinMap());
matchesValidator.validateIdentifications(peptideShakerGUI.getIdentification(), peptideShakerGUI.getMetrics(), pSMaps.getInputMap(), progressDialog, exceptionHandler, peptideShakerGUI.getIdentificationFeaturesGenerator(), peptideShakerGUI.getSequenceProvider(), peptideShakerGUI.getProteinDetailsProvider(), peptideShakerGUI.getSpectrumProvider(), peptideShakerGUI.getGeneMaps(), peptideShakerGUI.getIdentificationParameters(), peptideShakerGUI.getProjectType(), peptideShakerGUI.getProcessingParameters());
progressDialog.setPrimaryProgressCounterIndeterminate(true);
ProteinProcessor proteinProcessor = new ProteinProcessor(peptideShakerGUI.getIdentification(), peptideShakerGUI.getIdentificationParameters(), peptideShakerGUI.getIdentificationFeaturesGenerator(), peptideShakerGUI.getSequenceProvider());
proteinProcessor.processProteins(new ModificationLocalizationScorer(), peptideShakerGUI.getMetrics(), modificationFactory, progressDialog, peptideShakerGUI.getExceptionHandler(), peptideShakerGUI.getProcessingParameters());
if (!progressDialog.isRunCanceled()) {
// update the other tabs
peptideShakerGUI.getMetrics().setnValidatedProteins(-1);
peptideShakerGUI.getMetrics().setnConfidentProteins(-1);
peptideShakerGUI.setUpdated(PeptideShakerGUI.OVER_VIEW_TAB_INDEX, false);
peptideShakerGUI.setUpdated(PeptideShakerGUI.PROTEIN_FRACTIONS_TAB_INDEX, false);
peptideShakerGUI.setUpdated(PeptideShakerGUI.STRUCTURES_TAB_INDEX, false);
peptideShakerGUI.setUpdated(PeptideShakerGUI.MODIFICATIONS_TAB_INDEX, false);
peptideShakerGUI.setUpdated(PeptideShakerGUI.QC_PLOTS_TAB_INDEX, false);
peptideShakerGUI.setUpdated(PeptideShakerGUI.SPECTRUM_ID_TAB_INDEX, false);
peptideShakerGUI.setDataSaved(false);
} else {
idValidationParameters.setValidationQCParameters(validationQCParameters);
}
} catch (Exception e) {
peptideShakerGUI.catchException(e);
}
progressDialog.setRunFinished();
PeptideShakerGUI.this.repaintPanels();
}
}.start();
}
}
}
use of eu.isas.peptideshaker.processing.ProteinProcessor in project peptide-shaker by compomics.
the class ValidationPanel method validateButtonActionPerformed.
// GEN-LAST:event_formComponentResized
/**
* Validate the data using the current settings.
*
* @param evt
*/
private void validateButtonActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_validateButtonActionPerformed
double lastThreshold = Double.valueOf(thresholdInput.getText());
thresholdInputActionPerformed(null);
if (lastThreshold < 0 || lastThreshold > 100) {
JOptionPane.showMessageDialog(this, "Please verify the given threshold. Interval: [0, 100].", "Threshold Error", JOptionPane.WARNING_MESSAGE);
} else {
progressDialog = new ProgressDialogX(peptideShakerGUI, Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker.gif")), Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker-orange.gif")), true);
progressDialog.setTitle("Recalculating. Please Wait...");
progressDialog.setPrimaryProgressCounterIndeterminate(false);
new Thread(new Runnable() {
public void run() {
try {
progressDialog.setVisible(true);
} catch (IndexOutOfBoundsException e) {
// ignore
}
}
}, "ProgressDialog").start();
new Thread("RecalculateThread") {
@Override
public void run() {
try {
PSMaps pSMaps = new PSMaps();
pSMaps = (PSMaps) peptideShakerGUI.getIdentification().getUrParam(pSMaps);
MatchesValidator matchesValidator = new MatchesValidator(pSMaps.getPsmMap(), pSMaps.getPeptideMap(), pSMaps.getProteinMap());
matchesValidator.validateIdentifications(peptideShakerGUI.getIdentification(), peptideShakerGUI.getMetrics(), pSMaps.getInputMap(), progressDialog, peptideShakerGUI.getExceptionHandler(), peptideShakerGUI.getIdentificationFeaturesGenerator(), peptideShakerGUI.getSequenceProvider(), peptideShakerGUI.getProteinDetailsProvider(), peptideShakerGUI.getSpectrumProvider(), peptideShakerGUI.getGeneMaps(), peptideShakerGUI.getIdentificationParameters(), peptideShakerGUI.getProjectType(), peptideShakerGUI.getProcessingParameters());
progressDialog.setPrimaryProgressCounterIndeterminate(true);
if (peptideShakerGUI.getProjectType() == ProjectType.protein) {
ProteinProcessor proteinProcessor = new ProteinProcessor(peptideShakerGUI.getIdentification(), peptideShakerGUI.getIdentificationParameters(), peptideShakerGUI.getIdentificationFeaturesGenerator(), peptideShakerGUI.getSequenceProvider());
proteinProcessor.processProteins(new ModificationLocalizationScorer(), peptideShakerGUI.getMetrics(), modificationFactory, progressDialog, peptideShakerGUI.getExceptionHandler(), peptideShakerGUI.getProcessingParameters());
}
if (!progressDialog.isRunCanceled()) {
// update the other tabs
peptideShakerGUI.getMetrics().setnValidatedProteins(-1);
peptideShakerGUI.getMetrics().setnConfidentProteins(-1);
peptideShakerGUI.setUpdated(PeptideShakerGUI.OVER_VIEW_TAB_INDEX, false);
peptideShakerGUI.setUpdated(PeptideShakerGUI.PROTEIN_FRACTIONS_TAB_INDEX, false);
peptideShakerGUI.setUpdated(PeptideShakerGUI.STRUCTURES_TAB_INDEX, false);
peptideShakerGUI.setUpdated(PeptideShakerGUI.MODIFICATIONS_TAB_INDEX, false);
peptideShakerGUI.setUpdated(PeptideShakerGUI.QC_PLOTS_TAB_INDEX, false);
peptideShakerGUI.setUpdated(PeptideShakerGUI.SPECTRUM_ID_TAB_INDEX, false);
dataValidated = true;
validateButton.setEnabled(false);
double input = Double.valueOf(thresholdInput.getText());
int inputType = thresholdTypeCmb.getSelectedIndex();
TargetDecoyResults currentResults = currentTargetDecoyMap.getTargetDecoyResults();
currentResults.setUserInput(input);
currentResults.setInputType(inputType);
String selectedGroup = (String) groupSelectionTable.getValueAt(groupSelectionTable.getSelectedRow(), 1);
originalThresholds.put(selectedGroup, input);
originalThresholdTypes.put(selectedGroup, inputType);
peptideShakerGUI.setDataSaved(false);
} else {
// @TODO: ideally the validation settings ought to be reset as well..?
}
} catch (Exception e) {
peptideShakerGUI.catchException(e);
}
progressDialog.setRunFinished();
}
}.start();
}
}
Aggregations