Search in sources :

Example 1 with ProteinGeneDetailsProvider

use of com.compomics.util.experiment.biology.genes.ProteinGeneDetailsProvider in project peptide-shaker by compomics.

the class PeptideShakerGUI method main.

/**
 * The main method used to start PeptideShaker.
 *
 * @param args the arguments
 */
public static void main(String[] args) {
    // 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"));
    logger = loggerContext.getLogger("org.springframework");
    logger.setLevel(Level.toLevel("ERROR"));
    // set the look and feel
    boolean numbusLookAndFeelSet = false;
    try {
        numbusLookAndFeelSet = UtilitiesGUIDefaults.setLookAndFeel();
        // fix for the scroll bar thumb disappearing...
        LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
        UIDefaults defaults = lookAndFeel.getDefaults();
        defaults.put("ScrollBar.minimumThumbSize", new Dimension(30, 30));
    // edit the default font?
    // defaults.put("defaultFont", new Font("Segoe UI", Font.PLAIN, 12));
    } catch (Exception e) {
    }
    if (!numbusLookAndFeelSet) {
        JOptionPane.showMessageDialog(null, "Failed to set the default look and feel. Using backup look and feel.\n" + "PeptideShaker will work but not look as good as it should...", "Look and Feel", JOptionPane.WARNING_MESSAGE);
    }
    // need to add some padding to the text in the titled borders on Java 1.7
    if (!System.getProperty("java.version").startsWith("1.6")) {
        TITLED_BORDER_HORIZONTAL_PADDING = "   ";
        TITLED_BORDER_HORIZONTAL_PADDING_HTML = "   ";
    }
    // load gene mappings
    ProteinGeneDetailsProvider geneFactory = new ProteinGeneDetailsProvider();
    try {
        geneFactory.initialize(PeptideShaker.getJarFilePath());
    } catch (Exception e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "An error occurred while loading the gene mappings.", "Gene Mapping File Error", JOptionPane.ERROR_MESSAGE);
    }
    // load the species mapping
    try {
        SpeciesFactory speciesFactory = SpeciesFactory.getInstance();
        speciesFactory.initiate(PeptideShaker.getJarFilePath());
    } catch (Exception e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "An error occurred while loading the species mapping.", "File Error", JOptionPane.OK_OPTION);
    }
    // see if a psdb or url is to be opened, or a px accesion for reshake
    File psdbFile = null;
    boolean psdb = false;
    String zipUrl = null;
    boolean url = false;
    String zipUrlDownloadFolder = null;
    boolean downloadFolder = false;
    String pxAccession = null;
    boolean pxAccessionProvided = false;
    boolean pxAccessionPrivate = false;
    for (String arg : args) {
        if (psdb) {
            psdbFile = new File(arg);
            psdb = false;
        } else if (url) {
            zipUrl = arg;
            url = false;
        } else if (downloadFolder) {
            zipUrlDownloadFolder = arg;
            downloadFolder = false;
        } else if (pxAccessionProvided) {
            pxAccession = arg;
            pxAccessionProvided = false;
        }
        if (arg.equals(ToolFactory.PEPTIDE_SHAKER_FILE_OPTION)) {
            psdb = true;
        } else if (arg.equals(ToolFactory.PEPTIDE_SHAKER_URL_OPTION)) {
            url = true;
        } else if (arg.equals(ToolFactory.PEPTIDE_SHAKER_URL_DOWNLOAD_FOLDER_OPTION)) {
            downloadFolder = true;
        } else if (arg.equals(ToolFactory.PEPTIDE_SHAKER_PX_ACCESSION_OPTION)) {
            pxAccessionProvided = true;
        } else if (arg.equals(ToolFactory.PEPTIDE_SHAKER_PX_ACCESSION_PRIVATE_OPTION)) {
            pxAccessionPrivate = true;
        }
    }
    // check if the download folder was provided if a url was given
    if (zipUrl != null && zipUrlDownloadFolder == null) {
        zipUrl = null;
        JOptionPane.showMessageDialog(null, "Setting the download folder is mandatory when opening a URL. Please use the -zipUrlFolder option.", "Downloading URL Error", JOptionPane.WARNING_MESSAGE);
    }
    new PeptideShakerGUI(psdbFile, zipUrl, zipUrlDownloadFolder, pxAccession, pxAccessionPrivate, true);
}
Also used : UtilitiesGUIDefaults(com.compomics.util.gui.UtilitiesGUIDefaults) SpeciesFactory(com.compomics.util.experiment.biology.taxonomy.SpeciesFactory) ProteinGeneDetailsProvider(com.compomics.util.experiment.biology.genes.ProteinGeneDetailsProvider) LoggerContext(ch.qos.logback.classic.LoggerContext) ConnectException(java.net.ConnectException) UnknownHostException(java.net.UnknownHostException) Field(java.lang.reflect.Field) MavenJarFile(com.compomics.software.autoupdater.MavenJarFile)

Example 2 with ProteinGeneDetailsProvider

use of com.compomics.util.experiment.biology.genes.ProteinGeneDetailsProvider 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 3 with ProteinGeneDetailsProvider

use of com.compomics.util.experiment.biology.genes.ProteinGeneDetailsProvider in project peptide-shaker by compomics.

the class FileImporter method importGenes.

/**
 * Imports the gene information for this project.
 */
public void importGenes() {
    ProteinGeneDetailsProvider geneFactory = new ProteinGeneDetailsProvider();
    try {
        geneFactory.initialize(PeptideShaker.getJarFilePath());
    } catch (Exception e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "An error occurred while loading the gene mappings.", "Gene Mapping File Error", JOptionPane.ERROR_MESSAGE);
    }
    GeneParameters geneParameters = identificationParameters.getGeneParameters();
    geneMaps = geneFactory.getGeneMaps(geneParameters, fastaSummary, sequenceProvider, proteinDetailsProvider, waitingHandler);
}
Also used : GeneParameters(com.compomics.util.parameters.identification.advanced.GeneParameters) ProteinGeneDetailsProvider(com.compomics.util.experiment.biology.genes.ProteinGeneDetailsProvider) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException)

Aggregations

ProteinGeneDetailsProvider (com.compomics.util.experiment.biology.genes.ProteinGeneDetailsProvider)3 LoggerContext (ch.qos.logback.classic.LoggerContext)2 SpeciesFactory (com.compomics.util.experiment.biology.taxonomy.SpeciesFactory)2 Field (java.lang.reflect.Field)2 TimeoutException (java.util.concurrent.TimeoutException)2 MavenJarFile (com.compomics.software.autoupdater.MavenJarFile)1 MgfIndex (com.compomics.util.experiment.io.mass_spectrometry.mgf.MgfIndex)1 DummyFrame (com.compomics.util.gui.DummyFrame)1 UtilitiesGUIDefaults (com.compomics.util.gui.UtilitiesGUIDefaults)1 WaitingDialog (com.compomics.util.gui.waiting.waitinghandlers.WaitingDialog)1 WaitingHandlerCLIImpl (com.compomics.util.gui.waiting.waitinghandlers.WaitingHandlerCLIImpl)1 GeneParameters (com.compomics.util.parameters.identification.advanced.GeneParameters)1 Point (java.awt.Point)1 IOException (java.io.IOException)1 ConnectException (java.net.ConnectException)1 UnknownHostException (java.net.UnknownHostException)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1