[Bio] / FigKernelPackages / Clustering.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/Clustering.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Thu Feb 18 16:57:11 2010 UTC revision 1.5, Sun Nov 7 20:39:29 2010 UTC
# Line 1  Line 1 
1  #  #
2    # This is a SAS component.
3    #
4  # Copyright (c) 2003-2006 University of Chicago and Fellowship  # Copyright (c) 2003-2006 University of Chicago and Fellowship
5  # for Interpretations of Genomes. All Rights Reserved.  # for Interpretations of Genomes. All Rights Reserved.
6  #  #
# Line 32  Line 34 
34          if    ($dist_func_ref eq "avg_dist")            { $dist_func_ref = \&avg_dist }          if    ($dist_func_ref eq "avg_dist")            { $dist_func_ref = \&avg_dist }
35          elsif ($dist_func_ref eq "max_dist")            { $dist_func_ref = \&max_dist }          elsif ($dist_func_ref eq "max_dist")            { $dist_func_ref = \&max_dist }
36          elsif ($dist_func_ref eq "single_linkage_dist") { $dist_func_ref = \&single_linkage_dist }          elsif ($dist_func_ref eq "single_linkage_dist") { $dist_func_ref = \&single_linkage_dist }
37            elsif ($dist_func_ref eq "min_dist")            { $dist_func_ref = \&single_linkage_dist }
38          else { confess "Could not resolve the distance function" }          else { confess "Could not resolve the distance function" }
39      }      }
40      my @clusters = defined($things) ? @$things :      my @clusters = defined($things) ? map { [$_] } @$things :
41                                        map { [$_] } keys(%$connections);                                        map { [$_] } keys(%$connections);
42      my @trees    = map { [$_->[0],0,[undef]] } @clusters;      my @trees    = map { [$_->[0],0,[undef]] } @clusters;
43    
# Line 106  Line 109 
109          foreach my $y (@$clust2)          foreach my $y (@$clust2)
110          {          {
111              my $dist = $connections->{$x}->{$y};              my $dist = $connections->{$x}->{$y};
112              if ((! defined($best)) || (defined($dist) && ($dist > $best)))              if (! defined($dist)) { return undef }
113                if ((! defined($best)) || ($dist > $best))
114              {              {
115                  $best = $dist;                  $best = $dist;
116              }              }
# Line 125  Line 129 
129          foreach my $y (@$clust2)          foreach my $y (@$clust2)
130          {          {
131              my $dist = $connections->{$x}->{$y};              my $dist = $connections->{$x}->{$y};
132                if (! defined($dist)) { return undef }
133              $n++;              $n++;
134              $sum += $dist;              $sum += $dist;
135          }          }
136      }      }
137      return $n ? ($sum/$n) : undef;      return ($sum/$n);
138  }  }
139    
140  1  1

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.5

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3