File size: 1,011 Bytes
9ae74ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/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

if [ -p /dev/stdin ]; then
    while read tag; do
        echo $tag
    done > $tmp_list

fi

for tag in "$@"; do
    echo $tag
done >> $tmp_list


if [ ! -f $tmp_list ]; then
    echo >&2 ""
    echo >&2 "silentfrompdbsparallel by bcov - a tool to make a silent file from pdbs in parallel"
    echo >&2 "Usage:"
    echo >&2 "        cat list_of_tags.list | silentfrompdbs > silent.silent"
    echo >&2 "                             or"
    echo >&2 "        silentfrompdbs tag1 tag2 tag3 > silent.silent"
    exit 1
fi

tmp_fol=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13)
tmp_fol="tmp_${tmp_fol}"

cpus=16 #$(parallel --number-of-cores)

splitno=$((( $(wc -l $tmp_list | awk '{print $1}') / ($cpus * 8) + 1)))

mkdir $tmp_fol

split -l $splitno $tmp_list $tmp_fol/x

ls $tmp_fol/x* | parallel -j16 'cat {} | silentfrompdbs'

rm $tmp_list
rm -r $tmp_fol