Search in sources :

Example 1 with JSparklinesMultiIntervalChartTableCellRenderer

use of no.uib.jsparklines.renderers.JSparklinesMultiIntervalChartTableCellRenderer in project peptide-shaker by compomics.

the class ProteinStructurePanel method setPeptideTableProperties.

/**
 * Set up the properties of the peptide table.
 */
private void setPeptideTableProperties() {
    peptideTable.getColumn(" ").setMaxWidth(50);
    peptideTable.getColumn(" ").setMinWidth(50);
    peptideTable.getColumn("PDB").setMinWidth(50);
    peptideTable.getColumn("PDB").setMaxWidth(50);
    peptideTable.getColumn("Start").setMinWidth(50);
    // the validated column
    peptideTable.getColumn("").setMaxWidth(30);
    peptideTable.getColumn("").setMinWidth(30);
    // the selected columns
    peptideTable.getColumn("  ").setMaxWidth(30);
    peptideTable.getColumn("  ").setMinWidth(30);
    // the protein inference column
    peptideTable.getColumn("PI").setMaxWidth(37);
    peptideTable.getColumn("PI").setMinWidth(37);
    peptideTable.getTableHeader().setReorderingAllowed(false);
    // set up the peptide inference color map
    HashMap<Integer, Color> peptideInferenceColorMap = new HashMap<>();
    peptideInferenceColorMap.put(PSParameter.NOT_GROUP, peptideShakerGUI.getSparklineColor());
    peptideInferenceColorMap.put(PSParameter.RELATED, Color.YELLOW);
    peptideInferenceColorMap.put(PSParameter.RELATED_AND_UNRELATED, Color.ORANGE);
    peptideInferenceColorMap.put(PSParameter.UNRELATED, Color.RED);
    // set up the peptide inference tooltip map
    HashMap<Integer, String> peptideInferenceTooltipMap = new HashMap<>();
    peptideInferenceTooltipMap.put(PSParameter.NOT_GROUP, "Unique to a single protein");
    peptideInferenceTooltipMap.put(PSParameter.RELATED, "Belongs to a group of related proteins");
    peptideInferenceTooltipMap.put(PSParameter.RELATED_AND_UNRELATED, "Belongs to a group of related and unrelated proteins");
    peptideInferenceTooltipMap.put(PSParameter.UNRELATED, "Belongs to unrelated proteins");
    peptideTable.getColumn("PI").setCellRenderer(new JSparklinesIntegerColorTableCellRenderer(peptideShakerGUI.getSparklineColor(), peptideInferenceColorMap, peptideInferenceTooltipMap));
    peptideTable.getColumn("Start").setCellRenderer(new JSparklinesMultiIntervalChartTableCellRenderer(PlotOrientation.HORIZONTAL, 100d, 100d, peptideShakerGUI.getSparklineColor()));
    peptideTable.getColumn("PDB").setCellRenderer(new TrueFalseIconRenderer(new ImageIcon(this.getClass().getResource("/icons/pdb.png")), null, "Mapped to PDB Structure", null));
    peptideTable.getColumn("").setCellRenderer(new JSparklinesIntegerIconTableCellRenderer(MatchValidationLevel.getIconMap(this.getClass()), MatchValidationLevel.getTooltipMap()));
    peptideTable.getColumn("  ").setCellRenderer(new TrueFalseIconRenderer(new ImageIcon(this.getClass().getResource("/icons/star_yellow.png")), new ImageIcon(this.getClass().getResource("/icons/star_grey.png")), new ImageIcon(this.getClass().getResource("/icons/star_grey.png")), "Starred", null, null));
}
Also used : JSparklinesIntegerColorTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntegerColorTableCellRenderer) HashMap(java.util.HashMap) JSparklinesMultiIntervalChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesMultiIntervalChartTableCellRenderer) Color(java.awt.Color) JSparklinesIntegerIconTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntegerIconTableCellRenderer) TrueFalseIconRenderer(no.uib.jsparklines.extra.TrueFalseIconRenderer)

Example 2 with JSparklinesMultiIntervalChartTableCellRenderer

