コード例 #1
0
  public void clearData(boolean clearDatabaseFolder) {
    projectDetails = null;
    spectrumAnnotator = new SpectrumAnnotator();
    try {
      spectrumFactory.closeFiles();
    } catch (Exception e) {
      e.printStackTrace();
    }
    try {
      sequenceFactory.closeFile();
    } catch (Exception e) {
      e.printStackTrace();
    }
    try {
      GOFactory.getInstance().closeFiles();
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      spectrumFactory.clearFactory();
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      sequenceFactory.clearFactory();
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      GOFactory.getInstance().clearFactory();
    } catch (Exception e) {
      e.printStackTrace();
    }

    identifiedModifications = null;

    if (clearDatabaseFolder) {
      clearDatabaseFolder();
    }

    resetFeatureGenerator();

    // set up the tabs/panels

    currentPSFile = null;
  }
コード例 #2
0
/**
 * This dialog allows the user to resolve manually some protein inference issues.
 *
 * @author Marc Vaudel
 * @author Harald Barsnes
 */
public class ProteinInferenceDialog extends javax.swing.JDialog {

  /** The inspected protein match. */
  private ProteinMatch inspectedMatch;
  /** The protein accessions. */
  private ArrayList<String> accessions;
  /** The detected unique matches (if any). */
  private ArrayList<String> uniqueMatches = new ArrayList<String>();
  /** Associated matches presenting the same proteins or a share. */
  private ArrayList<String> associatedMatches = new ArrayList<String>();
  /** The sequence factory. */
  private SequenceFactory sequenceFactory = SequenceFactory.getInstance();
  /** The PeptideShaker parent frame. */
  private PeptideShakerGUI peptideShakerGUI;
  /** The candidate protein table column header tooltips. */
  private ArrayList<String> candidateProteinsTableToolTips;
  /** The unique hits table column header tooltips. */
  private ArrayList<String> uniqueHitsTableToolTips;
  /** The related hits table column header tooltips. */
  private ArrayList<String> relatedHitsTableToolTips;
  /** The identification. */
  private Identification identification;
  /** The selected main match. */
  private String previousMainMatch;

