forked from moulos-lab/star_protocols_wes3x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
08-preparebam.sh
executable file
·40 lines (35 loc) · 1.1 KB
/
08-preparebam.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
#!/bin/bash
BAM_PATH=$HOME_PATH/bam
CORES=16
for FILE in `ls $BAM_PATH/*.uns`
do
SAMPLE=`basename $FILE | sed s/\.uns//`
echo "Processing $SAMPLE"
$SAMTOOLS_PATH/samtools sort -n -@ $CORES -m 4G \
$BAM_PATH/$SAMPLE".uns" | \
$SAMTOOLS_PATH/samtools fixmate -m -
$BAM_PATH/$SAMPLE"_fixmate.bam"
done
rm $BAM_PATH/*.uns
for FILE in `ls $BAM_PATH/*_fixmate.bam`
do
SAMPLE=`basename $FILE | sed s/_fixmate\.bam//`
echo "Processing $SAMPLE"
$SAMTOOLS_PATH/samtools sort -@ $CORES -m 4G \
$BAM_PATH/$SAMPLE"_fixmate.bam" | \
$SAMTOOLS_PATH/samtools markdup - $BAM_PATH/$SAMPLE".bam"
echo "Indexing $SAMPLE"
$SAMTOOLS_PATH/samtools index $BAM_PATH/$SAMPLE".bam"
done
## For single-end BAM files
#for FILE in `ls $BAM_PATH/*.uns`
#do
# SAMPLE=`basename $FILE | sed s/\.uns//`
# echo "Processing $SAMPLE"
# $SAMTOOLS_PATH/samtools sort -@ $CORES -m 4G \
# $BAM_PATH/$SAMPLE".uns" | \
# $SAMTOOLS_PATH/samtools markdup - $BAM_PATH/$SAMPLE".bam"
# echo "Indexing $SAMPLE"
# $SAMTOOLS_PATH/samtools index $BAM_PATH/$SAMPLE".bam"
#done