#!/usr/local/bin/perl # -*-Fundamental-*- # A script to read the brtags.txt and tags.txt files generated by genmetadata, # and summarize the state of label mapping for the converison. # # To use it, cd into your conversion directory, and invoke it! open(BRTAGS, ") { chomp; $Brtags{$_} = 1; } close BRTAGS; # This hackery is here to support being able to use a "depot-global" # mapping file in conjunction with separate conversion of separate # modules: # #my %GLTAGS; #open(GLTAGS, "<../tags.txt") || die; #while () # { # chomp; # my ($tag, $mapping) = split(/\s+/, $_); # $GLTAGS{$tag} = $mapping; # } #close GLTAGS; open(TAGS, ") { chomp; ($tag, $mapping) = split(/\t+/, $_); # if (! defined($GLTAGS{$tag})) { die "tag $tag> missing in global map!\n"; } # $mapping = $GLTAGS{$tag}; $branch = "UNMAPPED"; # # *** mapping functions to test follow: # if ($tag =~ /^(.*)-\d{3}$/ && $Brtags{"$1-br"}) { $branch = "$1-br"; } elsif ($tag =~ /^OLDphoebe-\d\d\d[a-z]{0,1}-(\d+-\d+)$/ && $Brtags{"OLDphoebe-$1-br"}) { $branch = "OLDphoebe-$1-br"; } if ($mapping eq "UNMAPPED" && $branch eq "UNMAPPED") { if ($tag =~ /[_\-]branch[_\-]?point$/i || $tag =~ /[_\-]bp$/i || $tag =~ /^branch[_\-]point/i || $tag =~ /[_\-]br[_\-](point|base)$/i) { $result = "BRANCHPOINT-DROPPED"; } else { $result = "UNMAPPED"; } } elsif ($mapping eq "UNMAPPED") { $result = "$branch [F]"; } elsif ($branch eq "UNMAPPED") { $result = "$mapping [H]"; } elsif ($branch eq $mapping) { $result = "$branch [B]"; } else { $result = "F-B-COLLISION"; } if ($result eq "UNMAPPED" || $result eq "F-B-COLLISION") { if ($tag =~ /^OLDphoebe-2-0-/) { $result = "OLDphoebe-2-0-br [M]"; } elsif ($tag =~ /^cp-1-/) { $result = "main [M]"; } } # Get here with result for this mapping in $result: # $out .= "$tag\t$mapping\t$branch\t$result\n"; if (! defined($tally{$result})) { $tally{$result} = 1; } else { $tally{$result}++; } } $tot = 0; $nmapped = 0; $nother = 0; foreach my $key (sort(keys(%tally))) { if ($key =~ /^(UNMAPPED|F-B-COLLISION|BRANCHPOINT-DROPPED)$/) { printf ("%20s %d\n", $key, $tally{$key}); } elsif ($key =~ /\[/) { $nmapped += $tally{$key}; } else { $nother += $tally{$key}; } $tot += $tally{$key}; } printf ("%20s %d\n", "mapped", $nmapped); printf ("%20s %d\n", "other", $nother); printf ("%20s %d\n", "total tags", $tot); print "\n\n"; print($out); exit(0);