#!/usr/local/bin/gawk -f # # Use: # # splitnoa.awk peaks=hCH,NhH,cNH cycle6.noa # BEGIN { stderr="/dev/stderr" progname="splitnoa.awk" if ( ARGV[1]~/^(h|help)$/ || help!="" ) { print ARGV[0] # because of the which command, help is only available if # this script is in the PATH system("gawk '/^#/{print}/^BEGIN/{exit}' `which "progname"`") help=1 exit } } FILENAME ~ /[.]cya$/ { if (/^[^#]*peaks *:=/) { $1=$1 sub(/^peaks *:= */,"") sub(/#.*/,"") gsub(/ /,"") print $0 >stderr peaks=$0 } } peaks!="" { print "number of peaklists used",npf=split(peaks,peakfiles,"[,]"),$0 >stderr peaks="" } FILENAME ~ /[.](noa|ass)$/ { if (FNR==1) { spec++ filename = FILENAME sub(/.*[/]/,"",filename) print "reading from:",FILENAME,"["filename"]" } if ($1=="Peak") thispeak=$2 if (thispeakstderr print "">outfile } prevpeak = thispeak prevoutfile=outfile print > outfile }