-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuildslurmjobs_estimnetdirected.sh
executable file
·65 lines (59 loc) · 2 KB
/
buildslurmjobs_estimnetdirected.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
#!/bin/sh
#
# File: buildslurmjobs_estimnetdirected.sh
# Author: Alex Stivala
# Created: December 2014
#
#
# buildslurmjobs_estimnetdirected.sh - build directory tree for set of estimations
#
# Usage: buildslurmjobs_estimnetdirected.sh out_root_dir in_networks_files_basename
#
# Build directory heirarchy at out_root_dir with settings file and slurm
# script in subdirs for each network in sample statistics (PNet simulation
# outpt files) pattern in_networks_files
#
# Uses templatelate files and script in its own sripts directory
# The following variables are replaced:
# @JOBNAME
# @SETTINGS
# @ROOT
# @NETWORK
# in the following template files:
# config.template
# estimnetdirected_slurm_script.template
#
SCRIPTDIR=`dirname $0`
PBS_TEMPLATE=${SCRIPTDIR}/estimnetdirected_slurm_script.template
SETTINGS_TEMPLATE=${SCRIPTDIR}/config.template
root=`dirname ${SCRIPTDIR}`
if [ $# -ne 2 ]; then
echo "usage: $0 out_root_dir in_networks_files_Basename" >&2
exit 1
fi
out_root_dir=$1
infile_basename=$2
if [ ! -d $out_root_dir ]; then
mkdir $out_root_dir
fi
for samplefile in ${infile_basename}*.txt
do
samplenum=`echo ${samplefile} | sed "s!${infile_basename}!!g" | sed s'/[.]txt//g'`
outdir=${out_root_dir}/sample${samplenum}
mkdir ${outdir}
networkfile=${outdir}/arclist.txt
fgrep -i '*arcs' ${samplefile} >/dev/null 2>&1
if [ $? -eq 0 ]; then
# already Pajek arc list, just copy
cp ${samplefile} ${networkfile}
else
# convert from matrix to arc list
$SCRIPTDIR/extractnetwork.sh ${samplefile} | Rscript ${SCRIPTDIR}/convertMatrixToArclist.R > ${networkfile}
fi
settingfile=${outdir}/config.txt
networkfilename=`basename ${networkfile}`
settingfilename=`basename ${settingfile}`
cat $SETTINGS_TEMPLATE | sed "s!@NETWORK!${networkfilename}!g" > ${settingfile}
jobfilename=${outdir}/estimnetdirected_mpi_slurm_script.sh
cat $PBS_TEMPLATE | sed "s!@ROOT!${root}!g" | sed "s!@JOBNAME!estimnetdirected_${samplenum}!g" | sed "s!@SETTINGS!${settingfilename}!g" > ${jobfilename}
done