Search in sources :

Example 1 with WaitingDialog

use of com.compomics.util.gui.waiting.waitinghandlers.WaitingDialog in project peptide-shaker by compomics.

the class PeptideShakerCLI method call.

@Override
public Object call() {
    try {
        // set up the waiting handler
        if (cliInputBean.isGUI()) {
            // set the look and feel
            try {
                UtilitiesGUIDefaults.setLookAndFeel();
            } catch (Exception e) {
            // ignore, use default look and feel
            }
            ArrayList<String> tips;
            try {
                tips = Tips.getTips();
            } catch (Exception e) {
                tips = new ArrayList<>();
            // do something here?
            }
            waitingHandler = new WaitingDialog(new DummyFrame("PeptideShaker " + PeptideShaker.getVersion(), "/icons/peptide-shaker.gif"), Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker.gif")), Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker-orange.gif")), false, tips, "Importing Data", "PeptideShaker", PeptideShaker.getVersion(), true);
            ((WaitingDialog) waitingHandler).setCloseDialogWhenImportCompletes(false, false);
            ((WaitingDialog) waitingHandler).setLocationRelativeTo(null);
            Point tempLocation = ((WaitingDialog) waitingHandler).getLocation();
            ((WaitingDialog) waitingHandler).setLocation((int) tempLocation.getX() + 30, (int) tempLocation.getY() + 30);
            new Thread(new Runnable() {

                public void run() {
                    try {
                        ((WaitingDialog) waitingHandler).setVisible(true);
                    } catch (IndexOutOfBoundsException e) {
                    // ignore
                    }
                }
            }, "ProgressDialog").start();
        } else {
            waitingHandler = new WaitingHandlerCLIImpl();
        }
        // @TODO: improve the primary progress display?
        int progressCounter = cliInputBean.getIdFiles().size() + cliInputBean.getSpectrumFiles().size();
        // establishing the database connection
        progressCounter++;
        // the FASTA file
        progressCounter++;
        // the peptide to protein map
        progressCounter++;
        // computing probabilities etc
        progressCounter += 6;
        // 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;
        // peptide inference
        progressCounter++;
        // project zipping
        if (cliInputBean.getZipExport() != null) {
            progressCounter++;
        }
        // add one more just to not start at 0%
        progressCounter++;
        waitingHandler.setMaxPrimaryProgressCounter(progressCounter);
        // just to not start at 0%
        waitingHandler.increasePrimaryProgressCounter();
        // turn off illegal access log messages
        try {
            Class loggerClass = Class.forName("jdk.internal.module.IllegalAccessLogger");
            Field loggerField = loggerClass.getDeclaredField("logger");
            Class unsafeClass = Class.forName("sun.misc.Unsafe");
            Field unsafeField = unsafeClass.getDeclaredField("theUnsafe");
            unsafeField.setAccessible(true);
            Object unsafe = unsafeField.get(null);
            Long offset = (Long) unsafeClass.getMethod("staticFieldOffset", Field.class).invoke(unsafe, loggerField);
            // 
            unsafeClass.getMethod("putObjectVolatile", Object.class, long.class, Object.class).invoke(unsafe, loggerClass, offset, null);
        } catch (Throwable ex) {
        // ignore, i.e. simply show the warnings...
        // ex.printStackTrace();
        }
        // turn off the zoodb logging
        LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
        ch.qos.logback.classic.Logger logger = loggerContext.getLogger("org.zoodb");
        logger.setLevel(Level.toLevel("ERROR"));
        setDbFolder(PeptideShaker.getMatchesFolder());
        // Load user parameters
        utilitiesUserParameters = UtilitiesUserParameters.loadUserParameters();
        // Instantiate factories
        PeptideShaker.instantiateFacories(utilitiesUserParameters);
        modificationFactory = ModificationFactory.getInstance();
        enzymeFactory = EnzymeFactory.getInstance();
        // Load resources files
        loadSpecies();
        // Set the gene mappings
        ProteinGeneDetailsProvider geneFactory = new ProteinGeneDetailsProvider();
        geneFactory.initialize(PeptideShaker.getJarFilePath());
        // Load the species mapping
        try {
            SpeciesFactory speciesFactory = SpeciesFactory.getInstance();
            speciesFactory.initiate(PeptideShaker.getJarFilePath());
        } catch (Exception e) {
            waitingHandler.appendReport("An error occurred while loading the " + "species mapping. Gene annotation might be impaired. " + getLogFileMessage(), true, true);
            e.printStackTrace();
        }
        // create project
        try {
            createProject();
        } catch (Exception e) {
            waitingHandler.appendReport("An error occurred while creating the " + "PeptideShaker project. " + getLogFileMessage(), true, true);
            e.printStackTrace();
            waitingHandler.setRunCanceled();
        }
        // see if the project was created or canceled
        if (waitingHandler.isRunCanceled()) {
            try {
                closePeptideShaker(identification);
            } catch (Exception e) {
                waitingHandler.appendReport("An error occurred while closing PeptideShaker. " + getLogFileMessage(), true, true);
                e.printStackTrace();
            }
            System.exit(1);
            return 1;
        } else {
            waitingHandler.appendReport("Project successfully created.", true, true);
            waitingHandler.increasePrimaryProgressCounter();
        }
        // save project
        if (cliInputBean.getOutput() != null) {
            try {
                psdbFile = cliInputBean.getOutput();
                waitingHandler.appendReport("Saving results.", true, true);
                saveProject(waitingHandler, true);
                waitingHandler.appendReport("Results saved to " + psdbFile.getAbsolutePath() + ".", true, true);
                waitingHandler.appendReportEndLine();
            } catch (Exception e) {
                waitingHandler.appendReport("An exception occurred while saving the project. " + getLogFileMessage(), true, true);
                e.printStackTrace();
                waitingHandler.setRunCanceled();
            }
            waitingHandler.increasePrimaryProgressCounter();
        }
        // finished
        waitingHandler.setPrimaryProgressCounterIndeterminate(false);
        waitingHandler.setSecondaryProgressCounterIndeterminate(false);
        // follow up tasks if needed
        FollowUpCLIInputBean followUpCLIInputBean = cliInputBean.getFollowUpCLIInputBean();
        // array to be filled with all exported follow-up reports
        ArrayList<File> followupAnalysisFiles = new ArrayList<File>();
        if (followUpCLIInputBean.followUpNeeded()) {
            waitingHandler.appendReport("Starting follow up tasks.", true, true);
            // recalibrate spectra
            if (followUpCLIInputBean.recalibrationNeeded()) {
                waitingHandler.appendReport("Spectrum recalibration.", true, true);
                try {
                    followupAnalysisFiles.addAll(CLIExportMethods.recalibrateSpectra(followUpCLIInputBean, identification, sequenceProvider, msFileHandler, identificationParameters, waitingHandler));
                } catch (Exception e) {
                    waitingHandler.appendReport("An error occurred while recalibrating the spectra. " + getLogFileMessage(), true, true);
                    e.printStackTrace();
                    waitingHandler.setRunCanceled();
                }
            }
            // export spectra
            if (followUpCLIInputBean.spectrumExportNeeded()) {
                waitingHandler.appendReport("Spectrum export.", true, true);
                try {
                    followupAnalysisFiles.addAll(CLIExportMethods.exportSpectra(followUpCLIInputBean, identification, msFileHandler, waitingHandler, identificationParameters.getSequenceMatchingParameters()));
                } catch (Exception e) {
                    waitingHandler.appendReport("An error occurred while exporting the spectra. " + getLogFileMessage(), true, true);
                    e.printStackTrace();
                    waitingHandler.setRunCanceled();
                }
            }
            // export protein accessions
            if (followUpCLIInputBean.accessionExportNeeded()) {
                waitingHandler.appendReport("Protein accession export.", true, true);
                try {
                    followupAnalysisFiles.add(CLIExportMethods.exportAccessions(followUpCLIInputBean, identification, sequenceProvider, waitingHandler, filterParameters));
                } catch (Exception e) {
                    waitingHandler.appendReport("An error occurred while exporting the protein accessions. " + getLogFileMessage(), true, true);
                    e.printStackTrace();
                    waitingHandler.setRunCanceled();
                }
            }
            // export protein details
            if (followUpCLIInputBean.proteinSequencesExportNeeded()) {
                waitingHandler.appendReport("Protein sequences export.", true, true);
                try {
                    followupAnalysisFiles.add(CLIExportMethods.exportProteinSequences(followUpCLIInputBean, identification, sequenceProvider, waitingHandler, filterParameters));
                } catch (Exception e) {
                    waitingHandler.appendReport("An error occurred while exporting the protein details. " + getLogFileMessage(), true, true);
                    e.printStackTrace();
                    waitingHandler.setRunCanceled();
                }
            }
            // progenesis export
            if (followUpCLIInputBean.progenesisExportNeeded()) {
                waitingHandler.appendReport("Progenesis export.", true, true);
                try {
                    followupAnalysisFiles.add(CLIExportMethods.exportProgenesis(followUpCLIInputBean, identification, waitingHandler, sequenceProvider, proteinDetailsProvider, identificationParameters.getSequenceMatchingParameters()));
                    waitingHandler.appendReport("Progenesis export completed.", true, true);
                } catch (Exception e) {
                    waitingHandler.appendReport("An error occurred while exporting the Progenesis file. " + getLogFileMessage(), true, true);
                    e.printStackTrace();
                    waitingHandler.setRunCanceled();
                }
            }
            // inclusion list export
            if (followUpCLIInputBean.inclusionListNeeded()) {
                waitingHandler.appendReport("Inclusion list export.", true, true);
                try {
                    followupAnalysisFiles.add(CLIExportMethods.exportInclusionList(followUpCLIInputBean, identification, identificationFeaturesGenerator, msFileHandler, identificationParameters.getSearchParameters(), waitingHandler, filterParameters));
                } catch (Exception e) {
                    waitingHandler.appendReport("An error occurred while generating the inclusion list.", true, true);
                    e.printStackTrace();
                    waitingHandler.setRunCanceled();
                }
            }
            // proteoforms export
            if (followUpCLIInputBean.proteoformsNeeded()) {
                waitingHandler.appendReport("Proteoform export.", true, true);
                try {
                    followupAnalysisFiles.add(CLIExportMethods.exportProteoforms(followUpCLIInputBean, identification, waitingHandler));
                } catch (Exception e) {
                    waitingHandler.appendReport("An error occurred while generating the proteoforms list.", true, true);
                    e.printStackTrace();
                    waitingHandler.setRunCanceled();
                }
            }
            // DeepLC export
            if (followUpCLIInputBean.deepLcExportNeeded()) {
                waitingHandler.appendReport("DeepLC export.", true, true);
                try {
                    followupAnalysisFiles.addAll(CLIExportMethods.exportDeepLC(followUpCLIInputBean, identification, identificationParameters.getSearchParameters().getModificationParameters(), identificationParameters.getSequenceMatchingParameters(), sequenceProvider, msFileHandler, waitingHandler));
                } catch (Exception e) {
                    waitingHandler.appendReport("An error occurred while generating the proteoforms list.", true, true);
                    e.printStackTrace();
                    waitingHandler.setRunCanceled();
                }
            }
            // ms2pip export
            if (followUpCLIInputBean.ms2pipExportNeeded()) {
                waitingHandler.appendReport("ms2pip export.", true, true);
                try {
                    followupAnalysisFiles.addAll(CLIExportMethods.exportMs2pip(followUpCLIInputBean, identification, identificationParameters.getSearchParameters(), identificationParameters.getSequenceMatchingParameters(), sequenceProvider, msFileHandler, waitingHandler));
                } catch (Exception e) {
                    waitingHandler.appendReport("An error occurred while generating the proteoforms list.", true, true);
                    e.printStackTrace();
                    waitingHandler.setRunCanceled();
                }
            }
        }
        // report export if needed
        ReportCLIInputBean reportCLIInputBean = cliInputBean.getReportCLIInputBean();
        // array to be filled with all exported reports
        ArrayList<File> reportFiles = new ArrayList<File>();
        if (reportCLIInputBean.exportNeeded()) {
            // see if output folder is set, and if not set to the same folder as the psdb file
            boolean reportOutputFolderSet = reportCLIInputBean.getReportOutputFolder() != null;
            if (!reportOutputFolderSet) {
                if (cliInputBean.getOutput() == null) {
                    // @TODO: ideally this test should be done before starting the processing of the data!
                    waitingHandler.appendReport("Report output folder not set. Please use -out_reports (or the more general -out option). Processing canceled.", true, true);
                    System.err.println("Report output folder not set. Please use -out_reports (or the more general -out option). Processing canceled.");
                    waitingHandler.setRunCanceled();
                } else {
                    reportCLIInputBean.setReportOutputFolder(cliInputBean.getOutput().getParentFile());
                    reportOutputFolderSet = true;
                }
            }
            if (reportOutputFolderSet) {
                waitingHandler.appendReport("Exporting reports.", true, true);
                // Export report(s)
                if (reportCLIInputBean.exportNeeded()) {
                    // @TODO: this shall not be hard coded //peptideShakerGUI.getDisplayPreferences().getnAASurroundingPeptides()
                    int nSurroundingAAs = 2;
                    for (String reportType : reportCLIInputBean.getReportTypes()) {
                        waitingHandler.appendReport("Exporting " + reportType + ".", true, true);
                        try {
                            reportFiles.add(CLIExportMethods.exportReport(reportCLIInputBean, reportType, projectParameters.getProjectUniqueName(), projectDetails, identification, geneMaps, identificationFeaturesGenerator, identificationParameters, sequenceProvider, proteinDetailsProvider, msFileHandler, nSurroundingAAs, spectrumCountingParameters, waitingHandler));
                        } catch (Exception e) {
                            waitingHandler.appendReport("An error occurred while exporting the " + reportType + ". " + getLogFileMessage(), true, true);
                            e.printStackTrace();
                            waitingHandler.setRunCanceled();
                        }
                    }
                }
                // export documentation
                if (reportCLIInputBean.documentationExportNeeded()) {
                    waitingHandler.appendReport("Exporting report documentation.", true, true);
                    for (String reportType : reportCLIInputBean.getReportTypes()) {
                        try {
                            CLIExportMethods.exportDocumentation(reportCLIInputBean, reportType, waitingHandler);
                        } catch (Exception e) {
                            waitingHandler.appendReport("An error occurred while exporting the documentation for " + reportType + ". " + getLogFileMessage(), true, true);
                            e.printStackTrace();
                            waitingHandler.setRunCanceled();
                        }
                    }
                }
            }
        }
        // export as mzid
        MzidCLIInputBean mzidCLIInputBean = cliInputBean.getMzidCLIInputBean();
        File mzidFile = mzidCLIInputBean.getOutputFile();
        if (mzidFile != null) {
            waitingHandler.appendReportEndLine();
            waitingHandler.appendReport("Exporting project as mzIdentML.", true, true);
            // export mzid file
            // make sure that all annotations are included
            double currentIntensityLimit = this.getIdentificationParameters().getAnnotationParameters().getAnnotationIntensityLimit();
            this.getIdentificationParameters().getAnnotationParameters().setIntensityLimit(0.0);
            try {
                CLIExportMethods.exportMzId(mzidCLIInputBean, this, waitingHandler);
            } catch (Exception e) {
                waitingHandler.appendReport("An error occurred while generating the mzid file. " + getLogFileMessage(), true, true);
                e.printStackTrace();
                waitingHandler.setRunCanceled();
            } finally {
                // reset the annotation level
                this.getIdentificationParameters().getAnnotationParameters().setIntensityLimit(currentIntensityLimit);
            }
        }
        // export project as zip
        File zipFile = cliInputBean.getZipExport();
        if (zipFile != null) {
            waitingHandler.appendReportEndLine();
            waitingHandler.appendReport("Zipping project.", true, true);
            File parent = zipFile.getParentFile();
            try {
                parent.mkdirs();
            } catch (Exception e) {
                waitingHandler.appendReport("An error occurred while creating folder " + parent.getAbsolutePath() + ". " + getLogFileMessage(), true, true);
                waitingHandler.setRunCanceled();
            }
            ArrayList<File> spectrumFiles = new ArrayList<>();
            for (String spectrumFileName : getIdentification().getFractions()) {
                File spectrumFile = new File(msFileHandler.getFilePaths().get(spectrumFileName));
                spectrumFiles.add(spectrumFile);
            }
            File fastaFile = new File(projectDetails.getFastaFile());
            try {
                ProjectExport.exportProjectAsZip(zipFile, fastaFile, msFileHandler, followupAnalysisFiles, reportFiles, mzidFile, psdbFile, true, waitingHandler);
                final int NUMBER_OF_BYTES_PER_MEGABYTE = 1048576;
                double sizeOfZippedFile = Util.roundDouble(((double) zipFile.length() / NUMBER_OF_BYTES_PER_MEGABYTE), 2);
                waitingHandler.appendReport("Project zipped to \'" + zipFile.getAbsolutePath() + "\' (" + sizeOfZippedFile + " MB)", true, true);
                // export mgf file(s) out of the zip file
                boolean mgfExport = cliInputBean.getMgfExport();
                if (mgfExport) {
                    waitingHandler.appendReportEndLine();
                    waitingHandler.appendReport("Writing mgf file(s) to output folder.", true, true);
                    int i = 0;
                    for (String spectrumFileName : msFileHandler.getCmsFilePaths().keySet()) {
                        if (waitingHandler.isRunCanceled()) {
                            break;
                        }
                        waitingHandler.appendReport("Writing: " + IoUtil.removeExtension(spectrumFileName) + ".mgf" + " (" + (i + 1) + "/" + getIdentification().getFractions().size() + ")", true, true);
                        File mgfFile = new File(parent, IoUtil.removeExtension(spectrumFileName) + ".mgf");
                        MsFileExporter.writeMgfFile(msFileHandler, spectrumFileName, mgfFile, waitingHandler);
                        // writing the index too
                        MgfIndex mgfIndex = IndexedMgfReader.getMgfIndex(mgfFile, waitingHandler);
                        File indexFile = new File(parent, IoUtil.removeExtension(mgfIndex.getFileName()) + ".cui");
                        SerializationUtils.writeObject(mgfIndex, indexFile);
                        i++;
                    }
                    waitingHandler.appendReport("Written mgf file(s) to output folder.", true, true);
                }
                waitingHandler.increasePrimaryProgressCounter();
            } catch (IOException e) {
                e.printStackTrace();
                waitingHandler.appendReport("An error occurred while attempting to zip project in " + zipFile.getAbsolutePath() + ". " + getLogFileMessage(), true, true);
                waitingHandler.setRunCanceled();
            }
        }
        waitingHandler.appendReportEndLine();
        try {
            closePeptideShaker(identification);
        } catch (Exception e) {
            waitingHandler.appendReport("An error occurred while closing PeptideShaker. " + getLogFileMessage(), true, true);
            e.printStackTrace();
        }
        saveReport();
    } catch (Exception e) {
        e.printStackTrace();
        if (waitingHandler != null) {
            waitingHandler.appendReport("PeptideShaker processing failed. " + getLogFileMessage(), true, true);
            saveReport();
            waitingHandler.setRunCanceled();
        }
    }
    if (waitingHandler != null && !waitingHandler.isRunCanceled()) {
        waitingHandler.appendReport("PeptideShaker process completed.", true, true);
        waitingHandler.setSecondaryProgressText("Processing Completed.");
        // @TODO: Find other ways of cancelling the process? If not cancelled searchgui will not stop.
        System.exit(0);
        // Note that if a different solution is found, the DummyFrame has to be closed similar to the setVisible method in the WelcomeDialog!!
        return 0;
    } else {
        System.out.println("PeptideShaker process failed! " + getLogFileMessage());
        // @TODO: Find other ways of cancelling the process? If not cancelled searchgui will not stop.
        System.exit(1);
        // Note that if a different solution is found, the DummyFrame has to be closed similar to the setVisible method in the WelcomeDialog!!
        return 1;
    }
}
Also used : ArrayList(java.util.ArrayList) WaitingDialog(com.compomics.util.gui.waiting.waitinghandlers.WaitingDialog) Field(java.lang.reflect.Field) SpeciesFactory(com.compomics.util.experiment.biology.taxonomy.SpeciesFactory) MgfIndex(com.compomics.util.experiment.io.mass_spectrometry.mgf.MgfIndex) ProteinGeneDetailsProvider(com.compomics.util.experiment.biology.genes.ProteinGeneDetailsProvider) Point(java.awt.Point) LoggerContext(ch.qos.logback.classic.LoggerContext) TimeoutException(java.util.concurrent.TimeoutException) SQLException(java.sql.SQLException) Point(java.awt.Point) WaitingHandlerCLIImpl(com.compomics.util.gui.waiting.waitinghandlers.WaitingHandlerCLIImpl) DummyFrame(com.compomics.util.gui.DummyFrame)

