Search in sources :

Example 1 with ProteinGoTableModel

use of eu.isas.peptideshaker.gui.tablemodels.ProteinGoTableModel in project peptide-shaker by compomics.

the class GOEAPanel method proteinTableKeyReleased.

// GEN-LAST:event_proteinTableMouseReleased
/**
 * Update the protein selection.
 *
 * @param evt
 */
private void proteinTableKeyReleased(java.awt.event.KeyEvent evt) {
    // GEN-FIRST:event_proteinTableKeyReleased
    int row = proteinTable.getSelectedRow();
    if (row != -1) {
        // update the protein selection
        ProteinGoTableModel proteinGoTableModel = (ProteinGoTableModel) proteinTable.getModel();
        int selectedGroupIndex = proteinTable.convertRowIndexToModel(proteinTable.getSelectedRow());
        long proteinGroupKey = proteinGoTableModel.getProteins().get(selectedGroupIndex);
        String spectrumFile = null;
        String spectrumTitle = null;
        // try to select the "best" peptide for the selected peptide
        long peptideKey = peptideShakerGUI.getDefaultPeptideSelection(proteinGroupKey);
        // try to select the "best" psm for the selected peptide
        if (peptideKey != NO_KEY) {
            long psmKey = peptideShakerGUI.getDefaultPsmSelection(peptideKey);
            SpectrumMatch spectrumMatch = peptideShakerGUI.getIdentification().getSpectrumMatch(psmKey);
            spectrumFile = spectrumMatch.getSpectrumFile();
            spectrumTitle = spectrumMatch.getSpectrumTitle();
        }
        peptideShakerGUI.setSelectedItems(proteinGroupKey, peptideKey, spectrumFile, spectrumTitle);
    }
}
Also used : SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) ProteinGoTableModel(eu.isas.peptideshaker.gui.tablemodels.ProteinGoTableModel) ValueAndBooleanDataPoint(no.uib.jsparklines.data.ValueAndBooleanDataPoint) XYDataPoint(no.uib.jsparklines.data.XYDataPoint)

Example 2 with ProteinGoTableModel

use of eu.isas.peptideshaker.gui.tablemodels.ProteinGoTableModel in project peptide-shaker by compomics.

the class GOEAPanel method updateProteinTable.

/**
 * Update the protein table.
 */
