Treefam
GeneHandle
Summary
Package variables
No package variables defined.
Included modules
Carp
Scalar::Util qw ( weaken )
Synopsis
use Treefam::DBConnection;
my $dbc = new Treefam::DBConnection ();
my $gene_handle = $dbc->get_GeneHandle();
my $gene = $gene_handle->get_by_id('ENSG00000087586');
Description
Enables retrieval of Treefam::Gene objects.
Methods
Methods description
Arg1: string, pfam id of domain
Arg2: (optional) e-value cut-off
Description: Gets all genes with the given domain with e-value
below given cut-off (default is 1e-2).
Returntype: list of Treefam::Gene objects |
Arg: Treefam::Family
Description: Gets genes belonging to the given family
Returntype: list of Treefam::Gene objects |
Arg: string
Description: Gets genes with names matching given string
Returntype: list of Treefam::Gene objects |
Arg1: string, species name
Arg2: optional, Treefam::Family object
Description: Gets all genes of given species present in the
family if one is given, otherwise returns all
genes of the requested species found in Treefam
Returntype: list of Treefam::Gene objects |
Arg: gene ID
Description: Gets gene with given ID
Returntype: Treefam::Gene object |
Arg: sequence/transcript ID
Description: Gets gene with given ID
Returntype: Treefam::Gene object |
Arg: gene symbol
Description: Gets gene with given symbol
Returntype: Treefam::Gene object |
Arg: Treefam::DBConnection
Description: Creates a new gene object handle
Returntype: Treefam::GeneHandle |
Methods code
sub get_all_by_domain
{
my $self = shift;
my $pfamid = shift;
unless ($pfamid) {
croak "Pfam domain id required";
}
my $cutoff = shift if @_;
if (!$cutoff) {
$cutoff = 1e-2;
}
my @genes;
my $dbc = $self->{'DBConnection'};
my $dbh = $dbc->{'database_handle'};
my $query = qq(SELECT DISTINCT ID FROM pfam WHERE PFAM_ID=? AND EVALUE<=$cutoff);
my $sth = $dbh->prepare($query);
$sth->execute($pfamid);
while (my ($geneID)=$sth->fetchrow_array()) {
push (@genes,$self->get_by_sequence_id($geneID));
}
$sth->finish();
return @genes;} |
sub get_all_by_family
{
my ($self,$family) = @_;
my $dbc = $self->{'DBConnection'};
my $dbh = $dbc->{'database_handle'};
my $familyID = $family->ID;
my $type = $family->type eq 'familyA'? 'famA_gene' : 'famB_gene';
my $sth = $dbh->prepare("SELECT DISTINCT g.GID FROM genes g, $type t
WHERE t.AC= ? AND t.ID=g.ID");
$sth->execute($familyID);
my @genes=();
while (my ($g)=$sth->fetchrow_array()) {
push (@genes,$self->get_by_id($g));
}
$sth->finish();
return @genes;} |
sub get_all_by_name
{
my ($self,$name) = @_;
my $dbc = $self->{'DBConnection'};
my $dbh = $dbc->{'database_handle'};
my $sth = $dbh->prepare("SELECT DISTINCT g.GID FROM genes g WHERE g.desc LIKE '%$name%' ");
$sth->execute();
my @genes=();
while (my ($g)=$sth->fetchrow_array()) {
push (@genes,$self->get_by_id($g));
}
$sth->finish();
return @genes;} |
sub get_all_by_species
{
my ($self,$species,$family) = @_;
my $dbc = $self->{'DBConnection'};
my $dbh = $dbc->{'database_handle'};
my $sth;
if ($family) {
my $familyID = ref($family)? $family->ID : $family;
my $type = $family->type eq 'familyA'? 'famA_gene' : 'famB_gene';
$sth = $dbh->prepare("SELECT DISTINCT g.GID
FROM genes g, species s, $type t
WHERE g.tax_id = s.tax_id
AND (s.taxname = ? OR s.swcode = ?)
AND g.id = t.id
AND t.ac = ?");
$sth->execute($species,$species,$familyID);
}
else {
$sth = $dbh->prepare("SELECT DISTINCT g.GID
FROM genes g, species s
WHERE g.tax_id = s.tax_id
AND (s.taxname = ? OR s.swcode = ?)");
$sth->execute($species,$species);
}
my @genes=();
while (my ($g)=$sth->fetchrow_array()) {
push (@genes,$self->get_by_id($g));
}
$sth->finish();
return @genes;} |
sub get_by_id
{
my ($self,$geneID) = @_;
my $dbc = $self->{'DBConnection'};
my $dbh = $dbc->{'database_handle'};
my $query = qq( SELECT COUNT(*) FROM genes WHERE GID= ? );
my $sth= $dbh->prepare ($query);
$sth->execute($geneID);
my ($count) = $sth->fetchrow_array();
unless ($count) {
return undef;
}
return new Treefam::Gene($dbc,$geneID);} |
sub get_by_sequence_id
{
my ($self,$ID) = @_;
my $dbc = $self->{'DBConnection'};
my $dbh = $dbc->{'database_handle'};
my $query = qq( SELECT GID FROM genes WHERE ID= ? OR TID= ?);
my $sth= $dbh->prepare ($query);
$sth->execute($ID,$ID);
my ($geneID) = $sth->fetchrow_array();
return undef if (!defined($geneID));
return new Treefam::Gene($dbc,$geneID);} |
sub get_by_symbol
{
my ($self,$symbol) = @_;
my $dbc = $self->{'DBConnection'};
my $dbh = $dbc->{'database_handle'};
my $sth = $dbh->prepare("SELECT DISTINCT GID FROM genes
WHERE symbol=?");
$sth->execute($symbol);
my ($geneID) = $sth->fetchrow_array();
$sth->finish();
return undef if ( !defined $geneID );
return $self->get_by_id($geneID);} |
sub new
{
my $class = shift;
my $self = {};
$self->{'DBConnection'} = shift;
weaken($self->{'DBConnection'});
bless ($self, $class);
return $self;} |
General documentation