-
Notifications
You must be signed in to change notification settings - Fork 0
/
01-generate-htc-scripts.sh
executable file
·91 lines (80 loc) · 2.4 KB
/
01-generate-htc-scripts.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
# ###
#
# A script aims at generating HTC-BLAST execution scripts to be
# used on a scheduler-based computational infrastructure.
#
# Originally designed to evaluate BLAST on DATARMOR, the
# supercomputer from Ifremer.
#
# Use:
#
# ./01-generate-htc-scripts.sh
#
# Before running this script, please edit the template file:
#
# htc_blast_template.pbs
#
# @author Patrick G. Durand, Laure Quintric, Ifremer, Nov 2017
#
# File containing list of generated scripts
# It can be used to submit BLAST job by order
# (as generated by this script)
SCRIPTLISTFILE="script_list.txt"
[ -e $SCRIPTLISTFILE ] && rm $SCRIPTLISTFILE
touch $SCRIPTLISTFILE
# File containg the BLAST template
FILE="htc_blast_template.txt"
# Nb. "chunk:cores" to test
CORES=("1:28" "2:28" "3:28" "4:28" "10:28")
# BLAST comparisons to test:
# P:P = protein query vs protein bank
# M:N = nucl query (megablast) vs nucl bank
# N:N = nucl query (blastn) vs nucl bank
# P:N = protein query vs. nucl bank
# (P,M,N and more are defined in the template file).
COMPS=("P:P" "M:N" "N:N" "N:P")
# Memory to use (unit: Gb)
MEM=115
# Walltime to use (Unit: hours)
WTIME=48
nbscript=0
# For each type of BLAST comparison...
for COMP in "${COMPS[@]}" ; do
QTYPE=${COMP%:*}
STYPE=${COMP#*:}
# ... we will generate a BLAST script using a
# a particular nb cores (note: we always start
# from upper to lower values)
for (( j = ${#CORES[@]}-1 ; j >=0 ; j-- )) ; do
CHUNK_CORE="${CORES[j]}"
CHUNK=${CHUNK_CORE%:*}
CORE=${CHUNK_CORE#*:}
FCORE=$((CHUNK*CORE))
# generate a BLAST script file name
FSCRIPT=${QTYPE}-${STYPE}-${MEM}gb-${FCORE}c.pbs
echo "Generating $FSCRIPT ..."
[ -e $FSCRIPT ] && rm $FSCRIPT
touch $FSCRIPT
chmod +x $FSCRIPT
echo "$FSCRIPT" >> $SCRIPTLISTFILE
nbscript=$((nbscript+1))
# Read the template line by line and replace some
# variables (defined in the template) by their
# values as set in this script
while IFS= read -r line
do
line=${line//@CORE@/$CORE}
line=${line//@CHUNK@/$CHUNK}
line=${line//@FCORE@/$FCORE}
line=${line//@MEM@/$MEM}
line=${line//@QTYPE@/$QTYPE}
line=${line//@STYPE@/$STYPE}
line=${line//@WTIME@/$WTIME}
echo "$line" >> $FSCRIPT
done < "$FILE"
done
done
echo ""
echo "$nbscript scripts generated"
echo "You can now use '02-submit-scripts.sh' to submit jobs to PBS"