From 467a594e8924ed39171ff1a86323c323b1307782 Mon Sep 17 00:00:00 2001
From: Magali Ruffier <mr6@ebi.ac.uk>
Date: Tue, 7 Aug 2012 14:53:57 +0000
Subject: [PATCH] slices are ordered, better chance of finding the genes on the
 first slices

---
 modules/Bio/EnsEMBL/Pipeline/Production/StatsGenerator.pm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/modules/Bio/EnsEMBL/Pipeline/Production/StatsGenerator.pm b/modules/Bio/EnsEMBL/Pipeline/Production/StatsGenerator.pm
index 7d851a9f6e..ce53ed0267 100644
--- a/modules/Bio/EnsEMBL/Pipeline/Production/StatsGenerator.pm
+++ b/modules/Bio/EnsEMBL/Pipeline/Production/StatsGenerator.pm
@@ -19,7 +19,11 @@ sub run {
   my $sum = 0;
 
   my $slices = Bio::EnsEMBL::Registry->get_adaptor($species, 'core', 'slice')->fetch_all('toplevel');
-  while (my $slice = shift @$slices) {
+  my @sorted_slices = 
+     sort( { $a->coord_system()->rank() <=> $b->coord_system()->rank()
+             || $b->seq_region_length() <=> $a->seq_region_length() } @$slices) ;
+
+  while (my $slice = shift @sorted_slices) {
     foreach my $code (keys %attrib_codes) {
       my $count = $self->get_feature_count($slice, $code, $attrib_codes{$code});
       $self->store_attrib($slice, $count, $code);
-- 
GitLab