-
Notifications
You must be signed in to change notification settings - Fork 0
/
og2.sh
61 lines (50 loc) · 2.68 KB
/
og2.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
cd /cromwell_root
tmpDir=`mkdir -p "/cromwell_root/tmp.43725cb9" && echo "/cromwell_root/tmp.43725cb9"`
chmod 777 "$tmpDir"
export _JAVA_OPTIONS=-Djava.io.tmpdir="$tmpDir"
export TMPDIR="$tmpDir"
export HOME="$HOME"
(
cd /cromwell_root
)
(
cd /cromwell_root
# Set the exit code of a pipeline to that of the rightmost command
# to exit with a non-zero status, or zero if all commands of the pipeline exit
set -o pipefail
# cause a bash script to exit immediately when a command fails
set -e
# cause the bash shell to treat unset variables as an error and exit immediately
set -u
# echo each line of the script to stdout so we can see what is happening
set -o xtrace
#to turn off echo do 'set +o xtrace'
echo "Running pre-alignment"
samtools view -T /cromwell_root/topmed_workflow_testing/topmed_variant_caller/reference_files/hg38/hs38DH.fa -uh -F 0x900 /cromwell_root/topmed_workflow_testing/topmed_aligner/input_files/NWD176325.0005.recab.cram \
| bam-ext-mem-sort-manager squeeze --in -.ubam --keepDups --rmTags AS:i,BD:Z,BI:Z,XS:i,MC:Z,MD:Z,NM:i,MQ:i --out -.ubam \
| samtools sort -l 1 -@ 1 -n -T pre_output_base.samtools_sort_tmp - \
| samtools fixmate - - \
| bam-ext-mem-sort-manager bam2fastq --in -.bam --outBase pre_output_base --maxRecordLimitPerFq 20000000 --sortByReadNameOnTheFly --readname --gzip
) > '/cromwell_root/stdout' 2> '/cromwell_root/stderr'
echo $? > /cromwell_root/rc.tmp
(
# add a .file in every empty directory to facilitate directory delocalization on the cloud
cd /cromwell_root
find . -type d -empty -print | xargs -I % touch %/.file
)
(
cd /cromwell_root
sync
# make the directory which will keep the matching files
mkdir /cromwell_root/glob-7cc51463fe16c850aa9228b0db87877e
# create the glob control file that will allow for the globbing to succeed even if there is 0 match
echo "This file is used by Cromwell to allow for globs that would not match any file.
By its presence it works around the limitation of some backends that do not allow empty globs.
Regardless of the outcome of the glob, this file will not be part of the final list of globbed files." > /cromwell_root/glob-7cc51463fe16c850aa9228b0db87877e/cromwell_glob_control_file
# symlink all the files into the glob directory
( ln -L pre_output_base.* /cromwell_root/glob-7cc51463fe16c850aa9228b0db87877e 2> /dev/null ) || ( ln pre_output_base.* /cromwell_root/glob-7cc51463fe16c850aa9228b0db87877e )
# list all the files (except the control file) that match the glob into a file called glob-[md5 of glob].list
ls -1 /cromwell_root/glob-7cc51463fe16c850aa9228b0db87877e | grep -v cromwell_glob_control_file > /cromwell_root/glob-7cc51463fe16c850aa9228b0db87877e.list
)
mv /cromwell_root/rc.tmp /cromwell_root/rc