-
Notifications
You must be signed in to change notification settings - Fork 0
/
01-generate-plast-scripts.sh
executable file
·88 lines (77 loc) · 2.22 KB
/
01-generate-plast-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
#!/usr/bin/env bash
# ###
#
# A script aims at generating PLAST execution scripts to be
# used on a scheduler-based computational infrastructure.
#
# Originally designed to evaluate PLAST on DATARMOR, the
# supercomputer from Ifremer.
#
# Use:
#
# ./generate_scripts.sh
#
# Before running this script, please edit the template file:
#
# blast_template.pbs
#
# @author Patrick G. Durand, 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="plast_template.txt"
# Nb. cores to test
CORES=("8" "16" "32" "56")
# 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=("N:N")
#COMPS=("P:PL" "N:PL")
COMPS=("P:P" "N:P" "P:PL" "N:PL")
# Memory to use (unit: Gb)
MEM=32
# 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
CORE="${CORES[j]}"
# generate a BLAST script file name
FSCRIPT=${QTYPE}-${STYPE}-${MEM}gb-${CORE}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//@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"