Search in sources :

Example 1 with SelfUpdatingTableModel

use of com.compomics.util.gui.tablemodels.SelfUpdatingTableModel in project peptide-shaker by compomics.

the class ProteinStructurePanel method pdbMatchesJTableMouseReleased.

// GEN-LAST:event_peptideTableMouseReleased
/**
 * Update the PDB structure shown in the Jmol panel.
 *
 * @param evt
 */
private void pdbMatchesJTableMouseReleased(java.awt.event.MouseEvent evt) {
    // GEN-FIRST:event_pdbMatchesJTableMouseReleased
    setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
    boolean loadStructure = true;
    if (pdbMatchesJTable.getSelectedRow() != -1 && currentlyDisplayedPdbFile != null) {
        String tempPdbFile = (String) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), pdbMatchesJTable.getColumn("PDB").getModelIndex());
        if (currentlyDisplayedPdbFile.equalsIgnoreCase(tempPdbFile)) {
            loadStructure = false;
        }
    }
    if (loadStructure) {
        // just a trick to make sure that the users cannot select
        // another row until the selection has been updated
        this.setEnabled(false);
        DefaultTableModel dm = (DefaultTableModel) pdbChainsJTable.getModel();
        dm.getDataVector().removeAllElements();
        dm.fireTableDataChanged();
        // clear the peptide to pdb mappings in the peptide table
        for (int i = 0; i < peptideTable.getRowCount(); i++) {
            peptideTable.setValueAt(false, i, peptideTable.getColumn("PDB").getModelIndex());
        }
        // select the peptide in the table again
        int peptideRow = 0;
        long peptideKey = peptideShakerGUI.getSelectedPeptideKey();
        if (peptideKey != NO_KEY) {
            peptideRow = getPeptideRow(peptideKey);
        }
        if (peptideTable.getRowCount() > 0) {
            peptideTable.setRowSelectionInterval(peptideRow, peptideRow);
            peptideTable.scrollRectToVisible(peptideTable.getCellRect(peptideRow, peptideRow, false));
        }
        // empty the jmol panel
        if (jmolStructureShown) {
            jmolPanel = new JmolPanel();
            pdbPanel.removeAll();
            pdbPanel.add(jmolPanel);
            pdbPanel.revalidate();
            pdbPanel.repaint();
            jmolStructureShown = false;
            currentlyDisplayedPdbFile = null;
            ((TitledBorder) pdbOuterPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Structure" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
            pdbOuterPanel.repaint();
        }
        if (pdbMatchesJTable.getSelectedRow() != -1) {
            currentlyDisplayedPdbFile = (String) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), pdbMatchesJTable.getColumn("PDB").getModelIndex());
            // open protein link in web browser
            if (pdbMatchesJTable.getSelectedColumn() == pdbMatchesJTable.getColumn("PDB").getModelIndex() && evt.getButton() == MouseEvent.BUTTON1 && ((String) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), pdbMatchesJTable.getSelectedColumn())).lastIndexOf("<a href=\"") != -1) {
                String temp = currentlyDisplayedPdbFile.substring(currentlyDisplayedPdbFile.indexOf("\"") + 1);
                currentlyDisplayedPdbFile = temp.substring(0, temp.indexOf("\""));
                this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
                BareBonesBrowserLaunch.openURL(currentlyDisplayedPdbFile);
                this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
            }
            // get the pdb file
            int selectedPdbTableIndex = (Integer) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), 0);
            PdbParameter lParam = uniProtPdb.getPdbs().get(selectedPdbTableIndex - 1);
            chains = lParam.getBlocks();
            // get the protein sequence
            SelfUpdatingTableModel proteinTableModel = (SelfUpdatingTableModel) proteinTable.getModel();
            int proteinIndex = proteinTableModel.getViewIndex(proteinTable.getSelectedRow());
            long proteinKey = proteinKeys[proteinIndex];
            ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinKey);
            String proteinSequence = peptideShakerGUI.getSequenceProvider().getSequence(proteinMatch.getLeadingAccession());
            // add the chain information to the table
            for (int j = 0; j < chains.length; j++) {
                XYDataPoint temp = new XYDataPoint(chains[j].getStartProtein(), chains[j].getEndProtein());
                if (chains[j].getStartProtein() != chains[j].getEndProtein()) {
                    ((DefaultTableModel) pdbChainsJTable.getModel()).addRow(new Object[] { (j + 1), chains[j].getBlock(), temp, (((double) chains[j].getEndProtein() - chains[j].getStartProtein()) / proteinSequence.length()) * 100 });
                }
            }
            ((JSparklinesIntervalChartTableCellRenderer) pdbChainsJTable.getColumn("PDB-Protein").getCellRenderer()).setMaxValue(proteinSequence.length());
            if (pdbChainsJTable.getRowCount() > 0) {
                ((TitledBorder) pdbChainsPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Chains (" + pdbChainsJTable.getRowCount() + ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
            } else {
                ((TitledBorder) pdbChainsPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Chains" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
            }
            pdbChainsPanel.repaint();
            if (pdbChainsJTable.getRowCount() > 0) {
                pdbChainsJTable.setRowSelectionInterval(0, 0);
                pdbChainsJTable.scrollRectToVisible(pdbChainsJTable.getCellRect(0, 0, false));
                pdbChainsJTableMouseReleased(null);
            }
        } else {
            ((TitledBorder) pdbChainsPanel.getBorder()).setTitle(PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "PDB Chains" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING);
            pdbChainsPanel.repaint();
        }
        // give the power back to the user ;)
        this.setEnabled(true);
    } else {
        // open protein link in web browser
        if (pdbMatchesJTable.getSelectedColumn() == pdbMatchesJTable.getColumn("PDB").getModelIndex() && evt.getButton() == MouseEvent.BUTTON1 && ((String) pdbMatchesJTable.getValueAt(pdbMatchesJTable.getSelectedRow(), pdbMatchesJTable.getSelectedColumn())).lastIndexOf("<a href=\"") != -1) {
            String temp = currentlyDisplayedPdbFile.substring(currentlyDisplayedPdbFile.indexOf("\"") + 1);
            currentlyDisplayedPdbFile = temp.substring(0, temp.indexOf("\""));
            this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
            BareBonesBrowserLaunch.openURL(currentlyDisplayedPdbFile);
            this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        }
    }
    setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
}
Also used : DefaultTableModel(javax.swing.table.DefaultTableModel) TitledBorder(javax.swing.border.TitledBorder) XYDataPoint(no.uib.jsparklines.data.XYDataPoint) SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) JSparklinesIntervalChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer) PdbParameter(com.compomics.util.pdbfinder.pdb.PdbParameter) XYDataPoint(no.uib.jsparklines.data.XYDataPoint)