use of no.uib.jsparklines.renderers.JSparklinesMultiIntervalChartTableCellRenderer in project peptide-shaker by compomics.

the class ProteinStructurePanel method updatedPeptideSelection.

/**
 * Updates the peptide selection according to the currently selected
 * protein.
 *
 * @param proteinIndex the row index of the protein
 */
private void updatedPeptideSelection(int proteinIndex) {
    if (proteinIndex != -1) {
        this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
        DefaultTableModel dm = (DefaultTableModel) peptideTable.getModel();
        dm.getDataVector().removeAllElements();
        dm.fireTableDataChanged();
        long proteinMatchKey = proteinKeys[proteinIndex];
        ProteinMatch proteinMatch = peptideShakerGUI.getIdentification().getProteinMatch(proteinMatchKey);
        String proteinAccession = proteinMatch.getLeadingAccession();
        peptideTableMap = new HashMap<>();
        int index = 0;
        long[] peptideKeys = peptideShakerGUI.getIdentificationFeaturesGenerator().getSortedPeptideKeys(proteinMatchKey);
        for (long peptideKey : peptideKeys) {
            PeptideMatch peptideMatch = peptideShakerGUI.getIdentification().getPeptideMatch(peptideKey);
            PSParameter psParameter = (PSParameter) peptideMatch.getUrParam(PSParameter.dummy);
            if (!psParameter.getHidden()) {
                // find and add the peptide start and end indexes
                StartIndexes startIndexes = new StartIndexes(Arrays.stream(peptideMatch.getPeptide().getProteinMapping().get(proteinAccession)).map(site -> site + 1).boxed().collect(Collectors.toCollection(ArrayList::new)));
                int proteinInferenceType = psParameter.getProteinInferenceGroupClass();
                // @TODO: should be replaced by a table model!!!
                ((DefaultTableModel) peptideTable.getModel()).addRow(new Object[] { index + 1, psParameter.getStarred(), proteinInferenceType, peptideShakerGUI.getDisplayFeaturesGenerator().getTaggedPeptideSequence(peptideMatch, true, true, true), startIndexes, false, psParameter.getMatchValidationLevel().getIndex() });
                peptideTableMap.put(index + 1, peptideKey);
                index++;
            }
        }
        ((DefaultTableModel) peptideTable.getModel()).fireTableDataChanged();
        String title = PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING + "Peptides (";
        IdentificationFeaturesGenerator identificationFeaturesGenerator = peptideShakerGUI.getIdentificationFeaturesGenerator();
        int nValidatedPeptides = identificationFeaturesGenerator.getNValidatedPeptides(proteinMatchKey);
        int nConfidentPeptides = identificationFeaturesGenerator.getNConfidentPeptides(proteinMatchKey);
        int nPeptides = proteinMatch.getPeptideCount();
        if (nConfidentPeptides > 0) {
            title += nValidatedPeptides + "/" + nPeptides + " - " + nConfidentPeptides + " confident, " + (nValidatedPeptides - nConfidentPeptides) + " doubtful";
        } else {
            title += nValidatedPeptides + "/" + nPeptides;
        }
        title += ")" + PeptideShakerGUI.TITLED_BORDER_HORIZONTAL_PADDING;
        ((TitledBorder) peptidesPanel.getBorder()).setTitle(title);
        peptidesPanel.repaint();
        String proteinSequence = peptideShakerGUI.getSequenceProvider().getSequence(proteinAccession);
        peptideTable.getColumn("Start").setCellRenderer(new JSparklinesMultiIntervalChartTableCellRenderer(PlotOrientation.HORIZONTAL, (double) proteinSequence.length(), ((double) proteinSequence.length()) / 50, peptideShakerGUI.getSparklineColor()));
        ((JSparklinesMultiIntervalChartTableCellRenderer) peptideTable.getColumn("Start").getCellRenderer()).showReferenceLine(true, 0.02, Color.BLACK);
        ((JSparklinesMultiIntervalChartTableCellRenderer) peptideTable.getColumn("Start").getCellRenderer()).showNumberAndChart(true, TableProperties.getLabelWidth() - 10);
        // select the peptide in the table
        if (peptideTable.getRowCount() > 0) {
            int peptideRow = 0;
            long peptideKey = peptideShakerGUI.getSelectedPeptideKey();
            if (peptideKey != NO_KEY) {
                peptideRow = getPeptideRow(peptideKey);
            }
            if (peptideRow != -1) {
                peptideTable.setRowSelectionInterval(peptideRow, peptideRow);
                peptideTable.scrollRectToVisible(peptideTable.getCellRect(peptideRow, 0, false));
                peptideTableKeyReleased(null);
            }
        }
        this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    }
}
Also used : Color(java.awt.Color) PsPeptideFeature(com.compomics.util.io.export.features.peptideshaker.PsPeptideFeature) PsProteinFeature(com.compomics.util.io.export.features.peptideshaker.PsProteinFeature) Arrays(java.util.Arrays) JSparklinesArrayListBarChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesArrayListBarChartTableCellRenderer) NO_KEY(com.compomics.util.experiment.personalization.ExperimentObject.NO_KEY) IdentificationFeaturesGenerator(com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator) FileAndFileFilter(com.compomics.util.gui.file_handling.FileAndFileFilter) BareBonesBrowserLaunch(com.compomics.util.examples.BareBonesBrowserLaunch) JSparklinesBarChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesBarChartTableCellRenderer) FileChooserUtil(com.compomics.util.gui.file_handling.FileChooserUtil) JTableHeader(javax.swing.table.JTableHeader) ProteinInferencePeptideLevelDialog(eu.isas.peptideshaker.gui.protein_inference.ProteinInferencePeptideLevelDialog) PeptideShakerGUI(eu.isas.peptideshaker.gui.PeptideShakerGUI) MouseAdapter(java.awt.event.MouseAdapter) TitledBorder(javax.swing.border.TitledBorder) JSparklinesIntegerIconTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntegerIconTableCellRenderer) TableProperties(com.compomics.util.gui.TableProperties) SpectrumCountingMethod(com.compomics.util.experiment.quantification.spectrumcounting.SpectrumCountingMethod) ModificationParameters(com.compomics.util.parameters.identification.search.ModificationParameters) TableModelEvent(javax.swing.event.TableModelEvent) ExportScheme(com.compomics.util.io.export.ExportScheme) DefaultTableModel(javax.swing.table.DefaultTableModel) TrueFalseIconRenderer(no.uib.jsparklines.extra.TrueFalseIconRenderer) SequenceMatchingParameters(com.compomics.util.parameters.identification.advanced.SequenceMatchingParameters) PSExportFactory(eu.isas.peptideshaker.export.PSExportFactory) SelfUpdatingTableModel(com.compomics.util.gui.tablemodels.SelfUpdatingTableModel) Util(com.compomics.util.Util) KeyEvent(java.awt.event.KeyEvent) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) GuiUtilities(com.compomics.util.gui.GuiUtilities) DisplayParameters(eu.isas.peptideshaker.preferences.DisplayParameters) IdentificationParameters(com.compomics.util.parameters.identification.IdentificationParameters) Dimension(java.awt.Dimension) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter) SimpleFileWriter(com.compomics.util.io.flat.SimpleFileWriter) Graphics(java.awt.Graphics) Toolkit(java.awt.Toolkit) IntStream(java.util.stream.IntStream) Rectangle(java.awt.Rectangle) FindPdbForUniprotAccessions(com.compomics.util.pdbfinder.FindPdbForUniprotAccessions) HelpDialog(com.compomics.util.gui.error_handlers.HelpDialog) PdbParameter(com.compomics.util.pdbfinder.pdb.PdbParameter) HashMap(java.util.HashMap) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) PlotOrientation(org.jfree.chart.plot.PlotOrientation) TableModelListener(javax.swing.event.TableModelListener) SpectrumMatch(com.compomics.util.experiment.identification.matches.SpectrumMatch) ArrayList(java.util.ArrayList) JSparklinesIntervalChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntervalChartTableCellRenderer) JSparklinesMultiIntervalChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesMultiIntervalChartTableCellRenderer) JSparklinesIntegerColorTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesIntegerColorTableCellRenderer) XYPlottingDialog(com.compomics.util.gui.XYPlottingDialog) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) ProteinTableModel(eu.isas.peptideshaker.gui.tablemodels.ProteinTableModel) JmolAdapter(org.jmol.api.JmolAdapter) XYDataPoint(no.uib.jsparklines.data.XYDataPoint) ProteinInferenceDialog(eu.isas.peptideshaker.gui.protein_inference.ProteinInferenceDialog) MatchValidationLevel(com.compomics.util.experiment.identification.validation.MatchValidationLevel) BufferedWriter(java.io.BufferedWriter) FileWriter(java.io.FileWriter) SequenceProvider(com.compomics.util.experiment.io.biology.protein.SequenceProvider) ExportFeature(com.compomics.util.io.export.ExportFeature) Identification(com.compomics.util.experiment.identification.Identification) IOException(java.io.IOException) JmolViewer(org.jmol.api.JmolViewer) Peptide(com.compomics.util.experiment.biology.proteins.Peptide) ExportGraphicsDialog(com.compomics.util.gui.export.graphics.ExportGraphicsDialog) PdbBlock(com.compomics.util.pdbfinder.pdb.PdbBlock) MouseEvent(java.awt.event.MouseEvent) File(java.io.File) ExportFormat(com.compomics.util.io.export.ExportFormat) HtmlLinksRenderer(no.uib.jsparklines.extra.HtmlLinksRenderer) SmarterJmolAdapter(org.jmol.adapter.smarter.SmarterJmolAdapter) GeneDetailsDialog(com.compomics.util.gui.genes.GeneDetailsDialog) StartIndexes(no.uib.jsparklines.data.StartIndexes) ProgressDialogX(com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX) javax.swing(javax.swing) IdentificationFeaturesGenerator(com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator) StartIndexes(no.uib.jsparklines.data.StartIndexes) PeptideMatch(com.compomics.util.experiment.identification.matches.PeptideMatch) DefaultTableModel(javax.swing.table.DefaultTableModel) ArrayList(java.util.ArrayList) TitledBorder(javax.swing.border.TitledBorder) XYDataPoint(no.uib.jsparklines.data.XYDataPoint) JSparklinesMultiIntervalChartTableCellRenderer(no.uib.jsparklines.renderers.JSparklinesMultiIntervalChartTableCellRenderer) ProteinMatch(com.compomics.util.experiment.identification.matches.ProteinMatch) PSParameter(com.compomics.util.experiment.identification.peptide_shaker.PSParameter)

