-
Notifications
You must be signed in to change notification settings - Fork 13
/
silentfrompdbs
executable file
·90 lines (62 loc) · 2.32 KB
/
silentfrompdbs
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
88
#!/bin/bash
tags=""
tmp_list=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13)
tmp_list="tmp_${tmp_list}.list"
rm $tmp_list > /dev/null 2>&1
#https://stackoverflow.com/questions/19408649/pipe-input-into-a-script
if [ -p /dev/stdin ]; then
while read tag; do
echo $tag
# tags+="$tag\n"
# tags+="$tag\n"
done > $tmp_list
fi
silent_dir="$(dirname $(type -p "$0"))"
source "$silent_dir"/_extract_flags.sh
for tag in "$@"; do
echo $tag
done >> $tmp_list
if [ ! -f $tmp_list ]; then
echo >&2 ""
echo >&2 "silentfrompdbs by bcov - a tool to make a silent file from pdbs"
echo >&2 "Usage:"
echo >&2 " cat list_of_tags.list | silentfrompdbs > silent.silent"
echo >&2 " or"
echo >&2 " silentfrompdbs tag1 tag2 tag3 > silent.silent"
echo >&2 "Flags:"
echo >&2 " -j cpus"
echo >&2 " -p param_file"
echo >&2 " @flags_file"
exit 1
fi
# bakerlab stuff. Appologies to others but this fixes so many problems for us
PATH="$PATH:/software/rosetta/latest/bin"
jd2_program=score_jd2
#https://stackoverflow.com/questions/592620/how-to-check-if-a-program-exists-from-a-bash-script/677212#677212
command -v score_jd2 >/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;
jd2_program="$silent_dir"/pyjd2
}
if [ -z "${SILENT_J}" ]; then
# Do single-thread generation
tmp_file=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13)
tmp_file="tmp_${tmp_file}.silent"
$jd2_program -l $tmp_list -out:file:silent $tmp_file -out:file:silent_struct_type binary $SILENT_PARAMS $SILENT_AT 1>&2
"$silent_dir"/silentls $tmp_file | sed 's/_0001$//g' | "$silent_dir"/silentrename $tmp_file
rm $tmp_list
rm $tmp_file
rm $tmp_file.idx
else
# Do multi-thread extraction
tmp_fol=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13)
tmp_fol="tmp_${tmp_fol}"
cpus=${SILENT_J} #$(parallel --number-of-cores)
splitno=$((( $(wc -l $tmp_list | awk '{print $1}') / $cpus + 1)))
mkdir $tmp_fol
split -l $splitno $tmp_list $tmp_fol/x
ls $tmp_fol/x* | parallel -j$cpus "cat {} | $silent_dir/silentfrompdbs $SILENT_FLAGS_NO_J"
rm $tmp_list
rm -r $tmp_fol
fi