Example 2 with WaitingDialog

use of com.compomics.util.gui.waiting.waitinghandlers.WaitingDialog in project peptide-shaker by compomics.

the class PeptideShakerCLI method createProject.

/**
 * Creates the PeptideShaker project based on the identification files
 * provided in the command line input
 *
 * @throws java.io.IOException exception thrown if an error occurs while
 * reading or writing a file
 * @throws java.lang.InterruptedException exception thrown if a thread is
 * interrupted
 * @throws java.util.concurrent.TimeoutException exception thrown if a
 * process times out
 */
public void createProject() throws IOException, InterruptedException, TimeoutException {
    // define new project reference
    projectParameters = new ProjectParameters(cliInputBean.getExperimentID());
    // set the project details
    projectDetails = new ProjectDetails();
    projectDetails.setCreationDate(new Date());
    projectDetails.setPeptideShakerVersion(new Properties().getVersion());
    // set up spectrum provider
    msFileHandler = new MsFileHandler();
    // get the input files
    ArrayList<File> identificationFilesInput = cliInputBean.getIdFiles();
    ArrayList<File> dataFolders = new ArrayList<>();
    ArrayList<File> spectrumFiles = cliInputBean.getSpectrumFiles();
    File fastaFile = null;
    // Extract data from zip files, try to find the search parameter and spectrum files
    ArrayList<File> identificationFiles = new ArrayList<>();
    IdentificationParameters tempIdentificationParameters = null;
    for (File inputFile : identificationFilesInput) {
        File parentFile = inputFile.getParentFile();
        if (!dataFolders.contains(parentFile)) {
            dataFolders.add(parentFile);
        }
        File dataFolder = new File(parentFile, "mgf");
        if (dataFolder.exists() && !dataFolders.contains(dataFolder)) {
            dataFolders.add(dataFolder);
        }
        dataFolder = new File(parentFile, "mzml");
        if (dataFolder.exists() && !dataFolders.contains(dataFolder)) {
            dataFolders.add(dataFolder);
        }
        dataFolder = new File(parentFile, "cms");
        if (dataFolder.exists() && !dataFolders.contains(dataFolder)) {
            dataFolders.add(dataFolder);
        }
        dataFolder = new File(parentFile, "fasta");
        if (dataFolder.exists() && !dataFolders.contains(dataFolder)) {
            dataFolders.add(dataFolder);
        }
        dataFolder = new File(parentFile, PeptideShaker.DATA_DIRECTORY);
        if (dataFolder.exists() && !dataFolders.contains(dataFolder)) {
            dataFolders.add(dataFolder);
        }
        String fileName = inputFile.getName();
        if (fileName.toLowerCase().endsWith(".zip")) {
            waitingHandler.appendReport("Unzipping " + fileName + ".", true, true);
            String newName = PsZipUtils.getTempFolderName(fileName);
            String parentFolder = PsZipUtils.getUnzipParentFolder();
            if (parentFolder == null) {
                parentFolder = parentFile.getAbsolutePath();
            }
            File parentFolderFile = new File(parentFolder, PsZipUtils.getUnzipSubFolder());
            File destinationFolder = new File(parentFolderFile, newName);
            destinationFolder.mkdir();
            TempFilesManager.registerTempFolder(parentFolderFile);
            ZipUtils.unzip(inputFile, destinationFolder, waitingHandler);
            if (waitingHandler instanceof WaitingHandlerCLIImpl) {
                waitingHandler.appendReportEndLine();
            }
            dataFolder = new File(destinationFolder, PeptideShaker.DATA_DIRECTORY);
            if (dataFolder.exists() && !dataFolders.contains(dataFolder)) {
                dataFolders.add(dataFolder);
            }
            dataFolder = new File(destinationFolder, ".mgf");
            if (dataFolder.exists() && !dataFolders.contains(dataFolder)) {
                dataFolders.add(dataFolder);
            }
            dataFolder = new File(parentFile, "mzml");
            if (dataFolder.exists() && !dataFolders.contains(dataFolder)) {
                dataFolders.add(dataFolder);
            }
            dataFolder = new File(destinationFolder, ".cms");
            if (dataFolder.exists() && !dataFolders.contains(dataFolder)) {
                dataFolders.add(dataFolder);
            }
            dataFolder = new File(destinationFolder, ".fasta");
            if (dataFolder.exists() && !dataFolders.contains(dataFolder)) {
                dataFolders.add(dataFolder);
            }
            for (File unzippedFile : destinationFolder.listFiles()) {
                String nameLowerCase = unzippedFile.getName().toLowerCase();
                if (nameLowerCase.endsWith(".omx") || nameLowerCase.endsWith(".t.xml") || nameLowerCase.endsWith(".pep.xml") || nameLowerCase.endsWith(".dat") || nameLowerCase.endsWith(".mzid") || nameLowerCase.endsWith(".ms-amanda.csv") || nameLowerCase.endsWith(".res") || nameLowerCase.endsWith(".tide-search.target.txt") || nameLowerCase.endsWith(".tags") || nameLowerCase.endsWith(".pnovo.txt") || nameLowerCase.endsWith(".novor.csv") || nameLowerCase.endsWith(".psm") || nameLowerCase.endsWith(".omx.gz") || nameLowerCase.endsWith(".t.xml.gz") || nameLowerCase.endsWith(".pep.xml.gz") || nameLowerCase.endsWith(".mzid.gz") || nameLowerCase.endsWith(".ms-amanda.csv.gz") || nameLowerCase.endsWith(".res.gz") || nameLowerCase.endsWith(".tide-search.target.txt.gz") || nameLowerCase.endsWith(".tags.gz") || nameLowerCase.endsWith(".pnovo.txt.gz") || nameLowerCase.endsWith(".novor.csv.gz") || nameLowerCase.endsWith(".psm.gz")) {
                    identificationFiles.add(unzippedFile);
                } else if (nameLowerCase.endsWith(".par")) {
                    try {
                        tempIdentificationParameters = IdentificationParameters.getIdentificationParameters(unzippedFile);
                        ValidationQcParameters validationQCParameters = tempIdentificationParameters.getIdValidationParameters().getValidationQCParameters();
                        if (validationQCParameters == null || validationQCParameters.getPsmFilters() == null || validationQCParameters.getPeptideFilters() == null || validationQCParameters.getProteinFilters() == null || validationQCParameters.getPsmFilters().isEmpty() && validationQCParameters.getPeptideFilters().isEmpty() && validationQCParameters.getProteinFilters().isEmpty()) {
                            MatchesValidator.setDefaultMatchesQCFilters(validationQCParameters);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        waitingHandler.appendReport("An error occurred while parsing the parameters file " + unzippedFile.getName() + ". " + getLogFileMessage(), true, true);
                        waitingHandler.setRunCanceled();
                    }
                }
            }
        } else {
            identificationFiles.add(inputFile);
        }
    }
    // list the spectrum files found
    HashSet<String> dataFileNamesRequired = new HashSet<>();
    for (File spectrumFile : spectrumFiles) {
        dataFileNamesRequired.add(IoUtil.getFileName(spectrumFile));
    }
    for (File dataFolder : dataFolders) {
        for (File file : dataFolder.listFiles()) {
            String name = file.getName();
            if (name.endsWith(".mgf") || name.endsWith(".mgf.gz") || name.endsWith(".mzml") || name.endsWith(".mzml.gz") || name.endsWith(".cms")) {
                if (!dataFileNamesRequired.contains(name)) {
                    spectrumFiles.add(file);
                    dataFileNamesRequired.add(name);
                }
            } else if (name.endsWith(".fasta")) {
                if (!dataFileNamesRequired.contains(name)) {
                    fastaFile = file;
                    dataFileNamesRequired.add(name);
                }
            }
        }
    }
    // Load the spectrum files
    for (File spectrumFile : spectrumFiles) {
        File folder = CmsFolder.getParentFolder() == null ? spectrumFile.getParentFile() : new File(CmsFolder.getParentFolder());
        msFileHandler.register(spectrumFile, folder, waitingHandler);
    }
    // If there is a specific fasta file chosen, it is used insted of the one included in the searchgui zip
    if (cliInputBean.getFastaFile() != null) {
        fastaFile = cliInputBean.getFastaFile();
    }
    // get the identification parameters
    IdentificationParametersInputBean identificationParametersInputBean = cliInputBean.getIdentificationParametersInputBean();
    if (tempIdentificationParameters != null && identificationParametersInputBean.getInputFile() == null) {
        identificationParametersInputBean.setIdentificationParameters(tempIdentificationParameters);
        identificationParametersInputBean.updateIdentificationParameters();
    }
    identificationParameters = identificationParametersInputBean.getIdentificationParameters();
    ValidationQcParameters validationQCParameters = identificationParameters.getIdValidationParameters().getValidationQCParameters();
    if (validationQCParameters == null || validationQCParameters.getPsmFilters() == null || validationQCParameters.getPeptideFilters() == null || validationQCParameters.getProteinFilters() == null || validationQCParameters.getPsmFilters().isEmpty() && validationQCParameters.getPeptideFilters().isEmpty() && validationQCParameters.getProteinFilters().isEmpty()) {
        MatchesValidator.setDefaultMatchesQCFilters(validationQCParameters);
    }
    if (identificationParameters == null) {
        waitingHandler.appendReport("Identification parameters not found!", true, true);
        waitingHandler.setRunCanceled();
    }
    SearchParameters searchParameters = identificationParameters.getSearchParameters();
    String error = PeptideShaker.loadModifications(searchParameters);
    if (error != null) {
        System.out.println(error);
    }
    // try to locate the fasta file
    if (fastaFile == null) {
        waitingHandler.appendReport("FASTA file not set (or not in zip file)!", true, true);
        waitingHandler.setRunCanceled();
    } else if (!fastaFile.exists()) {
        boolean found = false;
        // look in the database folder
        try {
            File tempDbFolder = utilitiesUserParameters.getDbFolder();
            File newFile = new File(tempDbFolder, fastaFile.getName());
            if (newFile.exists()) {
                fastaFile = newFile;
                projectDetails.setFastaFile(fastaFile);
                found = true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (!found) {
            // look in the data folders
            for (File dataFolder : dataFolders) {
                File newFile = new File(dataFolder, fastaFile.getName());
                if (newFile.exists()) {
                    fastaFile = newFile;
                    projectDetails.setFastaFile(fastaFile);
                    found = true;
                    break;
                }
            }
            if (!found) {
                waitingHandler.appendReport("FASTA file \'" + fastaFile.getName() + "\' not found.", true, true);
                waitingHandler.setRunCanceled();
            }
        }
    } else {
        projectDetails.setFastaFile(fastaFile);
    }
    // get the summary information for the FASTA file
    try {
        // get the FASTA summary
        FastaSummary fastaSummary = loadFastaFile(waitingHandler);
        // set the background species
        identificationParameters.getGeneParameters().setBackgroundSpeciesFromFastaSummary(fastaSummary);
    } catch (IOException e) {
        e.printStackTrace();
        waitingHandler.appendReport("An error occurred while parsing the FASTA file.", true, true);
        waitingHandler.setRunCanceled();
    }
    // set the processing settings
    ProcessingParameters processingParameters = new ProcessingParameters();
    Integer nThreads = cliInputBean.getnThreads();
    if (nThreads != null) {
        processingParameters.setnThreads(nThreads);
    }
    // set the spectrum counting prefrences
    spectrumCountingParameters = new SpectrumCountingParameters();
    // set the project type
    projectType = cliInputBean.getProjectType();
    // check the project reference
    for (String forbiddenChar : Util.FORBIDDEN_CHARACTERS) {
        if (cliInputBean.getExperimentID().contains(forbiddenChar)) {
            waitingHandler.appendReport("The project name cannot not contain " + forbiddenChar + ".", true, true);
            waitingHandler.setRunCanceled();
        }
    }
    // incrementing the counter for a new PeptideShaker start run via CLI
    if (utilitiesUserParameters.isAutoUpdate()) {
        Util.sendGAUpdate("UA-36198780-1", "startrun-cl", "peptide-shaker-" + PeptideShaker.getVersion());
    }
    // create a shaker which will perform the analysis
    PeptideShaker peptideShaker = new PeptideShaker(projectParameters);
    // import the files
    int outcome = peptideShaker.importFiles(waitingHandler, identificationFiles, msFileHandler, identificationParameters, projectDetails, processingParameters, exceptionHandler);
    if (outcome == 0) {
        peptideShaker.createProject(identificationParameters, processingParameters, spectrumCountingParameters, msFileHandler, projectDetails, projectType, waitingHandler, false, exceptionHandler);
    }
    if (!waitingHandler.isRunCanceled()) {
        // identification as created by PeptideShaker
        identification = peptideShaker.getIdentification();
        // metrics saved while processing the data
        metrics = peptideShaker.getMetrics();
        // fene maps
        geneMaps = peptideShaker.getGeneMaps();
        // the identification feature generator
        identificationFeaturesGenerator = peptideShaker.getIdentificationFeaturesGenerator();
        // the sequence provider
        sequenceProvider = peptideShaker.getSequenceProvider();
        // the protein details provider
        proteinDetailsProvider = peptideShaker.getProteinDetailsProvider();
        if (waitingHandler instanceof WaitingDialog) {
            projectDetails.setReport(((WaitingDialog) waitingHandler).getReport(null));
            ((WaitingDialog) waitingHandler).setRunNotFinished();
            ((WaitingDialog) waitingHandler).setCloseDialogWhenImportCompletes(true, false);
        }
    } else {
        if (waitingHandler instanceof WaitingDialog) {
            saveReport();
        }
        TempFilesManager.deleteTempFolders();
        waitingHandler.setWaitingText("PeptideShaker Processing Canceled.");
        System.out.println("<CompomicsError>PeptideShaker processing canceled. " + getLogFileMessage() + "</CompomicsError>");
    }
}
Also used : ArrayList(java.util.ArrayList) WaitingDialog(com.compomics.util.gui.waiting.waitinghandlers.WaitingDialog) Properties(eu.isas.peptideshaker.utils.Properties) FastaSummary(com.compomics.util.experiment.io.biology.protein.FastaSummary) SearchParameters(com.compomics.util.parameters.identification.search.SearchParameters) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) ValidationQcParameters(com.compomics.util.parameters.identification.advanced.ValidationQcParameters) ProcessingParameters(com.compomics.util.parameters.tools.ProcessingParameters) MsFileHandler(com.compomics.util.experiment.io.mass_spectrometry.MsFileHandler) HashSet(java.util.HashSet) ProjectDetails(eu.isas.peptideshaker.preferences.ProjectDetails) IdentificationParametersInputBean(com.compomics.cli.identification_parameters.IdentificationParametersInputBean) SpectrumCountingParameters(com.compomics.util.parameters.quantification.spectrum_counting.SpectrumCountingParameters) Date(java.util.Date) TimeoutException(java.util.concurrent.TimeoutException) SQLException(java.sql.SQLException) Point(java.awt.Point) ProjectParameters(com.compomics.util.experiment.ProjectParameters) WaitingHandlerCLIImpl(com.compomics.util.gui.waiting.waitinghandlers.WaitingHandlerCLIImpl) PeptideShaker(eu.isas.peptideshaker.PeptideShaker)

Example 3 with WaitingDialog

use of com.compomics.util.gui.waiting.waitinghandlers.WaitingDialog in project peptide-shaker by compomics.

the class PeptideShakerCLI method saveReport.

/**
 * Save the peptide shaker report next to the psdb file.
 */
private void saveReport() {
    String report;
    if (waitingHandler instanceof WaitingDialog) {
        report = getExtendedProjectReport(((WaitingDialog) waitingHandler).getReport(null));
    } else {
        report = getExtendedProjectReport(null);
    }
    if (report != null) {
        if (waitingHandler instanceof WaitingDialog) {
            report = "<html><br>";
            report += "<b>Report:</b><br>";
            report += "<pre>" + ((WaitingDialog) waitingHandler).getReport(null) + "</pre>";
            report += "</html>";
        }
        try {
            DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss");
            File psReportFile = null;
            PathSettingsCLIInputBean pathSettingsCLIInputBean = cliInputBean.getPathSettingsCLIInputBean();
            if (getPsdbFile() != null) {
                String fileName = "PeptideShaker Report " + getPsdbFile().getName() + " " + df.format(new Date()) + ".html";
                psReportFile = new File(getPsdbFile().getParentFile(), fileName);
            } else if (cliInputBean.getOutput() != null) {
                String fileName = "PeptideShaker Report " + df.format(new Date()) + ".html";
                psReportFile = new File(cliInputBean.getOutput().getParentFile(), fileName);
            } else if (pathSettingsCLIInputBean.getLogFolder() != null) {
                String fileName = "PeptideShaker Report " + df.format(new Date()) + ".html";
                psReportFile = new File(pathSettingsCLIInputBean.getLogFolder(), fileName);
            }
            if (psReportFile != null) {
                FileWriter fw = new FileWriter(psReportFile);
                try {
                    fw.write(report);
                } finally {
                    fw.close();
                }
            }
        } catch (Exception ex) {
            waitingHandler.appendReport("An error occurred while saving the PeptideShaker report. " + getLogFileMessage(), true, true);
            ex.printStackTrace();
        }
    }
}
Also used : DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) WaitingDialog(com.compomics.util.gui.waiting.waitinghandlers.WaitingDialog) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) TimeoutException(java.util.concurrent.TimeoutException) SQLException(java.sql.SQLException)