private void updateProteinTable() {
    // @TODO: order the proteins in some way?
    if (goMappingsTable.getSelectedRow() != -1) {
        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("Loading Protein Data. Please Wait...");
        new Thread(new Runnable() {

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

            @Override
            public void run() {
                try {
                    // clear the old data
                    DefaultTableModel dm = (DefaultTableModel) proteinTable.getModel();
                    dm.getDataVector().removeAllElements();
                    dm.fireTableDataChanged();
                    // get the selected go accession number
                    String selectedGoAccession = (String) goMappingsTable.getValueAt(goMappingsTable.getSelectedRow(), goMappingsTable.getColumn("GO Accession").getModelIndex());
                    // remove the html tags
                    selectedGoAccession = selectedGoAccession.substring(selectedGoAccession.lastIndexOf("GTerm?id=") + "GTerm?id=".length(), selectedGoAccession.lastIndexOf("\"><font"));
                    // get the list of matching proteins
                    GeneMaps geneMaps = peptideShakerGUI.getGeneMaps();
                    HashSet<String> goProteins = geneMaps.getProteinsForGoTerm(selectedGoAccession);
                    Identification identification = peptideShakerGUI.getIdentification();
                    ArrayList<Long> proteinKeys = new ArrayList<>(goProteins.size());
                    HashMap<String, HashSet<Long>> proteinMap = identification.getProteinMap();
                    for (String goProtein : goProteins) {
                        HashSet<Long> tempKeys = proteinMap.get(goProtein);
                        if (tempKeys != null) {
                            proteinKeys.addAll(tempKeys);
                        }
                    }
                    // update the table
                    if (proteinTable.getModel() instanceof ProteinGoTableModel) {
                        ((ProteinGoTableModel) proteinTable.getModel()).updateDataModel(proteinKeys);
                    } else {
                        ProteinGoTableModel proteinTableModel = new ProteinGoTableModel(peptideShakerGUI.getIdentification(), peptideShakerGUI.getProteinDetailsProvider(), peptideShakerGUI.getIdentificationFeaturesGenerator(), peptideShakerGUI.getDisplayFeaturesGenerator(), proteinKeys, peptideShakerGUI.getDisplayParameters().showScores());
                        proteinTable.setModel(proteinTableModel);
                    }
                    setProteinGoTableProperties();
                    ((DefaultTableModel) proteinTable.getModel()).fireTableDataChanged();
                    if (proteinTable.getRowCount() > 0) {
                        // get the number of confident and doubtful matches
                        int nConfident = 0;
                        int nDoubtful = 0;
                        for (long proteinKey : proteinKeys) {
                            PSParameter psParameter = (PSParameter) (identification.getProteinMatch(proteinKey)).getUrParam(PSParameter.dummy);
                            MatchValidationLevel level = psParameter.getMatchValidationLevel();
                            if (level == MatchValidationLevel.confident) {
                                nConfident++;
                            } else if (level == MatchValidationLevel.doubtful) {
                                nDoubtful++;
                            }
                        }
                        String title = PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Gene Ontology Enrichment Analysis - " + goMappingsTable.getValueAt(goMappingsTable.getSelectedRow(), goMappingsTable.getColumn("GO Term").getModelIndex()) + " (";
                        try {
                            if (nConfident > 0) {
                                title += (nConfident + nDoubtful) + "/" + proteinKeys.size() + " - " + nConfident + " confident, " + nDoubtful + " doubtful";
                            } else {
                                title += proteinKeys.size();
                            }
                        } catch (Exception eNValidated) {
                            peptideShakerGUI.catchException(eNValidated);
                        }
                        title += ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING;
                        ((TitledBorder) plotPanel.getBorder()).setTitle(title);
                        plotPanel.repaint();
                        proteinTable.setRowSelectionInterval(0, 0);
                        proteinTable.scrollRectToVisible(proteinTable.getCellRect(0, 0, false));
                        // update the protein selection
                        ProteinGoTableModel proteinGoTableModel = (ProteinGoTableModel) proteinTable.getModel();
                        int selectedGroupIndex = proteinTable.convertRowIndexToModel(proteinTable.getSelectedRow());
                        long proteinGroupKey = proteinGoTableModel.getProteins().get(selectedGroupIndex);
                        peptideShakerGUI.setSelectedItems(proteinGroupKey, NO_KEY, null, null);
                        proteinTableKeyReleased(null);
                    }
                    progressDialog.setRunFinished();
                } catch (Exception e) {
                    progressDialog.setRunFinished();
                    peptideShakerGUI.catchException(e);
                }
            }
        }.start();
    }
}
Also used : DefaultTableModel(javax.swing.table.DefaultTableModel) Identification(com.compomics.util.experiment.identification.Identification) ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) ProteinGoTableModel(eu.isas.peptideshaker.gui.tablemodels.ProteinGoTableModel) GeneMaps(com.compomics.util.experiment.biology.genes.GeneMaps) MatchValidationLevel(com.compomics.util.experiment.identification.validation.MatchValidationLevel) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter)

Aggregations

ProteinGoTableModel (eu.isas.peptideshaker.gui.tablemodels.ProteinGoTableModel)2 GeneMaps (com.compomics.util.experiment.biology.genes.GeneMaps)1 Identification (com.compomics.util.experiment.identification.Identification)1 SpectrumMatch (com.compomics.util.experiment.identification.matches.SpectrumMatch)1 PSParameter (com.compomics.util.experiment.identification.peptide_shaker.PSParameter)1 MatchValidationLevel (com.compomics.util.experiment.identification.validation.MatchValidationLevel)1 ProgressDialogX (com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX)1 DefaultTableModel (javax.swing.table.DefaultTableModel)1 ValueAndBooleanDataPoint (no.uib.jsparklines.data.ValueAndBooleanDataPoint)1 XYDataPoint (no.uib.jsparklines.data.XYDataPoint)1