forked from CCBR/spacesavers2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspacesavers2_e2e
executable file
·142 lines (127 loc) · 4.14 KB
/
spacesavers2_e2e
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env bash
####################################################################################
# spacesavers2 end-to-end wrapper script
####################################################################################
set -e -o pipefail
sleep_duration=10
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# printing version
if [ $# -eq 1 ];then
case $1 in
-v|--version)
spacesavers2_catalog --version
exit 0
esac
fi
# ncpus=`nproc`
ARGPARSE_DESCRIPTION="End-to-end run of spacesavers2"
source ${SCRIPT_DIR}/resources/argparse.bash || exit 1
argparse "$@" <<EOF || exit 1
parser.add_argument('-f','--folder',required=True, help='Folder to run spacesavers_catalog on.')
parser.add_argument('-p','--prefix',required=True, help='Prefix for output files.')
parser.add_argument('-t','--threads',required=False, help='number of threads to use for catalog (default 4)', default=4)
parser.add_argument('-d','--maxdepth',required=False, help='maxdepth for mimeo (default 4)', default=4)
parser.add_argument('-l','--limit',required=False, help='limit for running spacesavers_grubbers (default 5)', default=5)
parser.add_argument('-q','--quota',required=False, help='total size of the volume (default = 200 for /data/CCBR)', default=200)
parser.add_argument('-o','--outfolder',required=True, help='Folder where all spacesavers_e2e output files will be saved')
parser.add_argument('-v','--version',required=False, action='store_true', help='print version')
EOF
# run spacesavers2
# dt=$(date +%Y%m%d)
# PREFIX=$(echo "${dt}.${FOLDER}"|sed "s/\//_/g")
outfile_catalog="${OUTFOLDER}/${PREFIX}.catalog"
outfile_catalog_err="${OUTFOLDER}/${PREFIX}.catalog.err"
outfile_catalog_log="${OUTFOLDER}/${PREFIX}.catalog.log"
outfile_mimeo_log="${OUTFOLDER}/${PREFIX}.mimeo.log"
outfile_mimeo_err="${OUTFOLDER}/${PREFIX}.mimeo.err"
outfile_blamematrix="${OUTFOLDER}/${PREFIX}.blamematrix.tsv"
outfile_blamematrix_log="${OUTFOLDER}/${PREFIX}.blamematrix.log"
outfile_blamematrix_err="${OUTFOLDER}/${PREFIX}.blamematrix.err"
if [ ! -d $OUTFOLDER ];then mkdir -p $OUTFOLDER;fi
exit_code=0
# spacesavers2_catalog
if [ -d $OUTFOLDER ];then
echo "Running spacesavers2_catalog..."
echo "Creating File: $outfile_catalog"
spacesavers2_catalog --version
cmd=$(
cat << EOF
spacesavers2_catalog \
--folder $FOLDER \
--threads $THREADS \
--outfile ${outfile_catalog} \
--bottomhash \
--brokenlink \
--geezers \
--quiet
EOF
)
echo $cmd
$cmd > ${outfile_catalog_log} 2> ${outfile_catalog_err}
exit_code=$?
echo "ExitCode:$exit_code"
if [ $exit_code -ne 0 ];then
exit 1
fi
else # exit if $OUTFOLDER does not exist
exit 1
fi
sleep $sleep_duration
# spacesavers2_mimeo
echo "Running spacesavers2_mimeo..."
command -V ktImportText 2>/dev/null || module load kronatools || (>&2 echo "module kronatools could not be loaded")
if [ ! -f "${outfile_catalog}" ];then
echo "Creation of ${outfile_catalog} FAILED!!"
exit 1
fi
spacesavers2_mimeo --version
cmd=$(
cat << EOF
spacesavers2_mimeo \
--catalog ${outfile_catalog} \
--outdir ${OUTFOLDER} \
--quota $QUOTA \
--duplicatesonly \
--maxdepth $MAXDEPTH \
--p $PREFIX \
--kronaplot
EOF
)
echo $cmd
$cmd > ${outfile_mimeo_log} 2> ${outfile_mimeo_err}
exit_code=$?
echo "ExitCode:$exit_code"
if [ $exit_code -ne 0 ];then
exit 1
fi
sleep $sleep_duration
# spacesavers2_grubbers
echo "Running spacesavers2_grubbers..."
nfilesgz=$(ls ${OUTFOLDER}/${PREFIX}*mimeo.files.gz|wc -l)
if [ $nfilesgz -eq 0 ];then
echo "No mimeo files were created! spacesavers2_mimeo FAILED!"
exit 1
fi
for filegz in `ls ${OUTFOLDER}/${PREFIX}*files.gz`;do
echo "Finding grubbers using $filegz"
outfile=`echo $filegz|sed "s/mimeo.files.gz/grubbers.tsv/g"`
logfile=`echo $filegz|sed "s/mimeo.files.gz/grubbers.log/g"`
errfile=`echo $filegz|sed "s/mimeo.files.gz/grubbers.err/g"`
spacesavers2_grubbers --version
cmd=$(
cat << EOF
spacesavers2_grubbers \
--filesgz $filegz \
--limit $LIMIT \
--outfile $outfile
EOF
)
echo $cmd
$cmd > $logfile 2> $errfile
exit_code=$?
echo "ExitCode:$exit_code"
if [ $exit_code -ne 0 ];then
exit 1
fi
done
echo "Done!"