  /**
   * 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");
  }

  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    backgroundPanel = new javax.swing.JPanel();
    okButton = new javax.swing.JButton();
    relatedHitsJPanel = new javax.swing.JPanel();
    relatedHitsJScrollPane = new javax.swing.JScrollPane();
    relatedHitsTable =
        new JTable() {
          protected JTableHeader createDefaultTableHeader() {
            return new JTableHeader(columnModel) {
              public String getToolTipText(MouseEvent e) {
                java.awt.Point p = e.getPoint();
                int index = columnModel.getColumnIndexAtX(p.x);
                int realIndex = columnModel.getColumn(index).getModelIndex();
                String tip = (String) relatedHitsTableToolTips.get(realIndex);
                return tip;
              }
            };
          }
        };
    uniqueHitsJPanel = new javax.swing.JPanel();
    uniqueHitsJScrollPane = new javax.swing.JScrollPane();
    uniqueHitsTable =
        new JTable() {
          protected JTableHeader createDefaultTableHeader() {
            return new JTableHeader(columnModel) {
              public String getToolTipText(MouseEvent e) {
                java.awt.Point p = e.getPoint();
                int index = columnModel.getColumnIndexAtX(p.x);
                int realIndex = columnModel.getColumn(index).getModelIndex();
                String tip = (String) uniqueHitsTableToolTips.get(realIndex);
                return tip;
              }
            };
          }
        };
    proteinMatchJPanel = new javax.swing.JPanel();
    proteinMatchJScrollPane = new javax.swing.JScrollPane();
    proteinMatchTable =
        new JTable() {
          protected JTableHeader createDefaultTableHeader() {
            return new JTableHeader(columnModel) {
              public String getToolTipText(MouseEvent e) {
                java.awt.Point p = e.getPoint();
                int index = columnModel.getColumnIndexAtX(p.x);
                int realIndex = columnModel.getColumn(index).getModelIndex();
                String tip = (String) candidateProteinsTableToolTips.get(realIndex);
                return tip;
              }
            };
          }
        };
    groupDetalsJPanel = new javax.swing.JPanel();
    matchInfoLbl = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    groupClassJComboBox = new javax.swing.JComboBox();
    helpJButton = new javax.swing.JButton();
    cancelButton = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("Protein Inference - Protein Level");
    setResizable(false);

    backgroundPanel.setBackground(new java.awt.Color(230, 230, 230));

    okButton.setText("OK");
    okButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            okButtonActionPerformed(evt);
          }
        });

    relatedHitsJPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Related Hits"));
    relatedHitsJPanel.setOpaque(false);

    relatedHitsTable.setModel(new AssociatedMatches());
    relatedHitsTable.setOpaque(false);
    relatedHitsTable.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseExited(java.awt.event.MouseEvent evt) {
            relatedHitsTableMouseExited(evt);
          }

          public void mouseReleased(java.awt.event.MouseEvent evt) {
            relatedHitsTableMouseReleased(evt);
          }
        });
    relatedHitsTable.addMouseMotionListener(
        new java.awt.event.MouseMotionAdapter() {
          public void mouseMoved(java.awt.event.MouseEvent evt) {
            relatedHitsTableMouseMoved(evt);
          }
        });
    relatedHitsJScrollPane.setViewportView(relatedHitsTable);

    javax.swing.GroupLayout relatedHitsJPanelLayout =
        new javax.swing.GroupLayout(relatedHitsJPanel);
    relatedHitsJPanel.setLayout(relatedHitsJPanelLayout);
    relatedHitsJPanelLayout.setHorizontalGroup(
        relatedHitsJPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                relatedHitsJPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        relatedHitsJScrollPane,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        723,
                        Short.MAX_VALUE)
                    .addContainerGap()));
    relatedHitsJPanelLayout.setVerticalGroup(
        relatedHitsJPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                relatedHitsJPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        relatedHitsJScrollPane,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        73,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    uniqueHitsJPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Unique Hits"));
    uniqueHitsJPanel.setOpaque(false);

    uniqueHitsTable.setModel(new UniqueMatches());
    uniqueHitsTable.setOpaque(false);
    uniqueHitsTable.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseExited(java.awt.event.MouseEvent evt) {
            uniqueHitsTableMouseExited(evt);
          }

          public void mouseReleased(java.awt.event.MouseEvent evt) {
            uniqueHitsTableMouseReleased(evt);
          }
        });
    uniqueHitsTable.addMouseMotionListener(
        new java.awt.event.MouseMotionAdapter() {
          public void mouseMoved(java.awt.event.MouseEvent evt) {
            uniqueHitsTableMouseMoved(evt);
          }
        });
    uniqueHitsJScrollPane.setViewportView(uniqueHitsTable);

    javax.swing.GroupLayout uniqueHitsJPanelLayout = new javax.swing.GroupLayout(uniqueHitsJPanel);
    uniqueHitsJPanel.setLayout(uniqueHitsJPanelLayout);
    uniqueHitsJPanelLayout.setHorizontalGroup(
        uniqueHitsJPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                uniqueHitsJPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        uniqueHitsJScrollPane,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        723,
                        Short.MAX_VALUE)
                    .addContainerGap()));
    uniqueHitsJPanelLayout.setVerticalGroup(
        uniqueHitsJPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                uniqueHitsJPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        uniqueHitsJScrollPane,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        70,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(14, Short.MAX_VALUE)));

    proteinMatchJPanel.setBorder(
        javax.swing.BorderFactory.createTitledBorder("Candidate Proteins"));
    proteinMatchJPanel.setOpaque(false);

    proteinMatchTable.setModel(new MatchTable());
    proteinMatchTable.setOpaque(false);
    proteinMatchTable.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseExited(java.awt.event.MouseEvent evt) {
            proteinMatchTableMouseExited(evt);
          }

          public void mouseReleased(java.awt.event.MouseEvent evt) {
            proteinMatchTableMouseReleased(evt);
          }
        });
    proteinMatchTable.addMouseMotionListener(
        new java.awt.event.MouseMotionAdapter() {
          public void mouseMoved(java.awt.event.MouseEvent evt) {
            proteinMatchTableMouseMoved(evt);
          }
        });
    proteinMatchJScrollPane.setViewportView(proteinMatchTable);

    javax.swing.GroupLayout proteinMatchJPanelLayout =
        new javax.swing.GroupLayout(proteinMatchJPanel);
    proteinMatchJPanel.setLayout(proteinMatchJPanelLayout);
    proteinMatchJPanelLayout.setHorizontalGroup(
        proteinMatchJPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                proteinMatchJPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        proteinMatchJScrollPane,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        723,
                        Short.MAX_VALUE)
                    .addContainerGap()));
    proteinMatchJPanelLayout.setVerticalGroup(
        proteinMatchJPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                proteinMatchJPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        proteinMatchJScrollPane,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        141,
                        Short.MAX_VALUE)
                    .addContainerGap()));

    groupDetalsJPanel.setBorder(
        javax.swing.BorderFactory.createTitledBorder("Protein Group Details"));
    groupDetalsJPanel.setOpaque(false);

    matchInfoLbl.setText("protein match information");

    jLabel2.setText("Type:");

    groupClassJComboBox.setModel(
        new javax.swing.DefaultComboBoxModel(
            new String[] {
              "Single Protein", "Isoforms", "Unrelated Isoforms", "Unrelated Proteins"
            }));

    javax.swing.GroupLayout groupDetalsJPanelLayout =
        new javax.swing.GroupLayout(groupDetalsJPanel);
    groupDetalsJPanel.setLayout(groupDetalsJPanelLayout);
    groupDetalsJPanelLayout.setHorizontalGroup(
        groupDetalsJPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                groupDetalsJPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel2)
                    .addGap(20, 20, 20)
                    .addComponent(
                        groupClassJComboBox,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        295,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(matchInfoLbl)
                    .addContainerGap(249, Short.MAX_VALUE)));
    groupDetalsJPanelLayout.setVerticalGroup(
        groupDetalsJPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                groupDetalsJPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        groupDetalsJPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(
                                groupClassJComboBox,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(matchInfoLbl))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    helpJButton.setIcon(
        new javax.swing.ImageIcon(getClass().getResource("/icons/help.GIF"))); // NOI18N
    helpJButton.setToolTipText("Help");
    helpJButton.setBorder(null);
    helpJButton.setBorderPainted(false);
    helpJButton.setContentAreaFilled(false);
    helpJButton.setFocusable(false);
    helpJButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    helpJButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    helpJButton.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseEntered(java.awt.event.MouseEvent evt) {
            helpJButtonMouseEntered(evt);
          }

          public void mouseExited(java.awt.event.MouseEvent evt) {
            helpJButtonMouseExited(evt);
          }
        });
    helpJButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            helpJButtonActionPerformed(evt);
          }
        });

    cancelButton.setText("Cancel");
    cancelButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            cancelButtonActionPerformed(evt);
          }
        });

    javax.swing.GroupLayout backgroundPanelLayout = new javax.swing.GroupLayout(backgroundPanel);
    backgroundPanel.setLayout(backgroundPanelLayout);
    backgroundPanelLayout.setHorizontalGroup(
        backgroundPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                backgroundPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        backgroundPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(
                                uniqueHitsJPanel,
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                groupDetalsJPanel,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                proteinMatchJPanel,
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                relatedHitsJPanel,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addGroup(
                                backgroundPanelLayout
                                    .createSequentialGroup()
                                    .addGap(10, 10, 10)
                                    .addComponent(helpJButton)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                        586,
                                        Short.MAX_VALUE)
                                    .addComponent(
                                        okButton,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        71,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(cancelButton)))
                    .addContainerGap()));
    backgroundPanelLayout.setVerticalGroup(
        backgroundPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                backgroundPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        groupDetalsJPanel,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        proteinMatchJPanel,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        uniqueHitsJPanel,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        relatedHitsJPanel,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(8, 8, 8)
                    .addGroup(
                        backgroundPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(helpJButton)
                            .addComponent(okButton)
                            .addComponent(cancelButton))
                    .addContainerGap()));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                backgroundPanel,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                Short.MAX_VALUE));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                backgroundPanel,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                Short.MAX_VALUE));

    pack();
  } // </editor-fold>//GEN-END:initComponents

  /**
   * 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

  /**
   * Change the cursor to a hand cursor.
   *
   * @param evt
   */
  private void helpJButtonMouseEntered(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_helpJButtonMouseEntered
    setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
  } // GEN-LAST:event_helpJButtonMouseEntered

  /**
   * Change the cursor back to the default cursor.
   *
   * @param evt
   */
  private void helpJButtonMouseExited(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_helpJButtonMouseExited
    setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
  } // GEN-LAST:event_helpJButtonMouseExited

