#!/usr/bin/perl -w # overlap - print overlap between test pairs # # Copyright (C) 2002 Daniel Quinlan # # This program is free software; you can redistribute it and/or modify # it under the terms of either the Artistic License or the GNU General # Public License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. use vars qw($opt_a $opt_h); use Getopt::Std; getopts("ah"); my $prog = $0; $prog =~ s@.*/@@; sub usage { my $status = shift; my $out = $status ? STDERR : STDOUT; print $out < $pair{$a} } keys %pair) { my ($a, $b) = split(/ /, $k); next unless $solo{$a}; next unless $solo{$b}; my $a_pct = $pair{$k} / $solo{$a}; my $b_pct = $pair{$k} / $solo{$b}; if ($opt_a) { printf "%d\t%.3f\t%.3f\t%s,%s\n", $pair{$k},$a_pct,$b_pct,$a,$b; printf "%d\t%.3f\t%.3f\t%s,%s\n", $pair{$k},$b_pct,$a_pct,$b,$a; } else { if (($a_pct > $b_pct) || ($a_pct == $b_pct && $a lt $b)) { printf "%d\t%.3f\t%.3f\t%s,%s\n", $pair{$k},$a_pct,$b_pct,$a,$b; } else { printf "%d\t%.3f\t%.3f\t%s,%s\n", $pair{$k},$b_pct,$a_pct,$b,$a; } } } sub read_file { my ($input) = @_; open(FILE, $input) || die "open failed: $input"; my $line = 0; while() { next if /^#/; if (/^[Y.]\s+-?\d+\s+\S+\s+(\S+)/) { my @tests = sort (split(/,/, $1)); for (my $i = 0; $i <= $#tests; $i++) { $solo{$tests[$i]}++; for (my $j = ($i + 1); $j <= $#tests; $j++) { next if $i == $j; $pair{$tests[$i] . " " . $tests[$j]}++; } } } else { die "$prog: error in input format in $input\n"; } } close(FILE); }