Bio-EnsEMBL
view release on metacpan or search on metacpan
lib/Bio/EnsEMBL/Map/DBSQL/DitagAdaptor.pm view on Meta::CPAN
my @ditags = @{ $ditagadaptor->fetch_by_type("ZZ11") };
=head1 DESCRIPTION
Provides database interaction for the Bio::EnsEMBL::Map::Ditag object
=head1 METHODS
=cut
package Bio::EnsEMBL::Map::DBSQL::DitagAdaptor;
$Bio::EnsEMBL::Map::DBSQL::DitagAdaptor::VERSION = '114.0.0';
use strict;
use vars ('@ISA');
use Bio::EnsEMBL::Map::Ditag;
use Bio::EnsEMBL::DBSQL::BaseAdaptor;
use Bio::EnsEMBL::Utils::Exception qw( throw warning );
@ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);
=head2 fetch_all_by_name
Arg [1] : ditag name
Example : $tag = $ditag_adaptor->fetch_by_name("U3");
Description: Retrieves ditags from the database using the name
Returntype : listref of Bio::EnsEMBL::Map::Ditag
Caller : general
=cut
sub fetch_all_by_name {
my ($self, $tagname) = @_;
if(!$tagname){
throw "must be called with a name of a ditag.";
}
my $sth = $self->prepare("SELECT d.ditag_id, d.name, d.type, d.tag_count, d.sequence
FROM ditag d
WHERE d.name = ?");
$sth->execute($tagname);
my $result = $self->_fetch($sth);
return $result;
}
=head2 fetch_by_dbID
Arg [1] : ditag type
Example : @all_tags = @{$ditag_adaptor->fetch_by_dbID(1003)};
Description: Retrieve ditags with a certain id from the database
Returntype : Bio::EnsEMBL::Map::Ditag
Caller : general
=cut
sub fetch_by_dbID {
my ($self, $tagid) = @_;
if(!$tagid){
throw "must be called with the type of a ditag.";
}
my $sth = $self->prepare("SELECT d.ditag_id, d.name, d.type, d.tag_count, d.sequence
FROM ditag d
WHERE d.ditag_id = ?");
$sth->execute($tagid);
my $result = $self->_fetch($sth);
return $result->[0];
}
=head2 fetch_all_by_type
Arg [1] : ditag type
Example : @all_tags = @{$ditag_adaptor->fetch_by_type("SME005")};
Description: Retrieves all ditags of a certain type from the database
Returntype : listref of Bio::EnsEMBL::Map::Ditag
Caller : general
=cut
sub fetch_all_by_type {
my ($self, $tagtype) = @_;
if(!$tagtype){
throw "must be called with the type of a ditag.";
}
my $sth = $self->prepare("SELECT d.ditag_id, d.name, d.type, d.tag_count, d.sequence
FROM ditag d
WHERE d.type = ?");
$sth->execute($tagtype);
my $result = $self->_fetch($sth);
return $result;
}
=head2 fetch_by_name_and_type
Arg [1] : ditag name
Arg [2] : ditag type
Example : $tag = $ditag_adaptor->fetch_by_name_and_type("U3", "SME005");
Description: Retrieves ditags from the database using name/type combination
which should be non-ambiguous
Returntype : Bio::EnsEMBL::Map::Ditag
Caller : general
=cut
sub fetch_by_name_and_type {
my ($self, $tagname, $tagtype) = @_;
if(!$tagname or !$tagtype){
throw "must be called with a name and type of a ditag.";
}
my $sth = $self->prepare("SELECT d.ditag_id, d.name, d.type, d.tag_count, d.sequence
FROM ditag d
WHERE d.name = ? and d.type = ?");
$sth->execute($tagname, $tagtype);
my $result = $self->_fetch($sth);
return $result->[0];
}
( run in 2.240 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )