Changeset 7472


Ignore:
Timestamp:
12/29/10 12:47:06 (9 years ago)
Author:
melissa
Message:

Added more flexible plate/well detection, so that InCell 3000 datasets are picked up by ScreenReader. Closes #628.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/in/ScreenReader.java

    r7433 r7472  
    103103    if (!open) return super.isThisType(filename, open); // no file system access 
    104104 
    105     String parent = new Location(filename).getParent(); 
     105    String parent = new Location(filename).getAbsoluteFile().getParent(); 
    106106    boolean validNames = isValidWellName(filename) && isValidPlateName(parent); 
    107107 
     
    200200    String[] screenList = screen.list(true); 
    201201    for (String f : screenList) { 
    202       if (isValidPlateName(f)) { 
    203         tmpPlates.add(new Location(screen, f).getAbsolutePath()); 
     202      Location plateFile = new Location(screen, f).getAbsoluteFile(); 
     203      if (isValidPlateName(plateFile.getAbsolutePath()) && 
     204        hasValidWells(plateFile)) 
     205      { 
     206        tmpPlates.add(plateFile.getAbsolutePath()); 
    204207      } 
    205208    } 
     
    234237      Vector<String> uniqueCols = new Vector<String>(); 
    235238      for (String well : plateList) { 
    236         if (isValidWellName(well)) { 
    237           tmpWells.add(new Location(plates[plate], well).getAbsolutePath()); 
     239        Location wellFile = new Location(plates[plate], well); 
     240        if (isValidWellName(wellFile.getAbsolutePath())) { 
    238241          String row = getRow(well); 
    239242          String col = getColumn(well); 
     243 
     244          boolean canAdd = true; 
     245          for (String tmpWell : tmpWells) { 
     246            String tmpRow = getRow(tmpWell); 
     247            String tmpCol = getColumn(tmpWell); 
     248            if (tmpRow.equals(row) && tmpCol.equals(col)) { 
     249              canAdd = false; 
     250              break; 
     251            } 
     252          } 
     253          if (!canAdd) continue; 
     254 
     255          tmpWells.add(wellFile.getAbsolutePath()); 
    240256 
    241257          if (!uniqueRows.contains(row)) { 
     
    353369 
    354370  private boolean isValidWellName(String filename) { 
     371    if (new Location(filename).getAbsoluteFile().isDirectory()) return false; 
    355372    String row = getRow(filename); 
    356373    String col = getColumn(filename); 
     
    366383 
    367384  private boolean isValidPlateName(String filename) { 
    368     return true; 
     385    return new Location(filename).isDirectory(); 
    369386  } 
    370387 
     
    431448  } 
    432449 
     450  private boolean hasValidWells(Location plate) { 
     451    if (!plate.isDirectory()) return false; 
     452    String[] wells = plate.list(true); 
     453    for (String well : wells) { 
     454      if (isValidWellName(new Location(plate, well).getAbsolutePath())) { 
     455        return true; 
     456      } 
     457    } 
     458    return false; 
     459  } 
     460 
    433461  private String getRow(String well) { 
    434462    String wellName = well.substring(well.lastIndexOf(File.separator) + 1); 
     463    char firstChar = Character.toUpperCase(wellName.charAt(0)); 
     464    while (wellName.indexOf("_") > 0 && (firstChar < 'A' || firstChar > 'P')) { 
     465      wellName = wellName.substring(wellName.indexOf("_") + 1); 
     466      firstChar = Character.toUpperCase(wellName.charAt(0)); 
     467    } 
    435468    return wellName.substring(0, 1).toUpperCase(); 
    436469  } 
     
    438471  private String getColumn(String well) { 
    439472    String wellName = well.substring(well.lastIndexOf(File.separator) + 1); 
    440     return wellName.substring(1); 
     473    char firstChar = Character.toUpperCase(wellName.charAt(0)); 
     474    while (wellName.indexOf("_") > 0 && (firstChar < 'A' || firstChar > 'P')) { 
     475      wellName = wellName.substring(wellName.indexOf("_") + 1); 
     476      firstChar = Character.toUpperCase(wellName.charAt(0)); 
     477    } 
     478    int end = wellName.lastIndexOf("_"); 
     479    if (end < 0) end = wellName.lastIndexOf("."); 
     480    if (end < 0) end = wellName.length(); 
     481    return wellName.substring(1, end); 
    441482  } 
    442483 
Note: See TracChangeset for help on using the changeset viewer.