private void guessHumanReadableName(final CyRow row) {
    boolean found = false;

    // Special handler for STRING. This is a hack...
    if (row.getTable().getColumn(STRING_ATTR_NAME) != null) {
      final List<String> stringList = row.getList(STRING_ATTR_NAME, String.class);
      if (stringList != null) found = findHumanReadableName(row, stringList, ncbiPattern, true);
    }

    if (found) return;

    // try NCBI
    if (row.getTable().getColumn(ENTREZ_GENE_ATTR_NAME) != null) {
      final List<String> ncbiList = row.getList(ENTREZ_GENE_ATTR_NAME, String.class);
      if (ncbiList != null) found = findHumanReadableName(row, ncbiList, ncbiPattern, true);
    }
    if (found) return;

    // Try Uniprot
    List<String> uniprotList = null;
    if (row.getTable().getColumn(UNIPROT_ATTR_NAME) != null) {
      uniprotList = row.getList(UNIPROT_ATTR_NAME, String.class);
      if (uniprotList != null) found = findHumanReadableName(row, uniprotList, exact1Pattern, true);
    }
    if (found) return;

    if (uniprotList != null) found = findHumanReadableName(row, uniprotList, uniprotPattern, false);

    if (found) return;

    // Unknown
    if (row.getTable().getColumn("unknown") != null) {
      final List<String> unknownList = row.getList("unknown", String.class);
      if (unknownList != null)
        found = findHumanReadableName(row, unknownList, uniprotPattern, false);
    }
    if (found) return;

    if (found == false) {
      // Give up. Use primary key
      row.set(PREDICTED_GENE_NAME, row.get(CyNetwork.NAME, String.class));
    }
  }
  @Test
  public void gaReaderTest() throws Exception {
    File file = new File("./src/test/resources/" + GA_YEAST);
    GeneAssociationReader reader =
        new GeneAssociationReader(
            "dummy dag", file.toURI().toURL().openStream(), "yeast GA", serviceRegistrar);

    System.out.print("Start read: ");
    reader.run(tm);

    final CyTable[] tables = reader.getTables();
    assertNotNull(tables);
    assertEquals(1, tables.length);
    assertNotNull(tables[0]);

    // All 22 Columns + NAME primary key + synonyms
    assertEquals(24, tables[0].getColumns().size());
    // For yeast test file.
    assertEquals(6359, tables[0].getRowCount());

    // Check table contents
    final CyTable table = tables[0];
    final CyRow row1 = table.getRow("S000003319");
    assertNotNull(row1);
    final List<String> bpList1 = row1.getList("biological process", String.class);
    assertNotNull(bpList1);
    assertFalse(bpList1.contains("GO:0000287"));
    assertTrue(bpList1.contains("GO:0006067"));
    assertFalse(bpList1.contains("fake value"));

    final String taxName = row1.get(GeneAssociationTag.TAXON.toString(), String.class);
    assertNotNull(taxName);
    assertEquals("Saccharomyces cerevisiae", taxName);

    final List<String> referenceList1 =
        row1.getList("biological process DB Reference", String.class);
    //		assertNotNull(referenceList1);
    //		assertEquals(2, referenceList1.size());

  }
  private void processOtherNames(CyRow row, final Map<String, List<String>> accs) {
    for (String originalDBName : accs.keySet()) {

      final String dbName = validateNamespace(originalDBName);

      if (row.getTable().getColumn(dbName) == null)
        row.getTable().createListColumn(dbName, String.class, false);

      List<String> currentList = row.getList(dbName, String.class);
      if (currentList == null) currentList = new ArrayList<String>();

      final Set<String> nameSet = new HashSet<String>(currentList);
      final List<String> names = accs.get(originalDBName);
      nameSet.addAll(names);
      row.set(dbName, new ArrayList<String>(nameSet));
    }
  }
  private void mergeRow(String keyName, CyRow sourceRow, CyRow targetRow) {
    for (CyColumn column : sourceRow.getTable().getColumns()) {
      if (cancelled) return;

      String columnName = column.getName();

      if (columnName.equals(keyName)) continue;

      Class<?> type = column.getType();

      if (type.equals(List.class)) {
        Class<?> elementType = column.getListElementType();
        List<?> list = sourceRow.getList(columnName, elementType);
        targetRow.set(columnName, list);
      } else {
        Object value = sourceRow.get(columnName, type);
        targetRow.set(columnName, value);
      }
    }
  }
  private void mapEntry(final String[] entries) {
    // Set primary key for the table, which is DB Object ID
    final String primaryKeyValue = entries[DB_OBJ_ID];

    final CyRow row = table.getRow(primaryKeyValue);
    row.set(CyNetwork.NAME, primaryKeyValue);

    // Check namespace
    final String namespace = NAMESPACE_MAP.get(entries[ASPECT]);

    for (int i = 0; i < EXPECTED_COL_COUNT; i++) {
      final GeneAssociationTag tag = GeneAssociationTag.values()[i];

      switch (tag) {

          // Evidence code and GO ID should be organized by namespace.
        case GO_ID:
          String goidString = entries[i];
          if (this.termIDList != null) goidString = convertToName(goidString);

          List<String> currentList = row.getList(namespace, String.class);
          if (currentList == null) currentList = new ArrayList<String>();

          if (currentList.contains(goidString) == false) currentList.add(goidString);
          row.set(namespace, currentList);
          break;

        case EVIDENCE:
        case DB_REFERENCE:
          final String value = entries[i];
          String columnName = namespace;
          if (tag == GeneAssociationTag.EVIDENCE) columnName = columnName + EVIDENCE_SUFFIX;
          else columnName = columnName + REFERENCE_SUFFIX;

          List<String> valueList = row.getList(columnName, String.class);
          if (valueList == null) valueList = new ArrayList<String>();
          if (valueList.contains(value) == false) valueList.add(value);
          row.set(columnName, valueList);

          break;
        case TAXON:
          final String taxID = entries[i].split(":")[1];
          final String taxName = speciesMap.get(taxID);
          if (taxName != null) row.set(tag.toString(), taxName);
          else if (taxID != null) row.set(tag.toString(), taxID);
          break;

        case ASPECT:
          // Ignore these lines
          break;

        case DB_OBJECT_ID:
        case DB_OBJECT_SYMBOL:
        case DB_OBJECT_SYNONYM:
          // Create consolidated id list attribute.
          List<String> synList = row.getList(SYNONYM_COL_NAME, String.class);
          if (synList == null) synList = new ArrayList<String>();

          if (tag == GeneAssociationTag.DB_OBJECT_SYNONYM) {
            final String[] vals = entries[i].split(LIST_DELIMITER);
            for (String val : vals) {
              if (synList.contains(val) == false) synList.add(val);
            }
          } else {
            if (synList.contains(entries[i]) == false) synList.add(entries[i]);
          }
          row.set(SYNONYM_COL_NAME, synList);
          break;
        default:
          if (LIST_INDEX.contains(i + 1)) {
            final String[] vals = entries[i].split(LIST_DELIMITER);

            List<String> listVals = row.getList(tag.toString(), String.class);
            if (listVals == null) listVals = new ArrayList<String>();
            for (String val : vals) {
              if (listVals.contains(val) == false) listVals.add(val);
            }
            row.set(tag.toString(), listVals);
          } else row.set(tag.toString(), entries[i]);
          break;
      }
    }
  }