#!/usr/bin/perl # This program will search the mfout files for the 5 models and # select the appropriate model based on AIC selection. # The program looks for 5 mfout files in subdirectories 1-5. named for # the model that you fit. For example: # 1/mfout 2/mfout 3/mfout 4/mfout 5/mfout. for $i (1..5) { open (IN, "$i/mfout") or die "could not open $i/mfout.$i\n"; until ($ls[0] eq "_total_spins") { $line = ; @ls = split (' ', $line); } $total_spins = $ls[1]; until ($ls[0] eq "data_sse") { $line = ; @ls = split (' ', $line); } for $k (1..4) {$line = } for $j (1..$total_spins) { $line = ; @ls = split (' ', $line); $x2[$i][$ls[0]] = $ls[1]; $res{$ls[0]}++; for $l (1..21) { $line = } } close IN; } $k{1}=2; $k{2}=4; $k{3}=4; $k{4}=6; $k{5}=6; foreach $i (sort {$a <=> $b} keys %res) { printf "%4d ", $i; %model = (); for $j (1..5) { printf "%10.2f ", $x2[$j][$i]; $model{$j} = $x2[$j][$i] + $k{$j}; #printf "%12.4f ", $model{$j}; } @sortedx2 = sort {$a <=> $b} values %model; for $o (1..5) { if (@sortedx2[0] == $model{$o}) { $min = $o; break; } } print " $min "; # open correct model file open (IN, "$min/mfout") or die "could not open $min/$i\n"; # find data section in file %param = (); $param{chi2}= $x2[$min][$i]; until ($ls[0] eq "data_model_1") { $line = ; @ls = split (' ', $line); } # find s2 until ($ls[0] eq "S2") { $line = ; @ls = split (' ', $line); } until ($ls[0] eq "$i") { $line = ; @ls = split (' ', $line); } $param{s2} = $ls[1]; # find s2f until ($ls[0] eq "S2f") { $line = ; @ls = split (' ', $line); } until ($ls[0] eq "$i") { $line = ; @ls = split (' ', $line); } $param{s2f} = $ls[1]; # find te until ($ls[0] eq "te") { $line = ; @ls = split (' ', $line); } until ($ls[0] eq "$i") { $line = ; @ls = split (' ', $line); } $param{te} = $ls[1]; # find Rex until ($ls[0] eq "Rex") { $line = ; @ls = split (' ', $line); } until ($ls[0] eq "$i") { $line = ; @ls = split (' ', $line); } $param{Rex} = $ls[1]; close IN; # print out model parameters printf "%6.2f %6.2f %7.2f %7.2f %10.2f", $param{s2}, $param{s2f}, $param{te}, $param{Rex}, $param{chi2}; print "\n"; }