Search in sources :

Example 1 with MzIdentMLExport

use of eu.isas.peptideshaker.export.MzIdentMLExport in project peptide-shaker by compomics.

the class MzIdentMLExportDialog method convertJButtonActionPerformed.

// GEN-LAST:event_contactEmailJTextFieldKeyReleased
/**
 * Convert the project to an mzIdentML file.
 *
 * @param evt
 */
private void convertJButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_convertJButtonActionPerformed
    final File finalOutputFile = new File(outputFolderJTextField.getText());
    progressDialog = new ProgressDialogX(peptideShakerGUI, Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker.gif")), Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker-orange.gif")), true);
    progressDialog.setPrimaryProgressCounterIndeterminate(true);
    progressDialog.setTitle("Exporting mzIdentML. Please Wait...");
    new Thread(new Runnable() {

        public void run() {
            try {
                progressDialog.setVisible(true);
            } catch (IndexOutOfBoundsException e) {
            // ignore
            }
        }
    }, "ProgressDialog").start();
    new Thread("ConvertThread") {

        @Override
        public void run() {
            IdentificationParameters identificationParameters = peptideShakerGUI.getIdentificationParameters();
            AnnotationParameters annotationParameters = identificationParameters.getAnnotationParameters();
            ProjectDetails projectDetails = peptideShakerGUI.getProjectDetails();
            // save the inserted mzid details with the project
            projectDetails.setContactFirstName(contactFirstNameJTextField.getText().trim());
            projectDetails.setContactLastName(contactLastNameJTextField.getText().trim());
            projectDetails.setContactEmail(contactEmailJTextField.getText().trim());
            projectDetails.setContactAddress(contactAddressJTextField.getText().trim());
            if (!contactUrlJTextField.getText().trim().isEmpty()) {
                projectDetails.setContactUrl(contactUrlJTextField.getText().trim());
            } else {
                projectDetails.setContactUrl(null);
            }
            projectDetails.setOrganizationName(organizationNameJTextField.getText().trim());
            projectDetails.setOrganizationEmail(organizationEmailJTextField.getText().trim());
            projectDetails.setOrganizationAddress(organizationAddressJTextField.getText().trim());
            if (!organizationUrlJTextField.getText().trim().isEmpty()) {
                projectDetails.setOrganizationUrl(organizationUrlJTextField.getText().trim());
            } else {
                projectDetails.setOrganizationUrl(null);
            }
            projectDetails.setIncludeProteinSequences(includeSequencesCheckBox.isSelected());
            projectDetails.setMzIdentOutputFile(outputFolderJTextField.getText());
            peptideShakerGUI.setDataSaved(false);
            boolean conversionCompleted = false;
            // make sure that all annotations are included
            double currentIntensityLimit = annotationParameters.getAnnotationIntensityLimit();
            annotationParameters.setIntensityLimit(0.0);
            try {
                FastaSummary fastaSummary = FastaSummary.getSummary(projectDetails.getFastaFile(), identificationParameters.getFastaParameters(), progressDialog);
                MzIdentMLExport mzIdentMLExport = new MzIdentMLExport(PeptideShaker.getVersion(), peptideShakerGUI.getIdentification(), projectDetails, identificationParameters, peptideShakerGUI.getSequenceProvider(), peptideShakerGUI.getProteinDetailsProvider(), peptideShakerGUI.getSpectrumProvider(), ModificationFactory.getInstance(), fastaSummary, peptideShakerGUI.getIdentificationFeaturesGenerator(), finalOutputFile, includeSequencesCheckBox.isSelected(), progressDialog, true);
                mzIdentMLExport.createMzIdentMLFile(mzIdentMLVersion);
                // validate the mzidentml file
                if (validateMzIdentML && !progressDialog.isRunCanceled()) {
                    progressDialog.setPrimaryProgressCounterIndeterminate(true);
                    progressDialog.setTitle("Validating mzIdentML. Please Wait...");
                    String errors = validateMzIdentML(finalOutputFile);
                    // see if any errors were found, and display them to the user
                    if (!errors.isEmpty()) {
                        JOptionPane.showMessageDialog(null, errors, "mzIdentML Errors", JOptionPane.ERROR_MESSAGE);
                    } else {
                        conversionCompleted = true;
                    }
                } else {
                    conversionCompleted = true;
                }
            } catch (Exception e) {
                peptideShakerGUI.catchException(e);
                progressDialog.setRunCanceled();
                progressDialog.dispose();
                return;
            } finally {
                // reset the annotation level
                annotationParameters.setIntensityLimit(currentIntensityLimit);
            }
            // close the progress dialog
            boolean processCancelled = progressDialog.isRunCanceled();
            progressDialog.setRunFinished();
            // display a conversion complete message to the user
            if (conversionCompleted && !processCancelled) {
                JOptionPane.showMessageDialog(MzIdentMLExportDialog.this, JOptionEditorPane.getJOptionEditorPane("mzIdentML file \'" + new File(outputFolderJTextField.getText()).getAbsolutePath() + "\' created." + "<br><br>" + "Review your mzIdentML files with <a href=\"https://github.com/PRIDE-Toolsuite/pride-inspector\">PRIDE Inspector</a>.<br>" + "Publish your mzIdentML files via <a href=\"http://www.proteomexchange.org/submission\">ProteomeXchange</a>."), "File Created", JOptionPane.INFORMATION_MESSAGE);
                dispose();
            }
            if (processCancelled) {
                JOptionPane.showMessageDialog(peptideShakerGUI, "mzIdentML conversion cancelled by the user.", "mzIdentML Conversion Cancelled", JOptionPane.WARNING_MESSAGE);
            }
        }
    }.start();
}
Also used : ProjectDetails(eu.isas.peptideshaker.preferences.ProjectDetails) AnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters) FastaSummary(com.compomics.util.experiment.io.biology.protein.FastaSummary) URISyntaxException(java.net.URISyntaxException) MalformedURLException(java.net.MalformedURLException) SAXException(org.xml.sax.SAXException) ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) MzIdentMLExport(eu.isas.peptideshaker.export.MzIdentMLExport) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters)

