Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add --seed arg to set --random-source for shuf #2

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading