Skip to content
Snippets Groups Projects
Commit c7a67709 authored by nservant's avatar nservant
Browse files

update hicpro2higlass

parent c5d240fe
No related branches found
No related tags found
No related merge requests found
...@@ -103,6 +103,7 @@ function help { ...@@ -103,6 +103,7 @@ function help {
echo " -i|--input INPUT : allValidPairs or matrix file generated by HiC-Pro" echo " -i|--input INPUT : allValidPairs or matrix file generated by HiC-Pro"
echo " -r|--res RESOLUTION : .matrix file resolution or maximum resolution to reach from the .allValidPairs input file" echo " -r|--res RESOLUTION : .matrix file resolution or maximum resolution to reach from the .allValidPairs input file"
echo " -c|--chrom CHROMSIZE : chromosome size file" echo " -c|--chrom CHROMSIZE : chromosome size file"
echo " -p|--proc NB_CPU : number of CPUs for cooler"
echo " [-n|--norm] : run cooler matrix balancing algorithm" echo " [-n|--norm] : run cooler matrix balancing algorithm"
echo " [-o|--out] : output path. Default is current path" echo " [-o|--out] : output path. Default is current path"
echo " [-t|--temp] TEMP : path to tmp folder. Default is current path" echo " [-t|--temp] TEMP : path to tmp folder. Default is current path"
...@@ -125,6 +126,7 @@ for arg in "$@"; do ...@@ -125,6 +126,7 @@ for arg in "$@"; do
"--bed") set -- "$@" "-b" ;; "--bed") set -- "$@" "-b" ;;
"--res") set -- "$@" "-r" ;; "--res") set -- "$@" "-r" ;;
"--chrom") set -- "$@" "-c" ;; "--chrom") set -- "$@" "-c" ;;
"--proc") set -- "$@" "-p" ;;
"--out") set -- "$@" "-o" ;; "--out") set -- "$@" "-o" ;;
"--temp") set -- "$@" "-t" ;; "--temp") set -- "$@" "-t" ;;
"--norm") set -- "$@" "-n" ;; "--norm") set -- "$@" "-n" ;;
...@@ -136,18 +138,20 @@ done ...@@ -136,18 +138,20 @@ done
INPUT_HICPRO="" INPUT_HICPRO=""
INPUT_BED="" INPUT_BED=""
NORMALIZE=0 NORMALIZE=0
NPROC=1
CHROMSIZES_FILE="" CHROMSIZES_FILE=""
RES=10000 RES=10000
OUT="./" OUT="./"
TEMP="./" TEMP="./"
while getopts ":i:b:c:r:o:t:nh" OPT while getopts ":i:b:c:p:r:o:t:nh" OPT
do do
case $OPT in case $OPT in
i) INPUT_HICPRO=$OPTARG;; i) INPUT_HICPRO=$OPTARG;;
b) INPUT_BED=$OPTARG;; b) INPUT_BED=$OPTARG;;
n) NORMALIZE=1;; n) NORMALIZE=1;;
c) CHROMSIZES_FILE=$OPTARG;; c) CHROMSIZES_FILE=$OPTARG;;
p) NPROC=$OPTARG;;
r) RES=$OPTARG;; r) RES=$OPTARG;;
o) OUT=$OPTARG;; o) OUT=$OPTARG;;
t) TEMP=$OPTARG;; t) TEMP=$OPTARG;;
...@@ -223,9 +227,9 @@ if [[ $DATATYPE == "MATRIX" ]]; then ...@@ -223,9 +227,9 @@ if [[ $DATATYPE == "MATRIX" ]]; then
echo -e "\nZoomify .cool file ..." echo -e "\nZoomify .cool file ..."
if [[ $NORMALIZE == 1 ]]; then if [[ $NORMALIZE == 1 ]]; then
cooler zoomify --balance $tmp_dir/$out cooler zoomify --nproc ${NPROC} --balance $tmp_dir/$out
else else
cooler zoomify --no-balance $tmp_dir/$out cooler zoomify --nproc ${NPROC} $tmp_dir/$out
fi fi
out=$(basename $INPUT_HICPRO | sed -e 's/.mat.*/.mcool/') out=$(basename $INPUT_HICPRO | sed -e 's/.mat.*/.mcool/')
...@@ -233,19 +237,19 @@ elif [[ $DATATYPE == "VALID" ]]; then ...@@ -233,19 +237,19 @@ elif [[ $DATATYPE == "VALID" ]]; then
out=$(basename $INPUT_HICPRO | sed -e 's/.allValidPairs.*/.cool/') out=$(basename $INPUT_HICPRO | sed -e 's/.allValidPairs.*/.cool/')
awk '{OFS="\t";print $2,$3,$4,$5,$6,$7,1}' $INPUT_HICPRO | sed -e 's/+/1/g' -e 's/-/16/g' > $tmp_dir/contacts.txt awk '{OFS="\t";print $2,$3,$4,$5,$6,$7,1}' $INPUT_HICPRO | sed -e 's/+/1/g' -e 's/-/16/g' > $tmp_dir/contacts.txt
cooler csort --nproc 2 -c1 1 -p1 2 -s1 3 -c2 4 -p2 5 -s2 6 \ cooler csort --nproc ${NPROC} -c1 1 -p1 2 -s1 3 -c2 4 -p2 5 -s2 6 \
-o $tmp_dir/contacts.sorted.txt.gz \ -o $tmp_dir/contacts.sorted.txt.gz \
$tmp_dir/contacts.txt \ $tmp_dir/contacts.txt \
$CHROMSIZES_FILE $CHROMSIZES_FILE
cooler makebins $CHROMSIZES_FILE $RES > $tmp_dir/bins.bed cooler makebins $CHROMSIZES_FILE $RES > $tmp_dir/bins.bed
cooler cload pairix $tmp_dir/bins.bed $tmp_dir/contacts.sorted.txt.gz $tmp_dir/$out cooler cload pairix --nproc ${NPROC} $tmp_dir/bins.bed $tmp_dir/contacts.sorted.txt.gz $tmp_dir/$out
echo -e "\nZoomify .cool file ..." echo -e "\nZoomify .cool file ..."
if [[ $NORMALIZE == 1 ]]; then if [[ $NORMALIZE == 1 ]]; then
cooler zoomify --balance $tmp_dir/$out cooler zoomify --nproc ${NPROC} --balance $tmp_dir/$out
else else
cooler zoomify --no-balance $tmp_dir/$out cooler zoomify --nproc ${NPROC} $tmp_dir/$out
fi fi
out=$(basename $INPUT_HICPRO | sed -e 's/.allValidPairs.*/.mcool/') out=$(basename $INPUT_HICPRO | sed -e 's/.allValidPairs.*/.mcool/')
fi fi
......
...@@ -66,6 +66,11 @@ process { ...@@ -66,6 +66,11 @@ process {
memory = { check_max( 10.GB * task.attempt, 'memory' ) } memory = { check_max( 10.GB * task.attempt, 'memory' ) }
time = { check_max( 5.h * task.attempt, 'time' ) } time = { check_max( 5.h * task.attempt, 'time' ) }
} }
withName:generate_cool {
cpus = check_max( 2, 'cpus' ) }
memory = { check_max( 16.GB * task.attempt, 'memory' ) }
time = { check_max( 4.h * task.attempt, 'time' ) }
}
} }
params { params {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment