Skip to content

Commit

Permalink
Merge pull request #2 from CCBR/rand-seed
Browse files Browse the repository at this point in the history
feat: add --seed arg to set --random-source for shuf
  • Loading branch information
kelly-sovacool authored Dec 11, 2024
2 parents 3793492 + 02756f9 commit e37780e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
IMAGE_NAME: recap
CONTEXT: "./"
NAMESPACE: nciccbr
VERSION_TAG: 0.2.2
VERSION_TAG: 0.3.0

jobs:
build-docker:
Expand Down
9 changes: 5 additions & 4 deletions RECAP_MACS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ then
fi

# 1) Re-mix ChIP and control bed files
bash $REMIX_PATH -i $INPUT_DIR -t $CHIP_NAME -c $CONTROL_NAME -o $OUTPUT_DIR -m unequal -b $BOOTSTRAP
bash $REMIX_PATH -i $INPUT_DIR -t $CHIP_NAME -c $CONTROL_NAME -o $OUTPUT_DIR -m unequal -b $BOOTSTRAP -s $SEED

# 2) Call original peaks using MACS
# Please specify your own MACS parameters!
Expand Down Expand Up @@ -186,9 +186,10 @@ while [[ $1 = -?* ]]; do
-t|--treatment) shift; CHIP_NAME=${1} ;;
-c|--control) shift; CONTROL_NAME=${1} ;;
-o|--output) shift; OUTPUT_DIR=${1} ;;
-b|--bootstrap) shift; BOOTSTRAP=${1} ;;
-e|--header) shift; HEADER=${1} ;;
-h|--help) usage >&2; exit 0 ;;
-b|--bootstrap) shift; BOOTSTRAP=${1} ;;
-s|--seed) shift; SEED=${1} ;;
-e|--header) shift; HEADER=${1} ;;
-h|--help) usage >&2; exit 0 ;;
*) echo "ERROR: Bad argument ${1}" ; exit 1 ;;
esac
shift
Expand Down
10 changes: 9 additions & 1 deletion RECAP_Re-Mix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ normal=$(tput sgr0)
# Default values are below
# ===============================================================

# source: https://www.gnu.org/software/coreutils/manual/html_node/Random-sources.html
function get_seeded_random() {
seed="$1"
openssl enc -aes-256-ctr -pass pass:"$seed" -nosalt \
</dev/zero 2>/dev/null
}

function mainRemix() {
####################### Begin Script Here #######################
Expand All @@ -61,6 +67,7 @@ echo "Control library: $CONTROL_NAME"
echo "Output directory (absolute path): $OUTPUT_DIR"
echo "Re-mix method: $METHOD_NAME"
echo "Number of re-mixes: $BOOTSTRAP"
echo "Random seed: $SEED"

if [[ ! -d $INPUT_DIR ]]
then
Expand Down Expand Up @@ -125,7 +132,7 @@ do
fi

echo "Re-mixing..."
shuf -o $TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp < $TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp
shuf --random-source=<(get_seeded_random $SEED) -o $TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp < $TREATMENT_NAME_BASE.bootstrap_$BOOTSTRAP_COUNT.tmp
echo "Check!"

echo "Creating re-mixed treatment library"
Expand Down Expand Up @@ -221,6 +228,7 @@ while [[ $1 = -?* ]]; do
exit 1
fi ;;
-b|--bootstrap) shift; BOOTSTRAP=${1} ;;
-s|--seed) shift; SEED=${1} ;;
-h|--help) usage >&2; exit 0 ;;
*) echo "ERROR: Bad argument ${1}" ; exit 1 ;;
esac
Expand Down

0 comments on commit e37780e

Please sign in to comment.