From 91b2f5aafaa14ed12a4090fc8b90ccbd1f2dd43f Mon Sep 17 00:00:00 2001 From: Magali Ruffier <mr6@ebi.ac.uk> Date: Wed, 13 Apr 2016 12:51:53 +0100 Subject: [PATCH] moved method to parent class --- modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm | 47 ++++++++++++++++++ .../Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm | 48 ------------------- 2 files changed, 47 insertions(+), 48 deletions(-) diff --git a/modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm index 2640874188..f206ddc523 100755 --- a/modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm @@ -1113,5 +1113,52 @@ sub get_dumped_data { return eval ($data); ## no critic } +# +# Given a logic name and an existing constraint this will +# add an analysis table constraint to the feature. Note that if no +# analysis_id exists in the columns of the primary table then no +# constraint is added at all +# +sub _logic_name_to_constraint { + my $self = shift; + my $constraint = shift; + my $logic_name = shift; + + return $constraint if(!$logic_name); + + #make sure that an analysis_id exists in the primary table + my ($prim_tab) = $self->_tables(); + my $prim_synonym = $prim_tab->[1]; + + my $found_analysis=0; + foreach my $col ($self->_columns) { + my ($syn,$col_name) = split(/\./,$col); + next if($syn ne $prim_synonym); + if($col_name eq 'analysis_id') { + $found_analysis = 1; + last; + } + } + + if(!$found_analysis) { + warning("This feature is not associated with an analysis.\n" . + "Ignoring logic_name argument = [$logic_name].\n"); + return $constraint; + } + + my $aa = $self->db->get_AnalysisAdaptor(); + my $an = $aa->fetch_by_logic_name($logic_name); + + if ( !defined($an) ) { + return undef; + } + + my $an_id = $an->dbID(); + + $constraint .= ' AND' if($constraint); + $constraint .= " ${prim_synonym}.analysis_id = $an_id"; + return $constraint; +} + 1; diff --git a/modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm index 477715299e..06e320d1ad 100755 --- a/modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm @@ -1166,54 +1166,6 @@ sub _remap { } -# -# Given a logic name and an existing constraint this will -# add an analysis table constraint to the feature. Note that if no -# analysis_id exists in the columns of the primary table then no -# constraint is added at all -# -sub _logic_name_to_constraint { - my $self = shift; - my $constraint = shift; - my $logic_name = shift; - - return $constraint if(!$logic_name); - - #make sure that an analysis_id exists in the primary table - my ($prim_tab) = $self->_tables(); - my $prim_synonym = $prim_tab->[1]; - - my $found_analysis=0; - foreach my $col ($self->_columns) { - my ($syn,$col_name) = split(/\./,$col); - next if($syn ne $prim_synonym); - if($col_name eq 'analysis_id') { - $found_analysis = 1; - last; - } - } - - if(!$found_analysis) { - warning("This feature is not associated with an analysis.\n" . - "Ignoring logic_name argument = [$logic_name].\n"); - return $constraint; - } - - my $aa = $self->db->get_AnalysisAdaptor(); - my $an = $aa->fetch_by_logic_name($logic_name); - - if ( !defined($an) ) { - return undef; - } - - my $an_id = $an->dbID(); - - $constraint .= ' AND' if($constraint); - $constraint .= " ${prim_synonym}.analysis_id = $an_id"; - return $constraint; -} - - =head2 store Arg [1] : list of Bio::EnsEMBL::SeqFeature -- GitLab