Skip to content
Snippets Groups Projects
Commit 313dc75e authored by Andy Yates's avatar Andy Yates
Browse files

Deprecating a number of calls. Instead we want more API compatible calls

parent 62ab49c2
No related branches found
No related tags found
No related merge requests found
...@@ -459,7 +459,7 @@ sub get_all_Genes { ...@@ -459,7 +459,7 @@ sub get_all_Genes {
} }
=head2 get_all_Gene_ids =head2 get_all_Genes_types
Arg[1] : Boolean - Do not include representative gene in list of ids. Arg[1] : Boolean - Do not include representative gene in list of ids.
Description : Fetches all the Gene objects within the allele group and their Description : Fetches all the Gene objects within the allele group and their
...@@ -516,4 +516,4 @@ sub get_all_members { ...@@ -516,4 +516,4 @@ sub get_all_members {
} }
1; 1;
\ No newline at end of file
...@@ -32,16 +32,16 @@ Alternative allele groupings ...@@ -32,16 +32,16 @@ Alternative allele groupings
my $aag_adaptor = Bio::EnsEMBL::Registry->get_DBAdaptor("Human","core","AltAlleleGroup"); my $aag_adaptor = Bio::EnsEMBL::Registry->get_DBAdaptor("Human","core","AltAlleleGroup");
# For a known Gene, find the reference alternative allele # For a known Gene, find the reference alternative allele
my $aag = $aag_adaptor->fetch_Group_by_dbID($gene->dbID); my $aag = $aag_adaptor->fetch_by_gene_id($gene->dbID);
my $reference_gene = $aag->get_ref_Gene; my $reference_gene = $aag->get_ref_Gene;
# Get a list of AltAlleleGroups # Get a list of AltAlleleGroups
my $list = $aag_adaptor->fetch_all_Groups_by_type('IS_REPRESENTATIVE'); my $list = $aag_adaptor->fetch_all_('IS_REPRESENTATIVE');
$list = $aag_adaptor->fetch_all_Groups(); $list = $aag_adaptor->fetch_all();
my $dbID = $aag_adaptor->store($aag); my $dbID = $aag_adaptor->store($aag);
$aag = $aag_adaptor->fetch_Group_by_id($dbID); $aag = $aag_adaptor->fetch_by_dbID($dbID);
$aag_adaptor->remove($aag); $aag_adaptor->remove($aag);
=head1 DESCRIPTION =head1 DESCRIPTION
...@@ -59,23 +59,41 @@ use warnings; ...@@ -59,23 +59,41 @@ use warnings;
use base qw/Bio::EnsEMBL::DBSQL::BaseAdaptor/; use base qw/Bio::EnsEMBL::DBSQL::BaseAdaptor/;
use Bio::EnsEMBL::AltAlleleGroup; use Bio::EnsEMBL::AltAlleleGroup;
use Bio::EnsEMBL::Utils::Exception qw/throw/; use Bio::EnsEMBL::Utils::Exception qw/throw deprecate/;
use Bio::EnsEMBL::Utils::Scalar qw/assert_ref/; use Bio::EnsEMBL::Utils::Scalar qw/assert_ref/;
use DBI qw( :sql_types ); use DBI qw( :sql_types );
=head2 fetch_all_Groups =head2 fetch_all_Groups
Arg[1] : (optional) String - type of group Arg[1] : (optional) String - type of group
Description : DEPRECATED. Please use fetch_all()
Returntype : ArrayRef of Bio::EnsEMBL::AltAlleleGroup
=cut
sub fetch_all_Groups {
my ($self, $type) = @_;
deprecate('Please use fetch_all()');
return $self->fetch_all($type);
}
=head2 fetch_all
Arg[1] : (optional) String - type of group
Restrict group fetches to just one type. Technically it selects
out mixed-annotation groups where a single member contains that type.
Description : Fetches all the alt-allele groups, creates objects to represent Description : Fetches all the alt-allele groups, creates objects to represent
them and returns them in a list them and returns them in a list. Specifying a group type
identifies all groups containing a member of this type. It
does not filter out the other members
Multispecies support is triggered by the is_multispecies flag Multispecies support is triggered by the is_multispecies flag
and species_id of the DBAdaptor. and species_id of the DBAdaptor.
Specifying a group type identifies all groups containing a Returntype : ArrayRef of Bio::EnsEMBL::AltAlleleGroup
member of this type. It does not filter out the other members
Returntype : Listref of Bio::EnsEMBL::AltAlleleGroup
=cut =cut
sub fetch_all_Groups { sub fetch_all {
my $self = shift; my $self = shift;
my $type = shift; my $type = shift;
...@@ -103,16 +121,18 @@ sub fetch_all_Groups { ...@@ -103,16 +121,18 @@ sub fetch_all_Groups {
WHERE c.species_id = ? AND b.attrib = ? WHERE c.species_id = ? AND b.attrib = ?
); );
} }
$get_all_sql = q( else {
SELECT DISTINCT alt_allele_group_id FROM alt_allele a $get_all_sql = q(
JOIN (gene g, seq_region s, coord_system c) SELECT DISTINCT alt_allele_group_id FROM alt_allele a
ON ( JOIN (gene g, seq_region s, coord_system c)
c.coord_system_id = s.coord_system_id ON (
AND s.seq_region_id = g.seq_region_id c.coord_system_id = s.coord_system_id
AND g.gene_id = a.gene_id AND s.seq_region_id = g.seq_region_id
) AND g.gene_id = a.gene_id
WHERE c.species_id = ? )
); WHERE c.species_id = ?
);
}
} else { } else {
if ($type) { if ($type) {
$get_all_sql = q(SELECT DISTINCT alt_allele_group_id $get_all_sql = q(SELECT DISTINCT alt_allele_group_id
...@@ -144,7 +164,7 @@ sub fetch_all_Groups { ...@@ -144,7 +164,7 @@ sub fetch_all_Groups {
$sth->bind_col(1, \$group_id ); $sth->bind_col(1, \$group_id );
while ( $sth->fetch() ) { while ( $sth->fetch() ) {
my $aag = $self->fetch_Group_by_id($group_id); my $aag = $self->fetch_by_dbID($group_id);
push @group_list, $aag; push @group_list, $aag;
} }
$sth->finish; $sth->finish;
...@@ -154,22 +174,34 @@ sub fetch_all_Groups { ...@@ -154,22 +174,34 @@ sub fetch_all_Groups {
=head2 fetch_all_Groups_by_type =head2 fetch_all_Groups_by_type
Arg[1] : String - type of group Arg[1] : String - type of group
Description : Convenience method for restricting group fetches to just one Description : DEPRECATED. Please use fetch_all()
type. Technically it selects out mixed-annotation groups where Returntype : ArrayRef of Bio::EnsEMBL::AltAlleleGroup
a single member contains that type.
Returntype : Listref of Bio::EnsEMBL::AltAlleleGroup
=cut =cut
sub fetch_all_Groups_by_type { sub fetch_all_Groups_by_type {
my $self = shift; my ($self, $type) = @_;
my $type = shift; # refers to alt_allele_attrib type deprecate('Please use fetch_all()');
my $group_list = $self->fetch_all($type);
my $group_list = $self->fetch_all_Groups($type);
return $group_list; return $group_list;
} }
=head2 fetch_Group_by_id =head2 fetch_Group_by_id
Arg[1] : AltAlleleGroup dbID.
Description : DEPRECATED. Please use fetch_by_dbID
Returntype : Bio::EnsEMBL::AltAlleleGroup
=cut
sub fetch_Group_by_id {
my ($self, $group_id) = @_;
deprecate('Please use fetch_by_dbID()');
return $self->fetch_by_dbID($group_id);
}
=head2 fetch_by_dbID
Arg[1] : AltAlleleGroup dbID. Arg[1] : AltAlleleGroup dbID.
Description : Creates and returns an AltAlleleGroup for the given group id Description : Creates and returns an AltAlleleGroup for the given group id
...@@ -177,7 +209,7 @@ sub fetch_all_Groups_by_type { ...@@ -177,7 +209,7 @@ sub fetch_all_Groups_by_type {
=cut =cut
sub fetch_Group_by_id { sub fetch_by_dbID {
my $self = shift; my $self = shift;
my $group_id = shift; my $group_id = shift;
...@@ -225,10 +257,33 @@ sub fetch_Group_by_id { ...@@ -225,10 +257,33 @@ sub fetch_Group_by_id {
return; return;
} }
=head2 fetch_Group_by_Gene_dbID
Arg[1] : Integer Gene ID of the member to query by
Description : DEPRECATED. Please use fetch_by_gene_id
Returntype : Bio::EnsEMBL::AltAlleleGroup
=cut
sub fetch_Group_by_Gene_dbID { sub fetch_Group_by_Gene_dbID {
my $self = shift; my ($self, $gene_id) = @_;
my $gene_id = shift; deprecate('Please use fetch_by_gene_id()');
return $self->fetch_by_gene_id($gene_id);
}
=head2 fetch_by_gene_id
Arg[1] : Integer Gene ID of the member to query by
Description : Creates and returns an AltAlleleGroup which contains
the specified gene member
Returntype : Bio::EnsEMBL::AltAlleleGroup
=cut
sub fetch_by_gene_id {
my ($self, $gene_id) = @_;
my $gene_id_sql = q( my $gene_id_sql = q(
SELECT alt_allele_group_id FROM alt_allele SELECT alt_allele_group_id FROM alt_allele
WHERE gene_id = ? WHERE gene_id = ?
...@@ -242,14 +297,14 @@ sub fetch_Group_by_Gene_dbID { ...@@ -242,14 +297,14 @@ sub fetch_Group_by_Gene_dbID {
$sth->fetch; $sth->fetch;
$sth->finish; $sth->finish;
if (!$@ && $group_id) { if (!$@ && $group_id) {
return $self->fetch_Group_by_id($group_id); return $self->fetch_by_dbID($group_id);
} }
return; return;
} }
=head2 store =head2 store
Arg[0] : Bio::EnsEMBL::AltAlleleGroup Arg[1] : Bio::EnsEMBL::AltAlleleGroup
Description: Used for persisting new groups to the database. Description: Used for persisting new groups to the database.
It updates the dbID of the object handed to it to match the It updates the dbID of the object handed to it to match the
database. database.
...@@ -373,4 +428,4 @@ sub _tables { ...@@ -373,4 +428,4 @@ sub _tables {
return (['alt_allele', 'a'], ['alt_allele_group', 'g'], ['alt_allele_attrib', 'b']); return (['alt_allele', 'a'], ['alt_allele_group', 'g'], ['alt_allele_attrib', 'b']);
} }
1; 1;
\ No newline at end of file
...@@ -86,7 +86,7 @@ ok($db, 'DB was retrieved'); ...@@ -86,7 +86,7 @@ ok($db, 'DB was retrieved');
my $aaga = $db->get_adaptor('AltAlleleGroup'); my $aaga = $db->get_adaptor('AltAlleleGroup');
# Test data consists of a single group, of type AUTOMATIC, with a reference Allele and 3 others # Test data consists of a single group, of type AUTOMATIC, with a reference Allele and 3 others
my $group_list = $aaga->fetch_all_Groups; my $group_list = $aaga->fetch_all;
my $aag = $group_list->[0]; my $aag = $group_list->[0];
is($aag->rep_Gene_id, 18256,"Check for correct selection of allele"); is($aag->rep_Gene_id, 18256,"Check for correct selection of allele");
...@@ -101,26 +101,26 @@ $gene = $gene_list->[0]; ...@@ -101,26 +101,26 @@ $gene = $gene_list->[0];
is (ref($gene),'Bio::EnsEMBL::Gene',"Returned object type from get_all_Genes"); is (ref($gene),'Bio::EnsEMBL::Gene',"Returned object type from get_all_Genes");
ok ($gene->dbID == 18256,"Ensure Gene objects acquire correct information"); ok ($gene->dbID == 18256,"Ensure Gene objects acquire correct information");
# test fetch_all_Groups_by_type # test fetch_all
$group_list = $aaga->fetch_all_Groups_by_type('UNLIKELY STRING'); $group_list = $aaga->fetch_all('UNLIKELY STRING');
ok(scalar(@{$group_list}) == 0,"Try outlandish typed group lookup"); ok(scalar(@{$group_list}) == 0,"Try outlandish typed group lookup");
$group_list = $aaga->fetch_all_Groups_by_type('HAS_CODING_POTENTIAL'); $group_list = $aaga->fetch_all('HAS_CODING_POTENTIAL');
ok(scalar(@$group_list) == 1,"Try known group type lookup"); ok(scalar(@$group_list) == 1,"Try known group type lookup");
# fetch_Group_by_id # fetch_Group_by_id
$aag = $group_list->[0]; $aag = $group_list->[0];
my $group_id = $aag->dbID; my $group_id = $aag->dbID;
my $new_aag = $aaga->fetch_Group_by_id($group_id); my $new_aag = $aaga->fetch_by_dbID($group_id);
is_deeply($aag, $new_aag, "Compare previously fetched group with group found by using the dbID"); is_deeply($aag, $new_aag, "Compare previously fetched group with group found by using the dbID");
$aag = $aaga->fetch_Group_by_id(undef); $aag = $aaga->fetch_by_dbID(undef);
ok(!defined($aag), "See what happens if no argument is given"); ok(!defined($aag), "See what happens if no argument is given");
# fetch_Group_by_Gene_dbID # fetch_Group_by_Gene_dbID
$aag = $aaga->fetch_all_Groups->[0]; $aag = $aaga->fetch_all->[0];
$new_aag = $aaga->fetch_Group_by_Gene_dbID(18257); $new_aag = $aaga->fetch_by_gene_id(18257);
is_deeply($new_aag,$aag,"Check single gene ID returns entire group correctly"); is_deeply($new_aag,$aag,"Check single gene ID returns entire group correctly");
# check store method # check store method
...@@ -128,7 +128,7 @@ my $dbID = $aaga->store($group); ...@@ -128,7 +128,7 @@ my $dbID = $aaga->store($group);
ok($dbID, 'A dbID was returned from the store method'); ok($dbID, 'A dbID was returned from the store method');
{ {
my $aag2 = $aaga->fetch_Group_by_id($dbID); my $aag2 = $aaga->fetch_by_dbID($dbID);
is_deeply($aag2->get_all_members,$group->get_all_members,"Compare stored with original"); is_deeply($aag2->get_all_members,$group->get_all_members,"Compare stored with original");
$group->add_member(4, {}); $group->add_member(4, {});
my $update_dbID = $aaga->update($group); my $update_dbID = $aaga->update($group);
...@@ -137,11 +137,11 @@ ok($dbID, 'A dbID was returned from the store method'); ...@@ -137,11 +137,11 @@ ok($dbID, 'A dbID was returned from the store method');
$group->remove_member(4); $group->remove_member(4);
$aaga->remove($group); $aaga->remove($group);
ok(! defined $aaga->fetch_Group_by_id($dbID), 'Using a deleted ID means no group returned'); ok(! defined $aaga->fetch_by_dbID($dbID), 'Using a deleted ID means no group returned');
my $new_dbID = $aaga->store($group); my $new_dbID = $aaga->store($group);
cmp_ok($new_dbID, '!=', $dbID, 'Should have been assgined a new ID'); cmp_ok($new_dbID, '!=', $dbID, 'Should have been assgined a new ID');
my $aag2 = $aaga->fetch_Group_by_id($new_dbID); my $aag2 = $aaga->fetch_by_dbID($new_dbID);
my $gene_ids = $aag2->get_all_Gene_ids(); my $gene_ids = $aag2->get_all_Gene_ids();
eq_or_diff($gene_ids,[1,2,3], "Update and re-retrieve the same AltAlleleGroup") or diag explain $gene_ids; eq_or_diff($gene_ids,[1,2,3], "Update and re-retrieve the same AltAlleleGroup") or diag explain $gene_ids;
...@@ -149,7 +149,7 @@ eq_or_diff($gene_ids,[1,2,3], "Update and re-retrieve the same AltAlleleGroup") ...@@ -149,7 +149,7 @@ eq_or_diff($gene_ids,[1,2,3], "Update and re-retrieve the same AltAlleleGroup")
# Proper test data is hard to fabricate and no samples exist. # Proper test data is hard to fabricate and no samples exist.
$aaga->db->is_multispecies(1); $aaga->db->is_multispecies(1);
$group_list = $aaga->fetch_all_Groups; $group_list = $aaga->fetch_all;
$aag = $group_list->[0]; $aag = $group_list->[0];
ok(scalar(@$group_list) == 1, "Pretend multi-species fetch returns same groups as normal."); ok(scalar(@$group_list) == 1, "Pretend multi-species fetch returns same groups as normal.");
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment