예제 #1
0
  /**
   * Check whether s qualifier string exists in a StringVector for that qualifier. If the
   * StringVector contains the hit, organism, description & e-value then return true.
   *
   * @param qualStr
   * @param qualStringVector
   * @return
   */
  public static boolean containsStringInStringVector(
      final String qualStr, final StringVector qualStringVector) {
    StringVector sim1 = StringVector.getStrings(qualStr, ";");
    for (int i = 0; i < qualStringVector.size(); i++) {
      String thisStr = (String) qualStringVector.get(i);

      StringVector sim2 = StringVector.getStrings(thisStr, ";");

      // hit
      if (!((String) sim1.get(1)).equals((String) sim2.get(1))) continue;

      // organism
      if (!((String) sim1.get(2)).equals((String) sim2.get(2))) continue;

      // description
      if (!((String) sim1.get(3)).equals((String) sim2.get(3))) continue;

      // e-value
      final String evalueString1 = getField("E()=", qualStr);
      final String evalueString2 = getField("E()=", thisStr);
      if (!(evalueString1.equals(evalueString2))) continue;

      return true;
    }
    return false;
  }
예제 #2
0
  /**
   * Build a vector of the row data
   *
   * @param similarityString
   * @return
   */
  private Vector getRowData(String similarityString, final Vector tableData) {
    Vector row = new Vector(NUMBER_COLUMNS);
    row.setSize(NUMBER_COLUMNS);

    if (similarityString.startsWith("\"")) similarityString = similarityString.substring(1);
    if (similarityString.endsWith("\""))
      similarityString = similarityString.substring(0, similarityString.length() - 1);

    StringVector sim = StringVector.getStrings(similarityString, ";");

    // organism
    if (sim.size() >= 3) {
      int columnIndex = tableData.indexOf(ORGANISM_COL);
      row.setElementAt(((String) sim.get(2)).trim(), columnIndex);
    }

    // hit
    if (sim.size() >= 2) {
      int columnIndex = tableData.indexOf(HIT_COL);

      String hit = ((String) sim.get(1)).trim();

      if (hit.startsWith("with=")) hit = hit.substring(5);

      final String hits[] = hit.split(" ");

      row.setElementAt(hits[0], columnIndex);

      if (hits.length > 1) {
        // dbxref
        columnIndex = tableData.indexOf(HIT_DBXREF_COL);

        if (hits[1].startsWith("(") && hits[1].endsWith(")"))
          hits[1] = hits[1].substring(1, hits[1].length() - 1);

        row.setElementAt(hits[1], columnIndex);
      }
    }

    // description
    if (sim.size() >= 4) {
      int columnIndex = tableData.indexOf(DESCRIPTION_COL);
      row.setElementAt(((String) sim.get(3)).trim(), columnIndex);
    }

    // e-value
    String evalueString;
    if (!(evalueString = getField("E()=", similarityString)).equals("")) {
      int columnIndex = tableData.indexOf(EVALUE_COL);
      row.setElementAt(evalueString, columnIndex);
    }

    // length
    String lenString;
    if (!(lenString = getField("length=", similarityString).trim()).equals("")) {
      int columnIndex = tableData.indexOf(LENGTH_COL);
      row.setElementAt(lenString, columnIndex);
    } else if (!(lenString = getField("length", similarityString).trim()).equals("")) {
      int columnIndex = tableData.indexOf(LENGTH_COL);
      row.setElementAt(lenString, columnIndex);
    }

    String ungappedId;
    if (!(ungappedId = getField("ungapped id", similarityString)).equals("")) {
      int columnIndex = tableData.indexOf(ID_COL);
      row.setElementAt(ungappedId, columnIndex);
    }

    String query;
    if (!(query = getField("query", similarityString).trim()).equals("")) {
      int columnIndex = tableData.indexOf(QUERY_COL);
      row.setElementAt(query, columnIndex);
    }

    String subject;
    if (!(subject = getField("subject", similarityString).trim()).equals("")) {
      int columnIndex = tableData.indexOf(SUBJECT_COL);
      row.setElementAt(subject, columnIndex);
    }

    String score;
    if (!(score = getField("score=", similarityString)).equals("")) {
      int columnIndex = tableData.indexOf(SCORE_COL);
      row.setElementAt(score, columnIndex);
    }

    String overlap;
    if (!(overlap = getField("overlap=", similarityString)).equals("")) {
      int columnIndex = tableData.indexOf(OVERLAP_COL);
      row.setElementAt(overlap, columnIndex);
    } else if (similarityString.indexOf("overlap;") > -1) {
      overlap = null;
      for (int i = 0; i < sim.size(); i++) {
        String val = (String) sim.get(i);
        if (val.endsWith("overlap")) {
          overlap = val;
          break;
        }
      }
      if (overlap != null) {
        int columnIndex = tableData.indexOf(OVERLAP_COL);
        row.setElementAt(overlap, columnIndex);
      }
    }

    int columnIndex = tableData.indexOf(METHOD_COL);
    row.setElementAt(((String) sim.get(0)).trim(), columnIndex);
    return row;
  }