  /**
   * Open the help dialog.
   *
   * @param evt
   */
  private void helpJButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_helpJButtonActionPerformed
    setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
    new HelpDialog(peptideShakerGUI, getClass().getResource("/helpFiles/ProteinInference.html"));
    setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
  } // GEN-LAST:event_helpJButtonActionPerformed

  /**
   * Changes the cursor into a hand cursor if the table cell contains an HTML link.
   *
   * @param evt
   */
  private void proteinMatchTableMouseMoved(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_proteinMatchTableMouseMoved
    int row = proteinMatchTable.rowAtPoint(evt.getPoint());
    int column = proteinMatchTable.columnAtPoint(evt.getPoint());

    proteinMatchTable.setToolTipText(null);

    if (column == 2 && proteinMatchTable.getValueAt(row, column) != null) {

      String tempValue = (String) proteinMatchTable.getValueAt(row, column);

      if (tempValue.lastIndexOf("<html>") != -1) {
        this.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
      } else {
        this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
      }
    } else if (column == proteinMatchTable.getColumn("Description").getModelIndex()
        && proteinMatchTable.getValueAt(row, column) != null) {
      if (GuiUtilities.getPreferredWidthOfCell(proteinMatchTable, row, column)
          > proteinMatchTable.getColumn("Description").getWidth()) {
        proteinMatchTable.setToolTipText("" + proteinMatchTable.getValueAt(row, column));
      }
      this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    } else {
      this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    }
  } // GEN-LAST:event_proteinMatchTableMouseMoved

  /**
   * Changes the cursor back to the default cursor a hand.
   *
   * @param evt
   */
  private void proteinMatchTableMouseExited(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_proteinMatchTableMouseExited
    this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
  } // GEN-LAST:event_proteinMatchTableMouseExited

  /**
   * Changes the cursor back to the default cursor.
   *
   * @param evt
   */
  private void uniqueHitsTableMouseExited(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_uniqueHitsTableMouseExited
    this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
  } // GEN-LAST:event_uniqueHitsTableMouseExited

  /**
   * Changes the cursor into a hand cursor if the table cell contains an HTML link.
   *
   * @param evt
   */
  private void uniqueHitsTableMouseMoved(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_uniqueHitsTableMouseMoved
    int row = uniqueHitsTable.rowAtPoint(evt.getPoint());
    int column = uniqueHitsTable.columnAtPoint(evt.getPoint());

    if (column == 1 && uniqueHitsTable.getValueAt(row, column) != null) {

      String tempValue = (String) uniqueHitsTable.getValueAt(row, column);

      if (tempValue.lastIndexOf("a href=") != -1) {
        this.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
      } else {
        this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
      }
    } else {
      this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    }
  } // GEN-LAST:event_uniqueHitsTableMouseMoved

  /**
   * Open the protein html links.
   *
   * @param evt
   */
  private void uniqueHitsTableMouseReleased(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_uniqueHitsTableMouseReleased
    int row = uniqueHitsTable.getSelectedRow();
    int column = uniqueHitsTable.getSelectedColumn();

    if (row != -1) {

      if (column == 1) {

        // open protein links in web browser
        if (evt != null
            && evt.getButton() == MouseEvent.BUTTON1
            && ((String) uniqueHitsTable.getValueAt(row, column)).lastIndexOf("a href=") != -1) {
          peptideShakerGUI.openProteinLinks((String) uniqueHitsTable.getValueAt(row, column));
        }
      }
    }
  } // GEN-LAST:event_uniqueHitsTableMouseReleased

  /**
   * Changes the cursor back to the default cursor.
   *
   * @param evt
   */
  private void relatedHitsTableMouseExited(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_relatedHitsTableMouseExited
    this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
  } // GEN-LAST:event_relatedHitsTableMouseExited

  /**
   * Changes the cursor into a hand cursor if the table cell contains an HTML link.
   *
   * @param evt
   */
  private void relatedHitsTableMouseMoved(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_relatedHitsTableMouseMoved
    int row = relatedHitsTable.rowAtPoint(evt.getPoint());
    int column = relatedHitsTable.columnAtPoint(evt.getPoint());

    if (column == 1 && relatedHitsTable.getValueAt(row, column) != null) {

      String tempValue = (String) relatedHitsTable.getValueAt(row, column);

      if (tempValue.lastIndexOf("a href=") != -1) {
        this.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
      } else {
        this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
      }
    } else {
      this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    }
  } // GEN-LAST:event_relatedHitsTableMouseMoved

  /**
   * 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

  /**
   * Closes the dialog.
   *
   * @param evt
   */
  private void cancelButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_cancelButtonActionPerformed
    this.setVisible(false);
    this.dispose();
  } // GEN-LAST:event_cancelButtonActionPerformed
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JPanel backgroundPanel;
  private javax.swing.JButton cancelButton;
  private javax.swing.JComboBox groupClassJComboBox;
  private javax.swing.JPanel groupDetalsJPanel;
  private javax.swing.JButton helpJButton;
  private javax.swing.JLabel jLabel2;
  private javax.swing.JLabel matchInfoLbl;
  private javax.swing.JButton okButton;
  private javax.swing.JPanel proteinMatchJPanel;
  private javax.swing.JScrollPane proteinMatchJScrollPane;
  private javax.swing.JTable proteinMatchTable;
  private javax.swing.JPanel relatedHitsJPanel;
  private javax.swing.JScrollPane relatedHitsJScrollPane;
  private javax.swing.JTable relatedHitsTable;
  private javax.swing.JPanel uniqueHitsJPanel;
  private javax.swing.JScrollPane uniqueHitsJScrollPane;
  private javax.swing.JTable uniqueHitsTable;
  // End of variables declaration//GEN-END:variables

  /** Table model for the protein match table. */
  private class MatchTable extends DefaultTableModel {

    @Override
    public int getRowCount() {
      return accessions.size();
    }

    @Override
    public int getColumnCount() {
      return 4;
    }

    @Override
    public String getColumnName(int column) {

      switch (column) {
        case 0:
          return "";
        case 1:
          return "  ";
        case 2:
          return "Accession";
        case 3:
          return "Description";
        default:
          return " ";
      }
    }

    @Override
    public Object getValueAt(int row, int column) {

      switch (column) {
        case 0:
          return (row + 1);
        case 1:
          return inspectedMatch.getMainMatch().equals(accessions.get(row));
        case 2:
          return peptideShakerGUI
              .getIdentificationFeaturesGenerator()
              .addDatabaseLink(accessions.get(row));
        case 3:
          try {
            return sequenceFactory.getHeader(accessions.get(row)).getDescription();
          } catch (Exception e) {
            peptideShakerGUI.catchException(e);
            return "Database Error";
          }
        default:
          return " ";
      }
    }

    @Override
    public Class getColumnClass(int columnIndex) {
      return getValueAt(0, columnIndex).getClass();
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
      return columnIndex == 1;
    }
  }

  /** Table model for the unique matches table. */
  private class UniqueMatches extends DefaultTableModel {

    @Override
    public int getRowCount() {
      return uniqueMatches.size();
    }

    @Override
    public int getColumnCount() {
      return 5;
    }

    @Override
    public String getColumnName(int column) {

      switch (column) {
        case 0:
          return "";
        case 1:
          return "Protein(s)";
        case 2:
          return "Score";
        case 3:
          return "Confidence";
        case 4:
          return " ";
        default:
          return "";
      }
    }

    @Override
    public Object getValueAt(int row, int column) {

      PSParameter pSParameter = new PSParameter();
      try {
        pSParameter =
            (PSParameter)
                identification.getProteinMatchParameter(uniqueMatches.get(row), pSParameter);
      } catch (Exception e) {
        peptideShakerGUI.catchException(e);
      }

      switch (column) {
        case 0:
          return (row + 1);
        case 1:
          return peptideShakerGUI
              .getIdentificationFeaturesGenerator()
              .addDatabaseLinks(
                  new ArrayList<String>(
                      Arrays.asList(ProteinMatch.getAccessions(uniqueMatches.get(row)))));
        case 2:
          return pSParameter.getProteinScore();
        case 3:
          return pSParameter.getProteinConfidence();
        case 4:
          return pSParameter.isValidated();
        default:
          return "";
      }
    }

    @Override
    public Class getColumnClass(int columnIndex) {
      return getValueAt(0, columnIndex).getClass();
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
      return false;
    }
  }

  /** Table model for the associated matches table. */
  private class AssociatedMatches extends DefaultTableModel {

    @Override
    public int getRowCount() {
      return associatedMatches.size();
    }

    @Override
    public int getColumnCount() {
      return 5;
    }

    @Override
    public String getColumnName(int column) {

      switch (column) {
        case 0:
          return "";
        case 1:
          return "Protein(s)";
        case 2:
          return "Score";
        case 3:
          return "Confidence";
        case 4:
          return " ";
        default:
          return "";
      }
    }

    @Override
    public Object getValueAt(int row, int column) {

      PSParameter pSParameter = new PSParameter();
      try {
        pSParameter =
            (PSParameter)
                identification.getProteinMatchParameter(associatedMatches.get(row), pSParameter);
      } catch (Exception e) {
        peptideShakerGUI.catchException(e);
      }
      switch (column) {
        case 0:
          return (row + 1);
        case 1:
          return peptideShakerGUI
              .getIdentificationFeaturesGenerator()
              .addDatabaseLinks(
                  new ArrayList<String>(
                      Arrays.asList(ProteinMatch.getAccessions(associatedMatches.get(row)))));
        case 2:
          return pSParameter.getProteinScore();
        case 3:
          return pSParameter.getProteinConfidence();
        case 4:
          return pSParameter.isValidated();
        default:
          return "";
      }
    }

    @Override
    public Class getColumnClass(int columnIndex) {
      return getValueAt(0, columnIndex).getClass();
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
      return false;
    }
  }
}
コード例 #3
0
public class PSFileImporter {