Example 2 with SelfUpdatingTableModel

use of com.compomics.util.gui.tablemodels.SelfUpdatingTableModel in project peptide-shaker by compomics.

the class ProteinStructurePanel method peptideTableMouseReleased.

// GEN-LAST:event_proteinTableMouseReleased
/**
 * Updates the PDB structure.
 *
 * @param evt
 */
private void peptideTableMouseReleased(java.awt.event.MouseEvent evt) {
    // GEN-FIRST:event_peptideTableMouseReleased
    setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
    if (evt != null) {
        peptideShakerGUI.setSelectedItems(peptideShakerGUI.getSelectedProteinKey(), NO_KEY, null, null);
    }
    int row = peptideTable.getSelectedRow();
    int column = peptideTable.getSelectedColumn();
    if (row != -1) {
        if (pdbMatchesJTable.getSelectedRow() != -1) {
            updatePeptideToPdbMapping();
        }
        // remember the selection
        newItemSelection();
        if (column == peptideTable.getColumn("  ").getModelIndex()) {
            long peptideKey = peptideTableMap.get(getPeptideIndex(row));
            PeptideMatch peptideMatch = peptideShakerGUI.getIdentification().getPeptideMatch(peptideKey);
            PSParameter psParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
            if (!psParameter.getStarred()) {
                peptideShakerGUI.getStarHider().starPeptide(peptideKey);
            } else {
                peptideShakerGUI.getStarHider().unStarPeptide(peptideKey);
            }
            peptideShakerGUI.setDataSaved(false);
        }
        // open the protein inference at the petide level dialog
        if (column == peptideTable.getColumn("PI").getModelIndex() && evt != null && evt.getButton() == MouseEvent.BUTTON1) {
            SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) proteinTable.getModel();
            int proteinIndex = tableModel.getViewIndex(proteinTable.getSelectedRow());
            long proteinKey = proteinKeys[proteinIndex];
            long peptideKey = peptideTableMap.get(getPeptideIndex(row));
            new ProteinInferencePeptideLevelDialog(peptideShakerGUI, true, peptideKey, proteinKey, peptideShakerGUI.getGeneMaps());
        }
    }
    setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
}
Also used : PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel) ProteinInferencePeptideLevelDialog(eu.isas.peptideshaker.gui.protein_inference.ProteinInferencePeptideLevelDialog) XYDataPoint(no.uib.jsparklines.data.XYDataPoint) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter)

Example 3 with SelfUpdatingTableModel

use of com.compomics.util.gui.tablemodels.SelfUpdatingTableModel in project peptide-shaker by compomics.

the class ProteinFractionsPanel method newItemSelection.

/**
 * Provides to the PeptideShakerGUI instance the currently selected protein,
 * peptide and PSM.
 */
public void newItemSelection() {
    long proteinKey = NO_KEY;
    long peptideKey = NO_KEY;
    String spectrumFile = null;
    String spectrumTitle = null;
    if (proteinTable.getSelectedRow() != -1) {
        SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) proteinTable.getModel();
        int index = tableModel.getViewIndex(proteinTable.getSelectedRow());
        proteinKey = proteinKeys[index];
        // try to select the "best" peptide for the selected peptide
        peptideKey = peptideShakerGUI.getDefaultPeptideSelection(proteinKey);
        // 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(proteinKey, peptideKey, spectrumFile, spectrumTitle);
}
Also used : SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch)

