@Override public String[] getSeriesUsedFiles(boolean noPixels) { if (noPixels) { return parameterFile == null ? null : new String[] {parameterFile}; } String id = new Location(currentId).getAbsolutePath(); return parameterFile == null ? new String[] {id} : new String[] {id, parameterFile}; }
private static String findCaseInsensitive(Location name) throws IOException { // The file we're looking for doesn't exist, so look for it in the // same directory in a case-insensitive manner. Note that this will // throw an exception if multiple copies are found. return cache.lookup(name.getAbsoluteFile()).getAbsolutePath(); }
/** * Return a list of absolute files in this directory. Hidden files will * be included in the list. * If this is not a directory, return null. */ public Location[] listFiles() { String[] s = list(); if (s == null) return null; Location[] f = new Location[s.length]; for (int i=0; i<f.length; i++) { f[i] = new Location(getAbsolutePath(), s[i]); f[i] = f[i].getAbsoluteFile(); } return f; }
/** Initialize the dataset from a .res file. */ private void initResFile(String id) throws FormatException, IOException { LOGGER.debug("initResFile({})", id); parseResFile(id); Location thisFile = new Location(id).getAbsoluteFile(); Location parent = thisFile.getParentFile(); LOGGER.debug(" Looking for an .mea file in {}", parent.getAbsolutePath()); String[] list = parent.list(); for (String file : list) { if (checkSuffix(file, MEA_SUFFIX)) { String mea = new Location(parent, file).getAbsolutePath(); LOGGER.debug(" Found .mea file {}", mea); initMeaFile(mea); if (!measurementFiles.contains(thisFile.getAbsolutePath())) { measurementFiles.add(thisFile.getAbsolutePath()); } return; } } throw new FormatException("Could not find an .mea file."); }
@Override public String[] getSeriesUsedFiles(boolean noPixels) { FormatTools.assertId(currentId, true, 1); String dir = pixelsFiles.get(getSeries()); Location realDir = new Location(dir).getParentFile(); realDir = realDir.getParentFile(); realDir = realDir.getParentFile(); dir = realDir.getAbsolutePath(); ArrayList<String> files = new ArrayList<String>(); files.add(new Location(getCurrentFile()).getAbsolutePath()); for (String f : allFiles) { if (f.startsWith(dir) && (!f.endsWith("2dseq") || !noPixels)) { if (!files.contains(f)) { files.add(f); } } } return files.toArray(new String[files.size()]); }
private String locateExperimentFile(String id) throws FormatException, IOException { if (!checkSuffix(id, "exp")) { Location parent = new Location(id).getAbsoluteFile().getParentFile(); if (checkSuffix(id, "tif")) parent = parent.getParentFile(); Location expFile = new Location(parent, EXPERIMENT_FILE); if (expFile.exists()) { return expFile.getAbsolutePath(); } throw new FormatException("Could not find " + EXPERIMENT_FILE + " in " + parent.getAbsolutePath()); } return id; }
@Override public String[] getSeriesUsedFiles(boolean noPixels) { if (noPixels) { return parameterFile == null ? null : new String[] {parameterFile}; } String id = new Location(currentId).getAbsolutePath(); return parameterFile == null ? new String[] {id} : new String[] {id, parameterFile}; }
/** * Return a list of files in this directory, or null if this file is * not a directory. * * @return a list of absolute files in this directory. Hidden files will * be included in the list. If this is not a directory, return null. * @see #list() */ public Location[] listFiles() { String[] s = list(); if (s == null) return null; Location[] f = new Location[s.length]; for (int i=0; i<f.length; i++) { f[i] = new Location(getAbsolutePath(), s[i]); f[i] = f[i].getAbsoluteFile(); } return f; }
@Override public String[] getSeriesUsedFiles(boolean noPixels) { FormatTools.assertId(currentId, true, 1); String dir = pixelsFiles.get(getSeries()); Location realDir = new Location(dir).getParentFile(); realDir = realDir.getParentFile(); realDir = realDir.getParentFile(); dir = realDir.getAbsolutePath(); ArrayList<String> files = new ArrayList<String>(); files.add(new Location(getCurrentFile()).getAbsolutePath()); for (String f : allFiles) { if (f.startsWith(dir) && (!f.endsWith("2dseq") || !noPixels)) { if (!files.contains(f)) { files.add(f); } } } return files.toArray(new String[files.size()]); }
private static String findCaseInsensitive(Location name) throws IOException { // The file we're looking for doesn't exist, so look for it in the // same directory in a case-insensitive manner. Note that this will // throw an exception if multiple copies are found. return cache.lookup(name.getAbsoluteFile()).getAbsolutePath(); }
private String locateExperimentFile(String id) throws FormatException, IOException { if (!checkSuffix(id, "exp")) { Location parent = new Location(id).getAbsoluteFile().getParentFile(); if (checkSuffix(id, "tif")) parent = parent.getParentFile(); Location expFile = new Location(parent, EXPERIMENT_FILE); if (expFile.exists()) { return expFile.getAbsolutePath(); } throw new FormatException("Could not find " + EXPERIMENT_FILE + " in " + parent.getAbsolutePath()); } return id; }
/** * Return the absolute form of this abstract location. * * @return a Location representing @see #getAbsolutePath * @see java.io.File#getAbsoluteFile() */ public Location getAbsoluteFile() { return new Location(getAbsolutePath()); }
private String[][] getTiffs() { final List<List<String>> files = new ArrayList<List<String>>(); Pattern p = Pattern.compile(".* - n\\d\\d\\d\\d\\d\\d\\.tif"); int nextWell = 0; for (String filename : rootList) { Location file = new Location(filename).getAbsoluteFile(); if (file.getName().startsWith("Well ") && file.isDirectory()) { String[] list = wellList.get(nextWell++); final List<String> tiffList = new ArrayList<String>(); for (String tiff : list) { if (p.matcher(tiff).matches()) { tiffList.add(new Location(file, tiff).getAbsolutePath()); } } files.add(tiffList); } } String[][] tiffFiles = new String[files.size()][]; for (int i=0; i<tiffFiles.length; i++) { tiffFiles[i] = files.get(i).toArray(new String[0]); } return tiffFiles; }
/** * Translate a file path from the XML file to an actual path on disk. * The path stored in the XML file may not have the same case as the path on * disk (typically all lower case on disk and possibly mixed case in XML). * If a matching file cannot be found, then the path from the XML file is returned. * * Uses {@link #directoryCache} so that any given directory is only listed once * per initialization, not once per lookup. */ private String lookup(String src) { Location f = new Location(src); String parent = f.getParent(); String name = f.getName(); String[] list = directoryCache.get(parent); if (list == null) { list = f.getParentFile().list(); Arrays.sort(list); directoryCache.put(parent, list); } for (String s : list) { if (s.equalsIgnoreCase(name)) { return new Location(f.getParentFile(), s).getAbsolutePath(); } } return src; }
/** Initialize the dataset from a .res file. */ private void initResFile(String id) throws FormatException, IOException { LOGGER.debug("initResFile({})", id); parseResFile(id); Location thisFile = new Location(id).getAbsoluteFile(); Location parent = thisFile.getParentFile(); LOGGER.debug(" Looking for an .mea file in {}", parent.getAbsolutePath()); String[] list = parent.list(); for (String file : list) { if (checkSuffix(file, MEA_SUFFIX)) { String mea = new Location(parent, file).getAbsolutePath(); LOGGER.debug(" Found .mea file {}", mea); initMeaFile(mea); if (!measurementFiles.contains(thisFile.getAbsolutePath())) { measurementFiles.add(thisFile.getAbsolutePath()); } return; } } throw new FormatException("Could not find an .mea file."); }
public Location getAbsoluteFile() { return new Location(getAbsolutePath()); }
private String[][] getTiffs() { final List<List<String>> files = new ArrayList<List<String>>(); Pattern p = Pattern.compile(".* - n\\d\\d\\d\\d\\d\\d\\.tif"); int nextWell = 0; for (String filename : rootList) { Location file = new Location(filename).getAbsoluteFile(); if (file.getName().startsWith("Well ") && file.isDirectory()) { String[] list = wellList.get(nextWell++); final List<String> tiffList = new ArrayList<String>(); for (String tiff : list) { if (p.matcher(tiff).matches()) { tiffList.add(new Location(file, tiff).getAbsolutePath()); } } files.add(tiffList); } } String[][] tiffFiles = new String[files.size()][]; for (int i=0; i<tiffFiles.length; i++) { tiffFiles[i] = files.get(i).toArray(new String[0]); } return tiffFiles; }
/** * Translate a file path from the XML file to an actual path on disk. * The path stored in the XML file may not have the same case as the path on * disk (typically all lower case on disk and possibly mixed case in XML). * If a matching file cannot be found, then the path from the XML file is returned. * * Uses {@link #directoryCache} so that any given directory is only listed once * per initialization, not once per lookup. */ private String lookup(String src) { Location f = new Location(src); String parent = f.getParent(); String name = f.getName(); String[] list = directoryCache.get(parent); if (list == null) { list = f.getParentFile().list(); Arrays.sort(list); directoryCache.put(parent, list); } for (String s : list) { if (s.equalsIgnoreCase(name)) { return new Location(f.getParentFile(), s).getAbsolutePath(); } } return src; }
/** * Works like {@link #findSeriesPatterns(String, String, String[])}, * but dir and nameList are inferred from the given file's absolute * path. * * @param base The file basename to use as a template for the match. * @return an array containing all identified patterns. */ public static String[] findSeriesPatterns(String base) { Location file = new Location(base).getAbsoluteFile(); Location parent = file.getParentFile(); String[] list = parent.list(true); if (list == null) { list = new String[0]; } return findSeriesPatterns(base, parent.getAbsolutePath(), list); }
/** Add the given file to the used files list. */ private void addUsedFile(String workingDirPath, String file) { if (file == null) return; Location f = new Location(workingDirPath, file); if (!workingDirPath.equals("")) allFiles.add(f.getAbsolutePath()); else allFiles.add(file); }