Exemplo n.º 1
1
  /**
   * Returns a list of descriptions corresponding to every item matching the search.
   *
   * @return a list of descriptions
   * @throws SQLException thrown if an SQLException occurs
   * @throws ClassNotFoundException thrown if a ClassNotFoundException occurs
   * @throws IOException thrown if an IOException occurs
   * @throws InterruptedException thrown if an InterruptedException occurs
   */
  public ArrayList<String> getPossibilitiesDescriptions()
      throws SQLException, ClassNotFoundException, IOException, InterruptedException {

    Identification identification = peptideShakerGUI.getIdentification();

    // Some necessary pre-caching
    ArrayList<Type> typeList = types.get(jumpType);
    ArrayList<String> keys = possibilities.get(jumpType),
        proteinKeys = new ArrayList<String>(),
        peptideKeys = new ArrayList<String>();
    for (int i = 0; i < keys.size(); i++) {
      String key = keys.get(i);
      if (typeList.get(i) == Type.PROTEIN) {
        proteinKeys.add(key);
      } else if (typeList.get(i) == Type.PEPTIDE) {
        peptideKeys.add(key);
      }
    }
    if (!proteinKeys.isEmpty()) {
      identification.loadProteinMatches(proteinKeys, null, false);
    }
    if (!peptideKeys.isEmpty()) {
      identification.loadPeptideMatches(peptideKeys, null, false);
    }

    ArrayList<String> descriptions = new ArrayList<String>();
    for (int i = 0; i < keys.size(); i++) {
      String key = keys.get(i);
      Type type = typeList.get(i);
      String description = getItemDescription(key, type);
      descriptions.add(description);
    }
    return descriptions;
  }
Exemplo n.º 2
0
 /**
  * Returns the description of an item.
  *
  * @param key the key of the item
  * @param itemType the type of the item
  * @return the description of an item
  * @throws SQLException thrown if an SQLException occurs
  * @throws ClassNotFoundException thrown if a ClassNotFoundException occurs
  * @throws IOException thrown if an IOException occurs
  * @throws InterruptedException thrown if an InterruptedException occurs
  */
 private String getItemDescription(String key, Type itemType)
     throws IllegalArgumentException, SQLException, IOException, ClassNotFoundException,
         InterruptedException {
   Identification identification = peptideShakerGUI.getIdentification();
   switch (itemType) {
     case PROTEIN:
       ProteinMatch proteinMatch = identification.getProteinMatch(key);
       String mainMatch = proteinMatch.getMainMatch();
       String description = sequenceFactory.getHeader(mainMatch).getSimpleProteinDescription();
       String result = mainMatch;
       for (String accession : ProteinMatch.getAccessions(key)) {
         if (!accession.equals(mainMatch)) {
           if (!result.equals(mainMatch)) {
             result += ", ";
           }
           result += accession;
         }
       }
       result += " - " + description;
       return result;
     case PEPTIDE:
       PeptideMatch peptideMatch = identification.getPeptideMatch(key);
       return peptideShakerGUI
           .getDisplayFeaturesGenerator()
           .getTaggedPeptideSequence(peptideMatch, true, true, true);
     case SPECTRUM:
       return Spectrum.getSpectrumTitle(key) + " (" + Spectrum.getSpectrumFile(key) + ")";
     default:
       return "Unknown";
   }
 }
  /**
   * Update the protein table according to the protein inference selection.
   *
   * @param evt
   */
  private void okButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_okButtonActionPerformed

    PSParameter psParameter = new PSParameter();

    try {
      psParameter =
          (PSParameter)
              identification.getProteinMatchParameter(inspectedMatch.getKey(), psParameter);
    } catch (Exception e) {
      peptideShakerGUI.catchException(e);
      this.dispose();
      return;
    }
    if (!inspectedMatch.getMainMatch().equals(previousMainMatch)
        || groupClassJComboBox.getSelectedIndex() != psParameter.getGroupClass()) {
      try {
        psParameter.setGroupClass(groupClassJComboBox.getSelectedIndex());
        identification.updateProteinMatchParameter(inspectedMatch.getKey(), psParameter);
        peptideShakerGUI.updateMainMatch(
            inspectedMatch.getMainMatch(), groupClassJComboBox.getSelectedIndex());
      } catch (Exception e) {
        peptideShakerGUI.catchException(e);
      }
      peptideShakerGUI.setDataSaved(false);
    }
    this.dispose();
  } // GEN-LAST:event_okButtonActionPerformed
  /**
   * Sets the main match if the main match column is selected, or opens the protein web link if the
   * accession number column is selected.
   *
   * @param evt
   */
  private void proteinMatchTableMouseReleased(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_proteinMatchTableMouseReleased

    int row = proteinMatchTable.rowAtPoint(evt.getPoint());
    int column = proteinMatchTable.columnAtPoint(evt.getPoint());

    if (row != -1) {

      if (column == 1) {
        try {
          inspectedMatch.setMainMatch(accessions.get(row));
          identification.updateProteinMatch(inspectedMatch);
          peptideShakerGUI
              .getIdentificationFeaturesGenerator()
              .updateCoverableAA(inspectedMatch.getKey());
          peptideShakerGUI
              .getIdentificationFeaturesGenerator()
              .updateSequenceCoverage(inspectedMatch.getKey());
          peptideShakerGUI
              .getIdentificationFeaturesGenerator()
              .updateObservableCoverage(inspectedMatch.getKey());
        } catch (Exception e) {
          peptideShakerGUI.catchException(e);
        }
        proteinMatchTable.revalidate();
        proteinMatchTable.repaint();
      } else if (column == 2) {

        // open protein link in web browser
        if (evt.getButton() == MouseEvent.BUTTON1
            && ((String) proteinMatchTable.getValueAt(row, column)).lastIndexOf("<html>") != -1) {

          String link = (String) proteinMatchTable.getValueAt(row, column);
          link = link.substring(link.indexOf("\"") + 1);
          link = link.substring(0, link.indexOf("\""));

          this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
          BareBonesBrowserLaunch.openURL(link);
          this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        }
      }
    }
  } // GEN-LAST:event_proteinMatchTableMouseReleased
  /**
   * Open the protein html links.
   *
   * @param evt
   */
  private void relatedHitsTableMouseReleased(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_relatedHitsTableMouseReleased
    int row = relatedHitsTable.getSelectedRow();
    int column = relatedHitsTable.getSelectedColumn();

    if (row != -1) {

      if (column == 1) {

        // open protein links in web browser
        if (evt != null
            && evt.getButton() == MouseEvent.BUTTON1
            && ((String) relatedHitsTable.getValueAt(row, column)).lastIndexOf("a href=") != -1) {
          peptideShakerGUI.openProteinLinks((String) relatedHitsTable.getValueAt(row, column));
        }
      }
    }
  } // GEN-LAST:event_relatedHitsTableMouseReleased
