This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#SBATCH --job-name mambaEnv | |
#SBATCH --cpus-per-task 6 | |
#SBATCH --mem 16G | |
#SBATCH --partition allnodes | |
#SBATCH --output ./mambaEnv.%j.out | |
#SBATCH --error ./mambaEnv.%j.err | |
# yaml filename is required argument 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hasPackage <- function( package ) { | |
suppressWarnings( suppressMessages( | |
require( package, quietly= TRUE, warn.conflicts= FALSE, character.only= TRUE ) | |
)) | |
} | |
# Set progress=FALSE to hide progress messages. Install messages always | |
# displayed as they are changing the system. | |
ensurePackages <- function( packages, installOk= FALSE, progress= TRUE, | |
exitOnError= installOk ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Prints error messages to stderr | |
# @PARAM Concatenates parameters with IFS (default space) to form an error | |
# message. | |
# @OUT Prints error message preceeded by "ERROR: " to standard error, | |
# translating escapes. | |
# @REQUIRES: echo -e | |
function sayErr() { | |
echo -e "ERROR: $@" >&2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USAGE: | |
# say $LEVEL_INFO "This is an" "informational message." | |
# #> "This is an informational message." | |
# | |
# sayError "This is an" "error message." | |
# #> "ERROR: This is an error message." | |
# | |
# LEVELS: | |
# In order from highest priority message to lowest: | |
# $LEVEL_ALL $LEVEL_ERROR $LEVEL_WARN $LEVEL_INFO $LEVEL_VERBOSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Avoids string-keyed arrays as not available in old bash on Macs. Supports: | |
# * arguments and values with spaces if quoted. | |
# * arguments embedded in options (e.g. "commands"). | |
# * arguments that look like option (start with a -) after a lone "--" | |
# * options with values, without values, and with optional values. | |
# * repeated options with values and counted flags. | |
# * both "key=value"" and "key value" style options | |
function parseCli() { | |
# globals | |
OPT_DOWNLOAD=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Append potentially empty string, but with separator if not empty | |
# "one" -> "one" if "$extra" is empty, "one" -> "one, two" if not | |
result="one${extra:+", ${extra}"}" | |
# Examples | |
extra=;[ "one${extra:+", ${extra}"}" == 'one' ] || echo "FALSE" | |
extra=''; [ "one${extra:+", ${extra}"}" == 'one' ] || echo "FALSE" | |
extra='two'; [ "one${extra:+", ${extra}"}" == 'one, two' ] || echo "FALSE" | |
# Useful for path changes adding possibly empty dir to path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################### | |
# DESC: Parses arguments with the bash built-in getopts, but allows for | |
# long options too. This only works when each long option has a short option, | |
# although short options need not have long ones. Designed to create global | |
# variables named opt_<option> containing the parsed command line options, and | |
# an array variable called opt_args with any additional non-option arguments. | |
# This is all hard coded, but simple to modify for local use. See the ### | |
# sections for what needs to be changed to create your own option variable set. | |
# Supports bundled options and the use of "--" to signal end of options. | |
# Does not support negated options. You can always just declare "myFlag" and |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#========================== | |
# Demo roxygen2 text markup | |
#========================== | |
# This shows how things do work, including wierd corner cases, not | |
# how they should be done. Most of the information comes from | |
# http://r-pkgs.had.co.nz/man.html | |
#' Demo page for roxygen2 text markup | |
#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#=================================================== | |
# Demo multi-function roxygen2 - three ways to do it | |
#=================================================== | |
# This shows how things do work, including wierd corner cases, not | |
# how they should be done. Most of the information comes from | |
# http://r-pkgs.had.co.nz/man.html | |
#==================================================== | |
# Demo multi-function roxygen2 page using @describeIn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#==================================== | |
# Demo package roxygen2 documentation | |
#==================================== | |
# This shows how things do work, including wierd corner cases, not | |
# how they should be done. Most of the information comes from | |
# http://r-pkgs.had.co.nz/man.html | |
#' Brief page title describing this package. | |
#' |
NewerOlder