  private File currentPSFile;
  private EnzymeFactory enzymeFactory = EnzymeFactory.getInstance();
  private String resource;
  /** The spectrum annotator. */
  private SpectrumAnnotator spectrumAnnotator = new SpectrumAnnotator();
  /** The project details. */
  private ProjectDetails projectDetails = null;
  /** The spectrum factory. */
  private SpectrumFactory spectrumFactory = SpectrumFactory.getInstance(100);
  /** The identification to display. */
  private Identification identification;
  /** The compomics PTM factory. */
  private PTMFactory ptmFactory = PTMFactory.getInstance();
  /** The parameters of the search. */
  private SearchParameters searchParameters = new SearchParameters();
  /** The initial processing preferences */
  private ProcessingPreferences processingPreferences = new ProcessingPreferences();
  /** The annotation preferences. */
  private AnnotationPreferences annotationPreferences = new AnnotationPreferences();
  /** The spectrum counting preferences. */
  private SpectrumCountingPreferences spectrumCountingPreferences =
      new SpectrumCountingPreferences();
  /** The PTM scoring preferences */
  private PTMScoringPreferences ptmScoringPreferences = new PTMScoringPreferences();
  /** The identification filter used for this project. */
  private IdFilter idFilter = new IdFilter();

  /** The actually identified modifications. */
  /**
   * Returns the modifications found in this project.
   *
   * @return the modifications found in this project
   */
  public ArrayList<String> getFoundModifications() {
    if (identifiedModifications == null) {
      identifiedModifications = new ArrayList<String>();
      for (String peptideKey : identification.getPeptideIdentification()) {

        boolean modified = false;

        for (String modificationName : Peptide.getModificationFamily(peptideKey)) {
          if (!identifiedModifications.contains(modificationName)) {
            identifiedModifications.add(modificationName);
            modified = true;
          }
        }
        if (!modified && !identifiedModifications.contains(PtmPanel.NO_MODIFICATION)) {
          identifiedModifications.add(PtmPanel.NO_MODIFICATION);
        }
      }
    }
    return identifiedModifications;
  }

  private ArrayList<String> identifiedModifications = null;
  /** Metrics picked-up while loading the files. */
  private Metrics metrics;
  /** The display preferences. */
  private DisplayPreferences displayPreferences = new DisplayPreferences();
  /** The sequence factory. */
  private SequenceFactory sequenceFactory = SequenceFactory.getInstance(30000);
  /** The filter preferences. */
  private FilterPreferences filterPreferences = new FilterPreferences();
  /** The compomics experiment. */
  private MsExperiment experiment = null;
  /** The investigated sample. */
  private Sample sample;
  /** The replicate number. */
  private int replicateNumber;
  /** The class used to provide sexy features out of the identification. */
  private IdentificationFeaturesGenerator identificationFeaturesGenerator;
  /** The last folder opened by the user. Defaults to user.home. */
  private String lastSelectedFolder = "user.home";
  /** The object cache used for the identification database. */
  private ObjectsCache objectsCache;

