[a0bcf1] | 1 | #!/bin/sh
|
---|
| 2 | #
|
---|
| 3 | # extracts a .pdb-file from a pcp config file and includes shielding measurements from .csv files
|
---|
| 4 |
|
---|
| 5 | if [ -z "$1" ]; then
|
---|
| 6 | echo "Usage: $0 <config> [output.xyz]"
|
---|
| 7 | else
|
---|
| 8 | config=$1
|
---|
| 9 | pfad=`dirname $1`
|
---|
| 10 | if [ ! -z "$2" ]; then
|
---|
| 11 | outputname=$2
|
---|
| 12 | else
|
---|
| 13 | outputname="$pfad/"`basename $1`
|
---|
| 14 | fi
|
---|
| 15 | fi
|
---|
| 16 |
|
---|
| 17 |
|
---|
| 18 | echo -n "Retrieving Ion types ..."
|
---|
| 19 | # Note [\t ] finds tabs AND spaces as separators
|
---|
| 20 | ions=(`grep '^Ion_Type.[^_]' $config | awk -F"[\t ]" {'print $9'}`)
|
---|
| 21 | elements=(`grep '^Ion_Type.[^_]' $config | awk -F"[\t ]" {'print $8'}`)
|
---|
| 22 | ionnumber=(`grep '^Ion_Type.[^_]' $config | awk -F"[\t ]" {'print $2'}`)
|
---|
| 23 | echo "done"
|
---|
| 24 |
|
---|
| 25 | level=0
|
---|
| 26 | while [ ! -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 |
|
---|
| 57 | done
|
---|
| 58 |
|
---|
| 59 | exit 0
|
---|