From f4ce1d991313db76d8db28ebc132860af13b9f42 Mon Sep 17 00:00:00 2001
From: Magali Ruffier <mr6@ebi.ac.uk>
Date: Wed, 22 Aug 2012 12:21:08 +0000
Subject: [PATCH] added a get_total method for snp density when counting
 features, do not use strict lower/higher

---
 .../Bio/EnsEMBL/Pipeline/Production/SnpDensity.pm   | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/modules/Bio/EnsEMBL/Pipeline/Production/SnpDensity.pm b/modules/Bio/EnsEMBL/Pipeline/Production/SnpDensity.pm
index 7e4325bbda..92a18b6155 100644
--- a/modules/Bio/EnsEMBL/Pipeline/Production/SnpDensity.pm
+++ b/modules/Bio/EnsEMBL/Pipeline/Production/SnpDensity.pm
@@ -15,12 +15,21 @@ sub get_density {
   my $sql = q{
      SELECT count(*) FROM variation_feature
      WHERE seq_region_id = ?
-     AND seq_region_start < ?
-     AND seq_region_end > ? };
+     AND seq_region_start <= ?
+     AND seq_region_end >= ? };
   my @params = [$block->get_seq_region_id, $block->end, $block->start];
   my $count = $helper->execute_single_result(-SQL => $sql, -PARAMS => @params);
   return $count;
 }
 
+sub get_total {
+  my ($self, $option) = @_;
+  my $species = $self->param('species');
+  my $variation_adaptor = Bio::EnsEMBL::Registry->get_DBAdaptor($species, 'variation');
+  my $helper = $variation_adaptor->dbc()->sql_helper();
+  my $sql = "SELECT count(*) FROM variation_feature";
+  return $helper->execute_single_result(-SQL => $sql);
+}
+
 return 1;
 
-- 
GitLab