Example 4 with WaitingDialog

use of com.compomics.util.gui.waiting.waitinghandlers.WaitingDialog in project peptide-shaker by compomics.

the class FileImporter method importFiles.

/**
 * Imports the identifications from the files.
 *
 * @param idFiles the identification files
 *
 * @return 0 if success, 1 if not
 */
public int importFiles(ArrayList<File> idFiles) {
    ArrayList<File> sortedIdFiles = idFiles.stream().collect(Collectors.groupingBy(File::getName, TreeMap::new, Collectors.toList())).values().stream().flatMap(List::stream).distinct().collect(Collectors.toCollection(ArrayList::new));
    try {
        importSequences(identificationParameters.getSequenceMatchingParameters(), identificationParameters.getSearchParameters(), identificationParameters.getFastaParameters(), identificationParameters.getPeptideVariantsParameters(), waitingHandler, exceptionHandler);
        if (waitingHandler.isRunCanceled()) {
            return 1;
        }
        GeneParameters geneParameters = identificationParameters.getGeneParameters();
        if (geneParameters.getUseGeneMapping()) {
            waitingHandler.setSecondaryProgressCounterIndeterminate(true);
            waitingHandler.appendReport("Importing gene mappings.", true, true);
            importGenes();
        } else {
            geneMaps = new GeneMaps();
        }
        if (waitingHandler.isRunCanceled()) {
            return 1;
        }
        waitingHandler.setSecondaryProgressCounterIndeterminate(true);
        waitingHandler.appendReport("Establishing local database connection.", true, true);
        waitingHandler.increasePrimaryProgressCounter();
        if (!waitingHandler.isRunCanceled()) {
            waitingHandler.appendReport("Reading identification files.", true, true);
            for (File idFile : sortedIdFiles) {
                importPsms(idFile);
                if (waitingHandler.isRunCanceled()) {
                    return 1;
                }
            }
            if (nRetained == 0) {
                waitingHandler.appendReport("No identification results.", true, true);
                waitingHandler.setRunCanceled();
                return 1;
            }
            // get the total number of spectra
            int nSpectra = 0;
            for (String spectrumFileName : identification.getFractions()) {
                nSpectra += spectrumProvider.getSpectrumTitles(spectrumFileName).length;
            }
            waitingHandler.appendReport("File import completed. " + nPSMs + " first hits imported (" + nTotal + " total) from " + nSpectra + " spectra.", true, true);
            waitingHandler.appendReport("[" + nRetained + " first hits passed the initial filtering]", true, true);
        }
    } catch (OutOfMemoryError error) {
        System.out.println("<CompomicsError>PeptideShaker ran out of memory! See the PeptideShaker log for details.</CompomicsError>");
        System.err.println("Ran out of memory!");
        System.err.println("Memory given to the Java virtual machine: " + Runtime.getRuntime().maxMemory() + ".");
        System.err.println("Memory used by the Java virtual machine: " + Runtime.getRuntime().totalMemory() + ".");
        System.err.println("Free memory in the Java virtual machine: " + Runtime.getRuntime().freeMemory() + ".");
        Runtime.getRuntime().gc();
        waitingHandler.appendReportEndLine();
        waitingHandler.appendReport("Ran out of memory!", true, true);
        waitingHandler.setRunCanceled();
        if (waitingHandler instanceof WaitingDialog) {
            JOptionPane.showMessageDialog((WaitingDialog) waitingHandler, JOptionEditorPane.getJOptionEditorPane("PeptideShaker used up all the available memory and had to be stopped.<br>" + "Memory boundaries are changed in the the Welcome Dialog (Settings<br>" + "& Help > Settings > Java Memory Settings) or in the Edit menu (Edit<br>" + "Java Options). See also <a href=\"https://compomics.github.io/projects/compomics-utilities/wiki/JavaTroubleShooting.html\">JavaTroubleShooting</a>."), "Out Of Memory", JOptionPane.ERROR_MESSAGE);
        }
        error.printStackTrace();
        return 1;
    } catch (Exception e) {
        waitingHandler.setRunCanceled();
        System.out.println("<CompomicsError>PeptideShaker processing failed. See the PeptideShaker log for details.</CompomicsError>");
        if (e instanceof NullPointerException) {
            waitingHandler.appendReport("An error occurred while loading the identification files.", true, true);
            waitingHandler.appendReport("Please see the error log (Help Menu > Bug Report) for details.", true, true);
        } else if (FrameExceptionHandler.getExceptionType(e).equalsIgnoreCase("Protein not found")) {
            waitingHandler.appendReport("An error occurred while loading the identification files:", true, true);
            waitingHandler.appendReport(e.getLocalizedMessage(), true, true);
            waitingHandler.appendReport("Please see https://compomics.github.io/projects/searchgui/wiki/DatabaseHelp.html.", true, true);
        } else {
            waitingHandler.appendReport("An error occurred while loading the identification files:", true, true);
            waitingHandler.appendReport(e.getLocalizedMessage(), true, true);
        }
        e.printStackTrace();
        System.err.println("Free memory: " + Runtime.getRuntime().freeMemory());
        return 1;
    }
    return 0;
}
Also used : GeneParameters(com.compomics.util.parameters.identification.advanced.GeneParameters) WaitingDialog(com.compomics.util.gui.waiting.waitinghandlers.WaitingDialog) File(java.io.File) GeneMaps(com.compomics.util.experiment.biology.genes.GeneMaps) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException)

