public class Config extends Object
Modifier and Type | Field and Description |
---|---|
static String |
BLJ_BASH_VAR |
static String |
BLJ_PROJ_VAR |
(package private) static Properties |
props |
Constructor and Description |
---|
Config() |
Modifier and Type | Method and Description |
---|---|
static void |
checkDependencies(BioModule module) |
static String |
convertRelativePath(String filePath,
File CONFIG_DOT)
Given a relative path (ie, one that starts with "."), get the absolute path---even when runnig in docker.
|
static String |
convertWindowsPathForDocker(String path) |
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 |
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 Map<String,String> |
getEnvVarMap()
Return the String, String map of environment variables and their values.
|
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.
|
static List<File> |
getExistingFileList(BioModule module,
String property) |
static File |
getExistingFileObject(BioModule module,
String property)
Build File using module and property name.
|
static File |
getExistingFileObjectFromPath(String filePath)
Build File using filePath.
|
static File |
getExistingFileObjectFromPath(String filePath,
boolean convertRelativePath,
boolean containerizePath)
Build File using filePath.
|
static File |
getFileObjectFromPath(String filePath,
boolean convertRelativePath,
boolean containerizePath)
Build File using filePath.
|
static TreeMap<String,String> |
getInitialProperties()
Get initial properties ordered by property
|
static Integer |
getIntegerProp(BioModule module,
String property)
Parse property value as integer
|
static List<String> |
getList(BioModule module,
String property)
Parse comma delimited property value to return list
|
static File |
getLocalConfigFile(String path)
Return file for path after modifying if running in a Docker container and/or interpreting bash env vars.
|
static String |
getModuleFormProp(BioModule module,
String property) |
static String |
getModulePropName(BioModule module,
String property)
Return property name after substituting the module name as its prefix.
|
static Integer |
getNonNegativeInteger(BioModule module,
String property)
Parse property as non-negative integer value
|
static File |
getPipelineDir()
Deprecated.
Use
BioLockJ.getPipelineDir() instead |
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) |
static String |
getString(BioModule module,
String property,
String defaultVal)
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 |
isInternalProperty(String property) |
static boolean |
isOnCluster()
Check if running on cluster
|
static void |
partiallyInitialize(File tempConfig) |
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 environment 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 |
resetUsedProps()
Dump all of the properties stored for the current module into the allUsedProps set,
and clear out the module-used-props to start with a clean slate.
|
static void |
saveModuleProps(BioModule module) |
static void |
setConfigProperty(String name,
Collection<?> data)
Sets a property value in the props cache as a list
|
static void |
setConfigProperty(String name,
Collection<?> data,
BioModule module)
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 |
setConfigProperty(String genericName,
String val,
BioModule module)
Sets a property value in the props cache
|
static void |
setFilePathProperty(String name,
String val) |
static void |
setFilePathProperty(String name,
String val,
BioModule module) |
static void |
showUnusedProps() |
public static final String BLJ_BASH_VAR
public static final String BLJ_PROJ_VAR
static Properties props
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 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 SpecialPropertiesException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameSpecialPropertiesException
- if property name does not start with "exe." or if other exceptions are encounteredpublic 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 ConfigPathException, DockerVolCreationException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigPathException
- if path is defined but is not an existing fileDockerVolCreationException
public static File getExistingFile(BioModule module, String property) throws ConfigPathException, DockerVolCreationException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigPathException
- if path is defined but is not an existing fileDockerVolCreationException
public 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 File getLocalConfigFile(String path) throws ConfigPathException, DockerVolCreationException
path
- File pathConfigPathException
- if the local pathDockerVolCreationException
public static String getModulePropName(BioModule module, String property)
module
- BioModuleproperty
- Property namepublic 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 File getPipelineDir()
BioLockJ.getPipelineDir()
insteadpublic 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, String defaultVal)
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. Save a copy of the
primary Config to the pipeline root directoryException
- if unable to load Propspublic static void partiallyInitialize(File tempConfig) throws Exception
Exception
public 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 ConfigPathException, ConfigNotFoundException, DockerVolCreationException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigPathException
- if path is defined but is not an existing fileConfigNotFoundException
- if property is undefinedDockerVolCreationException
public static List<File> requireExistingDirs(BioModule module, String property) throws ConfigPathException, ConfigNotFoundException, DockerVolCreationException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigPathException
- if directory paths are undefined or do not existConfigNotFoundException
- if a required property is undefinedDockerVolCreationException
public static File requireExistingFile(BioModule module, String property) throws ConfigPathException, ConfigNotFoundException, DockerVolCreationException
module
- BioModule to check for module-specific form of this propertyproperty
- Property nameConfigPathException
- if path is defined but is not an existing fileConfigNotFoundException
- if property is undefinedDockerVolCreationException
public 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, BioModule module) throws DockerVolCreationException
name
- Property namedata
- Collection of data to store using the key = propertymodule
- if module is not null, and the props already include a module-specific form of this property, save the new value to the module specific form.DockerVolCreationException
public static void setConfigProperty(String name, Collection<?> data) throws DockerVolCreationException
name
- Property namedata
- Collection of data to store using the key = propertyDockerVolCreationException
public static void setFilePathProperty(String name, String val, BioModule module) throws DockerVolCreationException
DockerVolCreationException
public static void setFilePathProperty(String name, String val) throws DockerVolCreationException
DockerVolCreationException
public static void setConfigProperty(String genericName, String val, BioModule module)
name
- Property nameval
- Value to assign to propertymodule
- if module is not null, and the props already include a module-specific form of this property, save the new value to the module specific form.public static void setConfigProperty(String name, String val)
name
- Property nameval
- Value to assign to propertypublic static File getFileObjectFromPath(String filePath, boolean convertRelativePath, boolean containerizePath) throws DockerVolCreationException
filePath
- File pathConfigPathException
- if path is defined but is not found on the file systemDockerVolCreationException
public static File getExistingFileObjectFromPath(String filePath) throws ConfigPathException, DockerVolCreationException
filePath
- File pathConfigPathException
- if path is defined but is not found on the file systemDockerVolCreationException
public static File getExistingFileObjectFromPath(String filePath, boolean convertRelativePath, boolean containerizePath) throws ConfigPathException, DockerVolCreationException
filePath
- convertRelativePath
- - should the "./" be converted to be relative to the config filecontainerizePath
- - should this be converted from host-path form to in-docker-container form.ConfigPathException
DockerVolCreationException
public static File getExistingFileObject(BioModule module, String property) throws ConfigPathException, DockerVolCreationException
module
- A BioModule, can be nullproperty
- A string property name.ConfigPathException
- if path is defined but is not found on the file systemDockerVolCreationException
public static List<File> getExistingFileList(BioModule module, String property) throws ConfigPathException, DockerVolCreationException
public static String convertRelativePath(String filePath, File CONFIG_DOT) throws DockerVolCreationException
filePath
- DockerVolCreationException
protected static Properties replaceEnvVars(Properties properties)
properties
- All Config Propertiespublic static Integer getIntegerProp(BioModule module, String property) throws ConfigFormatException
property
- Property nameConfigFormatException
- if property is defined, but does not return an integerpublic static boolean isInternalProperty(String property)
public static void resetUsedProps()
public static void saveModuleProps(BioModule module) throws IOException
IOException
public static void showUnusedProps() throws FileNotFoundException, IOException
FileNotFoundException
IOException
public static Map<String,String> getEnvVarMap() throws ConfigNotFoundException
ConfigNotFoundException
public static void checkDependencies(BioModule module) throws ConfigNotFoundException, ConfigFormatException