Example 4 with SelfUpdatingTableModel

use of com.compomics.util.gui.tablemodels.SelfUpdatingTableModel in project peptide-shaker by compomics.

the class OverviewPanel method updateProteinSequenceCoveragePanelTitle.

/**
 * Update the title of the protein sequence coverage panel.
 *
 * @param proteinAccession the accession of the protein of interest
 */
private void updateProteinSequenceCoveragePanelTitle(String proteinAccession) {
    currentProteinSequence = peptideShakerGUI.getSequenceProvider().getSequence(proteinAccession);
    SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) proteinTable.getModel();
    if (proteinTable.getSelectedRow() != -1) {
        long proteinKey = proteinKeys[tableModel.getViewIndex(proteinTable.getSelectedRow())];
        String title = PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Protein Sequence Coverage (";
        HashMap<Integer, Double> sequenceCoverage = peptideShakerGUI.getIdentificationFeaturesGenerator().getSequenceCoverage(proteinKey);
        double sequenceCoverageConfident = 100 * sequenceCoverage.get(MatchValidationLevel.confident.getIndex());
        double sequenceCoverageDoubtful = 100 * sequenceCoverage.get(MatchValidationLevel.doubtful.getIndex());
        double sequenceCoverageNotValidated = 100 * sequenceCoverage.get(MatchValidationLevel.not_validated.getIndex());
        double validatedCoverage = sequenceCoverageConfident + sequenceCoverageDoubtful;
        double totalCoverage = validatedCoverage + sequenceCoverageNotValidated;
        if (validatedCoverage > 0) {
            title += Util.roundDouble(totalCoverage, 2) + "%" + " - " + Util.roundDouble(sequenceCoverageConfident, 2) + "% confident, " + Util.roundDouble(sequenceCoverageDoubtful, 2) + "% doubtful, " + Util.roundDouble(sequenceCoverageNotValidated, 2) + "% not validated";
        } else {
            title += Util.roundDouble(sequenceCoverageNotValidated, 2) + "%";
        }
        title += " - ";
        double possibleCoverarge = 100.0 * peptideShakerGUI.getIdentificationFeaturesGenerator().getObservableCoverage(proteinKey);
        title += Util.roundDouble(possibleCoverarge, 2) + "% possible";
        title += " - ";
        title += currentProteinSequence.length() + " AA)";
        title += PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING;
        ((TitledBorder) sequenceCoverageTitledPanel.getBorder()).setTitle(title);
        sequenceCoverageTitledPanel.repaint();
    }
}
Also used : SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel) TitledBorder(javax.swing.border.TitledBorder)

Example 5 with SelfUpdatingTableModel

use of com.compomics.util.gui.tablemodels.SelfUpdatingTableModel in project peptide-shaker by compomics.

the class OverviewPanel method coverageShowAllPeptidesJRadioButtonMenuItemActionPerformed.

// GEN-LAST:event_sequenceCoverageOptionsJButtonMouseReleased
/**
 * Update the sequence coverage map.
 *
 * @param evt
 */
private void coverageShowAllPeptidesJRadioButtonMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
    if (proteinTable.getSelectedRow() != -1) {
        SelfUpdatingTableModel tableModel = (SelfUpdatingTableModel) proteinTable.getModel();
        long proteinKey = proteinKeys[tableModel.getViewIndex(proteinTable.getSelectedRow())];
        ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinKey);
        updateSequenceCoverage(proteinKey, proteinMatch.getLeadingAccession(), true);
    }
}
Also used : SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel)

Aggregations

SelfUpdatingTableModel (com.compomics.util.gui.tablemodels.SelfUpdatingTableModel)31 java.awt (java.awt)10 Identification (com.compomics.util.experiment.identification.Identification)9 PSParameter (com.compomics.util.experiment.identification.peptide_shaker.PSParameter)9 TitledBorder (javax.swing.border.TitledBorder)8 Peptide (com.compomics.util.experiment.biology.proteins.Peptide)7 IdentificationFeaturesGenerator (com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator)6 FileNotFoundException (java.io.FileNotFoundException)6 SequenceProvider (com.compomics.util.experiment.io.biology.protein.SequenceProvider)5 GeneDetailsDialog (com.compomics.util.gui.genes.GeneDetailsDialog)5 IdentificationParameters (com.compomics.util.parameters.identification.IdentificationParameters)5 SequenceMatchingParameters (com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters)5 ModificationParameters (com.compomics.util.parameters.identification.search.ModificationParameters)5 MatchValidationDialog (eu.isas.peptideshaker.gui.MatchValidationDialog)5 ProteinSequencePanel (eu.isas.peptideshaker.gui.protein_sequence.ProteinSequencePanel)5 DisplayParameters (eu.isas.peptideshaker.preferences.DisplayParameters)5 PSMaps (eu.isas.peptideshaker.scoring.PSMaps)5 DefaultTableModel (javax.swing.table.DefaultTableModel)5 JSparklinesDataSeries (no.uib.jsparklines.data.JSparklinesDataSeries)5 JSparklinesDataset (no.uib.jsparklines.data.JSparklinesDataset)5