TFBS::DB::TRANSFAC - interface to database of TRANSFAC public
position frequency matrices at TESS (
http://www.cbil.upenn.edu/tess)
-------------------------------- NOTICE ----------------------------------
The TRANSFAC database is free for non-commercial use. For commercial use
the TRANSFAC databases and programs have to be licensed. Please read
the DISCLAIMER at http://transfac.gbf.de/TRANSFAC/disclaimer.htm.
-------------------------------------------------------------------------
* creating a database object by connecting to TRANSFAC data
my $db = TFBS::DB::TRANSFAC->connect();
* retrieving a TFBS::Matrix::* object from the database
# retrieving a PFM by ID
my $pfm = $db->get_Matrix_by_ID('V$CEBPA_01','PFM');
#retrieving a PWM by TRANSFAC accession number
my $pwm = $db->get_Matrix_by_acc('M00116', 'PWM');
sub _get_Matrix_by_URL
{ my ($self, $url, $mt) = @_;
my $HTMLpage = get $url || return undef;
my (@As, @Cs, @Gs, @Ts, $name, $ID, $acc);
my @lines = split "\n", $HTMLpage;
foreach my $line (@lines) {
$line =~ s/\r//;
$line =~ s/<\/{0,1}b>//gi;
$line =~ s/ //gi;
if ($line =~ /Name<\/td><td>([^<]+)</) {
$name = $1;
}
elsif ($line =~ /ID<\/td><td>([^<]+)</) {
$ID = $1;
}
elsif ($line =~ /AccNo\/Logo<\/td><td>([^<]+)</) {
$acc = $1;
}
elsif ($line =~ /\d+\.\d+\s+(\d+\.\d+)\s+(\d+\.{0,1}\d*)\s+(\d+\.{0,1}\d*)\s+(\d+\.{0,1}\d*)\s+(\d+\.{0,1}\d*)/) {
my ($nr, $A, $C, $G, $T) = ($1,$2,$3,$4,$5); push @As,$A; push @Cs,$C; push @Gs,$G; push @Ts,$T;
}
}
return undef unless @As;
my $pfm = TFBS::Matrix::PFM-> new ( -ID => $ID,
-name => $name,
-tags => {acc=>$acc},
-matrix => [\@ As,\@ Cs,\@ Gs,\@ Ts]
);
if (!defined($mt) or uc($mt) eq "PFM") {return $pfm;}
elsif (uc($mt) eq "ICM") {return $pfm->to_ICM;}
elsif (uc($mt) eq "PWM") {return $pfm->to_PWM;}
else { $self->throw("Unrecognized matrix format: $mt"); }
}
1; } |
sub connect
{ my ($caller, %args) = @_;
my $self = bless {}, ref $caller || $caller;
unless (defined ($args{-accept_conditions}) and $args{-accept_conditions}) {
print STDERR <<ENDNOTICE -------------------------------- NOTICE ----------------------------------
The TRANSFAC database is free for non-commercial use. For commercial use
the TRANSFAC databases and programs have to be licensed. Please read
the DISCLAIMER at http://transfac.gbf.de/TRANSFAC/disclaimer.htm.
-----------
If you have read the disclaimer and accept the conditions stated therein,
you can suppres this notice by connecting to TRANSFAC like this:
my\$ db = TFBS::DB::TRANSFAC->connect(-accept_conditions => 1);
--------------------------------------------------------------------------
ENDNOTICE
;
}
if (defined $args{'-proxy'}) {
$ua->proxy('http',$args{'-proxy'});
}
return $self; } |
sub get_Matrix_by_ID
{ my ($self, $ID, $mt) = @_;
unless (defined $ID) {
$self->throw("No parameters passed to get_Matrix_by_ID.");
}
my $url = "http://www.cbil.upenn.edu/cgi-bin/tess/tess33?request=MTX-DBRTRV-Id&key=$ID";
return $self->_get_Matrix_by_URL($url, $mt); } |
sub get_Matrix_by_acc
{ my ($self, $acc, $mt) = @_;
unless (defined $acc) {
$self->throw("No parameters passed to get_Matrix_by_ID.");
}
my $url = "http://www.cbil.upenn.edu/cgi-bin/tess/tess33?request=MTX-DBRTRV-Accno&key=$acc";
return $self->_get_Matrix_by_URL($url, $mt); } |