Improved BASH script to extract stationary structure from Gaussian09 scan log file.

I have published a blog before to do this at https://sunxiaoquan.wordpress.com/2015/02/06/bash-script-to-extract-structure-at-stationary-point-from-gaussian09-scan-log-file/. Recently, I did a lot scan for a ring structure. And for some scan, Gaussian tried thousand times to find the stationary points. The previous script is too slow to extract structure from huge log file (>100M). So I improved it, the speed can not compare with perl or python. But it’s enough for daily use.

 

 

read -p "Gaussian log file " log
((atom=`grep "NAtoms=" $log | head -1 |cut -f2 -d"N" | cut -f2- -d" "`))
head=`cat $log | head -3 | tail -1 | cut -f1 -d"." | cut -f2 -d"="`
((m=`grep "Stationary point found" $log | wc -l`)) #get the total number of statoinary point step
((n=`grep "Z-Matrix orientation" $log | wc -l`)) #get the total number of scan step

a=(`grep -n "Stationary point found" $log | cut -f1 -d":"`)
b=(`grep -n "Z-Matrix orientation" $log | cut -f1 -d":"`)
((p=0))
for ((i=0;i<${#a[*]};i++));do
#echo i $i p $p
        for ((j=$p;j<${#b[*]};j++));do
                if (( ${b[$j]} > ${a[$i]} )); then
                        ((jj=$j-1))
                        (( c= ${b[$jj]} + 4 + $atom ))
                        ((q=$i+1))
                        echo $atom > "$head"_stationary_point"$q".xyz
                        echo >> "$head"_stationary_point"$q".xyz
                        cat $log | head -"$c" | tail -"$atom" | cut -c 15-20,31- >> "$head"_stationary_point"$q".xyz
                        ((p=$j))
                        break;
                fi
        done
done

mkdir "$head"_stationary_point
mv "$head"_stationary_point*.xyz ./"$head"_stationary_point
cd "$head"_stationary_point
for ((i=1;i<=$m;i++));do
        if (( $i == 1 ));then
        echo mol new "$head"_stationary_point"$i".xyz > combine.tcl
        else
        echo mol addfile "$head"_stationary_point"$i".xyz >> combine.tcl
        fi
done
unset a b
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s