  private com.compomics.util.experiment.ProteomicAnalysis proteomicAnalysis;
  private ProgressDialogX progressDialog;
  private javax.swing.JProgressBar jprog;

  public PSFileImporter(javax.swing.JProgressBar jprog) {
    this.progressDialog = new ProgressDialogX(false);
    this.jprog = jprog;
  }

  public void importPeptideShakerFile(File aPsFile, final String resource) {

    this.resource = resource;
    this.currentPSFile = aPsFile;
    loadGeneMapping();
    loadEnzymes();
    resetPtmFactory();
    // setDefaultPreferences(); // @TODO: i tried re-adding this but then we get a null pointer, but
    // the two below have to be added or the default neutral losses won't appear
    IonFactory.getInstance().addDefaultNeutralLoss(NeutralLoss.H2O);
    IonFactory.getInstance().addDefaultNeutralLoss(NeutralLoss.NH3);

    // exceptionHandler = new ExceptionHandler(this);

    new Thread("ProgressThread") {
      @Override
      public void run() {
        jprog.setValue(10);
      }
    }.start();

    Thread importThread =
        new Thread("ImportThread") {
          @Override
          public void run() {
            try {
              // reset enzymes, ptms and preferences
              loadEnzymes();
              resetPtmFactory();
              setDefaultPreferences();
              try {
                // close any open connection to an identification database
                if (identification != null) {
                  identification.close();
                }
              } catch (Exception e) {
                e.printStackTrace();
              }
              File experimentFile =
                  new File(
                      PeptideShaker.SERIALIZATION_DIRECTORY, PeptideShaker.experimentObjectName);
              File matchFolder = new File(PeptideShaker.SERIALIZATION_DIRECTORY);
              // empty the existing files in the matches folder
              if (matchFolder.exists()) {
                for (File file : matchFolder.listFiles()) {
                  if (file.isDirectory()) {
                    boolean deleted = Util.deleteDir(file);

                    if (!deleted) {
                      System.out.println("Failed to delete folder: " + file.getPath());
                    }
                  } else {
                    boolean deleted = file.delete();

                    if (!deleted) {
                      System.out.println("Failed to delete file: " + file.getPath());
                    }
                  }
                }
              }
              final int BUFFER = 2048;
              byte data[] = new byte[BUFFER];
              FileInputStream fi = new FileInputStream(currentPSFile);
              BufferedInputStream bis = new BufferedInputStream(fi, BUFFER);
              try {
                ArchiveInputStream tarInput =
                    new ArchiveStreamFactory().createArchiveInputStream(bis);
                ArchiveEntry archiveEntry;

                while ((archiveEntry = tarInput.getNextEntry()) != null) {
                  File destinationFile = new File(archiveEntry.getName());
                  File destinationFolder = destinationFile.getParentFile();
                  boolean destFolderExists = true;
                  if (!destinationFolder.exists()) {
                    destFolderExists = destinationFolder.mkdirs();
                  }
                  if (destFolderExists) {
                    FileOutputStream fos = new FileOutputStream(destinationFile);
                    BufferedOutputStream bos = new BufferedOutputStream(fos);
                    int count;
                    while ((count = tarInput.read(data, 0, BUFFER)) != -1
                        && !progressDialog.isRunCanceled()) {
                      bos.write(data, 0, count);
                    }

                    bos.close();
                    fos.close();

                    //	                                int progress = (int) (100 *
                    // tarInput.getBytesRead() / fileLength);
                    //	                               progressDialog.setValue(progress);
                  } else {
                    System.out.println(
                        "Folder does not exist: \'"
                            + destinationFolder.getAbsolutePath()
                            + "\'. User preferences not saved.");
                  }
                }
                tarInput.close();
              } catch (ArchiveException e) {
                // Most likely an old project
                experimentFile = currentPSFile;
                e.printStackTrace();
              }
              fi.close();
              bis.close();
              fi.close();

              MsExperiment tempExperiment = ExperimentIO.loadExperiment(experimentFile);
              Sample tempSample = null;
              PeptideShakerSettings experimentSettings = new PeptideShakerSettings();
              if (tempExperiment.getUrParam(experimentSettings) instanceof PSSettings) {
                // convert old settings files using utilities version 3.10.68 or older
                // convert the old ProcessingPreferences object
                PSSettings tempSettings =
                    (PSSettings) tempExperiment.getUrParam(experimentSettings);
                ProcessingPreferences tempProcessingPreferences = new ProcessingPreferences();
                tempProcessingPreferences.setProteinFDR(
                    tempSettings.getProcessingPreferences().getProteinFDR());
                tempProcessingPreferences.setPeptideFDR(
                    tempSettings.getProcessingPreferences().getPeptideFDR());
                tempProcessingPreferences.setPsmFDR(
                    tempSettings.getProcessingPreferences().getPsmFDR());
                // convert the old PTMScoringPreferences object
                PTMScoringPreferences tempPTMScoringPreferences = new PTMScoringPreferences();
                tempPTMScoringPreferences.setaScoreCalculation(
                    tempSettings.getPTMScoringPreferences().aScoreCalculation());
                tempPTMScoringPreferences.setaScoreNeutralLosses(
                    tempSettings.getPTMScoringPreferences().isaScoreNeutralLosses());
                tempPTMScoringPreferences.setFlrThreshold(
                    tempSettings.getPTMScoringPreferences().getFlrThreshold());
                // missing gene refrences
                GenePreferences genePreferences = getGenePreferences();
                //     String selectedSpecies = genePreferences.getCurrentSpecies();
                //    String speciesDatabase =
                // genePreferences.getEnsemblDatabaseName(selectedSpecies);

                experimentSettings =
                    new PeptideShakerSettings(
                        tempSettings.getSearchParameters(),
                        tempSettings.getAnnotationPreferences(),
                        tempSettings.getSpectrumCountingPreferences(),
                        tempSettings.getProjectDetails(),
                        tempSettings.getFilterPreferences(),
                        tempSettings.getDisplayPreferences(),
                        tempSettings.getMetrics(),
                        tempProcessingPreferences,
                        tempSettings.getIdentificationFeaturesCache(),
                        tempPTMScoringPreferences,
                        genePreferences,
                        new IdFilter());
                ;
              } else {
                experimentSettings =
                    (PeptideShakerSettings) tempExperiment.getUrParam(experimentSettings);
              }

              idFilter = experimentSettings.getIdFilter();
              setAnnotationPreferences(experimentSettings.getAnnotationPreferences());
              setSpectrumCountingPreferences(experimentSettings.getSpectrumCountingPreferences());
              setPtmScoringPreferences(experimentSettings.getPTMScoringPreferences());
              setProjectDetails(experimentSettings.getProjectDetails());
              setSearchParameters(experimentSettings.getSearchParameters());
              setProcessingPreferences(experimentSettings.getProcessingPreferences());
              setMetrics(experimentSettings.getMetrics());
              setDisplayPreferences(experimentSettings.getDisplayPreferences());

              if (experimentSettings.getFilterPreferences() != null) {
                setFilterPreferences(experimentSettings.getFilterPreferences());
              } else {
                setFilterPreferences(new FilterPreferences());
              }
              if (experimentSettings.getDisplayPreferences() != null) {
                setDisplayPreferences(experimentSettings.getDisplayPreferences());
                displayPreferences.compatibilityCheck(searchParameters.getModificationProfile());
              } else {
                setDisplayPreferences(new DisplayPreferences());
                displayPreferences.setDefaultSelection(searchParameters.getModificationProfile());
              }
              ArrayList<Sample> samples = new ArrayList(tempExperiment.getSamples().values());

              if (samples.size() == 1) {
                tempSample = samples.get(0);
              } else {
                tempSample = samples.get(0);
                String[] sampleNames = new String[samples.size()];
                for (int cpt = 0; cpt < sampleNames.length; cpt++) {
                  sampleNames[cpt] = samples.get(cpt).getReference();
                  System.out.println(sampleNames[cpt]);
                }
                SampleSelection sampleSelection =
                    new SampleSelection(null, true, sampleNames, "sample");
                sampleSelection.setVisible(false);
                String choice = sampleSelection.getChoice();
                for (Sample sampleTemp : samples) {
                  if (sampleTemp.getReference().equals(choice)) {
                    tempSample = sampleTemp;
                    break;
                  }
                }
              }

              ArrayList<Integer> replicates =
                  new ArrayList(tempExperiment.getAnalysisSet(tempSample).getReplicateNumberList());

              System.out.println(replicates);
              int tempReplicate;

              if (replicates.size() == 1) {
                tempReplicate = replicates.get(0);
              } else {
                String[] replicateNames = new String[replicates.size()];
                for (int cpt = 0; cpt < replicateNames.length; cpt++) {
                  replicateNames[cpt] = samples.get(cpt).getReference();
                }
                SampleSelection sampleSelection =
                    new SampleSelection(null, true, replicateNames, "replicate");
                sampleSelection.setVisible(false);
                Integer choice = new Integer(sampleSelection.getChoice());
                tempReplicate = 0;
              }

              setProject(tempExperiment, tempSample, tempReplicate);

              identificationFeaturesGenerator =
                  new IdentificationFeaturesGenerator(
                      identification,
                      searchParameters,
                      idFilter,
                      metrics,
                      spectrumCountingPreferences);
              if (experimentSettings.getIdentificationFeaturesCache() != null) {
                identificationFeaturesGenerator.setIdentificationFeaturesCache(
                    experimentSettings.getIdentificationFeaturesCache());
              }

              //	                    mainProgressDialog.setTitle("Loading FASTA File. Please
              // Wait...");

              try {
                File providedFastaLocation =
                    experimentSettings.getSearchParameters().getFastaFile();
                String fileName = providedFastaLocation.getName();
                File projectFolder = currentPSFile.getParentFile();
                File dataFolder = new File(projectFolder, "data");

                // try to locate the FASTA file
                if (providedFastaLocation.exists()) {
                  SequenceFactory.getInstance().loadFastaFile(providedFastaLocation);
                } else if (new File(projectFolder, fileName).exists()) {
                  SequenceFactory.getInstance().loadFastaFile(new File(projectFolder, fileName));
                  experimentSettings
                      .getSearchParameters()
                      .setFastaFile(new File(projectFolder, fileName));
                } else if (new File(dataFolder, fileName).exists()) {
                  SequenceFactory.getInstance().loadFastaFile(new File(dataFolder, fileName));
                  experimentSettings
                      .getSearchParameters()
                      .setFastaFile(new File(dataFolder, fileName));
                } else {
                  // return error

                  System.out.println("fastafile is missing");
                }
              } catch (Exception e) {
                e.printStackTrace();
                System.out.println("fastafile is missing");
              }

              //	                 mainProgressDialog.setTitle("Locating Spectrum Files. Please
              // Wait...");

              for (String spectrumFileName : identification.getSpectrumFiles()) {

                try {
                  File providedSpectrumLocation = projectDetails.getSpectrumFile(spectrumFileName);
                  // try to locate the spectrum file
                  if (providedSpectrumLocation == null || !providedSpectrumLocation.exists()) {
                    File projectFolder = currentPSFile.getParentFile();
                    File fileInProjectFolder = new File(projectFolder, spectrumFileName);
                    File dataFolder = new File(projectFolder, "data");
                    File fileInDataFolder = new File(dataFolder, spectrumFileName);
                    File fileInLastSelectedFolder =
                        new File(getLastSelectedFolder(), spectrumFileName);
                    if (fileInProjectFolder.exists()) {
                      projectDetails.addSpectrumFile(fileInProjectFolder);
                    } else if (fileInDataFolder.exists()) {
                      projectDetails.addSpectrumFile(fileInDataFolder);
                    } else if (fileInLastSelectedFolder.exists()) {
                      projectDetails.addSpectrumFile(fileInLastSelectedFolder);
                    } else {

                      System.out.println("error no file");
                    }
                  }
                } catch (Exception e) {
                  clearData(true);
                  // clearPreferences();
                  e.printStackTrace();
                  System.out.println("error no file");
                  return;
                }
              }

              objectsCache = new ObjectsCache();
              objectsCache.setAutomatedMemoryManagement(true);

              if (identification.isDB()) {
                try {
                  String dbFolder =
                      new File(resource, PeptideShaker.SERIALIZATION_DIRECTORY).getAbsolutePath();
                  identification.establishConnection(dbFolder, false, objectsCache);
                } catch (Exception e) {
                  e.printStackTrace();
                }
              } else {
                updateAnnotationPreferencesFromSearchSettings();
                annotationPreferences.useAutomaticAnnotation(true);
              }

              int cpt = 1, nfiles = identification.getSpectrumFiles().size();
              for (String fileName : identification.getSpectrumFiles()) {

                //                             mainProgressDialog.setTitle("Importing Spectrum
                // Files. Please Wait...");
                try {
                  File mgfFile = projectDetails.getSpectrumFile(fileName);
                  spectrumFactory.addSpectra(mgfFile, progressDialog);
                } catch (Exception e) {
                  clearData(true);
                  e.printStackTrace();
                  return;
                }
              }
              boolean compatibilityIssue =
                  getSearchParameters().getIonSearched1() == null
                      || getSearchParameters().getIonSearched2() == null;

              if (compatibilityIssue) {
                JOptionPane.showMessageDialog(
                    null,
                    "The annotation preferences for this project may have changed.\n\n"
                        + "Note that PeptideShaker has substancially improved, we strongly\n"
                        + "recommend reprocessing your identification files.",
                    "Annotation Preferences",
                    JOptionPane.INFORMATION_MESSAGE);
                updateAnnotationPreferencesFromSearchSettings();
              }

              if (identification.getSpectrumIdentificationMap() == null) {
                // 0.18 version, needs update of the spectrum mapping
                identification.updateSpectrumMapping();
              }
            } catch (OutOfMemoryError error) {
              System.out.println(
                  "Ran out of memory! (runtime.maxMemory(): "
                      + Runtime.getRuntime().maxMemory()
                      + ")");
              Runtime.getRuntime().gc();
              JOptionPane.showMessageDialog(
                  null,
                  "The task used up all the available memory and had to be stopped.\n"
                      + "Memory boundaries are set in ../resources/conf/JavaOptions.txt.",
                  "Out Of Memory Error",
                  JOptionPane.ERROR_MESSAGE);
              error.printStackTrace();
            } catch (Exception exp) {
              exp.printStackTrace();
            }
          }
        };
    importThread.setPriority(Thread.MAX_PRIORITY);
    //        importThread.start();
    //        while (importThread.isAlive()) {
    //            try {
    //                Thread.currentThread().sleep(100);
    //
    //            } catch (Exception e) {
    //                e.printStackTrace();
    //            }
    //        }
    ExecutorService es = Executors.newCachedThreadPool();
    es.execute(importThread);
    es.shutdown();
    try {
      boolean finshed = es.awaitTermination(1, TimeUnit.DAYS);
      System.gc();
      return;

      //        t.start();
    } catch (InterruptedException ex) {
      System.err.println(ex.getMessage());
      // Logger.getLogger(UpdatedOutputGenerator.class.getName()).log(Level.SEVERE, null, ex);
    }
    System.gc();
    //        return;

  }

