1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#!/usr/bin/env perl -w
use TFBS::Matrix::PFM;
use TFBS::DB::JASPAR2;
use Test;
plan(tests => 2);
my @dbparams;
if (-e 't/MYSQLCONNECT') {
open FILE, 't/MYSQLCONNECT';
my $line = <FILE>;
@dbparams = split "::", $line;
close FILE;
$skip = 0;
}
else {
print "ok # Skip (MySQL server not set up)\n"x2;
exit(0);
}
# set up a matrix
my $matrixstring =
"12 3 0 0 4 0\n0 0 0 11 7 0\n0 9 12 0 0 0\n0 0 0 1 1 12";
my $pfm = TFBS::Matrix::PFM->new(-matrix=>$matrixstring, -ID=>"TEST001");
my $rawstring1 = $pfm->rawprint();
my $db;
# write/read test
$db = TFBS::DB::JASPAR2->create
("dbi:mysql:JASPAR2TEST:$dbparams[0]",$dbparams[1], $dbparams[2]);
$db->store_Matrix($pfm);
my $pfm2= $db->get_Matrix_by_ID("TEST001", "PFM");
my $rawstring2 = $pfm2->rawprint;
ok ($rawstring1, $rawstring2);
# delete test
$db->delete_Matrix_having_ID('TEST001');
my $nopfm = $db->get_Matrix_by_ID("TEST001", "PFM");
ok(undef, $nopfm);
END {
$db &&
$db->dbh &&
$db->dbh->do("drop database if exists JASPAR2TEST");
}
|