コード例 #1
0
  /**
   * @param features
   * @param qualifiersToTransfer
   * @param key
   * @param sameKey
   * @param isDatabaseEntry
   * @param geneNames
   * @return
   */
  private static String[] transfer(
      final FeatureVector features,
      final QualifierVector qualifiersToTransfer,
      final String key,
      final boolean sameKey,
      final boolean overwrite,
      final boolean isDatabaseEntry,
      String[] geneNames,
      final StringBuffer genesUpdated) {
    final TransferFeaturePredicate predicate =
        new TransferFeaturePredicate(key, sameKey, isDatabaseEntry, geneNames);

    for (int i = 0; i < features.size(); i++) {
      Feature thisFeature = features.elementAt(i);
      if (predicate.testPredicate(thisFeature)) {
        StringBuffer qualifierBuffer = new StringBuffer();
        for (int j = 0; j < qualifiersToTransfer.size(); j++) {
          Qualifier newQualifier = qualifiersToTransfer.elementAt(j);
          String qualifierName = newQualifier.getName();
          try {
            if (overwrite) {
              thisFeature.setQualifier(newQualifier);
              qualifierBuffer.append(
                  "  "
                      + qualifierName
                      + " (overwritten)\n"
                      + parseStringVector(newQualifier.getValues()));
            } else {
              final StringVector oldValues;
              if (thisFeature.getQualifierByName(newQualifier.getName()) == null) oldValues = null;
              else oldValues = thisFeature.getQualifierByName(newQualifier.getName()).getValues();

              final Qualifier newQualifierTmp =
                  getQualifierWithoutDuplicateValues(newQualifier, oldValues);
              if (newQualifierTmp == null) continue;
              thisFeature.addQualifierValues(newQualifierTmp);
              qualifierBuffer.append(
                  "  "
                      + qualifierName
                      + " (added)\n"
                      + parseStringVector(newQualifier.getValues()));
            }
          } catch (Exception e1) {
            e1.printStackTrace();
          }
        }

        geneNames = removeArrayElement(geneNames, predicate.getGeneName());
        if (qualifierBuffer.length() > 0)
          genesUpdated.append(
              thisFeature.getSystematicName() + " (" + key + ")\n" + qualifierBuffer);
      }
    }
    return geneNames;
  }
コード例 #2
0
ファイル: ReferencesPanel.java プロジェクト: ambarrio/Artemis
  private void updateFromFeature(Feature feature) {
    GridBagConstraints c = new GridBagConstraints();
    JPanel gridPanel = new JPanel(new GridBagLayout());
    gridPanel.setBackground(Color.white);

    //
    // literature & dbxref
    literatureTextArea = new QualifierTextArea();
    literatureTextArea.setBorder(BorderFactory.createLineBorder(Color.gray));
    dbxrefTextArea = new QualifierTextArea();
    dbxrefTextArea.setBorder(BorderFactory.createLineBorder(Color.gray));

    literatureTextArea
        .getDocument()
        .addDocumentListener(new TextAreaDocumentListener(literatureTextArea));

    dbxrefTextArea.getDocument().addDocumentListener(new TextAreaDocumentListener(dbxrefTextArea));

    final QualifierVector qualifiers = feature.getQualifiers().copy();
    final StringBuffer litBuffer = new StringBuffer();
    final StringBuffer dbxrefBuffer = new StringBuffer();

    for (int i = 0; i < qualifiers.size(); ++i) {
      Qualifier this_qualifier = (Qualifier) qualifiers.elementAt(i);
      if (this_qualifier.getName().equals("literature"))
        appendToBuffer(this_qualifier.getValues(), litBuffer);
      else if (this_qualifier.getName().equalsIgnoreCase("Dbxref"))
        appendToBuffer(this_qualifier.getValues(), dbxrefBuffer);
    }

    c.gridx = 0;
    c.gridy = 0;
    c.ipadx = 5;
    c.ipady = 5;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.fill = GridBagConstraints.NONE;
    gridPanel.add(new JLabel("Literature"), c);
    c.gridx = 1;
    gridPanel.add(literatureTextArea, c);

    c.gridx = 0;
    c.gridy = 1;
    gridPanel.add(new JLabel("Dbxref"), c);
    c.gridx = 1;
    gridPanel.add(dbxrefTextArea, c);

    add(gridPanel);

    literatureTextArea.setText(litBuffer.toString() + "\n");
    dbxrefTextArea.setText(dbxrefBuffer.toString() + "\n");
  }