Changeset 1092


Ignore:
Timestamp:
May 27, 2009, 10:00:02 AM (12 years ago)
Author:
Nicklas Nordborg
Message:

References #217: GCT exporter

Make sure assay names are unique in the GCT file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.genepattern/trunk/src/net/sf/basedb/genepattern/export/GctExporter.java

    r1091 r1092  
    33import java.sql.SQLException;
    44import java.util.Arrays;
     5import java.util.HashSet;
    56import java.util.List;
     7import java.util.Set;
    68
    79import net.sf.basedb.core.BioAssay;
     
    128130    int index = 0;
    129131   
     132    boolean hasUniqueNames = checkUniqueNames(assays);
     133   
    130134    // Reporter fields
    131135    for (DynamicField field : reporterFields)
     
    136140    for (BioAssay ba : assays)
    137141    {
    138       data[index++] = ba.getName();
     142      data[index++] = hasUniqueNames ? ba.getName() : ba.getName() + "-" + ba.getId();
    139143    }
    140144    out.tablePrintData(data);
     
    286290  }
    287291 
     292  /**
     293    Check if all bioassay names are unique.
     294    @return TRUE if the names are unique, FALSE otherwise
     295  */
     296  private boolean checkUniqueNames(List<BioAssay> assays)
     297  {
     298    Set<String> names = new HashSet<String>();
     299    for (BioAssay ba : assays)
     300    {
     301      if (names.contains(ba.getName())) return false;
     302      names.add(ba.getName());
     303    }
     304    return true;
     305  }
     306
     307 
    288308}
Note: See TracChangeset for help on using the changeset viewer.