public boolean testPredicate(Feature targetFeature) {
    String targetKey = targetFeature.getKey().getKeyString();
    if (sameKey && !targetKey.equals(key)) return false;

    Vector<String> chadoNames = null;
    if (isDatabaseEntry) {
      GFFStreamFeature gffFeature = ((GFFStreamFeature) targetFeature.getEmblFeature());
      if (gffFeature.getChadoGene() != null) {
        chadoNames = new Vector<String>();

        ChadoCanonicalGene chadoGene = gffFeature.getChadoGene();
        chadoNames.add(chadoGene.getGeneUniqueName());
        List<uk.ac.sanger.artemis.io.Feature> transcripts = chadoGene.getTranscripts();
        for (int i = 0; i < transcripts.size(); i++) {
          GFFStreamFeature feature = (GFFStreamFeature) transcripts.get(i);
          chadoNames.add(GeneUtils.getUniqueName(feature));
        }
      }
    }

    String thisFeatureSystematicName = targetFeature.getSystematicName();
    for (int i = 0; i < geneNames.length; i++) {
      if (geneNames[i].equals(thisFeatureSystematicName)
          || (chadoNames != null && chadoNames.contains(geneNames[i]))) {
        geneName = geneNames[i];
        return true;
      }
    }
    return false;
  }
  /**
   * Construct the panel for setting up the gene list and the list of qualifiers to transfer.
   *
   * @param feature
   * @param pane
   * @param qualifierCheckBoxes
   * @param geneNameCheckBoxes
   * @param geneNames
   */
  private void addMainPanel(
      final Feature feature,
      final JPanel pane,
      final Vector<QualifierPanel> qualifierPanels,
      final Vector<JCheckBox> geneNameCheckBoxes,
      final List<String> geneNames) {
    GridBagConstraints c = new GridBagConstraints();
    int nrows = 0;

    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridx = 2;
    c.gridy = 0;
    c.ipadx = 50;

    JLabel geneLabel = new JLabel("Qualifier(s)");
    geneLabel.setFont(geneLabel.getFont().deriveFont(Font.BOLD));
    pane.add(geneLabel, c);

    c.gridy = 0;
    c.gridx = 0;
    JLabel label = new JLabel("Gene List");
    label.setFont(label.getFont().deriveFont(Font.BOLD));
    pane.add(label, c);

    nrows += 3;
    c.gridx = 2;
    c.gridy = nrows;
    c.anchor = GridBagConstraints.WEST;

    addQualifierPanel(feature, qualifierPanels, c, nrows, pane);
    nrows += 2;

    if (feature.getEmblFeature() instanceof GFFStreamFeature) {
      GFFStreamFeature gffFeature = ((GFFStreamFeature) feature.getEmblFeature());
      if (gffFeature.getChadoGene() != null) {
        String id = GeneUtils.getUniqueName(gffFeature);
        ChadoCanonicalGene chadoGene = gffFeature.getChadoGene();
        Feature gene = (Feature) chadoGene.getGene().getUserData();

        if (!id.equals(GeneUtils.getUniqueName(((GFFStreamFeature) chadoGene.getGene()))))
          addQualifierPanel(gene, qualifierPanels, c, nrows, pane);

        nrows += 2;

        String transcriptName =
            chadoGene.getTranscriptFromName(GeneUtils.getUniqueName(gffFeature));

        if (transcriptName != null) {
          GFFStreamFeature transcript =
              (GFFStreamFeature) chadoGene.getFeatureFromId(transcriptName);
          addQualifierPanel((Feature) transcript.getUserData(), qualifierPanels, c, nrows, pane);
          nrows += 2;

          Set<uk.ac.sanger.artemis.io.Feature> children = chadoGene.getChildren(transcript);
          Iterator<uk.ac.sanger.artemis.io.Feature> it = children.iterator();

          while (it.hasNext()) {
            GFFStreamFeature kid = (GFFStreamFeature) it.next();
            if (id.equals(GeneUtils.getUniqueName(((GFFStreamFeature) kid)))) continue;
            addQualifierPanel((Feature) kid.getUserData(), qualifierPanels, c, nrows, pane);
            nrows += 2;
          }
        }
      }
    }

    c.gridx = 0;
    c.gridy = 3;
    c.gridheight = nrows;
    c.fill = GridBagConstraints.BOTH;

    final Box geneNameBox = Box.createVerticalBox();
    pane.add(geneNameBox, c);

    if (geneNames != null) {
      for (int i = 0; i < geneNames.size(); i++) {
        JCheckBox cb = new JCheckBox((String) geneNames.get(i), true);
        geneNameBox.add(cb);
        geneNameCheckBoxes.add(cb);
      }
    }

    c.gridy = 1;
    c.gridheight = 1;
    c.fill = GridBagConstraints.NONE;
    c.gridx = 2;
    final JButton toggle = new JButton("Toggle");
    toggle.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            for (int i = 0; i < qualifierPanels.size(); i++) {
              QualifierPanel qP = qualifierPanels.get(i);
              Enumeration<JCheckBox> enumQualifiers = qP.getQualifierCheckBoxes().keys();
              while (enumQualifiers.hasMoreElements()) {
                JCheckBox cb = enumQualifiers.nextElement();
                cb.setSelected(!cb.isSelected());
              }
            }
          }
        });
    pane.add(toggle, c);

    Box xBox = Box.createHorizontalBox();
    final JButton toggleGeneList = new JButton("Toggle");
    toggleGeneList.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            for (int i = 0; i < geneNameCheckBoxes.size(); i++) {
              JCheckBox cb = geneNameCheckBoxes.get(i);
              cb.setSelected(!cb.isSelected());
            }
            geneNameBox.repaint();
          }
        });
    xBox.add(toggleGeneList);

    final JButton addGenes = new JButton("Add");
    addGenes.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JTextArea geneNameTextArea = new JTextArea();
            geneNameTextArea.setEditable(true);
            JScrollPane jsp = new JScrollPane(geneNameTextArea);

            int res =
                JOptionPane.showConfirmDialog(
                    TransferAnnotationTool.this,
                    jsp,
                    "Paste Feature Names to Add",
                    JOptionPane.OK_CANCEL_OPTION);
            if (res == JOptionPane.CANCEL_OPTION) return;

            String geneNames[] = geneNameTextArea.getText().split("\\s");
            for (int i = 0; i < geneNames.length; i++) {
              if (geneNames[i] == null || geneNames[i].equals("")) continue;
              JCheckBox cb = new JCheckBox(geneNames[i], true);
              geneNameBox.add(cb);
              geneNameCheckBoxes.add(cb);
            }
            pane.revalidate();
          }
        });
    xBox.add(addGenes);
    c.gridx = 0;
    pane.add(xBox, c);

    final List<String> clusterList = (matchPanel == null ? null : matchPanel.getGeneNameList(true));
    if (clusterList != null && !geneNames.contains(clusterList.get(0))) {
      final JButton importCluster = new JButton("Import Cluster Names");
      importCluster.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              for (String n : clusterList) {
                if (n == null || n.equals("")) continue;
                JCheckBox cb = new JCheckBox(n, true);
                geneNameBox.add(cb);
                geneNameCheckBoxes.add(cb);
              }
              importCluster.setEnabled(false);
              pane.revalidate();
            }
          });
      c.gridy = 2;
      pane.add(importCluster, c);
    }
  }