Aggregations

Util (com.compomics.util.Util)1 BareBonesBrowserLaunch (com.compomics.util.examples.BareBonesBrowserLaunch)1 Peptide (com.compomics.util.experiment.biology.proteins.Peptide)1 Identification (com.compomics.util.experiment.identification.Identification)1 IdentificationFeaturesGenerator (com.compomics.util.experiment.identification.features.IdentificationFeaturesGenerator)1 PeptideMatch (com.compomics.util.experiment.identification.matches.PeptideMatch)1 ProteinMatch (com.compomics.util.experiment.identification.matches.ProteinMatch)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 SequenceProvider (com.compomics.util.experiment.io.biology.protein.SequenceProvider)1 NO_KEY (com.compomics.util.experiment.personalization.ExperimentObject.NO_KEY)1 SpectrumCountingMethod (com.compomics.util.experiment.quantification.spectrumcounting.SpectrumCountingMethod)1 GuiUtilities (com.compomics.util.gui.GuiUtilities)1 TableProperties (com.compomics.util.gui.TableProperties)1 XYPlottingDialog (com.compomics.util.gui.XYPlottingDialog)1 HelpDialog (com.compomics.util.gui.error_handlers.HelpDialog)1 ExportGraphicsDialog (com.compomics.util.gui.export.graphics.ExportGraphicsDialog)1 FileAndFileFilter (com.compomics.util.gui.file_handling.FileAndFileFilter)1 FileChooserUtil (com.compomics.util.gui.file_handling.FileChooserUtil)1