Commit 350d3590 authored by Gonzalo S Nido's avatar Gonzalo S Nido
Browse files

Changed samtools merge for cat in all calls

parent 6c0dd0ab
......@@ -46,10 +46,10 @@ SUBSET_READS=true
# exit when any command fails
# Exit when any command fails
set -e
# trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# trap 'echo "\"${last_command}\" command filed with exit code $?"' EXIT
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
trap 'if [ "$?" -ne "0" ]; then echo "\"${last_command}\" command filed with exit code different from 0"; fi' EXIT
# Get number of processors in the machine
N_proc=$( grep -c processor /proc/cpuinfo )
......@@ -179,8 +179,8 @@ echo "##################################################"
echo -ne " 1.1 Aligning... "
cpus=`expr ${RAM} / 16`
if [[ $cpus -eq 0 ]]; then cpus=1; fi
if [ "${RAM}" -lt "16" ]; then cpus=1; else cpus=$( expr ${RAM} / 16 ); fi
echo -ne "(${cpus} cores) "
CMD="${bismark} ${b38_ref} -1 ${R1} -2 ${R2} --multicore ${cpus} ${SUBSET_READS} \
-o ${output_dir} --prefix b38 --path_to_bowtie ${bowtie_path} \
......@@ -202,6 +202,7 @@ else
echo "DONE"
fi
echo -ne " 1.2 Merging bamfiles... "
bamfile_list=""
......@@ -341,8 +342,8 @@ echo "##################################################"
echo -ne " 2.1 Aligning... "
cpus=`expr ${RAM} / 16`
if [[ $cpus -eq 0 ]]; then cpus=1; fi
if [ "${RAM}" -lt "16" ]; then cpus=1; else cpus=$( expr ${RAM} / 16 ); fi
echo -ne "(${cpus} cores) "
CMD="${bismark} ${mt_ref} -1 ${R1} -2 ${R2} --multicore ${cpus} ${SUBSET_READS} \
-o ${output_dir} --prefix MT --path_to_bowtie ${bowtie_path} \
......@@ -376,7 +377,7 @@ for element in "${array[@]}"; do
bamfile_list="${bamfile_list} ${bamfile}"
done
CMD="${samtools} merge -n -r -@ ${cpus} ${output_dir}/MT_${sample_id}.bam ${bamfile_list} > \
CMD="${samtools} cat -o ${output_dir}/MT_${sample_id}.bam ${bamfile_list} > \
${log_dir}/2_2_merge.stdout 2> \
${log_dir}/2_2_merge.stderr"
echo -e ${CMD} > ${log_dir}/2_2_merge.cmd
......@@ -471,9 +472,8 @@ echo "##################################################"
echo -ne " 3.1 Aligning vs nuclear DNA... "
cpus=`expr ${RAM} / 16`
if [[ $cpus -eq 0 ]]; then cpus=1; fi
if [ "${RAM}" -lt "16" ]; then cpus=1; else cpus=$( expr ${RAM} / 16 ); fi
echo -ne "(${cpus} cores) "
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} \
......@@ -496,6 +496,7 @@ else
fi
echo -ne " 3.2 Merging unaligned reads... "
unmapped_list_r1=""
unmapped_list_r2=""
IFS=',' read -r -a array <<< "${R1}"
......@@ -536,6 +537,7 @@ fi
echo -ne " 3.3 Deleting nuclear bamfiles... "
bamfile_list=""
IFS=',' read -r -a array <<< "${R1}"
for element in "${array[@]}"; do
......@@ -565,7 +567,10 @@ fi
echo -ne " 3.4 Re-aligning unmapped reads to mtDNA... "
cpus=`expr ${N_proc} / 4`
cpus=`expr ${RAM} / 16`
if [[ $cpus -eq 0 ]]; then cpus=1; fi
CMD="(${bismark} ${mt_ref} -1 ${output_dir}/b38_noMT_${sample_id}_unmapped.R1.fastq.gz \
-2 ${output_dir}/b38_noMT_${sample_id}_unmapped.R2.fastq.gz --multicore ${cpus} \
-o ${output_dir} --prefix umap_to_MT --path_to_bowtie ${bowtie_path} \
......@@ -595,6 +600,7 @@ rm ${output_dir}/b38_noMT_${sample_id}_unmapped.R?.fastq.gz
echo -ne " 3.5 Dedupping alignments... "
CMD="${deduplicate_bismark} --paired --samtools_path ${samtools_path} \
--output_dir ${output_dir} ${output_dir}/umap_to_MT_${sample_id}.bam > \
${log_dir}/3_5_dedup.stdout 2> \
......@@ -622,7 +628,9 @@ fi
echo -ne " 3.6 Extracting methylation in MT..."
cpus=`expr ${N_proc} / 3`
CMD="${bismark_meth_extract} -p --comprehensive --output ${output_dir} \
--gzip --multicore ${cpus} \
--samtools_path ${samtools_path} \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment