Mercurial > repos > bcclaywell > microbiome_pplacer_suite
annotate util.sh @ 8:35f9b833e12b draft default tip
planemo upload commit 2774930eebe258ecd56c8f1c5ddabf5092282ab9
author | bcclaywell |
---|---|
date | Mon, 12 Oct 2015 16:09:02 -0400 |
parents | b6ece07bec6a |
children |
rev | line source |
---|---|
0 | 1 #!/bin/bash |
2 | |
3 extify() { | |
4 local REQ_EXT=$1 | |
5 shift | |
6 | |
7 local OUTPUT="" | |
8 local FILE | |
9 for FILE in $*; do | |
10 local BASENAME=$(basename ${FILE}) | |
11 local EXT=${BASENAME##*.} | |
12 if [[ ${EXT} != ${REQ_EXT} ]]; then | |
13 local LINK="${BASENAME%%.*}.${REQ_EXT}" | |
14 if [[ ! -f ${LINK} ]]; then | |
15 ln -s ${FILE} ${LINK} | |
16 fi | |
17 FILE="${LINK}" | |
18 fi | |
19 OUTPUT="${OUTPUT} ${FILE}" | |
20 done | |
21 | |
22 echo ${OUTPUT} | |
23 } | |
24 | |
25 # from http://www.linuxjournal.com/content/use-date-command-measure-elapsed-time | |
26 timer() { | |
27 if [[ $# -eq 0 ]]; then | |
28 echo $(date '+%s') | |
29 else | |
30 local stime=$1 | |
31 etime=$(date '+%s') | |
32 | |
33 if [[ -z "$stime" ]]; then stime=$etime; fi | |
34 | |
35 dt=$((etime - stime)) | |
36 ds=$((dt % 60)) | |
37 dm=$(((dt / 60) % 60)) | |
38 dh=$((dt / 3600)) | |
39 printf '%d:%02d:%02d' $dh $dm $ds | |
40 fi | |
41 } | |
42 | |
43 on_exit() { | |
44 echo "Elapsed time: $(timer ${START_TIME})" | |
45 } | |
46 | |
47 set -eux | |
48 | |
7
b6ece07bec6a
planemo upload commit 45906ba522c7c319067e93d5cd5d7161223c3336
bcclaywell
parents:
0
diff
changeset
|
49 env > env.log |
0 | 50 |
51 START_TIME=$(timer) | |
52 trap on_exit EXIT |