Newer
Older
ameyner2
committed
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
41
42
43
44
45
46
#!/bin/bash
#PBS -l walltime=48:00:00
#PBS -l ncpus=16,mem=8gb
#PBS -q sgp
#PBS -N trio_whole_exome_cram_compression
#PBS -j oe
# enable running singletons
if [ -z $PBS_ARRAY_INDEX ]
then
if [ -z $INDEX ]
then
export PBS_ARRAY_INDX=1
else
export PBS_ARRAY_INDEX=$INDEX
fi
fi
# Expects environment variables to be set
# PROJECT_ID - e.g. 12345_LastnameFirstname
# CONFIG_SH - absolute path to configuration script setting environment variables
source $CONFIG_SH
FAMILY_ID=`head -n $PBS_ARRAY_INDEX $PARAMS_DIR/$PROJECT_ID.family_ids.txt | tail -n 1`
# This assumes that ${PROJECT_ID}_${FAMILY_ID} is unique, and it should be - if there was
# a re-run of a family, it should have a new project id.
cd $OUTPUT_DIR/*${PROJECT_ID}_${FAMILY_ID}*
for BAM in */*.bam
do
# 1. Compress to CRAM format without quality score binning
CRAM=${BAM%.bam}.cram
samtools view -@ 16 -T $REFERENCE_GENOME -C -o $CRAM $BAM
# 2. Index the CRAM file - good sanity check
samtools index $CRAM
# 3. Compare the stats from the BAM and CRAM files
samtools flagstat $BAM > $BAM.flagstat.txt
samtools flagstat $CRAM > $CRAM.flagstat.txt
diff $BAM.flagstat.txt $CRAM.flagstat.txt
done