public class BioLockJUtil extends Object
Modifier and Type | Field and Description |
---|---|
static String |
INTERNAL_PIPELINE_INPUT_TYPES
Internal
Config String property: "internal.pipelineInputTypes"This value is set after parsing the input files from Config property:
"input.dirPaths" in the method: getPipelineInputFiles() . |
static String |
PIPELINE_HUMANN2_COUNT_TABLE_INPUT_TYPE
Pipeline input file type indicating the file is Humann2 generated
|
static String |
PIPELINE_LOG_NORMAL_TAXA_COUNT_TABLE_INPUT_TYPE
Internal
Config String property: "taxa_count_log_norm"Set as the value of "internal.pipelineInputTypes" for log-normalized taxa count files that meet the file requirements to pass TaxaUtil.isLogNormalizedTaxaFile(File) . |
static String |
PIPELINE_NORMAL_TAXA_COUNT_TABLE_INPUT_TYPE
Internal
Config String property: "taxa_count_norm"Set as the value of "internal.pipelineInputTypes" for normalized taxa count files that meet the file requirements to pass TaxaUtil.isNormalizedTaxaFile(File) . |
static String |
PIPELINE_OTU_COUNT_TABLE_INPUT_TYPE
Internal
Config String property: "otu_count"Set as the value of "internal.pipelineInputTypes" for OTU count files that meet the file requirements to pass OtuUtil.isOtuFile(File) . |
static String |
PIPELINE_PARSER_INPUT_TYPE
Internal
Config String property: "classifier_output"Set as the value of "internal.pipelineInputTypes" for classifier output files. |
static String |
PIPELINE_R_INPUT_TYPE
Internal
Config String property: "R"Set as the value of "internal.pipelineInputTypes" if input files are some type of count table merged with the metadata such as those output by AddMetadataToTaxaTables . |
static String |
PIPELINE_SEQ_INPUT_TYPE
Internal
Config String property: "seq"Set as the value of "internal.pipelineInputTypes" for sequence input files. |
static String |
PIPELINE_STATS_TABLE_INPUT_TYPE
Internal
Config String property: "stats"Set as the value of "internal.pipelineInputTypes" if input files are tables of statistics such as those output by R_CalculateStats . |
static String |
PIPELINE_TAXA_COUNT_TABLE_INPUT_TYPE
Internal
Config String property: "taxa_count"Set as the value of "internal.pipelineInputTypes" for taxa count files that meet the file requirements to pass TaxaUtil.isTaxaFile(File) . |
Constructor and Description |
---|
BioLockJUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
addLeadingSpaces(String val,
int length)
Add leading spaces until the val is padded to given length
|
static String |
addTrailingSpaces(String val,
int length)
Add trailing spaces until the val is padded to given length
|
static boolean |
deleteWithRetry(File file,
int numTries)
Delete file or directory with retry.
|
static String |
fileExt(File file)
Return the file extension - but ignore ".gz".
|
static String |
formatDigits(Integer input,
Integer numDigits)
This method formats the input number to have a length of at least numDigits.
Simply add leading zeros until numDigits is reached. |
static String |
formatNumericOutput(Long input,
boolean addCommas)
This method formats the input number by adding commas.
|
static String |
formatPercentage(long num,
long denom)
Build the percentage display string for the num/denom ratio as "##.##%"
|
static File |
getBljDir()
Get the program source (either the jar path or main class biolockj.BioLockJ);
|
static List<String> |
getClassNames(Collection<?> objs)
Return an ordered list of the class names from the input collection.
|
static String |
getCollectionAsString(Collection<?> data)
Concatenate data and return as a comma separated String.
|
static File |
getCommonParent(File f1,
File f2)
Compare files to return a common parent directory (if any)
|
static List<String> |
getFilePaths(Collection<File> files)
Return an ordered list of absolute file paths from the input collection.
|
static BufferedReader |
getFileReader(File file)
Get a
BufferedReader for standard text file or GZIPInputStream for gzipped files ending in ".gz" |
static List<File> |
getInputDirs()
Get the list of input directories for the pipeline.
|
static File |
getLocalDir(String path)
Return directory for path after modifying if running in a Docker container and/or interpreting bash env vars.
|
static File |
getLocalFile(String path)
Return file for path after modifying if running in a Docker container and/or interpreting bash env vars.
|
static Collection<File> |
getPipelineInputFiles()
Basic input files may be sequences, or any other file type acceptable in a pipeline module.
|
static File |
getSource()
Get the source of the java runtime classes ( /bin directory or JAR file ).
|
static String |
getVersion()
Method returns the current version of BioLockJ.
|
static void |
ignoreFile(File file)
Method used to add a file to the ignore file list property.
|
static String |
join(Collection<?> collection)
Merge the collection into a String with 1 space between each element.toString() value.
|
static boolean |
noNullOrEmptyVals(Collection<Object> vals)
Verify all items in collection are not null and do not have empty toString() values.
|
static List<List<String>> |
parseCountTable(File file)
Read in BioLockJ count table, each inner lists represents 1 line from the file.
Each cell in the tab delimited file is stored as 1 element in the inner lists. |
static boolean |
pipelineInputType(String type)
Convenience method to check pipeline input file type.
|
static String |
printLongFormList(Collection<?> data)
Print collection one item per line.
|
static List<File> |
removeIgnoredAndEmptyFiles(Collection<File> files)
Remove ignored and empty files from the input files.
|
static String |
removeOuterQuotes(String value)
Remove the outer single or double quotes of the given value.
Quotes are only removed if quotes are found as very 1st and last characters. |
static String |
removeQuotes(String value)
Remove all single and double quotation marks found in value.
|
static void |
setPipelineInputFiles(List<File> files)
Setter for pipeline input files.
|
public static final String INTERNAL_PIPELINE_INPUT_TYPES
Config
String property: "internal.pipelineInputTypes"Config
property:
"input.dirPaths" in the method: getPipelineInputFiles()
. The primary purpose of
storing this value is to determine if BioModule.getPreRequisiteModules()
are appropriate
to add during pipeline initialization.BioModule.getPreRequisiteModules()
are add dependent modules if missing from the
Config
. This ensures the current module will have the correct input files and is a convenient
way to manage the size and readability of Config
files. Prerequisite modules are always
appropriate for full pipelines with sequence input file, however if the output from a prerequisite module is used
as the input for a new pipeline via "input.dirPaths", adding the prerequisite module will
cause FATAL pipeline errors.public static final String PIPELINE_HUMANN2_COUNT_TABLE_INPUT_TYPE
public static final String PIPELINE_LOG_NORMAL_TAXA_COUNT_TABLE_INPUT_TYPE
Config
String property: "taxa_count_log_norm"TaxaUtil.isLogNormalizedTaxaFile(File)
.public static final String PIPELINE_NORMAL_TAXA_COUNT_TABLE_INPUT_TYPE
Config
String property: "taxa_count_norm"TaxaUtil.isNormalizedTaxaFile(File)
.public static final String PIPELINE_OTU_COUNT_TABLE_INPUT_TYPE
Config
String property: "otu_count"OtuUtil.isOtuFile(File)
.public static final String PIPELINE_PARSER_INPUT_TYPE
Config
String property: "classifier_output"public static final String PIPELINE_R_INPUT_TYPE
Config
String property: "R"AddMetadataToTaxaTables
. These
files can be input into any R_Module
.public static final String PIPELINE_SEQ_INPUT_TYPE
Config
String property: "seq"public static final String PIPELINE_STATS_TABLE_INPUT_TYPE
Config
String property: "stats"R_CalculateStats
.public static final String PIPELINE_TAXA_COUNT_TABLE_INPUT_TYPE
Config
String property: "taxa_count"TaxaUtil.isTaxaFile(File)
.public static String addLeadingSpaces(String val, int length)
val
- Value to add spaceslength
- Total length of val with spacespublic static String addTrailingSpaces(String val, int length)
val
- Value to add spaceslength
- Total length of val with spacespublic static boolean deleteWithRetry(File file, int numTries) throws Exception
file
- File or directorynumTries
- Number of attemptsException
- if errors occurpublic static String fileExt(File file)
file
- Filepublic static String formatDigits(Integer input, Integer numDigits)
input
- Integer valuenumDigits
- Number of digits return value should containpublic static String formatNumericOutput(Long input, boolean addCommas)
input
- Long valueaddCommas
- boolean if numeric output should be displayed using commaspublic static String formatPercentage(long num, long denom)
num
- Numeratordenom
- Denominatorpublic static File getBljDir() throws ConfigPathException
ConfigPathException
- if unable to determine $BLJ sourcepublic static List<String> getClassNames(Collection<?> objs)
objs
- Objectspublic static String getCollectionAsString(Collection<?> data)
data
- Collection of datapublic static File getCommonParent(File f1, File f2)
f1
- File 1f2
- File 2public static List<String> getFilePaths(Collection<File> files)
files
- Filespublic static BufferedReader getFileReader(File file) throws FileNotFoundException, IOException
BufferedReader
for standard text file or GZIPInputStream
for gzipped files ending in ".gz"file
- to be readBufferedReader
or GZIPInputStream
if file is gzippedFileNotFoundException
- if file does not existIOException
- if unable to read or write the filepublic static List<File> getInputDirs() throws Exception
Exception
- if errors occurpublic static File getLocalDir(String path) throws ConfigPathException
path
- Directory pathConfigPathException
- if the local path is not foundpublic static File getLocalFile(String path) throws ConfigPathException
path
- File pathConfigPathException
- if the local path is not foundpublic static Collection<File> getPipelineInputFiles() throws Exception
Exception
- if errors occurpublic static File getSource() throws URISyntaxException
URISyntaxException
- if unable to locate the Java sourcepublic static String getVersion() throws Exception
Exception
- if errors occurpublic static void ignoreFile(File file)
file
- File to ignorepublic static String join(Collection<?> collection)
collection
- Collection of objectspublic static boolean noNullOrEmptyVals(Collection<Object> vals)
vals
- Collection of objectspublic static List<List<String>> parseCountTable(File file) throws Exception
file
- Path abundance fileException
- if errors occurpublic static boolean pipelineInputType(String type) throws ConfigNotFoundException
type
- Pipeline input file typeConfig
."internal.pipelineInputTypes"ConfigNotFoundException
- if "internal.pipelineInputTypes" is undefinedpublic static String printLongFormList(Collection<?> data)
data
- Collection of datapublic static List<File> removeIgnoredAndEmptyFiles(Collection<File> files)
files
- Collection of filespublic static String removeOuterQuotes(String value)
value
- Possibly quoted valuepublic static String removeQuotes(String value)
value
- Possibly quoted value