List of usage examples for org.apache.commons.lang SystemUtils FILE_SEPARATOR
String FILE_SEPARATOR
To view the source code for org.apache.commons.lang SystemUtils FILE_SEPARATOR.
Click Source Link
The file.separator
System Property.
From source file:org.apache.ctakes.jdl.common.FileUtilTest.java
@Theory public void fullPath(String fileName) throws IOException { for (String token : FileUtil.getJavaClassPaths()) { assertThat(FileUtil.fullPath(new File(token), fileName), is(new File(token + SystemUtils.FILE_SEPARATOR + fileName).getCanonicalPath())); }/*w w w .j a v a2s .c om*/ }
From source file:org.apache.forrest.conf.ForrestConfModule.java
public void initialize() throws Exception { // add all homes important to forrest to the properties setHomes();//from w w w. jav a2 s .c o m loadSystemProperties(filteringProperties); // NOTE: the first values set get precedence, as in AntProperties String forrestPropertiesStringURI; try { // get forrest.properties and load the values forrestPropertiesStringURI = projectHome + SystemUtils.FILE_SEPARATOR + "forrest.properties"; filteringProperties = loadAntPropertiesFromURI(filteringProperties, forrestPropertiesStringURI); // get the values from local.forrest.properties.xml forrestPropertiesStringURI = projectHome + SystemUtils.FILE_SEPARATOR + "local.forrest.properties.xml"; filteringProperties = loadXMLPropertiesFromURI(filteringProperties, forrestPropertiesStringURI); // get the values from project forrest.properties.xml forrestPropertiesStringURI = projectHome + SystemUtils.FILE_SEPARATOR + "forrest.properties.xml"; filteringProperties = loadXMLPropertiesFromURI(filteringProperties, forrestPropertiesStringURI); // get the values from user forrest.properties.xml String userHome = filteringProperties.getProperty("user.home"); if (userHome != null) { forrestPropertiesStringURI = userHome + SystemUtils.FILE_SEPARATOR + "forrest.properties.xml"; filteringProperties = loadXMLPropertiesFromURI(filteringProperties, forrestPropertiesStringURI); } // get the values from global forrest.properties.xml String globalHome = filteringProperties.getProperty("global.home"); if (globalHome != null) { forrestPropertiesStringURI = globalHome + SystemUtils.FILE_SEPARATOR + "forrest.properties.xml"; filteringProperties = loadXMLPropertiesFromURI(filteringProperties, forrestPropertiesStringURI); } // get the values from default.forrest.properties.xml forrestPropertiesStringURI = contextHome + SystemUtils.FILE_SEPARATOR + "default.forrest.properties.xml"; filteringProperties = loadXMLPropertiesFromURI(filteringProperties, forrestPropertiesStringURI); // Load plugin default properties String strPluginList = filteringProperties.getProperty("project.required.plugins"); if (strPluginList != null) { StringTokenizer st = new StringTokenizer(strPluginList, ","); while (st.hasMoreTokens()) { forrestPropertiesStringURI = ForrestConfUtils.getPluginDir(st.nextToken().trim()); forrestPropertiesStringURI = forrestPropertiesStringURI + SystemUtils.FILE_SEPARATOR + "default.plugin.properties.xml"; filteringProperties = loadXMLPropertiesFromURI(filteringProperties, forrestPropertiesStringURI); } } // get default-forrest.properties and load the values String defaultForrestPropertiesStringURI = contextHome + SystemUtils.FILE_SEPARATOR + "default-forrest.properties"; filteringProperties = loadAntPropertiesFromURI(filteringProperties, defaultForrestPropertiesStringURI); } finally { ForrestConfUtils.aliasSkinProperties(filteringProperties); if (debugging()) debug("Loaded project properties:" + filteringProperties); } }
From source file:org.apache.forrest.conf.ForrestConfUtils.java
public static String getProjectHome() throws Exception { String projectHome = getSystemProperty("project.home"); if (projectHome.equals(defaultHome)) { projectHome = defaultHome + SystemUtils.FILE_SEPARATOR + "/project"; }/*from w ww .j a v a2 s . co m*/ return projectHome; }
From source file:org.apache.forrest.conf.ForrestConfUtils.java
public static String getContextHome() throws Exception { String forrestHome = getForrestHome(); String contextHome;/*from w ww . j av a 2s .co m*/ if (forrestHome.equals(defaultHome)) { contextHome = defaultHome; } else { //FIXME: HARDCODE VALUE // contextHome = forrestHome + SystemUtils.FILE_SEPARATOR + "main/webapp"; } return contextHome; }
From source file:org.apache.forrest.conf.ForrestConfUtils.java
/** * Get the directory in which a given plugin is located. * @param name of the plugin to locate/*ww w . ja v a2 s . c o m*/ * @return * @throws Exception */ public static String getPluginDir(String name) throws Exception { String forrestHome = getForrestHome(); //FIXME: HARDCODE VALUE // return forrestHome + SystemUtils.FILE_SEPARATOR + "build" + SystemUtils.FILE_SEPARATOR + "plugins" + SystemUtils.FILE_SEPARATOR + name; }
From source file:org.bdval.ConsensusBDVModel.java
/** * Loads the juror models used for consensus. * @param options specific options to use when loading the model * @throws IOException if there is a problem accessing the model * @throws ClassNotFoundException if the type of the model is not recognized *//*from w w w .j av a 2 s . c o m*/ private void loadJurorModels(final DAVOptions options) throws IOException, ClassNotFoundException { jurorModels.clear(); final String pathToModel = FilenameUtils.getFullPath(modelFilename); final String endpointName = FilenameUtils.getBaseName(FilenameUtils.getPathNoEndSeparator(pathToModel)); if (properties.getBoolean("bdval.consensus.jurors.embedded", false)) { final File tmpdir = File.createTempFile("juror-models", ""); tmpdir.delete(); tmpdir.mkdir(); try { // load juror models from the zip file final ZipFile zipFile = new ZipFile(zipFilename); for (final String jurorPrefix : jurorModelFilenamePrefixes) { // zip files should always use "/" as a separator final String jurorFilename = "models/" + endpointName + "/" + jurorPrefix + ".zip"; LOG.debug("Loading juror model " + jurorFilename); final InputStream jurorStream = zipFile.getInputStream(zipFile.getEntry(jurorFilename)); final File jurorFile = new File(FilenameUtils.concat(tmpdir.getPath(), jurorFilename)); // put the juror model to disk so it can be loaded with existing code IOUtils.copy(jurorStream, FileUtils.openOutputStream(jurorFile)); final BDVModel jurorModel = new BDVModel(jurorFile.getPath()); jurorModel.load(options); jurorModels.add(jurorModel); } } finally { FileUtils.forceDeleteOnExit(tmpdir); } } else { // load juror models from disk final File finalModelPath = new File(pathToModel); final File finalModelParentPath = new File(finalModelPath.getParent()); // assume the model is under a directory "models" at the same level as a models // directory which contains the model components. for (final String jurorPrefix : jurorModelFilenamePrefixes) { final String modelComponentFilename = finalModelParentPath.getParent() + SystemUtils.FILE_SEPARATOR + "models" + SystemUtils.FILE_SEPARATOR + endpointName + SystemUtils.FILE_SEPARATOR + jurorPrefix; LOG.debug("Loading model component " + modelComponentFilename); final BDVModel jurorModel = new BDVModel(modelComponentFilename); jurorModel.load(options); jurorModels.add(jurorModel); } } if (jurorModels.size() < 1) { throw new IllegalStateException("No juror models could be found"); } jurorModelsAreLoaded = true; }
From source file:org.bdval.DAVMode.java
/** * Define basic command line options for this mode. Individual modes should override * making sure that options are reused or removed appropriately. Options cannot * be defined more than once in {@link com.martiansoftware.jsap.JSAP}. * * @param jsap the JSAP command line parser * @throws JSAPException if there is a problem building the options */// w ww.j a va 2 s.c o m @Override public void defineOptions(final JSAP jsap) throws JSAPException { super.defineOptions(jsap); // help option is defined by the superclass call final Parameter inputFilenameOption = new FlaggedOption("input").setStringParser(JSAP.STRING_PARSER) .setDefault(JSAP.NO_DEFAULT).setRequired(true).setShortFlag('i').setLongFlag("input") .setHelp("Input filename. This file contains the measurement data used to" + " discover markers."); jsap.registerParameter(inputFilenameOption); final Parameter outputFlag = new FlaggedOption("output").setStringParser(JSAP.STRING_PARSER) .setDefault(JSAP.NO_DEFAULT).setRequired(false).setShortFlag('o').setLongFlag("output") .setHelp("Name of the output file. Output is printed to the console when this " + "flag is absent or when the value \"-\" is given."); jsap.registerParameter(outputFlag); final Parameter propertiesFlag = new FlaggedOption("properties").setStringParser(JSAP.STRING_PARSER) .setDefault(JSAP.NO_DEFAULT).setRequired(false) .setLongFlag("properties").setHelp( "Name of the properties file. A Java properties file with bdval specific configuration properties."); jsap.registerParameter(propertiesFlag); final Parameter outputOverwriteFlag = new FlaggedOption("overwrite-output") .setStringParser(JSAP.BOOLEAN_PARSER).setDefault("false").setRequired(true) .setLongFlag("overwrite-output") .setHelp("When true and -o is specified, the output file will be over-written."); jsap.registerParameter(outputOverwriteFlag); final Parameter modelIdFlag = new FlaggedOption("model-id").setStringParser(JSAP.STRING_PARSER) .setDefault("no_model_id").setRequired(false).setLongFlag("model-id") .setHelp("The model-id, created in ExecuteSplitsMode (a hash of the options)"); jsap.registerParameter(modelIdFlag); final Parameter tasksFlag = new FlaggedOption("task-list").setStringParser(JSAP.STRING_PARSER) .setDefault(JSAP.NO_DEFAULT).setRequired(true).setShortFlag('t').setLongFlag("task-list") .setHelp("Name of the file that describes the classification tasks. " + "This file is tab delimited, with one line per task. " + "First column is the input filename. " + "Second column is the name of the first condition. " + "Third column is the name of the second condition. " + "Fourth column is the number of samples in the first condition. " + "Fifth column is the number of samples in the second condition."); jsap.registerParameter(tasksFlag); final Parameter geneListsFlag = new FlaggedOption("gene-lists").setStringParser(JSAP.STRING_PARSER) .setDefault(JSAP.NO_DEFAULT).setRequired(false).setShortFlag('g').setLongFlag("gene-lists") .setHelp("Name of the file that describes the gene lists. " + "This file is tab delimited, with one line per gene list. " + "First column is the name of the gene list. " + "Second column (optional) is the name of the file which describes " + "the gene list. " + "If the file has only one column, the name of the gene list must be " + "full (for the full array). If the name of the gene " + "list is random, the second field indicates how many random probesets " + "must be selected, and a third field indicates the random seed to use " + "for probeset selection."); jsap.registerParameter(geneListsFlag); final Parameter geneListFlag = new FlaggedOption("gene-list").setStringParser(JSAP.STRING_PARSER) .setDefault(JSAP.NO_DEFAULT).setRequired(false).setLongFlag("gene-list") .setHelp("Argument of the form gene-list-name|filename. " + "The filename points to a single gene list file."); jsap.registerParameter(geneListFlag); final Parameter platformFlag = new FlaggedOption("platform-filenames").setStringParser(JSAP.STRING_PARSER) .setDefault(JSAP.NO_DEFAULT).setRequired(true).setShortFlag('p').setLongFlag("platform-filenames") .setHelp("Comma separated list of platform filenames."); jsap.registerParameter(platformFlag); final Parameter conditionFlag = new FlaggedOption("conditions").setStringParser(JSAP.STRING_PARSER) .setDefault(JSAP.NO_DEFAULT).setRequired(true).setShortFlag('c').setLongFlag("conditions") .setHelp("Specify the file with the mapping condition-name column-identifier " + "(tab delimited, with one mapping per line)."); jsap.registerParameter(conditionFlag); final Parameter seed = new FlaggedOption("seed").setStringParser(JSAP.INTEGER_PARSER) .setDefault(JSAP.NO_DEFAULT).setRequired(false).setLongFlag("seed") .setHelp("Seed to initialize random generator."); jsap.registerParameter(seed); final Parameter pathways = new FlaggedOption("pathways").setStringParser(JSAP.STRING_PARSER) .setDefault(JSAP.NO_DEFAULT).setRequired(false).setLongFlag("pathways") .setHelp("Filename of the pathway description information. " + "The pathway description information is a file with one line per " + "pathway. Each line has two tab delimited field. The first field provides a " + "pathway identifier. The second field is space delimited. Each token of the " + " second field is an " + "(Ensembl) gene ids for gene that belong to the pathway. " + "When this option is provided, features are aggregated by pathway " + "and computations are performed in aggregated feature space. " + "Some aggregation algorithms may generate several aggregated " + "features per pathway. When this option is active, the " + "option --gene2probes must be provided on the command line."); jsap.registerParameter(pathways); final Parameter pathwayAggregationMethod = new FlaggedOption("pathway-aggregation-method") .setStringParser(JSAP.STRING_PARSER).setDefault("PCA").setRequired(false) .setLongFlag("pathway-aggregation-method") .setHelp("Indicate which method should be used to aggregate features for pathway " + "runs. Two methods are available: PCA or average. PCA performs a " + "principal component analysis for the probesets of each pathway. " + "Average uses a single feature for each pathway calculated as the " + "average of the probeset signal in each pathway. Default is PCA."); jsap.registerParameter(pathwayAggregationMethod); final Parameter gene2Probes = new FlaggedOption("gene2probes").setStringParser(JSAP.STRING_PARSER) .setDefault(JSAP.NO_DEFAULT).setRequired(false).setLongFlag("gene-to-probes") .setHelp("Filename of the gene to probe description information. " + "The pathway description information is a file with one line per gene. " + "Each line is tab delimited. The first field is an ensembl gene id. " + "The second field is a probe id which measures expression of a " + "transcript of the gene. Several lines may share the same gene " + "id, indicating that multiple probe ids exist for the gene. "); jsap.registerParameter(gene2Probes); final Parameter floorParam = new FlaggedOption("floor").setStringParser(JSAP.DOUBLE_PARSER) .setDefault(JSAP.NO_DEFAULT).setRequired(false).setLongFlag("floor") .setHelp("Specify a floor value for the signal. If a signal is lower " + "than the floor, it is set to the floor. If no floor is provided, " + "values are unchanged."); jsap.registerParameter(floorParam); final Parameter twoChannelArray = new FlaggedOption("two-channel-array") .setStringParser(JSAP.BOOLEAN_PARSER).setDefault(JSAP.NO_DEFAULT).setRequired(false) .setLongFlag("two-channel-array") .setHelp("Indicate that the data is for a two channel array. This flag affects " + "how the floor value is interpreted. " + "For two channel arrays, values on the array are set to 1.0" + "if (Math.abs(oldValue-1.0)+1)<=floorValue, whereas for one channel " + "array the condition becomes: oldValue<=floorValue."); jsap.registerParameter(twoChannelArray); final Parameter log10Array = new FlaggedOption("log-10-array").setStringParser(JSAP.BOOLEAN_PARSER) .setDefault(JSAP.NO_DEFAULT).setRequired(false).setLongFlag("log-10-array") .setHelp("See --logged-array"); jsap.registerParameter(log10Array); final Parameter loggedArray = new FlaggedOption("logged-array").setStringParser(JSAP.BOOLEAN_PARSER) .setDefault(JSAP.NO_DEFAULT).setRequired(false).setLongFlag("logged-array") .setHelp("Indicate that the data on this array has been logged. This option " + "affects flooring for two color aryays. When the option is specified, " + "the floor is applied around a center value of zero. When the option " + "is not specified, two color arrays are floored around a value of 1 " + "(no change)."); jsap.registerParameter(loggedArray); final Parameter scalingOption = new FlaggedOption("scale-features").setStringParser(JSAP.BOOLEAN_PARSER) .setDefault("true").setRequired(false).setLongFlag("scale-features") .setHelp("Indicate whether the features should be scaled to the range [-1 1]. " + "If false, no scaling occurs. If true (default), features are scaled."); jsap.registerParameter(scalingOption); final Parameter percentileScalingOption = new FlaggedOption("percentile-scaling") .setStringParser(JSAP.BOOLEAN_PARSER).setDefault("false").setRequired(false) .setLongFlag("percentile-scaling") .setHelp("Indicate whether feature scaling is done with percentile and median " + "or full range and average. When percentiles are used, the range " + "of each feature is determined as the range of the " + "20-80 percentile of the data and median is used instead of the mean."); jsap.registerParameter(percentileScalingOption); final Parameter scalerClassName = new FlaggedOption("scaler-class-name").setStringParser(JSAP.STRING_PARSER) .setRequired(false).setLongFlag("scaler-class-name") .setHelp("The classname of the scaler implementation. Overrides " + "--percentile-scaling if provided."); jsap.registerParameter(scalerClassName); final Parameter normalizeOption = new FlaggedOption("normalize-features") .setStringParser(JSAP.BOOLEAN_PARSER).setDefault("false").setRequired(false) .setLongFlag("normalize-features") .setHelp("Indicate whether the feature vectors should be normalized. If false, " + "no normalizing occurs. If true (default), features are normalized."); jsap.registerParameter(normalizeOption); final Parameter classifierClassName = new FlaggedOption("classifier").setStringParser(JSAP.CLASS_PARSER) .setDefault(LibSvmClassifier.class.getCanonicalName()).setRequired(false).setShortFlag('l') .setLongFlag("classifier").setHelp("Fully qualified class name of the classifier implementation."); jsap.registerParameter(classifierClassName); final Parameter classifierParameterArgument = new FlaggedOption("classifier-parameters") .setStringParser(JSAP.STRING_PARSER).setDefault(JSAP.NO_DEFAULT).setRequired(false) .setAllowMultipleDeclarations(true).setShortFlag('a').setLongFlag("classifier-parameters") .setHelp("Comma separated list of parameters that will be passed to the " + "classifier. Parameters vary from one classifier to the next. Check " + "the documentation of the classifier and the source code to see " + "which parameters can be set."); jsap.registerParameter(classifierParameterArgument); final Parameter geneFeaturesDirArgument = new FlaggedOption("gene-features-dir") .setStringParser(JSAP.STRING_PARSER).setDefault("." + SystemUtils.FILE_SEPARATOR).setRequired(false) .setLongFlag("gene-features-dir") .setHelp("The directory where gene features files will be read from" + " (when specified in a -gene-lists.txt file)."); jsap.registerParameter(geneFeaturesDirArgument); final Parameter datasetNameArgument = new FlaggedOption("dataset-name").setStringParser(JSAP.STRING_PARSER) .setRequired(false).setDefault("dataset-name").setLongFlag("dataset-name") .setHelp("The name of the dataset being run."); jsap.registerParameter(datasetNameArgument); // TODO: ?? Could we be more precise here. An example? final Parameter datasetRootArgument = new FlaggedOption("dataset-root").setStringParser(JSAP.STRING_PARSER) .setRequired(false).setDefault("ds-root").setLongFlag("dataset-root") .setHelp("The root directory where the dataset files exist."); jsap.registerParameter(datasetRootArgument); final Switch outputStatsFromGeneListSwitch = new Switch("output-stats-from-gene-list") .setLongFlag("output-stats-from-gene-list"); jsap.registerParameter(outputStatsFromGeneListSwitch); final Parameter rservePortFlag = new FlaggedOption("rserve-port").setStringParser(JSAP.INTEGER_PARSER) .setDefault("-1").setRequired(false).setLongFlag("rserve-port").setHelp("The Rserve port to use"); jsap.registerParameter(rservePortFlag); final Parameter splitIdParam = new FlaggedOption("process-split-id").setStringParser(JSAP.INTEGER_PARSER) .setRequired(false).setLongFlag("process-split-id") .setHelp("Restricts execution to a split id. A split execution plan must be " + "provided as well. The split id is used together with the split plan to " + "determine which samples should be processed. Typical usage would be " + "\"--process-split-id 2 --split-plan theplan.txt --split-type training\" " + "This would result in training samples being used that match split #2 " + "in theplan.txt."); jsap.registerParameter(splitIdParam); final Parameter splitPlanParam = new FlaggedOption("split-plan").setStringParser(JSAP.STRING_PARSER) .setRequired(false).setLongFlag("split-plan") .setHelp("Filename for the split plan definition. See process-split-id."); jsap.registerParameter(splitPlanParam); final Parameter splitTypeParam = new FlaggedOption("split-type").setStringParser(JSAP.STRING_PARSER) .setRequired(false).setLongFlag("split-type") .setHelp("Split type (i.e., training, test, feature-selection, must match " + "a type listed in the split plan). See process-split-id."); jsap.registerParameter(splitTypeParam); final Parameter cacheDirParam = new FlaggedOption("cache-dir").setStringParser(JSAP.STRING_PARSER) .setDefault("cache").setRequired(true).setLongFlag("cache-dir") .setHelp("Cache directory. Specify a directory when intermediate processed " + "tables will be saved for faster access."); jsap.registerParameter(cacheDirParam); final Parameter cacheEnabledParam = new Switch("cache-enabled").setLongFlag("enable-cache") .setHelp("Enables caching for faster access to processed tables."); jsap.registerParameter(cacheEnabledParam); final Parameter pathwayComponentDirParam = new FlaggedOption("pathway-components-dir") .setStringParser(JSAP.STRING_PARSER).setDefault("pathway-components").setRequired(false) .setLongFlag("pathway-components-dir") .setHelp("Directory where pathway components will be stored. "); jsap.registerParameter(pathwayComponentDirParam); }
From source file:org.bdval.TestDAVMode.java
/** * Validates that the cache is created properly in DAVMode when enabled. * @throws JSAPException If there was a problem setting up the test * @throws IOException If there was a problem with the cache * @throws ColumnTypeException If there was a problem reading the tables * @throws InvalidColumnException If there was a problem reading the tables * @throws TypeMismatchException If there was a problem reading the tables *//* w w w.j av a 2 s. c om*/ @Test public void testTableCacheEnabled() throws IOException, JSAPException, InvalidColumnException, ColumnTypeException, TypeMismatchException { final String cacheDirectoryName = getTempCacheDirectory(); final String inputFileName = "test-data/test.tmm.gz"; final String[] args = { "--enable-cache", "--cache-dir", cacheDirectoryName, "--input", inputFileName }; final DAVMode davMode = new DAVMode(); final DAVOptions davOptions = new DAVOptions(); final JSAP jsap = new JSAP(); davMode.defineOptions(jsap); final JSAPResult jsapResult = jsap.parse(args); davMode.setupTableCache(jsapResult, davOptions); final File cacheDirectory = new File(cacheDirectoryName); assertTrue("Cache directory should have been created", cacheDirectory.exists()); // create the actual cache directory davMode.setupPathwayOptions(jsapResult, davOptions); davMode.setupInput(jsapResult, davOptions); davMode.processTable(new FullGeneList(null), davOptions.inputTable, davOptions, new ArrayList<Set<String>>(), true); final File cacheFile = new File(FilenameUtils.concat(cacheDirectoryName, "pathways=false" + SystemUtils.FILE_SEPARATOR + "cached-table-null-complete-0.bin")); assertTrue("Cache file should have been created", cacheFile.exists()); final TableCache tableCache = new TableCache( new File(FilenameUtils.concat(cacheDirectoryName, "pathways=false"))); assertTrue("Table should be cached at this point", tableCache.isTableCached(0, null, null)); // note that the cached table is not the same as the input dataset Table table = tableCache.getCachedTable(0, null, null); assertNotNull("The table from the cache should not be null", table); assertEquals("There should be 6 columns", 6, table.getColumnNumber()); assertEquals("There should be 2 rows", 2, table.getRowNumber()); davMode.removeFromCache(0, null, null); assertFalse("Cache file should have been deleted", cacheFile.exists()); assertFalse("Table should no longer be cached at this point", tableCache.isTableCached(0, null, null)); table = tableCache.getCachedTable(0, null, null); assertNull("The table from the cache should be null", table); }
From source file:org.caleydo.data.importer.tcga.FirehoseProvider.java
private File createTempDirectory(String tmpOutputDirectory, Date run, String tumor) { String runId;/*from ww w . j a va 2s . c o m*/ if (run == null) runId = "unknown"; else { runId = Settings.formatClean(run); } return new File( tmpOutputDirectory + runId + SystemUtils.FILE_SEPARATOR + tumor + SystemUtils.FILE_SEPARATOR); }
From source file:org.exem.flamingo.agent.nn.hdfs.HdfsFileInfo.java
public static String getPath(String fullyQualifiedPath) { int sep = fullyQualifiedPath.lastIndexOf(SystemUtils.FILE_SEPARATOR); if (sep != 0) { return fullyQualifiedPath.substring(0, sep); }//from www . j a v a 2 s . c om return SystemUtils.FILE_SEPARATOR; }