-
Notifications
You must be signed in to change notification settings - Fork 13
/
silentextract
executable file
·65 lines (44 loc) · 1.74 KB
/
silentextract
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/bash
if [ $# -eq 0 ]; then
echo >&2 ""
echo >&2 "silentextract by bcov - a tool to easily extract all tags from silent files"
echo >&2 "Usage:"
echo >&2 " silentextract myfile.silent"
echo >&2 "Flags:"
echo >&2 " -j cpus"
echo >&2 " -p param_file"
echo >&2 " @flags_file"
exit 1
fi
silent_dir="$(dirname $(type -p "$0"))"
source "$silent_dir"/_extract_flags.sh
silent=$1
# bakerlab stuff. Appologies to others but this fixes so many problems for us
PATH="$PATH:/software/rosetta/latest/bin"
extract_program=extract_pdbs
#https://stackoverflow.com/questions/592620/how-to-check-if-a-program-exists-from-a-bash-script/677212#677212
command -v extract_pdbs >/dev/null 2>&1 || {
#echo >&2 "You must have extract_pdbs on your path!";
#echo >&2 "Try doing cd silent_tools; ln -s /software/rosetta/latest/bin/extract_pdbs ."
#exit 1;
extract_program="$silent_dir"/pyextract_pdbs
}
if [ -z "${SILENT_J}" ]; then
# Do single-thread extraction
"$extract_program" -in:file:silent $silent -in:file:silent_struct_type binary $SILENT_PARAMS $SILENT_AT 1>&2
else
# Do multi-thread extraction
tmp_fol=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13)
tmp_fol="tmp_${tmp_fol}"
rm -r $tmp_fol > /dev/null 2>&1
mkdir $tmp_fol
tmp_list="$tmp_fol/list"
cpus=${SILENT_J}
"$silent_dir"/silentls $silent > $tmp_list
splitno=$((( $(wc -l $tmp_list | awk '{print $1}') / $cpus + 1)))
split -l $splitno $tmp_list $tmp_fol/x
ls $tmp_fol/x* | parallel -j$cpus "cat {} | $silent_dir/silentslice $silent > {}.silent"
ls $tmp_fol/x*.silent | parallel -j$cpus "$silent_dir/silentextract $SILENT_FLAGS_NO_J {}"
rm $tmp_list
rm -r $tmp_fol
fi