Example 5 with WaitingDialog

use of com.compomics.util.gui.waiting.waitinghandlers.WaitingDialog 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

WaitingDialog (com.compomics.util.gui.waiting.waitinghandlers.WaitingDialog)5 TimeoutException (java.util.concurrent.TimeoutException)4 SQLException (java.sql.SQLException)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 ProjectParameters (com.compomics.util.experiment.ProjectParameters)2 WaitingHandlerCLIImpl (com.compomics.util.gui.waiting.waitinghandlers.WaitingHandlerCLIImpl)2 PeptideShaker (eu.isas.peptideshaker.PeptideShaker)2 ProjectDetails (eu.isas.peptideshaker.preferences.ProjectDetails)2 Point (java.awt.Point)2 LoggerContext (ch.qos.logback.classic.LoggerContext)1 IdentificationParametersInputBean (com.compomics.cli.identification_parameters.IdentificationParametersInputBean)1 ExceptionHandler (com.compomics.util.exceptions.ExceptionHandler)1 WaitingDialogExceptionHandler (com.compomics.util.exceptions.exception_handlers.WaitingDialogExceptionHandler)1 GeneMaps (com.compomics.util.experiment.biology.genes.GeneMaps)1 ProteinGeneDetailsProvider (com.compomics.util.experiment.biology.genes.ProteinGeneDetailsProvider)1 SpeciesFactory (com.compomics.util.experiment.biology.taxonomy.SpeciesFactory)1 FastaSummary (com.compomics.util.experiment.io.biology.protein.FastaSummary)1 MsFileHandler (com.compomics.util.experiment.io.mass_spectrometry.MsFileHandler)1 MgfIndex (com.compomics.util.experiment.io.mass_spectrometry.mgf.MgfIndex)1