  /** Loads the enzymes from the enzyme file into the enzyme factory. */
  private void loadEnzymes() {
    try {
      enzymeFactory.importEnzymes(new File(resource, PeptideShaker.ENZYME_FILE));
    } catch (Exception e) {
      System.out.println("Not able to load the enzyme file." + "Wrong enzyme file.");
      e.printStackTrace();
    }
  }

  /** Loads the modifications from the modification file. */
  public void resetPtmFactory() {
    // reset ptm factory
    ptmFactory.reloadFactory();
    ptmFactory = PTMFactory.getInstance();
    try {
      ptmFactory.importModifications(new File(resource, PeptideShaker.MODIFICATIONS_FILE), false);
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      ptmFactory.importModifications(
          new File(resource, PeptideShaker.USER_MODIFICATIONS_FILE), true);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  /** Set the default preferences. */
  private void setDefaultPreferences() {
    searchParameters = new SearchParameters();
    annotationPreferences.setAnnotationLevel(0.75);
    annotationPreferences.useAutomaticAnnotation(true);
    spectrumCountingPreferences.setSelectedMethod(SpectralCountingMethod.NSAF);
    spectrumCountingPreferences.setValidatedHits(true);
    IonFactory.getInstance().addDefaultNeutralLoss(NeutralLoss.NH3);
    IonFactory.getInstance().addDefaultNeutralLoss(NeutralLoss.H2O);
    processingPreferences = new ProcessingPreferences();
    ptmScoringPreferences = new PTMScoringPreferences();
  }

  /** Imports the gene mapping. */
  private void loadGeneMapping() {
    try {
      geneFactory.initialize(new File(resource, GENE_MAPPING_PATH), null);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  /** The path to the gene mapping file. */
  private final String GENE_MAPPING_PATH = "/resources/conf/gene_ontology/gene_details_human";
  /** The gene factory. */
  private GeneFactory geneFactory = GeneFactory.getInstance();

  /**
   * Updates the new annotation preferences.
   *
   * @param annotationPreferences the new annotation preferences
   */
  public void setAnnotationPreferences(AnnotationPreferences annotationPreferences) {
    this.annotationPreferences = annotationPreferences;
  }

  /**
   * Sets new spectrum counting preferences.
   *
   * @param spectrumCountingPreferences new spectrum counting preferences
   */
  public void setSpectrumCountingPreferences(
      SpectrumCountingPreferences spectrumCountingPreferences) {
    this.spectrumCountingPreferences = spectrumCountingPreferences;
  }

  /**
   * Sets the PTM scoring preferences
   *
   * @param ptmScoringPreferences the PTM scoring preferences
   */
  public void setPtmScoringPreferences(PTMScoringPreferences ptmScoringPreferences) {
    this.ptmScoringPreferences = ptmScoringPreferences;
  }

  /**
   * Sets the project details.
   *
   * @param projectDetails the project details
   */
  public void setProjectDetails(ProjectDetails projectDetails) {
    this.projectDetails = projectDetails;
  }

  /**
   * Updates the search parameters.
   *
   * @param searchParameters the new search parameters
   */
  public void setSearchParameters(SearchParameters searchParameters) {
    this.searchParameters = searchParameters;
    PeptideShaker.loadModifications(searchParameters);
  }

  /**
   * Sets the initial processing preferences.
   *
   * @param processingPreferences the initial processing preferences
   */
  public void setProcessingPreferences(ProcessingPreferences processingPreferences) {
    this.processingPreferences = processingPreferences;
  }

  /**
   * Sets the metrics saved while loading the files.
   *
   * @param metrics the metrics saved while loading the files
   */
  public void setMetrics(Metrics metrics) {
    this.metrics = metrics;
  }

  /**
   * Sets the display preferences to use.
   *
   * @param displayPreferences the display preferences to use
   */
  public void setDisplayPreferences(DisplayPreferences displayPreferences) {
    this.displayPreferences = displayPreferences;
  }
  /**
   * Sets the gui filter preferences to use. .\
   *
   * @param filterPreferences the gui filter preferences to use
   */
  public void setFilterPreferences(FilterPreferences filterPreferences) {
    this.filterPreferences = filterPreferences;
  }
  /**
   * This method sets the information of the project when opened.
   *
   * @param experiment the experiment conducted
   * @param sample The sample analyzed
   * @param replicateNumber The replicate number
   */
  public void setProject(MsExperiment experiment, Sample sample, int replicateNumber) {
    this.experiment = experiment;
    this.sample = sample;
    this.replicateNumber = replicateNumber;
    ProteomicAnalysis proteomic_Analysis =
        experiment.getAnalysisSet(sample).getProteomicAnalysis(replicateNumber);
    identification = proteomic_Analysis.getIdentification(IdentificationMethod.MS2_IDENTIFICATION);
  }

  /**
   * Returns the last selected folder.
   *
   * @return the last selected folder
   */
  public String getLastSelectedFolder() {
    return lastSelectedFolder;
  }

  /**
   * Set the last selected folder.
   *
   * @param lastSelectedFolder the folder to set
   */
  public void setLastSelectedFolder(String lastSelectedFolder) {
    this.lastSelectedFolder = lastSelectedFolder;
  }

  /**
   * Returns the identification displayed.
   *
   * @return the identification displayed
   */
  public com.compomics.util.experiment.identification.Identification getIdentification() {
    return identification;
  }

  /**
   * Returns the identification features generator.
   *
   * @return the identification features generator
   */
  public IdentificationFeaturesGenerator getIdentificationFeaturesGenerator() {
    return identificationFeaturesGenerator;
  }

  /**
   * Returns the search parameters.
   *
   * @return the search parameters
   */
  public SearchParameters getSearchParameters() {
    return searchParameters;
  }

  /**
   * Return the display preferences to use.
   *
   * @return the display preferences to use
   */
  public DisplayPreferences getDisplayPreferences() {
    return displayPreferences;
  }

  public ArrayList<IonMatch> getIonsCurrentlyMatched() throws MzMLUnmarshallerException {
    return spectrumAnnotator.getCurrentAnnotation(
        annotationPreferences.getIonTypes(),
        annotationPreferences.getNeutralLosses(),
        annotationPreferences.getValidatedCharges());
  }

  public SpectrumAnnotator getSpectrumAnnorator() {
    return spectrumAnnotator;
  }

  public void clearData(boolean clearDatabaseFolder) {
    projectDetails = null;
    spectrumAnnotator = new SpectrumAnnotator();
    try {
      spectrumFactory.closeFiles();
    } catch (Exception e) {
      e.printStackTrace();
    }
    try {
      sequenceFactory.closeFile();
    } catch (Exception e) {
      e.printStackTrace();
    }
    try {
      GOFactory.getInstance().closeFiles();
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      spectrumFactory.clearFactory();
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      sequenceFactory.clearFactory();
    } catch (Exception e) {
      e.printStackTrace();
    }

    try {
      GOFactory.getInstance().clearFactory();
    } catch (Exception e) {
      e.printStackTrace();
    }

    identifiedModifications = null;

    if (clearDatabaseFolder) {
      clearDatabaseFolder();
    }

    resetFeatureGenerator();

    // set up the tabs/panels

    currentPSFile = null;
  }

  /** Resets the feature generator. */
  public void resetFeatureGenerator() {
    identificationFeaturesGenerator =
        new IdentificationFeaturesGenerator(
            identification, searchParameters, idFilter, metrics, spectrumCountingPreferences);
  }

  /** Clears the database folder. */
  private void clearDatabaseFolder() {

    boolean databaseClosed = true;

    // close the database connection
    if (identification != null) {

      try {
        identification.close();
        identification = null;
      } catch (SQLException e) {
        databaseClosed = false;
        e.printStackTrace();
        JOptionPane.showMessageDialog(
            null, "Failed to close the database.", "Database Error", JOptionPane.WARNING_MESSAGE);
      }
    }

    // empty the matches folder
    if (databaseClosed) {
      File matchFolder = new File(resource, PeptideShaker.SERIALIZATION_DIRECTORY);

      if (matchFolder.exists()) {

        File[] tempFiles = matchFolder.listFiles();

        if (tempFiles != null) {
          for (File currentFile : tempFiles) {
            Util.deleteDir(currentFile);
          }
        }

        if (matchFolder.listFiles() != null && matchFolder.listFiles().length > 0) {
          JOptionPane.showMessageDialog(
              null,
              "Failed to empty the database folder:\n" + matchFolder.getPath() + ".",
              "Database Cleanup Failed",
              JOptionPane.WARNING_MESSAGE);
        }
      }
    }
  }

  /** Updates the ions used for fragment annotation. */
  public void updateAnnotationPreferencesFromSearchSettings() {
    annotationPreferences.setPreferencesFromSearchParamaers(searchParameters);
  }

  /**
   * Returns the gene preferences.
   *
   * @return the gene preferences
   */
  public GenePreferences getGenePreferences() {
    return genePreferences;
  }

  private GenePreferences genePreferences = new GenePreferences();

  /**
   * Returns the experiment.
   *
   * @return the experiment
   */
  public MsExperiment getExperiment() {
    return experiment;
  }

  /*
   * Returns the sample.
   * @return the sample
   */
  public Sample getSample() {
    return sample;
  }
  /**
   * Returns the replicate number.
   *
   * @return the replicateNumber
   */
  public int getReplicateNumber() {
    return this.replicateNumber;
  }

  /**
   * Returns the desired spectrum.
   *
   * @param spectrumKey the key of the spectrum
   * @return the desired spectrum
   */
  public MSnSpectrum getSpectrum(String spectrumKey) {
    String spectrumFile = Spectrum.getSpectrumFile(spectrumKey);
    String spectrumTitle = Spectrum.getSpectrumTitle(spectrumKey);
    try {
      return (MSnSpectrum) spectrumFactory.getSpectrum(spectrumFile, spectrumTitle);
    } catch (Exception e) {
      System.out.println(e.getMessage());
      return null;
    }
  }
}