public class Config extends Object
Constructor and Description |
---|
Config() |
Modifier and Type | Method and Description |
---|---|
static boolean |
getBoolean(BioModule module,
String property)
Parse property value (Y or N) to return boolean, if not found, return false;
|
static String |
getConfigFileExt()
Gets the configuration file extension (often ".properties")
|
static String |
getConfigFileName()
Gets the configuration file name
|
static String |
getConfigFilePath()
Gets the full Config file path passed to BioLockJ as a runtime parameter.
|
static Double |
getDoubleVal(BioModule module,
String property)
Parse property for numeric (double) value
|
static String |
getExe(BioModule module,
String property)
Get exe.* property name.
|
static String |
getExeParams(BioModule module,
String property)
Call this function to get the parameters configured for this property.
Make sure the last character for non-null results is an empty character for use in bash scripts calling the corresponding executable. |
static File |
getExistingDir(BioModule module,
String property)
Get a valid File directory or return null
|
static File |
getExistingFile(BioModule module,
String property)
Get a valid File or return null.
|
protected static File |
getExistingFileObject(String filePath)
Build File using filePath.
|
static TreeMap<String,String> |
getInitialProperties()
Get initial properties ordered by property
|
static List<String> |
getList(BioModule module,
String property)
Parse comma delimited property value to return list
|
static String |
getModuleProp(BioModule module,
String prop)
Return module specific property if configured, otherwise use the given prop.
|
static String |
getModuleProp(String moduleName,
String prop)
Return module specific property if configured, otherwise use the given prop.
|
static Integer |
getNonNegativeInteger(BioModule module,
String property)
Parse property as non-negative integer value
|
static Double |
getPositiveDoubleVal(BioModule module,
String property)
Parse property as positive double value
|
static Integer |
getPositiveInteger(BioModule module,
String property)
Parse property as positive integer value
|
static TreeMap<String,String> |
getProperties()
Get current properties ordered by property
|
static Set<String> |
getSet(BioModule module,
String property)
Parse comma-separated property value to build an unordered Set
|
static String |
getString(BioModule module,
String property)
Get property value as String.
|
static Set<String> |
getTreeSet(BioModule module,
String property)
Parse comma-separated property value to build an ordered Set
|
static Map<String,String> |
getUsedProps()
Cache of the properties used in this pipeline.
|
static void |
initialize()
Initialize
Config by reading in properties from config runtime parameter. |
static boolean |
isOnCluster()
Check if running on cluster
|
static String |
pipelineName()
Get the current pipeline name (root folder name)
|
static String |
pipelinePath()
Get the current pipeline absolute directory path (root folder path)
|
static String |
replaceEnvVar(String arg)
Interpret env variable if included in the arg string, otherwise return the arg.
|
protected static Properties |
replaceEnvVars(Properties properties)
Interpret env variables defined in the Config file and runtime env - for example
These props are used in: $BLJ/resources/config/defult/docker.properties: BLJ_ROOT=/mnt/efs EFS_DB=${BLJ_ROOT}/db humann2.protDB=${EFS_DB}/uniref Therefore, getString( "humann2.protDB" ) returns "/mnt/efs/db/uniref" If not found, check runtiem env (i.e., $HOME/bash_profile) |
static boolean |
requireBoolean(BioModule module,
String property)
Required to return a valid boolean or
|
static Double |
requireDoubleVal(BioModule module,
String property)
Requires valid double value
|
static File |
requireExistingDir(BioModule module,
String property)
Requires valid existing directory.
|
static List<File> |
requireExistingDirs(BioModule module,
String property)
Requires valid list of file directories
|
static File |
requireExistingFile(BioModule module,
String property)
Require valid existing file
|
static Integer |
requireInteger(BioModule module,
String property)
Requires valid integer value
|
static List<String> |
requireList(BioModule module,
String property)
Require valid list property
|
static Double |
requirePositiveDouble(BioModule module,
String property)
Require valid positive double value
|
static Integer |
requirePositiveInteger(BioModule module,
String property)
Require valid positive integer value
|
static Set<String> |
requireSet(BioModule module,
String property)
Require valid Set value
|
static String |
requireString(BioModule module,
String property)
Require valid String value
|
static void |
setConfigProperty(String name,
Collection<?> data)
Sets a property value in the props cache as a list
|
static void |
setConfigProperty(String name,
String val)
Sets a property value in the props cache
|
static void |
setPipelineDir(File dir)
Set the root pipeline directory path
|
protected static void |
setPipelineRootDir()
Set Create a pipeline root directory if the pipeline is new.
|
public static boolean getBoolean(BioModule module, String property) throws ConfigFormatException
module
- Source BioModule calling this functionproperty
- Property nameConfigFormatException
- if property value is not null but also not Y or N.public static String getConfigFileExt()
public static String getConfigFileName()
public static String getConfigFilePath()
public static Double getDoubleVal(BioModule module, String property) throws ConfigFormatException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigFormatException
- if property is defined, but set with a non-numeric valuepublic static String getExe(BioModule module, String property) throws Exception
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameException
- if property does not start with "exe."public static String getExeParams(BioModule module, String property) throws Exception
module
- Calling moduleproperty
- exe parameter nameException
- if errors occurpublic static File getExistingDir(BioModule module, String property) throws Exception
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameException
- if path is defined but is not an existing directory or other errors occurpublic static File getExistingFile(BioModule module, String property) throws Exception
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameException
- if path is defined but is not an existing file or if other errors occurpublic static TreeMap<String,String> getInitialProperties()
public static List<String> getList(BioModule module, String property)
module
- BioModule to check for module-specific form of this propertyproperty
- Property namepublic static String getModuleProp(BioModule module, String prop)
module
- BioModuleprop
- Propertypublic static String getModuleProp(String moduleName, String prop)
moduleName
- BioModule nameprop
- Propertypublic static Integer getNonNegativeInteger(BioModule module, String property) throws ConfigFormatException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigFormatException
- if defined but is not a non-negative integer valuepublic static Double getPositiveDoubleVal(BioModule module, String property) throws ConfigFormatException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigFormatException
- if property is defined, but not set with a positive numberpublic static Integer getPositiveInteger(BioModule module, String property) throws ConfigFormatException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigFormatException
- if property is defined, but not set with a positive integerpublic static TreeMap<String,String> getProperties()
public static Set<String> getSet(BioModule module, String property)
module
- BioModule to check for module-specific form of this propertyproperty
- Property namepublic static String getString(BioModule module, String property)
module
- BioModule to check for module-specific form of this propertyproperty
- Config
file property namepublic static Set<String> getTreeSet(BioModule module, String property)
module
- BioModule to check for module-specific form of this propertyproperty
- Property namepublic static Map<String,String> getUsedProps()
public static void initialize() throws Exception
Config
by reading in properties from config runtime parameter.Exception
- if unable to load Propspublic static boolean isOnCluster()
public static String pipelineName()
public static String pipelinePath()
public static String replaceEnvVar(String arg)
arg
- Property or runtime argumentpublic static boolean requireBoolean(BioModule module, String property) throws ConfigNotFoundException, ConfigFormatException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigNotFoundException
- if propertyName is undefinedConfigFormatException
- if property is defined, but not set to a boolean valuepublic static Double requireDoubleVal(BioModule module, String property) throws ConfigNotFoundException, ConfigFormatException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigNotFoundException
- if property is undefinedConfigFormatException
- if property is defined, but set with a non-numeric valuepublic static File requireExistingDir(BioModule module, String property) throws Exception
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameException
- if property is undefined or if property is not a valid directory pathpublic static List<File> requireExistingDirs(BioModule module, String property) throws Exception
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameException
- if errors occurpublic static File requireExistingFile(BioModule module, String property) throws Exception
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameException
- if property is undefined or if property is not a valid file pathpublic static Integer requireInteger(BioModule module, String property) throws ConfigNotFoundException, ConfigFormatException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigNotFoundException
- if property is undefinedConfigFormatException
- if property is not a valid integerpublic static List<String> requireList(BioModule module, String property) throws ConfigNotFoundException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigNotFoundException
- if property is undefinedpublic static Double requirePositiveDouble(BioModule module, String property) throws ConfigNotFoundException, ConfigFormatException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigNotFoundException
- if property is undefinedConfigFormatException
- if property is defined, but not set to a positive numeric valuepublic static Integer requirePositiveInteger(BioModule module, String property) throws ConfigNotFoundException, ConfigFormatException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigNotFoundException
- if property is undefinedConfigFormatException
- if property is defined, but not set to a positive integer valuepublic static Set<String> requireSet(BioModule module, String property) throws ConfigNotFoundException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigNotFoundException
- if property is undefinedpublic static String requireString(BioModule module, String property) throws ConfigNotFoundException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigNotFoundException
- if property is undefinedpublic static void setConfigProperty(String name, Collection<?> data)
name
- Property namedata
- Collection of data to store using the key = propertypublic static void setConfigProperty(String name, String val)
name
- Property nameval
- Value to assign to propertypublic static void setPipelineDir(File dir)
dir
- Pipeline directory pathprotected static File getExistingFileObject(String filePath) throws Exception
filePath
- File pathException
- if path is defined but is not found on the file system or other errors occurprotected static Properties replaceEnvVars(Properties properties)
properties
- All Config Properties