source: util/meas2pdb.sh@ 725869

Last change on this file since 725869 was a0bcf1, checked in by Frederik Heber <heber@…>, 17 years ago

-initial commit
-Minimum set of files needed from ESPACK SVN repository
-Switch to three tantamount package parts instead of all relating to pcp (as at some time Ralf's might find inclusion as well)

  • Property mode set to 100755
File size: 2.0 KB
Line 
1#!/bin/sh
2#
3# extracts a .pdb-file from a pcp config file and includes shielding measurements from .csv files
4
5if [ -z "$1" ]; then
6 echo "Usage: $0 <config> [output.xyz]"
7else
8 config=$1
9 pfad=`dirname $1`
10 if [ ! -z "$2" ]; then
11 outputname=$2
12 else
13 outputname="$pfad/"`basename $1`
14 fi
15fi
16
17
18echo -n "Retrieving Ion types ..."
19# Note [\t ] finds tabs AND spaces as separators
20ions=(`grep '^Ion_Type.[^_]' $config | awk -F"[\t ]" {'print $9'}`)
21elements=(`grep '^Ion_Type.[^_]' $config | awk -F"[\t ]" {'print $8'}`)
22ionnumber=(`grep '^Ion_Type.[^_]' $config | awk -F"[\t ]" {'print $2'}`)
23echo "done"
24
25level=0
26while [ ! -z "`find $pfad -name pcp.chi.L${level}.csv`" ]; do
27 output="${outputname}.L${level}.pdb"
28 echo "Converting $config to $output...done"
29 let level=$level+1
30 # Schreibe Kopf
31 echo -e "COMPND\t$config" >$output
32 echo -e "AUTHOR\tgenerated with meas2pdb" >>$output
33 # Fuege Ionen dran
34 nr=1
35 j=1
36 #echo " 1 2 3 4 5 6 7 8" >>$output
37 #echo "12345678901234567890123456789012345678901234567890123456789012345678901234567890" >>$output
38 while [ $j -le ${#ions[*]} ]; do
39 k=0
40 ions_per_type=(`grep ^Ion_Type${j}_ $config | sed -e "s#\.#,#g" | awk -F"[\t ]" '{print $2" "$3" "$4}'`)
41 step=3
42 #echo "Step size for Ion type $j is $step"
43 while [ $k -lt ${ionnumber[$j-1]} ]; do
44 serial=`echo $nr | awk -F"\n" '{printf "% 5d",$1}'`
45 name=`echo ${ions[$j-1]} | awk -F"\n" '{printf "%2.2s",$1}'`
46 nmr=`tail -n $level $pfad/*sigma_i${k}_${ions[$j-1]}_PAS.csv | head -n 1 | sed -e "s#\.#,#g" | awk -F"[\t ]" '{printf ("%6.2f", (($5*1e+6)))}' | sed -e "s#,#\.#g"`
47 coords=`echo -e "${ions_per_type[(($k*$step))]}\t${ions_per_type[(($k*$step+1))]}\t${ions_per_type[(($k*$step+2))]}" | awk -F"[\t ]" '{printf "%8.3f%8.3f%8.3f",$1,$2,$3}' | sed -e "s#,#\.#g"`
48 echo -e "ATOM ${serial} ${name} UNK A 1 ${coords}${nmr} 1.00 ${name}" >>$output
49 let k=$k+1
50 let nr=$nr+1
51 done
52 let j=$j+1
53 done
54 # Schliesse mit Fuss
55 echo "END" >>$output
56
57done
58
59exit 0
Note: See TracBrowser for help on using the repository browser.