Exemplo n.º 6
0
  /** Updates the item selection in the selected tab. */
  public void updateSelectionInTab() {

    indexLabel.setForeground(Color.BLACK);

    if (types.get(jumpType).get(currentSelection.get(jumpType)) == Type.PROTEIN) {
      peptideShakerGUI.setSelectedItems(
          possibilities.get(jumpType).get(currentSelection.get(jumpType)),
          PeptideShakerGUI.NO_SELECTION,
          PeptideShakerGUI.NO_SELECTION);
      peptideShakerGUI.updateSelectionInCurrentTab();
    } else if (types.get(jumpType).get(currentSelection.get(jumpType)) == Type.PEPTIDE) {
      peptideShakerGUI.setSelectedItems(
          PeptideShakerGUI.NO_SELECTION,
          possibilities.get(jumpType).get(currentSelection.get(jumpType)),
          PeptideShakerGUI.NO_SELECTION);
      if (peptideShakerGUI.getSelectedTab() == PeptideShakerGUI.MODIFICATIONS_TAB_INDEX
          && !peptideShakerGUI
              .getDisplayedPeptides()
              .contains(possibilities.get(jumpType).get(currentSelection.get(jumpType)))) {
        // warn the user that the current selection is not in the tab
        indexLabel.setForeground(Color.RED);
      } else {
        peptideShakerGUI.updateSelectionInCurrentTab();
      }
    } else {
      peptideShakerGUI.setSelectedItems(
          PeptideShakerGUI.NO_SELECTION,
          PeptideShakerGUI.NO_SELECTION,
          possibilities.get(jumpType).get(currentSelection.get(jumpType)));
      peptideShakerGUI.updateSelectionInCurrentTab();
    }
    String label =
        "("
            + (currentSelection.get(jumpType) + 1)
            + " of "
            + possibilities.get(jumpType).size()
            + ")";
    indexLabel.setText(label);
    lastLabel.put(jumpType, label);
  }
  /**
   * Creates new form ProteinInferenceDialog.
   *
   * @param peptideShakerGUI
   * @param inspectedMatch
   * @param identification
   */
  public ProteinInferenceDialog(
      PeptideShakerGUI peptideShakerGUI, String inspectedMatch, Identification identification) {
    super(peptideShakerGUI, true);
    this.identification = identification;
    this.peptideShakerGUI = peptideShakerGUI;

    try {
      this.inspectedMatch = identification.getProteinMatch(inspectedMatch);
      previousMainMatch = this.inspectedMatch.getMainMatch();
    } catch (Exception e) {
      peptideShakerGUI.catchException(e);
      this.dispose();
    }

    accessions = new ArrayList(Arrays.asList(ProteinMatch.getAccessions(inspectedMatch)));

    for (String proteinAccession : accessions) {
      if (identification.getProteinIdentification().contains(proteinAccession)) {
        uniqueMatches.add(proteinAccession);
      }
    }

    for (String proteinKey : identification.getProteinIdentification()) {
      if (ProteinMatch.getNProteins(proteinKey) > 1
          && !associatedMatches.contains(proteinKey)
          && !proteinKey.equals(inspectedMatch)) {
        for (String proteinAccession : accessions) {
          if (proteinKey.contains(proteinAccession)) {
            associatedMatches.add(proteinKey);
            break;
          }
        }
      }
    }

    initComponents();

    // make sure that the scroll panes are see-through
    proteinMatchJScrollPane.getViewport().setOpaque(false);
    uniqueHitsJScrollPane.getViewport().setOpaque(false);
    relatedHitsJScrollPane.getViewport().setOpaque(false);

    groupClassJComboBox.setRenderer(new AlignedListCellRenderer(SwingConstants.CENTER));

    PSParameter psParameter = new PSParameter();
    try {
      psParameter =
          (PSParameter) identification.getProteinMatchParameter(inspectedMatch, psParameter);
    } catch (Exception e) {
      peptideShakerGUI.catchException(e);
    }
    matchInfoLbl.setText(
        "[Score: "
            + Util.roundDouble(psParameter.getProteinScore(), 2)
            + ", Confidence: "
            + Util.roundDouble(psParameter.getProteinConfidence(), 2)
            + "]");

    // set up the table column properties
    setColumnProperies();

    // The index should be set in the design according to the PSParameter class static fields!
    groupClassJComboBox.setSelectedIndex(psParameter.getGroupClass());

    setLocationRelativeTo(peptideShakerGUI);
    setVisible(true);
  }
  /** Set the properties for the columns in the results tables. */
  private void setColumnProperies() {

    proteinMatchTable.getTableHeader().setReorderingAllowed(false);
    uniqueHitsTable.getTableHeader().setReorderingAllowed(false);
    relatedHitsTable.getTableHeader().setReorderingAllowed(false);

    proteinMatchTable.getColumn("  ").setMinWidth(30);
    proteinMatchTable.getColumn("  ").setMaxWidth(30);

    // set the preferred size of the accession column
    Integer width =
        peptideShakerGUI.getPreferredAccessionColumnWidth(
            proteinMatchTable, proteinMatchTable.getColumn("Accession").getModelIndex(), 2);
    if (width != null) {
      proteinMatchTable.getColumn("Accession").setMinWidth(width);
      proteinMatchTable.getColumn("Accession").setMaxWidth(width);
    } else {
      proteinMatchTable.getColumn("Accession").setMinWidth(15);
      proteinMatchTable.getColumn("Accession").setMaxWidth(Integer.MAX_VALUE);
    }

    // the validated column
    uniqueHitsTable.getColumn(" ").setMaxWidth(30);
    relatedHitsTable.getColumn(" ").setMaxWidth(30);
    uniqueHitsTable.getColumn(" ").setMinWidth(30);
    relatedHitsTable.getColumn(" ").setMinWidth(30);

    proteinMatchTable.getColumn("").setMaxWidth(30);
    uniqueHitsTable.getColumn("").setMaxWidth(30);
    relatedHitsTable.getColumn("").setMaxWidth(30);
    proteinMatchTable.getColumn("").setMinWidth(30);
    uniqueHitsTable.getColumn("").setMinWidth(30);
    relatedHitsTable.getColumn("").setMinWidth(30);

    // the score and confidence columns
    uniqueHitsTable.getColumn("Confidence").setMaxWidth(90);
    uniqueHitsTable.getColumn("Confidence").setMinWidth(90);
    uniqueHitsTable.getColumn("Score").setMaxWidth(90);
    uniqueHitsTable.getColumn("Score").setMinWidth(90);

    relatedHitsTable.getColumn("Confidence").setMaxWidth(90);
    relatedHitsTable.getColumn("Confidence").setMinWidth(90);
    relatedHitsTable.getColumn("Score").setMaxWidth(90);
    relatedHitsTable.getColumn("Score").setMinWidth(90);

    // change the cell renderer to fix a problem in Nimbus and alternating row colors
    proteinMatchTable.getColumn("  ").setCellRenderer(new NimbusCheckBoxRenderer());

    proteinMatchTable
        .getColumn("Accession")
        .setCellRenderer(
            new HtmlLinksRenderer(
                peptideShakerGUI.getSelectedRowHtmlTagFontColor(),
                peptideShakerGUI.getNotSelectedRowHtmlTagFontColor()));

    uniqueHitsTable
        .getColumn("Protein(s)")
        .setCellRenderer(
            new HtmlLinksRenderer(
                peptideShakerGUI.getSelectedRowHtmlTagFontColor(),
                peptideShakerGUI.getNotSelectedRowHtmlTagFontColor()));
    uniqueHitsTable
        .getColumn(" ")
        .setCellRenderer(
            new TrueFalseIconRenderer(
                new ImageIcon(this.getClass().getResource("/icons/accept.png")),
                new ImageIcon(this.getClass().getResource("/icons/Error_3.png")),
                "Validated",
                "Not Validated"));
    uniqueHitsTable
        .getColumn("Score")
        .setCellRenderer(
            new JSparklinesBarChartTableCellRenderer(
                PlotOrientation.HORIZONTAL, 100.0, peptideShakerGUI.getSparklineColor()));
    uniqueHitsTable
        .getColumn("Confidence")
        .setCellRenderer(
            new JSparklinesBarChartTableCellRenderer(
                PlotOrientation.HORIZONTAL, 100.0, peptideShakerGUI.getSparklineColor()));
    ((JSparklinesBarChartTableCellRenderer) uniqueHitsTable.getColumn("Score").getCellRenderer())
        .showNumberAndChart(true, peptideShakerGUI.getLabelWidth() + 5);
    ((JSparklinesBarChartTableCellRenderer)
            uniqueHitsTable.getColumn("Confidence").getCellRenderer())
        .showNumberAndChart(true, peptideShakerGUI.getLabelWidth() + 5);

    relatedHitsTable
        .getColumn("Protein(s)")
        .setCellRenderer(
            new HtmlLinksRenderer(
                peptideShakerGUI.getSelectedRowHtmlTagFontColor(),
                peptideShakerGUI.getNotSelectedRowHtmlTagFontColor()));
    relatedHitsTable
        .getColumn(" ")
        .setCellRenderer(
            new TrueFalseIconRenderer(
                new ImageIcon(this.getClass().getResource("/icons/accept.png")),
                new ImageIcon(this.getClass().getResource("/icons/Error_3.png")),
                "Validated",
                "Not Validated"));
    relatedHitsTable
        .getColumn("Score")
        .setCellRenderer(
            new JSparklinesBarChartTableCellRenderer(
                PlotOrientation.HORIZONTAL, 100.0, peptideShakerGUI.getSparklineColor()));
    relatedHitsTable
        .getColumn("Confidence")
        .setCellRenderer(
            new JSparklinesBarChartTableCellRenderer(
                PlotOrientation.HORIZONTAL, 100.0, peptideShakerGUI.getSparklineColor()));
    ((JSparklinesBarChartTableCellRenderer) relatedHitsTable.getColumn("Score").getCellRenderer())
        .showNumberAndChart(true, peptideShakerGUI.getLabelWidth() + 5);
    ((JSparklinesBarChartTableCellRenderer)
            relatedHitsTable.getColumn("Confidence").getCellRenderer())
        .showNumberAndChart(true, peptideShakerGUI.getLabelWidth() + 5);

    // set up the table header tooltips
    candidateProteinsTableToolTips = new ArrayList<String>();
    candidateProteinsTableToolTips.add(null);
    candidateProteinsTableToolTips.add("Currently Selected Protein Match");
    candidateProteinsTableToolTips.add("Protein Accession");
    candidateProteinsTableToolTips.add("Protein Description");

    uniqueHitsTableToolTips = new ArrayList<String>();
    uniqueHitsTableToolTips.add(null);
    uniqueHitsTableToolTips.add("Protein Accession(s)");
    uniqueHitsTableToolTips.add("Protein Score");
    uniqueHitsTableToolTips.add("Protein Confidence");
    uniqueHitsTableToolTips.add("Validated");

    relatedHitsTableToolTips = new ArrayList<String>();
    relatedHitsTableToolTips.add(null);
    relatedHitsTableToolTips.add("Protein Accession(s)");
    relatedHitsTableToolTips.add("Protein Score");
    relatedHitsTableToolTips.add("Protein Confidence");
    relatedHitsTableToolTips.add("Validated");
  }