#! /usr/bin/perl # ./NH-jmod4edit.pl dir_name increment_param #increment_param is the parameter in the third dimension (for example relaxT) # #In stage I it will produce the ft2.com to be manipulated in nmrDraw: #>NH-jmod4edit.pl dir_name/ increment_param (NOTE: the neccesity of the slash after the dir_name may be OS dependent) # #In stage II, after we set the phase it will copy ft2.com to all increments and will convert to sparky: #>NH-jmod4edit.pl dir_name/ increment_param spark (NOTE: the neccesity of the slash after the dir_name may be OS dependent) open (IN,"<$ARGV[0]../procpar")|| die "cannot open file filename: $!"; my @timelistparam; while () { $line=$_; if ($line =~ /^sw /) { # match line against "HUMAN" $line = ; chomp($line); my @listparam = split (" ",$line); $sw=$listparam[1]; } if ($line =~ /^sw1 /) { # match line against "HUMAN" $line = ; chomp($line); my @listparam = split (" ",$line); $sw1=$listparam[1]; } if ($line =~ /^sfrq /) { # match line against "HUMAN" $line = ; chomp($line); my @listparam = split (" ",$line); $sfrq=$listparam[1]; } if ($line =~ /^dfrq2 /) { # match line against "HUMAN" $line = ; chomp($line); @listparam = split (" ",$line); $dfrq2=$listparam[1]; } if ($line =~ /^ni /) { # match line against "HUMAN" $line = ; chomp($line); my @listparam = split (" ",$line); $ni=$listparam[1]; print "$line\n"; } if ($line =~ /^np /) { # match line against "HUMAN" $line = ; chomp($line); my @listparam = split (" ",$line); $np=$listparam[1]; print "$line\n"; } if ($line =~ /^$ARGV[1] /) { # match line against "HUMAN" $line = ; chomp($line); @timelistparam = split (" ",$line); $T=$timelistparam[0]; print "$line\n"; # print line if matches #last; } } close(IN); if($ARGV[2] ne "spark") # for starting with the processing { open (IN, ">$ARGV[0]/separate_2d.c")|| die "cannot open file filename $A1: $!"; print IN "/* separate_3d.c This program takes data of the form array='f_Iz, phase2, phase' with f_Iz = 'n,y' and makes two data sets. The first is f_Iz ='n' and the second is f_Iz='y'. It also can be used for other interleaved experiments. For example, Kappa = 0, 2. January 10, 1997. Daiwen Yang mod by TC array: phase,phase2,kappa */ #include #include #include #define MAXDATA (16384*2) main(argc,argv) int argc; char *argv[]; { FILE *fi,"; for ($count=1; $count < $T;$count++) { print IN "*fi$count, ";} print IN "*fi$T;\n char head_1[50],head_2[50]; int ni,ni2,np,i,j,k,m; static int data_1[MAXDATA],data_2[MAXDATA], dataout_1[MAXDATA], dataout_2[MAXDATA]; \n"; print IN "fi = fopen(argv[1]\,\"r\")\;\n"; for ($count=1; $count< $T+1; $count++) { $count2=$count+1; print IN "fi$count = fopen(argv[$count2]\,\"w\")\;\n"; } $count=$count+1; $count2=$count+1; print IN "if (fi==NULL) { fprintf(stderr,\"file 1 cannot \open\\n\"); exit(1); } ni = atoi(argv[$count]); np = atoi(argv[$count2]); if (np > MAXDATA) { fprintf(stderr,\"t3 point exeeds limit \%d\\n\",MAXDATA); exit(1); }\n"; print IN " /* read header */\n fread(head_1,1,32,fi);\n"; for ($count=1; $count< $T+1; $count++) { $count2=$count+1; print IN " fwrite(head_1,1,32,fi$count);\n"; } print IN " for(j=1; j<= ni; j++) {\n"; for ($count=1; $count< $T+1; $count++) { print IN " fread(head_1,1,28,fi); fread(&data_1[1],4,np,fi); fwrite(head_1,1,28,fi$count); fwrite(&data_1[1],4,np,fi$count); fread(head_2,1,28,fi); fread(&data_2[1],4,np,fi); fwrite(head_2,1,28,fi$count); fwrite(&data_2[1],4,np,fi$count);\n"; } print IN "} \n fclose(fi);\n"; for ($count=1; $count< $T+1; $count++) { print IN "fclose(fi$count); ";} print IN "}\n"; close(IN); chdir("$ARGV[0]"); system("gcc separate_2d.c"); for ($count=1; $count< $T+1; $count++) { @fids[$count-1]="fid$count";} $cut=join(" ","./a.out" ,"../fid", @fids,$ni,$np); system("$cut"); print "$cut\n"; #system("varian"); open (IN, ">fid.com")|| die "cannot open file filename $A1: $!"; print IN "#!/bin/csh \n"; $xT=$np/2; $yN=2*$ni; for ($count=1; $count< $T+1; $count++) { print IN "var2pipe -in ./fid$count -noaswap \\ -xN $np -yN $yN \\ -xT $xT -yT $ni \\ -xMODE Complex -yMODE Complex \\ "; printf IN " -xSW %8.3f -ySW %8.3f \\\n", $sw, $sw1; printf IN " -xOBS %6.3f -yOBS %5.3f \\\n", $sfrq,$dfrq2; print IN " -xCAR 4.775 -yCAR 118.044 \\ -xLAB H1 -yLAB N15 \\ -ndim 2 -aq2D States \\ -out ./test$count.fid -verb -ov \n"; } close(IN); system("chmod +x fid.com"); system("fid.com"); #--------------------------- writing the first ft2.com file for nmrDraw open (IN, ">ft2.com")|| die "cannot open file filename $A1: $!"; print IN "#!/bin/csh \n"; print IN " nmrPipe -in test1.fid \\ |nmrPipe -fn SOL \\ #| nmrPipe -fn MAC -macro \$NMRTXT/ranceY.M -noRd -noWr \\ | nmrPipe -fn SP -off 0.5 -end 1.00 -pow 1 -c 0.5 \\ | nmrPipe -fn ZF -auto \\ | nmrPipe -fn FT -auto \\ | nmrPipe -fn PS -p0 0.0 -p1 0.0 -di -verb \\ | nmrPipe -fn EXT -x1 6ppm -xn 12ppm -sw \\ | nmrPipe -fn TP \\ #| nmrPipe -fn LP -fb -ord 12 \\ #| nmrPipe -fn LP -x1 1 -xn 60 -pred 30 -after -verb \\ | nmrPipe -fn SP -off 0.5 -end 1.00 -pow 1 -c 1.0 \\ | nmrPipe -fn ZF -auto -size 1024 \\ | nmrPipe -fn FT -auto \\ | nmrPipe -fn PS -p0 -68.0 -p1 135.0 -di -verb \\ | nmrPipe -fn REV \\ #| nmrPipe -fn CS -ls 1.7ppm -sw \\ | nmrPipe -fn POLY -auto \\ | nmrPipe -fn TP \\ | nmrPipe -fn POLY -auto \\ -ov -out test1.ft2\n"; close(IN); system("chmod +x *"); system("ft2.com"); } #-------------------------- writing the new ft2.com file, extracting the phase values from the previous ft2.com file in the nmrpipe folder. if($ARGV[2]eq "spark") { chdir("$ARGV[0]"); system("ls"); open (IN,") { $line=$_; if ($line =~ /-fn PS -p0 /) { if($flag) #for f1 { chomp($line); @listparam = split (" ",$line); $ph0_1=$listparam[5]; $ph1_1=$listparam[7]; print "$line\n"; $flag=0; }else{ # for f2 chomp($line); @listparam = split (" ",$line); $ph0_2=$listparam[5]; $ph1_2=$listparam[7]; print "$ph0_2 $ph1_2\n"; last; } } } close(IN); open (IN, ">ft2.com")|| die "cannot open file filename $A1: $!"; print IN "#!/bin/csh \n"; for ($count=1; $count< $T+1; $count++) { print IN " nmrPipe -in test$count.fid \\ |nmrPipe -fn SOL \\ #| nmrPipe -fn MAC -macro \$NMRTXT/ranceY.M -noRd -noWr \\ | nmrPipe -fn SP -off 0.5 -end 1.00 -pow 1 -c 0.5 \\ | nmrPipe -fn ZF -auto \\ | nmrPipe -fn FT -auto \\\n"; printf IN "| nmrPipe -fn PS -p0 %3.1f -p1 %3.1f -di -verb \\\n", $ph0_1,$ph1_1; print IN "| nmrPipe -fn EXT -x1 6ppm -xn 12ppm -sw \\ | nmrPipe -fn TP \\ #| nmrPipe -fn LP -fb -ord 12 \\ #| nmrPipe -fn LP -x1 1 -xn 60 -pred 30 -after -verb \\ | nmrPipe -fn SP -off 0.5 -end 1.00 -pow 1 -c 1.0 \\ | nmrPipe -fn ZF -size 1024 \\ | nmrPipe -fn FT -auto \\\n"; printf IN "| nmrPipe -fn PS -p0 %3.1f -p1 %3.1f -di -verb \\\n", $ph0_2,$ph1_2; print IN "| nmrPipe -fn POLY -auto \\ | nmrPipe -fn REV \\ #| nmrPipe -fn CS -ls 1.7ppm -sw \\ | nmrPipe -fn TP \\ | nmrPipe -fn POLY -auto \\ -ov -out test$count.ft2\n"; } close(IN); system("ft2.com"); for ($count=1; $count< $T+1; $count++) { $k=$timelistparam[$count]*1000; $cmd="pipe2ucsf test$count.ft2 $k.lista.ct-NHjmod_media.ucsf"; #must be sure that pipe2ucsf is aliased in the /usr/local/bin directory system("$cmd"); } } ##while(){ ## chomp($_);