-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathsilentextractspecific
More file actions
executable file
·69 lines (47 loc) · 1.49 KB
/
Copy pathsilentextractspecific
File metadata and controls
executable file
·69 lines (47 loc) · 1.49 KB
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
#!/bin/bash
tags=""
#https://stackoverflow.com/questions/369758/how-to-trim-whitespace-from-a-bash-variable
trim() {
local var="$*"
# remove leading whitespace characters
var="${var#"${var%%[![:space:]]*}"}"
# remove trailing whitespace characters
var="${var%"${var##*[![:space:]]}"}"
echo -n "$var"
}
#https://stackoverflow.com/questions/19408649/pipe-input-into-a-script
if [ -p /dev/stdin ]; then
while IFS= read tag; do
tags="$tags $(trim $tag)"
done
fi
if [ $# -eq 0 ]; then
echo >&2 ""
echo >&2 "silentextractspecific by bcov - a tool to easily extract specific tags from silent files"
echo >&2 "Usage:"
echo >&2 " cat list_of_tags.list | silentextractspecific myfile.silent"
echo >&2 " or"
echo >&2 " silentextractspecific myfile.silent tag1 tag2 tag3"
echo >&2 "Flags:"
echo >&2 " -j cpus"
echo >&2 " -p param_file"
echo >&2 " -l ligand embedded params mode"
echo >&2 " @flags_file"
exit 1
fi
silent_dir="$(dirname $(type -p "$0"))"
source "$silent_dir"/_extract_flags.sh
silent=$1
shift
for tag in "$@"; do
tags="$tags $(trim $tag)"
done
if [ -z "$tags" ]; then
exit 0;
fi
tmp_file=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13)
tmp_file="tmp_${tmp_file}.silent"
echo "$tags" | "$silent_dir"/silentslice $silent > $tmp_file
"$silent_dir"/silentextract $SILENT_FLAGS $tmp_file
rm $tmp_file
rm $tmp_file.idx 2>/dev/null