forked from caraortizmah/x-ray_scripting_out
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep8.sh
executable file
·82 lines (62 loc) · 2.81 KB
/
step8.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
#!/bin/bash
# Creating core/virt MO matrix as a function of the total transition state ocurrences
out2_file1="$1" # trans_st.out
arg="$2" # Excited states range
opt_soc="$3" # SOC option
# Extracting just rows containing core to virtual MO transitions
awk 'NF { if ( $1 != "STATE" && $1 != "Calculating"){ print $0 } }' $out2_file1 > exc_states.tmp2
#ordered list of core MO involved from all states
lst_coremo="$(awk '{print $1}' exc_states.tmp2 | cut -d'-' -f1 | sort -nu | uniq)"
#ordered list of virtual MO involved from all states
lst_virtmo="$(awk '{print $1}' exc_states.tmp2 | cut -d'>' -f2 | sort -nu | uniq)"
#cols_n="$(echo $lst_coremo | wc -w)" #number of columns in a "file"
echo "virt\core " $lst_coremo > corevirtMO_matrix.tmp
echo "virt\core " $lst_coremo > corevirtMO_matrix_ts_probability.tmp
#echo $lst_virtmo | awk '{ while (c++<NF) printf "%s\n", $c}' | awk -v col=${cols_n} 'NF { while (c++<col) s=s " 0.0 "; printf "%s %s\n", $0, s}' >> corevirtMO_matrix.tmp
for ii in $lst_virtmo
do
row_val=$ii
pos_val=""
pos_val_ts=""
for jj in $lst_coremo
do
# Transition ocurrence number
ts_num="$(grep -n " ${jj}->${ii} " exc_states.tmp2 | wc -l)"
pos_val="$(echo "$pos_val $ts_num")"
# Total transition ocurrence states probability
if (( $opt_soc!=1 )); then
# There is just one weight when option is S'=S
list_ts_p="$(grep -n " ${jj}->${ii} " exc_states.tmp2 | awk '{print $4}')"
else
# Multiplication by $6 (an additional weight) that corresponds to
# the weight from the SOC evaluation
list_ts_p="$(grep -n " ${jj}->${ii} " exc_states.tmp2 | awk '{print $4*$6}')"
fi
if (( $ts_num > 0)); then
# Average
#ts_p="$(echo $list_ts_p | awk -v x=0 -v y=$ts_num '{while (c++<=NR) x=x+$c; print x/y}')"
# Weighted average
ts_p="$(echo $list_ts_p | awk -v x=0 -v y=0 '{while (c++<=NF){ x=x+($c*$c); y=y+$c}; print x/y}')"
else
ts_p=0
fi
pos_val_ts="$(echo "$pos_val_ts $ts_p")"
#="$(echo corevirtMO_matrix.tmp | awk -v ii="$ii" -v jj="$jj" 'a[$1]==ii{for (c=1;c<=NF;c++) { if ($c == jj) { print c } }}')"
done
echo "$row_val $pos_val" >> corevirtMO_matrix.tmp
echo "$row_val $pos_val_ts" >> corevirtMO_matrix_ts_probability.tmp
done
mv corevirtMO_matrix.tmp corevirtMO_matrix.out
mv corevirtMO_matrix_ts_probability.tmp corevirtMO_matrix_ts_probability.out
sed -r 's/\s+/,/g' corevirtMO_matrix.out > corevirtMO_matrix.csv
sed -r 's/\s+/,/g' corevirtMO_matrix_ts_probability.out > corevirtMO_matrix_ts_probability.csv
rm exc_states.tmp2
if (( $opt_soc!=1 )); then
head -n -1 exc_states.tmp > test2
mv test2 exc_states.tmp
else
head -n -1 exc_states3.tmp > test2
mv test2 exc_states3.tmp
fi
# Four files as outputs from this script (corevirtMO_matrix.out, corevirtMO_matrix_ts_probability.out,
# corevirtMO_matrix.csv, corevirtMO_matrix_ts_probability.csv)