Search in sources :

Example 1 with WaitingDialogExceptionHandler

use of com.compomics.util.exceptions.exception_handlers.WaitingDialogExceptionHandler in project peptide-shaker by compomics.

the class NewDialog method loadButtonActionPerformed.

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

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

Aggregations

ExceptionHandler (com.compomics.util.exceptions.ExceptionHandler)1 WaitingDialogExceptionHandler (com.compomics.util.exceptions.exception_handlers.WaitingDialogExceptionHandler)1 ProjectParameters (com.compomics.util.experiment.ProjectParameters)1 WaitingDialog (com.compomics.util.gui.waiting.waitinghandlers.WaitingDialog)1 ProjectType (com.compomics.util.parameters.peptide_shaker.ProjectType)1 PeptideShaker (eu.isas.peptideshaker.PeptideShaker)1 ProjectDetails (eu.isas.peptideshaker.preferences.ProjectDetails)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1