forked from adamnovak/sequence-graphs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtraversalScaling.sh
executable file
·68 lines (47 loc) · 1.85 KB
/
traversalScaling.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
62
63
64
65
66
#!/usr/bin/env bash
# traversalScaling.sh: Produce TSV files of times for suffix tree traversal at
# different context lengths. Takes the FASTA to index as input.
# Die on errors
set -e
# Grab the FASTA to index.
FASTA="${1}"
# Make a directory to aggregate output from background subshells.
OUT_DIR=`mktemp -d`
# Don't go crazy on the parallel processing; each needs 100 threads.
PARALLEL_LIMIT=5
for CONTEXT in {1..30}
do
(
# Grab a temp directory
INDEX=`mktemp -d`
# Pick a temp file to send our output to.
OUT_FILE="${OUT_DIR}/${CONTEXT}.tsv"
# Make a scratch file
SCRATCH_FILE=`mktemp`
echo "# Start" >> ${OUT_FILE}
echo "# Starting context ${CONTEXT} into ${OUT_FILE}"
# Run on the FASTA file for each context.
echo "# createIndex/createIndex ${INDEX} ${FASTA} --context ${CONTEXT} &> ${SCRATCH_FILE}"
createIndex/createIndex ${INDEX} ${FASTA} --context ${CONTEXT} &> ${SCRATCH_FILE}
echo "# done!"
# Grab the line for the second traversal and extract the first number: wall clock time in seconds.
TIME_TAKEN=`cat ${SCRATCH_FILE} | grep "timer - Level Index Construction" | sed 's/[^0-9]*\([0-9]\+\.[0-9]\+\).*/\1/'`
# Print them out as a two-column TSV
printf "${CONTEXT}\t${TIME_TAKEN}\n" >> "$OUT_FILE"
echo "# Context ${CONTEXT} done in ${TIME_TAKEN}"
# Get rid of the temp directory.
rm -Rf ${INDEX}
# And the scratch file
rm ${SCRATCH_FILE}
) &
if [[ $(($CONTEXT % $PARALLEL_LIMIT)) == 0 ]]
then
# Wait for this whole batch of processes
echo "# Waiting for batch"
wait
fi
done
# Wait for all the subshells to finish.
wait
# Aggregate all the output
cat ${OUT_DIR}/*.tsv