Example 2 with MzIdentMLExport

use of eu.isas.peptideshaker.export.MzIdentMLExport in project peptide-shaker by compomics.

the class CLIExportMethods method exportMzId.

/**
 * Exports the project in the mzIdentML format.
 *
 * @param mzidCLIInputBean the user input
 * @param psbdParent a psbd file parent allowing accessing the information it
 * contains
 * @param waitingHandler a waiting handler allowing display of progress and
 * interruption of the export
 *
 * @throws IOException exception thrown whenever an IO exception occurred
 * while reading or writing to a file
 */
public static void exportMzId(MzidCLIInputBean mzidCLIInputBean, PsdbParent psbdParent, WaitingHandler waitingHandler) throws IOException {
    ProjectDetails projectDetails = psbdParent.getProjectDetails();
    projectDetails.setContactFirstName(mzidCLIInputBean.getContactFirstName());
    projectDetails.setContactLastName(mzidCLIInputBean.getContactLastName());
    projectDetails.setContactEmail(mzidCLIInputBean.getContactEmail());
    projectDetails.setContactAddress(mzidCLIInputBean.getContactAddress());
    projectDetails.setContactUrl(mzidCLIInputBean.getContactUrl());
    projectDetails.setOrganizationName(mzidCLIInputBean.getOrganizationName());
    projectDetails.setOrganizationEmail(mzidCLIInputBean.getOrganizationMail());
    projectDetails.setOrganizationAddress(mzidCLIInputBean.getOrganizationAddress());
    projectDetails.setOrganizationUrl(mzidCLIInputBean.getOrganizationUrl());
    projectDetails.setIncludeProteinSequences(mzidCLIInputBean.getIncludeProteinSequences());
    projectDetails.setPrideOutputFolder(mzidCLIInputBean.getOutputFile().getAbsolutePath());
    IdentificationParameters identificationParameters = psbdParent.getIdentificationParameters();
    FastaSummary fastaSummary = FastaSummary.getSummary(projectDetails.getFastaFile(), identificationParameters.getFastaParameters(), waitingHandler);
    MzIdentMLExport mzIdentMLExport = new MzIdentMLExport(PeptideShaker.getVersion(), psbdParent.getIdentification(), psbdParent.getProjectDetails(), identificationParameters, psbdParent.getSequenceProvider(), psbdParent.getProteinDetailsProvider(), psbdParent.getSpectrumProvider(), ModificationFactory.getInstance(), fastaSummary, psbdParent.getIdentificationFeaturesGenerator(), mzidCLIInputBean.getOutputFile(), mzidCLIInputBean.getIncludeProteinSequences(), waitingHandler, mzidCLIInputBean.isGzip());
    mzIdentMLExport.createMzIdentMLFile(mzidCLIInputBean.getMzIdentMLVersion());
}
Also used : ProjectDetails(eu.isas.peptideshaker.preferences.ProjectDetails) MzIdentMLExport(eu.isas.peptideshaker.export.MzIdentMLExport) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) FastaSummary(com.compomics.util.experiment.io.biology.protein.FastaSummary)

Aggregations

FastaSummary (com.compomics.util.experiment.io.biology.protein.FastaSummary)2 IdentificationParameters (com.compomics.util.parameters.identification.IdentificationParameters)2 MzIdentMLExport (eu.isas.peptideshaker.export.MzIdentMLExport)2 ProjectDetails (eu.isas.peptideshaker.preferences.ProjectDetails)2 AnnotationParameters (com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters)1 ProgressDialogX (com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 SAXException (org.xml.sax.SAXException)1