Treefam
FamilyHandle
Summary
Package variables
No package variables defined.
Included modules
Carp
Scalar::Util qw ( weaken )
Synopsis
use Treefam::DBConnection;
my $dbc = new Treefam::DBConnection ();
my $famh = $dbc->get_FamilyHandle();
my $family = $famh->get_by_id('TF300011');
Description
Enables retrieval of Treefam family objects.
Methods
Methods description
Arg1: string, pfam id of domain
Arg2: (optional) e-value cut-off
Description: Gets all families that have genes with the
given domain with e-value below given cut-off
(default is 1e-2).
Returntype: list of Treefam::Family objects |
Arg1: string, species (Swissprot code or latin name)
Arg2: optional, string, type of families (A or B)
Description: Gets all families that have genes of the
given species
Returntype: list of Treefam::Family objects |
Arg: string, type of families: A or B
Description: Gets all families of given type
Returntype: list of Treefam::Family objects |
Arg: Treefam family database ID
Description: A synonym for get_by_id. Gets family with given
Treefam database ID
Returntype: Treefam::Family object |
Arg: Treefam::Gene object
Description: Gets family containing given gene.
Returntype: Treefam::Family object |
Arg: Treefam family database ID
Description: Gets family with given Treefam database ID
Returntype: Treefam::Family object |
Arg: family symbol
Description: Gets family with given symbol.
Only curated families have symbols.
Returntype: Treefam::Family object |
Arg: Treefam::DBConnection
Description: Creates a new family object handle
Returntype: Treefam::FamilyHandle |
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 @families;
my $dbc = $self->{'DBConnection'};
my $dbh = $dbc->{'database_handle'};
my $query = qq(SELECT DISTINCT t1.AC FROM famA_gene t1, pfam p
WHERE t1.ID = p.ID
AND p.PFAM_ID = ?
UNION
SELECT DISTINCT t2.AC FROM famB_gene t2, pfam p
WHERE t2.ID = p.ID
AND p.PFAM_ID = ?);
my $sth = $dbh->prepare($query);
$sth->execute($pfamid,$pfamid);
while (my ($familyID)=$sth->fetchrow_array()) {
push (@families,$self->get_by_id($familyID));
}
$sth->finish();
return @families;} |
sub get_all_by_species
{
my ($self,$species,$type) = @_;
my $dbc = $self->{'DBConnection'};
my $dbh = $dbc->{'database_handle'};
my $query;
if ($type) {
$type = ($type eq 'A') ? 'famA_gene' : 'famB_gene';
$query = qq( SELECT DISTINCT t.AC FROM $type t, genes g, species s
WHERE t.ID = g.ID
AND g.TAX_ID = s.TAX_ID
AND (s.SWCODE = ? OR s. TAXNAME = ?));
}
else {
$query = qq( SELECT DISTINCT t1.AC FROM famA_gene t1, genes g, species s
WHERE t1.ID = g.ID
AND g.TAX_ID = s.TAX_ID
AND (s.SWCODE = ? OR s. TAXNAME = ?)
UNION
SELECT DISTINCT t2.AC FROM famB_gene t2, genes g, species s WHERE t2.ID = g.ID AND g.TAX_ID = s.TAX_ID AND (s.SWCODE = ? OR s. TAXNAME = ?)); } my $sth = $dbh->prepare($query); $sth->execute($species,$species,$species,$species); my @families; while ( my ($familyID) = $sth->fetchrow_array()) { push @families,$self->get_by_id($familyID); } $sth->finish(); return @families;
} |
sub get_all_by_type
{
my ($self,$type) = @_;
my $dbc = $self->{'DBConnection'};
my $dbh = $dbc->{'database_handle'};
$type = ($type eq 'A') ? 'familyA' : 'familyB';
my $query = qq( SELECT DISTINCT AC FROM $type );
my $sth = $dbh->prepare($query);
$sth->execute();
my @families;
while ( my ($familyID) = $sth->fetchrow_array()) {
push @families,$self->get_by_id($familyID);
}
$sth->finish();
return @families;} |
sub get_by_ac
{
my ($self,$familyID) = @_;
return $self->get_by_id($familyID); } |
sub get_by_gene
{
my ($self,$gene) = @_;
my $geneID = ref($gene) ? $gene->ID() : $gene;
my $dbc = $self->{'DBConnection'};
my $dbh = $dbc->{'database_handle'};
foreach my $type('famB_gene','famA_gene') {
my $query = qq( SELECT AC FROM $type t LEFT JOIN genes g ON t.ID=g.ID
WHERE g.GID= ? );
my $sth = $dbh->prepare($query);
$sth->execute($geneID);
my ($familyID) = $sth->fetchrow_array();
$sth->finish();
return $self->get_by_id($familyID) if ($familyID);
}
return undef;} |
sub get_by_id
{
my ($self,$familyID) = @_;
my $dbc = $self->{'DBConnection'};
my $dbh = $dbc->{'database_handle'};
my $type = $familyID=~/^TF1/ ? 'familyA' : 'familyB';
my $query = qq{ SELECT COUNT(*) FROM $type WHERE AC= ? };
my $sth= $dbh->prepare ($query);
$sth->execute($familyID);
my ($count) = $sth->fetchrow_array();
unless ($count) {
return undef;
}
return new Treefam::Family($dbc,$familyID,$type);
}
1;} |
sub get_by_symbol
{
my ($self,$symbol) = @_;
my $dbc = $self->{'DBConnection'};
my $dbh = $dbc->{'database_handle'};
my $sth = $dbh->prepare("SELECT AC FROM familyA
WHERE symbol=?");
$sth->execute($symbol);
my ($familyID) = $sth->fetchrow_array();
$sth->finish();
return undef if( !defined $familyID );
return $self->get_by_id($familyID);} |
sub new
{
my $class = shift;
my $self = {};
$self->{'DBConnection'} = shift;
weaken($self->{'DBConnection'});
bless ($self, $class);
return $self;} |
General documentation