Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gonzalo S Nido
wgbs-pipeline
Commits
6c0dd0ab
Commit
6c0dd0ab
authored
Aug 19, 2020
by
Gonzalo S Nido
Browse files
Fixed number of cores for alignment based on RAM
parent
c515c520
Changes
1
Hide whitespace changes
Inline
Side-by-side
wgbs-pipeline.sh
View file @
6c0dd0ab
...
...
@@ -34,12 +34,12 @@ psrecord="psrecord"
########################################
# To activate CPU and RAM monitoring
MONITOR
=
false
#
MONITOR=true
#
MONITOR=false
MONITOR
=
true
# To subset reads to 10,000 (debug)
SUBSET_READS
=
false
#
SUBSET_READS=true
#
SUBSET_READS=false
SUBSET_READS
=
true
########################################
...
...
@@ -53,6 +53,8 @@ set -e
# Get number of processors in the machine
N_proc
=
$(
grep
-c
processor /proc/cpuinfo
)
# Get RAM in the machine
RAM
=
$(
free
-g
|
grep
'^Mem'
|
awk
'{print $2}'
)
# Ensure reference files/indices are there, download and index otherwise
if
[[
!
-s
${
b38_ref
}
/Bisulfite_Genome/GA_conversion/genome_mfa.GA_conversion.fa
]]
;
then
...
...
@@ -159,8 +161,8 @@ if $MONITOR; then
fi
if
$SUBSET_READS
;
then
SUBSET_READS
=
"-u 10000"
echo
"SUBSETTING TO 10000 READS ONLY!!!!"
SUBSET_READS
=
"-u 10000
0
"
echo
"SUBSETTING TO 10000
0
READS ONLY!!!!"
echo
fi
...
...
@@ -176,8 +178,10 @@ echo "##################################################"
echo
-ne
" 1.1 Aligning... "
cpus
=
`
expr
${
N_proc
}
/ 4
`
#CMD="${bismark} ${b38_ref} -1 ${R1} -2 ${R2} --multicore ${cpus} -u 100000 \
cpus
=
`
expr
${
RAM
}
/ 16
`
if
[[
$cpus
-eq
0
]]
;
then
cpus
=
1
;
fi
CMD
=
"
${
bismark
}
${
b38_ref
}
-1
${
R1
}
-2
${
R2
}
--multicore
${
cpus
}
${
SUBSET_READS
}
\
-o
${
output_dir
}
--prefix b38 --path_to_bowtie
${
bowtie_path
}
\
--samtools_path
${
samtools_path
}
--temp_dir
${
tmp_dir
}
>
\
...
...
@@ -199,6 +203,7 @@ else
fi
echo
-ne
" 1.2 Merging bamfiles... "
bamfile_list
=
""
IFS
=
','
read
-r
-a
array
<<<
"
${
R1
}
"
for
element
in
"
${
array
[@]
}
"
;
do
...
...
@@ -207,9 +212,7 @@ for element in "${array[@]}"; do
bamfile_list
=
"
${
bamfile_list
}
${
bamfile
}
"
done
cpus
=
`
expr
${
N_proc
}
/ 2
`
#CMD="${samtools} merge -n -r -@ ${cpus} ${output_dir}/b38_${sample_id}.bam ${bamfile_list} > \
CMD
=
"
${
samtools
}
cat -@
${
cpus
}
-o
${
output_dir
}
/b38_
${
sample_id
}
.bam
${
bamfile_list
}
>
\
CMD
=
"
${
samtools
}
cat -o
${
output_dir
}
/b38_
${
sample_id
}
.bam
${
bamfile_list
}
>
\
${
log_dir
}
/1_2_merge.stdout 2>
\
${
log_dir
}
/1_2_merge.stderr"
echo
-e
${
CMD
}
>
${
log_dir
}
/1_2_merge.cmd
...
...
@@ -234,6 +237,7 @@ fi
echo
-ne
" 1.3 Dedupping alignment... "
CMD
=
"
${
deduplicate_bismark
}
--paired --samtools_path
${
samtools_path
}
\
--output_dir
${
output_dir
}
${
output_dir
}
/b38_
${
sample_id
}
.bam >
\
${
log_dir
}
/1_3_dedup.stdout 2>
\
...
...
@@ -257,10 +261,11 @@ if [ -s "${output_dir}/b38_${sample_id}.deduplicated.bam" ]; then
mv
${
output_dir
}
/b38_
${
sample_id
}
.deduplicated.bam
${
output_dir
}
/b38_
${
sample_id
}
.dedup.bam
fi
exit
1
echo
-ne
" 1.4 Extracting methylation... "
cpus
=
`
expr
${
N_proc
}
/ 3
`
CMD
=
"
${
bismark_meth_extract
}
-p --comprehensive --output
${
output_dir
}
\
--multicore
${
cpus
}
\
--samtools_path
${
samtools_path
}
\
...
...
@@ -283,6 +288,7 @@ else
fi
echo
-ne
" 1.5 Extracting MT and Lambda methylation... "
CMD
=
"cat
${
output_dir
}
/CpG_context_b38_
${
sample_id
}
.dedup.txt | python3
${
ext_chr_srt
}
${
MT_chr_name
}
| gzip -nc >
\
${
output_dir
}
/CpG_context_chrM_
${
sample_id
}
.dedup.txt.gz &&
\
cat
${
output_dir
}
/CpG_context_b38_
${
sample_id
}
.dedup.txt | python3
${
ext_chr_srt
}
${
LAMBDA_chr_name
}
| gzip -nc >
\
...
...
@@ -317,6 +323,8 @@ fi
echo
exit
1
...
...
@@ -332,8 +340,10 @@ echo "##################################################"
echo
-ne
" 2.1 Aligning... "
cpus
=
`
expr
${
N_proc
}
/ 4
`
#CMD="${bismark} ${mt_ref} -1 ${R1} -2 ${R2} --multicore ${cpus} -u 100000 \
cpus
=
`
expr
${
RAM
}
/ 16
`
if
[[
$cpus
-eq
0
]]
;
then
cpus
=
1
;
fi
CMD
=
"
${
bismark
}
${
mt_ref
}
-1
${
R1
}
-2
${
R2
}
--multicore
${
cpus
}
${
SUBSET_READS
}
\
-o
${
output_dir
}
--prefix MT --path_to_bowtie
${
bowtie_path
}
\
--samtools_path
${
samtools_path
}
--temp_dir
${
tmp_dir
}
>
\
...
...
@@ -355,6 +365,9 @@ else
fi
echo
-ne
" 2.2 Merging bamfiles... "
cpus
=
`
expr
${
N_proc
}
/ 2
`
bamfile_list
=
""
IFS
=
','
read
-r
-a
array
<<<
"
${
R1
}
"
for
element
in
"
${
array
[@]
}
"
;
do
...
...
@@ -363,7 +376,6 @@ for element in "${array[@]}"; do
bamfile_list
=
"
${
bamfile_list
}
${
bamfile
}
"
done
cpus
=
`
expr
${
N_proc
}
/ 2
`
CMD
=
"
${
samtools
}
merge -n -r -@
${
cpus
}
${
output_dir
}
/MT_
${
sample_id
}
.bam
${
bamfile_list
}
>
\
${
log_dir
}
/2_2_merge.stdout 2>
\
${
log_dir
}
/2_2_merge.stderr"
...
...
@@ -414,7 +426,9 @@ fi
echo
-ne
" 2.4 Extracting methylation... "
cpus
=
`
expr
${
N_proc
}
/ 3
`
CMD
=
"
${
bismark_meth_extract
}
-p --comprehensive --output
${
output_dir
}
\
--gzip --multicore
${
cpus
}
\
--samtools_path
${
samtools_path
}
\
...
...
@@ -456,8 +470,11 @@ echo "##################################################"
echo
-ne
" 3.1 Aligning vs nuclear DNA... "
cpus
=
`
expr
${
N_proc
}
/ 4
`
#CMD="${bismark} ${nuc_ref} -1 ${R1} -2 ${R2} --multicore ${cpus} -u 100000 \
cpus
=
`
expr
${
RAM
}
/ 16
`
if
[[
$cpus
-eq
0
]]
;
then
cpus
=
1
;
fi
CMD
=
"
${
bismark
}
${
nuc_ref
}
-1
${
R1
}
-2
${
R2
}
--multicore
${
cpus
}
${
SUBSET_READS
}
\
--un --ambiguous -o
${
output_dir
}
--prefix b38_noMT --path_to_bowtie
${
bowtie_path
}
\
--samtools_path
${
samtools_path
}
--temp_dir
${
tmp_dir
}
>
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment