From ea945dc6462cdc0fcec214404112491aab009d7a Mon Sep 17 00:00:00 2001
From: Alessandro Vullo <avullo@ebi.ac.uk>
Date: Wed, 10 Dec 2014 15:59:30 +0000
Subject: [PATCH] [ENSCORESW-1117]. Get the list of genome components for a
 polyploid genome.

---
 modules/Bio/EnsEMBL/DBSQL/GenomeContainer.pm | 26 ++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/modules/Bio/EnsEMBL/DBSQL/GenomeContainer.pm b/modules/Bio/EnsEMBL/DBSQL/GenomeContainer.pm
index cce550d925..f3cfd3e013 100644
--- a/modules/Bio/EnsEMBL/DBSQL/GenomeContainer.pm
+++ b/modules/Bio/EnsEMBL/DBSQL/GenomeContainer.pm
@@ -1186,4 +1186,30 @@ sub is_polyploid {
   return $polyploid > 2;
 }
 
+=head2 get_genome_components
+
+  Arg        : None
+  Example    : $components = $genome->get_genome_components();
+  Description: Returns the list of (diploid) components, for a
+               polyploid genome
+  Returntype : Arrayref
+  Exceptions : none
+  Caller     : general
+  Status     : Stable
+
+=cut
+
+sub get_genome_components {
+  my $self = shift;
+
+  my $sql_helper = $self->dbc->sql_helper;
+
+  my $sql = 
+    "SELECT DISTINCT value 
+     FROM seq_region_attrib JOIN attrib_type 
+     USING (attrib_type_id) WHERE attrib_type.code='genome_component'";
+
+  return $sql_helper->execute_simple(-SQL => $sql);
+}
+
 1;
-- 
GitLab