Commit 3417e5b5 authored by Holger Brandl's avatar Holger Brandl

modernized dge_merge_treps

parent 0dea3358
......@@ -259,36 +259,26 @@ fi
local bam_dir=$1; # bam_dir=$baseDir/mapped_trim/
local bio_reps=$2; # bio_samples="test,lala"
local bio_samples=$2; # bio_samples="test,lala"
if [ ! -d "$bam_dir" ]; then
echo "bam file directory does not exist! $usage'" >&2 ; return;
fi
if [ $(echo "$bio_samples" | grep "," | wc -l ) -ne 1 ]; then
if [ $(echo "${bio_samples}" | grep "," | wc -l ) -ne 1 ]; then
echo "Invalid biosample spec! $usage'" >&2 ; return;
fi
#for sample in aRG bRG N; do
for sample in $(echo $bio_samples | tr ",", " "); do
# DEBUG sample=Insm1_1103
## todo use joblist instead here
(
sampleBams=$(find $bam_dir -name '*bam' | grep -v unmapped | grep $sample)
echo "merging $sample with $sampleBams"
## todo add read-groups to bam files
if [ 1 -eq $(echo "$sampleBams" | wc -l) ]; then
cp $sampleBams $sample.bam
else
samtools merge - $(echo $sampleBams | xargs echo) | samtools sort - $sample
fi
samtools index $sample.bam
)&
for condition in $(echo ${bio_samples} | tr ",", " "); do
echo merging ${condition}
bamFiles=$(ls ${bam_dir}/${condition}*.bam | xargs echo)
jl submit --jl .merge_reps "
samtools merge --threads 10 - ${bamFiles} | samtools sort -T ${condition} -o ${condition}.bam -
samtools index ${condition}.bam
"
done
jl wait .merge_reps
}
export -f dge_merge_treps
......
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