#!/bin/sh # # extracts a .pdb-file from a pcp config file and includes shielding measurements from .csv files if [ -z "$1" ]; then echo "Usage: $0 [output.xyz]" else config=$1 pfad=`dirname $1` if [ ! -z "$2" ]; then outputname=$2 else outputname="$pfad/"`basename $1` fi fi echo -n "Retrieving Ion types ..." # Note [\t ] finds tabs AND spaces as separators ions=(`grep '^Ion_Type.[^_]' $config | awk -F"[\t ]" {'print $9'}`) elements=(`grep '^Ion_Type.[^_]' $config | awk -F"[\t ]" {'print $8'}`) ionnumber=(`grep '^Ion_Type.[^_]' $config | awk -F"[\t ]" {'print $2'}`) echo "done" level=0 while [ ! -z "`find $pfad -name pcp.chi.L${level}.csv`" ]; do output="${outputname}.L${level}.pdb" echo "Converting $config to $output...done" let level=$level+1 # Schreibe Kopf echo -e "COMPND\t$config" >$output echo -e "AUTHOR\tgenerated with meas2pdb" >>$output # Fuege Ionen dran nr=1 j=1 #echo " 1 2 3 4 5 6 7 8" >>$output #echo "12345678901234567890123456789012345678901234567890123456789012345678901234567890" >>$output while [ $j -le ${#ions[*]} ]; do k=0 ions_per_type=(`grep ^Ion_Type${j}_ $config | sed -e "s#\.#,#g" | awk -F"[\t ]" '{print $2" "$3" "$4}'`) step=3 #echo "Step size for Ion type $j is $step" while [ $k -lt ${ionnumber[$j-1]} ]; do serial=`echo $nr | awk -F"\n" '{printf "% 5d",$1}'` name=`echo ${ions[$j-1]} | awk -F"\n" '{printf "%2.2s",$1}'` 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"` 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"` echo -e "ATOM ${serial} ${name} UNK A 1 ${coords}${nmr} 1.00 ${name}" >>$output let k=$k+1 let nr=$nr+1 done let j=$j+1 done # Schliesse mit Fuss echo "END" >>$output done exit 0