-
Notifications
You must be signed in to change notification settings - Fork 1
/
transl_to_rdf_cc_worker.sh
executable file
·104 lines (76 loc) · 1.98 KB
/
transl_to_rdf_cc_worker.sh
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
source ./scripts/env.sh
WORK_DIR=
FILE_LIST=
TOTAL=
ARGV=`getopt --long -o "d:l:n:t:" "$@"`
eval set -- "$ARGV"
while true ; do
case "$1" in
-d)
WORK_DIR=$2
shift
;;
-l)
FILE_LIST=$2
shift
;;
-n)
PROC_INFO=$2
shift
;;
-t)
TOTAL=$2
shift
;;
*)
break
;;
esac
shift
done
if ! [[ $PROC_INFO =~ .*of.* ]] ; then
echo "Invalid thread id ($PROC_INFO)."
exit 1
fi
MAXPROCS=`echo $PROC_INFO | cut -d 'f' -f 2`
PROC_ID=`echo $PROC_INFO | cut -d 'o' -f 1`
PROC_ID=$(($PROC_ID - 1))
# TOTAL=`wc -l < $FILE_LIST`
proc_id=0
while read pdbml_file
do
proc_id_mod=$(($proc_id % $MAXPROCS))
if [ $proc_id_mod = $PROC_ID ] ; then
if [ ! -e $pdbml_file ] ; then
let proc_id++
continue
fi
cc_id=`basename $pdbml_file .xml`
rdf_file=$WORK_DIR/$cc_id.rdf
#if [ ${#cc_id} -gt 3 ] ; then
# div_dir=$WORK_DIR/${cc_id:2}
#else
# div_dir=$WORK_DIR/${cc_id:0:1}
#fi
div_dir=$WORK_DIR/${cc_id: -1}
err_file=$WORK_DIR/transl_to_rdf_cc_$cc_id.err
if ( [ ! -e $rdf_file ] && [ ! -e $div_dir/`basename $rdf_file`.gz ] ) || [ -e $err_file ] ; then
#pdbml_file=${pdbml_gz_file%.*} # remove the last '.gz'
#gunzip -c $pdbml_gz_file | xsltproc -o $rdf_file $CC2RDF_XSL - 2> $err_file && rm -f $err_file || ( rm -f $rdf_file ; cat $err_file ; exit 1 )
#xsltproc -o $rdf_file $CC2RDF_XSL $pdbml_file 2> $err_file && rm -f $err_file || ( rm -f $rdf_file ; cat $err_file ; exit 1 )
xsltproc -o $rdf_file --stringparam primitive_type_mapping $_PDBX_PRIMITIVE_TYPE_MAPPING_XML $CC2RDF_XSL $pdbml_file 2> $err_file && rm -f $err_file || ( rm -f $rdf_file ; cat $err_file ; exit 1 )
if [ $has_rapper_command != "false" ] ; then
rapper -q -c $rdf_file 2> $err_file && rm -f $err_file || ( cat $err_file ; exit 1 )
fi
mk_div_dir $div_dir
if [ -s $rdf_file ] ; then
gzip_in_div_dir $rdf_file $div_dir
fi
fi
if [ $proc_id_mod -eq 0 ] ; then
echo -e -n "\rDone "$((proc_id + 1)) of $TOTAL ...
fi
fi
let proc_id++
done < $FILE_LIST